[llvm] CallPromotionUtils: Correctly use IndexSize when determining the bit width of pointer offsets. (PR #119483)

Owen Anderson via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 10 19:02:21 PST 2024


================
@@ -710,9 +710,13 @@ bool llvm::tryPromoteCall(CallBase &CB) {
   BasicBlock::iterator BBI(VTablePtrLoad);
   Value *VTablePtr = FindAvailableLoadedValue(
       VTablePtrLoad, VTablePtrLoad->getParent(), BBI, 0, nullptr, nullptr);
-  if (!VTablePtr)
+  if (!VTablePtr || !VTablePtr->getType()->isPointerTy())
     return false; // No vtable found.
-  APInt VTableOffsetGVBase(DL.getTypeSizeInBits(VTablePtr->getType()), 0);
+
+  // VTablePtr may not actually have a pointer type, so we can't find the
+  // address space through it. However, we know that the address space must be
+  // the same one used to load from the vtable in VTablePtrLoad.
----------------
resistor wrote:

Done.

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


More information about the llvm-commits mailing list