Skip to content

Commit 846ee2e

Browse files
committed
[MLIR][LLVMIR] Fix emission of debug intrinsics
1 parent 96af14b commit 846ee2e

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

mlir/lib/Target/LLVMIR/ModuleImport.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2634,6 +2634,11 @@ ModuleImport::processDebugIntrinsic(llvm::DbgVariableIntrinsic *dbgIntr,
26342634
}
26352635
}
26362636
builder.setInsertionPointAfterValue(*argOperand);
2637+
auto insertionPoint = builder.getInsertionPoint();
2638+
Operation &insertionPointOp = *insertionPoint;
2639+
if (insertionPoint.isValid() && isa<LLVM::LandingpadOp>(&insertionPointOp)) {
2640+
builder.setInsertionPointAfter(&insertionPointOp);
2641+
}
26372642
}
26382643
auto locationExprAttr =
26392644
debugImporter->translateExpression(dbgIntr->getExpression());
@@ -2695,6 +2700,15 @@ ModuleImport::processDebugIntrinsic(llvm::DbgVariableIntrinsic *dbgIntr,
26952700
auto addressExprAttr =
26962701
debugImporter->translateExpression(addressExprNode);
26972702

2703+
if (argOperand->getParentBlock() != addressOperand->getParentBlock()) {
2704+
return (Operation *)nullptr;
2705+
}
2706+
2707+
auto *addressOp = addressOperand->getDefiningOp();
2708+
if (addressOp && domInfo.dominates(*argOperand, addressOp)) {
2709+
builder.setInsertionPointAfter(addressOp);
2710+
}
2711+
26982712
return builder
26992713
.create<LLVM::DbgAssignOp>(loc, *argOperand, localVariableAttr,
27002714
locationExprAttr, assignIdAttr,

0 commit comments

Comments
 (0)