Skip to content

Commit 11aa370

Browse files
committed
StoreInst should store Align, not MaybeAlign
This is D77454, except for stores. All the infrastructure work was done for loads, so the remaining changes necessary are relatively small. Differential Revision: https://reviews.llvm.org/D79968
1 parent 18a855d commit 11aa370

File tree

58 files changed

+355
-362
lines changed

Some content is hidden

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

58 files changed

+355
-362
lines changed

clang/lib/CodeGen/CGExpr.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ Address CodeGenFunction::CreateDefaultAlignTempAlloca(llvm::Type *Ty,
126126

127127
void CodeGenFunction::InitTempAlloca(Address Var, llvm::Value *Init) {
128128
assert(isa<llvm::AllocaInst>(Var.getPointer()));
129-
auto *Store = new llvm::StoreInst(Init, Var.getPointer());
130-
Store->setAlignment(Var.getAlignment().getAsAlign());
129+
auto *Store = new llvm::StoreInst(Init, Var.getPointer(), /*volatile*/ false,
130+
Var.getAlignment().getAsAlign());
131131
llvm::BasicBlock *Block = AllocaInsertPt->getParent();
132132
Block->getInstList().insertAfter(AllocaInsertPt->getIterator(), Store);
133133
}

llvm/examples/ThinLtoJIT/ThinLtoInstrumentationLayer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ void ThinLtoInstrumentationLayer::compileFunctionReachedFlagSetter(
191191
new StoreInst(ConstantInt::get(Int64Ty, 0),
192192
B.CreateIntToPtr(ConstantInt::get(Int64Ty, SyncFlagAddr),
193193
Int64Ty->getPointerTo()),
194-
IsVolatile, MaybeAlign(64), AtomicOrdering::Release,
194+
IsVolatile, Align(64), AtomicOrdering::Release,
195195
SyncScope::System, NoInsertBefore));
196196
}
197197
}

