use of com.oracle.truffle.llvm.runtime.debug.scope.LLVMSourceLocation in project sulong by graalvm.
the class LLVMBasicBlockNode method fillStackTrace.
private void fillStackTrace(SulongStackTrace stackTrace, int errorIndex) {
final LLVMSourceLocation loc = getLastAvailableSourceLocation(errorIndex);
final LLVMFunctionStartNode f = NodeUtil.findParent(this, LLVMFunctionStartNode.class);
stackTrace.addStackTraceElement(f.getOriginalName(), loc, f.getName(), f.getBcSource().getName(), blockName());
}
use of com.oracle.truffle.llvm.runtime.debug.scope.LLVMSourceLocation in project sulong by graalvm.
the class LLVMPrintStackTrace method fillStackTrace.
private static void fillStackTrace(SulongStackTrace stackTrace, Node node) {
LLVMBasicBlockNode block = NodeUtil.findParent(node, LLVMBasicBlockNode.class);
LLVMFunctionStartNode f = NodeUtil.findParent(node, LLVMFunctionStartNode.class);
if (block == null || f == null) {
LLVMIntrinsicExpressionNode intrinsic = NodeUtil.findParent(node, LLVMIntrinsicExpressionNode.class);
if (intrinsic != null) {
stackTrace.addStackTraceElement(intrinsic.toString(), null, null);
}
return;
}
LLVMSourceLocation location = null;
if (node instanceof LLVMNode && ((LLVMNode) node).getSourceLocation() != null) {
location = ((LLVMNode) node).getSourceLocation();
}
if (location == null) {
location = block.getSourceLocation();
}
if (location != null) {
stackTrace.addStackTraceElement(f.getOriginalName(), location, f.getBcName(), f.getBcSource().getName(), blockName(block));
return;
}
SourceSection s = node.getSourceSection();
if (s == null) {
s = f.getSourceSection();
}
if (s == null) {
stackTrace.addStackTraceElement(f.getBcName(), f.getBcSource().getName(), blockName(block));
} else {
location = LLVMSourceLocation.createUnknown(s);
stackTrace.addStackTraceElement(f.getOriginalName(), location, f.getBcName(), f.getBcSource().getName(), blockName(block));
}
}
use of com.oracle.truffle.llvm.runtime.debug.scope.LLVMSourceLocation in project sulong by graalvm.
the class DIScopeBuilder method buildLocation.
LLVMSourceLocation buildLocation(MDBaseNode md) {
if (globalCache.containsKey(md)) {
return globalCache.get(md);
} else if (localCache.containsKey(md)) {
return localCache.get(md);
}
final Builder builder = new Builder();
md.accept(builder);
final LLVMSourceLocation location = builder.build();
if (isLocalScope(location)) {
localCache.put(md, location);
} else {
globalCache.put(md, location);
}
return location;
}
use of com.oracle.truffle.llvm.runtime.debug.scope.LLVMSourceLocation in project sulong by graalvm.
the class DITypeExtractor method visit.
@Override
public void visit(MDBasicType mdType) {
final String name = MDNameExtractor.getName(mdType.getName());
final long size = mdType.getSize();
final long align = mdType.getAlign();
final long offset = mdType.getOffset();
LLVMSourceBasicType.Kind kind;
switch(mdType.getEncoding()) {
case DW_ATE_ADDRESS:
kind = LLVMSourceBasicType.Kind.ADDRESS;
break;
case DW_ATE_BOOLEAN:
kind = LLVMSourceBasicType.Kind.BOOLEAN;
break;
case DW_ATE_FLOAT:
kind = LLVMSourceBasicType.Kind.FLOATING;
break;
case DW_ATE_SIGNED:
kind = LLVMSourceBasicType.Kind.SIGNED;
break;
case DW_ATE_SIGNED_CHAR:
kind = LLVMSourceBasicType.Kind.SIGNED_CHAR;
break;
case DW_ATE_UNSIGNED:
kind = LLVMSourceBasicType.Kind.UNSIGNED;
break;
case DW_ATE_UNSIGNED_CHAR:
kind = LLVMSourceBasicType.Kind.UNSIGNED_CHAR;
break;
default:
kind = LLVMSourceBasicType.Kind.UNKNOWN;
break;
}
final LLVMSourceLocation location = scopeBuilder.buildLocation(mdType);
final LLVMSourceType type = new LLVMSourceBasicType(name, size, align, offset, kind, location);
parsedTypes.put(mdType, type);
}
use of com.oracle.truffle.llvm.runtime.debug.scope.LLVMSourceLocation in project sulong by graalvm.
the class LLVMBitcodeInstructionVisitor method visit.
@Override
public void visit(InvokeInstruction call) {
final Type targetType = call.getType();
int argumentCount = getArgumentCount(call.getArgumentCount(), targetType);
final LLVMExpressionNode[] argNodes = new LLVMExpressionNode[argumentCount];
final Type[] argTypes = new Type[argumentCount];
int argIndex = 0;
argNodes[argIndex] = nodeFactory.createFrameRead(runtime, PointerType.VOID, getStackSlot());
argTypes[argIndex] = new PointerType(null);
argIndex++;
if (targetType instanceof StructureType) {
argTypes[argIndex] = new PointerType(targetType);
argNodes[argIndex] = nodeFactory.createAlloca(runtime, targetType);
argIndex++;
}
for (int i = 0; argIndex < argumentCount; i++, argIndex++) {
argNodes[argIndex] = symbols.resolve(call.getArgument(i));
argTypes[argIndex] = call.getArgument(i).getType();
final AttributesGroup paramAttr = call.getParameterAttributesGroup(i);
if (isByValue(paramAttr)) {
argNodes[argIndex] = capsuleAddressByValue(argNodes[argIndex], argTypes[argIndex], paramAttr);
}
}
final SymbolImpl target = call.getCallTarget();
int regularIndex = call.normalSuccessor().getBlockIndex();
int unwindIndex = call.unwindSuccessor().getBlockIndex();
List<FrameSlot> normalTo = new ArrayList<>();
List<FrameSlot> unwindTo = new ArrayList<>();
List<Type> normalType = new ArrayList<>();
List<Type> unwindType = new ArrayList<>();
List<LLVMExpressionNode> normalValue = new ArrayList<>();
List<LLVMExpressionNode> unwindValue = new ArrayList<>();
if (blockPhis != null) {
for (Phi phi : blockPhis) {
FrameSlot slot = getSlot(phi.getPhiValue().getName());
LLVMExpressionNode value = symbols.resolve(phi.getValue());
if (call.normalSuccessor() == phi.getBlock()) {
normalTo.add(slot);
normalType.add(phi.getValue().getType());
normalValue.add(value);
} else {
unwindTo.add(slot);
unwindType.add(phi.getValue().getType());
unwindValue.add(value);
}
}
}
LLVMExpressionNode normalPhi = nodeFactory.createPhi(runtime, normalValue.toArray(new LLVMExpressionNode[normalValue.size()]), normalTo.toArray(new FrameSlot[normalTo.size()]), normalType.toArray(Type.EMPTY_ARRAY));
LLVMExpressionNode unwindPhi = nodeFactory.createPhi(runtime, unwindValue.toArray(new LLVMExpressionNode[unwindValue.size()]), unwindTo.toArray(new FrameSlot[unwindTo.size()]), unwindType.toArray(Type.EMPTY_ARRAY));
final LLVMSourceLocation source = sourceFunction.getSourceLocation(call);
LLVMExpressionNode function = nodeFactory.createLLVMBuiltin(runtime, target, argNodes, argCount, null);
if (function == null) {
function = symbols.resolve(target);
}
LLVMControlFlowNode result = nodeFactory.createFunctionInvoke(runtime, getSlot(call.getName()), function, argNodes, new FunctionType(targetType, argTypes, false), regularIndex, unwindIndex, normalPhi, unwindPhi, source);
setControlFlowNode(result);
}
Aggregations