[Mlir-commits] [mlir] [MLIR][LLVM] Fix debug value/declare import in face of landing pads (PR #132871)

Tobias Gysi llvmlistbot at llvm.org
Tue Mar 25 00:00:42 PDT 2025


================
@@ -2512,7 +2512,22 @@ ModuleImport::processDebugIntrinsic(llvm::DbgVariableIntrinsic *dbgIntr,
     Block *dominatedBlock = (*dominatedBlocks.begin())->getBlock();
     builder.setInsertionPoint(dominatedBlock->getTerminator());
   } else {
-    builder.setInsertionPointAfterValue(*argOperand);
+    Value insertPt = *argOperand;
+    if (!op) {
+      // The value might be coming from a phi value and is now a block argument,
+      // which means the insertion point is set to the start of the block. If
+      // this block is a target destination of an invoke, the insertion point
+      // must happen after the landing pad operation.
+      auto blockArg = llvm::cast<BlockArgument>(*argOperand);
+      mlir::Block *insertionBlock = blockArg.getOwner();
----------------
gysit wrote:

```suggestion
      auto blockArg = cast<BlockArgument>(*argOperand);
      Block *insertionBlock = blockArg.getOwner();
```
nit:

https://github.com/llvm/llvm-project/pull/132871


More information about the Mlir-commits mailing list