diff options
author | Orlando Cazalet-Hyams <orlando.hyams@sony.com> | 2025-07-16 10:43:09 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-07-16 10:43:09 +0100 |
commit | 653872f782e1faaabc1da23769e6b35b10e74bde (patch) | |
tree | aef270a85250499c2ccb6337adf671d9e3697cb9 /llvm/lib/IR/Verifier.cpp | |
parent | 60579ec3059b2b6cc9dad90eaac1ed363fc395a7 (diff) | |
download | llvm-653872f782e1faaabc1da23769e6b35b10e74bde.zip llvm-653872f782e1faaabc1da23769e6b35b10e74bde.tar.gz llvm-653872f782e1faaabc1da23769e6b35b10e74bde.tar.bz2 |
[KeyInstr] Fix verifier check (#149043)
The verifier check was in the wrong place, meaning it wasn't actually
checking many instructions.
Fixing that causes a test failure (coro-dwarf-key-instrs.cpp) because
coros turn off the feature but still annotate instructions with the
metadata (which is a supported situation, but the verifier doesn't like
it, and it's hard to teach the verifier to like it).
Fix that by avoiding emitting any key instruction metadata if the
DISubprogram has opted out of key instructions.
Diffstat (limited to 'llvm/lib/IR/Verifier.cpp')
-rw-r--r-- | llvm/lib/IR/Verifier.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index dc5373e..4868845 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -3185,12 +3185,6 @@ void Verifier::visitFunction(const Function &F) { CheckDI(SP->describes(&F), "!dbg attachment points at wrong subprogram for function", N, &F, &I, DL, Scope, SP); - - if (DL->getAtomGroup()) - CheckDI(DL->getScope()->getSubprogram()->getKeyInstructionsEnabled(), - "DbgLoc uses atomGroup but DISubprogram doesn't have Key " - "Instructions enabled", - DL, DL->getScope()->getSubprogram()); }; for (auto &BB : F) for (auto &I : BB) { @@ -5492,6 +5486,15 @@ void Verifier::visitInstruction(Instruction &I) { if (MDNode *N = I.getDebugLoc().getAsMDNode()) { CheckDI(isa<DILocation>(N), "invalid !dbg metadata attachment", &I, N); visitMDNode(*N, AreDebugLocsAllowed::Yes); + + if (auto *DL = dyn_cast<DILocation>(N)) { + if (DL->getAtomGroup()) { + CheckDI(DL->getScope()->getSubprogram()->getKeyInstructionsEnabled(), + "DbgLoc uses atomGroup but DISubprogram doesn't have Key " + "Instructions enabled", + DL, DL->getScope()->getSubprogram()); + } + } } if (auto *DII = dyn_cast<DbgVariableIntrinsic>(&I)) { |