Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion clang/lib/CodeGen/ItaniumCXXABI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5055,7 +5055,11 @@ void ItaniumCXXABI::emitBeginCatch(CodeGenFunction &CGF,

// Emit the local.
CodeGenFunction::AutoVarEmission var = CGF.EmitAutoVarAlloca(*CatchParam);
InitCatchParam(CGF, *CatchParam, var.getObjectAddress(CGF), S->getBeginLoc());
{
ApplyAtomGroup Grp(CGF.getDebugInfo());
InitCatchParam(CGF, *CatchParam, var.getObjectAddress(CGF),
S->getBeginLoc());
}
CGF.EmitAutoVarCleanups(var);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Risk that a destructor for the catch-parameter could be given this instruction group?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes if a few things were different and wrong. 1. Calls aren't annotated. 2. If they were, it would be a bug if whatever call handling code didn't have its own ApplyAtomGroup for the dtor.

I could add a scope around ApplyAtomGroup and InitCatchParam, and/or add more tests, if you think it would be useful?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm -- yes please for the braces, no worries about the tests. This is just about reducing the amount of potentially-unexpected behaviour

}

Expand Down
20 changes: 20 additions & 0 deletions clang/test/DebugInfo/KeyInstructions/try-catch.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// RUN: %clang_cc1 -triple x86_64-linux-gnu -gkey-instructions %s -debug-info-kind=line-tables-only -emit-llvm -o - -fexceptions -fcxx-exceptions \
// RUN: | FileCheck %s

void except() {
// FIXME(OCH): Should `store i32 32, ptr %exception` be key?
throw 32;
}

void attempt() {
try { except(); }
// CHECK: catch:
// CHECK: %4 = call ptr @__cxa_begin_catch(ptr %exn)
// CHECK: %5 = load i32{{.*}}, !dbg [[G1R2:!.*]]
// CHECK: store i32 %5, ptr %e{{.*}}, !dbg [[G1R1:!.*]]
// CHECK: call void @__cxa_end_catch()
catch (int e) { }
}

// CHECK: [[G1R2]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 2)
// CHECK: [[G1R1]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1)
Loading