Skip to content

Commit bf1d422

Browse files
authored
[KeyInstr][Clang] Catch variable init atom (#134641)
This patch is part of a stack that teaches Clang to generate Key Instructions metadata for C and C++. RFC: https://discourse.llvm.org/t/rfc-improving-is-stmt-placement-for-better-interactive-debugging/82668 The feature is only functional in LLVM if LLVM is built with CMake flag LLVM_EXPERIMENTAL_KEY_INSTRUCTIONs. Eventually that flag will be removed.
1 parent 059885c commit bf1d422

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

clang/lib/CodeGen/ItaniumCXXABI.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5055,7 +5055,11 @@ void ItaniumCXXABI::emitBeginCatch(CodeGenFunction &CGF,
50555055

50565056
// Emit the local.
50575057
CodeGenFunction::AutoVarEmission var = CGF.EmitAutoVarAlloca(*CatchParam);
5058-
InitCatchParam(CGF, *CatchParam, var.getObjectAddress(CGF), S->getBeginLoc());
5058+
{
5059+
ApplyAtomGroup Grp(CGF.getDebugInfo());
5060+
InitCatchParam(CGF, *CatchParam, var.getObjectAddress(CGF),
5061+
S->getBeginLoc());
5062+
}
50595063
CGF.EmitAutoVarCleanups(var);
50605064
}
50615065

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// RUN: %clang_cc1 -triple x86_64-linux-gnu -gkey-instructions %s -debug-info-kind=line-tables-only -emit-llvm -o - -fexceptions -fcxx-exceptions \
2+
// RUN: | FileCheck %s
3+
4+
void except() {
5+
// FIXME(OCH): Should `store i32 32, ptr %exception` be key?
6+
throw 32;
7+
}
8+
9+
void attempt() {
10+
try { except(); }
11+
// CHECK: catch:
12+
// CHECK: %4 = call ptr @__cxa_begin_catch(ptr %exn)
13+
// CHECK: %5 = load i32{{.*}}, !dbg [[G1R2:!.*]]
14+
// CHECK: store i32 %5, ptr %e{{.*}}, !dbg [[G1R1:!.*]]
15+
// CHECK: call void @__cxa_end_catch()
16+
catch (int e) { }
17+
}
18+
19+
// CHECK: [[G1R2]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 2)
20+
// CHECK: [[G1R1]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1)

0 commit comments

Comments
 (0)