[OpaquePtr] Remove uses of CGF.Builder.CreateConstInBoundsGEP1_64() without type

Remove uses of to-be-deprecated API.
This commit is contained in:
Nikita Popov 2021-07-17 17:00:00 +02:00
parent 32e2729e33
commit 5071360eb1
4 changed files with 25 additions and 21 deletions

View File

@ -262,7 +262,7 @@ static CGCallee BuildAppleKextVirtualCall(CodeGenFunction &CGF,
VTableIndex += VTLayout.getVTableOffset(AddressPoint.VTableIndex) +
AddressPoint.AddressPointIndex;
llvm::Value *VFuncPtr =
CGF.Builder.CreateConstInBoundsGEP1_64(VTable, VTableIndex, "vfnkxt");
CGF.Builder.CreateConstInBoundsGEP1_64(Ty, VTable, VTableIndex, "vfnkxt");
llvm::Value *VFunc = CGF.Builder.CreateAlignedLoad(
Ty, VFuncPtr, llvm::Align(CGF.PointerAlignInBytes));
CGCallee Callee(GD, VFunc);

View File

@ -493,7 +493,7 @@ llvm::Value *CodeGenFunction::GetVTTParameter(GlobalDecl GD,
if (CGM.getCXXABI().NeedsVTTParameter(CurGD)) {
// A VTT parameter was passed to the constructor, use it.
llvm::Value *VTT = LoadCXXVTT();
return Builder.CreateConstInBoundsGEP1_64(VTT, SubVTTIndex);
return Builder.CreateConstInBoundsGEP1_64(VoidPtrTy, VTT, SubVTTIndex);
} else {
// We're the complete constructor, so get the VTT by name.
llvm::GlobalValue *VTT = CGM.getVTables().GetAddrOfVTT(RD);

View File

@ -1254,7 +1254,7 @@ void ItaniumCXXABI::emitVirtualObjectDelete(CodeGenFunction &CGF,
// 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.
@ -1466,7 +1466,8 @@ llvm::Value *ItaniumCXXABI::EmitTypeid(CodeGenFunction &CGF,
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());
@ -1547,7 +1548,8 @@ llvm::Value *ItaniumCXXABI::EmitDynamicCastToVoid(CodeGenFunction &CGF,
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");
}
@ -1872,7 +1874,8 @@ llvm::Value *ItaniumCXXABI::getVTableAddressPointInStructorWithVTT(
/// 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,
@ -1943,9 +1946,10 @@ CGCallee ItaniumCXXABI::getVirtualFunctionPointer(CodeGenFunction &CGF,
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;
@ -1962,14 +1966,14 @@ CGCallee ItaniumCXXABI::getVirtualFunctionPointer(CodeGenFunction &CGF,
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());
}
@ -2108,8 +2112,8 @@ static llvm::Value *performTypeAdjustment(CodeGenFunction &CGF,
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 =
@ -2138,7 +2142,7 @@ static llvm::Value *performTypeAdjustment(CodeGenFunction &CGF,
// 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);
}

View File

@ -1951,7 +1951,7 @@ CGCallee MicrosoftCXXABI::getVirtualFunctionPointer(CodeGenFunction &CGF,
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());
}
@ -2080,14 +2080,14 @@ MicrosoftCXXABI::EmitVirtualMemPtrThunk(const CXXMethodDecl *MD,
// 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});