[clang] [llvm] [PAC] Fix address discrimination for type info vtable pointers (PR #102199)
Eli Friedman via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 30 13:04:39 PDT 2024
================
@@ -4207,16 +4214,31 @@ llvm::Constant *ItaniumRTTIBuilder::BuildTypeInfo(
break;
}
- llvm::Constant *Init = llvm::ConstantStruct::getAnon(Fields);
-
SmallString<256> Name;
llvm::raw_svector_ostream Out(Name);
CGM.getCXXABI().getMangleContext().mangleCXXRTTI(Ty, Out);
llvm::Module &M = CGM.getModule();
llvm::GlobalVariable *OldGV = M.getNamedGlobal(Name);
- llvm::GlobalVariable *GV =
- new llvm::GlobalVariable(M, Init->getType(),
- /*isConstant=*/true, Linkage, Init, Name);
+ llvm::GlobalVariable *GV = new llvm::GlobalVariable(
+ M, llvm::ConstantStruct::getTypeForElements(Fields),
----------------
efriedma-quic wrote:
Since you're going to replace the initializer anyway, you don't need to call ConstantStruct::getTypeForElements here; you can just use an arbitrary type, like i8. That should allow you to pass the global into BuildVTablePointer(), instead of replacing it later.
https://github.com/llvm/llvm-project/pull/102199
More information about the cfe-commits
mailing list