Skip to content

Commit 6d3e7c7

Browse files
committed
[OpaquePtr] Remove uses of CreateConstGEP1_32() without element type
Remove uses of to-be-deprecated API. I've fallen back to calling getPointerElementType() in some cases where the correct type wasn't immediately obvious to me.
1 parent 9277ce7 commit 6d3e7c7

File tree

7 files changed

+33
-22
lines changed

7 files changed

+33
-22
lines changed

clang/lib/CodeGen/CGBuiltin.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14769,7 +14769,7 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID,
1476914769

1477014770
for (int i = 0; i < 6; ++i) {
1477114771
Value *Extract = Builder.CreateExtractValue(Call, i + 1);
14772-
Value *Ptr = Builder.CreateConstGEP1_32(Ops[2], i * 16);
14772+
Value *Ptr = Builder.CreateConstGEP1_32(Int8Ty, Ops[2], i * 16);
1477314773
Ptr = Builder.CreateBitCast(
1477414774
Ptr, llvm::PointerType::getUnqual(Extract->getType()));
1477514775
Builder.CreateAlignedStore(Extract, Ptr, Align(1));
@@ -14785,7 +14785,7 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID,
1478514785

1478614786
for (int i = 0; i < 7; ++i) {
1478714787
Value *Extract = Builder.CreateExtractValue(Call, i + 1);
14788-
Value *Ptr = Builder.CreateConstGEP1_32(Ops[3], i * 16);
14788+
Value *Ptr = Builder.CreateConstGEP1_32(Int8Ty, Ops[3], i * 16);
1478914789
Ptr = Builder.CreateBitCast(
1479014790
Ptr, llvm::PointerType::getUnqual(Extract->getType()));
1479114791
Builder.CreateAlignedStore(Extract, Ptr, Align(1));
@@ -14873,7 +14873,7 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID,
1487314873
Value *InOps[9];
1487414874
InOps[0] = Ops[2];
1487514875
for (int i = 0; i != 8; ++i) {
14876-
Value *Ptr = Builder.CreateConstGEP1_32(Ops[1], i);
14876+
Value *Ptr = Builder.CreateConstGEP1_32(Ty, Ops[1], i);
1487714877
InOps[i + 1] = Builder.CreateAlignedLoad(Ty, Ptr, Align(16));
1487814878
}
1487914879

@@ -14891,7 +14891,7 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID,
1489114891
Builder.SetInsertPoint(NoError);
1489214892
for (int i = 0; i != 8; ++i) {
1489314893
Value *Extract = Builder.CreateExtractValue(Call, i + 1);
14894-
Value *Ptr = Builder.CreateConstGEP1_32(Ops[0], i);
14894+
Value *Ptr = Builder.CreateConstGEP1_32(Extract->getType(), Ops[0], i);
1489514895
Builder.CreateAlignedStore(Extract, Ptr, Align(16));
1489614896
}
1489714897
Builder.CreateBr(End);
@@ -14900,7 +14900,7 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID,
1490014900
for (int i = 0; i != 8; ++i) {
1490114901
Value *Out = Builder.CreateExtractValue(Call, i + 1);
1490214902
Constant *Zero = llvm::Constant::getNullValue(Out->getType());
14903-
Value *Ptr = Builder.CreateConstGEP1_32(Ops[0], i);
14903+
Value *Ptr = Builder.CreateConstGEP1_32(Out->getType(), Ops[0], i);
1490414904
Builder.CreateAlignedStore(Zero, Ptr, Align(16));
1490514905
}
1490614906
Builder.CreateBr(End);

clang/lib/CodeGen/CGCUDANV.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,8 @@ void CGNVCUDARuntime::emitDeviceStubBodyNew(CodeGenFunction &CGF,
326326
llvm::Value* VarPtr = CGF.GetAddrOfLocalVar(Args[i]).getPointer();
327327
llvm::Value *VoidVarPtr = CGF.Builder.CreatePointerCast(VarPtr, VoidPtrTy);
328328
CGF.Builder.CreateDefaultAlignedStore(
329-
VoidVarPtr, CGF.Builder.CreateConstGEP1_32(KernelArgs.getPointer(), i));
329+
VoidVarPtr,
330+
CGF.Builder.CreateConstGEP1_32(VoidPtrTy, KernelArgs.getPointer(), i));
330331
}
331332

332333
llvm::BasicBlock *EndBlock = CGF.createBasicBlock("setup.end");

clang/lib/CodeGen/CGOpenMPRuntime.cpp

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -743,13 +743,15 @@ static void EmitOMPAggregateInit(CodeGenFunction &CGF, Address DestAddr,
743743
if (DRD) {
744744
// Shift the address forward by one element.
745745
llvm::Value *SrcElementNext = CGF.Builder.CreateConstGEP1_32(
746-
SrcElementPHI, /*Idx0=*/1, "omp.arraycpy.dest.element");
746+
SrcAddr.getElementType(), SrcElementPHI, /*Idx0=*/1,
747+
"omp.arraycpy.dest.element");
747748
SrcElementPHI->addIncoming(SrcElementNext, CGF.Builder.GetInsertBlock());
748749
}
749750

750751
// Shift the address forward by one element.
751752
llvm::Value *DestElementNext = CGF.Builder.CreateConstGEP1_32(
752-
DestElementPHI, /*Idx0=*/1, "omp.arraycpy.dest.element");
753+
DestAddr.getElementType(), DestElementPHI, /*Idx0=*/1,
754+
"omp.arraycpy.dest.element");
753755
// Check whether we've reached the end.
754756
llvm::Value *Done =
755757
CGF.Builder.CreateICmpEQ(DestElementNext, DestEnd, "omp.arraycpy.done");
@@ -4155,8 +4157,9 @@ getPointerAndSize(CodeGenFunction &CGF, const Expr *E) {
41554157
dyn_cast<OMPArraySectionExpr>(E->IgnoreParenImpCasts())) {
41564158
LValue UpAddrLVal =
41574159
CGF.EmitOMPArraySectionExpr(ASE, /*IsLowerBound=*/false);
4158-
llvm::Value *UpAddr =
4159-
CGF.Builder.CreateConstGEP1_32(UpAddrLVal.getPointer(CGF), /*Idx0=*/1);
4160+
Address UpAddrAddress = UpAddrLVal.getAddress(CGF);
4161+
llvm::Value *UpAddr = CGF.Builder.CreateConstGEP1_32(
4162+
UpAddrAddress.getElementType(), UpAddrAddress.getPointer(), /*Idx0=*/1);
41604163
llvm::Value *LowIntPtr = CGF.Builder.CreatePtrToInt(Addr, CGF.SizeTy);
41614164
llvm::Value *UpIntPtr = CGF.Builder.CreatePtrToInt(UpAddr, CGF.SizeTy);
41624165
SizeVal = CGF.Builder.CreateNUWSub(UpIntPtr, LowIntPtr);
@@ -5375,9 +5378,11 @@ static void EmitOMPAggregateReduction(
53755378

53765379
// Shift the address forward by one element.
53775380
llvm::Value *LHSElementNext = CGF.Builder.CreateConstGEP1_32(
5378-
LHSElementPHI, /*Idx0=*/1, "omp.arraycpy.dest.element");
5381+
LHSAddr.getElementType(), LHSElementPHI, /*Idx0=*/1,
5382+
"omp.arraycpy.dest.element");
53795383
llvm::Value *RHSElementNext = CGF.Builder.CreateConstGEP1_32(
5380-
RHSElementPHI, /*Idx0=*/1, "omp.arraycpy.src.element");
5384+
RHSAddr.getElementType(), RHSElementPHI, /*Idx0=*/1,
5385+
"omp.arraycpy.src.element");
53815386
// Check whether we've reached the end.
53825387
llvm::Value *Done =
53835388
CGF.Builder.CreateICmpEQ(LHSElementNext, LHSEnd, "omp.arraycpy.done");
@@ -8728,7 +8733,8 @@ class MappableExprsHandler {
87288733
CombinedInfo.Mappers.push_back(nullptr);
87298734
// Size is (addr of {highest+1} element) - (addr of lowest element)
87308735
llvm::Value *HB = HBAddr.getPointer();
8731-
llvm::Value *HAddr = CGF.Builder.CreateConstGEP1_32(HB, /*Idx0=*/1);
8736+
llvm::Value *HAddr =
8737+
CGF.Builder.CreateConstGEP1_32(HBAddr.getElementType(), HB, /*Idx0=*/1);
87328738
llvm::Value *CLAddr = CGF.Builder.CreatePointerCast(LB, CGF.VoidPtrTy);
87338739
llvm::Value *CHAddr = CGF.Builder.CreatePointerCast(HAddr, CGF.VoidPtrTy);
87348740
llvm::Value *Diff = CGF.Builder.CreatePtrDiff(CHAddr, CLAddr);
@@ -9898,8 +9904,9 @@ void CGOpenMPRuntime::emitUserDefinedMapper(const OMPDeclareMapperDecl *D,
98989904

98999905
// Update the pointer to point to the next element that needs to be mapped,
99009906
// and check whether we have mapped all elements.
9907+
llvm::Type *ElemTy = PtrPHI->getType()->getPointerElementType();
99019908
llvm::Value *PtrNext = MapperCGF.Builder.CreateConstGEP1_32(
9902-
PtrPHI, /*Idx0=*/1, "omp.arraymap.next");
9909+
ElemTy, PtrPHI, /*Idx0=*/1, "omp.arraymap.next");
99039910
PtrPHI->addIncoming(PtrNext, LastBB);
99049911
llvm::Value *IsDone =
99059912
MapperCGF.Builder.CreateICmpEQ(PtrNext, PtrEnd, "omp.arraymap.isdone");

clang/lib/CodeGen/CGStmtOpenMP.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -883,9 +883,11 @@ void CodeGenFunction::EmitOMPAggregateAssign(
883883

884884
// Shift the address forward by one element.
885885
llvm::Value *DestElementNext = Builder.CreateConstGEP1_32(
886-
DestElementPHI, /*Idx0=*/1, "omp.arraycpy.dest.element");
886+
DestAddr.getElementType(), DestElementPHI, /*Idx0=*/1,
887+
"omp.arraycpy.dest.element");
887888
llvm::Value *SrcElementNext = Builder.CreateConstGEP1_32(
888-
SrcElementPHI, /*Idx0=*/1, "omp.arraycpy.src.element");
889+
SrcAddr.getElementType(), SrcElementPHI, /*Idx0=*/1,
890+
"omp.arraycpy.src.element");
889891
// Check whether we've reached the end.
890892
llvm::Value *Done =
891893
Builder.CreateICmpEQ(DestElementNext, DestEnd, "omp.arraycpy.done");

