[clang] 834c8ff - [CodeGen] Avoid some uses of deprecated Address constructor
Nikita Popov via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 15 02:13:21 PST 2021
Author: Nikita Popov
Date: 2021-12-15T11:13:10+01:00
New Revision: 834c8ff5879839d108af256dfd86bd498ac65efd
URL: https://github.com/llvm/llvm-project/commit/834c8ff5879839d108af256dfd86bd498ac65efd
DIFF: https://github.com/llvm/llvm-project/commit/834c8ff5879839d108af256dfd86bd498ac65efd.diff
LOG: [CodeGen] Avoid some uses of deprecated Address constructor
Explicitly pass in the element type instead.
Added:
Modified:
clang/lib/CodeGen/CGBuilder.h
clang/lib/CodeGen/CGBuiltin.cpp
Removed:
################################################################################
diff --git a/clang/lib/CodeGen/CGBuilder.h b/clang/lib/CodeGen/CGBuilder.h
index f3b759743d38..86c108c54878 100644
--- a/clang/lib/CodeGen/CGBuilder.h
+++ b/clang/lib/CodeGen/CGBuilder.h
@@ -197,6 +197,7 @@ class CGBuilderTy : public CGBuilderBaseTy {
return Address(CreateStructGEP(Addr.getElementType(),
Addr.getPointer(), Index, Name),
+ ElTy->getElementType(Index),
Addr.getAlignment().alignmentAtOffset(Offset));
}
@@ -218,6 +219,7 @@ class CGBuilderTy : public CGBuilderBaseTy {
return Address(
CreateInBoundsGEP(Addr.getElementType(), Addr.getPointer(),
{getSize(CharUnits::Zero()), getSize(Index)}, Name),
+ ElTy->getElementType(),
Addr.getAlignment().alignmentAtOffset(Index * EltSize));
}
@@ -234,6 +236,7 @@ class CGBuilderTy : public CGBuilderBaseTy {
return Address(CreateInBoundsGEP(Addr.getElementType(), Addr.getPointer(),
getSize(Index), Name),
+ ElTy,
Addr.getAlignment().alignmentAtOffset(Index * EltSize));
}
@@ -250,6 +253,7 @@ class CGBuilderTy : public CGBuilderBaseTy {
return Address(CreateGEP(Addr.getElementType(), Addr.getPointer(),
getSize(Index), Name),
+ Addr.getElementType(),
Addr.getAlignment().alignmentAtOffset(Index * EltSize));
}
@@ -259,6 +263,7 @@ class CGBuilderTy : public CGBuilderBaseTy {
assert(Addr.getElementType() == TypeCache.Int8Ty);
return Address(CreateInBoundsGEP(Addr.getElementType(), Addr.getPointer(),
getSize(Offset), Name),
+ Addr.getElementType(),
Addr.getAlignment().alignmentAtOffset(Offset));
}
Address CreateConstByteGEP(Address Addr, CharUnits Offset,
@@ -266,6 +271,7 @@ class CGBuilderTy : public CGBuilderBaseTy {
assert(Addr.getElementType() == TypeCache.Int8Ty);
return Address(CreateGEP(Addr.getElementType(), Addr.getPointer(),
getSize(Offset), Name),
+ Addr.getElementType(),
Addr.getAlignment().alignmentAtOffset(Offset));
}
@@ -281,8 +287,9 @@ class CGBuilderTy : public CGBuilderBaseTy {
/*isSigned=*/true);
if (!GEP->accumulateConstantOffset(DL, Offset))
llvm_unreachable("offset of GEP with constants is always computable");
- return Address(GEP, Addr.getAlignment().alignmentAtOffset(
- CharUnits::fromQuantity(Offset.getSExtValue())));
+ return Address(GEP, GEP->getResultElementType(),
+ Addr.getAlignment().alignmentAtOffset(
+ CharUnits::fromQuantity(Offset.getSExtValue())));
}
using CGBuilderBaseTy::CreateMemCpy;
@@ -333,6 +340,7 @@ class CGBuilderTy : public CGBuilderBaseTy {
return Address(CreatePreserveStructAccessIndex(ElTy, Addr.getPointer(),
Index, FieldIndex, DbgInfo),
+ ElTy->getElementType(Index),
Addr.getAlignment().alignmentAtOffset(Offset));
}
};
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index a50f852f9051..c9ae244d5a96 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -5246,9 +5246,9 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
llvm::Type *BPP = Int8PtrPtrTy;
DestAddr = Address(Builder.CreateBitCast(DestAddr.getPointer(), BPP, "cp"),
- DestAddr.getAlignment());
+ Int8PtrTy, DestAddr.getAlignment());
SrcAddr = Address(Builder.CreateBitCast(SrcAddr.getPointer(), BPP, "ap"),
- SrcAddr.getAlignment());
+ Int8PtrTy, SrcAddr.getAlignment());
Value *ArgPtr = Builder.CreateLoad(SrcAddr, "ap.val");
return RValue::get(Builder.CreateStore(ArgPtr, DestAddr));
@@ -15405,7 +15405,8 @@ Value *CodeGenFunction::EmitPPCBuiltinExpr(unsigned BuiltinID,
// If the user wants the entire vector, just load the entire vector.
if (NumBytes == 16) {
Value *BC = Builder.CreateBitCast(Ops[0], ResTy->getPointerTo());
- Value *LD = Builder.CreateLoad(Address(BC, CharUnits::fromQuantity(1)));
+ Value *LD =
+ Builder.CreateLoad(Address(BC, ResTy, CharUnits::fromQuantity(1)));
if (!IsLE)
return LD;
@@ -15466,8 +15467,8 @@ Value *CodeGenFunction::EmitPPCBuiltinExpr(unsigned BuiltinID,
RevMask.push_back(15 - Idx);
StVec = Builder.CreateShuffleVector(Ops[2], Ops[2], RevMask);
}
- return Builder.CreateStore(StVec,
- Address(BC, CharUnits::fromQuantity(1)));
+ return Builder.CreateStore(
+ StVec, Address(BC, Ops[2]->getType(), CharUnits::fromQuantity(1)));
}
auto *ConvTy = Int64Ty;
unsigned NumElts = 0;
@@ -15501,8 +15502,8 @@ Value *CodeGenFunction::EmitPPCBuiltinExpr(unsigned BuiltinID,
Function *F = CGM.getIntrinsic(Intrinsic::bswap, ConvTy);
Elt = Builder.CreateCall(F, Elt);
}
- return Builder.CreateStore(Elt,
- Address(PtrBC, CharUnits::fromQuantity(1)));
+ return Builder.CreateStore(
+ Elt, Address(PtrBC, ConvTy, CharUnits::fromQuantity(1)));
};
unsigned Stored = 0;
unsigned RemainingBytes = NumBytes;
@@ -16296,7 +16297,8 @@ Value *EmitAMDGPUWorkGroupSize(CodeGenFunction &CGF, unsigned Index) {
auto *DstTy =
CGF.Int16Ty->getPointerTo(GEP->getType()->getPointerAddressSpace());
auto *Cast = CGF.Builder.CreateBitCast(GEP, DstTy);
- auto *LD = CGF.Builder.CreateLoad(Address(Cast, CharUnits::fromQuantity(2)));
+ auto *LD = CGF.Builder.CreateLoad(
+ Address(Cast, CGF.Int16Ty, CharUnits::fromQuantity(2)));
llvm::MDBuilder MDHelper(CGF.getLLVMContext());
llvm::MDNode *RNode = MDHelper.createRange(APInt(16, 1),
APInt(16, CGF.getTarget().getMaxOpenCLWorkGroupSize() + 1));
@@ -16316,7 +16318,8 @@ Value *EmitAMDGPUGridSize(CodeGenFunction &CGF, unsigned Index) {
auto *DstTy =
CGF.Int32Ty->getPointerTo(GEP->getType()->getPointerAddressSpace());
auto *Cast = CGF.Builder.CreateBitCast(GEP, DstTy);
- auto *LD = CGF.Builder.CreateLoad(Address(Cast, CharUnits::fromQuantity(4)));
+ auto *LD = CGF.Builder.CreateLoad(
+ Address(Cast, CGF.Int32Ty, CharUnits::fromQuantity(4)));
LD->setMetadata(llvm::LLVMContext::MD_invariant_load,
llvm::MDNode::get(CGF.getLLVMContext(), None));
return LD;
@@ -18616,8 +18619,8 @@ Value *CodeGenFunction::EmitHexagonBuiltinExpr(unsigned BuiltinID,
auto MakeCircOp = [this, E](unsigned IntID, bool IsLoad) {
// The base pointer is passed by address, so it needs to be loaded.
Address A = EmitPointerWithAlignment(E->getArg(0));
- Address BP = Address(
- Builder.CreateBitCast(A.getPointer(), Int8PtrPtrTy), A.getAlignment());
+ Address BP = Address(Builder.CreateBitCast(
+ A.getPointer(), Int8PtrPtrTy), Int8PtrTy, A.getAlignment());
llvm::Value *Base = Builder.CreateLoad(BP);
// The treatment of both loads and stores is the same: the arguments for
// the builtin are the same as the arguments for the intrinsic.
@@ -18661,7 +18664,7 @@ Value *CodeGenFunction::EmitHexagonBuiltinExpr(unsigned BuiltinID,
// per call.
Address DestAddr = EmitPointerWithAlignment(E->getArg(1));
DestAddr = Address(Builder.CreateBitCast(DestAddr.getPointer(), Int8PtrTy),
- DestAddr.getAlignment());
+ Int8Ty, DestAddr.getAlignment());
llvm::Value *DestAddress = DestAddr.getPointer();
// Operands are Base, Dest, Modifier.
More information about the cfe-commits
mailing list