diff options
author | Nikita Popov <npopov@redhat.com> | 2025-04-04 21:34:45 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-04-04 15:34:45 +0200 |
commit | ecd4c0857b69e2c3f592d805bafde8e9f6a19005 (patch) | |
tree | 60f3a074cf68a0f5a72cf9995d8609fa352c499d /llvm/lib/IR/Verifier.cpp | |
parent | fd6260f13bfecfb13537e184f4e8365cf35492fd (diff) | |
download | llvm-ecd4c0857b69e2c3f592d805bafde8e9f6a19005.zip llvm-ecd4c0857b69e2c3f592d805bafde8e9f6a19005.tar.gz llvm-ecd4c0857b69e2c3f592d805bafde8e9f6a19005.tar.bz2 |
[Verifier] Require that dbg.declare variable is a ptr (#134355)
As far as I understand, the first operand of dbg_declare should be a
pointer (inside a metadata wrapper). However, using a non-pointer is
currently not rejected, and we have some tests that use non-pointer
types. As far as I can tell, these tests either meant to use dbg_value
or are just incorrect hand-crafted tests.
Ran into this while trying to `fix` #134008.
Diffstat (limited to 'llvm/lib/IR/Verifier.cpp')
-rw-r--r-- | llvm/lib/IR/Verifier.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index 7c6cd41..7423e74 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -6666,10 +6666,14 @@ 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)) { visitDIArgList(*AL, F); + } CheckDI(isa_and_nonnull<DILocalVariable>(DVR.getRawVariable()), "invalid #dbg record variable", &DVR, DVR.getRawVariable()); |