Cameron Zwarich
e35642342b
Eliminate the use of dominance frontiers in PromoteMemToReg. In addition to
...
eliminating a potentially quadratic data structure, this also gives a 17%
speedup when running -scalarrepl on test-suite + SPEC2000 + SPEC2006. My initial
experiment gave a greater speedup around 25%, but I moved the dominator tree
level computation from dominator tree construction to PromoteMemToReg.
Since this approach to computing IDFs has a much lower overhead than the old
code using precomputed DFs, it is worth looking at using this new code for the
second scalarrepl pass as well.
llvm-svn: 123609
2011-01-17 01:08:59 +00:00
Chris Lattner
e6d5b3c4ce
Generalize LoadAndStorePromoter a bit and switch LICM
...
to use it.
llvm-svn: 123501
2011-01-15 00:12:35 +00:00
Chris Lattner
2cf8e75d34
Add a new LoadAndStorePromoter class, which implements the general
...
"promote a bunch of load and stores" logic, allowing the code to
be shared and reused.
llvm-svn: 123456
2011-01-14 19:36:13 +00:00
Chris Lattner
b1ba935526
indentation
...
llvm-svn: 123426
2011-01-14 04:23:53 +00:00
Jakob Stoklund Olesen
37fe53c1a9
Fix a non-deterministic loop in llvm::MergeBlockIntoPredecessor.
...
DT->changeImmediateDominator() trivially ignores identity updates, so there is
really no need for the uniqueing provided by SmallPtrSet.
I expect this to fix PR8954.
llvm-svn: 123286
2011-01-11 22:54:38 +00:00
Chris Lattner
1674862564
this pass claims to preserve scev, make sure to tell it about deletions.
...
llvm-svn: 123247
2011-01-11 18:14:50 +00:00
Frits van Bommel
f5bd48972a
Factor the actual simplification out of SimplifyIndirectBrOnSelect and into a new helper function so it can be reused in e.g. an upcoming SimplifySwitchOnSelect.
...
No functional change.
llvm-svn: 123234
2011-01-11 12:52:11 +00:00
Chris Lattner
a82a6cfe6d
when MergeBlockIntoPredecessor merges two blocks, update MemDep if it
...
is floating around in the ether.
llvm-svn: 123223
2011-01-11 08:16:49 +00:00
Chris Lattner
dc7b2160ba
Fix FoldSingleEntryPHINodes to update memdep and AA when it deletes
...
phi nodes. It is called from MergeBlockIntoPredecessor which is
called from GVN, which claims to preserve these.
I'm skeptical that this is the actual problem behind PR8954, but
this is a stab in the right direction.
llvm-svn: 123222
2011-01-11 08:13:40 +00:00
Chris Lattner
b1a9c9ed36
random cleanups
...
llvm-svn: 123221
2011-01-11 08:00:40 +00:00
Chris Lattner
145e4ee94e
various code cleanups, enhance MergeBlockIntoPredecessor to preserve
...
loop info.
llvm-svn: 123074
2011-01-08 19:08:40 +00:00
Chris Lattner
f1a01c01d9
reduce nesting.
...
llvm-svn: 123071
2011-01-08 18:47:43 +00:00
Cameron Zwarich
a40df277f1
Make more passes preserve dominators (or state that they preserve dominators if
...
they all ready do). This removes two dominator recomputations prior to isel,
which is a 1% improvement in total llc time for 403.gcc.
The only potentially suspect thing is making GCStrategy recompute dominators if
it used a custom lowering strategy.
llvm-svn: 123064
2011-01-08 17:01:52 +00:00
Chris Lattner
397937fa0d
Revamp the ValueMapper interfaces in a couple ways:
...
1. Take a flags argument instead of a bool. This makes
it more clear to the reader what it is used for.
2. Add a flag that says that "remapping a value not in the
map is ok".
3. Reimplement MapValue to share a bunch of code and be a lot
more efficient. For lookup failures, don't drop null values
into the map.
4. Using the new flag a bunch of code can vaporize in LinkModules
and LoopUnswitch, kill it.
No functionality change.
llvm-svn: 123058
2011-01-08 08:15:20 +00:00
Jay Foad
03be607946
Remove all uses of the "ugly" method BranchInst::setUnconditionalDest().
...
llvm-svn: 123025
2011-01-07 20:25:56 +00:00
Duncan Sands
667024a2eb
Speed up instsimplify by about 10-15% by not bothering to retry
...
InstructionSimplify on instructions that didn't change since the
last time round the loop.
llvm-svn: 122745
2011-01-03 10:50:04 +00:00
Chris Lattner
e396e846b4
split dom frontier handling stuff out to its own DominanceFrontier header,
...
so that Dominators.h is *just* domtree. Also prune #includes a bit.
llvm-svn: 122714
2011-01-02 22:09:33 +00:00
Duncan Sands
2d1c116071
Fix PR8702 by not having LoopSimplify claim to preserve LCSSA form. As described
...
in the PR, the pass could break LCSSA form when inserting preheaders. It probably
would be easy enough to fix this, but since currently we always go into LCSSA form
after running this pass, doing so is not urgent.
llvm-svn: 122695
2011-01-02 13:38:21 +00:00
Duncan Sands
74270e8100
Simplify this pass by using a depth-first iterator to ensure that all
...
operands are visited before the instructions themselves.
llvm-svn: 122647
2010-12-31 17:49:05 +00:00
Duncan Sands
ca280dbcd5
Zap dead instructions harder.
...
llvm-svn: 122645
2010-12-31 16:17:54 +00:00
Benjamin Kramer
c84434924f
Make a bunch of symbols internal.
...
llvm-svn: 122642
2010-12-30 22:34:44 +00:00
Benjamin Kramer
30e1ba0fcc
BuildLibCalls: Nuke EmitMemCpy, EmitMemMove and EmitMemSet. They are dead and superseded by IRBuilder.
...
llvm-svn: 122576
2010-12-27 00:25:32 +00:00
Chris Lattner
a73a53e67f
don't lose TD info
...
llvm-svn: 122556
2010-12-25 20:52:04 +00:00
Chris Lattner
38d6d6d367
switch the inliner alignment enforcement stuff to use the
...
getOrEnforceKnownAlignment function, which simplifies the code
and makes it stronger.
llvm-svn: 122555
2010-12-25 20:42:38 +00:00
Chris Lattner
c4cb20b9bf
Move getOrEnforceKnownAlignment out of instcombine into Transforms/Utils.
...
llvm-svn: 122554
2010-12-25 20:37:57 +00:00
Jeffrey Yasskin
a199652a3e
Change all self assignments X=X to (void)X, so that we can turn on a
...
new gcc warning that complains on self-assignments and
self-initializations.
llvm-svn: 122458
2010-12-23 00:58:24 +00:00
Duncan Sands
c7868f60bc
Visit instructions deterministically. Use a FIFO so as to approximately
...
visit instructions before their uses, since InstructionSimplify does a
better job in that case. All this prompted by Frits van Bommel.
llvm-svn: 122343
2010-12-21 17:08:55 +00:00
Duncan Sands
6e2fd37144
If an instruction simplifies, try again to simplify any uses of it. This is
...
not very important since the pass is only used for testing, but it does make
it more realistic. Suggested by Frits van Bommel.
llvm-svn: 122336
2010-12-21 16:12:03 +00:00
Duncan Sands
0a1b3c4cee
Oops, forgot to add the pass itself!
...
llvm-svn: 122265
2010-12-20 21:07:42 +00:00
Duncan Sands
09fbb211eb
Add a new convenience pass for testing InstructionSimplify. Previously
...
it could only be tested indirectly, via instcombine, gvn or some other
pass that makes use of InstructionSimplify, which means that testcases
had to be carefully contrived to dance around any other transformations
that that pass did.
llvm-svn: 122264
2010-12-20 20:54:37 +00:00
Chris Lattner
ba962825a4
when eliding a byval copy due to inlining a readonly function, we have
...
to make sure that the reused alloca has sufficient alignment.
llvm-svn: 122236
2010-12-20 08:10:40 +00:00
Chris Lattner
c0a48df9f9
pull byval processing out to its own helper function.
...
llvm-svn: 122235
2010-12-20 07:57:41 +00:00
Chris Lattner
029952c844
fix PR8769, a miscompilation by inliner when inlining a function with a byval
...
argument. The generated alloca has to have at least the alignment of the
byval, if not, the client may be making assumptions that the new alloca won't
satisfy.
llvm-svn: 122234
2010-12-20 07:45:28 +00:00
Chris Lattner
25d76d1e53
simplify this a bit.
...
llvm-svn: 122156
2010-12-18 20:22:49 +00:00
Benjamin Kramer
39b30b18fa
SimplifyCFG: Ranges can be larger than 64 bits. Fixes Release-selfhost build.
...
llvm-svn: 122054
2010-12-17 10:48:14 +00:00
Chris Lattner
e92f8121d4
improve switch formation to handle small range
...
comparisons formed by comparisons. For example,
this:
void foo(unsigned x) {
if (x == 0 || x == 1 || x == 3 || x == 4 || x == 6)
bar();
}
compiles into:
_foo: ## @foo
## BB#0: ## %entry
cmpl $6, %edi
ja LBB0_2
## BB#1: ## %entry
movl %edi, %eax
movl $91, %ecx
btq %rax, %rcx
jb LBB0_3
instead of:
_foo: ## @foo
## BB#0: ## %entry
cmpl $2, %edi
jb LBB0_4
## BB#1: ## %switch.early.test
cmpl $6, %edi
ja LBB0_3
## BB#2: ## %switch.early.test
movl %edi, %eax
movl $88, %ecx
btq %rax, %rcx
jb LBB0_4
This catches a bunch of cases in GCC, which look like this:
%804 = load i32* @which_alternative, align 4, !tbaa !0
%805 = icmp ult i32 %804, 2
%806 = icmp eq i32 %804, 3
%or.cond121 = or i1 %805, %806
%807 = icmp eq i32 %804, 4
%or.cond124 = or i1 %or.cond121, %807
br i1 %or.cond124, label %.thread, label %808
turning this into a range comparison.
llvm-svn: 122045
2010-12-17 06:20:15 +00:00
Chris Lattner
1499119975
make qsort predicate more conformant by returning 0 for equal values.
...
llvm-svn: 121838
2010-12-15 04:52:41 +00:00
Chris Lattner
c1aaf52608
- Insert new instructions before DomBlock's terminator,
...
which is simpler than finding a place to insert in BB.
- Don't perform the 'if condition hoisting' xform on certain
i1 PHIs, as it interferes with switch formation.
This re-fixes "example 7", without breaking the world hopefully.
llvm-svn: 121764
2010-12-14 08:46:09 +00:00
Chris Lattner
22d4dc5a4d
fix two significant issues with FoldTwoEntryPHINode:
...
first, it can kick in on blocks whose conditions have been
folded to a constant, even though one of the edges will be
trivially folded.
second, it doesn't clean up the "if diamond" that it just
eliminated away. This is a problem because other simplifycfg
xforms kick in depending on the order of block visitation,
causing pointless work.
llvm-svn: 121762
2010-12-14 08:01:53 +00:00
Chris Lattner
362f9a82c0
remove the instsimplify logic I added in r121754. It is apparently
...
breaking the selfhost builds, though I can't fathom how.
llvm-svn: 121761
2010-12-14 07:53:03 +00:00
Chris Lattner
c2e42269ae
clean up logic, convert std::set to SmallPtrSet, handle the case
...
when all 2-entry phis are simplified away.
llvm-svn: 121760
2010-12-14 07:41:39 +00:00
Chris Lattner
8e4194276b
tidy up a bit, move DEBUG down to when we commit to doing the transform so we
...
don't print it unless the xform happens.
llvm-svn: 121758
2010-12-14 07:23:10 +00:00
Chris Lattner
811462b2f4
use SimplifyInstruction instead of reimplementing part of it.
...
llvm-svn: 121757
2010-12-14 07:20:29 +00:00
Chris Lattner
e2400eb801
simplify GetIfCondition by using getSinglePredecessor.
...
llvm-svn: 121756
2010-12-14 07:15:21 +00:00
Chris Lattner
8ea88e66dd
use AddPredecessorToBlock in 3 places instead of a manual loop.
...
llvm-svn: 121755
2010-12-14 07:09:42 +00:00
Chris Lattner
a87ac36a54
make FoldTwoEntryPHINode use instsimplify a bit, make
...
GetIfCondition faster by avoiding pred_iterator. No
really interesting change.
llvm-svn: 121754
2010-12-14 07:00:00 +00:00
Chris Lattner
027d572664
remove the dead (and terrible) llvm::RemoveSuccessor function.
...
llvm-svn: 121753
2010-12-14 06:51:55 +00:00
Chris Lattner
d9436ab7d7
improve DEBUG's a bit, switch to eraseFromParent() to simplify
...
code a bit, switch from constant folding to instsimplify.
llvm-svn: 121751
2010-12-14 06:17:25 +00:00
Chris Lattner
093b5b256d
reapply my recent change that disables a piece of the switch formation
...
work, but fixes 400.perlbmk.
llvm-svn: 121749
2010-12-14 05:57:30 +00:00
Owen Anderson
5536134dc4
Fix recent buildbot breakage by pulling SimplifyCFG back to its state as of r121694, the most recent state
...
where I'm confident there were no crashes or miscompilations. XFAIL the test added since then for now.
llvm-svn: 121733
2010-12-13 23:49:28 +00:00
Chris Lattner
dcba81d96f
temporarily disable part of my previous patch, which causes an iterator invalidation issue, causing a crash on some versions of perlbmk.
...
llvm-svn: 121728
2010-12-13 23:02:19 +00:00
Chris Lattner
759d8aa712
add some DEBUG's.
...
llvm-svn: 121711
2010-12-13 19:55:30 +00:00
Benjamin Kramer
7f1cdac1e4
Fix sort predicate. qsort(3)'s predicate semantics differ from std::sort's. Fixes PR 8780.
...
llvm-svn: 121705
2010-12-13 18:20:38 +00:00
Chris Lattner
0368bf7457
reinstate my patch: the miscompile was caused by an inverted branch in the
...
'and' case.
llvm-svn: 121695
2010-12-13 08:12:19 +00:00
Chris Lattner
caad324345
Completely disable the optimization I added in r121680 until
...
I can track down a miscompile. This should bring the buildbots
back to life
llvm-svn: 121693
2010-12-13 07:41:29 +00:00
Chris Lattner
5ce3e42d80
Make simplifycfg reprocess newly formed "br (cond1 | cond2)" conditions
...
when simplifying, allowing them to be eagerly turned into switches. This
is the last step required to get "Example 7" from this blog post:
http://blog.regehr.org/archives/320
On X86, we now generate this machine code, which (to my eye) seems better
than the ICC generated code:
_crud: ## @crud
## BB#0: ## %entry
cmpb $33, %dil
jb LBB0_4
## BB#1: ## %switch.early.test
addb $-34, %dil
cmpb $58, %dil
ja LBB0_3
## BB#2: ## %switch.early.test
movzbl %dil, %eax
movabsq $288230376537592865, %rcx ## imm = 0x400000017001421
btq %rax, %rcx
jb LBB0_4
LBB0_3: ## %lor.rhs
xorl %eax, %eax
ret
LBB0_4: ## %lor.end
movl $1, %eax
ret
llvm-svn: 121690
2010-12-13 07:00:06 +00:00
Chris Lattner
20b9e84c7e
make this logic a bit simpler.
...
llvm-svn: 121689
2010-12-13 06:36:51 +00:00
Chris Lattner
74d917e19d
split all the guts of SimplifyCFGOpt::run out into one function
...
per terminator kind.
llvm-svn: 121688
2010-12-13 06:25:44 +00:00
Chris Lattner
ea15ce73be
fix a bug in r121680 that upset the various buildbots.
...
llvm-svn: 121687
2010-12-13 05:34:18 +00:00
Chris Lattner
1eb2e235c8
refactor the speculative execution logic to be factored into the cond branch code instead of
...
doing a cfg search for every block simplified.
llvm-svn: 121686
2010-12-13 05:26:52 +00:00
Chris Lattner
4b9e3a31b0
simplify a bunch of code.
...
llvm-svn: 121685
2010-12-13 05:20:28 +00:00
Chris Lattner
d79dd057bf
move HoistThenElseCodeToIf up to a more logical and efficient-to-handle place.
...
llvm-svn: 121684
2010-12-13 05:15:29 +00:00
Chris Lattner
80f8577d74
move 'MergeBlocksIntoPredecessor' call earlier. Use
...
getSinglePredecessor to simplify code.
llvm-svn: 121683
2010-12-13 05:10:48 +00:00
Chris Lattner
7ad8e06c3b
factor new code out to a SimplifyBranchOnICmpChain helper function.
...
llvm-svn: 121681
2010-12-13 05:03:41 +00:00
Chris Lattner
5cbbcc56ad
enhance the "change or icmp's into switch" xform to handle one value in an
...
'or sequence' that it doesn't understand. This allows us to optimize
something insane like this:
int crud (unsigned char c, unsigned x)
{
if(((((((((( (int) c <= 32 ||
(int) c == 46) || (int) c == 44)
|| (int) c == 58) || (int) c == 59) || (int) c == 60)
|| (int) c == 62) || (int) c == 34) || (int) c == 92)
|| (int) c == 39) != 0)
foo();
}
into:
define i32 @crud(i8 zeroext %c, i32 %x) nounwind ssp noredzone {
entry:
%cmp = icmp ult i8 %c, 33
br i1 %cmp, label %if.then, label %switch.early.test
switch.early.test: ; preds = %entry
switch i8 %c, label %if.end [
i8 39, label %if.then
i8 44, label %if.then
i8 58, label %if.then
i8 59, label %if.then
i8 60, label %if.then
i8 62, label %if.then
i8 46, label %if.then
i8 92, label %if.then
i8 34, label %if.then
]
by pulling the < comparison out ahead of the newly formed switch.
llvm-svn: 121680
2010-12-13 04:50:38 +00:00
Chris Lattner
f6be61e969
merge two very similar functions into one that has a bool argument.
...
llvm-svn: 121678
2010-12-13 04:26:26 +00:00
Chris Lattner
003b79e2d3
don't bother handling non-canonical icmp's
...
llvm-svn: 121676
2010-12-13 04:18:32 +00:00
Chris Lattner
9bd0b12342
inline a function, making the result much simpler.
...
llvm-svn: 121675
2010-12-13 04:15:19 +00:00
Chris Lattner
25b642edfd
Fix my previous patch to handle a degenerate case that the llvm-gcc
...
bootstrap buildbot tripped over.
llvm-svn: 121674
2010-12-13 03:43:57 +00:00
Chris Lattner
9b089512e9
convert some methods to be static functions
...
llvm-svn: 121673
2010-12-13 03:30:12 +00:00
Chris Lattner
46cc5158bb
zap two more std::sorts.
...
llvm-svn: 121672
2010-12-13 03:24:30 +00:00
Chris Lattner
a21c02e807
fix a fairly serious oversight with switch formation from
...
or'd conditions. Previously we'd compile something like this:
int crud (unsigned char c) {
return c == 62 || c == 34 || c == 92;
}
into:
switch i8 %c, label %lor.rhs [
i8 62, label %lor.end
i8 34, label %lor.end
]
lor.rhs: ; preds = %entry
%cmp8 = icmp eq i8 %c, 92
br label %lor.end
lor.end: ; preds = %entry, %entry, %lor.rhs
%0 = phi i1 [ true, %entry ], [ %cmp8, %lor.rhs ], [ true, %entry ]
%lor.ext = zext i1 %0 to i32
ret i32 %lor.ext
which failed to merge the compare-with-92 into the switch. With this patch
we simplify this all the way to:
switch i8 %c, label %lor.rhs [
i8 62, label %lor.end
i8 34, label %lor.end
i8 92, label %lor.end
]
lor.rhs: ; preds = %entry
br label %lor.end
lor.end: ; preds = %entry, %entry, %entry, %lor.rhs
%0 = phi i1 [ true, %entry ], [ false, %lor.rhs ], [ true, %entry ], [ true, %entry ]
%lor.ext = zext i1 %0 to i32
ret i32 %lor.ext
which is much better for codegen's switch lowering stuff. This kicks in 33 times
on 176.gcc (for example) cutting 103 instructions off the generated code.
llvm-svn: 121671
2010-12-13 03:18:54 +00:00
Chris Lattner
134d892049
convert an std::sort to array_pod_sort.
...
llvm-svn: 121669
2010-12-13 02:00:58 +00:00
Chris Lattner
153b680cdd
move the "br (X == 0 | X == 1), T, F" -> switch optimization to a new
...
location in simplifycfg. In the old days, SimplifyCFG was never run on
the entry block, so we had to scan over all preds of the BB passed into
simplifycfg to do this xform, now we can just check blocks ending with
a condbranch. This avoids a scan over all preds of every simplified
block, which should be a significant compile-time perf win on functions
with lots of edges. No functionality change.
llvm-svn: 121668
2010-12-13 01:57:34 +00:00
Chris Lattner
644a93e06b
reduce indentation and generally simplify code, no functionality change.
...
llvm-svn: 121667
2010-12-13 01:47:07 +00:00
Chris Lattner
859fad7373
use getFirstNonPHIOrDbg to simplify this code.
...
llvm-svn: 121664
2010-12-13 01:28:06 +00:00
Chris Lattner
21587c9f65
improve comment
...
llvm-svn: 120994
2010-12-06 07:43:04 +00:00
Frits van Bommel
31cf7b99f9
Teach SimplifyCFG to turn
...
(indirectbr (select cond, blockaddress(@fn, BlockA),
blockaddress(@fn, BlockB)))
into
(br cond, BlockA, BlockB).
llvm-svn: 120943
2010-12-05 18:29:03 +00:00
Chris Lattner
0ec89ea5d9
remove the pointless check of MemoryUseIntrinsic from
...
is trivially dead, since these have side effects. This makes the
(misnamed) MemoryUseIntrinsic class dead, so remove it.
llvm-svn: 120382
2010-11-30 02:03:47 +00:00
Duncan Sands
42e2ffcd33
Replace calls to ConstantFoldInstruction with calls to SimplifyInstruction
...
in two places that are really interested in simplified instructions, not
constants.
llvm-svn: 120044
2010-11-23 20:26:33 +00:00
Duncan Sands
f0224e2119
Don't keep track of inserted phis in PromoteMemoryToRegister: the information
...
is never used. Patch by Cameron Zwarich.
llvm-svn: 119963
2010-11-22 09:41:24 +00:00
Benjamin Kramer
9141603779
Simplify code. No change in functionality.
...
llvm-svn: 119908
2010-11-20 18:43:35 +00:00
Duncan Sands
4562d3b919
Factor code for testing whether replacing one value with another
...
preserves LCSSA form out of ScalarEvolution and into the LoopInfo
class. Use it to check that SimplifyInstruction simplifications
are not breaking LCSSA form. Fixes PR8622.
llvm-svn: 119727
2010-11-18 19:59:41 +00:00
Duncan Sands
c84443a206
Have InlineFunction use SimplifyInstruction rather than
...
hasConstantValue. I was leery of using SimplifyInstruction
while the IR was still in a half-baked state, which is the
reason for delaying the simplification until the IR is fully
cooked.
llvm-svn: 119494
2010-11-17 11:16:23 +00:00
Duncan Sands
a2af48a00b
Have RemovePredecessorAndSimplify you SimplifyInstruction
...
rather than hasConstantValue.
llvm-svn: 119457
2010-11-17 04:12:05 +00:00
Duncan Sands
74aeda71dd
Have a few places that want to simplify phi nodes use SimplifyInstruction
...
rather than calling hasConstantValue. No intended functionality change.
llvm-svn: 119352
2010-11-16 17:41:24 +00:00
John Thompson
6115a7f1d4
Inline asm multiple alternative constraints development phase 2 - improved basic logic, added initial platform support.
...
llvm-svn: 117667
2010-10-29 17:29:13 +00:00
Duncan Sands
5b25503aab
Fix PR8445: a block with no predecessors may be the entry block, in which case
...
it isn't unreachable and should not be zapped. The check for the entry block
was missing in one case: a block containing a unwind instruction. While there,
do some small cleanups: "M" is not a great name for a Function* (it would be
more appropriate for a Module*), change it to "Fn"; use Fn in more places.
llvm-svn: 117224
2010-10-24 12:23:30 +00:00
Chandler Carruth
7799a873bb
Switch attribute macros to use 'LLVM_' as a prefix. We retain the old names
...
until other LLVM projects using these are cleaned up.
llvm-svn: 117200
2010-10-23 08:10:43 +00:00
Owen Anderson
deee1e18f1
Passes do not need to recursively initialize passes that they preserve, if
...
they do not also require them. This allows us to reduce inter-pass linkage
dependencies.
llvm-svn: 116854
2010-10-19 20:08:44 +00:00
Owen Anderson
46990c17f7
Get rid of static constructors for pass registration. Instead, every pass exposes an initializeMyPassFunction(), which
...
must be called in the pass's constructor. This function uses static dependency declarations to recursively initialize
the pass's dependencies.
Clients that only create passes through the createFooPass() APIs will require no changes. Clients that want to use the
CommandLine options for passes will need to manually call the appropriate initialization functions in PassInitialization.h
before parsing commandline arguments.
I have tested this with all standard configurations of clang and llvm-gcc on Darwin. It is possible that there are problems
with the static dependencies that will only be visible with non-standard options. If you encounter any crash in pass
registration/creation, please send the testcase to me directly.
llvm-svn: 116820
2010-10-19 17:21:58 +00:00
Devang Patel
dbe2dbee5b
Transfer debug loc to lowered call.
...
Patch by Alexander Herz!
llvm-svn: 116733
2010-10-18 18:53:44 +00:00
Rafael Espindola
16d5617ec3
Fix PR8313 by changing ValueToValueMap use a TrackingVH.
...
llvm-svn: 116390
2010-10-13 02:08:17 +00:00
Rafael Espindola
aa5448f520
Be more consistent in using ValueToValueMapTy.
...
llvm-svn: 116387
2010-10-13 01:36:30 +00:00
Owen Anderson
63f757463c
Begin adding static dependence information to passes, which will allow us to
...
perform initialization without static constructors AND without explicit initialization
by the client. For the moment, passes are required to initialize both their
(potential) dependencies and any passes they preserve. I hope to be able to relax
the latter requirement in the future.
llvm-svn: 116334
2010-10-12 19:48:12 +00:00
Owen Anderson
69cbf2e8b7
Now with fewer extraneous semicolons!
...
llvm-svn: 115996
2010-10-07 22:25:06 +00:00
Owen Anderson
4a9acfa34a
Next step on the getting-rid-of-static-ctors train: begin adding per-library
...
initialization functions that initialize the set of passes implemented in
that library. Add C bindings for these functions as well.
llvm-svn: 115927
2010-10-07 17:55:47 +00:00
Owen Anderson
a8a7bf484f
Move the pass initialization helper functions into the llvm namespace, and add
...
a header declaring them all. This is also where we will declare per-library pass-set
initializer functions down the road.
llvm-svn: 115900
2010-10-07 04:13:08 +00:00
Oscar Fuentes
eb27a44982
Removed a bunch of unnecessary target_link_libraries.
...
llvm-svn: 114999
2010-09-28 22:39:14 +00:00
Michael J. Spencer
87fea6690f
Get rid of pop_macro warnings on MSVC.
...
llvm-svn: 114750
2010-09-24 19:48:47 +00:00
Michael J. Spencer
90f807fda5
Revert "CMake: Get rid of LLVMLibDeps.cmake and export the libraries normally."
...
This reverts commit r113632
Conflicts:
cmake/modules/AddLLVM.cmake
llvm-svn: 113819
2010-09-13 23:59:48 +00:00
John Thompson
ae3a86d6de
Added skeleton for inline asm multiple alternative constraint support.
...
llvm-svn: 113766
2010-09-13 18:15:37 +00:00
Gabor Greif
dfe6dea95f
typoes
...
llvm-svn: 113647
2010-09-10 22:25:58 +00:00
Michael J. Spencer
98ad3f2ea7
CMake: Get rid of LLVMLibDeps.cmake and export the libraries normally.
...
llvm-svn: 113632
2010-09-10 21:14:25 +00:00
Dan Gohman
e1ad0ebbcc
Fix LoopSimplify to notify ScalarEvolution when splitting a loop backedge
...
into an inner loop, as the new loop iteration may differ substantially.
This fixes PR8078.
llvm-svn: 113057
2010-09-04 02:42:48 +00:00
Duncan Sands
a95548a8d2
Reapply commit 112699, speculatively reverted by echristo, since
...
I'm sure it is harmless. Original commit message:
If PrototypeValue is erased in the middle of using the SSAUpdator
then the SSAUpdator may access freed memory. Instead, simply pass
in the type and name explicitly, which is all that was used anyway.
llvm-svn: 112810
2010-09-02 08:14:03 +00:00
Eric Christopher
f72b7040a2
Speculatively revert 112699 and 112702, they seem to be causing
...
self host errors on clang-x86-64.
llvm-svn: 112719
2010-09-01 17:29:10 +00:00
Duncan Sands
f7e2f45e1a
If PrototypeValue is erased in the middle of using the SSAUpdator
...
then the SSAUpdator may access freed memory. Instead, simply pass
in the type and name explicitly, which is all that was used anyway.
llvm-svn: 112699
2010-09-01 10:29:33 +00:00
Chris Lattner
fac07b1dca
implement SSAUpdater::RewriteUseAfterInsertions, a helpful form of RewriteUse.
...
llvm-svn: 112409
2010-08-29 04:54:06 +00:00
Chris Lattner
4b49ada02c
remove the ABCD and SSI passes. They don't have any clients that
...
I'm aware of, aren't maintained, and LVI will be replacing their value.
nlewycky approved this on irc.
llvm-svn: 112355
2010-08-28 03:51:24 +00:00
Dan Gohman
8088d5e31d
Reapply r112091 and r111922, support for metadata linking, with a
...
fix: add a flag to MapValue and friends which indicates whether
any module-level mappings are being made. In the common case of
inlining, no module-level mappings are needed, so MapValue doesn't
need to examine non-function-local metadata, which can be very
expensive in the case of a large module with really deep metadata
(e.g. a large C++ program compiled with -g).
This flag is a little awkward; perhaps eventually it can be moved
into the ClonedCodeInfo class.
llvm-svn: 112190
2010-08-26 15:41:53 +00:00
Daniel Dunbar
3839de70f5
Revert r111922, "MapValue support for MDNodes. This is similar to r109117,
...
except ...", it is causing *massive* performance regressions when building Clang
with itself (-O3 -g).
llvm-svn: 112158
2010-08-26 03:48:11 +00:00
Daniel Dunbar
aeb8abb0e0
Revert r112091, "Remap metadata attached to instructions when remapping
...
individual ...", which depends on r111922, which I am reverting.
llvm-svn: 112157
2010-08-26 03:48:08 +00:00
Dan Gohman
d19a0a49d1
Remap metadata attached to instructions when remapping individual
...
instructions, not when remapping modules.
llvm-svn: 112091
2010-08-25 21:36:50 +00:00
Dan Gohman
30fd721e48
Use MapValue in the Linker instead of having a private function
...
which does the same thing. This eliminates redundant code and
handles MDNodes better. MDNode linking still doesn't fully
work yet though.
llvm-svn: 111941
2010-08-24 18:50:07 +00:00
Dan Gohman
5cbd5888e7
MapValue support for MDNodes. This is similar to r109117, except
...
that it avoids a lot of unnecessary cloning by avoiding remapping
MDNode cycles when none of the nodes in the cycle actually need to
be remapped. Also it uses the new temporary MDNode mechanism.
llvm-svn: 111922
2010-08-24 17:10:10 +00:00
Owen Anderson
fe3d206e65
Now that PassInfo and Pass::ID have been separated, move the rest of the passes over to the new registration API.
...
llvm-svn: 111815
2010-08-23 17:52:01 +00:00
Chris Lattner
4c6e9192d1
fit in 80 cols
...
llvm-svn: 111348
2010-08-18 03:13:35 +00:00
Chris Lattner
d20a060467
remove some dead code.
...
llvm-svn: 111344
2010-08-18 02:41:56 +00:00
Dan Gohman
aec27f6889
Use the getUniquePredecessor() utility function, instead of doing
...
what it does manually.
llvm-svn: 111248
2010-08-17 17:07:02 +00:00
Dan Gohman
80b2503100
Avoid #include <ScalarEvolution.h> in LoopSimplify.cpp, which doesn't
...
actually use ScalarEvolution.
llvm-svn: 111124
2010-08-16 14:44:03 +00:00
Dan Gohman
9178d0792f
Instead, teach SimplifyCFG to trim non-address-taken blocks from
...
indirectbr destination lists.
llvm-svn: 111122
2010-08-16 14:41:14 +00:00
Dan Gohman
afb3db46d2
LoopSimplify shouldn't split loop backedges that use indirectbr. PR7867.
...
llvm-svn: 111061
2010-08-14 00:43:09 +00:00
Dan Gohman
d04a608a73
Teach SimplifyCFG how to simplify indirectbr instructions.
...
- Eliminate redundant successors.
- Convert an indirectbr with one successor into a direct branch.
Also, generalize SimplifyCFG to be able to be run on a function entry block.
It knows quite a few simplifications which are applicable to the entry
block, and it only needs a few checks to avoid trouble with the entry block.
llvm-svn: 111060
2010-08-14 00:29:42 +00:00
Dan Gohman
13c66ce161
Eliminate PromoteMemoryToRegisterID; just use addPreserved("mem2reg")
...
instead, as an example of what this looks like.
llvm-svn: 110478
2010-08-06 21:48:06 +00:00
Owen Anderson
f2fea95f2f
Reapply r110396, with fixes to appease the Linux buildbot gods.
...
llvm-svn: 110460
2010-08-06 18:33:48 +00:00
Owen Anderson
aadd8a89ca
Revert r110396 to fix buildbots.
...
llvm-svn: 110410
2010-08-06 00:23:35 +00:00
Owen Anderson
b9762c07cb
Don't use PassInfo* as a type identifier for passes. Instead, use the address of the static
...
ID member as the sole unique type identifier. Clean up APIs related to this change.
llvm-svn: 110396
2010-08-05 23:42:04 +00:00
Gabor Greif
ecd9b45b05
simplify
...
llvm-svn: 109589
2010-07-28 15:52:43 +00:00
Gabor Greif
394841cea8
simplify: CallSite::get --> CallSite constructor
...
llvm-svn: 109506
2010-07-27 15:02:37 +00:00
Dan Gohman
23a6a1bdc5
Remove LCSSA's bogus dependence on LoopSimplify and LoopSimplify's bogus
...
dependence on DominanceFrontier. Instead, add an explicit DominanceFrontier
pass in StandardPasses.h to ensure that it gets scheduled at the right
time.
Declare that loop unrolling preserves ScalarEvolution, and shuffle some
getAnalysisUsages.
This eliminates one LoopSimplify and one LCCSA run in the standard
compile opts sequence.
llvm-svn: 109413
2010-07-26 18:11:16 +00:00
Dan Gohman
7d588b7dec
Preserve ScalarEvolution in the loop unroller.
...
llvm-svn: 109412
2010-07-26 18:02:06 +00:00
Nick Lewycky
8cbc57da86
Revert this because we can't clone cyclic MDNodes which are creating during a
...
build of llvm-gcc.
llvm-svn: 109355
2010-07-24 20:54:02 +00:00
Nick Lewycky
7094bd27bc
Whether function-local or not, a MDNode may reference a Function in which case
...
it needs to be mapped to refer to the function in the new module, not the old
one. Fixes PR7700.
llvm-svn: 109353
2010-07-24 19:43:25 +00:00
Devang Patel
f53de95e64
Speculatively revert 109117
...
llvm-svn: 109132
2010-07-22 18:44:00 +00:00
Gabor Greif
feb96f2df2
keep in 80 cols
...
llvm-svn: 109122
2010-07-22 17:18:03 +00:00
Devang Patel
58b7143697
Map MDNode correctly.
...
A non function local MDNode can have an operand which is cloned by MapValue().
llvm-svn: 109117
2010-07-22 16:35:00 +00:00
Gabor Greif
96a9f8c7c6
mass elimination of reliance on automatic iterator dereferencing
...
llvm-svn: 109103
2010-07-22 13:36:47 +00:00
Gabor Greif
87ef691878
pass dereferenced iterator to dyn_cast
...
llvm-svn: 109098
2010-07-22 11:43:44 +00:00
Gabor Greif
a7509fca78
undo 80 column trespassing I caused
...
llvm-svn: 109092
2010-07-22 10:37:47 +00:00
Dan Gohman
859ffd353e
Make NamedMDNode not be a subclass of Value, and simplify the interface
...
for creating and populating NamedMDNodes.
llvm-svn: 109061
2010-07-21 23:38:33 +00:00
Owen Anderson
f8addbb0a1
Fix batch of converting RegisterPass<> to INTIALIZE_PASS().
...
llvm-svn: 109045
2010-07-21 22:09:45 +00:00
Dan Gohman
6f009c4a42
Use DebugLocs instead of MDNodes.
...
llvm-svn: 108967
2010-07-20 23:49:05 +00:00
Dan Gohman
66ae369e76
Don't look up the "dbg" metadata kind by name.
...
llvm-svn: 108961
2010-07-20 23:09:34 +00:00
Dan Gohman
b5593f8fda
Reorder the contents of various getAnalysisUsage functions, eliminating
...
a redundant loopsimplify run from the default -O2 sequence.
llvm-svn: 108539
2010-07-16 17:58:45 +00:00
Gabor Greif
17c48ecd68
eliminate CallInst::ArgOffset
...
llvm-svn: 108522
2010-07-16 09:38:02 +00:00
Owen Anderson
b9f325bab4
Remove unneeded check, and correct style.
...
llvm-svn: 108427
2010-07-15 16:38:22 +00:00
Chris Lattner
63cfa4b8e0
make various clients of ReplaceAndSimplifyAllUses tolerate
...
it *changing* the things it replaces, not just causing them
to drop to null. There is no functionality change yet, but
this is required for a subsequent patch.
llvm-svn: 108414
2010-07-15 06:06:04 +00:00
Owen Anderson
5de6c42ebd
Extend SimplifyCFG's common-destination folding heuristic to allow a single
...
"bonus" instruction to be speculatively executed. Add a heuristic to
ensure we're not tripping up out-of-order execution by checking that this bonus
instruction only uses values that were already guaranteed to be available.
This allows us to eliminate the short circuit in (x&1)&&(x&2).
llvm-svn: 108351
2010-07-14 19:52:16 +00:00
Gabor Greif
95805d51b8
cache dereferenced iterators
...
llvm-svn: 108133
2010-07-12 10:59:23 +00:00
Gabor Greif
32f6368a27
cache dereferenced iterators
...
llvm-svn: 108132
2010-07-12 10:49:54 +00:00
Gabor Greif
4d1241bddb
cache result of operator*
...
llvm-svn: 107984
2010-07-09 16:31:08 +00:00
Gabor Greif
fc355ccebb
cache result of operator*
...
llvm-svn: 107983
2010-07-09 16:26:41 +00:00
Gabor Greif
9259059af3
cache result of operator*
...
llvm-svn: 107981
2010-07-09 16:17:52 +00:00
Gabor Greif
4d54dede01
cache result of operator*
...
llvm-svn: 107975
2010-07-09 15:25:42 +00:00
Gabor Greif
dcaa85787c
cache result of operator*
...
llvm-svn: 107974
2010-07-09 15:25:09 +00:00
Gabor Greif
a9fbbe2dbb
cache result of operator*
...
llvm-svn: 107968
2010-07-09 14:29:14 +00:00
Gabor Greif
a5fdd0955d
cache result of operator*
...
llvm-svn: 107966
2010-07-09 14:18:23 +00:00
Gabor Greif
cda479a708
cache operator*'s result (in multiple functions)
...
llvm-svn: 107965
2010-07-09 14:02:13 +00:00
Devang Patel
1c47157b66
MDString is already checked earlier.
...
llvm-svn: 107516
2010-07-02 21:13:23 +00:00
Jim Grosbach
f5a790e251
lowerinvoke needs to handle aggregate function args like sjlj eh does.
...
llvm-svn: 107335
2010-06-30 22:22:59 +00:00
Gabor Greif
a77e545e60
use getArgOperand instead of getOperand
...
llvm-svn: 107269
2010-06-30 09:14:26 +00:00
Gabor Greif
98947dcd6d
use CallInst::ArgOffset
...
llvm-svn: 107003
2010-06-28 12:30:07 +00:00
Gabor Greif
1c2bae559b
use ArgOperand API and CallInst::ArgOffset
...
llvm-svn: 107002
2010-06-28 12:29:20 +00:00
Dale Johannesen
b1fc776fca
The hasMemory argument is irrelevant to how the argument
...
for an "i" constraint should get lowered; PR 6309. While
this argument was passed around a lot, this is the only
place it was used, so it goes away from a lot of other
places.
llvm-svn: 106893
2010-06-25 21:55:36 +00:00
Gabor Greif
42cbeeeb2e
use ArgOperand API (one more hunk I could split)
...
llvm-svn: 106825
2010-06-25 07:58:41 +00:00
Gabor Greif
d2559bceee
use ArgOperand API (some hunks I could split)
...
llvm-svn: 106824
2010-06-25 07:57:14 +00:00
Gabor Greif
14afc1e2d9
use callsite to obtain all arguments
...
llvm-svn: 106728
2010-06-24 09:56:43 +00:00
Devang Patel
0c927a80fe
Use ValueMap instead of DenseMap.
...
The ValueMapper used by various cloning utility maps MDNodes also.
llvm-svn: 106706
2010-06-24 00:33:28 +00:00
Devang Patel
ad744f3fa3
Use available typedef for " DenseMap<const Value*, Value*>".
...
llvm-svn: 106699
2010-06-24 00:00:42 +00:00
Devang Patel
373b10cbaa
Cosmetic change.
...
Do not use "ValueMap" as a name for a local variable or an argument.
llvm-svn: 106698
2010-06-23 23:55:51 +00:00
Devang Patel
1967a51efc
Revert 106592 for now. It causes clang-selfhost build failure.
...
llvm-svn: 106598
2010-06-22 23:29:55 +00:00
Devang Patel
a24bf5907c
If a metadata operand is seeded in value map and the metadata should also be seeded in value map. This is not limited to function local metadata.
...
Failure to seed metdata in such cases causes troubles when in a cloned module, metadata from a new module refers to values in old module. Usually this results in mysterious bugpoint crashes. For example,
Checking to see if we can delete global inits: Unknown constant!
UNREACHABLE executed at /d/g/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:904!
llvm-svn: 106592
2010-06-22 22:53:21 +00:00
Devang Patel
dca60347e5
While cloning a module, clone metadata attached with instructions.
...
llvm-svn: 106591
2010-06-22 22:50:42 +00:00
Devang Patel
eba73529a6
Clone named metadata while cloning a module.
...
Reapply Bob's patch.
llvm-svn: 106560
2010-06-22 18:52:38 +00:00
Dan Gohman
74d5144414
Use pre-increment instead of post-increment when the result is not used.
...
llvm-svn: 106542
2010-06-22 15:08:57 +00:00
Devang Patel
981ff4464c
Revert 106528. It is causing self host failures.
...
llvm-svn: 106529
2010-06-22 06:14:09 +00:00
Devang Patel
d5696fa05b
Do not rely on DenseMap slot which can be easily invalidated when DenseMap grows.
...
llvm-svn: 106528
2010-06-22 05:16:56 +00:00
Bob Wilson
714eba185c
Revert my change to clone named metadata. Buildbots are complaining.
...
--- Reverse-merging r106508 into '.':
U lib/Transforms/Utils/CloneModule.cpp
llvm-svn: 106521
2010-06-22 02:08:51 +00:00
Bob Wilson
6a07aa9ae8
Include named metadata when cloning a module.
...
llvm-svn: 106508
2010-06-22 00:11:03 +00:00
Dan Gohman
6a3c46ad49
Use A.append(...) instead of A.insert(A.end(), ...) when A is a
...
SmallVector, and other SmallVector simplifications.
llvm-svn: 106452
2010-06-21 19:47:52 +00:00
Jim Grosbach
f5107a8ada
remove trailing whitespace
...
llvm-svn: 106164
2010-06-16 22:41:09 +00:00
Benjamin Kramer
21a49e9375
simplify-libcalls: fold strstr(a, b) == a -> strncmp(a, b, strlen(b)) == 0
...
llvm-svn: 106047
2010-06-15 21:34:25 +00:00
Devang Patel
8bf4434e6e
Copy location info for current function argument from dbg.declare if respective store instruction does not have any location info.
...
llvm-svn: 105490
2010-06-04 22:27:30 +00:00
Jim Grosbach
909aafbacf
Remove unused code
...
llvm-svn: 105293
2010-06-01 21:56:30 +00:00
Jim Grosbach
b37767db31
fix think-o
...
llvm-svn: 105291
2010-06-01 21:35:50 +00:00
Jim Grosbach
ec24c70e3f
Simplify things a bit more. Fix prototype to use SmallVectorImpl and
...
change a few SmallVectors to vanilla C arrays.
llvm-svn: 105289
2010-06-01 21:06:46 +00:00
Jim Grosbach
457e04c48c
mirror of r105280 changes for LowerInvoke, which uses the same basic logic here
...
llvm-svn: 105281
2010-06-01 18:04:56 +00:00
Jim Grosbach
eb2ca21aec
Use SmallVector instead of std::vector.
...
llvm-svn: 105279
2010-06-01 17:56:41 +00:00
Duncan Sands
da677f56f2
Fix PR7272: when inlining through a callsite with byval arguments,
...
the newly created allocas may be used by inlined calls, so these
need to have their tail call flags cleared. Fixes PR7272.
llvm-svn: 105255
2010-05-31 21:00:26 +00:00
Nick Lewycky
418d80e555
The memcpy intrinsic only takes i8* for %src and %dst, so cast them to that
...
first. Fixes PR7265.
llvm-svn: 105206
2010-05-31 06:16:35 +00:00
Dan Gohman
0d7d3faf8e
Move FindAvailableLoadedValue isSafeToLoadUnconditionally out of
...
lib/Transforms/Utils and into lib/Analysis so that Analysis passes
can use them.
llvm-svn: 104949
2010-05-28 16:19:17 +00:00
Devang Patel
46e30f80bf
Fix typo.
...
llvm-svn: 104914
2010-05-28 01:29:50 +00:00
Devang Patel
d7be13168c
Fix typo.
...
llvm-svn: 104913
2010-05-28 01:17:51 +00:00
Devang Patel
8d4eb26f24
Do not drop location info for inlined function args.
...
llvm-svn: 104884
2010-05-27 20:25:04 +00:00
Douglas Gregor
2f2491405a
Fixes for Microsoft Visual Studio 2010, from Steven Watanabe!
...
llvm-svn: 103457
2010-05-11 06:17:44 +00:00
Devang Patel
0638b539bb
Wrap const MDNode * inside DIDescriptor.
...
llvm-svn: 103295
2010-05-07 20:54:48 +00:00
Devang Patel
5b2d1c23a7
Use overloaded operators instead of DIDescriptor::getNode()
...
llvm-svn: 103276
2010-05-07 18:19:32 +00:00
Bob Wilson
e81252b747
Combine the implementations of the core part of the SSAUpdater and
...
MachineSSAUpdater to avoid duplicating all the code.
llvm-svn: 103060
2010-05-04 23:18:19 +00:00
Chris Lattner
66d1a6ad69
rename InlineInfo.DevirtualizedCalls -> InlinedCalls to
...
reflect that it includes all inlined calls now, not just
devirtualized ones.
llvm-svn: 102824
2010-05-01 01:26:13 +00:00