aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen
diff options
context:
space:
mode:
authorJeremy Morse <jeremy.morse@sony.com>2025-07-14 11:28:07 +0100
committerGitHub <noreply@github.com>2025-07-14 11:28:07 +0100
commit65d20bb0ab27f1b0078cc8811d02f7b47eb779bf (patch)
tree00a71095b30e43e23ebcc1f32e82349655d21141 /clang/lib/CodeGen
parent34bb38ffbf12539bd403794ac2f7c29e50094d5f (diff)
downloadllvm-65d20bb0ab27f1b0078cc8811d02f7b47eb779bf.zip
llvm-65d20bb0ab27f1b0078cc8811d02f7b47eb779bf.tar.gz
llvm-65d20bb0ab27f1b0078cc8811d02f7b47eb779bf.tar.bz2
[KeyInstr] Disable key-instructions for coroutine scopes (#147551)
At this time (immediately prior to llvm21 branching) we haven't instrumented coroutine generation to identify the "key" instructions of things like co_return and similar. This will lead to worse stepping behaviours, as there won't be any key instruction for those lines. This patch removes the key-instructions flag from the DISubprograms for coroutines, which will cause AsmPrinter to use the "old" / existing linetable stepping behaviour, avoiding a regression until we can instrument these constructs. (I'm going to post on discourse about whether this is a good idea or not in a moment)
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r--clang/lib/CodeGen/CGDebugInfo.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index 8bf7d24..5240853 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -4629,6 +4629,7 @@ void CGDebugInfo::emitFunctionStart(GlobalDecl GD, SourceLocation Loc,
llvm::DIFile *Unit = getOrCreateFile(Loc);
llvm::DIScope *FDContext = Unit;
llvm::DINodeArray TParamsArray;
+ bool KeyInstructions = CGM.getCodeGenOpts().DebugKeyInstructions;
if (!HasDecl) {
// Use llvm function name.
LinkageName = Fn->getName();
@@ -4645,6 +4646,9 @@ void CGDebugInfo::emitFunctionStart(GlobalDecl GD, SourceLocation Loc,
}
collectFunctionDeclProps(GD, Unit, Name, LinkageName, FDContext,
TParamsArray, Flags);
+ // Disable KIs if this is a coroutine.
+ KeyInstructions =
+ KeyInstructions && !isa_and_present<CoroutineBodyStmt>(FD->getBody());
} else if (const auto *OMD = dyn_cast<ObjCMethodDecl>(D)) {
Name = getObjCMethodName(OMD);
Flags |= llvm::DINode::FlagPrototyped;
@@ -4706,7 +4710,7 @@ void CGDebugInfo::emitFunctionStart(GlobalDecl GD, SourceLocation Loc,
llvm::DISubprogram *SP = DBuilder.createFunction(
FDContext, Name, LinkageName, Unit, LineNo, DIFnType, ScopeLine,
FlagsForDef, SPFlagsForDef, TParamsArray.get(), Decl, nullptr,
- Annotations, "", CGM.getCodeGenOpts().DebugKeyInstructions);
+ Annotations, "", KeyInstructions);
Fn->setSubprogram(SP);
// We might get here with a VarDecl in the case we're generating