From e1008acc0bd8eedc8967ded37a5633075795986d Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Fri, 12 Feb 2021 00:07:23 +0100 Subject: [PATCH] [OpaquePtrs] Remove some uses of type-less CreateLoad APIs (NFC) Explicitly pass loaded type when creating loads, in preparation for the deprecation of these APIs. There are still a couple of uses left. --- lib/Frontend/OpenMP/OMPIRBuilder.cpp | 17 +++++++++-------- lib/Target/AMDGPU/AMDGPULateCodeGenPrepare.cpp | 2 +- lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp | 11 ++++++----- lib/Transforms/Utils/AMDGPUEmitPrintf.cpp | 2 +- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/lib/Frontend/OpenMP/OMPIRBuilder.cpp b/lib/Frontend/OpenMP/OMPIRBuilder.cpp index a1d7a53c361..0827298654d 100644 --- a/lib/Frontend/OpenMP/OMPIRBuilder.cpp +++ b/lib/Frontend/OpenMP/OMPIRBuilder.cpp @@ -552,11 +552,12 @@ IRBuilder<>::InsertPoint OpenMPIRBuilder::createParallel( AllocaInst *PrivTIDAddr = Builder.CreateAlloca(Int32, nullptr, "tid.addr.local"); - Instruction *PrivTID = Builder.CreateLoad(PrivTIDAddr, "tid"); + Instruction *PrivTID = Builder.CreateLoad(Int32, PrivTIDAddr, "tid"); // Add some fake uses for OpenMP provided arguments. - ToBeDeleted.push_back(Builder.CreateLoad(TIDAddr, "tid.addr.use")); - Instruction *ZeroAddrUse = Builder.CreateLoad(ZeroAddr, "zero.addr.use"); + ToBeDeleted.push_back(Builder.CreateLoad(Int32, TIDAddr, "tid.addr.use")); + Instruction *ZeroAddrUse = Builder.CreateLoad(Int32, ZeroAddr, + "zero.addr.use"); ToBeDeleted.push_back(ZeroAddrUse); // ThenBB @@ -637,7 +638,7 @@ IRBuilder<>::InsertPoint OpenMPIRBuilder::createParallel( // Initialize the local TID stack location with the argument value. Builder.SetInsertPoint(PrivTID); Function::arg_iterator OutlinedAI = OutlinedFn.arg_begin(); - Builder.CreateStore(Builder.CreateLoad(OutlinedAI), PrivTIDAddr); + Builder.CreateStore(Builder.CreateLoad(Int32, OutlinedAI), PrivTIDAddr); // If no "if" clause was present we do not need the call created during // outlining, otherwise we reuse it in the serialized parallel region. @@ -755,7 +756,7 @@ IRBuilder<>::InsertPoint OpenMPIRBuilder::createParallel( // Load back next to allocations in the to-be-outlined region. Builder.restoreIP(InnerAllocaIP); - Inner = Builder.CreateLoad(Ptr); + Inner = Builder.CreateLoad(V.getType(), Ptr); } Value *ReplacementValue = nullptr; @@ -1141,8 +1142,8 @@ CanonicalLoopInfo *OpenMPIRBuilder::createStaticWorkshareLoop( Builder.CreateCall(StaticInit, {SrcLoc, ThreadNum, SchedulingType, PLastIter, PLowerBound, PUpperBound, PStride, One, Chunk}); - Value *LowerBound = Builder.CreateLoad(PLowerBound); - Value *InclusiveUpperBound = Builder.CreateLoad(PUpperBound); + Value *LowerBound = Builder.CreateLoad(IVTy, PLowerBound); + Value *InclusiveUpperBound = Builder.CreateLoad(IVTy, PUpperBound); Value *TripCountMinusOne = Builder.CreateSub(InclusiveUpperBound, LowerBound); Value *TripCount = Builder.CreateAdd(TripCountMinusOne, One); setCanonicalLoopTripCount(CLI, TripCount); @@ -1561,7 +1562,7 @@ OpenMPIRBuilder::createCopyPrivate(const LocationDescription &Loc, Value *Ident = getOrCreateIdent(SrcLocStr); Value *ThreadId = getOrCreateThreadID(Ident); - llvm::Value *DidItLD = Builder.CreateLoad(DidIt); + llvm::Value *DidItLD = Builder.CreateLoad(Builder.getInt32Ty(), DidIt); Value *Args[] = {Ident, ThreadId, BufSize, CpyBuf, CpyFn, DidItLD}; diff --git a/lib/Target/AMDGPU/AMDGPULateCodeGenPrepare.cpp b/lib/Target/AMDGPU/AMDGPULateCodeGenPrepare.cpp index 8aea33cf289..e4aa6de10f2 100644 --- a/lib/Target/AMDGPU/AMDGPULateCodeGenPrepare.cpp +++ b/lib/Target/AMDGPU/AMDGPULateCodeGenPrepare.cpp @@ -168,7 +168,7 @@ bool AMDGPULateCodeGenPrepare::visitLoadInst(LoadInst &LI) { IRB.CreateConstGEP1_64(IRB.CreateBitCast(Base, Int8PtrTy), Offset - Adjust), Int32PtrTy); - LoadInst *NewLd = IRB.CreateAlignedLoad(NewPtr, Align(4)); + LoadInst *NewLd = IRB.CreateAlignedLoad(IRB.getInt32Ty(), NewPtr, Align(4)); NewLd->copyMetadata(LI); NewLd->setMetadata(LLVMContext::MD_range, nullptr); diff --git a/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp b/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp index b854757bb31..e07eb659320 100644 --- a/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp +++ b/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp @@ -797,15 +797,16 @@ public: /// vectors. MatrixTy loadMatrix(Type *Ty, Value *Ptr, MaybeAlign MAlign, Value *Stride, bool IsVolatile, ShapeInfo Shape, IRBuilder<> &Builder) { - auto VType = cast(Ty); - Value *EltPtr = createElementPtr(Ptr, VType->getElementType(), Builder); + auto *VType = cast(Ty); + Type *EltTy = VType->getElementType(); + Type *VecTy = FixedVectorType::get(EltTy, Shape.getStride()); + Value *EltPtr = createElementPtr(Ptr, EltTy, Builder); MatrixTy Result; for (unsigned I = 0, E = Shape.getNumVectors(); I < E; ++I) { Value *GEP = computeVectorAddr(EltPtr, Builder.getInt64(I), Stride, - Shape.getStride(), VType->getElementType(), - Builder); + Shape.getStride(), EltTy, Builder); Value *Vector = Builder.CreateAlignedLoad( - GEP, getAlignForIndex(I, Stride, VType->getElementType(), MAlign), + VecTy, GEP, getAlignForIndex(I, Stride, EltTy, MAlign), IsVolatile, "col.load"); Result.addVector(Vector); diff --git a/lib/Transforms/Utils/AMDGPUEmitPrintf.cpp b/lib/Transforms/Utils/AMDGPUEmitPrintf.cpp index ccdcf7cbce3..9210096c4f3 100644 --- a/lib/Transforms/Utils/AMDGPUEmitPrintf.cpp +++ b/lib/Transforms/Utils/AMDGPUEmitPrintf.cpp @@ -138,7 +138,7 @@ static Value *getStrlenWithNull(IRBuilder<> &Builder, Value *Str) { PtrPhi->addIncoming(PtrNext, While); // Condition for the while loop. - auto Data = Builder.CreateLoad(PtrPhi); + auto Data = Builder.CreateLoad(Builder.getInt8Ty(), PtrPhi); auto Cmp = Builder.CreateICmpEQ(Data, CharZero); Builder.CreateCondBr(Cmp, WhileDone, While);