Commit Graph

26 Commits

Author SHA1 Message Date
Mark Lacey
924e30ea61 Rewrite BB args whose only use is in struct/tuple extract.
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
2014-04-18 07:19:33 +00:00
Michael Gottesman
0bc4f9c936 Call SILFunction destructor when we cleanup functions so that if the function contains a function_ref, the function referenced by the function_ref has its refcount properly decrement.
Otherwise a function_ref which was supposed to be deallocated would keep
functions alive.

rdar://16287331

Swift SVN r16192
2014-04-11 01:44:38 +00:00
Nadav Rotem
5f35d44ecf Remove unused arguments from the block argument list.
Swift SVN r15006
2014-03-13 21:29:56 +00:00
Nadav Rotem
cbd1eac034 Add a helper function.
Swift SVN r13092
2014-01-29 06:12:03 +00:00
Argyrios Kyrtzidis
cc8804d570 Ubreak build, accomodate LLVM API changes.
Swift SVN r12094
2014-01-09 09:47:26 +00:00
Michael Gottesman
f9461acf29 Fix whitespace.
Swift SVN r11955
2014-01-06 21:31:24 +00:00
Michael Gottesman
6570a42c9a Add reverse iterators to SILBasicBlock.
Swift SVN r11952
2014-01-06 21:28:03 +00:00
Mark Lacey
0ec7617a2c Simplify enum and Int1 integer_literal instructions.
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
2013-11-05 19:11:45 +00:00
Chris Lattner
db9cda3d96 introduce a SILBasicBlock::getPreds() range to match getSuccs()
Swift SVN r9851
2013-10-31 20:54:59 +00:00
Chris Lattner
03e7b756d0 teach simplify-cfg to merge blocks connected by an uncond branch, when
the dest has no other predecessors.  This fires 6926 times on the stdlib.


Swift SVN r9794
2013-10-30 16:48:59 +00:00
Stephen Lin
3f5c0dbf0e Update SILArgument::getModule(), SILBasicBlock::getModule() and SILInstruction::getModule() signatures to match SILFunction::getModule(), for consistency; standardize usage of SILFunction::getParent() to SILFunction::getModule().
Swift SVN r8932
2013-10-04 21:12:20 +00:00
Anna Zaks
5b71c8dcc5 [SIL] Propagate basic block arguments.
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
2013-09-20 21:53:28 +00:00
Anna Zaks
4d7de376bb [SIL] Refactor splitBasicBlock() into splitBasicBlock and splitBasicBlockAndBranch
This API is more explicit and avoids relying on passing around empty SILLocation.
(No functional change.)

Swift SVN r7988
2013-09-06 17:46:12 +00:00
Chris Lattner
a864b8ea00 enhance the union retain/release implementations to split the block when
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
2013-09-04 22:02:50 +00:00
Michael Gottesman
c86a54a438 Renamed SILBasicBlock::getInsts() => SILBasicBlock::getInstList() as discussed on the list.
Swift SVN r7776
2013-08-30 03:40:37 +00:00
Ted Kremenek
8f5b8ccb02 Rename "This" to "Self" and "this" to "self".
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
2013-08-27 21:58:27 +00:00
Stephen Lin
4ae68cd72f Completion of MandatoryInlining pass: recursive inlining, multiple basic blocks, and diagnosis of circular inlining.
Swift SVN r7242
2013-08-14 22:30:21 +00:00
Anna Zaks
e5c3a7ea80 [SIL] Make sure SILBasicBlock destructor gets called.
This also ensures that the instructions indie the basic block
get destructed.

Swift SVN r6667
2013-07-27 00:25:03 +00:00
Anna Zaks
098f197cb8 [SIL] Add convenience SILBasicBlock successor iterators.
Swift SVN r6665
2013-07-27 00:25:02 +00:00
Chris Lattner
c7373c563b add regular convenience methods to SIL IR objects for getting parent containers.
Add a getOperand(n) method to SILInstruction.


Swift SVN r6425
2013-07-21 06:12:29 +00:00
Chris Lattner
496446ce64 Make all SIL objects that are print()-able, also raw_ostream insertable
with <<.  Use this to implement a DEBUG() dump in MemoryPromotion.cpp


Swift SVN r6412
2013-07-20 02:43:26 +00:00
Joe Groff
5e2779b51e SIL: Uncurry function types within the Swift type system.
Remove uncurry level as a property of SILType/SILFunctionTypeInfo. During SIL type lowering, map a (Type, UncurryLevel) pair to a Swift CanType with the uncurried arguments as a Swift tuple. For example, T -> (U, V) -> W at uncurry level 1 becomes ((U, V), T) -> W--in reverse order to match the low-level calling convention. Update SILGen and IRGen all over the place for this representation change.

SILFunctionTypeInfo is still used in the SILType representation, but it's no longer load-bearing. Everything remaining in it can be derived from a Swift type.

This is an ABI break. Be sure to rebuild clean!

Swift SVN r5296
2013-05-24 01:51:07 +00:00
Chris Lattner
0ad6fac283 Remove the basic block name field from SILBasicBlock. The name is currently
ignored and is going to be a private detail of the SILParser.


Swift SVN r5276
2013-05-22 22:24:39 +00:00
John McCall
dd4f26c6dc It does seem to make non-generic assumptions about the node
type, though;  I had to define a WriteAsOperand function and
add a front() method to SILFunction to get this to work.
Rip out my dominators implementation and replace it with
LLVM's.  I'd forgotten that LLVM's was actually generic.

Swift SVN r4717
2013-04-12 21:24:27 +00:00
Chris Lattner
a71bc3a78e rename Value -> SILValue, BasicBlock -> SILBasicBlock, BBArgument -> SILArgument.
Swift SVN r4594
2013-04-03 21:05:42 +00:00
Chris Lattner
1beebda868 move Instruction/BasicBlock/BBArgument files to have SIL prefixes.
Swift SVN r4591
2013-04-03 18:43:54 +00:00