@@ -274,11 +274,6 @@ class LoweredValue {
274
274
return kind == Kind::BoxWithAddress;
275
275
}
276
276
277
- Address getAddress () const {
278
- assert (kind == Kind::Address && " not an allocated address" );
279
- return address.getAddress ();
280
- }
281
-
282
277
StackAddress getStackAddress () const {
283
278
assert (kind == Kind::Address && " not an allocated address" );
284
279
return address;
@@ -301,6 +296,17 @@ class LoweredValue {
301
296
assert (kind == Kind::DynamicallyEnforcedAddress);
302
297
return dynamicallyEnforcedAddress;
303
298
}
299
+
300
+ Address getAnyAddress () const {
301
+ if (kind == LoweredValue::Kind::Address) {
302
+ return address.getAddress ();
303
+ } else if (kind == LoweredValue::Kind::ContainedAddress) {
304
+ return getAddressInContainer ();
305
+ } else {
306
+ assert (kind == LoweredValue::Kind::DynamicallyEnforcedAddress);
307
+ return getDynamicallyEnforcedAddress ().Addr ;
308
+ }
309
+ }
304
310
305
311
void getExplosion (IRGenFunction &IGF, Explosion &ex) const ;
306
312
@@ -559,15 +565,7 @@ class IRGenSILFunction :
559
565
// / Get the Address of a SIL value of address type, which must have been
560
566
// / lowered.
561
567
Address getLoweredAddress (SILValue v) {
562
- auto &&lv = getLoweredValue (v);
563
- if (lv.kind == LoweredValue::Kind::Address) {
564
- return lv.getAddress ();
565
- } else if (lv.kind == LoweredValue::Kind::ContainedAddress) {
566
- return lv.getAddressInContainer ();
567
- } else {
568
- assert (lv.kind == LoweredValue::Kind::DynamicallyEnforcedAddress);
569
- return lv.getDynamicallyEnforcedAddress ().Addr ;
570
- }
568
+ return getLoweredValue (v).getAnyAddress ();
571
569
}
572
570
573
571
StackAddress getLoweredStackAddress (SILValue v) {
@@ -2623,14 +2621,13 @@ static void addIncomingSILArgumentsToPHINodes(IRGenSILFunction &IGF,
2623
2621
OperandValueArrayRef args) {
2624
2622
unsigned phiIndex = 0 ;
2625
2623
for (SILValue arg : args) {
2626
- const LoweredValue &lv = IGF.getLoweredValue (arg);
2627
-
2628
- if (lv.isAddress ()) {
2629
- addIncomingAddressToPHINodes (IGF, lbb, phiIndex, lv.getAddress ());
2624
+ if (arg->getType ().isAddress ()) {
2625
+ addIncomingAddressToPHINodes (IGF, lbb, phiIndex,
2626
+ IGF.getLoweredAddress (arg));
2630
2627
continue ;
2631
2628
}
2632
2629
2633
- Explosion argValue = lv. getExplosion (IGF );
2630
+ Explosion argValue = IGF. getLoweredExplosion (arg );
2634
2631
addIncomingExplosionToPHINodes (IGF, lbb, phiIndex, argValue);
2635
2632
}
2636
2633
}
@@ -4647,16 +4644,18 @@ void IRGenSILFunction::visitIsNonnullInst(swift::IsNonnullInst *i) {
4647
4644
// Get the value we're testing, which may be a function, an address or an
4648
4645
// instance pointer.
4649
4646
llvm::Value *val;
4650
- const LoweredValue &lv = getLoweredValue (i->getOperand ());
4651
-
4652
- if (i->getOperand ()->getType ().is <SILFunctionType>()) {
4653
- Explosion values = lv.getExplosion (*this );
4654
- val = values.claimNext (); // Function pointer.
4655
- values.claimNext (); // Ignore the data pointer.
4656
- } else if (lv.isAddress ()) {
4657
- val = lv.getAddress ().getAddress ();
4647
+
4648
+ SILValue operand = i->getOperand ();
4649
+ auto type = operand->getType ();
4650
+ if (type.isAddress ()) {
4651
+ val = getLoweredAddress (operand).getAddress ();
4652
+ } else if (auto fnType = type.getAs <SILFunctionType>()) {
4653
+ Explosion values = getLoweredExplosion (operand);
4654
+ val = values.claimNext (); // Function pointer.
4655
+ if (fnType->getRepresentation () == SILFunctionTypeRepresentation::Thick)
4656
+ (void ) values.claimNext (); // Ignore the data pointer.
4658
4657
} else {
4659
- Explosion values = lv. getExplosion (* this );
4658
+ Explosion values = getLoweredExplosion (operand );
4660
4659
val = values.claimNext ();
4661
4660
}
4662
4661
@@ -5049,7 +5048,7 @@ void IRGenSILFunction::visitCopyAddrInst(swift::CopyAddrInst *i) {
5049
5048
setAllocatedAddressForBuffer (i->getDest (), addr);
5050
5049
}
5051
5050
} else {
5052
- Address dest = loweredDest.getAddress ();
5051
+ Address dest = loweredDest.getAnyAddress ();
5053
5052
5054
5053
if (i->isInitializationOfDest ()) {
5055
5054
if (i->isTakeOfSrc ()) {
0 commit comments