[compiler-rt] [llvm] [CallPromotionUtils]Implement conditional indirect call promotion with vtable-based comparison (PR #81378)
Mingming Liu via llvm-commits
llvm-commits at lists.llvm.org
Wed May 15 14:30:49 PDT 2024
================
@@ -568,6 +589,46 @@ CallBase &llvm::promoteCallWithIfThenElse(CallBase &CB, Function *Callee,
return promoteCall(NewInst, Callee);
}
+Constant *llvm::getVTableAddressPointOffset(GlobalVariable *VTable,
+ uint32_t AddressPointOffset) {
+ Module &M = *VTable->getParent();
+ const DataLayout &DL = M.getDataLayout();
+ LLVMContext &Context = M.getContext();
+ Type *VTableType = VTable->getValueType();
+ assert(AddressPointOffset < DL.getTypeAllocSize(VTableType) &&
+ "Out-of-bound access");
+ APInt AddressPointOffsetAPInt(32, AddressPointOffset, false);
+ SmallVector<APInt> Indices =
+ DL.getGEPIndicesForOffset(VTableType, AddressPointOffsetAPInt);
----------------
minglotus-6 wrote:
I found `CallPromotionUtils.cpp` doesn't use `getVTableAddressPointOffset` either, so moved it to `CallPromotionUtilsTest.cpp`
https://github.com/llvm/llvm-project/pull/81378
More information about the llvm-commits
mailing list