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

Stephen Tozer via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 4 05:59:31 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:

In this case, we're transferring the dbg_record from an alloca to an alloca, so there's no need to change the expression. I believe popping the DW_OP_deref is handled in mem2reg, which will be invoked by SROA later on.

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


More information about the llvm-commits mailing list