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"
@@ -3431,6 +3432,29 @@ class AddressAssignment {
3431
3432
toDeleteBlockArg.push_back (std::make_pair (b, argIdx));
3432
3433
}
3433
3434
3435
+ bool isPotentiallyCArray (SILType ty) {
3436
+ if (ty.isAddress () || ty.isClassOrClassMetatype ()) {
3437
+ return false ;
3438
+ }
3439
+
3440
+ auto canType = ty.getASTType ();
3441
+ if (canType->hasTypeParameter ()) {
3442
+ assert (genEnv && " Expected a GenericEnv" );
3443
+ canType = genEnv->mapTypeIntoContext (canType)->getCanonicalType ();
3444
+ }
3445
+
3446
+ if (canType.getAnyGeneric () || isa<TupleType>(canType)) {
3447
+ assert (ty.isObject () &&
3448
+ " Expected only two categories: address and object" );
3449
+ assert (!canType->hasTypeParameter ());
3450
+ const TypeInfo &TI = irgenModule->getTypeInfoForLowered (canType);
3451
+ auto explosionSchema = TI.getSchema ();
3452
+ if (explosionSchema.size () > 15 )
3453
+ return true ;
3454
+ }
3455
+ return false ;
3456
+ }
3457
+
3434
3458
bool isLargeLoadableType (SILType ty) {
3435
3459
if (ty.isAddress () || ty.isClassOrClassMetatype ()) {
3436
3460
return false ;
@@ -3448,7 +3472,11 @@ class AddressAssignment {
3448
3472
assert (!canType->hasTypeParameter ());
3449
3473
const TypeInfo &TI = irgenModule->getTypeInfoForLowered (canType);
3450
3474
auto &nativeSchemaOrigParam = TI.nativeParameterValueSchema (*irgenModule);
3451
- return nativeSchemaOrigParam.size () > 15 ;
3475
+ if (nativeSchemaOrigParam.size () > 15 )
3476
+ return true ;
3477
+ auto explosionSchema = TI.getSchema ();
3478
+ if (explosionSchema.size () > 15 )
3479
+ return true ;
3452
3480
}
3453
3481
return false ;
3454
3482
}
@@ -3764,7 +3792,7 @@ class AssignAddressToDef : SILInstructionVisitor<AssignAddressToDef> {
3764
3792
builder.createStore (bc->getLoc (), bc->getOperand (), opdAddr,
3765
3793
StoreOwnershipQualifier::Unqualified);
3766
3794
assignment.mapValueToAddress (origValue, addr);
3767
-
3795
+ assignment. markForDeletion (bc);
3768
3796
return ;
3769
3797
}
3770
3798
auto opdAddr = assignment.getAddressForValue (bc->getOperand ());
@@ -3926,7 +3954,9 @@ class RewriteUser : SILInstructionVisitor<RewriteUser> {
3926
3954
}
3927
3955
3928
3956
void visitDebugValueInst (DebugValueInst *dbg) {
3929
- if (!dbg->hasAddrVal () && overlapsWithOnStackDebugLoc (dbg->getOperand ())) {
3957
+ if (!dbg->hasAddrVal () &&
3958
+ (assignment.isPotentiallyCArray (dbg->getOperand ()->getType ()) ||
3959
+ overlapsWithOnStackDebugLoc (dbg->getOperand ()))) {
3930
3960
assignment.markForDeletion (dbg);
3931
3961
return ;
3932
3962
}
0 commit comments