[llvm] Handle #dbg_values in SROA. (PR #94070)

Stephen Tozer via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 18 03:27:55 PDT 2024


================
@@ -5045,10 +5045,20 @@ static void insertNewDbgInst(DIBuilder &DIB, DbgVariableRecord *Orig,
                                                    BeforeInst->getIterator());
     return;
   }
+
+  if (Orig->isDbgValue()) {
+    DbgVariableRecord *DVR = DbgVariableRecord::createDbgVariableRecord(
+        NewAddr, Orig->getVariable(), NewFragmentExpr, Orig->getDebugLoc());
+    BeforeInst->getParent()->insertDbgRecordBefore(DVR,
+                                                   BeforeInst->getIterator());
----------------
SLTozer wrote:

Just a note for the future based on a point @jmorse raised to me offline - if we have a dbg.value that pointed at the whole alloca being split, then it should be deleted here (but could be saved by implicit_pointer in theory), but if a dbg.value was pointing at one of the split fragments of the alloca, it can still have a valid address after this. I think that's something to implement in another patch rather than adding to this one, though.

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


More information about the llvm-commits mailing list