Skip to content

Commit 638b319

Browse files
committed
[KeyInstr][Clang] Catch variable init atom
This patch is part of a stack that teaches Clang to generate Key Instructions metadata for C and C++. The Key Instructions project is introduced, including a "quick summary" section at the top which adds context for this PR, here: 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. The Clang-side work is demoed here: #130943
1 parent c25359b commit 638b319

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

clang/lib/CodeGen/ItaniumCXXABI.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5051,6 +5051,7 @@ void ItaniumCXXABI::emitBeginCatch(CodeGenFunction &CGF,
50515051

50525052
// Emit the local.
50535053
CodeGenFunction::AutoVarEmission var = CGF.EmitAutoVarAlloca(*CatchParam);
5054+
ApplyAtomGroup Grp(CGF.getDebugInfo());
50545055
InitCatchParam(CGF, *CatchParam, var.getObjectAddress(CGF), S->getBeginLoc());
50555056
CGF.EmitAutoVarCleanups(var);
50565057
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// RUN: %clang -gkey-instructions %s -gmlt -S -emit-llvm -o - -fexceptions \
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)