[clang-tools-extra] [clang][CodeGen] The `eh_typeid_for` intrinsic needs special care too (PR #65699)

Alex Voicu via cfe-commits cfe-commits at lists.llvm.org
Sun Sep 10 06:40:25 PDT 2023


================
@@ -1149,7 +1149,10 @@ 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);
+    llvm::Type *argTy = llvm_eh_typeid_for->getArg(0)->getType();
+    // With opaque ptrs, only the address space can be a mismatch.
+    if (typeValue->getType() != argTy)
+      typeValue = CGF.Builder.CreateAddrSpaceCast(typeValue, argTy);
----------------
AlexVlx wrote:

We can, I've only used the builder for symmetry (everything else uses direct emission) and convenience (we already have the LLVM types handy). I'll switch it over to the hook, and hoist the intrinsic arg type retrieval since it doesn't need to be in the loop.

https://github.com/llvm/llvm-project/pull/65699


More information about the cfe-commits mailing list