@@ -100,7 +100,7 @@ using OffsetAndArgPart = std::pair<int64_t, ArgPart>;
100
100
101
101
static Value *createByteGEP (IRBuilderBase &IRB, const DataLayout &DL,
102
102
Value *Ptr, Type *ResElemTy, int64_t Offset) {
103
- // For non-opaque pointers, try create a "nice" GEP if possible, otherwise
103
+ // For non-opaque pointers, try to create a "nice" GEP if possible, otherwise
104
104
// fall back to an i8 GEP to a specific offset.
105
105
unsigned AddrSpace = Ptr->getType ()->getPointerAddressSpace ();
106
106
APInt OrigOffset (DL.getIndexTypeSizeInBits (Ptr->getType ()), Offset);
@@ -207,7 +207,7 @@ static Function *doPromotion(
207
207
208
208
// The new function will have the !dbg metadata copied from the original
209
209
// function. The original function may not be deleted, and dbg metadata need
210
- // to be unique so we need to drop it.
210
+ // to be unique, so we need to drop it.
211
211
F->setSubprogram (nullptr );
212
212
213
213
LLVM_DEBUG (dbgs () << " ARG PROMOTION: Promoting to:" << *NF << " \n "
@@ -235,7 +235,7 @@ static Function *doPromotion(
235
235
236
236
// Loop over the operands, inserting GEP and loads in the caller as
237
237
// appropriate.
238
- auto AI = CB.arg_begin ();
238
+ auto * AI = CB.arg_begin ();
239
239
ArgNo = 0 ;
240
240
for (Function::arg_iterator I = F->arg_begin (), E = F->arg_end (); I != E;
241
241
++I, ++AI, ++ArgNo)
@@ -250,15 +250,15 @@ static Function *doPromotion(
250
250
ConstantInt::get (Type::getInt32Ty (F->getContext ()), 0 ), nullptr };
251
251
const StructLayout *SL = DL.getStructLayout (STy);
252
252
Align StructAlign = *I->getParamAlign ();
253
- for (unsigned i = 0 , e = STy->getNumElements (); i != e ; ++i ) {
254
- Idxs[1 ] = ConstantInt::get (Type::getInt32Ty (F->getContext ()), i );
253
+ for (unsigned J = 0 , Elems = STy->getNumElements (); J != Elems ; ++J ) {
254
+ Idxs[1 ] = ConstantInt::get (Type::getInt32Ty (F->getContext ()), J );
255
255
auto *Idx =
256
- IRB.CreateGEP (STy, *AI, Idxs, (*AI)->getName () + " ." + Twine (i ));
256
+ IRB.CreateGEP (STy, *AI, Idxs, (*AI)->getName () + " ." + Twine (J ));
257
257
// TODO: Tell AA about the new values?
258
258
Align Alignment =
259
- commonAlignment (StructAlign, SL->getElementOffset (i ));
259
+ commonAlignment (StructAlign, SL->getElementOffset (J ));
260
260
Args.push_back (IRB.CreateAlignedLoad (
261
- STy->getElementType (i ), Idx, Alignment, Idx->getName () + " .val" ));
261
+ STy->getElementType (J ), Idx, Alignment, Idx->getName () + " .val" ));
262
262
ArgAttrVec.push_back (AttributeSet ());
263
263
}
264
264
} else if (!I->use_empty ()) {
@@ -355,13 +355,13 @@ static Function *doPromotion(
355
355
nullptr };
356
356
const StructLayout *SL = DL.getStructLayout (STy);
357
357
358
- for (unsigned i = 0 , e = STy->getNumElements (); i != e ; ++i ) {
359
- Idxs[1 ] = ConstantInt::get (Type::getInt32Ty (F->getContext ()), i );
358
+ for (unsigned J = 0 , Elems = STy->getNumElements (); J != Elems ; ++J ) {
359
+ Idxs[1 ] = ConstantInt::get (Type::getInt32Ty (F->getContext ()), J );
360
360
Value *Idx = GetElementPtrInst::Create (
361
- AgTy, TheAlloca, Idxs, TheAlloca->getName () + " ." + Twine (i ),
361
+ AgTy, TheAlloca, Idxs, TheAlloca->getName () + " ." + Twine (J ),
362
362
InsertPt);
363
- I2->setName (Arg.getName () + " ." + Twine (i ));
364
- Align Alignment = commonAlignment (StructAlign, SL->getElementOffset (i ));
363
+ I2->setName (Arg.getName () + " ." + Twine (J ));
364
+ Align Alignment = commonAlignment (StructAlign, SL->getElementOffset (J ));
365
365
new StoreInst (&*I2++, Idx, false , Alignment, InsertPt);
366
366
}
367
367
@@ -523,7 +523,7 @@ static bool findArgParts(Argument *Arg, const DataLayout &DL, AAResults &AAR,
523
523
return false ;
524
524
}
525
525
526
- // If this load is not guaranteed to execute and we haven't seen a load at
526
+ // If this load is not guaranteed to execute, and we haven't seen a load at
527
527
// this offset before (or it had lower alignment), then we need to remember
528
528
// that requirement.
529
529
// Note that skipping loads of previously seen offsets is only correct
@@ -625,7 +625,7 @@ static bool findArgParts(Argument *Arg, const DataLayout &DL, AAResults &AAR,
625
625
Offset = Pair.first + DL.getTypeStoreSize (Pair.second .Ty );
626
626
}
627
627
628
- // Okay, now we know that the argument is only used by load instructions and
628
+ // Okay, now we know that the argument is only used by load instructions, and
629
629
// it is safe to unconditionally perform all of them. Use alias analysis to
630
630
// check to see if the pointer is guaranteed to not be modified from entry of
631
631
// the function to each of the load instructions.
@@ -659,37 +659,37 @@ static bool findArgParts(Argument *Arg, const DataLayout &DL, AAResults &AAR,
659
659
return true ;
660
660
}
661
661
662
- bool ArgumentPromotionPass::isDenselyPacked (Type *type , const DataLayout &DL) {
662
+ bool ArgumentPromotionPass::isDenselyPacked (Type *Ty , const DataLayout &DL) {
663
663
// There is no size information, so be conservative.
664
- if (!type ->isSized ())
664
+ if (!Ty ->isSized ())
665
665
return false ;
666
666
667
667
// If the alloc size is not equal to the storage size, then there are padding
668
668
// bytes. For x86_fp80 on x86-64, size: 80 alloc size: 128.
669
- if (DL.getTypeSizeInBits (type ) != DL.getTypeAllocSizeInBits (type ))
669
+ if (DL.getTypeSizeInBits (Ty ) != DL.getTypeAllocSizeInBits (Ty ))
670
670
return false ;
671
671
672
672
// FIXME: This isn't the right way to check for padding in vectors with
673
673
// non-byte-size elements.
674
- if (VectorType *seqTy = dyn_cast<VectorType>(type ))
675
- return isDenselyPacked (seqTy ->getElementType (), DL);
674
+ if (VectorType *SeqTy = dyn_cast<VectorType>(Ty ))
675
+ return isDenselyPacked (SeqTy ->getElementType (), DL);
676
676
677
677
// For array types, check for padding within members.
678
- if (ArrayType *seqTy = dyn_cast<ArrayType>(type ))
679
- return isDenselyPacked (seqTy ->getElementType (), DL);
678
+ if (ArrayType *SeqTy = dyn_cast<ArrayType>(Ty ))
679
+ return isDenselyPacked (SeqTy ->getElementType (), DL);
680
680
681
- if (!isa<StructType>(type ))
681
+ if (!isa<StructType>(Ty ))
682
682
return true ;
683
683
684
684
// Check for padding within and between elements of a struct.
685
- StructType *StructTy = cast<StructType>(type );
685
+ StructType *StructTy = cast<StructType>(Ty );
686
686
const StructLayout *Layout = DL.getStructLayout (StructTy);
687
687
uint64_t StartPos = 0 ;
688
- for (unsigned i = 0 , E = StructTy->getNumElements (); i < E; ++i ) {
689
- Type *ElTy = StructTy->getElementType (i );
688
+ for (unsigned I = 0 , E = StructTy->getNumElements (); I < E; ++I ) {
689
+ Type *ElTy = StructTy->getElementType (I );
690
690
if (!isDenselyPacked (ElTy, DL))
691
691
return false ;
692
- if (StartPos != Layout->getElementOffsetInBits (i ))
692
+ if (StartPos != Layout->getElementOffsetInBits (I ))
693
693
return false ;
694
694
StartPos += DL.getTypeAllocSizeInBits (ElTy);
695
695
}
@@ -698,19 +698,19 @@ bool ArgumentPromotionPass::isDenselyPacked(Type *type, const DataLayout &DL) {
698
698
}
699
699
700
700
// / Checks if the padding bytes of an argument could be accessed.
701
- static bool canPaddingBeAccessed (Argument *arg ) {
702
- assert (arg ->hasByValAttr ());
701
+ static bool canPaddingBeAccessed (Argument *Arg ) {
702
+ assert (Arg ->hasByValAttr ());
703
703
704
704
// Track all the pointers to the argument to make sure they are not captured.
705
705
SmallPtrSet<Value *, 16 > PtrValues;
706
- PtrValues.insert (arg );
706
+ PtrValues.insert (Arg );
707
707
708
708
// Track all of the stores.
709
709
SmallVector<StoreInst *, 16 > Stores;
710
710
711
711
// Scan through the uses recursively to make sure the pointer is always used
712
712
// sanely.
713
- SmallVector<Value *, 16 > WorkList (arg ->users ());
713
+ SmallVector<Value *, 16 > WorkList (Arg ->users ());
714
714
while (!WorkList.empty ()) {
715
715
Value *V = WorkList.pop_back_val ();
716
716
if (isa<GetElementPtrInst>(V) || isa<PHINode>(V)) {
@@ -801,7 +801,7 @@ promoteArguments(Function *F, function_ref<AAResults &(Function &F)> AARGetter,
801
801
if (CB->isMustTailCall ())
802
802
return nullptr ;
803
803
804
- if (CB->getParent ()-> getParent () == F)
804
+ if (CB->getFunction () == F)
805
805
IsRecursive = true ;
806
806
}
807
807
@@ -840,14 +840,14 @@ promoteArguments(Function *F, function_ref<AAResults &(Function &F)> AARGetter,
840
840
// Only handle arguments with specified alignment; if it's unspecified, the
841
841
// actual alignment of the argument is target-specific.
842
842
Type *ByValTy = PtrArg->getParamByValType ();
843
- bool isSafeToPromote =
843
+ bool IsSafeToPromote =
844
844
ByValTy && PtrArg->getParamAlign () &&
845
845
(ArgumentPromotionPass::isDenselyPacked (ByValTy, DL) ||
846
846
!canPaddingBeAccessed (PtrArg));
847
- if (isSafeToPromote ) {
847
+ if (IsSafeToPromote ) {
848
848
if (StructType *STy = dyn_cast<StructType>(ByValTy)) {
849
849
if (MaxElements > 0 && STy->getNumElements () > MaxElements) {
850
- LLVM_DEBUG (dbgs () << " argpromotion disable promoting argument '"
850
+ LLVM_DEBUG (dbgs () << " ArgPromotion disables promoting argument '"
851
851
<< PtrArg->getName ()
852
852
<< " ' because it would require adding more"
853
853
<< " than " << MaxElements
@@ -1048,7 +1048,7 @@ bool ArgPromotion::runOnSCC(CallGraphSCC &SCC) {
1048
1048
else
1049
1049
OldF->setLinkage (Function::ExternalLinkage);
1050
1050
1051
- // And updat ethe SCC we're iterating as well.
1051
+ // And update the SCC we're iterating as well.
1052
1052
SCC.ReplaceNode (OldNode, NewNode);
1053
1053
}
1054
1054
}
0 commit comments