This just runs a transform range on getSuccessor()'s ArrayRef<SILSuccessor> so
one does not need to always call Successor.getBB() when iterating over successor
blocks. Instead the transform range does that call for you.
I also updated some loops to use this new SILBasicBlock method to make sure that
the code is tested out by tests that are already in tree. All these places
should be functionally the same albeit a bit cleaner.
Use malloc/free for allocating/freeing SIL instructions instead of using the BumpPtrAllocator. This allows for memory reuse and significantly reduces the memory footprint of the compiler.
For example, a peak memory usage during a compilation of the standard library and StdlibUnitTest is reduced by 25%-30%. The performance of the compiler seems to be not affected by this change, i.e. no slowdown is measured.
The use-after-free issues reported by build bots are fixed now.
rdar://23303031
Hubris is my name. = /. I put in a verifier check to make sure that we can
properly look up some value and if we have two blocks related via a non-local
successor chain, the first is a CFG level successor of the second.
Swift SVN r32759
Move the implementation of SILBasicBlock::splitBasicBlockAndBranch into
CFG's util function swift::splitBasicBlockAndBranch since it's the only
user, and update the latter to take a SILBuilder and use it to create
the branch to the split-off block.
Swift SVN r32128
Due to inreased use of llvm::make_range in LLVM headers and ADL for
types defined in the swift namespace, some of the LLVM headers started
to trigger ambiguity errors between llvm::make_range and
swift::make_range.
Swift SVN r29700
TerminatorInsts. Now you can walk over the successor list of a terminator
and actually modify the SILSuccessor directly, allowing better CFG
transformations. NFC.
Swift SVN r26140
constructor in SILBasicBlock::createArgument.
By default the argument is nullptr so any place that currently does not
need to pass in the ValueDecl will not need to be updated given the new
behavior.
Swift SVN r22379
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
If we have BB args that are only used in a struct/tuple extract, and
that are generated in each predecessor with a struct/tuple instruction,
retype the BB arg and replace the argument with what would have been the
extracted value.
This provides more opportunties for jump threading to kick in.
Swift SVN r16509
In cases like the one below, replace the integer_literal instructions
with the condition branching to the block that the instruction is in.
cond_br %10, bb1, bb3
bb1:
%13 = integer_literal $Builtin.Int1, -1
br bb2(%13 : $Builtin.Int1)
bb3:
%18 = integer_literal $Builtin.Int1, 0
br bb2(%18 : $Builtin.Int1)
Similarly, for
switch_enum %0 : $Bool, case #Bool.true!enumelt: bb1
bb1:
%1 = enum $Bool, #Bool.true!enumelt
we'll replace the enum with %0.
Use this functionality from within the CFG simplification pass to
simplify basic block args in an attempt to expose opportunities for
further CFG simplification.
Swift SVN r9968
Propagate/remove basic block input values when all predecessors supply
the same arguments. Another optimization needed to fold 'true'.
TODO: I need to figure out additional surcumstances in which to to trigger this
optimization and if we need to rerun CCP after this. (For example, we need to
rerun this after constant folding the terminator in order to fold 'true'.)
Swift SVN r8518
inserting a diamond into the middle of an existing block. This fixes a
problem that manifests in memory promotion when lowering an assign.
Swift SVN r7917
This was not likely an error-free change. Where you see problems
please correct them. This went through a fairly tedious audit
before committing, but comments might have been changed incorrectly,
not changed at all, etc.
Swift SVN r7631