// Track back to entry -2 and pull out the offset there.
llvm::Value *OffsetPtr = CGF.Builder.CreateConstInBoundsGEP1_64(
- VTable, -2, "complete-offset.ptr");
+ CGF.IntPtrTy, VTable, -2, "complete-offset.ptr");
llvm::Value *Offset = CGF.Builder.CreateAlignedLoad(CGF.IntPtrTy, OffsetPtr, CGF.getPointerAlign());
// Apply the offset.
Value = CGF.Builder.CreateBitCast(Value, StdTypeInfoPtrTy->getPointerTo());
} else {
// Load the type info.
- Value = CGF.Builder.CreateConstInBoundsGEP1_64(Value, -1ULL);
+ Value =
+ CGF.Builder.CreateConstInBoundsGEP1_64(StdTypeInfoPtrTy, Value, -1ULL);
}
return CGF.Builder.CreateAlignedLoad(StdTypeInfoPtrTy, Value,
CGF.getPointerAlign());
CGF.GetVTablePtr(ThisAddr, PtrDiffLTy->getPointerTo(), ClassDecl);
// Get the offset-to-top from the vtable.
- OffsetToTop = CGF.Builder.CreateConstInBoundsGEP1_64(VTable, -2ULL);
+ OffsetToTop =
+ CGF.Builder.CreateConstInBoundsGEP1_64(PtrDiffLTy, VTable, -2ULL);
OffsetToTop = CGF.Builder.CreateAlignedLoad(
PtrDiffLTy, OffsetToTop, CGF.getPointerAlign(), "offset.to.top");
}
/// Load the VTT.
llvm::Value *VTT = CGF.LoadCXXVTT();
if (VirtualPointerIndex)
- VTT = CGF.Builder.CreateConstInBoundsGEP1_64(VTT, VirtualPointerIndex);
+ VTT = CGF.Builder.CreateConstInBoundsGEP1_64(
+ CGF.VoidPtrTy, VTT, VirtualPointerIndex);
// And load the address point from the VTT.
return CGF.Builder.CreateAlignedLoad(CGF.VoidPtrTy, VTT,
Address This,
llvm::Type *Ty,
SourceLocation Loc) {
+ llvm::Type *TyPtr = Ty->getPointerTo();
auto *MethodDecl = cast<CXXMethodDecl>(GD.getDecl());
llvm::Value *VTable = CGF.GetVTablePtr(
- This, Ty->getPointerTo()->getPointerTo(), MethodDecl->getParent());
+ This, TyPtr->getPointerTo(), MethodDecl->getParent());
uint64_t VTableIndex = CGM.getItaniumVTableContext().getMethodVTableIndex(GD);
llvm::Value *VFunc;
llvm::Value *Load = CGF.Builder.CreateCall(
CGM.getIntrinsic(llvm::Intrinsic::load_relative, {CGM.Int32Ty}),
{VTable, llvm::ConstantInt::get(CGM.Int32Ty, 4 * VTableIndex)});
- VFuncLoad = CGF.Builder.CreateBitCast(Load, Ty->getPointerTo());
+ VFuncLoad = CGF.Builder.CreateBitCast(Load, TyPtr);
} else {
VTable =
- CGF.Builder.CreateBitCast(VTable, Ty->getPointerTo()->getPointerTo());
- llvm::Value *VTableSlotPtr =
- CGF.Builder.CreateConstInBoundsGEP1_64(VTable, VTableIndex, "vfn");
+ CGF.Builder.CreateBitCast(VTable, TyPtr->getPointerTo());
+ llvm::Value *VTableSlotPtr = CGF.Builder.CreateConstInBoundsGEP1_64(
+ TyPtr, VTable, VTableIndex, "vfn");
VFuncLoad =
- CGF.Builder.CreateAlignedLoad(Ty->getPointerTo(), VTableSlotPtr,
+ CGF.Builder.CreateAlignedLoad(TyPtr, VTableSlotPtr,
CGF.getPointerAlign());
}
llvm::Value *VTablePtr = CGF.Builder.CreateLoad(VTablePtrPtr);
llvm::Value *Offset;
- llvm::Value *OffsetPtr =
- CGF.Builder.CreateConstInBoundsGEP1_64(VTablePtr, VirtualAdjustment);
+ llvm::Value *OffsetPtr = CGF.Builder.CreateConstInBoundsGEP1_64(
+ CGF.Int8Ty, VTablePtr, VirtualAdjustment);
if (CGF.CGM.getItaniumVTableContext().isRelativeLayout()) {
// Load the adjustment offset from the vtable as a 32-bit int.
OffsetPtr =
// In a derived-to-base conversion, the non-virtual adjustment is
// applied second.
if (NonVirtualAdjustment && IsReturnAdjustment) {
- ResultPtr = CGF.Builder.CreateConstInBoundsGEP1_64(ResultPtr,
+ ResultPtr = CGF.Builder.CreateConstInBoundsGEP1_64(CGF.Int8Ty, ResultPtr,
NonVirtualAdjustment);
}
CGF.EmitTypeMetadataCodeForVCall(getObjectWithVPtr(), VTable, Loc);
llvm::Value *VFuncPtr =
- Builder.CreateConstInBoundsGEP1_64(VTable, ML.Index, "vfn");
+ Builder.CreateConstInBoundsGEP1_64(Ty, VTable, ML.Index, "vfn");
VFunc = Builder.CreateAlignedLoad(Ty, VFuncPtr, CGF.getPointerAlign());
}
// Load the vfptr and then callee from the vftable. The callee should have
// adjusted 'this' so that the vfptr is at offset zero.
+ llvm::Type *ThunkPtrTy = ThunkTy->getPointerTo();
llvm::Value *VTable = CGF.GetVTablePtr(
- getThisAddress(CGF), ThunkTy->getPointerTo()->getPointerTo(), MD->getParent());
+ getThisAddress(CGF), ThunkPtrTy->getPointerTo(), MD->getParent());
- llvm::Value *VFuncPtr =
- CGF.Builder.CreateConstInBoundsGEP1_64(VTable, ML.Index, "vfn");
+ llvm::Value *VFuncPtr = CGF.Builder.CreateConstInBoundsGEP1_64(
+ ThunkPtrTy, VTable, ML.Index, "vfn");
llvm::Value *Callee =
- CGF.Builder.CreateAlignedLoad(ThunkTy->getPointerTo(), VFuncPtr,
- CGF.getPointerAlign());
+ CGF.Builder.CreateAlignedLoad(ThunkPtrTy, VFuncPtr, CGF.getPointerAlign());
CGF.EmitMustTailThunk(MD, getThisValue(CGF), {ThunkTy, Callee});