Search in sources :

Example 1 with ClearLocalVariableParts

use of com.oracle.truffle.llvm.parser.nodes.LLVMRuntimeDebugInformation.ClearLocalVariableParts in project graal by oracle.

the class LLVMBitcodeInstructionVisitor method handleDebugIntrinsic.

private void handleDebugIntrinsic(SymbolImpl value, SourceVariable variable, MDExpression expression, long index, boolean isDeclaration) {
    if (index != 0) {
        // this is unsupported, it doesn't appear in LLVM 3.8+
        return;
    }
    int valueFrameSlot = -1;
    Object valueObject = null;
    if (value instanceof UndefinedConstant) {
        valueObject = symbols.resolve(new NullConstant(MetaType.DEBUG));
    } else if (value instanceof AbstractConstant) {
        valueObject = symbols.resolve(value);
    } else if (value instanceof GlobalValueSymbol) {
        valueObject = symbols.resolve(value);
    } else if (value instanceof SSAValue) {
        valueFrameSlot = symbols.findOrAddFrameSlot((SSAValue) value);
    } else {
        return;
    }
    if (valueObject == null && valueFrameSlot == -1) {
        return;
    }
    int partIndex = -1;
    int[] clearParts = null;
    if (ValueFragment.describesFragment(expression)) {
        ValueFragment fragment = ValueFragment.parse(expression);
        List<ValueFragment> siblings = variable.getFragments();
        List<Integer> clearSiblings = new ArrayList<>(siblings.size());
        partIndex = ValueFragment.getPartIndex(fragment, siblings, clearSiblings);
        if (!clearSiblings.isEmpty()) {
            clearParts = clearSiblings.stream().mapToInt(Integer::intValue).toArray();
        }
    }
    if (partIndex < 0 && variable.hasFragments()) {
        partIndex = variable.getFragmentIndex(0, (int) variable.getSymbol().getType().getSize());
        if (partIndex < 0) {
            throw new LLVMParserException("Cannot find index of value fragment!");
        }
        clearParts = new int[variable.getFragments().size() - 1];
        for (int i = 0; i < partIndex; i++) {
            clearParts[i] = i;
        }
        for (int i = partIndex; i < clearParts.length; i++) {
            clearParts[i] = i + 1;
        }
    }
    boolean mustDereference = isDeclaration || mustDereferenceValue(expression, variable.getSourceType(), value);
    if (clearParts != null && clearParts.length != 0) {
        debugInfo.add(new ClearLocalVariableParts(instructionNodes.size(), variable.getSymbol(), clearParts));
    }
    if (partIndex < 0 && clearParts == null) {
        debugInfo.add(new SimpleLocalVariable(instructionNodes.size(), mustDereference, valueObject, valueFrameSlot, variable.getSymbol()));
    } else if (partIndex >= 0) {
        debugInfo.add(new SetLocalVariablePart(instructionNodes.size(), mustDereference, valueObject, valueFrameSlot, variable.getSymbol(), partIndex));
    }
}
Also used : UndefinedConstant(com.oracle.truffle.llvm.parser.model.symbols.constants.UndefinedConstant) ArrayList(java.util.ArrayList) NullConstant(com.oracle.truffle.llvm.parser.model.symbols.constants.NullConstant) SSAValue(com.oracle.truffle.llvm.runtime.types.symbols.SSAValue) SetLocalVariablePart(com.oracle.truffle.llvm.parser.nodes.LLVMRuntimeDebugInformation.SetLocalVariablePart) SimpleLocalVariable(com.oracle.truffle.llvm.parser.nodes.LLVMRuntimeDebugInformation.SimpleLocalVariable) GlobalValueSymbol(com.oracle.truffle.llvm.parser.model.symbols.globals.GlobalValueSymbol) AbstractConstant(com.oracle.truffle.llvm.parser.model.symbols.constants.AbstractConstant) ClearLocalVariableParts(com.oracle.truffle.llvm.parser.nodes.LLVMRuntimeDebugInformation.ClearLocalVariableParts) ValueFragment(com.oracle.truffle.llvm.parser.metadata.debuginfo.ValueFragment) LLVMParserException(com.oracle.truffle.llvm.runtime.except.LLVMParserException)

Aggregations

ValueFragment (com.oracle.truffle.llvm.parser.metadata.debuginfo.ValueFragment)1 AbstractConstant (com.oracle.truffle.llvm.parser.model.symbols.constants.AbstractConstant)1 NullConstant (com.oracle.truffle.llvm.parser.model.symbols.constants.NullConstant)1 UndefinedConstant (com.oracle.truffle.llvm.parser.model.symbols.constants.UndefinedConstant)1 GlobalValueSymbol (com.oracle.truffle.llvm.parser.model.symbols.globals.GlobalValueSymbol)1 ClearLocalVariableParts (com.oracle.truffle.llvm.parser.nodes.LLVMRuntimeDebugInformation.ClearLocalVariableParts)1 SetLocalVariablePart (com.oracle.truffle.llvm.parser.nodes.LLVMRuntimeDebugInformation.SetLocalVariablePart)1 SimpleLocalVariable (com.oracle.truffle.llvm.parser.nodes.LLVMRuntimeDebugInformation.SimpleLocalVariable)1 LLVMParserException (com.oracle.truffle.llvm.runtime.except.LLVMParserException)1 SSAValue (com.oracle.truffle.llvm.runtime.types.symbols.SSAValue)1 ArrayList (java.util.ArrayList)1