Commit Graph

45 Commits

Author SHA1 Message Date
Nadav Rotem
240ff14db1 Split DominanceAnalysis into Dom and PDom using FunctionAnalysisBase.
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
2015-03-27 20:54:28 +00:00
Nadav Rotem
d78b376d07 [passes] Replace the old invalidation lattice with a new invalidation scheme.
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
2015-03-23 21:18:58 +00:00
Chris Lattner
4f708c049b fix const correctness and standardize on names for the successor list of
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
2015-03-14 17:52:27 +00:00
Erik Eckstein
f49ab3f697 Support struct_element_addr and tuple_element_addr in SILMem2Reg.
SILMem2Reg can now optimize sequences like:
  alloc_stack
  store whole struct to stack
  get struct_element_addr
  load struct member from stack

This pattern occurs quite often. And this change can reduce the number of SIL instructions in some functions significantly.
The effect on the benchmarks is not significant (only a few small improvements).



Swift SVN r24917
2015-02-03 12:29:41 +00:00
Mark Lacey
e6acf31881 Refactor SILMem2Reg to compute dominator tree levels once per function.
We were computing them once per alloc_stack that we processed.

Swift SVN r24325
2015-01-09 21:29:23 +00:00
Mark Lacey
f5329446ae Small cleanup - remove unused typedef.
Swift SVN r24286
2015-01-08 22:56:00 +00:00
Mark Lacey
6c355f31bb Small clean-up in SILMem2Reg.
Swift SVN r23635
2014-12-03 03:33:09 +00:00
Mark Lacey
136d5dfd53 In SILMem2Reg, promote alloc_stack where the address appears in debug_value_addr.
Fixes rdar://problem/19087215, which is necessary in order to reasonably
fix rdar://problem/18709125.

Swift SVN r23629
2014-12-03 02:40:09 +00:00
Mark Lacey
8becf62650 Allow uninitialized void types in SILMem2Reg.
I ran into this while working on rdar://problem/18709125.

Fixes rdar://problem/19118507.

