Skip to content

Commit a198078

Browse files
author
git apple-llvm automerger
committed
Merge commit 'c568a207d8ba' from llvm.org/release/21.x into stable/21.x
2 parents 627ec09 + c568a20 commit a198078

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

clang/lib/CodeGen/CGDebugInfo.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,10 @@ void CGDebugInfo::addInstToSpecificSourceAtom(llvm::Instruction *KeyInstruction,
176176
if (!Group || !CGM.getCodeGenOpts().DebugKeyInstructions)
177177
return;
178178

179+
llvm::DISubprogram *SP = KeyInstruction->getFunction()->getSubprogram();
180+
if (!SP || !SP->getKeyInstructionsEnabled())
181+
return;
182+
179183
addInstSourceAtomMetadata(KeyInstruction, Group, /*Rank=*/1);
180184

181185
llvm::Instruction *BackupI =

llvm/lib/IR/Verifier.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3262,12 +3262,6 @@ void Verifier::visitFunction(const Function &F) {
32623262
CheckDI(SP->describes(&F),
32633263
"!dbg attachment points at wrong subprogram for function", N, &F,
32643264
&I, DL, Scope, SP);
3265-
3266-
if (DL->getAtomGroup())
3267-
CheckDI(DL->getScope()->getSubprogram()->getKeyInstructionsEnabled(),
3268-
"DbgLoc uses atomGroup but DISubprogram doesn't have Key "
3269-
"Instructions enabled",
3270-
DL, DL->getScope()->getSubprogram());
32713265
};
32723266
for (auto &BB : F)
32733267
for (auto &I : BB) {
@@ -5596,6 +5590,15 @@ void Verifier::visitInstruction(Instruction &I) {
55965590
if (MDNode *N = I.getDebugLoc().getAsMDNode()) {
55975591
CheckDI(isa<DILocation>(N), "invalid !dbg metadata attachment", &I, N);
55985592
visitMDNode(*N, AreDebugLocsAllowed::Yes);
5593+
5594+
if (auto *DL = dyn_cast<DILocation>(N)) {
5595+
if (DL->getAtomGroup()) {
5596+
CheckDI(DL->getScope()->getSubprogram()->getKeyInstructionsEnabled(),
5597+
"DbgLoc uses atomGroup but DISubprogram doesn't have Key "
5598+
"Instructions enabled",
5599+
DL, DL->getScope()->getSubprogram());
5600+
}
5601+
}
55995602
}
56005603

56015604
if (auto *DII = dyn_cast<DbgVariableIntrinsic>(&I)) {

llvm/test/DebugInfo/KeyInstructions/Generic/verify.ll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
define dso_local void @f() !dbg !10 {
99
entry:
10+
; Include non-key location to check verifier is checking the whole function.
11+
%0 = add i32 0, 0, !dbg !14
1012
ret void, !dbg !13
1113
}
1214

@@ -20,3 +22,4 @@ entry:
2022
!11 = !DISubroutineType(types: !12)
2123
!12 = !{null}
2224
!13 = !DILocation(line: 1, column: 11, scope: !10, atomGroup: 1, atomRank: 1)
25+
!14 = !DILocation(line: 1, column: 11, scope: !10)

0 commit comments

Comments
 (0)