Skip to content

Commit f385abf

Browse files
committed
[Clang][CodeGen] Follow-up for vtable, typeinfo et al. are globals
https://reviews.llvm.org/rG8acdcf4016876d122733991561be706b64026e73 didn't include handling for the fact that `throw`'s implementation takes a pointer to a type's `typeinfo` struct, which implies that its signature needs to change as well. This corrects that and adds a test. Reviewed By: rjmccall Differential Revision: https://reviews.llvm.org/D155759
1 parent be9f55f commit f385abf

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

clang/lib/CodeGen/ItaniumCXXABI.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1252,7 +1252,7 @@ static llvm::FunctionCallee getThrowFn(CodeGenModule &CGM) {
12521252
// void __cxa_throw(void *thrown_exception, std::type_info *tinfo,
12531253
// void (*dest) (void *));
12541254

1255-
llvm::Type *Args[3] = { CGM.Int8PtrTy, CGM.Int8PtrTy, CGM.Int8PtrTy };
1255+
llvm::Type *Args[3] = { CGM.Int8PtrTy, CGM.GlobalsInt8PtrTy, CGM.Int8PtrTy };
12561256
llvm::FunctionType *FTy =
12571257
llvm::FunctionType::get(CGM.VoidTy, Args, /*isVarArg=*/false);
12581258

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// RUN: %clang_cc1 %s -triple amdgcn-amd-amdhsa -emit-llvm -fcxx-exceptions -fexceptions -std=c++11 -o - | FileCheck %s
2+
3+
struct X {
4+
~X();
5+
};
6+
7+
struct Error {
8+
Error(const X&) noexcept;
9+
};
10+
11+
void f() {
12+
try {
13+
throw Error(X());
14+
} catch (...) { }
15+
}
16+
17+
// CHECK: declare void @__cxa_throw(ptr, ptr addrspace(1), ptr)

0 commit comments

Comments
 (0)