Swift SVN r23620
2014-12-02 23:01:05 +00:00
Mark Lacey
b44f7a5d3a Refactor a portion of SILMem2Reg.
This starts us in the direction of supporting promotion of
alloc_stack'ed addresses that appear in
debug_value_addr (rdar://problem/19087215), which will get us one step
closer to leaving debug_value/debug_value_addr around in optimized
builds (rdar://problem/18709125). NFC.

Swift SVN r23612
2014-12-02 05:35:45 +00:00
Michael Gottesman
1afc987739 Refactor the SILArgument API on SILBasicBlock so we can insert bb arguments anywhere in the argument list. Also clean up the API names so that they all match.
Swift SVN r23543
2014-11-22 00:24:40 +00:00
Ben Langmuir
e9e1666ab0 Update for upstream LLVM changes
* removal of StringMap's GetOrCreateValue
* SmallSet::insert now returns a pair like std::set

Swift SVN r23435
2014-11-19 16:49:30 +00:00
Arnold Schwaighofer
1dedc7a1fe Mem2Reg: Split critical non cond_br edges
This way we are guaranteed to be able to build SSA form.

Swift SVN r22760
2014-10-15 17:07:05 +00:00
Andrew Trick
54d7a31e13 Handle unreachable blocks in StackAllocationPromoter::getDefinitionForValue.
Fixes a crash exposed by disabling SimplifyCFG.

Swift SVN r21042
2014-08-05 17:14:32 +00:00
Manman Ren
1bace828d4 Move addArgumentToBranch to Local.h so we can use it in LoadStoreOpt. NFC.
Swift SVN r20726
2014-07-30 00:03:45 +00:00
Manman Ren
47865a1b3b NFC: space.
Swift SVN r20196
2014-07-19 00:44:04 +00:00
Mark Lacey
38f730cbd8 Fix a problem with SILMem2Reg exposed by local changes to DCE.
I hit this with some local changes I have to the DCE pass.

Swift SVN r18633
2014-05-26 06:18:22 +00:00
Nadav Rotem
b3d85b635b Currently we check if the block is directly reachable. This patch expands the check to global reachability by checking if the block is dominated by the entry block.
Swift SVN r16359
2014-04-15 04:56:36 +00:00
Nadav Rotem
a3f0926008 Make sure silMem2Reg does not crash on values in blocks that are not dominated by the entry block.
Swift SVN r16100
2014-04-09 04:55:38 +00:00
Nadav Rotem
993e72a564 Fix a bug in the code that updates predecessors that I ran into while investigating rdar://16373728. Before the fix we skipped blocks that branched into two different blocks with phi nodes for the same value.
Swift SVN r15279
2014-03-20 19:47:20 +00:00
Chris Lattner
001c1890e5 put all the SIL*Transform classes in anonymous namespaces, there is
no need for their symbols to be exported out of their implementation
file.


Swift SVN r14714
2014-03-06 01:49:53 +00:00
Andrew Trick
731000b4cd Added -sil-print-all and -sil-verify-all options.
Swift SVN r13662
2014-02-07 23:07:11 +00:00
Nadav Rotem
27a1a63134 Remove unneeded empty virtual destructors.
Swift SVN r13599
2014-02-06 22:24:33 +00:00
Nadav Rotem
1ef0d157ca PassManager: Inject the function/module into the Transformation.
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
2014-02-06 22:11:21 +00:00
Nadav Rotem
7902982833 Teach Mem2Reg not to invalidate all the analysis if no change was made.
Swift SVN r13582
2014-02-06 17:35:18 +00:00
Michael Gottesman
3b43e09bae Change getAnalysis<T> to be asserting and provide a new entry point getAnalysisOrNull<T>. Remove all of the unneeded asserts in the various passes.
Swift SVN r13576
2014-02-06 10:06:18 +00:00
Nadav Rotem
0651b9bbd0 Add a new Dominance Analysis that wraps DomInfo and PDomInfo, and migrate the
passes that use them.



Swift SVN r13571
2014-02-06 07:52:16 +00:00
Nadav Rotem
99b075c32a Rename SILFunctionTrans -> SILFunctionTransform
Swift SVN r13536
2014-02-06 01:32:10 +00:00
Nadav Rotem
f8c7b54d28 Delete the unused performXXX() functions.
Swift SVN r13531
2014-02-06 00:57:28 +00:00
Michael Gottesman
631f9326ab [PM] Change enum => enum class everywhere in the PM code. Additionally fix some typos.
Swift SVN r13507
2014-02-05 21:25:15 +00:00
Nadav Rotem
baa1d1679a Teach some of the passes about the new PM.
Swift SVN r13494
2014-02-05 18:58:23 +00:00
Nadav Rotem
a07aed9d1f Change errs() -> dbgs() in a few files.
Swift SVN r12572
2014-01-20 06:36:50 +00:00
Jordan Rose
11008f0ed1 Split diagnostics out into separate files.
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
2014-01-17 00:15:12 +00:00
Nadav Rotem
4196ce0383 Remove the ugly hack of adding dummy-values.
After r11597 we can add arguments to a block before modifying the branch instructions that target it.



Swift SVN r11598
2013-12-23 06:24:16 +00:00
Nadav Rotem
bfb1c20ed5 Now we promote all non-captured allocas, so we can remove NumAllocStackRemoved because we can calculate it using the other statistics.
Swift SVN r11587
2013-12-23 00:59:42 +00:00
Nadav Rotem
75962b42d1 Remove dead code
Swift SVN r11584
2013-12-23 00:55:46 +00:00
Nadav Rotem
631e7e2230 Update the statistics
Swift SVN r11583
2013-12-23 00:54:01 +00:00
Dave Abrahams
8f6bb405f2 Drop an unused variable
Swift SVN r11581
2013-12-23 00:50:08 +00:00
Nadav Rotem
f44cb1e978 Implement a linear time algorithm for placing phi-nodes.
This commit implements the DJ-graph data-structure and linear time algorithm
for calculating the iterative dominance frontier and placing PHI nodes.
This is the same algorithm that is used by recent versions of LLVM.



Swift SVN r11578
2013-12-22 22:43:43 +00:00
Nadav Rotem
c2541038f8 MEM2REG: It is possible to limit the insertion of phi values by analyzing the liveness of values in the function.
This patch prevents the propagation of PHI-values by using the lifetime markers of the allocation:
1. If the phi value is not dominated by the Allocation then it can't be alive.
2. If the phi value is properly dominated by the deallocation then it must be dead.



Swift SVN r11513
2013-12-20 18:21:09 +00:00
Nadav Rotem
be46520ed8 Refactor fixPhiPredBlock into a helper function that modifies branches. No functionality change.
Swift SVN r11459
2013-12-19 01:05:14 +00:00
Nadav Rotem
b0c7527760 Implement DF-based mem2reg
Swift SVN r11437
2013-12-18 21:33:29 +00:00
Nadav Rotem
ab12a4a7ad Move static members into the class because future features will need access to class members. No functionality change.
Swift SVN r11269
2013-12-13 21:39:08 +00:00
Nadav Rotem
addbe4a086 Iterate over the AllocStack instructions in the function instead of collecting them before we optimize them.
Swift SVN r11202
2013-12-12 19:27:07 +00:00
Nadav Rotem
d0c96e4eeb Implement a very very basic SIL Mem2Reg pass that promotes write-only and single-basicblock allocas.
This pass removes 1/4 of the allocas in the standard library.



Swift SVN r11189
2013-12-12 17:42:50 +00:00