use of com.oracle.truffle.llvm.parser.nodes.LLVMRuntimeDebugInformation.SimpleLocalVariable 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));
}
}
Aggregations