@@ -395,7 +395,7 @@ static bool slotOnlyDiscardsData(const Value *RetVal, const Value *CallVal,
395
395
396
396
// / For an aggregate type, determine whether a given index is within bounds or
397
397
// / not.
398
- static bool indexReallyValid (CompositeType *T, unsigned Idx) {
398
+ static bool indexReallyValid (Type *T, unsigned Idx) {
399
399
if (ArrayType *AT = dyn_cast<ArrayType>(T))
400
400
return Idx < AT->getNumElements ();
401
401
@@ -419,7 +419,7 @@ static bool indexReallyValid(CompositeType *T, unsigned Idx) {
419
419
// / function again on a finished iterator will repeatedly return
420
420
// / false. SubTypes.back()->getTypeAtIndex(Path.back()) is either an empty
421
421
// / aggregate or a non-aggregate
422
- static bool advanceToNextLeafType (SmallVectorImpl<CompositeType *> &SubTypes,
422
+ static bool advanceToNextLeafType (SmallVectorImpl<Type *> &SubTypes,
423
423
SmallVectorImpl<unsigned > &Path) {
424
424
// First march back up the tree until we can successfully increment one of the
425
425
// coordinates in Path.
@@ -435,16 +435,16 @@ static bool advanceToNextLeafType(SmallVectorImpl<CompositeType *> &SubTypes,
435
435
// We know there's *some* valid leaf now, so march back down the tree picking
436
436
// out the left-most element at each node.
437
437
++Path.back ();
438
- Type *DeeperType = SubTypes.back ()->getTypeAtIndex (Path.back ());
438
+ Type *DeeperType =
439
+ ExtractValueInst::getIndexedType (SubTypes.back (), Path.back ());
439
440
while (DeeperType->isAggregateType ()) {
440
- CompositeType *CT = cast<CompositeType>(DeeperType);
441
- if (!indexReallyValid (CT, 0 ))
441
+ if (!indexReallyValid (DeeperType, 0 ))
442
442
return true ;
443
443
444
- SubTypes.push_back (CT );
444
+ SubTypes.push_back (DeeperType );
445
445
Path.push_back (0 );
446
446
447
- DeeperType = CT-> getTypeAtIndex ( 0U );
447
+ DeeperType = ExtractValueInst::getIndexedType (DeeperType, 0 );
448
448
}
449
449
450
450
return true ;
@@ -460,17 +460,15 @@ static bool advanceToNextLeafType(SmallVectorImpl<CompositeType *> &SubTypes,
460
460
// / For example, if Next was {[0 x i64], {{}, i32, {}}, i32} then we would setup
461
461
// / Path as [1, 1] and SubTypes as [Next, {{}, i32, {}}] to represent the first
462
462
// / i32 in that type.
463
- static bool firstRealType (Type *Next,
464
- SmallVectorImpl<CompositeType *> &SubTypes,
463
+ static bool firstRealType (Type *Next, SmallVectorImpl<Type *> &SubTypes,
465
464
SmallVectorImpl<unsigned > &Path) {
466
465
// First initialise the iterator components to the first "leaf" node
467
466
// (i.e. node with no valid sub-type at any index, so {} does count as a leaf
468
467
// despite nominally being an aggregate).
469
- while (Next->isAggregateType () &&
470
- indexReallyValid (cast<CompositeType>(Next), 0 )) {
471
- SubTypes.push_back (cast<CompositeType>(Next));
468
+ while (Type *FirstInner = ExtractValueInst::getIndexedType (Next, 0 )) {
469
+ SubTypes.push_back (Next);
472
470
Path.push_back (0 );
473
- Next = cast<CompositeType>(Next)-> getTypeAtIndex ( 0U ) ;
471
+ Next = FirstInner ;
474
472
}
475
473
476
474
// If there's no Path now, Next was originally scalar already (or empty
@@ -480,7 +478,8 @@ static bool firstRealType(Type *Next,
480
478
481
479
// Otherwise, use normal iteration to keep looking through the tree until we
482
480
// find a non-aggregate type.
483
- while (SubTypes.back ()->getTypeAtIndex (Path.back ())->isAggregateType ()) {
481
+ while (ExtractValueInst::getIndexedType (SubTypes.back (), Path.back ())
482
+ ->isAggregateType ()) {
484
483
if (!advanceToNextLeafType (SubTypes, Path))
485
484
return false ;
486
485
}
@@ -490,14 +489,15 @@ static bool firstRealType(Type *Next,
490
489
491
490
// / Set the iterator data-structures to the next non-empty, non-aggregate
492
491
// / subtype.
493
- static bool nextRealType (SmallVectorImpl<CompositeType *> &SubTypes,
492
+ static bool nextRealType (SmallVectorImpl<Type *> &SubTypes,
494
493
SmallVectorImpl<unsigned > &Path) {
495
494
do {
496
495
if (!advanceToNextLeafType (SubTypes, Path))
497
496
return false ;
498
497
499
498
assert (!Path.empty () && " found a leaf but didn't set the path?" );
500
- } while (SubTypes.back ()->getTypeAtIndex (Path.back ())->isAggregateType ());
499
+ } while (ExtractValueInst::getIndexedType (SubTypes.back (), Path.back ())
500
+ ->isAggregateType ());
501
501
502
502
return true ;
503
503
}
@@ -669,7 +669,7 @@ bool llvm::returnTypeIsEligibleForTailCall(const Function *F,
669
669
}
670
670
671
671
SmallVector<unsigned , 4 > RetPath, CallPath;
672
- SmallVector<CompositeType *, 4 > RetSubTypes, CallSubTypes;
672
+ SmallVector<Type *, 4 > RetSubTypes, CallSubTypes;
673
673
674
674
bool RetEmpty = !firstRealType (RetVal->getType (), RetSubTypes, RetPath);
675
675
bool CallEmpty = !firstRealType (CallVal->getType (), CallSubTypes, CallPath);
@@ -692,7 +692,8 @@ bool llvm::returnTypeIsEligibleForTailCall(const Function *F,
692
692
// We've exhausted the values produced by the tail call instruction, the
693
693
// rest are essentially undef. The type doesn't really matter, but we need
694
694
// *something*.
695
- Type *SlotType = RetSubTypes.back ()->getTypeAtIndex (RetPath.back ());
695
+ Type *SlotType =
696
+ ExtractValueInst::getIndexedType (RetSubTypes.back (), RetPath.back ());
696
697
CallVal = UndefValue::get (SlotType);
697
698
}
698
699
0 commit comments