clang/lib/CodeGen/ItaniumCXXABI.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4449,7 +4449,8 @@ static void InitCatchParam(CodeGenFunction &CGF,
44494449
// we have to skip past in order to reach the exception data.
44504450
unsigned HeaderSize =
44514451
CGF.CGM.getTargetCodeGenInfo().getSizeOfUnwindException();
4452-
AdjustedExn = CGF.Builder.CreateConstGEP1_32(Exn, HeaderSize);
4452+
AdjustedExn =
4453+
CGF.Builder.CreateConstGEP1_32(CGF.Int8Ty, Exn, HeaderSize);
44534454

44544455
// However, if we're catching a pointer-to-record type that won't
44554456
// work, because the personality function might have adjusted

clang/lib/CodeGen/MicrosoftCXXABI.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,7 +1228,7 @@ void MicrosoftCXXABI::initializeHiddenVirtualInheritanceMembers(
12281228
llvm::Value *VtorDispPtr =
12291229
Builder.CreateInBoundsGEP(CGF.Int8Ty, Int8This, VBaseOffset);
12301230
// vtorDisp is always the 32-bits before the vbase in the class layout.
1231-
VtorDispPtr = Builder.CreateConstGEP1_32(VtorDispPtr, -4);
1231+
VtorDispPtr = Builder.CreateConstGEP1_32(CGF.Int8Ty, VtorDispPtr, -4);
12321232
VtorDispPtr = Builder.CreateBitCast(
12331233
VtorDispPtr, CGF.Int32Ty->getPointerTo(AS), "vtordisp.ptr");
12341234

@@ -2227,7 +2227,7 @@ llvm::Value *MicrosoftCXXABI::performThisAdjustment(CodeGenFunction &CGF,
22272227
// Non-virtual adjustment might result in a pointer outside the allocated
22282228
// object, e.g. if the final overrider class is laid out after the virtual
22292229
// base that declares a method in the most derived class.
2230-
V = CGF.Builder.CreateConstGEP1_32(V, TA.NonVirtual);
2230+
V = CGF.Builder.CreateConstGEP1_32(CGF.Int8Ty, V, TA.NonVirtual);
22312231
}
22322232

22332233
// Don't need to bitcast back, the call CodeGen will handle this.

llvm/lib/Target/AArch64/AArch64StackTagging.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ class InitializerBuilder {
239239
<< ") zero\n");
240240
Value *Ptr = BasePtr;
241241
if (Offset)
242-
Ptr = IRB.CreateConstGEP1_32(Ptr, Offset);
242+
Ptr = IRB.CreateConstGEP1_32(IRB.getInt8Ty(), Ptr, Offset);
243243
IRB.CreateCall(SetTagZeroFn,
244244
{Ptr, ConstantInt::get(IRB.getInt64Ty(), Size)});
245245
}
@@ -249,7 +249,7 @@ class InitializerBuilder {
249249
<< ") undef\n");
250250
Value *Ptr = BasePtr;
251251
if (Offset)
252-
Ptr = IRB.CreateConstGEP1_32(Ptr, Offset);
252+
Ptr = IRB.CreateConstGEP1_32(IRB.getInt8Ty(), Ptr, Offset);
253253
IRB.CreateCall(SetTagFn, {Ptr, ConstantInt::get(IRB.getInt64Ty(), Size)});
254254
}
255255

@@ -258,7 +258,7 @@ class InitializerBuilder {
258258
LLVM_DEBUG(dbgs() << " " << *A << "\n " << *B << "\n");
259259
Value *Ptr = BasePtr;
260260
if (Offset)
261-
Ptr = IRB.CreateConstGEP1_32(Ptr, Offset);
261+
Ptr = IRB.CreateConstGEP1_32(IRB.getInt8Ty(), Ptr, Offset);
262262
IRB.CreateCall(StgpFn, {Ptr, A, B});
263263
}
264264

0 commit comments

Comments
 (0)