[clang] [clang] Implement type/address discrimination of type_info vtable. (PR #99726)

Daniil Kovalev via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 31 00:18:17 PDT 2024


kovdan01 wrote:

@ahmedbougacha It looks like there is some missing codegen logic. Particularly, in `ItaniumRTTIBuilder::BuildVTablePointer` (clang/lib/CodeGen/ItaniumCXXABI.cpp), there is the following piece of code:

```
  if (auto &Schema = CGM.getCodeGenOpts().PointerAuth.CXXTypeInfoVTablePointer)
    VTable = CGM.getConstantSignedPointer(VTable, Schema, nullptr, GlobalDecl(),
                                          QualType(Ty, 0));
```

Here, `nullptr` is used as `StorageAddress` unconditionally, so, address discrimination is not actually enabled even if requested. It caused test-suite failures in several EH-related tests.

I was able to fix that locally by just using a dummy `ptr inttoptr (i64 1 to ptr)` value as `StorageAddress` (just like you did with coroutines and as I did with init/fini, see https://github.com/llvm/llvm-project/pull/96478#issuecomment-2196819332), and tests became passing. I'm not sure how to get a proper `StorageAddress` here, so I've used that dummy placeholder which actually seems to do the job.

Do you have some logic for this locally that you've not upstreamed yet? If yes, could you please open a PR adding that? If no, I'm happy to submit a PR with a fix described above by myself.

Also tagging @asl

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


More information about the cfe-commits mailing list