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

Stephen Tozer via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 4 02:52:07 PDT 2025


================
@@ -6666,9 +6666,12 @@ void Verifier::visit(DbgVariableRecord &DVR) {
   CheckDI(MD && (isa<ValueAsMetadata>(MD) || isa<DIArgList>(MD) ||
                  (isa<MDNode>(MD) && !cast<MDNode>(MD)->getNumOperands())),
           "invalid #dbg record address/value", &DVR, MD);
-  if (auto *VAM = dyn_cast<ValueAsMetadata>(MD))
+  if (auto *VAM = dyn_cast<ValueAsMetadata>(MD)) {
     visitValueAsMetadata(*VAM, F);
-  else if (auto *AL = dyn_cast<DIArgList>(MD))
+    if (DVR.isDbgDeclare())
+      CheckDI(VAM->getValue()->getType()->isPointerTy(),
+              "location of #dbg_declare must be a pointer", &DVR, MD);
+  } else if (auto *AL = dyn_cast<DIArgList>(MD))
----------------
SLTozer wrote:

Nit, since the if now uses braces the "else if" should as well.

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


More information about the llvm-commits mailing list