Skip to content

Commit cef6a6c

Browse files
Merge pull request #73607 from aschwaighofer/revert_c_array_heurisic_6.0
[6.0] Revert "Merge pull request #72708 from aschwaighofer/c_array_heuristic_6.0"
2 parents 78b635a + ccb9ca1 commit cef6a6c

File tree

3 files changed

+9
-68
lines changed

3 files changed

+9
-68
lines changed

lib/IRGen/LoadableByAddress.cpp

Lines changed: 9 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
//===----------------------------------------------------------------------===//
1818

1919
#define DEBUG_TYPE "loadable-address"
20-
#include "Explosion.h"
2120
#include "FixedTypeInfo.h"
2221
#include "IRGenMangler.h"
2322
#include "IRGenModule.h"
@@ -3432,29 +3431,6 @@ class AddressAssignment {
34323431
toDeleteBlockArg.push_back(std::make_pair(b, argIdx));
34333432
}
34343433

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-
34583434
bool isLargeLoadableType(SILType ty) {
34593435
if (ty.isAddress() || ty.isClassOrClassMetatype()) {
34603436
return false;
@@ -3472,11 +3448,7 @@ class AddressAssignment {
34723448
assert(!canType->hasTypeParameter());
34733449
const TypeInfo &TI = irgenModule->getTypeInfoForLowered(canType);
34743450
auto &nativeSchemaOrigParam = TI.nativeParameterValueSchema(*irgenModule);
3475-
if (nativeSchemaOrigParam.size() > 15)
3476-
return true;
3477-
auto explosionSchema = TI.getSchema();
3478-
if (explosionSchema.size() > 15)
3479-
return true;
3451+
return nativeSchemaOrigParam.size() > 15;
34803452
}
34813453
return false;
34823454
}
@@ -3489,7 +3461,7 @@ class AddressAssignment {
34893461
auto it = valueToAddressMap.find(v);
34903462

34913463
// This can happen if we deem a container type small but a contained type
3492-
// big.
3464+
// big or if we lower an undef value.
34933465
if (it == valueToAddressMap.end()) {
34943466
if (auto *sv = dyn_cast<SingleValueInstruction>(v)) {
34953467
auto addr = createAllocStack(v->getType());
@@ -3499,6 +3471,11 @@ class AddressAssignment {
34993471
mapValueToAddress(v, addr);
35003472
return addr;
35013473
}
3474+
if (isa<SILUndef>(v)) {
3475+
auto undefAddr = createAllocStack(v->getType());
3476+
mapValueToAddress(v, undefAddr);
3477+
return undefAddr;
3478+
}
35023479
}
35033480
assert(it != valueToAddressMap.end());
35043481

@@ -3794,6 +3771,7 @@ class AssignAddressToDef : SILInstructionVisitor<AssignAddressToDef> {
37943771
StoreOwnershipQualifier::Unqualified);
37953772
assignment.mapValueToAddress(origValue, addr);
37963773
assignment.markForDeletion(bc);
3774+
37973775
return;
37983776
}
37993777
auto opdAddr = assignment.getAddressForValue(bc->getOperand());
@@ -3955,9 +3933,7 @@ class RewriteUser : SILInstructionVisitor<RewriteUser> {
39553933
}
39563934

39573935
void visitDebugValueInst(DebugValueInst *dbg) {
3958-
if (!dbg->hasAddrVal() &&
3959-
(assignment.isPotentiallyCArray(dbg->getOperand()->getType()) ||
3960-
overlapsWithOnStackDebugLoc(dbg->getOperand()))) {
3936+
if (!dbg->hasAddrVal() && overlapsWithOnStackDebugLoc(dbg->getOperand())) {
39613937
assignment.markForDeletion(dbg);
39623938
return;
39633939
}

test/IRGen/Inputs/large_union.h

Lines changed: 0 additions & 13 deletions
This file was deleted.

test/IRGen/large_union.swift

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)