-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Clang][CodeGen]
__dynamic_cast
should care about type_info
's add…
…ress space `__dynamic_cast` relies on `type_info`, which its signature assumed to be in the generic / default address space. This patch corrects the oversight (we know that `type_info` resides in the GlobalVar address space) and adds an associated test. Reviewed By: yaxunl Differential Revision: https://reviews.llvm.org/D155870
- Loading branch information
Showing
2 changed files
with
28 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// RUN: %clang_cc1 -I%S %s -triple amdgcn-amd-amdhsa -emit-llvm -fcxx-exceptions -fexceptions -o - | FileCheck %s | ||
struct A { virtual void f(); }; | ||
struct B : A { }; | ||
|
||
// CHECK: {{define.*@_Z1fP1A}} | ||
// CHECK-SAME: personality ptr @__gxx_personality_v0 | ||
B fail; | ||
const B& f(A *a) { | ||
try { | ||
// CHECK: call ptr @__dynamic_cast | ||
// CHECK: br i1 | ||
// CHECK: invoke void @__cxa_bad_cast() [[NR:#[0-9]+]] | ||
dynamic_cast<const B&>(*a); | ||
} catch (...) { | ||
// CHECK: landingpad { ptr, i32 } | ||
// CHECK-NEXT: catch ptr null | ||
} | ||
return fail; | ||
} | ||
|
||
// CHECK: declare ptr @__dynamic_cast(ptr, ptr addrspace(1), ptr addrspace(1), i64) [[NUW_RO:#[0-9]+]] | ||
|
||
// CHECK: attributes [[NUW_RO]] = { nounwind memory(read) } | ||
// CHECK: attributes [[NR]] = { noreturn } |