llvm/include/llvm/IR/Instructions.h

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -306,17 +306,16 @@ class StoreInst : public Instruction {
306306
public:
307307
StoreInst(Value *Val, Value *Ptr, Instruction *InsertBefore);
308308
StoreInst(Value *Val, Value *Ptr, BasicBlock *InsertAtEnd);
309-
StoreInst(Value *Val, Value *Ptr, bool isVolatile = false,
310-
Instruction *InsertBefore = nullptr);
309+
StoreInst(Value *Val, Value *Ptr, bool isVolatile, Instruction *InsertBefore);
311310
StoreInst(Value *Val, Value *Ptr, bool isVolatile, BasicBlock *InsertAtEnd);
312-
StoreInst(Value *Val, Value *Ptr, bool isVolatile, MaybeAlign Align,
311+
StoreInst(Value *Val, Value *Ptr, bool isVolatile, Align Align,
313312
Instruction *InsertBefore = nullptr);
314-
StoreInst(Value *Val, Value *Ptr, bool isVolatile, MaybeAlign Align,
313+
StoreInst(Value *Val, Value *Ptr, bool isVolatile, Align Align,
315314
BasicBlock *InsertAtEnd);
316-
StoreInst(Value *Val, Value *Ptr, bool isVolatile, MaybeAlign Align,
315+
StoreInst(Value *Val, Value *Ptr, bool isVolatile, Align Align,
317316
AtomicOrdering Order, SyncScope::ID SSID = SyncScope::System,
318317
Instruction *InsertBefore = nullptr);
319-
StoreInst(Value *Val, Value *Ptr, bool isVolatile, MaybeAlign Align,
318+
StoreInst(Value *Val, Value *Ptr, bool isVolatile, Align Align,
320319
AtomicOrdering Order, SyncScope::ID SSID, BasicBlock *InsertAtEnd);
321320

322321
// allocate space for exactly two operands
@@ -339,17 +338,13 @@ class StoreInst : public Instruction {
339338
/// Return the alignment of the access that is being performed
340339
/// FIXME: Remove this function once transition to Align is over.
341340
/// Use getAlign() instead.
342-
unsigned getAlignment() const {
343-
if (const auto MA = getAlign())
344-
return MA->value();
345-
return 0;
346-
}
341+
unsigned getAlignment() const { return getAlign().value(); }
347342

348-
MaybeAlign getAlign() const {
349-
return decodeMaybeAlign((getSubclassDataFromInstruction() >> 1) & 31);
343+
Align getAlign() const {
344+
return *decodeMaybeAlign((getSubclassDataFromInstruction() >> 1) & 31);
350345
}
351346

352-
void setAlignment(MaybeAlign Alignment);
347+
void setAlignment(Align Alignment);
353348

354349
/// Returns the ordering constraint of this store instruction.
355350
AtomicOrdering getOrdering() const {

llvm/lib/AsmParser/LLParser.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7112,8 +7112,12 @@ int LLParser::ParseStore(Instruction *&Inst, PerFunctionState &PFS) {
71127112
if (Ordering == AtomicOrdering::Acquire ||
71137113
Ordering == AtomicOrdering::AcquireRelease)
71147114
return Error(Loc, "atomic store cannot use Acquire ordering");
7115+
if (!Alignment && !Val->getType()->isSized())
7116+
return Error(Loc, "storing unsized types is not allowed");
7117+
if (!Alignment)
7118+
Alignment = M->getDataLayout().getABITypeAlign(Val->getType());
71157119

7116-
Inst = new StoreInst(Val, Ptr, isVolatile, Alignment, Ordering, SSID);
7120+
Inst = new StoreInst(Val, Ptr, isVolatile, *Alignment, Ordering, SSID);
71177121
return AteExtraComma ? InstExtraComma : InstNormal;
71187122
}
71197123

llvm/lib/Bitcode/Reader/BitcodeReader.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4922,7 +4922,9 @@ Error BitcodeReader::parseFunctionBody(Function *F) {
49224922
MaybeAlign Align;
49234923
if (Error Err = parseAlignmentValue(Record[OpNum], Align))
49244924
return Err;
4925-
I = new StoreInst(Val, Ptr, Record[OpNum + 1], Align);
4925+
if (!Align)
4926+
Align = TheModule->getDataLayout().getABITypeAlign(Val->getType());
4927+
I = new StoreInst(Val, Ptr, Record[OpNum + 1], *Align);
49264928
InstructionList.push_back(I);
49274929
break;
49284930
}
@@ -4955,7 +4957,9 @@ Error BitcodeReader::parseFunctionBody(Function *F) {
49554957
MaybeAlign Align;
49564958
if (Error Err = parseAlignmentValue(Record[OpNum], Align))
49574959
return Err;
4958-
I = new StoreInst(Val, Ptr, Record[OpNum + 1], Align, Ordering, SSID);
4960+
if (!Align)
4961+
return error("Alignment missing from atomic store");
4962+
I = new StoreInst(Val, Ptr, Record[OpNum + 1], *Align, Ordering, SSID);
49594963
InstructionList.push_back(I);
49604964
break;
49614965
}

llvm/lib/CodeGen/GCRootLowering.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,9 @@ static bool InsertRootInitializers(Function &F, ArrayRef<AllocaInst *> Roots) {
160160

161161
for (AllocaInst *Root : Roots)
162162
if (!InitedRoots.count(Root)) {
163-
StoreInst *SI = new StoreInst(
163+
new StoreInst(
164164
ConstantPointerNull::get(cast<PointerType>(Root->getAllocatedType())),
165-
Root);
166-
SI->insertAfter(Root);
165+
Root, Root->getNextNode());
167166
MadeChange = true;
168167
}
169168

llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,10 +244,8 @@ int IRTranslator::getOrCreateFrameIndex(const AllocaInst &AI) {
244244
}
245245

246246
Align IRTranslator::getMemOpAlign(const Instruction &I) {
247-
if (const StoreInst *SI = dyn_cast<StoreInst>(&I)) {
248-
Type *ValTy = SI->getValueOperand()->getType();
249-
return SI->getAlign().getValueOr(DL->getABITypeAlign(ValTy));
250-
}
247+
if (const StoreInst *SI = dyn_cast<StoreInst>(&I))
248+
return SI->getAlign();
251249
if (const LoadInst *LI = dyn_cast<LoadInst>(&I)) {
252250
return DL->getValueOrABITypeAlignment(LI->getAlign(), LI->getType());
253251
}

llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4616,7 +4616,7 @@ void SelectionDAGBuilder::visitAtomicStore(const StoreInst &I) {
46164616
MachineFunction &MF = DAG.getMachineFunction();
46174617
MachineMemOperand *MMO = MF.getMachineMemOperand(
46184618
MachinePointerInfo(I.getPointerOperand()), Flags, MemVT.getStoreSize(),
4619-
*I.getAlign(), AAMDNodes(), nullptr, SSID, Ordering);
4619+
I.getAlign(), AAMDNodes(), nullptr, SSID, Ordering);
46204620

46214621
SDValue Val = getValue(I.getValueOperand());
46224622
if (Val.getValueType() != MemVT)

llvm/lib/CodeGen/SjLjEHPrepare.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,8 +466,7 @@ bool SjLjEHPrepare::setupEntryBlockAndCallSites(Function &F) {
466466
}
467467
Instruction *StackAddr = CallInst::Create(StackAddrFn, "sp");
468468
StackAddr->insertAfter(&I);
469-
Instruction *StoreStackAddr = new StoreInst(StackAddr, StackPtr, true);
470-
StoreStackAddr->insertAfter(StackAddr);
469+
new StoreInst(StackAddr, StackPtr, true, StackAddr->getNextNode());
471470
}
472471
}
473472

llvm/lib/IR/Core.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2025,7 +2025,7 @@ void LLVMSetAlignment(LLVMValueRef V, unsigned Bytes) {
20252025
else if (LoadInst *LI = dyn_cast<LoadInst>(P))
20262026
LI->setAlignment(Align(Bytes));
20272027
else if (StoreInst *SI = dyn_cast<StoreInst>(P))
2028-
SI->setAlignment(MaybeAlign(Bytes));
2028+
SI->setAlignment(Align(Bytes));
20292029
else
20302030
llvm_unreachable(
20312031
"only GlobalValue, AllocaInst, LoadInst and StoreInst have alignment");

llvm/lib/IR/Instructions.cpp

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,13 +1326,13 @@ void LoadInst::AssertOK() {
13261326
"Alignment required for atomic load");
13271327
}
13281328

1329-
Align computeLoadAlign(Type *Ty, BasicBlock *BB) {
1329+
Align computeLoadStoreDefaultAlign(Type *Ty, BasicBlock *BB) {
13301330
const DataLayout &DL = BB->getModule()->getDataLayout();
13311331
return DL.getABITypeAlign(Ty);
13321332
}
13331333

1334-
Align computeLoadAlign(Type *Ty, Instruction *I) {
1335-
return computeLoadAlign(Ty, I->getParent());
1334+
Align computeLoadStoreDefaultAlign(Type *Ty, Instruction *I) {
1335+
return computeLoadStoreDefaultAlign(Ty, I->getParent());
13361336
}
13371337

13381338
LoadInst::LoadInst(Type *Ty, Value *Ptr, const Twine &Name,
@@ -1345,13 +1345,13 @@ LoadInst::LoadInst(Type *Ty, Value *Ptr, const Twine &Name,
13451345

13461346
LoadInst::LoadInst(Type *Ty, Value *Ptr, const Twine &Name, bool isVolatile,
13471347
Instruction *InsertBef)
1348-
: LoadInst(Ty, Ptr, Name, isVolatile, computeLoadAlign(Ty, InsertBef),
1349-
InsertBef) {}
1348+
: LoadInst(Ty, Ptr, Name, isVolatile,
1349+
computeLoadStoreDefaultAlign(Ty, InsertBef), InsertBef) {}
13501350

13511351
LoadInst::LoadInst(Type *Ty, Value *Ptr, const Twine &Name, bool isVolatile,
13521352
BasicBlock *InsertAE)
1353-
: LoadInst(Ty, Ptr, Name, isVolatile, computeLoadAlign(Ty, InsertAE),
1354-
InsertAE) {}
1353+
: LoadInst(Ty, Ptr, Name, isVolatile,
1354+
computeLoadStoreDefaultAlign(Ty, InsertAE), InsertAE) {}
13551355

13561356
LoadInst::LoadInst(Type *Ty, Value *Ptr, const Twine &Name, bool isVolatile,
13571357
Align Align, Instruction *InsertBef)
@@ -1418,23 +1418,27 @@ StoreInst::StoreInst(Value *val, Value *addr, BasicBlock *InsertAtEnd)
14181418

14191419
StoreInst::StoreInst(Value *val, Value *addr, bool isVolatile,
14201420
Instruction *InsertBefore)
1421-
: StoreInst(val, addr, isVolatile, /*Align=*/None, InsertBefore) {}
1421+
: StoreInst(val, addr, isVolatile,
1422+
computeLoadStoreDefaultAlign(val->getType(), InsertBefore),
1423+
InsertBefore) {}
14221424

14231425
StoreInst::StoreInst(Value *val, Value *addr, bool isVolatile,
14241426
BasicBlock *InsertAtEnd)
1425-
: StoreInst(val, addr, isVolatile, /*Align=*/None, InsertAtEnd) {}
1427+
: StoreInst(val, addr, isVolatile,
1428+
computeLoadStoreDefaultAlign(val->getType(), InsertAtEnd),
1429+
InsertAtEnd) {}
14261430

1427-
StoreInst::StoreInst(Value *val, Value *addr, bool isVolatile, MaybeAlign Align,
1431+
StoreInst::StoreInst(Value *val, Value *addr, bool isVolatile, Align Align,
14281432
Instruction *InsertBefore)
14291433
: StoreInst(val, addr, isVolatile, Align, AtomicOrdering::NotAtomic,
14301434
SyncScope::System, InsertBefore) {}
14311435

1432-
StoreInst::StoreInst(Value *val, Value *addr, bool isVolatile, MaybeAlign Align,
1436+
StoreInst::StoreInst(Value *val, Value *addr, bool isVolatile, Align Align,
14331437
BasicBlock *InsertAtEnd)
14341438
: StoreInst(val, addr, isVolatile, Align, AtomicOrdering::NotAtomic,
14351439
SyncScope::System, InsertAtEnd) {}
14361440

1437-
StoreInst::StoreInst(Value *val, Value *addr, bool isVolatile, MaybeAlign Align,
1441+
StoreInst::StoreInst(Value *val, Value *addr, bool isVolatile, Align Align,
14381442
AtomicOrdering Order, SyncScope::ID SSID,
14391443
Instruction *InsertBefore)
14401444
: Instruction(Type::getVoidTy(val->getContext()), Store,
@@ -1448,7 +1452,7 @@ StoreInst::StoreInst(Value *val, Value *addr, bool isVolatile, MaybeAlign Align,
14481452
AssertOK();
14491453
}
14501454

1451-
StoreInst::StoreInst(Value *val, Value *addr, bool isVolatile, MaybeAlign Align,
1455+
StoreInst::StoreInst(Value *val, Value *addr, bool isVolatile, Align Align,
14521456
AtomicOrdering Order, SyncScope::ID SSID,
14531457
BasicBlock *InsertAtEnd)
14541458
: Instruction(Type::getVoidTy(val->getContext()), Store,
@@ -1462,8 +1466,8 @@ StoreInst::StoreInst(Value *val, Value *addr, bool isVolatile, MaybeAlign Align,
14621466
AssertOK();
14631467
}
14641468

1465-
void StoreInst::setAlignment(MaybeAlign Alignment) {
1466-
assert((!Alignment || *Alignment <= MaximumAlignment) &&
1469+
void StoreInst::setAlignment(Align Alignment) {
1470+
assert(Alignment <= MaximumAlignment &&
14671471
"Alignment is greater than MaximumAlignment!");
14681472
setInstructionSubclassData((getSubclassDataFromInstruction() & ~(31 << 1)) |
14691473
(encode(Alignment) << 1));
@@ -4248,9 +4252,8 @@ LoadInst *LoadInst::cloneImpl() const {
42484252
}
42494253

42504254
StoreInst *StoreInst::cloneImpl() const {
4251-
return new StoreInst(getOperand(0), getOperand(1), isVolatile(),
4252-
MaybeAlign(getAlignment()), getOrdering(),
4253-
getSyncScopeID());
4255+
return new StoreInst(getOperand(0), getOperand(1), isVolatile(), getAlign(),
4256+
getOrdering(), getSyncScopeID());
42544257
}
42554258

42564259
AtomicCmpXchgInst *AtomicCmpXchgInst::cloneImpl() const {

llvm/lib/Target/AMDGPU/AMDGPUPrintfRuntimeBinding.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -387,9 +387,7 @@ bool AMDGPUPrintfRuntimeBinding::lowerPrintfForGpu(
387387
Value *id_gep_cast =
388388
new BitCastInst(BufferIdx, idPointer, "PrintBuffIdCast", Brnch);
389389

390-
StoreInst *stbuff =
391-
new StoreInst(ConstantInt::get(I32Ty, UniqID), id_gep_cast);
392-
stbuff->insertBefore(Brnch); // to Remove unused variable warning
390+
new StoreInst(ConstantInt::get(I32Ty, UniqID), id_gep_cast, Brnch);
393391

394392
SmallVector<Value *, 2> FourthIdxList;
395393
ConstantInt *fourInt =

llvm/lib/Target/NVPTX/NVPTXLowerAggrCopies.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ bool NVPTXLowerAggrCopies::runOnFunction(Function &F) {
114114
/* SrcAddr */ SrcAddr, /* DstAddr */ DstAddr,
115115
/* CopyLen */ CopyLen,
116116
/* SrcAlign */ LI->getAlign(),
117-
/* DestAlign */ SI->getAlign().valueOrOne(),
117+
/* DestAlign */ SI->getAlign(),
118118
/* SrcIsVolatile */ LI->isVolatile(),
119119
/* DstIsVolatile */ SI->isVolatile(), TTI);
120120

llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ Instruction *InstCombiner::SimplifyAnyMemTransfer(AnyMemTransferInst *MI) {
160160
// into libcall in CodeGen. This is not evident performance gain so disable
161161
// it now.
162162
if (isa<AtomicMemTransferInst>(MI))
163-
if (CopyDstAlign < Size || CopySrcAlign < Size)
163+
if (*CopyDstAlign < Size || *CopySrcAlign < Size)
164164
return nullptr;
165165

166166
// Use an integer load+store unless we can find something better.
@@ -207,8 +207,7 @@ Instruction *InstCombiner::SimplifyAnyMemTransfer(AnyMemTransferInst *MI) {
207207

208208
StoreInst *S = Builder.CreateStore(L, Dest);
209209
// Alignment from the mem intrinsic will be better, so use it.
210-
S->setAlignment(
211-
MaybeAlign(CopyDstAlign)); // FIXME: Check if we can use Align instead.
210+
S->setAlignment(*CopyDstAlign);
212211
if (CopyMD)
213212
S->setMetadata(LLVMContext::MD_tbaa, CopyMD);
214213
if (LoopMemParallelMD)
@@ -1144,8 +1143,7 @@ Instruction *InstCombiner::simplifyMaskedStore(IntrinsicInst &II) {
11441143
// If the mask is all ones, this is a plain vector store of the 1st argument.
11451144
if (ConstMask->isAllOnesValue()) {
11461145
Value *StorePtr = II.getArgOperand(1);
1147-
MaybeAlign Alignment(
1148-
cast<ConstantInt>(II.getArgOperand(2))->getZExtValue());
1146+
Align Alignment(cast<ConstantInt>(II.getArgOperand(2))->getZExtValue());
11491147
return new StoreInst(II.getArgOperand(0), StorePtr, false, Alignment);
11501148
}
11511149

@@ -2482,7 +2480,7 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) {
24822480
Type *OpPtrTy =
24832481
PointerType::getUnqual(II->getArgOperand(0)->getType());
24842482
Value *Ptr = Builder.CreateBitCast(II->getArgOperand(1), OpPtrTy);
2485-
return new StoreInst(II->getArgOperand(0), Ptr);
2483+
return new StoreInst(II->getArgOperand(0), Ptr, false, Align(16));
24862484
}
24872485
break;
24882486
case Intrinsic::ppc_vsx_stxvw4x:
@@ -2524,7 +2522,7 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) {
25242522
Value *TOp = Builder.CreateFPTrunc(II->getArgOperand(0), VTy);
25252523
Type *OpPtrTy = PointerType::getUnqual(VTy);
25262524
Value *Ptr = Builder.CreateBitCast(II->getArgOperand(1), OpPtrTy);
2527-
return new StoreInst(TOp, Ptr);
2525+
return new StoreInst(TOp, Ptr, false, Align(16));
25282526
}
25292527
break;
25302528
case Intrinsic::ppc_qpx_qvstfd:
@@ -2534,7 +2532,7 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) {
25342532
Type *OpPtrTy =
25352533
PointerType::getUnqual(II->getArgOperand(0)->getType());
25362534
Value *Ptr = Builder.CreateBitCast(II->getArgOperand(1), OpPtrTy);
2537-
return new StoreInst(II->getArgOperand(0), Ptr);
2535+
return new StoreInst(II->getArgOperand(0), Ptr, false, Align(32));
25382536
}
25392537
break;
25402538

llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1571,9 +1571,9 @@ bool InstCombiner::mergeStoreIntoSuccessor(StoreInst &SI) {
15711571

15721572
// Advance to a place where it is safe to insert the new store and insert it.
15731573
BBI = DestBB->getFirstInsertionPt();
1574-
StoreInst *NewSI = new StoreInst(MergedVal, SI.getOperand(1), SI.isVolatile(),
1575-
MaybeAlign(SI.getAlignment()),
1576-
SI.getOrdering(), SI.getSyncScopeID());
1574+
StoreInst *NewSI =
1575+
new StoreInst(MergedVal, SI.getOperand(1), SI.isVolatile(), SI.getAlign(),
1576+
SI.getOrdering(), SI.getSyncScopeID());
15771577
InsertNewInstBefore(NewSI, *BBI);
15781578
NewSI->setDebugLoc(MergedLoc);
15791579

llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1332,9 +1332,8 @@ static bool eliminateDeadStores(BasicBlock &BB, AliasAnalysis *AA,
13321332

13331333
auto *SI = new StoreInst(
13341334
ConstantInt::get(Earlier->getValueOperand()->getType(), Merged),
1335-
Earlier->getPointerOperand(), false,
1336-
MaybeAlign(Earlier->getAlignment()), Earlier->getOrdering(),
1337-
Earlier->getSyncScopeID(), DepWrite);
1335+
Earlier->getPointerOperand(), false, Earlier->getAlign(),
1336+
Earlier->getOrdering(), Earlier->getSyncScopeID(), DepWrite);
13381337

13391338
unsigned MDToKeep[] = {LLVMContext::MD_dbg, LLVMContext::MD_tbaa,
13401339
LLVMContext::MD_alias_scope,

llvm/lib/Transforms/Scalar/GVNHoist.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -894,9 +894,8 @@ class GVNHoist {
894894
std::min(ReplacementLoad->getAlign(), cast<LoadInst>(I)->getAlign()));
895895
++NumLoadsRemoved;
896896
} else if (auto *ReplacementStore = dyn_cast<StoreInst>(Repl)) {
897-
ReplacementStore->setAlignment(
898-
MaybeAlign(std::min(ReplacementStore->getAlignment(),
899-
cast<StoreInst>(I)->getAlignment())));
897+
ReplacementStore->setAlignment(std::min(ReplacementStore->getAlign(),
898+
cast<StoreInst>(I)->getAlign()));
900899
++NumStoresRemoved;
901900
} else if (auto *ReplacementAlloca = dyn_cast<AllocaInst>(Repl)) {
902901
ReplacementAlloca->setAlignment(

0 commit comments

Comments
 (0)