[clang] 46354ba - [OpaquePtrs] Remove some uses of type-less CreateLoad APIs (NFC)

Nikita Popov via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 11 05:41:09 PST 2021


Author: Nikita Popov
Date: 2021-03-11T14:40:57+01:00
New Revision: 46354bac76f60e988537181b3609a8e3ac89f523

URL: https://github.com/llvm/llvm-project/commit/46354bac76f60e988537181b3609a8e3ac89f523
DIFF: https://github.com/llvm/llvm-project/commit/46354bac76f60e988537181b3609a8e3ac89f523.diff

LOG: [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.

Added: 
    

Modified: 
    clang/lib/CodeGen/CGBuilder.h
    clang/lib/CodeGen/CGBuiltin.cpp
    clang/lib/CodeGen/CGCXX.cpp
    clang/lib/CodeGen/CodeGenFunction.h
    llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
    llvm/lib/Target/AMDGPU/AMDGPULateCodeGenPrepare.cpp
    llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp
    llvm/lib/Transforms/Utils/AMDGPUEmitPrintf.cpp
    polly/lib/CodeGen/IslNodeBuilder.cpp
    polly/lib/CodeGen/LoopGenerators.cpp
    polly/lib/CodeGen/LoopGeneratorsGOMP.cpp
    polly/lib/CodeGen/LoopGeneratorsKMP.cpp
    polly/lib/CodeGen/PerfMonitor.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/CodeGen/CGBuilder.h b/clang/lib/CodeGen/CGBuilder.h
index 320278eac124..4e22db67c57e 100644
--- a/clang/lib/CodeGen/CGBuilder.h
+++ b/clang/lib/CodeGen/CGBuilder.h
@@ -66,19 +66,20 @@ class CGBuilderTy : public CGBuilderBaseTy {
   // Note that we intentionally hide the CreateLoad APIs that don't
   // take an alignment.
   llvm::LoadInst *CreateLoad(Address Addr, const llvm::Twine &Name = "") {
-    return CreateAlignedLoad(Addr.getPointer(),
+    return CreateAlignedLoad(Addr.getElementType(), Addr.getPointer(),
                              Addr.getAlignment().getAsAlign(), Name);
   }
   llvm::LoadInst *CreateLoad(Address Addr, const char *Name) {
     // This overload is required to prevent string literals from
     // ending up in the IsVolatile overload.
-    return CreateAlignedLoad(Addr.getPointer(),
+    return CreateAlignedLoad(Addr.getElementType(), Addr.getPointer(),
                              Addr.getAlignment().getAsAlign(), Name);
   }
   llvm::LoadInst *CreateLoad(Address Addr, bool IsVolatile,
                              const llvm::Twine &Name = "") {
-    return CreateAlignedLoad(
-        Addr.getPointer(), Addr.getAlignment().getAsAlign(), IsVolatile, Name);
+    return CreateAlignedLoad(Addr.getElementType(), Addr.getPointer(),
+                             Addr.getAlignment().getAsAlign(), IsVolatile,
+                             Name);
   }
 
   using CGBuilderBaseTy::CreateAlignedLoad;

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 44bd151093cc..a3a33e46583b 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -14663,11 +14663,12 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID,
       break;
     }
 
+    llvm::Type *Ty = FixedVectorType::get(Builder.getInt64Ty(), 2);
     Value *InOps[9];
     InOps[0] = Ops[2];
     for (int i = 0; i != 8; ++i) {
       Value *Ptr = Builder.CreateConstGEP1_32(Ops[1], i);
-      InOps[i + 1] = Builder.CreateAlignedLoad(Ptr, Align(16));
+      InOps[i + 1] = Builder.CreateAlignedLoad(Ty, Ptr, Align(16));
     }
 
     Value *Call = Builder.CreateCall(CGM.getIntrinsic(IID), InOps);

diff  --git a/clang/lib/CodeGen/CGCXX.cpp b/clang/lib/CodeGen/CGCXX.cpp
index a4bd2c6d5da0..641740c37a68 100644
--- a/clang/lib/CodeGen/CGCXX.cpp
+++ b/clang/lib/CodeGen/CGCXX.cpp
@@ -252,8 +252,8 @@ static CGCallee BuildAppleKextVirtualCall(CodeGenFunction &CGF,
          "No kext in Microsoft ABI");
   CodeGenModule &CGM = CGF.CGM;
   llvm::Value *VTable = CGM.getCXXABI().getAddrOfVTable(RD, CharUnits());
-  Ty = Ty->getPointerTo()->getPointerTo();
-  VTable = CGF.Builder.CreateBitCast(VTable, Ty);
+  Ty = Ty->getPointerTo();
+  VTable = CGF.Builder.CreateBitCast(VTable, Ty->getPointerTo());
   assert(VTable && "BuildVirtualCall = kext vtbl pointer is null");
   uint64_t VTableIndex = CGM.getItaniumVTableContext().getMethodVTableIndex(GD);
   const VTableLayout &VTLayout = CGM.getItaniumVTableContext().getVTableLayout(RD);
@@ -264,7 +264,7 @@ static CGCallee BuildAppleKextVirtualCall(CodeGenFunction &CGF,
   llvm::Value *VFuncPtr =
     CGF.Builder.CreateConstInBoundsGEP1_64(VTable, VTableIndex, "vfnkxt");
   llvm::Value *VFunc = CGF.Builder.CreateAlignedLoad(
-      VFuncPtr, llvm::Align(CGF.PointerAlignInBytes));
+      Ty, VFuncPtr, llvm::Align(CGF.PointerAlignInBytes));
   CGCallee Callee(GD, VFunc);
   return Callee;
 }

diff  --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h
index 98e8d5bb9efa..fc342bbdbd71 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/lib/CodeGen/CodeGenFunction.h
@@ -4807,7 +4807,8 @@ inline llvm::Value *DominatingLLVMValue::restore(CodeGenFunction &CGF,
 
   // Otherwise, it should be an alloca instruction, as set up in save().
   auto alloca = cast<llvm::AllocaInst>(value.getPointer());
-  return CGF.Builder.CreateAlignedLoad(alloca, alloca->getAlign());
+  return CGF.Builder.CreateAlignedLoad(alloca->getAllocatedType(), alloca,
+                                       alloca->getAlign());
 }
 
 }  // end namespace CodeGen

diff  --git a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
index a1d7a53c3617..0827298654d5 100644
--- a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ b/llvm/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/llvm/lib/Target/AMDGPU/AMDGPULateCodeGenPrepare.cpp b/llvm/lib/Target/AMDGPU/AMDGPULateCodeGenPrepare.cpp
index 8aea33cf289d..e4aa6de10f2d 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPULateCodeGenPrepare.cpp
+++ b/llvm/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/llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp b/llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp
index b854757bb31e..e07eb6593200 100644
--- a/llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp
+++ b/llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp
@@ -797,15 +797,16 @@ class LowerMatrixIntrinsics {
   /// vectors.
   MatrixTy loadMatrix(Type *Ty, Value *Ptr, MaybeAlign MAlign, Value *Stride,
                       bool IsVolatile, ShapeInfo Shape, IRBuilder<> &Builder) {
-    auto VType = cast<VectorType>(Ty);
-    Value *EltPtr = createElementPtr(Ptr, VType->getElementType(), Builder);
+    auto *VType = cast<VectorType>(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/llvm/lib/Transforms/Utils/AMDGPUEmitPrintf.cpp b/llvm/lib/Transforms/Utils/AMDGPUEmitPrintf.cpp
index ccdcf7cbce38..9210096c4f3e 100644
--- a/llvm/lib/Transforms/Utils/AMDGPUEmitPrintf.cpp
+++ b/llvm/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);
 

diff  --git a/polly/lib/CodeGen/IslNodeBuilder.cpp b/polly/lib/CodeGen/IslNodeBuilder.cpp
index ba13969c3427..cb176cffba5f 100644
--- a/polly/lib/CodeGen/IslNodeBuilder.cpp
+++ b/polly/lib/CodeGen/IslNodeBuilder.cpp
@@ -1139,22 +1139,22 @@ static Value *buildFADOutermostDimensionLoad(Value *GlobalDescriptor,
                       Builder.getInt64(0), Builder.getInt32(2)};
   Value *endPtr = Builder.CreateInBoundsGEP(GlobalDescriptor, endIdx,
                                             ArrayName + "_end_ptr");
-  Value *end = Builder.CreateLoad(endPtr, ArrayName + "_end");
+  Type *type = cast<GEPOperator>(endPtr)->getResultElementType();
+  assert(isa<IntegerType>(type) && "expected type of end to be integral");
+
+  Value *end = Builder.CreateLoad(type, endPtr, ArrayName + "_end");
 
   Value *beginIdx[4] = {Builder.getInt64(0), Builder.getInt32(3),
                         Builder.getInt64(0), Builder.getInt32(1)};
   Value *beginPtr = Builder.CreateInBoundsGEP(GlobalDescriptor, beginIdx,
                                               ArrayName + "_begin_ptr");
-  Value *begin = Builder.CreateLoad(beginPtr, ArrayName + "_begin");
+  Value *begin = Builder.CreateLoad(type, beginPtr, ArrayName + "_begin");
 
   Value *size =
       Builder.CreateNSWSub(end, begin, ArrayName + "_end_begin_delta");
-  Type *endType = dyn_cast<IntegerType>(end->getType());
-  assert(endType && "expected type of end to be integral");
 
-  size = Builder.CreateNSWAdd(end,
-                              ConstantInt::get(endType, 1, /* signed = */ true),
-                              ArrayName + "_size");
+  size = Builder.CreateNSWAdd(
+      end, ConstantInt::get(type, 1, /* signed = */ true), ArrayName + "_size");
 
   return size;
 }
@@ -1211,7 +1211,7 @@ Value *IslNodeBuilder::preloadUnconditionally(isl_set *AccessRange,
   auto Name = Ptr->getName();
   auto AS = Ptr->getType()->getPointerAddressSpace();
   Ptr = Builder.CreatePointerCast(Ptr, Ty->getPointerTo(AS), Name + ".cast");
-  PreloadVal = Builder.CreateLoad(Ptr, Name + ".load");
+  PreloadVal = Builder.CreateLoad(Ty, Ptr, Name + ".load");
   if (LoadInst *PreloadInst = dyn_cast<LoadInst>(PreloadVal))
     PreloadInst->setAlignment(cast<LoadInst>(AccInst)->getAlign());
 

diff  --git a/polly/lib/CodeGen/LoopGenerators.cpp b/polly/lib/CodeGen/LoopGenerators.cpp
index fca800dd511a..702503908702 100644
--- a/polly/lib/CodeGen/LoopGenerators.cpp
+++ b/polly/lib/CodeGen/LoopGenerators.cpp
@@ -245,7 +245,8 @@ void ParallelLoopGenerator::extractValuesFromStruct(
     SetVector<Value *> OldValues, Type *Ty, Value *Struct, ValueMapT &Map) {
   for (unsigned i = 0; i < OldValues.size(); i++) {
     Value *Address = Builder.CreateStructGEP(Ty, Struct, i);
-    Value *NewValue = Builder.CreateLoad(Address);
+    Type *ElemTy = cast<GetElementPtrInst>(Address)->getResultElementType();
+    Value *NewValue = Builder.CreateLoad(ElemTy, Address);
     NewValue->setName("polly.subfunc.arg." + OldValues[i]->getName());
     Map[OldValues[i]] = NewValue;
   }

diff  --git a/polly/lib/CodeGen/LoopGeneratorsGOMP.cpp b/polly/lib/CodeGen/LoopGeneratorsGOMP.cpp
index 66ebd4dee831..294d91f2f398 100644
--- a/polly/lib/CodeGen/LoopGeneratorsGOMP.cpp
+++ b/polly/lib/CodeGen/LoopGeneratorsGOMP.cpp
@@ -142,8 +142,8 @@ ParallelLoopGeneratorGOMP::createSubFn(Value *Stride, AllocaInst *StructData,
 
   // Add code to load the iv bounds for this set of iterations.
   Builder.SetInsertPoint(PreHeaderBB);
-  Value *LB = Builder.CreateLoad(LBPtr, "polly.par.LB");
-  Value *UB = Builder.CreateLoad(UBPtr, "polly.par.UB");
+  Value *LB = Builder.CreateLoad(LongType, LBPtr, "polly.par.LB");
+  Value *UB = Builder.CreateLoad(LongType, UBPtr, "polly.par.UB");
 
   // Subtract one as the upper bound provided by OpenMP is a < comparison
   // whereas the codegenForSequential function creates a <= comparison.

diff  --git a/polly/lib/CodeGen/LoopGeneratorsKMP.cpp b/polly/lib/CodeGen/LoopGeneratorsKMP.cpp
index 1fa3f89bb005..272f8ae828af 100644
--- a/polly/lib/CodeGen/LoopGeneratorsKMP.cpp
+++ b/polly/lib/CodeGen/LoopGeneratorsKMP.cpp
@@ -181,8 +181,8 @@ ParallelLoopGeneratorKMP::createSubFn(Value *SequentialLoopStride,
                           Map);
 
   const auto Alignment = llvm::Align(is64BitArch() ? 8 : 4);
-  Value *ID =
-      Builder.CreateAlignedLoad(IDPtr, Alignment, "polly.par.global_tid");
+  Value *ID = Builder.CreateAlignedLoad(Builder.getInt32Ty(), IDPtr, Alignment,
+                                        "polly.par.global_tid");
 
   Builder.CreateAlignedStore(LB, LBPtr, Alignment);
   Builder.CreateAlignedStore(UB, UBPtr, Alignment);
@@ -223,8 +223,10 @@ ParallelLoopGeneratorKMP::createSubFn(Value *SequentialLoopStride,
       Builder.CreateCondBr(HasIteration, PreHeaderBB, ExitBB);
 
       Builder.SetInsertPoint(PreHeaderBB);
-      LB = Builder.CreateAlignedLoad(LBPtr, Alignment, "polly.indvar.LB");
-      UB = Builder.CreateAlignedLoad(UBPtr, Alignment, "polly.indvar.UB");
+      LB = Builder.CreateAlignedLoad(LongType, LBPtr, Alignment,
+                                     "polly.indvar.LB");
+      UB = Builder.CreateAlignedLoad(LongType, UBPtr, Alignment,
+                                     "polly.indvar.UB");
     }
     break;
   case OMPGeneralSchedulingType::StaticChunked:
@@ -234,11 +236,13 @@ ParallelLoopGeneratorKMP::createSubFn(Value *SequentialLoopStride,
       Builder.CreateAlignedStore(AdjustedUB, UBPtr, Alignment);
       createCallStaticInit(ID, IsLastPtr, LBPtr, UBPtr, StridePtr, ChunkSize);
 
-      Value *ChunkedStride =
-          Builder.CreateAlignedLoad(StridePtr, Alignment, "polly.kmpc.stride");
+      Value *ChunkedStride = Builder.CreateAlignedLoad(
+          LongType, StridePtr, Alignment, "polly.kmpc.stride");
 
-      LB = Builder.CreateAlignedLoad(LBPtr, Alignment, "polly.indvar.LB");
-      UB = Builder.CreateAlignedLoad(UBPtr, Alignment, "polly.indvar.UB.temp");
+      LB = Builder.CreateAlignedLoad(LongType, LBPtr, Alignment,
+                                     "polly.indvar.LB");
+      UB = Builder.CreateAlignedLoad(LongType, UBPtr, Alignment,
+                                     "polly.indvar.UB.temp");
 
       Value *UBInRange =
           Builder.CreateICmp(llvm::CmpInst::Predicate::ICMP_SLE, UB, AdjustedUB,
@@ -252,9 +256,9 @@ ParallelLoopGeneratorKMP::createSubFn(Value *SequentialLoopStride,
 
       if (Scheduling == OMPGeneralSchedulingType::StaticChunked) {
         Builder.SetInsertPoint(PreHeaderBB);
-        LB = Builder.CreateAlignedLoad(LBPtr, Alignment,
+        LB = Builder.CreateAlignedLoad(LongType, LBPtr, Alignment,
                                        "polly.indvar.LB.entry");
-        UB = Builder.CreateAlignedLoad(UBPtr, Alignment,
+        UB = Builder.CreateAlignedLoad(LongType, UBPtr, Alignment,
                                        "polly.indvar.UB.entry");
       }
 

diff  --git a/polly/lib/CodeGen/PerfMonitor.cpp b/polly/lib/CodeGen/PerfMonitor.cpp
index b452dc3bcc09..f6efc532364f 100644
--- a/polly/lib/CodeGen/PerfMonitor.cpp
+++ b/polly/lib/CodeGen/PerfMonitor.cpp
@@ -138,11 +138,12 @@ Function *PerfMonitor::insertFinalReporting() {
   // Measure current cycles and compute final timings.
   Function *RDTSCPFn = getRDTSCP();
 
+  Type *Int64Ty = Builder.getInt64Ty();
   Value *CurrentCycles =
       Builder.CreateExtractValue(Builder.CreateCall(RDTSCPFn), {0});
-  Value *CyclesStart = Builder.CreateLoad(CyclesTotalStartPtr, true);
+  Value *CyclesStart = Builder.CreateLoad(Int64Ty, CyclesTotalStartPtr, true);
   Value *CyclesTotal = Builder.CreateSub(CurrentCycles, CyclesStart);
-  Value *CyclesInScops = Builder.CreateLoad(CyclesInScopsPtr, true);
+  Value *CyclesInScops = Builder.CreateLoad(Int64Ty, CyclesInScopsPtr, true);
 
   // Print the runtime information.
   RuntimeDebugBuilder::createCPUPrinter(Builder, "Polly runtime information\n");
@@ -175,11 +176,12 @@ void PerfMonitor::AppendScopReporting() {
   Builder.SetInsertPoint(FinalStartBB);
   ReturnFromFinal->eraseFromParent();
 
+  Type *Int64Ty = Builder.getInt64Ty();
   Value *CyclesInCurrentScop =
-      Builder.CreateLoad(this->CyclesInCurrentScopPtr, true);
+      Builder.CreateLoad(Int64Ty, this->CyclesInCurrentScopPtr, true);
 
   Value *TripCountForCurrentScop =
-      Builder.CreateLoad(this->TripCountForCurrentScopPtr, true);
+      Builder.CreateLoad(Int64Ty, this->TripCountForCurrentScopPtr, true);
 
   std::string EntryName, ExitName;
   std::tie(EntryName, ExitName) = S.getEntryExitStr();
@@ -231,7 +233,8 @@ Function *PerfMonitor::insertInitFunction(Function *FinalReporting) {
   // multiple times. To avoid initializations being run multiple times (and
   // especially to avoid that atExitFn is called more than once), we bail
   // out if the initializer is run more than once.
-  Value *HasRunBefore = Builder.CreateLoad(AlreadyInitializedPtr);
+  Value *HasRunBefore =
+      Builder.CreateLoad(Builder.getInt1Ty(), AlreadyInitializedPtr);
   Builder.CreateCondBr(HasRunBefore, EarlyReturn, InitBB);
   Builder.SetInsertPoint(EarlyReturn);
   Builder.CreateRetVoid();
@@ -276,20 +279,23 @@ void PerfMonitor::insertRegionEnd(Instruction *InsertBefore) {
 
   Builder.SetInsertPoint(InsertBefore);
   Function *RDTSCPFn = getRDTSCP();
-  LoadInst *CyclesStart = Builder.CreateLoad(CyclesInScopStartPtr, true);
+  Type *Int64Ty = Builder.getInt64Ty();
+  LoadInst *CyclesStart =
+      Builder.CreateLoad(Int64Ty, CyclesInScopStartPtr, true);
   Value *CurrentCycles =
       Builder.CreateExtractValue(Builder.CreateCall(RDTSCPFn), {0});
   Value *CyclesInScop = Builder.CreateSub(CurrentCycles, CyclesStart);
-  Value *CyclesInScops = Builder.CreateLoad(CyclesInScopsPtr, true);
+  Value *CyclesInScops = Builder.CreateLoad(Int64Ty, CyclesInScopsPtr, true);
   CyclesInScops = Builder.CreateAdd(CyclesInScops, CyclesInScop);
   Builder.CreateStore(CyclesInScops, CyclesInScopsPtr, true);
 
-  Value *CyclesInCurrentScop = Builder.CreateLoad(CyclesInCurrentScopPtr, true);
+  Value *CyclesInCurrentScop =
+      Builder.CreateLoad(Int64Ty, CyclesInCurrentScopPtr, true);
   CyclesInCurrentScop = Builder.CreateAdd(CyclesInCurrentScop, CyclesInScop);
   Builder.CreateStore(CyclesInCurrentScop, CyclesInCurrentScopPtr, true);
 
   Value *TripCountForCurrentScop =
-      Builder.CreateLoad(TripCountForCurrentScopPtr, true);
+      Builder.CreateLoad(Int64Ty, TripCountForCurrentScopPtr, true);
   TripCountForCurrentScop =
       Builder.CreateAdd(TripCountForCurrentScop, Builder.getInt64(1));
   Builder.CreateStore(TripCountForCurrentScop, TripCountForCurrentScopPtr,


        


More information about the cfe-commits mailing list