17
17
// ===----------------------------------------------------------------------===//
18
18
19
19
#define DEBUG_TYPE " loadable-address"
20
+ #include " Explosion.h"
20
21
#include " FixedTypeInfo.h"
21
22
#include " IRGenMangler.h"
22
23
#include " IRGenModule.h"
@@ -3432,6 +3433,29 @@ class AddressAssignment {
3432
3433
toDeleteBlockArg.push_back (std::make_pair (b, argIdx));
3433
3434
}
3434
3435
3436
+ bool isPotentiallyCArray (SILType ty) {
3437
+ if (ty.isAddress () || ty.isClassOrClassMetatype ()) {
3438
+ return false ;
3439
+ }
3440
+
3441
+ auto canType = ty.getASTType ();
3442
+ if (canType->hasTypeParameter ()) {
3443
+ assert (genEnv && " Expected a GenericEnv" );
3444
+ canType = genEnv->mapTypeIntoContext (canType)->getCanonicalType ();
3445
+ }
3446
+
3447
+ if (canType.getAnyGeneric () || isa<TupleType>(canType)) {
3448
+ assert (ty.isObject () &&
3449
+ " Expected only two categories: address and object" );
3450
+ assert (!canType->hasTypeParameter ());
3451
+ const TypeInfo &TI = irgenModule->getTypeInfoForLowered (canType);
3452
+ auto explosionSchema = TI.getSchema ();
3453
+ if (explosionSchema.size () > 15 )
3454
+ return true ;
3455
+ }
3456
+ return false ;
3457
+ }
3458
+
3435
3459
bool isLargeLoadableType (SILType ty) {
3436
3460
if (ty.isAddress () || ty.isClassOrClassMetatype ()) {
3437
3461
return false ;
@@ -3449,7 +3473,11 @@ class AddressAssignment {
3449
3473
assert (!canType->hasTypeParameter ());
3450
3474
const TypeInfo &TI = irgenModule->getTypeInfoForLowered (canType);
3451
3475
auto &nativeSchemaOrigParam = TI.nativeParameterValueSchema (*irgenModule);
3452
- return nativeSchemaOrigParam.size () > 15 ;
3476
+ if (nativeSchemaOrigParam.size () > 15 )
3477
+ return true ;
3478
+ auto explosionSchema = TI.getSchema ();
3479
+ if (explosionSchema.size () > 15 )
3480
+ return true ;
3453
3481
}
3454
3482
return false ;
3455
3483
}
@@ -3765,7 +3793,7 @@ class AssignAddressToDef : SILInstructionVisitor<AssignAddressToDef> {
3765
3793
builder.createStore (bc->getLoc (), bc->getOperand (), opdAddr,
3766
3794
StoreOwnershipQualifier::Unqualified);
3767
3795
assignment.mapValueToAddress (origValue, addr);
3768
-
3796
+ assignment. markForDeletion (bc);
3769
3797
return ;
3770
3798
}
3771
3799
auto opdAddr = assignment.getAddressForValue (bc->getOperand ());
@@ -3936,7 +3964,9 @@ class RewriteUser : SILInstructionVisitor<RewriteUser> {
3936
3964
}
3937
3965
3938
3966
void visitDebugValueInst (DebugValueInst *dbg) {
3939
- if (!dbg->hasAddrVal () && overlapsWithOnStackDebugLoc (dbg->getOperand ())) {
3967
+ if (!dbg->hasAddrVal () &&
3968
+ (assignment.isPotentiallyCArray (dbg->getOperand ()->getType ()) ||
3969
+ overlapsWithOnStackDebugLoc (dbg->getOperand ()))) {
3940
3970
assignment.markForDeletion (dbg);
3941
3971
return ;
3942
3972
}
0 commit comments