[clang] f385abf - [Clang][CodeGen] Follow-up for `vtable`, `typeinfo` et al. are globals
Alex Voicu via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 19 15:57:57 PDT 2023
Author: Alex Voicu
Date: 2023-07-19T23:57:12+01:00
New Revision: f385abf131e01b12b14ac3bc7214eb119b40523e
URL: https://github.com/llvm/llvm-project/commit/f385abf131e01b12b14ac3bc7214eb119b40523e
DIFF: https://github.com/llvm/llvm-project/commit/f385abf131e01b12b14ac3bc7214eb119b40523e.diff
LOG: [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
Added:
clang/test/CodeGenCXX/throw-expression-typeinfo-in-address-space.cpp
Modified:
clang/lib/CodeGen/ItaniumCXXABI.cpp
Removed:
################################################################################
diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp b/clang/lib/CodeGen/ItaniumCXXABI.cpp
index 16e53c466424ab..8870383f8d663c 100644
--- a/clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -1252,7 +1252,7 @@ static llvm::FunctionCallee getThrowFn(CodeGenModule &CGM) {
// void __cxa_throw(void *thrown_exception, std::type_info *tinfo,
// void (*dest) (void *));
- llvm::Type *Args[3] = { CGM.Int8PtrTy, CGM.Int8PtrTy, CGM.Int8PtrTy };
+ llvm::Type *Args[3] = { CGM.Int8PtrTy, CGM.GlobalsInt8PtrTy, CGM.Int8PtrTy };
llvm::FunctionType *FTy =
llvm::FunctionType::get(CGM.VoidTy, Args, /*isVarArg=*/false);
diff --git a/clang/test/CodeGenCXX/throw-expression-typeinfo-in-address-space.cpp b/clang/test/CodeGenCXX/throw-expression-typeinfo-in-address-space.cpp
new file mode 100644
index 00000000000000..d8c23d427e67a3
--- /dev/null
+++ b/clang/test/CodeGenCXX/throw-expression-typeinfo-in-address-space.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 %s -triple amdgcn-amd-amdhsa -emit-llvm -fcxx-exceptions -fexceptions -std=c++11 -o - | FileCheck %s
+
+struct X {
+ ~X();
+};
+
+struct Error {
+ Error(const X&) noexcept;
+};
+
+void f() {
+ try {
+ throw Error(X());
+ } catch (...) { }
+}
+
+// CHECK: declare void @__cxa_throw(ptr, ptr addrspace(1), ptr)
More information about the cfe-commits
mailing list