Skip to content

Commit 001e18c

Browse files
committed
[NFC] clang-format SROA.cpp
1 parent 7864711 commit 001e18c

File tree

1 file changed

+48
-50
lines changed

1 file changed

+48
-50
lines changed

llvm/lib/Transforms/Scalar/SROA.cpp

Lines changed: 48 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ calculateFragment(DILocalVariable *Variable,
293293
if (!CurrentFragment) {
294294
if (auto Size = Variable->getSizeInBits()) {
295295
// Treat the current fragment as covering the whole variable.
296-
CurrentFragment = DIExpression::FragmentInfo(*Size, 0);
296+
CurrentFragment = DIExpression::FragmentInfo(*Size, 0);
297297
if (Target == CurrentFragment)
298298
return UseNoFrag;
299299
}
@@ -1213,8 +1213,9 @@ class AllocaSlices::SliceBuilder : public PtrUseVisitor<SliceBuilder> {
12131213
if (!IsOffsetKnown)
12141214
return PI.setAborted(&II);
12151215

1216-
insertUse(II, Offset, Length ? Length->getLimitedValue()
1217-
: AllocSize - Offset.getLimitedValue(),
1216+
insertUse(II, Offset,
1217+
Length ? Length->getLimitedValue()
1218+
: AllocSize - Offset.getLimitedValue(),
12181219
(bool)Length);
12191220
}
12201221

@@ -1669,7 +1670,7 @@ static void speculatePHINodeLoads(IRBuilderTy &IRB, PHINode &PN) {
16691670
}
16701671

16711672
// Inject loads into all of the pred blocks.
1672-
DenseMap<BasicBlock*, Value*> InjectedLoads;
1673+
DenseMap<BasicBlock *, Value *> InjectedLoads;
16731674
for (unsigned Idx = 0, Num = PN.getNumIncomingValues(); Idx != Num; ++Idx) {
16741675
BasicBlock *Pred = PN.getIncomingBlock(Idx);
16751676
Value *InVal = PN.getIncomingValue(Idx);
@@ -1678,7 +1679,7 @@ static void speculatePHINodeLoads(IRBuilderTy &IRB, PHINode &PN) {
16781679
// basic block, as long as the value is the same. So if we already injected
16791680
// a load in the predecessor, then we should reuse the same load for all
16801681
// duplicated entries.
1681-
if (Value* V = InjectedLoads.lookup(Pred)) {
1682+
if (Value *V = InjectedLoads.lookup(Pred)) {
16821683
NewPN->addIncoming(V, Pred);
16831684
continue;
16841685
}
@@ -2077,8 +2078,7 @@ static bool isVectorPromotionViableForSlice(Partition &P, const Slice &S,
20772078
if (BeginIndex * ElementSize != BeginOffset ||
20782079
BeginIndex >= cast<FixedVectorType>(Ty)->getNumElements())
20792080
return false;
2080-
uint64_t EndOffset =
2081-
std::min(S.endOffset(), P.endOffset()) - P.beginOffset();
2081+
uint64_t EndOffset = std::min(S.endOffset(), P.endOffset()) - P.beginOffset();
20822082
uint64_t EndIndex = EndOffset / ElementSize;
20832083
if (EndIndex * ElementSize != EndOffset ||
20842084
EndIndex > cast<FixedVectorType>(Ty)->getNumElements())
@@ -2754,8 +2754,8 @@ class AllocaSliceRewriter : public InstVisitor<AllocaSliceRewriter, bool> {
27542754
Instruction *OldUserI = cast<Instruction>(OldUse->getUser());
27552755
IRB.SetInsertPoint(OldUserI);
27562756
IRB.SetCurrentDebugLocation(OldUserI->getDebugLoc());
2757-
IRB.getInserter().SetNamePrefix(
2758-
Twine(NewAI.getName()) + "." + Twine(BeginOffset) + ".");
2757+
IRB.getInserter().SetNamePrefix(Twine(NewAI.getName()) + "." +
2758+
Twine(BeginOffset) + ".");
27592759

27602760
CanSROA &= visit(cast<Instruction>(OldUse->getUser()));
27612761
if (VecTy || IntTy)
@@ -2808,7 +2808,7 @@ class AllocaSliceRewriter : public InstVisitor<AllocaSliceRewriter, bool> {
28082808
#else
28092809
Twine()
28102810
#endif
2811-
);
2811+
);
28122812
}
28132813

28142814
/// Compute suitable alignment to access this slice of the *new*
@@ -3189,8 +3189,7 @@ class AllocaSliceRewriter : public InstVisitor<AllocaSliceRewriter, bool> {
31893189
const bool CanContinue = [&]() {
31903190
if (VecTy || IntTy)
31913191
return true;
3192-
if (BeginOffset > NewAllocaBeginOffset ||
3193-
EndOffset < NewAllocaEndOffset)
3192+
if (BeginOffset > NewAllocaBeginOffset || EndOffset < NewAllocaEndOffset)
31943193
return false;
31953194
// Length must be in range for FixedVectorType.
31963195
auto *C = cast<ConstantInt>(II.getLength());
@@ -3984,9 +3983,9 @@ class AggLoadStoreRewriter : public InstVisitor<AggLoadStoreRewriter, bool> {
39843983
if (!Sel)
39853984
return false;
39863985

3987-
LLVM_DEBUG(dbgs() << " Rewriting gep(select) -> select(gep):"
3988-
<< "\n original: " << *Sel
3989-
<< "\n " << GEPI);
3986+
LLVM_DEBUG(dbgs() << " Rewriting gep(select) -> select(gep):\n";
3987+
dbgs() << " original: " << *Sel << "\n";
3988+
dbgs() << " " << GEPI << "\n";);
39903989

39913990
auto GetNewOps = [&](Value *SelOp) {
39923991
SmallVector<Value *> NewOps;
@@ -4023,9 +4022,9 @@ class AggLoadStoreRewriter : public InstVisitor<AggLoadStoreRewriter, bool> {
40234022
Visited.insert(NSelI);
40244023
enqueueUsers(*NSelI);
40254024

4026-
LLVM_DEBUG(dbgs() << "\n to: " << *NTrue
4027-
<< "\n " << *NFalse
4028-
<< "\n " << *NSel << '\n');
4025+
LLVM_DEBUG(dbgs() << " to: " << *NTrue << "\n";
4026+
dbgs() << " " << *NFalse << "\n";
4027+
dbgs() << " " << *NSel << "\n";);
40294028

40304029
return true;
40314030
}
@@ -4037,18 +4036,17 @@ class AggLoadStoreRewriter : public InstVisitor<AggLoadStoreRewriter, bool> {
40374036

40384037
PHINode *PHI = cast<PHINode>(GEPI.getPointerOperand());
40394038
if (GEPI.getParent() != PHI->getParent() ||
4040-
llvm::any_of(PHI->incoming_values(), [](Value *In)
4041-
{ Instruction *I = dyn_cast<Instruction>(In);
4042-
return !I || isa<GetElementPtrInst>(I) || isa<PHINode>(I) ||
4043-
succ_empty(I->getParent()) ||
4044-
!I->getParent()->isLegalToHoistInto();
4045-
}))
4039+
llvm::any_of(PHI->incoming_values(), [](Value *In) {
4040+
Instruction *I = dyn_cast<Instruction>(In);
4041+
return !I || isa<GetElementPtrInst>(I) || isa<PHINode>(I) ||
4042+
succ_empty(I->getParent()) ||
4043+
!I->getParent()->isLegalToHoistInto();
4044+
}))
40464045
return false;
40474046

4048-
LLVM_DEBUG(dbgs() << " Rewriting gep(phi) -> phi(gep):"
4049-
<< "\n original: " << *PHI
4050-
<< "\n " << GEPI
4051-
<< "\n to: ");
4047+
LLVM_DEBUG(dbgs() << " Rewriting gep(phi) -> phi(gep):\n";
4048+
dbgs() << " original: " << *PHI << "\n";
4049+
dbgs() << " " << GEPI << "\n";);
40524050

40534051
SmallVector<Value *, 4> Index(GEPI.indices());
40544052
bool IsInBounds = GEPI.isInBounds();
@@ -4078,8 +4076,10 @@ class AggLoadStoreRewriter : public InstVisitor<AggLoadStoreRewriter, bool> {
40784076
Visited.insert(NewPN);
40794077
enqueueUsers(*NewPN);
40804078

4081-
LLVM_DEBUG(for (Value *In : NewPN->incoming_values())
4082-
dbgs() << "\n " << *In;
4079+
LLVM_DEBUG(dbgs() << " to: ";
4080+
for (Value *In
4081+
: NewPN->incoming_values()) dbgs()
4082+
<< "\n " << *In;
40834083
dbgs() << "\n " << *NewPN << '\n');
40844084

40854085
return true;
@@ -4089,8 +4089,7 @@ class AggLoadStoreRewriter : public InstVisitor<AggLoadStoreRewriter, bool> {
40894089
if (foldGEPSelect(GEPI))
40904090
return true;
40914091

4092-
if (isa<PHINode>(GEPI.getPointerOperand()) &&
4093-
foldGEPPhi(GEPI))
4092+
if (isa<PHINode>(GEPI.getPointerOperand()) && foldGEPPhi(GEPI))
40944093
return true;
40954094

40964095
enqueueUsers(GEPI);
@@ -4162,17 +4161,17 @@ static Type *getTypePartition(const DataLayout &DL, Type *Ty, uint64_t Offset,
41624161
return nullptr;
41634162

41644163
if (isa<ArrayType>(Ty) || isa<VectorType>(Ty)) {
4165-
Type *ElementTy;
4166-
uint64_t TyNumElements;
4167-
if (auto *AT = dyn_cast<ArrayType>(Ty)) {
4168-
ElementTy = AT->getElementType();
4169-
TyNumElements = AT->getNumElements();
4170-
} else {
4171-
// FIXME: This isn't right for vectors with non-byte-sized or
4172-
// non-power-of-two sized elements.
4173-
auto *VT = cast<FixedVectorType>(Ty);
4174-
ElementTy = VT->getElementType();
4175-
TyNumElements = VT->getNumElements();
4164+
Type *ElementTy;
4165+
uint64_t TyNumElements;
4166+
if (auto *AT = dyn_cast<ArrayType>(Ty)) {
4167+
ElementTy = AT->getElementType();
4168+
TyNumElements = AT->getNumElements();
4169+
} else {
4170+
// FIXME: This isn't right for vectors with non-byte-sized or
4171+
// non-power-of-two sized elements.
4172+
auto *VT = cast<FixedVectorType>(Ty);
4173+
ElementTy = VT->getElementType();
4174+
TyNumElements = VT->getNumElements();
41764175
}
41774176
uint64_t ElementSize = DL.getTypeAllocSize(ElementTy).getFixedValue();
41784177
uint64_t NumSkippedElements = Offset / ElementSize;
@@ -4853,9 +4852,8 @@ AllocaInst *SROA::rewritePartition(AllocaInst &AI, AllocaSlices &AS,
48534852
++NumNewAllocas;
48544853
}
48554854

4856-
LLVM_DEBUG(dbgs() << "Rewriting alloca partition "
4857-
<< "[" << P.beginOffset() << "," << P.endOffset()
4858-
<< ") to: " << *NewAI << "\n");
4855+
LLVM_DEBUG(dbgs() << "Rewriting alloca partition " << "[" << P.beginOffset()
4856+
<< "," << P.endOffset() << ") to: " << *NewAI << "\n");
48594857

48604858
// Track the high watermark on the worklist as it is only relevant for
48614859
// promoted allocas. We will reset it to this point if the alloca is not in
@@ -5040,8 +5038,7 @@ bool SROA::splitAlloca(AllocaInst &AI, AllocaSlices &AS) {
50405038
IsSorted = false;
50415039
}
50425040
}
5043-
}
5044-
else {
5041+
} else {
50455042
// We only allow whole-alloca splittable loads and stores
50465043
// for a large alloca to avoid creating too large BitVector.
50475044
for (Slice &S : AS) {
@@ -5069,7 +5066,7 @@ bool SROA::splitAlloca(AllocaInst &AI, AllocaSlices &AS) {
50695066
uint64_t Offset;
50705067
uint64_t Size;
50715068
Fragment(AllocaInst *AI, uint64_t O, uint64_t S)
5072-
: Alloca(AI), Offset(O), Size(S) {}
5069+
: Alloca(AI), Offset(O), Size(S) {}
50735070
};
50745071
SmallVector<Fragment, 4> Fragments;
50755072

@@ -5083,7 +5080,8 @@ bool SROA::splitAlloca(AllocaInst &AI, AllocaSlices &AS) {
50835080
DL.getTypeSizeInBits(NewAI->getAllocatedType()).getFixedValue();
50845081
// Don't include any padding.
50855082
uint64_t Size = std::min(AllocaSize, P.size() * SizeOfByte);
5086-
Fragments.push_back(Fragment(NewAI, P.beginOffset() * SizeOfByte, Size));
5083+
Fragments.push_back(
5084+
Fragment(NewAI, P.beginOffset() * SizeOfByte, Size));
50875085
}
50885086
}
50895087
++NumPartitions;

0 commit comments

Comments
 (0)