[llvm] [CodeExtractor] Improve debug info for input values. (PR #136016)

Michael Kruse via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 23 03:20:59 PDT 2025


================
@@ -1270,14 +1278,48 @@ static void fixupDebugInfoPostExtraction(Function &OldFunc, Function &NewFunc,
       /*LineNo=*/0, SPType, /*ScopeLine=*/0, DINode::FlagZero, SPFlags);
   NewFunc.setSubprogram(NewSP);
 
+  auto UpdateOrInsertDebugRecord = [&](auto *DR, Value *OldLoc, Value *NewLoc,
+                                       DIExpression *Expr, bool Declare) {
+    if (DR->getParent()->getParent() == &NewFunc)
+      DR->replaceVariableLocationOp(OldLoc, NewLoc);
+    else {
+      if (Declare)
+        DIB.insertDeclare(NewLoc, DR->getVariable(), Expr, DR->getDebugLoc(),
+                          &NewFunc.getEntryBlock());
+      else
----------------
Meinersbur wrote:

```suggestion
      if (Declare) {
        DIB.insertDeclare(NewLoc, DR->getVariable(), Expr, DR->getDebugLoc(),
                          &NewFunc.getEntryBlock());
        return;
      }
```
[llvm.org/docs/CodingStandards.html#use-early-exits-and-continue-to-simplify-code](https://llvm.org/docs/CodingStandards.html#use-early-exits-and-continue-to-simplify-code)

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


More information about the llvm-commits mailing list