[clang] [PAC][clang] Implement address/type discrimination for VTT vtable pointers (PR #205808)

Oliver Hunt via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 10 17:48:50 PDT 2026


================
@@ -2221,13 +2222,19 @@ llvm::Value *ItaniumCXXABI::getVTableAddressPointInStructorWithVTT(
       CGF.Builder.CreateAlignedLoad(CGF.GlobalsVoidPtrTy, VTT,
                                     CGF.getPointerAlign());
 
-  if (auto &Schema = CGF.CGM.getCodeGenOpts().PointerAuth.CXXVTTVTablePointers) {
-    CGPointerAuthInfo PointerAuth = CGF.EmitPointerAuthInfo(Schema, VTT,
-                                                            GlobalDecl(),
-                                                            QualType());
+  if (auto &Schema = CGM.getCodeGenOpts().PointerAuth.CXXVTTVTablePointers) {
+    llvm::ConstantInt *TypeDesc = nullptr;
+    if (Schema.getOtherDiscrimination() ==
+        PointerAuthSchema::Discrimination::Type)
+      TypeDesc = llvm::ConstantInt::get(
+          CGM.IntPtrTy,
+          CGM.getContext().getPointerAuthVTablePointerDiscriminator(
----------------
ojhunt wrote:

*part of the reason I'm pushing so hard here is that this code is not currently handling the case where the vtable signing schema is overridden, which is generally an ABI constraint.

Now this runs into a "is this practically relevant?" the arm64e ABI is frozen: we can't make a change like this. For ABIs that are not frozen the ABI constraint simply isn't relevant - as long as they're always signed this way there's no problem that would require the ABI manipulation, so maybe it's fine to ignore that?

I'm somewhat on the fence at this point, and the only _strong_ complaint is the shared discriminator between vtt entries and the vtable pointer.

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


More information about the cfe-commits mailing list