Skip to content

[6.0] Revert "Merge pull request #72708 from aschwaighofer/c_array_heuristic_6.0" #73607

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 9 additions & 33 deletions lib/IRGen/LoadableByAddress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
//===----------------------------------------------------------------------===//

#define DEBUG_TYPE "loadable-address"
#include "Explosion.h"
#include "FixedTypeInfo.h"
#include "IRGenMangler.h"
#include "IRGenModule.h"
Expand Down Expand Up @@ -3432,29 +3431,6 @@ class AddressAssignment {
toDeleteBlockArg.push_back(std::make_pair(b, argIdx));
}

bool isPotentiallyCArray(SILType ty) {
if (ty.isAddress() || ty.isClassOrClassMetatype()) {
return false;
}

auto canType = ty.getASTType();
if (canType->hasTypeParameter()) {
assert(genEnv && "Expected a GenericEnv");
canType = genEnv->mapTypeIntoContext(canType)->getCanonicalType();
}

if (canType.getAnyGeneric() || isa<TupleType>(canType)) {
assert(ty.isObject() &&
"Expected only two categories: address and object");
assert(!canType->hasTypeParameter());
const TypeInfo &TI = irgenModule->getTypeInfoForLowered(canType);
auto explosionSchema = TI.getSchema();
if (explosionSchema.size() > 15)
return true;
}
return false;
}

bool isLargeLoadableType(SILType ty) {
if (ty.isAddress() || ty.isClassOrClassMetatype()) {
return false;
Expand All @@ -3472,11 +3448,7 @@ class AddressAssignment {
assert(!canType->hasTypeParameter());
const TypeInfo &TI = irgenModule->getTypeInfoForLowered(canType);
auto &nativeSchemaOrigParam = TI.nativeParameterValueSchema(*irgenModule);
if (nativeSchemaOrigParam.size() > 15)
return true;
auto explosionSchema = TI.getSchema();
if (explosionSchema.size() > 15)
return true;
return nativeSchemaOrigParam.size() > 15;
}
return false;
}
Expand All @@ -3489,7 +3461,7 @@ class AddressAssignment {
auto it = valueToAddressMap.find(v);

// This can happen if we deem a container type small but a contained type
// big.
// big or if we lower an undef value.
if (it == valueToAddressMap.end()) {
if (auto *sv = dyn_cast<SingleValueInstruction>(v)) {
auto addr = createAllocStack(v->getType());
Expand All @@ -3499,6 +3471,11 @@ class AddressAssignment {
mapValueToAddress(v, addr);
return addr;
}
if (isa<SILUndef>(v)) {
auto undefAddr = createAllocStack(v->getType());
mapValueToAddress(v, undefAddr);
return undefAddr;
}
}
assert(it != valueToAddressMap.end());

Expand Down Expand Up @@ -3794,6 +3771,7 @@ class AssignAddressToDef : SILInstructionVisitor<AssignAddressToDef> {
StoreOwnershipQualifier::Unqualified);
assignment.mapValueToAddress(origValue, addr);
assignment.markForDeletion(bc);

return;
}
auto opdAddr = assignment.getAddressForValue(bc->getOperand());
Expand Down Expand Up @@ -3955,9 +3933,7 @@ class RewriteUser : SILInstructionVisitor<RewriteUser> {
}

void visitDebugValueInst(DebugValueInst *dbg) {
if (!dbg->hasAddrVal() &&
(assignment.isPotentiallyCArray(dbg->getOperand()->getType()) ||
overlapsWithOnStackDebugLoc(dbg->getOperand()))) {
if (!dbg->hasAddrVal() && overlapsWithOnStackDebugLoc(dbg->getOperand())) {
assignment.markForDeletion(dbg);
return;
}
Expand Down
13 changes: 0 additions & 13 deletions test/IRGen/Inputs/large_union.h

This file was deleted.

22 changes: 0 additions & 22 deletions test/IRGen/large_union.swift

This file was deleted.