Skip to content

Commit 14359ef

Browse files
committed
[opaque pointer types] Pass value type to LoadInst creation.
This cleans up all LoadInst creation in LLVM to explicitly pass the value type rather than deriving it from the pointer's element-type. Differential Revision: https://reviews.llvm.org/D57172 llvm-svn: 352911
1 parent d9e85a0 commit 14359ef

File tree

78 files changed

+459
-363
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+459
-363
lines changed

llvm/lib/Bitcode/Reader/BitcodeReader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4404,7 +4404,7 @@ Error BitcodeReader::parseFunctionBody(Function *F) {
44044404
unsigned Align;
44054405
if (Error Err = parseAlignmentValue(Record[OpNum], Align))
44064406
return Err;
4407-
I = new LoadInst(Op, "", Record[OpNum+1], Align, Ordering, SSID);
4407+
I = new LoadInst(Ty, Op, "", Record[OpNum + 1], Align, Ordering, SSID);
44084408

44094409
InstructionList.push_back(I);
44104410
break;

llvm/lib/CodeGen/AtomicExpandPass.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ LoadInst *AtomicExpand::convertAtomicLoadToIntegerType(LoadInst *LI) {
381381
Addr->getType()->getPointerAddressSpace());
382382
Value *NewAddr = Builder.CreateBitCast(Addr, PT);
383383

384-
auto *NewLI = Builder.CreateLoad(NewAddr);
384+
auto *NewLI = Builder.CreateLoad(NewTy, NewAddr);
385385
NewLI->setAlignment(LI->getAlignment());
386386
NewLI->setVolatile(LI->isVolatile());
387387
NewLI->setAtomic(LI->getOrdering(), LI->getSyncScopeID());
@@ -1769,8 +1769,8 @@ bool AtomicExpand::expandAtomicOpToLibcall(
17691769
// from call}
17701770
Type *FinalResultTy = I->getType();
17711771
Value *V = UndefValue::get(FinalResultTy);
1772-
Value *ExpectedOut =
1773-
Builder.CreateAlignedLoad(AllocaCASExpected, AllocaAlignment);
1772+
Value *ExpectedOut = Builder.CreateAlignedLoad(
1773+
CASExpected->getType(), AllocaCASExpected, AllocaAlignment);
17741774
Builder.CreateLifetimeEnd(AllocaCASExpected_i8, SizeVal64);
17751775
V = Builder.CreateInsertValue(V, ExpectedOut, 0);
17761776
V = Builder.CreateInsertValue(V, Result, 1);
@@ -1780,7 +1780,8 @@ bool AtomicExpand::expandAtomicOpToLibcall(
17801780
if (UseSizedLibcall)
17811781
V = Builder.CreateBitOrPointerCast(Result, I->getType());
17821782
else {
1783-
V = Builder.CreateAlignedLoad(AllocaResult, AllocaAlignment);
1783+
V = Builder.CreateAlignedLoad(I->getType(), AllocaResult,
1784+
AllocaAlignment);
17841785
Builder.CreateLifetimeEnd(AllocaResult_i8, SizeVal64);
17851786
}
17861787
I->replaceAllUsesWith(V);

llvm/lib/CodeGen/GCRootLowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ bool LowerIntrinsics::DoLowering(Function &F, GCStrategy &S) {
213213
}
214214
case Intrinsic::gcread: {
215215
// Replace a read barrier with a simple load.
216-
Value *Ld = new LoadInst(CI->getArgOperand(1), "", CI);
216+
Value *Ld = new LoadInst(CI->getType(), CI->getArgOperand(1), "", CI);
217217
Ld->takeName(CI);
218218
CI->replaceAllUsesWith(Ld);
219219
CI->eraseFromParent();

llvm/lib/CodeGen/InterleavedLoadCombinePass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1218,7 +1218,7 @@ bool InterleavedLoadCombineImpl::combine(std::list<VectorInfo> &InterleavedLoad,
12181218
"interleaved.wide.ptrcast");
12191219

12201220
// Create the wide load and update the MemorySSA.
1221-
auto LI = Builder.CreateAlignedLoad(CI, InsertionPoint->getAlignment(),
1221+
auto LI = Builder.CreateAlignedLoad(ILTy, CI, InsertionPoint->getAlignment(),
12221222
"interleaved.wide.load");
12231223
auto MSSAU = MemorySSAUpdater(&MSSA);
12241224
MemoryUse *MSSALoad = cast<MemoryUse>(MSSAU.createMemoryAccessBefore(

llvm/lib/CodeGen/PreISelIntrinsicLowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ static bool lowerLoadRelative(Function &F) {
4444
Value *OffsetPtr =
4545
B.CreateGEP(Int8Ty, CI->getArgOperand(0), CI->getArgOperand(1));
4646
Value *OffsetPtrI32 = B.CreateBitCast(OffsetPtr, Int32PtrTy);
47-
Value *OffsetI32 = B.CreateAlignedLoad(OffsetPtrI32, 4);
47+
Value *OffsetI32 = B.CreateAlignedLoad(Int32Ty, OffsetPtrI32, 4);
4848

4949
Value *ResultPtr = B.CreateGEP(Int8Ty, CI->getArgOperand(0), OffsetI32);
5050

llvm/lib/CodeGen/SafeStack.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ Value *SafeStack::getStackGuard(IRBuilder<> &IRB, Function &F) {
371371
if (!StackGuardVar)
372372
StackGuardVar =
373373
F.getParent()->getOrInsertGlobal("__stack_chk_guard", StackPtrTy);
374-
return IRB.CreateLoad(StackGuardVar, "StackGuard");
374+
return IRB.CreateLoad(StackPtrTy, StackGuardVar, "StackGuard");
375375
}
376376

377377
void SafeStack::findInsts(Function &F,
@@ -452,7 +452,8 @@ SafeStack::createStackRestorePoints(IRBuilder<> &IRB, Function &F,
452452
++NumUnsafeStackRestorePoints;
453453

454454
IRB.SetInsertPoint(I->getNextNode());
455-
Value *CurrentTop = DynamicTop ? IRB.CreateLoad(DynamicTop) : StaticTop;
455+
Value *CurrentTop =
456+
DynamicTop ? IRB.CreateLoad(StackPtrTy, DynamicTop) : StaticTop;
456457
IRB.CreateStore(CurrentTop, UnsafeStackPtr);
457458
}
458459

@@ -461,7 +462,7 @@ SafeStack::createStackRestorePoints(IRBuilder<> &IRB, Function &F,
461462

462463
void SafeStack::checkStackGuard(IRBuilder<> &IRB, Function &F, ReturnInst &RI,
463464
AllocaInst *StackGuardSlot, Value *StackGuard) {
464-
Value *V = IRB.CreateLoad(StackGuardSlot);
465+
Value *V = IRB.CreateLoad(StackPtrTy, StackGuardSlot);
465466
Value *Cmp = IRB.CreateICmpNE(StackGuard, V);
466467

467468
auto SuccessProb = BranchProbabilityInfo::getBranchProbStackProtector(true);
@@ -659,7 +660,8 @@ void SafeStack::moveDynamicAllocasToUnsafeStack(
659660
uint64_t TySize = DL.getTypeAllocSize(Ty);
660661
Value *Size = IRB.CreateMul(ArraySize, ConstantInt::get(IntPtrTy, TySize));
661662

662-
Value *SP = IRB.CreatePtrToInt(IRB.CreateLoad(UnsafeStackPtr), IntPtrTy);
663+
Value *SP = IRB.CreatePtrToInt(IRB.CreateLoad(StackPtrTy, UnsafeStackPtr),
664+
IntPtrTy);
663665
SP = IRB.CreateSub(SP, Size);
664666

665667
// Align the SP value to satisfy the AllocaInst, type and stack alignments.
@@ -697,7 +699,7 @@ void SafeStack::moveDynamicAllocasToUnsafeStack(
697699

698700
if (II->getIntrinsicID() == Intrinsic::stacksave) {
699701
IRBuilder<> IRB(II);
700-
Instruction *LI = IRB.CreateLoad(UnsafeStackPtr);
702+
Instruction *LI = IRB.CreateLoad(StackPtrTy, UnsafeStackPtr);
701703
LI->takeName(II);
702704
II->replaceAllUsesWith(LI);
703705
II->eraseFromParent();
@@ -792,7 +794,7 @@ bool SafeStack::run() {
792794
// Load the current stack pointer (we'll also use it as a base pointer).
793795
// FIXME: use a dedicated register for it ?
794796
Instruction *BasePointer =
795-
IRB.CreateLoad(UnsafeStackPtr, false, "unsafe_stack_ptr");
797+
IRB.CreateLoad(StackPtrTy, UnsafeStackPtr, false, "unsafe_stack_ptr");
796798
assert(BasePointer->getType() == StackPtrTy);
797799

798800
AllocaInst *StackGuardSlot = nullptr;

llvm/lib/CodeGen/ScalarizeMaskedMemIntrin.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ static void scalarizeMaskedLoad(CallInst *CI) {
143143

144144
// Short-cut if the mask is all-true.
145145
if (isa<Constant>(Mask) && cast<Constant>(Mask)->isAllOnesValue()) {
146-
Value *NewI = Builder.CreateAlignedLoad(Ptr, AlignVal);
146+
Value *NewI = Builder.CreateAlignedLoad(VecType, Ptr, AlignVal);
147147
CI->replaceAllUsesWith(NewI);
148148
CI->eraseFromParent();
149149
return;
@@ -166,7 +166,7 @@ static void scalarizeMaskedLoad(CallInst *CI) {
166166
continue;
167167
Value *Gep =
168168
Builder.CreateInBoundsGEP(EltTy, FirstEltPtr, Builder.getInt32(Idx));
169-
LoadInst *Load = Builder.CreateAlignedLoad(Gep, AlignVal);
169+
LoadInst *Load = Builder.CreateAlignedLoad(EltTy, Gep, AlignVal);
170170
VResult =
171171
Builder.CreateInsertElement(VResult, Load, Builder.getInt32(Idx));
172172
}
@@ -198,7 +198,7 @@ static void scalarizeMaskedLoad(CallInst *CI) {
198198

199199
Value *Gep =
200200
Builder.CreateInBoundsGEP(EltTy, FirstEltPtr, Builder.getInt32(Idx));
201-
LoadInst *Load = Builder.CreateAlignedLoad(Gep, AlignVal);
201+
LoadInst *Load = Builder.CreateAlignedLoad(EltTy, Gep, AlignVal);
202202
Value *NewVResult = Builder.CreateInsertElement(VResult, Load,
203203
Builder.getInt32(Idx));
204204

@@ -366,6 +366,7 @@ static void scalarizeMaskedGather(CallInst *CI) {
366366
Value *Src0 = CI->getArgOperand(3);
367367

368368
VectorType *VecType = cast<VectorType>(CI->getType());
369+
Type *EltTy = VecType->getElementType();
369370

370371
IRBuilder<> Builder(CI->getContext());
371372
Instruction *InsertPt = CI;
@@ -387,7 +388,7 @@ static void scalarizeMaskedGather(CallInst *CI) {
387388
Value *Ptr = Builder.CreateExtractElement(Ptrs, Builder.getInt32(Idx),
388389
"Ptr" + Twine(Idx));
389390
LoadInst *Load =
390-
Builder.CreateAlignedLoad(Ptr, AlignVal, "Load" + Twine(Idx));
391+
Builder.CreateAlignedLoad(EltTy, Ptr, AlignVal, "Load" + Twine(Idx));
391392
VResult = Builder.CreateInsertElement(
392393
VResult, Load, Builder.getInt32(Idx), "Res" + Twine(Idx));
393394
}
@@ -418,7 +419,7 @@ static void scalarizeMaskedGather(CallInst *CI) {
418419
Value *Ptr = Builder.CreateExtractElement(Ptrs, Builder.getInt32(Idx),
419420
"Ptr" + Twine(Idx));
420421
LoadInst *Load =
421-
Builder.CreateAlignedLoad(Ptr, AlignVal, "Load" + Twine(Idx));
422+
Builder.CreateAlignedLoad(EltTy, Ptr, AlignVal, "Load" + Twine(Idx));
422423
Value *NewVResult = Builder.CreateInsertElement(VResult, Load,
423424
Builder.getInt32(Idx),
424425
"Res" + Twine(Idx));

llvm/lib/CodeGen/ShadowStackGCLowering.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,8 @@ bool ShadowStackGCLowering::runOnFunction(Function &F) {
312312
AtEntry.SetInsertPoint(IP->getParent(), IP);
313313

314314
// Initialize the map pointer and load the current head of the shadow stack.
315-
Instruction *CurrentHead = AtEntry.CreateLoad(Head, "gc_currhead");
315+
Instruction *CurrentHead =
316+
AtEntry.CreateLoad(StackEntryTy->getPointerTo(), Head, "gc_currhead");
316317
Instruction *EntryMapPtr = CreateGEP(Context, AtEntry, ConcreteStackEntryTy,
317318
StackEntry, 0, 1, "gc_frame.map");
318319
AtEntry.CreateStore(FrameMap, EntryMapPtr);
@@ -353,7 +354,8 @@ bool ShadowStackGCLowering::runOnFunction(Function &F) {
353354
Instruction *EntryNextPtr2 =
354355
CreateGEP(Context, *AtExit, ConcreteStackEntryTy, StackEntry, 0, 0,
355356
"gc_frame.next");
356-
Value *SavedHead = AtExit->CreateLoad(EntryNextPtr2, "gc_savedhead");
357+
Value *SavedHead = AtExit->CreateLoad(StackEntryTy->getPointerTo(),
358+
EntryNextPtr2, "gc_savedhead");
357359
AtExit->CreateStore(SavedHead, Head);
358360
}
359361

llvm/lib/CodeGen/SjLjEHPrepare.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,14 +189,16 @@ Value *SjLjEHPrepare::setupFunctionContext(Function &F,
189189
Builder.CreateConstGEP2_32(FunctionContextTy, FuncCtx, 0, 2, "__data");
190190

191191
// The exception values come back in context->__data[0].
192+
Type *Int32Ty = Type::getInt32Ty(F.getContext());
192193
Value *ExceptionAddr = Builder.CreateConstGEP2_32(doubleUnderDataTy, FCData,
193194
0, 0, "exception_gep");
194-
Value *ExnVal = Builder.CreateLoad(ExceptionAddr, true, "exn_val");
195+
Value *ExnVal = Builder.CreateLoad(Int32Ty, ExceptionAddr, true, "exn_val");
195196
ExnVal = Builder.CreateIntToPtr(ExnVal, Builder.getInt8PtrTy());
196197

197198
Value *SelectorAddr = Builder.CreateConstGEP2_32(doubleUnderDataTy, FCData,
198199
0, 1, "exn_selector_gep");
199-
Value *SelVal = Builder.CreateLoad(SelectorAddr, true, "exn_selector_val");
200+
Value *SelVal =
201+
Builder.CreateLoad(Int32Ty, SelectorAddr, true, "exn_selector_val");
200202

201203
substituteLPadValues(LPI, ExnVal, SelVal);
202204
}

llvm/lib/CodeGen/StackProtector.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ static Value *getStackGuard(const TargetLoweringBase *TLI, Module *M,
322322
IRBuilder<> &B,
323323
bool *SupportsSelectionDAGSP = nullptr) {
324324
if (Value *Guard = TLI->getIRStackGuard(B))
325-
return B.CreateLoad(Guard, true, "StackGuard");
325+
return B.CreateLoad(B.getInt8PtrTy(), Guard, true, "StackGuard");
326326

327327
// Use SelectionDAG SSP handling, since there isn't an IR guard.
328328
//
@@ -417,7 +417,7 @@ bool StackProtector::InsertStackProtectors() {
417417
// Generate the function-based epilogue instrumentation.
418418
// The target provides a guard check function, generate a call to it.
419419
IRBuilder<> B(RI);
420-
LoadInst *Guard = B.CreateLoad(AI, true, "Guard");
420+
LoadInst *Guard = B.CreateLoad(B.getInt8PtrTy(), AI, true, "Guard");
421421
CallInst *Call = B.CreateCall(GuardCheck, {Guard});
422422
Call->setAttributes(GuardCheck->getAttributes());
423423
Call->setCallingConv(GuardCheck->getCallingConv());
@@ -472,7 +472,7 @@ bool StackProtector::InsertStackProtectors() {
472472
// Generate the stack protector instructions in the old basic block.
473473
IRBuilder<> B(BB);
474474
Value *Guard = getStackGuard(TLI, M, B);
475-
LoadInst *LI2 = B.CreateLoad(AI, true);
475+
LoadInst *LI2 = B.CreateLoad(B.getInt8PtrTy(), AI, true);
476476
Value *Cmp = B.CreateICmpEQ(Guard, LI2);
477477
auto SuccessProb =
478478
BranchProbabilityInfo::getBranchProbStackProtector(true);

llvm/lib/CodeGen/WasmEHPrepare.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,8 @@ void WasmEHPrepare::prepareEHPad(BasicBlock *BB, bool NeedLSDA,
344344
PersCI->setDoesNotThrow();
345345

346346
// Pseudocode: int selector = __wasm.landingpad_context.selector;
347-
Instruction *Selector = IRB.CreateLoad(SelectorField, "selector");
347+
Instruction *Selector =
348+
IRB.CreateLoad(IRB.getInt32Ty(), SelectorField, "selector");
348349

349350
// Replace the return value from wasm.get.ehselector() with the selector value
350351
// loaded from __wasm_lpad_context.selector.

llvm/lib/CodeGen/WinEHPrepare.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,7 +1079,8 @@ AllocaInst *WinEHPrepare::insertPHILoads(PHINode *PN, Function &F) {
10791079
SpillSlot = new AllocaInst(PN->getType(), DL->getAllocaAddrSpace(), nullptr,
10801080
Twine(PN->getName(), ".wineh.spillslot"),
10811081
&F.getEntryBlock().front());
1082-
Value *V = new LoadInst(SpillSlot, Twine(PN->getName(), ".wineh.reload"),
1082+
Value *V = new LoadInst(PN->getType(), SpillSlot,
1083+
Twine(PN->getName(), ".wineh.reload"),
10831084
&*PHIBlock->getFirstInsertionPt());
10841085
PN->replaceAllUsesWith(V);
10851086
return SpillSlot;
@@ -1221,13 +1222,15 @@ void WinEHPrepare::replaceUseWithLoad(Value *V, Use &U, AllocaInst *&SpillSlot,
12211222
Value *&Load = Loads[IncomingBlock];
12221223
// Insert the load into the predecessor block
12231224
if (!Load)
1224-
Load = new LoadInst(SpillSlot, Twine(V->getName(), ".wineh.reload"),
1225+
Load = new LoadInst(V->getType(), SpillSlot,
1226+
Twine(V->getName(), ".wineh.reload"),
12251227
/*Volatile=*/false, IncomingBlock->getTerminator());
12261228

12271229
U.set(Load);
12281230
} else {
12291231
// Reload right before the old use.
1230-
auto *Load = new LoadInst(SpillSlot, Twine(V->getName(), ".wineh.reload"),
1232+
auto *Load = new LoadInst(V->getType(), SpillSlot,
1233+
Twine(V->getName(), ".wineh.reload"),
12311234
/*Volatile=*/false, UsingInst);
12321235
U.set(Load);
12331236
}

llvm/lib/ExecutionEngine/Orc/IndirectionUtils.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,14 +235,13 @@ void makeStub(Function &F, Value &ImplPointer) {
235235
assert(F.isDeclaration() && "Can't turn a definition into a stub.");
236236
assert(F.getParent() && "Function isn't in a module.");
237237
Module &M = *F.getParent();
238-
FunctionType *FTy = F.getFunctionType();
239238
BasicBlock *EntryBlock = BasicBlock::Create(M.getContext(), "entry", &F);
240239
IRBuilder<> Builder(EntryBlock);
241-
LoadInst *ImplAddr = Builder.CreateLoad(&ImplPointer);
240+
LoadInst *ImplAddr = Builder.CreateLoad(F.getType(), &ImplPointer);
242241
std::vector<Value*> CallArgs;
243242
for (auto &A : F.args())
244243
CallArgs.push_back(&A);
245-
CallInst *Call = Builder.CreateCall(FTy, ImplAddr, CallArgs);
244+
CallInst *Call = Builder.CreateCall(F.getFunctionType(), ImplAddr, CallArgs);
246245
Call->setTailCall();
247246
Call->setAttributes(F.getAttributes());
248247
if (F.getReturnType()->isVoidTy())

llvm/lib/FuzzMutate/RandomIRBuilder.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ Value *RandomIRBuilder::newSource(BasicBlock &BB, ArrayRef<Instruction *> Insts,
5353
IP = ++I->getIterator();
5454
assert(IP != BB.end() && "guaranteed by the findPointer");
5555
}
56-
auto *NewLoad = new LoadInst(Ptr, "L", &*IP);
56+
auto *NewLoad = new LoadInst(
57+
cast<PointerType>(Ptr->getType())->getElementType(), Ptr, "L", &*IP);
5758

5859
// Only sample this load if it really matches the descriptor
5960
if (Pred.matches(Srcs, NewLoad))

llvm/lib/IR/AutoUpgrade.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,16 +1162,16 @@ static Value *UpgradeMaskedStore(IRBuilder<> &Builder,
11621162
static Value *UpgradeMaskedLoad(IRBuilder<> &Builder,
11631163
Value *Ptr, Value *Passthru, Value *Mask,
11641164
bool Aligned) {
1165+
Type *ValTy = Passthru->getType();
11651166
// Cast the pointer to the right type.
1166-
Ptr = Builder.CreateBitCast(Ptr,
1167-
llvm::PointerType::getUnqual(Passthru->getType()));
1167+
Ptr = Builder.CreateBitCast(Ptr, llvm::PointerType::getUnqual(ValTy));
11681168
unsigned Align =
11691169
Aligned ? cast<VectorType>(Passthru->getType())->getBitWidth() / 8 : 1;
11701170

11711171
// If the mask is all ones just emit a regular store.
11721172
if (const auto *C = dyn_cast<Constant>(Mask))
11731173
if (C->isAllOnesValue())
1174-
return Builder.CreateAlignedLoad(Ptr, Align);
1174+
return Builder.CreateAlignedLoad(ValTy, Ptr, Align);
11751175

11761176
// Convert the mask from an integer type to a vector of i1.
11771177
unsigned NumElts = Passthru->getType()->getVectorNumElements();
@@ -2199,7 +2199,7 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
21992199
Type *VT = VectorType::get(EltTy, NumSrcElts);
22002200
Value *Op = Builder.CreatePointerCast(CI->getArgOperand(0),
22012201
PointerType::getUnqual(VT));
2202-
Value *Load = Builder.CreateAlignedLoad(Op, 1);
2202+
Value *Load = Builder.CreateAlignedLoad(VT, Op, 1);
22032203
if (NumSrcElts == 2)
22042204
Rep = Builder.CreateShuffleVector(Load, UndefValue::get(Load->getType()),
22052205
{ 0, 1, 0, 1 });
@@ -2945,7 +2945,7 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
29452945
// Convert the type of the pointer to a pointer to the stored type.
29462946
Value *BC =
29472947
Builder.CreateBitCast(Ptr, PointerType::getUnqual(VTy), "cast");
2948-
LoadInst *LI = Builder.CreateAlignedLoad(BC, VTy->getBitWidth() / 8);
2948+
LoadInst *LI = Builder.CreateAlignedLoad(VTy, BC, VTy->getBitWidth() / 8);
29492949
LI->setMetadata(M->getMDKindID("nontemporal"), Node);
29502950
Rep = LI;
29512951
} else if (IsX86 &&

llvm/lib/Target/AArch64/AArch64PromoteConstant.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,8 @@ void AArch64PromoteConstant::insertDefinitions(Function &F,
493493
for (const auto &IPI : InsertPts) {
494494
// Create the load of the global variable.
495495
IRBuilder<> Builder(IPI.first);
496-
LoadInst *LoadedCst = Builder.CreateLoad(&PromotedGV);
496+
LoadInst *LoadedCst =
497+
Builder.CreateLoad(PromotedGV.getValueType(), &PromotedGV);
497498
LLVM_DEBUG(dbgs() << "**********\n");
498499
LLVM_DEBUG(dbgs() << "New def: ");
499500
LLVM_DEBUG(LoadedCst->print(dbgs()));

llvm/lib/Target/AMDGPU/AMDGPUCodeGenPrepare.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,7 @@ bool AMDGPUCodeGenPrepare::visitLoadInst(LoadInst &I) {
806806
Type *I32Ty = Builder.getInt32Ty();
807807
Type *PT = PointerType::get(I32Ty, I.getPointerAddressSpace());
808808
Value *BitCast= Builder.CreateBitCast(I.getPointerOperand(), PT);
809-
LoadInst *WidenLoad = Builder.CreateLoad(BitCast);
809+
LoadInst *WidenLoad = Builder.CreateLoad(I32Ty, BitCast);
810810
WidenLoad->copyMetadata(I);
811811

812812
// If we have range metadata, we need to convert the type, and not make

llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1357,12 +1357,12 @@ bool AMDGPULibCalls::fold_sincos(CallInst *CI, IRBuilder<> &B,
13571357
if (!isSin) { // CI->cos, UI->sin
13581358
B.SetInsertPoint(&*ItOld);
13591359
UI->replaceAllUsesWith(&*Call);
1360-
Instruction *Reload = B.CreateLoad(Alloc);
1360+
Instruction *Reload = B.CreateLoad(Alloc->getAllocatedType(), Alloc);
13611361
CI->replaceAllUsesWith(Reload);
13621362
UI->eraseFromParent();
13631363
CI->eraseFromParent();
13641364
} else { // CI->sin, UI->cos
1365-
Instruction *Reload = B.CreateLoad(Alloc);
1365+
Instruction *Reload = B.CreateLoad(Alloc->getAllocatedType(), Alloc);
13661366
UI->replaceAllUsesWith(Reload);
13671367
CI->replaceAllUsesWith(Call);
13681368
UI->eraseFromParent();

0 commit comments

Comments
 (0)