diff options
author | Alex Voicu <alexandru.voicu@amd.com> | 2023-09-20 17:12:19 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-20 17:12:19 +0100 |
commit | de018f5ca4b2598f6bbf7a27a1fb51935792c276 (patch) | |
tree | b6ec77ad923c0527198a318af61b649f4b680ea2 /clang/lib/CodeGen/CGException.cpp | |
parent | 0de0b6dded4752040350feb9c81415d82478d065 (diff) | |
download | llvm-de018f5ca4b2598f6bbf7a27a1fb51935792c276.zip llvm-de018f5ca4b2598f6bbf7a27a1fb51935792c276.tar.gz llvm-de018f5ca4b2598f6bbf7a27a1fb51935792c276.tar.bz2 |
[clang][CodeGen] The `eh_typeid_for` intrinsic needs special care too (#65699)
This change is symmetric with the one reviewed in
<https://reviews.llvm.org/D157452> and handles the exception handling
specific intrinsic, which slipped through the cracks, in the same way,
by inserting an address-space cast iff RTTI is in a non-default AS.
Diffstat (limited to 'clang/lib/CodeGen/CGException.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGException.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGException.cpp b/clang/lib/CodeGen/CGException.cpp index 3996f29..87594f7 100644 --- a/clang/lib/CodeGen/CGException.cpp +++ b/clang/lib/CodeGen/CGException.cpp @@ -1136,6 +1136,8 @@ static void emitCatchDispatchBlock(CodeGenFunction &CGF, // Select the right handler. llvm::Function *llvm_eh_typeid_for = CGF.CGM.getIntrinsic(llvm::Intrinsic::eh_typeid_for); + llvm::Type *argTy = llvm_eh_typeid_for->getArg(0)->getType(); + LangAS globAS = CGF.CGM.GetGlobalVarAddressSpace(nullptr); // Load the selector value. llvm::Value *selector = CGF.getSelectorFromSlot(); @@ -1149,7 +1151,11 @@ static void emitCatchDispatchBlock(CodeGenFunction &CGF, assert(handler.Type.Flags == 0 && "landingpads do not support catch handler flags"); assert(typeValue && "fell into catch-all case!"); - typeValue = CGF.Builder.CreateBitCast(typeValue, CGF.Int8PtrTy); + // With opaque ptrs, only the address space can be a mismatch. + if (typeValue->getType() != argTy) + typeValue = + CGF.getTargetHooks().performAddrSpaceCast(CGF, typeValue, globAS, + LangAS::Default, argTy); // Figure out the next block. bool nextIsEnd; |