[PATCH] D23715: Add @llvm.dbg.value entries for the phi node created by -mem2reg

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 22 11:03:53 PDT 2016


dblaikie added a comment.

I'll leave final sign-off to Adrian, who's worked with the value/variable tracking stuff in more depth more recently than I have.


================
Comment at: lib/Transforms/Utils/Local.cpp:1069
@@ +1068,3 @@
+    DbgValueInst *DVI = dyn_cast<DbgValueInst>(&I);
+    if (!DVI)
+      return false;
----------------
Might even just roll the DVI test into the single return expression:

  return DVI && DVI->getValue() == APN && ... ;


================
Comment at: test/Transforms/Util/mem2reg-dbg.ll:36-37
@@ +35,4 @@
+  %1 = load i32, i32* %c, align 4, !dbg !24
+; CHECK: %c.0 = phi i32 [ 12, %if.then ], [ 1, %entry ]
+; CHECK-NEXT: call void @llvm.dbg.value(metadata i32 %c.0, i64 0, metadata !15, metadata !13), !dbg !16
+  ret i32 %1, !dbg !25
----------------
LLVM registers don't necessarily have names in non-Asserts builds, so it's best to phrase the test so it doesn't use register names (c.0, if.then, entry, etc).

  [[PHI:%.*]] = phi i32 [ 12, {{.*}} ], [ 1, {{.*}} ]
  call.void @llvm.dbg.value(metadata i32 [[PHI]], ...

(in some cases register names still appear in Asserts builds, but these are mostly just oversight/things we haven't consistently removed)


https://reviews.llvm.org/D23715





More information about the llvm-commits mailing list