Skip to content

Do not emit shadow copied for inout parameters #5218

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 41 commits into from
Oct 13, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
ecf1afc
delete InOutDeshadowing pass
dduan Apr 8, 2016
6c50ebd
eliminate support for shadow inout params
dduan Apr 8, 2016
7d508fb
3 tests
dduan Jun 8, 2016
39c67fc
protocols.swift
dduan Jun 8, 2016
4ba998c
x
dduan Jun 8, 2016
aea67df
properties
dduan Jun 8, 2016
d97def7
fixed one
dduan Jun 9, 2016
88708b3
fixed one
dduan Jun 9, 2016
0bff937
fixed one
dduan Jun 9, 2016
18d64ec
fixed one
dduan Jun 9, 2016
a085caf
fixed one
dduan Jun 9, 2016
58b09c4
fixed one
dduan Jun 9, 2016
7d4513f
fixed one
dduan Jun 9, 2016
d28b9d8
fixed one
dduan Jun 9, 2016
e8495de
fixed one
dduan Jun 9, 2016
b5cb3da
fix test/SILGen/optional_lvalue.swift test case
Oct 10, 2016
2fb4c7f
capture inout non-let arguments by address
Oct 10, 2016
79b01a3
fixed one
dduan Jun 19, 2016
31a6823
fix test/SILGen/generic_closures.swift test-case
Oct 10, 2016
ddcfba4
delete InOutDeshadowing pass
dduan Apr 8, 2016
26f6f33
eliminate support for shadow inout params
dduan Apr 8, 2016
08e4c40
3 tests
dduan Jun 8, 2016
1f7733d
protocols.swift
dduan Jun 8, 2016
69b7d32
x
dduan Jun 8, 2016
d9f11d7
properties
dduan Jun 8, 2016
c988b7e
fixed one
dduan Jun 9, 2016
4f9f6e0
fixed one
dduan Jun 9, 2016
214a94b
fixed one
dduan Jun 9, 2016
ad545ce
fixed one
dduan Jun 9, 2016
15c576b
fixed one
dduan Jun 9, 2016
c7cc59c
fixed one
dduan Jun 9, 2016
d6da12e
fixed one
dduan Jun 9, 2016
ce0be56
fixed one
dduan Jun 9, 2016
6ee5153
fixed one
dduan Jun 9, 2016
7051909
fix test/SILGen/optional_lvalue.swift test case
Oct 10, 2016
16c4d95
capture inout non-let arguments by address
Oct 10, 2016
c44c2be
fixed one
dduan Jun 19, 2016
ed31bb6
fix test/SILGen/generic_closures.swift test-case
Oct 10, 2016
49e9d30
Rebase: Merge branch 'inout_shadow_escaping_closure' of github.com:sh…
Oct 11, 2016
7068295
combine createDebugValue(s) per atrick's review
Oct 11, 2016
674674f
add unit tests that verify ocal functions capturing inout are now han…
Oct 11, 2016
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
2 changes: 0 additions & 2 deletions include/swift/SILOptimizer/PassManager/Passes.def
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,6 @@ PASS(HighLevelLICM, "high-level-licm",
"High Level Loop invariant code motion")
PASS(IVInfoPrinter, "iv-info-printer",
"Display induction variable information")
PASS(InOutDeshadowing, "inout-deshadow",
"Remove inout argument shadow variables")
PASS(InstCount, "inst-count",
"Count all instructions in the module using llvm Statistics")
PASS(JumpThreadSimplifyCFG, "simplify-cfg",
Expand Down
4 changes: 4 additions & 0 deletions lib/SIL/TypeLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ CaptureKind TypeConverter::getDeclCaptureKind(CapturedValue capture) {
if (var->isLet() && !getTypeLowering(var->getType()).isAddressOnly())
return CaptureKind::Constant;

if (var->getType()->is<InOutType>()) {
return CaptureKind::StorageAddress;
}

// If we're capturing into a non-escaping closure, we can generally just
// capture the address of the value as no-escape.
return capture.isNoEscape() ?
Expand Down
24 changes: 6 additions & 18 deletions lib/SILGen/SILGenProlog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,30 +262,18 @@ struct ArgumentInitHelper {
gen.B.createDebugValueAddr(loc, address, {vd->isLet(), ArgNo});
return;
}

// Allocate the local variable for the inout.
auto initVar = gen.emitLocalVariableWithCleanup(vd, false, ArgNo);

// Initialize with the value from the inout with an "autogenerated"
// copyaddr.
loc.markAutoGenerated();
gen.B.createCopyAddr(loc, address, initVar->getAddress(),
IsNotTake, IsInitialization);
initVar->finishInitialization(gen);

// Set up a cleanup to write back to the inout.
gen.Cleanups.pushCleanup<CleanupWriteBackToInOut>(vd, address);
assert(argrv.getType().isAddress() && "expected inout to be address");
} else {
assert(vd->isLet() && "expected parameter to be immutable!");
// If the variable is immutable, we can bind the value as is.
// Leave the cleanup on the argument, if any, in place to consume the
// argument if we're responsible for it.
gen.VarLocs[vd] = SILGenFunction::VarLoc::get(argrv.getValue());
if (argrv.getType().isAddress())
gen.B.createDebugValueAddr(loc, argrv.getValue(), {vd->isLet(), ArgNo});
else
gen.B.createDebugValue(loc, argrv.getValue(), {vd->isLet(), ArgNo});
}
gen.VarLocs[vd] = SILGenFunction::VarLoc::get(argrv.getValue());
if (argrv.getType().isAddress())
gen.B.createDebugValueAddr(loc, argrv.getValue(), {vd->isLet(), ArgNo});
else
gen.B.createDebugValue(loc, argrv.getValue(), {vd->isLet(), ArgNo});
}

void emitParam(ParamDecl *PD) {
Expand Down
1 change: 0 additions & 1 deletion lib/SILOptimizer/Mandatory/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ set(MANDATORY_SOURCES
Mandatory/DiagnoseUnreachable.cpp
Mandatory/PredictableMemOpt.cpp
Mandatory/ConstantPropagation.cpp
Mandatory/InOutDeshadowing.cpp
PARENT_SCOPE)
321 changes: 0 additions & 321 deletions lib/SILOptimizer/Mandatory/InOutDeshadowing.cpp

This file was deleted.

1 change: 0 additions & 1 deletion lib/SILOptimizer/PassManager/Passes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ bool swift::runSILDiagnosticPasses(SILModule &Module) {
// Otherwise run the rest of diagnostics.
PM.addCapturePromotion();
PM.addAllocBoxToStack();
PM.addInOutDeshadowing();
PM.addNoReturnFolding();
PM.addDefiniteInitialization();

Expand Down
Loading