@@ -293,7 +293,7 @@ calculateFragment(DILocalVariable *Variable,
293
293
if (!CurrentFragment) {
294
294
if (auto Size = Variable->getSizeInBits ()) {
295
295
// Treat the current fragment as covering the whole variable.
296
- CurrentFragment = DIExpression::FragmentInfo (*Size, 0 );
296
+ CurrentFragment = DIExpression::FragmentInfo (*Size, 0 );
297
297
if (Target == CurrentFragment)
298
298
return UseNoFrag;
299
299
}
@@ -1213,8 +1213,9 @@ class AllocaSlices::SliceBuilder : public PtrUseVisitor<SliceBuilder> {
1213
1213
if (!IsOffsetKnown)
1214
1214
return PI.setAborted (&II);
1215
1215
1216
- insertUse (II, Offset, Length ? Length->getLimitedValue ()
1217
- : AllocSize - Offset.getLimitedValue (),
1216
+ insertUse (II, Offset,
1217
+ Length ? Length->getLimitedValue ()
1218
+ : AllocSize - Offset.getLimitedValue (),
1218
1219
(bool )Length);
1219
1220
}
1220
1221
@@ -1669,7 +1670,7 @@ static void speculatePHINodeLoads(IRBuilderTy &IRB, PHINode &PN) {
1669
1670
}
1670
1671
1671
1672
// Inject loads into all of the pred blocks.
1672
- DenseMap<BasicBlock*, Value*> InjectedLoads;
1673
+ DenseMap<BasicBlock *, Value *> InjectedLoads;
1673
1674
for (unsigned Idx = 0 , Num = PN.getNumIncomingValues (); Idx != Num; ++Idx) {
1674
1675
BasicBlock *Pred = PN.getIncomingBlock (Idx);
1675
1676
Value *InVal = PN.getIncomingValue (Idx);
@@ -1678,7 +1679,7 @@ static void speculatePHINodeLoads(IRBuilderTy &IRB, PHINode &PN) {
1678
1679
// basic block, as long as the value is the same. So if we already injected
1679
1680
// a load in the predecessor, then we should reuse the same load for all
1680
1681
// duplicated entries.
1681
- if (Value* V = InjectedLoads.lookup (Pred)) {
1682
+ if (Value * V = InjectedLoads.lookup (Pred)) {
1682
1683
NewPN->addIncoming (V, Pred);
1683
1684
continue ;
1684
1685
}
@@ -2077,8 +2078,7 @@ static bool isVectorPromotionViableForSlice(Partition &P, const Slice &S,
2077
2078
if (BeginIndex * ElementSize != BeginOffset ||
2078
2079
BeginIndex >= cast<FixedVectorType>(Ty)->getNumElements ())
2079
2080
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 ();
2082
2082
uint64_t EndIndex = EndOffset / ElementSize;
2083
2083
if (EndIndex * ElementSize != EndOffset ||
2084
2084
EndIndex > cast<FixedVectorType>(Ty)->getNumElements ())
@@ -2754,8 +2754,8 @@ class AllocaSliceRewriter : public InstVisitor<AllocaSliceRewriter, bool> {
2754
2754
Instruction *OldUserI = cast<Instruction>(OldUse->getUser ());
2755
2755
IRB.SetInsertPoint (OldUserI);
2756
2756
IRB.SetCurrentDebugLocation (OldUserI->getDebugLoc ());
2757
- IRB.getInserter ().SetNamePrefix (
2758
- Twine (NewAI. getName ()) + " . " + Twine (BeginOffset) + " ." );
2757
+ IRB.getInserter ().SetNamePrefix (Twine (NewAI. getName ()) + " . " +
2758
+ Twine (BeginOffset) + " ." );
2759
2759
2760
2760
CanSROA &= visit (cast<Instruction>(OldUse->getUser ()));
2761
2761
if (VecTy || IntTy)
@@ -2808,7 +2808,7 @@ class AllocaSliceRewriter : public InstVisitor<AllocaSliceRewriter, bool> {
2808
2808
#else
2809
2809
Twine ()
2810
2810
#endif
2811
- );
2811
+ );
2812
2812
}
2813
2813
2814
2814
// / Compute suitable alignment to access this slice of the *new*
@@ -3189,8 +3189,7 @@ class AllocaSliceRewriter : public InstVisitor<AllocaSliceRewriter, bool> {
3189
3189
const bool CanContinue = [&]() {
3190
3190
if (VecTy || IntTy)
3191
3191
return true ;
3192
- if (BeginOffset > NewAllocaBeginOffset ||
3193
- EndOffset < NewAllocaEndOffset)
3192
+ if (BeginOffset > NewAllocaBeginOffset || EndOffset < NewAllocaEndOffset)
3194
3193
return false ;
3195
3194
// Length must be in range for FixedVectorType.
3196
3195
auto *C = cast<ConstantInt>(II.getLength ());
@@ -3984,9 +3983,9 @@ class AggLoadStoreRewriter : public InstVisitor<AggLoadStoreRewriter, bool> {
3984
3983
if (!Sel)
3985
3984
return false ;
3986
3985
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 " ; );
3990
3989
3991
3990
auto GetNewOps = [&](Value *SelOp) {
3992
3991
SmallVector<Value *> NewOps;
@@ -4023,9 +4022,9 @@ class AggLoadStoreRewriter : public InstVisitor<AggLoadStoreRewriter, bool> {
4023
4022
Visited.insert (NSelI);
4024
4023
enqueueUsers (*NSelI);
4025
4024
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 " ; );
4029
4028
4030
4029
return true ;
4031
4030
}
@@ -4037,18 +4036,17 @@ class AggLoadStoreRewriter : public InstVisitor<AggLoadStoreRewriter, bool> {
4037
4036
4038
4037
PHINode *PHI = cast<PHINode>(GEPI.getPointerOperand ());
4039
4038
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
+ }))
4046
4045
return false ;
4047
4046
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 " ;);
4052
4050
4053
4051
SmallVector<Value *, 4 > Index (GEPI.indices ());
4054
4052
bool IsInBounds = GEPI.isInBounds ();
@@ -4078,8 +4076,10 @@ class AggLoadStoreRewriter : public InstVisitor<AggLoadStoreRewriter, bool> {
4078
4076
Visited.insert (NewPN);
4079
4077
enqueueUsers (*NewPN);
4080
4078
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;
4083
4083
dbgs () << " \n " << *NewPN << ' \n ' );
4084
4084
4085
4085
return true ;
@@ -4089,8 +4089,7 @@ class AggLoadStoreRewriter : public InstVisitor<AggLoadStoreRewriter, bool> {
4089
4089
if (foldGEPSelect (GEPI))
4090
4090
return true ;
4091
4091
4092
- if (isa<PHINode>(GEPI.getPointerOperand ()) &&
4093
- foldGEPPhi (GEPI))
4092
+ if (isa<PHINode>(GEPI.getPointerOperand ()) && foldGEPPhi (GEPI))
4094
4093
return true ;
4095
4094
4096
4095
enqueueUsers (GEPI);
@@ -4162,17 +4161,17 @@ static Type *getTypePartition(const DataLayout &DL, Type *Ty, uint64_t Offset,
4162
4161
return nullptr ;
4163
4162
4164
4163
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 ();
4176
4175
}
4177
4176
uint64_t ElementSize = DL.getTypeAllocSize (ElementTy).getFixedValue ();
4178
4177
uint64_t NumSkippedElements = Offset / ElementSize;
@@ -4853,9 +4852,8 @@ AllocaInst *SROA::rewritePartition(AllocaInst &AI, AllocaSlices &AS,
4853
4852
++NumNewAllocas;
4854
4853
}
4855
4854
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 " );
4859
4857
4860
4858
// Track the high watermark on the worklist as it is only relevant for
4861
4859
// 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) {
5040
5038
IsSorted = false ;
5041
5039
}
5042
5040
}
5043
- }
5044
- else {
5041
+ } else {
5045
5042
// We only allow whole-alloca splittable loads and stores
5046
5043
// for a large alloca to avoid creating too large BitVector.
5047
5044
for (Slice &S : AS) {
@@ -5069,7 +5066,7 @@ bool SROA::splitAlloca(AllocaInst &AI, AllocaSlices &AS) {
5069
5066
uint64_t Offset;
5070
5067
uint64_t Size;
5071
5068
Fragment (AllocaInst *AI, uint64_t O, uint64_t S)
5072
- : Alloca(AI), Offset(O), Size(S) {}
5069
+ : Alloca(AI), Offset(O), Size(S) {}
5073
5070
};
5074
5071
SmallVector<Fragment, 4 > Fragments;
5075
5072
@@ -5083,7 +5080,8 @@ bool SROA::splitAlloca(AllocaInst &AI, AllocaSlices &AS) {
5083
5080
DL.getTypeSizeInBits (NewAI->getAllocatedType ()).getFixedValue ();
5084
5081
// Don't include any padding.
5085
5082
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));
5087
5085
}
5088
5086
}
5089
5087
++NumPartitions;
0 commit comments