threaded into IRGen; tests to follow when that's done.
I made a preliminary effort to make the inliner do the
right thing with try_apply, but otherwise tried to avoid
touching the optimizer any more than was required by the
removal of ApplyInstBase.
Swift SVN r26747
This commit splits DominanceAnalysis into two analysis (Dom and PDom) that
can be cached and invalidates using the common FunctionAnalysisBase interface
independent of one another.
Swift SVN r26643
The old invalidation lattice was incorrect because changes to control flow could cause changes to the
call graph, so we've decided to change the way passes invalidate analysis. In the new scheme, the lattice
is replaced with a list of traits that passes preserve or invalidate. The current traits are Calls and Branches.
Now, passes report which traits they preserve, which is the opposite of the previous implementation where
passes needed to report what they invalidate.
Node: I tried to limit the changes in this commit to mechanical changes to ease the review. I will cleanup some
of the code in a following commit.
Swift SVN r26449
In order to not completely loose testcoverage while rdar://problem/18709125
is under investiagtion, add a special flag for enabling debug value
liveness.
Patch by Michael Gottesman!
<rdar://problem/19267059>
Swift SVN r24416
without a valid SILDebugScope. An assertion in IRGenSIL prevents future
optimizations from regressing in this regard.
Introducing SILBuilderWithScope and SILBuilderwithPostprocess to ease the
transition.
This patch is large, but mostly mechanical.
<rdar://problem/18494573> Swift: Debugger is not stopping at the set breakpoint
Swift SVN r22978
Enhances DCE to make unreachable those regions of code that have no
effect.
This allows loops like:
for i in 0..n {
// do nothing
}
to be eliminated by first running DCE to make the loop unreachable, and
the CFG simplification to actually delete the blocks that make up the
loop (assuming we're talking -Ofast and cond_fails have been removed).
What's especially nice is that this can make unreachable several levels
of dead code, including deleting the code that produces the values used
to conditionally branch to other dead code, all in a single pass rather
than needing to iterate between DCE and CFG simplification to achieve
the same effect. For example, this:
func f(b: Bool, c: Bool, d: Bool) {
if (b && c) {
// nothing useful here
if (c && d) {
// nothing useful here
if (b && d) {
// nothing useful here
}
}
}
}
is effectively reduced to:
func f(b: Bool, c: Bool, d: Bool) {
goto end // pretend for a second we have goto
if (b && c) {
// nothing useful here
if (c && d) {
// nothing useful here
if (b && d) {
// nothing useful here
}
}
}
end:
}
after a single pass, after which unreachable code elimination reduces
this to:
func f(b: Bool, c: Bool, d: Bool) {
}
Swift SVN r18664
In a loop like this:
var j = 2
for var i = 0; i < 100; ++i {
j += 3
}
it will completely eliminate j.
It does not yet support rewriting conditional branches as unconditional
branches in the cases where only empty blocks are control dependent on
an edge. Once this support is added, it will also completely eliminate
the loop itself.
Swift SVN r18615
Also rename dead_code_elimination.sil to diagnose_unreachable.sil.
This more accurately reflects what this file implements, and makes way
for adding a new DeadCodeElimination.cpp that does classic dead (as
opposed to unreachable) code elimination.
I will fix up the contents of the files as a separate step.
Swift SVN r18613
The pass assumed that it is safe to delete instructions following a noreturn
call. If the instruction has an outside block user this would cause an failure
because we were deleting an instruction with uses.
Having control flow with uses from instructions after a noreturn call can happen
if we inline a transparent function after the noreturn call.
rdar://16852358
Swift SVN r17813
This will allow stdlib code to explicitly mark branches it knows to be unreachable. Make this work with SIL diagnostics by lowering the builtin to a normal builtin_function_ref/apply in SILGen, and special-case handling the builtin in DCE by removing the apply along with the following dead instructions when we recognize an unreachable block.
Swift SVN r16745
Fix a phase ordering problem: SILGen of a noreturn function doesn't drop an unreachable after the function,
and doing so is problematic for various reasons (all expressions would have to handle their insertion point
vaporizing, and would have to emit unreachable code diagnostics). Instead, run a simple pass that folds
noreturn calls and diagnoses unreachable code, and do it before DI. This prevents DI from seeing false
paths, and rejecting what seems like invalid code.
Swift SVN r14711
Now the pass does not need to know about the pass manager. We also don't have
runOnFunction or runOnModule anymore because the trnasformation knows
which module it is processing. The Pass itself knows how to invalidate the
analysis, based on the injected pass manager that is internal to the
transformation.
Now our DCE transformation looks like this:
class DCE : public SILModuleTransform {
void run() {
performSILDeadCodeElimination(getModule());
invalidateAnalysis(SILAnalysis::InvalidationKind::All);
}
};
Swift SVN r13598
Thanks to the way we've set up our diagnostics engine, there's not actually
a reason for /everything/ to get rebuilt when /one/ diagnostic changes.
I've split them up into five categories for now: Parse, Sema, SIL, IRGen,
and Frontend, plus a set of "Common" diagnostics that are used in multiple
areas of the compiler. We can massage this later.
No functionality change, but should speed up compile times!
Swift SVN r12438
conditional destroy logic generated by DI. This silences a bogus warning
building the stdlib, in which DCE is proved that conditional destroy logic
wasn't needed.
Swift SVN r10735
functions. Before it would only delete them once they got inlined,
which is a waste of compile time and serves no purpose.
This exposed a bug in mandatory inlining, which is now fixed. It
strinks the stdlib by 4500 lines, almost 10%.
Swift SVN r9906
in transparent functions. They will be deleted anyway when they get inlined
into callers, so there is no reason to do the work to carry them around and
inline them, only to delete them.
This shrinks the sil for the stdlib by about 5%: from 71672 lines to 67718 lines.
Swift SVN r9818