[llvm] [Verifier] Require that dbg.declare variable is a ptr (PR #134355)

Orlando Cazalet-Hyams via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 4 02:29:39 PDT 2025


================
@@ -55,8 +55,9 @@ end:                                        ; preds = %body
 
 define i64 @simulateWithDbgDeclare(<2 x i32> %a) local_unnamed_addr  {
 entry:
+  %ptr = alloca i32
   %rand = tail call i64 @lrand48() #3
-  tail call void @llvm.dbg.declare(metadata i64 %rand, metadata !6, metadata !7), !dbg !8
+  tail call void @llvm.dbg.declare(metadata ptr %ptr, metadata !6, metadata !7), !dbg !8
----------------
OCHyams wrote:

I think this slightly changes the tested behaviour, because the new dbg.declare will get put in the MF side-table:

https://godbolt.org/z/bh6oEM55G

The old dbg.declare causes a DBG_INSTR_REF, whereas the new on gets stuffed into `stack:`. I think this may be the case in a couple of other tests too. If you make `%ptr` an argument instead of a local alloca it looks like a `DBG_VALUE` is generated.

Since the test isn't checking for the debug instruction in the output, maybe it doesn't matter, but I'd personally err on the side of minimising the change in output. YMMV.

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


More information about the llvm-commits mailing list