Skip to content

Commit 5a81a60

Browse files
committed
[NFC] Remove more calls to getAlignment()
These are deprecated and should be replaced with getAlign(). Some of these asserts don't do anything because Load/Store/AllocaInst never have a 0 align value.
1 parent d558336 commit 5a81a60

File tree

8 files changed

+14
-19
lines changed

8 files changed

+14
-19
lines changed

llvm/lib/Analysis/MemDerefPrinter.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ bool MemDerefPrinter::runOnFunction(Function &F) {
5959
Value *PO = LI->getPointerOperand();
6060
if (isDereferenceablePointer(PO, LI->getType(), DL))
6161
Deref.push_back(PO);
62-
if (isDereferenceableAndAlignedPointer(
63-
PO, LI->getType(), MaybeAlign(LI->getAlignment()), DL))
62+
if (isDereferenceableAndAlignedPointer(PO, LI->getType(),
63+
MaybeAlign(LI->getAlign()), DL))
6464
DerefAndAligned.insert(PO);
6565
}
6666
}
@@ -94,8 +94,8 @@ PreservedAnalyses MemDerefPrinterPass::run(Function &F,
9494
Value *PO = LI->getPointerOperand();
9595
if (isDereferenceablePointer(PO, LI->getType(), DL))
9696
Deref.push_back(PO);
97-
if (isDereferenceableAndAlignedPointer(
98-
PO, LI->getType(), MaybeAlign(LI->getAlignment()), DL))
97+
if (isDereferenceableAndAlignedPointer(PO, LI->getType(),
98+
MaybeAlign(LI->getAlign()), DL))
9999
DerefAndAligned.insert(PO);
100100
}
101101
}

llvm/lib/Analysis/ValueTracking.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4678,8 +4678,8 @@ bool llvm::isSafeToSpeculativelyExecute(const Value *V,
46784678
return false;
46794679
const DataLayout &DL = LI->getModule()->getDataLayout();
46804680
return isDereferenceableAndAlignedPointer(
4681-
LI->getPointerOperand(), LI->getType(), MaybeAlign(LI->getAlignment()),
4682-
DL, CtxI, DT, TLI);
4681+
LI->getPointerOperand(), LI->getType(), MaybeAlign(LI->getAlign()), DL,
4682+
CtxI, DT, TLI);
46834683
}
46844684
case Instruction::Call: {
46854685
auto *CI = cast<const CallInst>(Inst);

llvm/lib/IR/Instructions.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,8 +1410,6 @@ bool AllocaInst::isStaticAlloca() const {
14101410
void LoadInst::AssertOK() {
14111411
assert(getOperand(0)->getType()->isPointerTy() &&
14121412
"Ptr must have pointer type.");
1413-
assert(!(isAtomic() && getAlignment() == 0) &&
1414-
"Alignment required for atomic load");
14151413
}
14161414

14171415
static Align computeLoadStoreDefaultAlign(Type *Ty, BasicBlock *BB) {
@@ -1490,8 +1488,6 @@ void StoreInst::AssertOK() {
14901488
assert(cast<PointerType>(getOperand(1)->getType())
14911489
->isOpaqueOrPointeeTypeMatches(getOperand(0)->getType()) &&
14921490
"Ptr must be a pointer to Val type!");
1493-
assert(!(isAtomic() && getAlignment() == 0) &&
1494-
"Alignment required for atomic store");
14951491
}
14961492

14971493
StoreInst::StoreInst(Value *val, Value *addr, Instruction *InsertBefore)

llvm/lib/Target/AArch64/AArch64StackTagging.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ Instruction *AArch64StackTagging::insertBaseTaggedPointer(
488488

489489
void AArch64StackTagging::alignAndPadAlloca(AllocaInfo &Info) {
490490
const Align NewAlignment =
491-
max(MaybeAlign(Info.AI->getAlignment()), kTagGranuleSize);
491+
max(MaybeAlign(Info.AI->getAlign()), kTagGranuleSize);
492492
Info.AI->setAlignment(NewAlignment);
493493

494494
uint64_t Size = Info.AI->getAllocationSizeInBits(*DL).getValue() / 8;

llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,6 @@ static Instruction *unpackLoadToAggregate(InstCombinerImpl &IC, LoadInst &LI) {
640640
return nullptr;
641641

642642
StringRef Name = LI.getName();
643-
assert(LI.getAlignment() && "Alignment must be set at this point");
644643

645644
if (auto *ST = dyn_cast<StructType>(T)) {
646645
// If the struct only have one element, we unpack.

llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1220,7 +1220,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
12201220
Value *Shadow = SI->isAtomic() ? getCleanShadow(Val) : getShadow(Val);
12211221
Value *ShadowPtr, *OriginPtr;
12221222
Type *ShadowTy = Shadow->getType();
1223-
const Align Alignment = assumeAligned(SI->getAlignment());
1223+
const Align Alignment = SI->getAlign();
12241224
const Align OriginAlignment = std::max(kMinOriginAlignment, Alignment);
12251225
std::tie(ShadowPtr, OriginPtr) =
12261226
getShadowOriginPtr(Addr, IRB, ShadowTy, Alignment, /*isStore*/ true);

llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -805,9 +805,9 @@ bool LoopIdiomRecognize::processLoopStores(SmallVectorImpl<StoreInst *> &SL,
805805
Type *IntIdxTy = DL->getIndexType(StorePtr->getType());
806806
const SCEV *StoreSizeSCEV = SE->getConstant(IntIdxTy, StoreSize);
807807
if (processLoopStridedStore(StorePtr, StoreSizeSCEV,
808-
MaybeAlign(HeadStore->getAlignment()),
809-
StoredVal, HeadStore, AdjacentStores, StoreEv,
810-
BECount, IsNegStride)) {
808+
MaybeAlign(HeadStore->getAlign()), StoredVal,
809+
HeadStore, AdjacentStores, StoreEv, BECount,
810+
IsNegStride)) {
811811
TransformedStores.insert(AdjacentStores.begin(), AdjacentStores.end());
812812
Changed = true;
813813
}

llvm/lib/Transforms/Vectorize/VectorCombine.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -989,9 +989,9 @@ bool VectorCombine::scalarizeLoadExtract(Instruction &I) {
989989
if (!FixedVT)
990990
return false;
991991

992-
InstructionCost OriginalCost = TTI.getMemoryOpCost(
993-
Instruction::Load, LI->getType(), Align(LI->getAlignment()),
994-
LI->getPointerAddressSpace());
992+
InstructionCost OriginalCost =
993+
TTI.getMemoryOpCost(Instruction::Load, LI->getType(), LI->getAlign(),
994+
LI->getPointerAddressSpace());
995995
InstructionCost ScalarizedCost = 0;
996996

997997
Instruction *LastCheckedInst = LI;

0 commit comments

Comments
 (0)