Skip to content

Commit d680e97

Browse files
committed
[MLIR][LLVMIR] Fix emission of debug intrinsics
1 parent 1d89942 commit d680e97

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

mlir/lib/Target/LLVMIR/ModuleImport.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3146,8 +3146,12 @@ ModuleImport::processDebugIntrinsic(llvm::DbgVariableIntrinsic *dbgIntr,
31463146
isa<LandingpadOp>(insertionBlock->front()))
31473147
insertPt = cast<LandingpadOp>(insertionBlock->front()).getRes();
31483148
}
3149-
3150-
builder.setInsertionPointAfterValue(insertPt);
3149+
builder.setInsertionPointAfterValue(*argOperand);
3150+
auto insertionPoint = builder.getInsertionPoint();
3151+
Operation &insertionPointOp = *insertionPoint;
3152+
if (insertionPoint.isValid() && isa<LLVM::LandingpadOp>(&insertionPointOp)) {
3153+
builder.setInsertionPointAfter(&insertionPointOp);
3154+
}
31513155
}
31523156
auto locationExprAttr =
31533157
debugImporter->translateExpression(dbgIntr->getExpression());
@@ -3209,6 +3213,15 @@ ModuleImport::processDebugIntrinsic(llvm::DbgVariableIntrinsic *dbgIntr,
32093213
auto addressExprAttr =
32103214
debugImporter->translateExpression(addressExprNode);
32113215

3216+
if (argOperand->getParentBlock() != addressOperand->getParentBlock()) {
3217+
return (Operation *)nullptr;
3218+
}
3219+
3220+
auto *addressOp = addressOperand->getDefiningOp();
3221+
if (addressOp && domInfo.dominates(*argOperand, addressOp)) {
3222+
builder.setInsertionPointAfter(addressOp);
3223+
}
3224+
32123225
return builder
32133226
.create<LLVM::DbgAssignOp>(loc, *argOperand, localVariableAttr,
32143227
locationExprAttr, assignIdAttr,

0 commit comments

Comments
 (0)