Skip to content

Commit 6755d0e

Browse files
committed
LargeTypesReg2Mem: Ammend heuristic to include projections of block
arguments
1 parent c554ae1 commit 6755d0e

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

lib/IRGen/LoadableByAddress.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3495,6 +3495,7 @@ class LargeLoadableHeuristic {
34953495
UseAggressiveHeuristic(UseAggressiveHeuristic) {}
34963496

34973497
void visit(SILInstruction *i);
3498+
void visit(SILArgument *arg);
34983499

34993500
bool isLargeLoadableType(SILType ty);
35003501
bool isPotentiallyCArray(SILType ty);
@@ -3539,6 +3540,27 @@ class LargeLoadableHeuristic {
35393540
};
35403541
}
35413542

3543+
void LargeLoadableHeuristic::visit(SILArgument *arg) {
3544+
auto objType = arg->getType().getObjectType();
3545+
if (numRegisters(objType) < NumRegistersLargeType)
3546+
return;
3547+
3548+
auto &entry = largeTypeProperties[objType];
3549+
for (auto *use : arg->getUses()) {
3550+
auto *usr = use->getUser();
3551+
switch (usr->getKind()) {
3552+
case SILInstructionKind::TupleExtractInst:
3553+
case SILInstructionKind::StructExtractInst: {
3554+
auto projectionTy = cast<SingleValueInstruction>(usr)->getType();
3555+
if (numRegisters(projectionTy) >= NumRegistersLargeType)
3556+
entry.addProjection();
3557+
break;
3558+
}
3559+
default:
3560+
continue;
3561+
}
3562+
}
3563+
}
35423564
void LargeLoadableHeuristic::visit(SILInstruction *i) {
35433565
if (!UseAggressiveHeuristic)
35443566
return;
@@ -4611,6 +4633,9 @@ static void runPeepholesAndReg2Mem(SILPassManager *pm, SILModule *silMod,
46114633
UseAggressiveHeuristic);
46124634
Peepholes opts(pm, silMod, irgenModule);
46134635
for (SILBasicBlock &BB : currF) {
4636+
for (auto *arg : BB.getArguments()) {
4637+
heuristic.visit(arg);
4638+
}
46144639
for (SILInstruction &I : BB) {
46154640
heuristic.visit(&I);
46164641
if (opts.ignore(&I))

0 commit comments

Comments
 (0)