@@ -449,8 +449,8 @@ static bool isSupportedAtomicType(Type *Ty) {
449
449
// /
450
450
// / Note that this will create all of the instructions with whatever insert
451
451
// / point the \c InstCombiner currently is using.
452
- static LoadInst *combineLoadToNewType (InstCombiner &IC, LoadInst &LI, Type *NewTy,
453
- const Twine &Suffix = " " ) {
452
+ LoadInst *InstCombiner:: combineLoadToNewType (LoadInst &LI, Type *NewTy,
453
+ const Twine &Suffix) {
454
454
assert ((!LI.isAtomic () || isSupportedAtomicType (NewTy)) &&
455
455
" can't fold an atomic load to requested type" );
456
456
@@ -460,16 +460,16 @@ static LoadInst *combineLoadToNewType(InstCombiner &IC, LoadInst &LI, Type *NewT
460
460
if (!(match (Ptr, m_BitCast (m_Value (NewPtr))) &&
461
461
NewPtr->getType ()->getPointerElementType () == NewTy &&
462
462
NewPtr->getType ()->getPointerAddressSpace () == AS))
463
- NewPtr = IC. Builder .CreateBitCast (Ptr, NewTy->getPointerTo (AS));
463
+ NewPtr = Builder.CreateBitCast (Ptr, NewTy->getPointerTo (AS));
464
464
465
465
unsigned Align = LI.getAlignment ();
466
466
if (!Align)
467
467
// If old load did not have an explicit alignment specified,
468
468
// manually preserve the implied (ABI) alignment of the load.
469
469
// Else we may inadvertently incorrectly over-promise alignment.
470
- Align = IC. getDataLayout ().getABITypeAlignment (LI.getType ());
470
+ Align = getDataLayout ().getABITypeAlignment (LI.getType ());
471
471
472
- LoadInst *NewLoad = IC. Builder .CreateAlignedLoad (
472
+ LoadInst *NewLoad = Builder.CreateAlignedLoad (
473
473
NewTy, NewPtr, Align, LI.isVolatile (), LI.getName () + Suffix);
474
474
NewLoad->setAtomic (LI.getOrdering (), LI.getSyncScopeID ());
475
475
copyMetadataForLoad (*NewLoad, LI);
@@ -607,9 +607,8 @@ static Instruction *combineLoadToOperationType(InstCombiner &IC, LoadInst &LI) {
607
607
return SI && SI->getPointerOperand () != &LI &&
608
608
!SI->getPointerOperand ()->isSwiftError ();
609
609
})) {
610
- LoadInst *NewLoad = combineLoadToNewType (
611
- IC, LI,
612
- Type::getIntNTy (LI.getContext (), DL.getTypeStoreSizeInBits (Ty)));
610
+ LoadInst *NewLoad = IC.combineLoadToNewType (
611
+ LI, Type::getIntNTy (LI.getContext (), DL.getTypeStoreSizeInBits (Ty)));
613
612
// Replace all the stores with stores of the newly loaded value.
614
613
for (auto UI = LI.user_begin (), UE = LI.user_end (); UI != UE;) {
615
614
auto *SI = cast<StoreInst>(*UI++);
@@ -631,7 +630,7 @@ static Instruction *combineLoadToOperationType(InstCombiner &IC, LoadInst &LI) {
631
630
if (auto * CI = dyn_cast<CastInst>(LI.user_back ()))
632
631
if (CI->isNoopCast (DL))
633
632
if (!LI.isAtomic () || isSupportedAtomicType (CI->getDestTy ())) {
634
- LoadInst *NewLoad = combineLoadToNewType (IC, LI, CI->getDestTy ());
633
+ LoadInst *NewLoad = IC. combineLoadToNewType (LI, CI->getDestTy ());
635
634
CI->replaceAllUsesWith (NewLoad);
636
635
IC.eraseInstFromFunction (*CI);
637
636
return &LI;
@@ -659,8 +658,8 @@ static Instruction *unpackLoadToAggregate(InstCombiner &IC, LoadInst &LI) {
659
658
// If the struct only have one element, we unpack.
660
659
auto NumElements = ST->getNumElements ();
661
660
if (NumElements == 1 ) {
662
- LoadInst *NewLoad = combineLoadToNewType (IC, LI, ST->getTypeAtIndex (0U ),
663
- " .unpack" );
661
+ LoadInst *NewLoad = IC. combineLoadToNewType (LI, ST->getTypeAtIndex (0U ),
662
+ " .unpack" );
664
663
AAMDNodes AAMD;
665
664
LI.getAAMetadata (AAMD);
666
665
NewLoad->setAAMetadata (AAMD);
@@ -709,7 +708,7 @@ static Instruction *unpackLoadToAggregate(InstCombiner &IC, LoadInst &LI) {
709
708
auto *ET = AT->getElementType ();
710
709
auto NumElements = AT->getNumElements ();
711
710
if (NumElements == 1 ) {
712
- LoadInst *NewLoad = combineLoadToNewType (IC, LI, ET, " .unpack" );
711
+ LoadInst *NewLoad = IC. combineLoadToNewType (LI, ET, " .unpack" );
713
712
AAMDNodes AAMD;
714
713
LI.getAAMetadata (AAMD);
715
714
NewLoad->setAAMetadata (AAMD);
@@ -1352,7 +1351,7 @@ static bool removeBitcastsFromLoadStoreOnMinMax(InstCombiner &IC,
1352
1351
return false ;
1353
1352
1354
1353
IC.Builder .SetInsertPoint (LI);
1355
- LoadInst *NewLI = combineLoadToNewType (IC, *LI, CmpLoadTy);
1354
+ LoadInst *NewLI = IC. combineLoadToNewType (*LI, CmpLoadTy);
1356
1355
// Replace all the stores with stores of the newly loaded value.
1357
1356
for (auto *UI : LI->users ()) {
1358
1357
auto *USI = cast<StoreInst>(UI);
0 commit comments