Skip to content

Commit 8f7b51e

Browse files
committed
[CodeGen] Make __clang_call_terminate have an unwind table entry
This enables unwinders to step past that frame on architectures that don't use DWARF unwinding (such as armv7), e.g. when debugging. The problem should theoretically be architecture-agnostic, but according to https://discourse.llvm.org/t/51633/2 it gets masked on architectures that use DWARF unwind info. Fixes #40696 Reviewed By: efriedma, rnk Differential Revision: https://reviews.llvm.org/D151393
1 parent 023504f commit 8f7b51e

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

clang/lib/CodeGen/ItaniumCXXABI.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4689,6 +4689,7 @@ static llvm::FunctionCallee getClangCallTerminateFn(CodeGenModule &CGM) {
46894689
cast<llvm::Function>(fnRef.getCallee()->stripPointerCasts());
46904690
if (fn->empty()) {
46914691
CGM.SetLLVMFunctionAttributes(GlobalDecl(), FI, fn, /*IsThunk=*/false);
4692+
CGM.SetLLVMFunctionAttributesForDefinition(nullptr, fn);
46924693
fn->setDoesNotThrow();
46934694
fn->setDoesNotReturn();
46944695

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// RUN: %clang_cc1 -triple=x86_64-linux-gnu -fexceptions -fcxx-exceptions -emit-llvm -o - %s | \
2+
// RUN: FileCheck --check-prefixes=CHECK,NOUNWIND %s
3+
// RUN: %clang_cc1 -triple=x86_64-linux-gnu -fexceptions -fcxx-exceptions -funwind-tables=1 -emit-llvm -o - %s | \
4+
// RUN: FileCheck --check-prefixes=CHECK,SYNCUNWIND %s
5+
// RUN: %clang_cc1 -triple=x86_64-linux-gnu -fexceptions -fcxx-exceptions -funwind-tables=2 -emit-llvm -o - %s | \
6+
// RUN: FileCheck --check-prefixes=CHECK,ASYNCUNWIND %s
7+
8+
void caller(void callback()) noexcept { callback(); }
9+
10+
// CHECK: define {{.*}}void @__clang_call_terminate({{[^)]*}}) #[[#ATTRNUM:]]
11+
// CHECK: attributes #[[#ATTRNUM]] = {
12+
// NOUNWIND-NOT: uwtable
13+
// NOUNWIND-SAME: }
14+
// SYNCUNWIND-SAME: uwtable(sync)
15+
// ASYNCUNWIND-SAME: uwtable{{ }}

0 commit comments

Comments
 (0)