1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-21 20:12:56 +02:00
Commit Graph

8495 Commits

Author SHA1 Message Date
Bill Wendling
bc21b6ec6d When inserting new instructions, use getFirstInsertionPt instead of
getFirstNonPHI so that it will skip over the landingpad instructions as well.

llvm-svn: 138537
2011-08-25 01:08:34 +00:00
Bill Wendling
15062f817a Skip the landingpad instruction when determining the insertion point.
llvm-svn: 138481
2011-08-24 21:06:46 +00:00
Bill Wendling
0301dcfde8 Use getFirstInsertionPt instead of getFirstNonPHI so that it skips to the proper
insertion place.

llvm-svn: 138473
2011-08-24 20:28:43 +00:00
Rafael Espindola
e864ec28bd Fix a crashing bug in SplitBlock when it is called on a block with no
dominator information even though dominators were previously computed.

Patch by Nick Sumner.

llvm-svn: 138449
2011-08-24 18:07:01 +00:00
Dan Gohman
a6ceaf82c5 Add a comment.
llvm-svn: 138243
2011-08-22 17:29:37 +00:00
Dan Gohman
9619488506 Constant pointers to objects don't need reference counting.
llvm-svn: 138242
2011-08-22 17:29:11 +00:00
Bill Wendling
bfc0c6c1de If we're splitting the landing pad block and assigning it only one predecessor,
then don't split it a second time, since that block will be dead.

llvm-svn: 138153
2011-08-19 23:46:30 +00:00
Bill Wendling
31d80032c6 The landingpad instruction isn't dead simply because it's value isn't used.
llvm-svn: 138102
2011-08-19 21:52:06 +00:00
Benjamin Kramer
0d60a5573c Make a bunch of symbols private.
llvm-svn: 138025
2011-08-19 01:42:18 +00:00
Benjamin Kramer
c5a90f3683 C API functions must be able to see their extern "C" definitions, or it will be impossible to call them from C.
llvm-svn: 138022
2011-08-19 01:36:54 +00:00
Dan Gohman
c5d64c76e0 Track a retain+release nesting level independently of the
known-incremented level, because the two concepts can be used
to prove the saftey of a retain+release removal in different
ways.

llvm-svn: 138016
2011-08-19 00:26:36 +00:00
Bill Wendling
4eead96931 Intelligently split the landing pad block.
We have to be careful when splitting the landing pad block, because the
landingpad instruction is required to remain as the first non-PHI of an invoke's
unwind edge. To retain this, we split the block into two blocks, moving the
predecessors within the loop to one block and the remaining predecessors to the
other. The landingpad instruction is cloned into the new blocks.

llvm-svn: 138015
2011-08-19 00:09:22 +00:00
Bill Wendling
3079e1ccda Add SplitLandingPadPredecessors().
SplitLandingPadPredecessors is similar to SplitBlockPredecessors in that it
splits the current block and attaches a set of predecessors to the new basic
block. However, it differs from SplitBlockPredecessors in that it's specifically
designed to handle landing pad blocks.

Two new basic blocks are created: one that is has the vector of predecessors as
its predecessors and one that has the remaining predecessors as its
predecessors. Those two new blocks then receive a cloned copy of the landingpad
instruction from the original block. The landingpad instructions are joined in a
PHI, etc. Like SplitBlockPredecessors, it updates the LLVM IR, AliasAnalysis,
DominatorTree, DominanceFrontier, LoopInfo, and LCCSA analyses.

llvm-svn: 138014
2011-08-19 00:05:40 +00:00
Bill Wendling
ba667af404 Use 'getFirstInsertionPt' when trying to insert new instructions during LICM.
llvm-svn: 138008
2011-08-18 23:42:36 +00:00
Dan Gohman
323adc0a3a Make it clear that this code is iterating in reverse order through the array.
llvm-svn: 137985
2011-08-18 21:27:42 +00:00
Bill Wendling
fef33f1d24 Revert r137871. The loop simplify pass should require all exits from a loop that
aren't from an indirect branch need to be dominated by the loop header.

llvm-svn: 137981
2011-08-18 21:10:01 +00:00
Bill Wendling
f3c0fabac7 Split out the updating of PHI nodes after splitting the BB into a separate
function.

llvm-svn: 137979
2011-08-18 20:51:04 +00:00
Bill Wendling
dec05a3784 Use this fantzy ArrayRef thing to pass in the list of predecessors.
llvm-svn: 137978
2011-08-18 20:39:32 +00:00
Nick Lewycky
0b43a027b3 The edge from DISubprogram to DICompileUnit has been removed in recent versions
of debug info.

llvm-svn: 137972
2011-08-18 19:07:42 +00:00
Bill Wendling
3fbc8471bb Use static instead of anonymous namespace.
llvm-svn: 137959
2011-08-18 17:57:57 +00:00
Bill Wendling
42b9a110e0 Split out the analysis updating code into a helper function. No intended
functionality change.

llvm-svn: 137926
2011-08-18 05:25:23 +00:00
Devang Patel
43e799cc40 Dramatically speedup codegen prepare by a) avoiding use of dominator tree and b) doing a separate pass over dbg.value instructions.
llvm-svn: 137908
2011-08-18 00:50:51 +00:00
Devang Patel
e1be26fa38 Do not use DebugInfoFinder. Extract debug info directly from llvm.dbg.cu named mdnode.
llvm-svn: 137890
2011-08-17 22:49:38 +00:00
Eli Friedman
775a316a06 Atomic load/store handling for the passes using memdep (GVN, DSE, memcpyopt).
llvm-svn: 137888
2011-08-17 22:22:24 +00:00
Bill Wendling
fa8d0e1aea Disable PRE for landing pads.
PRE needs the landing pads to have their critical edges split. Doing this for a
landing pad is non-trivial. Abandon the attempt to perform PRE when we come
across a landing pad. (Reviewed by Owen!)

llvm-svn: 137876
2011-08-17 21:32:02 +00:00
Bill Wendling
e626358c3c Increment the insertion iterator to beyond the landingpad instruction.
llvm-svn: 137872
2011-08-17 21:21:31 +00:00
Bill Wendling
094d34f377 Don't optimize the landing pad exit block.
One way to exit the loop is through an unwind edge. However, that may involve
splitting the critical edge of the landing pad, which is non-trivial. Prevent
the transformation from rewriting the landing pad exit loop block.

llvm-svn: 137871
2011-08-17 21:20:43 +00:00
Bill Wendling
c8581928f3 Assert that we aren't trying to split the critical edge of a landing pad. Doing
so requires more care than this generic algorithm should handle.

llvm-svn: 137866
2011-08-17 21:04:05 +00:00
Bill Wendling
3566980062 Revert r137655. There is some question about whether the 'landingpad'
instruction should be marked as potentially reading and/or writing memory.

llvm-svn: 137863
2011-08-17 20:36:44 +00:00
Eli Friedman
e1655eebc3 Silly mistake from r137777; restore significant isStructTy() checks. While here, be a bit more defensive
with unknown instructions.

Fixes PR10687.

llvm-svn: 137836
2011-08-17 18:10:43 +00:00
Eli Friedman
b4733f623f A bunch of misc fixes to SCCPSolver::ResolvedUndefsIn, including a fix to stop
making random bad assumptions about instructions which are not explicitly listed.  

Includes fix for rdar://9956541, a version of "undef ^ undef should return
0 because it's easier than arguing with users".

llvm-svn: 137777
2011-08-16 22:06:31 +00:00
Eli Friedman
e0095e4339 Minor bug in SCCP found by inspection. (I don't think it's possible to hit this with a normal pass pipeline, but fixing for completeness.)
llvm-svn: 137755
2011-08-16 21:12:35 +00:00
Bill Wendling
3d7b8eaa78 Use the getFirstInsertionPt() method instead of getFirstNonPHI + an 'isa<>'
check for a LandingPadInst.

llvm-svn: 137745
2011-08-16 20:45:24 +00:00
Bill Wendling
32612231af I think there was some confusion about what I meant. :-) Replacing the comment.
llvm-svn: 137743
2011-08-16 20:41:17 +00:00
David Chisnall
cfbcd5cf21 Add a mechanism for optimisation plugins to register passes that all front ends can use without needing to be aware of the plugin (or the plugin be aware of the front end).
Before 3.0, I'd like to add a mechanism for automatically loading a set of plugins from a config file.  API suggestions welcome...

llvm-svn: 137717
2011-08-16 13:58:41 +00:00
Bill Wendling
3e159bd43d A few places where we want to skip the landingpad instruction for insertion.
llvm-svn: 137712
2011-08-16 04:52:55 +00:00
Eli Friedman
66e399697a Revert a bit of r137667; the logic in question can safely handle atomic load/store.
llvm-svn: 137702
2011-08-16 01:28:22 +00:00
Eli Friedman
f969dabf83 After talking with Bill, it seems like the LandingPad handling here is likely
to be wrong (or at least somewhat suspect).  Leave a FIXME for Bill.

llvm-svn: 137694
2011-08-16 00:41:37 +00:00
Eli Friedman
eb7e5209e5 Minor comment fixes.
llvm-svn: 137693
2011-08-16 00:20:11 +00:00
Eli Friedman
6a475e691d Update SimplifyCFG for atomic operations.
This commit includes a mention of the landingpad instruction, but it's not
changing the behavior around it.  I think the current behavior is correct,
though.  Bill, can you double-check that?

llvm-svn: 137691
2011-08-15 23:59:28 +00:00
Eli Friedman
f0e7c084ea Add comments and test for atomic load/store and mem2reg.
llvm-svn: 137690
2011-08-15 23:55:52 +00:00
Bill Wendling
3a5b0249c3 In places where it's using "getFirstNonPHI", skip the landingpad instruction if necessary.
llvm-svn: 137679
2011-08-15 23:19:54 +00:00
Bill Wendling
3016a47ed2 Don't sink the instruction to before a landingpad instruction.
llvm-svn: 137672
2011-08-15 22:53:05 +00:00
Eli Friedman
fdd5480178 Update inter-procedural optimizations for atomic load/store.
llvm-svn: 137667
2011-08-15 22:16:46 +00:00
Eli Friedman
36ef5fd140 Update instcombine for atomic load/store.
llvm-svn: 137664
2011-08-15 22:09:40 +00:00
Bill Wendling
a75d2d0416 Duncan pointed out that the LandingPadInst might read memory. (It might also
write to memory.) Marking it as such makes some checks for immobility go away.

llvm-svn: 137655
2011-08-15 21:14:31 +00:00
Eli Friedman
b25f5aeda5 Fix llvm::CloneModule to correctly clone globals. Patch per bug report by Simon Moll on llvmdev.
llvm-svn: 137654
2011-08-15 21:05:06 +00:00
Eli Friedman
e18709e5b2 Atomic load/store support in LICM.
llvm-svn: 137648
2011-08-15 20:52:09 +00:00
Bill Wendling
0c8837a1f1 The "landingpad" instruction will never be "trivially" dead.
llvm-svn: 137642
2011-08-15 20:10:51 +00:00
Bill Wendling
a8d6570a7a Don't try to sink the landingpad instruction. It's immobile.
llvm-svn: 137629
2011-08-15 18:23:40 +00:00
Bill Wendling
b0c5dd0ebd Mark the SCC as "might unwind" if we run into a 'resume' instruction.
llvm-svn: 137627
2011-08-15 18:22:00 +00:00
Bill Wendling
a5dc9de3c4 Skip the insertion iterator past the landingpad instruction if there.
llvm-svn: 137626
2011-08-15 18:21:07 +00:00
Bill Wendling
e4ea267524 Add inlining for the new EH scheme.
This builds off of the current scheme, but instead of llvm.eh.exception and
llvm.eh.selector, it uses the landingpad instruction. And instead of
llvm.eh.resume, it uses the resume instruction.

Because of the invariants in the landing pad instruction, a lot of code that's
currently needed to find the appropriate intrinsic calls for an invoke
instruction won't be needed once we go to the new EH scheme. The "FIXME"s tell
us what to remove after we switch.

llvm-svn: 137576
2011-08-14 08:01:36 +00:00
Nick Lewycky
e020632f7e This transform is not safe. Thanks to Eli for pointing that out!
llvm-svn: 137575
2011-08-14 04:51:49 +00:00
Nick Lewycky
0326303a7a Don't attempt to add 'nsw' when intermediate instructions had no such guarantee.
llvm-svn: 137572
2011-08-14 03:41:33 +00:00
Nick Lewycky
b6a9488190 Teach instcombine to preserve the nsw bit by doing an after-the-fact analysis
when combining add and sub instructions. Patch by Pranav Bhandarkar!

llvm-svn: 137570
2011-08-14 01:45:19 +00:00
Bill Wendling
4cbbcd4f82 Initial commit of the 'landingpad' instruction.
This implements the 'landingpad' instruction. It's used to indicate that a basic
block is a landing pad. There are several restrictions on its use (see
LangRef.html for more detail). These restrictions allow the exception handling
code to gather the information it needs in a much more sane way.

This patch has the definition, implementation, C interface, parsing, and bitcode
support in it.

llvm-svn: 137501
2011-08-12 20:24:12 +00:00
Chris Lattner
ef56f8992d switch to use the new api for structtypes.
llvm-svn: 137480
2011-08-12 18:06:37 +00:00
Duncan Sands
10a9e984bc Silence a bunch (but not all) "variable written but not read" warnings
when building with assertions disabled.

llvm-svn: 137460
2011-08-12 14:54:45 +00:00
Dan Gohman
c188a47b62 Don't convert objc_autoreleaseReturnValue to objc_autorelease if the result
is returned through a bitcast.

llvm-svn: 137402
2011-08-12 00:36:31 +00:00
Dan Gohman
783fdc6375 Don't let arbitrary calls disrupt nested retain+release pairs if
the retains and releases all use the same SSA pointer value.

Also, don't let CFG hazards disrupt nested retain+release pair
optimizations.

llvm-svn: 137399
2011-08-12 00:26:31 +00:00
Dan Gohman
0b4ede167a Use an actual reverse-CFG reverse-postorder for the bottom-up traversal,
rather than plain postorder, so that CFG constructs like single-exit loops
are reliably visited in a sensible order.

llvm-svn: 137398
2011-08-12 00:24:29 +00:00
Andrew Trick
5a5a5ebe68 Allow loop unrolling to get known trip counts from ScalarEvolution.
SCEV unrolling can unroll loops with arbitrary induction variables. It
is a prerequisite for -disable-iv-rewrite performance. It is also
easily handles loops of arbitrary structure including multiple exits
and is generally more robust.

This is under a temporary option to avoid affecting default
behavior for the next couple of weeks. It is needed so that I can
checkin unit tests for updateUnloop.

llvm-svn: 137384
2011-08-11 23:36:16 +00:00
Dan Gohman
93efd104ca Fix typos in comments, and delete an unused function.
llvm-svn: 137352
2011-08-11 21:06:32 +00:00
Devang Patel
1541972a13 Distinguish between two copies of one inlined variable. Take 2.
llvm-svn: 137253
2011-08-10 21:50:54 +00:00
Andrew Trick
c1871c7c97 Comments. Thanks for the spell check Nick!
Also, my apologies for spoiling the autocomplete on SimplifyInstructions.cpp. I couldn't think of a better filename.

llvm-svn: 137229
2011-08-10 18:07:05 +00:00
Andrew Trick
4a938add93 Invoke SimplifyIndVar when we partially unroll a loop. Fixes PR10534.
llvm-svn: 137203
2011-08-10 04:29:49 +00:00
Andrew Trick
f598747450 Cleanup. Make ScalarEvolution an explicit argument of the
SimplifyIndVar utility since it is required.

llvm-svn: 137202
2011-08-10 04:22:26 +00:00
Andrew Trick
afa9344ce9 SimplifyIndVar: make foldIVUser iterative to fold a chain of operands.
llvm-svn: 137199
2011-08-10 04:01:31 +00:00
Benjamin Kramer
aa77183382 Update CMake build.
llvm-svn: 137198
2011-08-10 03:51:58 +00:00
Andrew Trick
b85da1c369 Added a SimplifyIndVar utility to simplify induction variable users
based on ScalarEvolution without changing the induction variable phis.

This utility is the main tool of IndVarSimplifyPass, but the pass also
restructures induction variables in strange ways that are sensitive to
pass ordering. This provides a way for other loop passes to simplify
new uses of induction variables created during transformation. The
utility may be used by any pass that preserves ScalarEvolution. Soon
LoopUnroll will use it.

The net effect in this checkin is to cleanup the IndVarSimplify pass
by factoring out the SimplifyIndVar algorithm into a standalone utility.

llvm-svn: 137197
2011-08-10 03:46:27 +00:00
Andrew Trick
d10d5f0609 Cleanup. Added LoopBlocksDFS::perform for simple clients.
llvm-svn: 137195
2011-08-10 01:59:05 +00:00
Andrew Trick
3ed0cd3cb6 Fix the LoopUnroller to handle nontrivial loops and partial unrolling.
These are not individual bug fixes. I had to rewrite a good chunk of
the unroller to make it sane. I think it was getting lucky on trivial
completely unrolled loops with no early exits. I included some fairly
simple unit tests for partial unrolling. I didn't do much stress
testing, so it may not be perfect, but should be usable now.

llvm-svn: 137190
2011-08-10 00:28:10 +00:00
Eli Friedman
5a2d27800e Representation of 'atomic load' and 'atomic store' in IR.
llvm-svn: 137170
2011-08-09 23:02:53 +00:00
Rafael Espindola
48a85d74bb Add a C interface to PassManagerBuilder. It is missing the addExtension
functionality since in the C api a pass is created and added to a pass
manager in a single call.

llvm-svn: 137159
2011-08-09 22:17:34 +00:00
Andrew Trick
b9ef7f9e3e LoopUnroll looks like it has some stale code. Remove it to prove my sanity and avoid further confusion.
llvm-svn: 137106
2011-08-09 03:11:29 +00:00
Bill Wendling
e3f1ab16df There is only one instance of this placeholder being created. Just use that
instead of a vector.

llvm-svn: 137099
2011-08-09 01:17:10 +00:00
Bill Wendling
23cae0966d Remove an instance where the 'unwind' instruction was created.
The 'unwind' instruction was acting essentially as a placeholder, because it
would be replaced at the end of this function by a branch to the "unwind
handler". The 'unwind' instruction is going away, so use 'unreachable' instead,
which serves the same purpose as a placeholder.

llvm-svn: 137098
2011-08-09 01:09:21 +00:00
Andrew Trick
a7fc7983d4 Made SCEV's UDiv expressions more canonical. When dividing a
recurrence, the initial values low bits can sometimes be ignored.

To take advantage of this, added FoldIVUser to IndVarSimplify to fold
an IV operand into a udiv/lshr if the operator doesn't affect the
result.

-indvars -disable-iv-rewrite now transforms

i = phi i4
i1 = i0 + 1
idx = i1 >> (2 or more)
i4 = i + 4

into

i = phi i4
idx = i0 >> ...
i4 = i + 4

llvm-svn: 137013
2011-08-06 07:00:37 +00:00
Chandler Carruth
e833bbd11e Temporarily revert r135528 which distinguishes between two copies of one
inlined variable, based on the discussion in PR10542.

This explodes the runtime of several passes down the pipeline due to
a large number of "copies" remaining live across a large function. This
only shows up with both debug and opt, but when it does it creates
a many-minute compile when self-hosting LLVM+Clang. There are several
other cases that show these types of regressions.

All of this is tracked in PR10542, and progress is being made on fixing
the issue. Once its addressed, the re-instated, but until then this
restores the performance for self-hosting and other opt+debug builds.

Devang, let me know if this causes any trouble, or impedes fixing it in
any way, and thanks for working on this!

llvm-svn: 136953
2011-08-05 00:51:31 +00:00
Devang Patel
e5379a1a5d We need to map DebugLoc. It leads to Fuction * (through subprogram entry node) which should be appropriately mapped.
llvm-svn: 136910
2011-08-04 20:02:18 +00:00
Evan Cheng
b5b42f6869 Fix an obvious type. Patch by Ivan Krasin.
llvm-svn: 136900
2011-08-04 18:40:26 +00:00
Bill Wendling
fdea9930ac Remove the LowerSetJmp pass. It wasn't used effectively by any of the targets.
This is some of my original LLVM code. *wipes tear*

llvm-svn: 136821
2011-08-03 22:18:20 +00:00
Andrew Trick
bbb5c7b0aa SCEV: Use AssertingVH to catch dangling BasicBlock* when passes forget
to notify SCEV of a change. Add forgetLoop in a couple of those places.

llvm-svn: 136797
2011-08-03 18:32:11 +00:00
Andrew Trick
0ba77723bf whitespace
llvm-svn: 136795
2011-08-03 18:28:21 +00:00
Nick Lewycky
16af9d24c5 Small cleanups:
- use SmallVectorImpl& for the function argument.
  - ignore the operands on the GEP, even if they aren't constant! Much as we
    pretend the malloc succeeds, we pretend that malloc + whatever-you-GEP'd-by
    is not null. It's magic!

llvm-svn: 136757
2011-08-03 01:11:40 +00:00
Nick Lewycky
82418c24b8 Fix logical error when detecting lifetime intrinsics.
Don't replace a gep/bitcast with 'undef' because that will form a "free(undef)"
which in turn means "unreachable". What we wanted was a no-op. Instead, analyze
the whole tree and look for all the instructions we need to delete first, then
delete them second, not relying on the use_list to stay consistent.

llvm-svn: 136752
2011-08-03 00:43:35 +00:00
Nick Lewycky
05fed81aa9 Teach InstCombine that lifetime intrincs aren't a real user on the result of a
malloc call.

llvm-svn: 136732
2011-08-02 22:08:01 +00:00
Rafael Espindola
2b0d064f3b Move methods in PassManagerBuilder offline.
llvm-svn: 136727
2011-08-02 21:50:27 +00:00
Eli Friedman
043fa7cc86 Add new atomic instructions to SCCP. No functional change, but stops debug spam.
llvm-svn: 136723
2011-08-02 21:35:16 +00:00
Nick Lewycky
2f04a6b411 Lifetime intrinsics on undef are dead.
llvm-svn: 136722
2011-08-02 21:19:27 +00:00
Owen Anderson
1d291c9425 Revert r136503 and r136480 in an effort to fix non-determinism in the llvm-gcc buildbots on i386. Devang is looking into the root cause.
llvm-svn: 136674
2011-08-02 02:23:42 +00:00
Bill Wendling
8a625cebd2 Add the 'resume' instruction for the new EH rewrite.
This adds the 'resume' instruction class, IR parsing, and bitcode reading and
writing. The 'resume' instruction resumes propagation of an existing (in-flight)
exception whose unwinding was interrupted with a 'landingpad' instruction (to be
added later).

llvm-svn: 136589
2011-07-31 06:30:59 +00:00
Rafael Espindola
92b7e5d6e5 Add a small gep optimization I noticed was missing while reading some IL.
llvm-svn: 136585
2011-07-31 04:43:41 +00:00
Bill Wendling
57ddbb84ac Revert r136253, r136263, r136269, r136313, r136325, r136326, r136329, r136338,
r136339, r136341, r136369, r136387, r136392, r136396, r136429, r136430, r136444,
r136445, r136446, r136253 pending review.

llvm-svn: 136556
2011-07-30 05:42:50 +00:00
Devang Patel
c98d0fe74b Clear DbgValues in the end.
llvm-svn: 136503
2011-07-29 19:49:58 +00:00
Devang Patel
3750561b36 Clean up debug info after reassociation.
llvm-svn: 136480
2011-07-29 19:00:35 +00:00
Eli Friedman
6f2419f1a2 Misc optimizer+codegen work for 'cmpxchg' and 'atomicrmw'. They appear to be
working on x86 (at least for trivial testcases); other architectures will
need more work so that they actually emit the appropriate instructions for
orderings stricter than 'monotonic'. (As far as I can tell, the ARM, PPC,
Mips, and Alpha backends need such changes.)

llvm-svn: 136457
2011-07-29 03:05:32 +00:00
Eli Friedman
a07aa98eff Make sure to correctly clear the exact/nuw/nsw flags off of shifts when they are combined together. <rdar://problem/9859829>
llvm-svn: 136435
2011-07-29 00:18:19 +00:00
Chandler Carruth
f7890e34b9 Rewrite the CMake build to use explicit dependencies between libraries,
specified in the same file that the library itself is created. This is
more idiomatic for CMake builds, and also allows us to correctly specify
dependencies that are missed due to bugs in the GenLibDeps perl script,
or change from compiler to compiler. On Linux, this returns CMake to
a place where it can relably rebuild several targets of LLVM.

I have tried not to change the dependencies from the ones in the current
auto-generated file. The only places I've really diverged are in places
where I was seeing link failures, and added a dependency. The goal of
this patch is not to start changing the dependencies, merely to move
them into the correct location, and an explicit form that we can control
and change when necessary.

This also removes a serialization point in the build because we don't
have to scan all the libraries before we begin building various tools.
We no longer have a step of the build that regenerates a file inside the
source tree. A few other associated cleanups fall out of this.

This isn't really finished yet though. After talking to dgregor he urged
switching to a single CMake macro to construct libraries with both
sources and dependencies in the arguments. Migrating from the two macros
to that style will be a follow-up patch.

Also, llvm-config is still generated with GenLibDeps.pl, which means it
still has slightly buggy dependencies. The internal CMake
'llvm-config-like' macro uses the correct explicitly specified
dependencies however. A future patch will switch llvm-config generation
(when using CMake) to be based on these deps as well.

This may well break Windows. I'm getting a machine set up now to dig
into any failures there. If anyone can chime in with problems they see
or ideas of how to solve them for Windows, much appreciated.

llvm-svn: 136433
2011-07-29 00:14:25 +00:00
Bill Wendling
db288e16ed Some minor cleanups. No functionalitical change.
llvm-svn: 136341
2011-07-28 07:44:07 +00:00
Bill Wendling
55af961b37 Leverage some of the code that John wrote to manage the landing pads.
The new EH is more simple in many respects. Mainly, we don't have to worry about
the "llvm.eh.exception" and "llvm.eh.selector" calls being in weird places.

llvm-svn: 136339
2011-07-28 07:31:46 +00:00
Bill Wendling
8b4ec26e4f Automatically merge the landingpad clauses when we come across a callee's
landingpad.

llvm-svn: 136329
2011-07-28 02:40:13 +00:00
Benjamin Kramer
20bc47e9c1 Fix a use after free. An instruction can't be both an intrinsic call and a fence.
llvm-svn: 136319
2011-07-28 01:20:19 +00:00
Bill Wendling
3af08d0231 Initial stab at getting inlining working with the EH rewrite.
This takes the new 'resume' instruction and turns it into a direct jump to the
caller's landing pad code. The caller's landingpad instruction is merged with
the landingpad instructions of the callee. This is a bit rough and makes some
assumptions in how the code works. But it passes a simple test.

llvm-svn: 136313
2011-07-28 00:38:23 +00:00
Bill Wendling
6f17cb3233 Refuse to inline two functions which use different personality functions.
llvm-svn: 136269
2011-07-27 21:44:28 +00:00
Bill Wendling
b20cfdfe95 Merge the contents from exception-handling-rewrite to the mainline.
This adds the new instructions 'landingpad' and 'resume'.

llvm-svn: 136253
2011-07-27 20:18:04 +00:00
Nick Lewycky
59edfce6f7 Teach the ConstantMerge pass about alignment. Fixes PR10514!
llvm-svn: 136250
2011-07-27 19:47:34 +00:00
Eli Friedman
f226974353 Misc mid-level changes for new 'fence' instruction.
llvm-svn: 136205
2011-07-27 01:08:30 +00:00
Bill Wendling
b09ac9d7ec Use the correct for for the version. It's little endian and my brain is
obviously big endian. :-)
PR10502

llvm-svn: 136111
2011-07-26 18:31:41 +00:00
Rafael Espindola
a4148a5a84 Add LLVMAddAlwaysInlinerPass to the C API.
llvm-svn: 136083
2011-07-26 15:23:23 +00:00
Rafael Espindola
d7295c15ab LLVM 3.0 is here, remove old do nothing method.
llvm-svn: 136082
2011-07-26 15:17:32 +00:00
Nick Lewycky
271216a67b Finish adding support for lifetime intrinsics to SROA. Fixes PR10121!
llvm-svn: 136008
2011-07-25 23:14:22 +00:00
Andrew Trick
8e55bd70ba Add clarifying comments for the new arguments to UnrollLoop.
llvm-svn: 135988
2011-07-25 22:17:47 +00:00
Nick Lewycky
be5834d122 Add missing space (this line is no longer pushing the 80-column limit).
llvm-svn: 135973
2011-07-25 21:16:04 +00:00
Rafael Espindola
e982fa5f80 Add LLVMAddLowerExpectIntrinsicPass to the C API.
llvm-svn: 135966
2011-07-25 20:57:59 +00:00
Frits van Bommel
775ac35cf1 Shorten some expressions by using ArrayRef::slice().
llvm-svn: 135910
2011-07-25 15:13:01 +00:00
Jay Foad
6513dac6e2 Convert GetElementPtrInst to use ArrayRef.
llvm-svn: 135904
2011-07-25 09:48:08 +00:00
Andrew Trick
53ed0491c0 Move trip count discovery outside of the generic LoopUnroll helper. This
removes its dependence on canonical induction variables.

llvm-svn: 135829
2011-07-23 00:33:05 +00:00
Andrew Trick
6dc31a31ed whitespace
llvm-svn: 135828
2011-07-23 00:29:16 +00:00
Dan Gohman
1c4dff0ab3 Move the last uses of RetainFunc etc. over to using getRetainCallee() etc.
so that a declaration for objc_retain is created when needed if it doesn't
already exist. rdar://9825114.

llvm-svn: 135821
2011-07-22 22:29:21 +00:00
Jay Foad
5ceaa632f9 Fix more MSVC warnings caused by a cases I missed when converting
ConstantExpr::getGetElementPtr to use ArrayRef.

llvm-svn: 135762
2011-07-22 08:52:50 +00:00
Jay Foad
42463ed852 Convert IRBuilder::CreateGEP and IRBuilder::CreateInBoundsGEP to use
ArrayRef.

llvm-svn: 135761
2011-07-22 08:16:57 +00:00
Jay Foad
e12d8629a8 Fix an MSVC warning, caused by a case I missed when converting
ConstantExpr::getGetElementPtr to use ArrayRef.

llvm-svn: 135758
2011-07-22 07:54:01 +00:00
Dan Gohman
b320950f65 Fix MergeInVectorType to check for vector types with the same alloc
size but different element types, so that it filters out the cases
that CreateShuffleVectorCast doesn't handle. This fixes rdar://9786827.

llvm-svn: 135721
2011-07-21 23:30:09 +00:00
Andrew Trick
66db1adfe1 Cleanup: make std::pair usage slightly less indecipherable without actually naming variables!
llvm-svn: 135684
2011-07-21 17:37:39 +00:00
Jay Foad
42eb18b051 Make better use of ConstantExpr::getGetElementPtr's InBounds parameter.
llvm-svn: 135676
2011-07-21 15:15:37 +00:00
Jay Foad
d4458dd707 Convert ConstantExpr::getGetElementPtr and
ConstantExpr::getInBoundsGetElementPtr to use ArrayRef.

llvm-svn: 135673
2011-07-21 14:31:17 +00:00
Chris Lattner
c4ab50bd33 move tier out of an anonymous namespace, it doesn't make sense
to for it to be an an anon namespace and be in a header.

Eliminate some extraenous uses of tie.

llvm-svn: 135669
2011-07-21 06:21:31 +00:00
Andrew Trick
1f9b4f8617 LSR, correct fix for rdar://9786536. Silly casting bug.
llvm-svn: 135654
2011-07-21 01:45:54 +00:00
Andrew Trick
ebf9ee5200 LSR must sometimes sign-extend before generating double constants.
rdar://9786536

llvm-svn: 135650
2011-07-21 01:05:01 +00:00
Andrew Trick
4b641bba84 LSR crashes on an empty IVUsers list.
rdar://9786536

llvm-svn: 135644
2011-07-21 00:40:04 +00:00
Eli Friedman
c18314afef Clean up includes of llvm/Analysis/ConstantFolding.h so it's included where it's used and not included where it isn't.
llvm-svn: 135628
2011-07-20 21:57:23 +00:00
Eli Friedman
f98434b2c7 Bring LICM into compliance with the new "Memory Model for Concurrent Operations" in LangRef.
llvm-svn: 135625
2011-07-20 21:37:47 +00:00
Jay Foad
03130446b5 Fix a GCC warning.
llvm-svn: 135581
2011-07-20 08:15:21 +00:00
Andrew Trick
57280c0f11 indvars: Added getInsertPointForUses to find a valid place to truncate the IV.
llvm-svn: 135568
2011-07-20 05:32:06 +00:00
Andrew Trick
9c4333db13 indvars -disable-iv-rewrite: Add NarrowIVDefUse to cache def-use
info. Holding Use* pointers is bad form even though it happened to
work in this case.

llvm-svn: 135566
2011-07-20 04:39:24 +00:00
Andrew Trick
ee2d72e5f1 indvars -disable-iv-rewrite fix: derived GEP IVs
llvm-svn: 135558
2011-07-20 02:08:58 +00:00
Eli Friedman
f809f44cf5 PR10386: Don't try to split an edge from an indirectbr.
llvm-svn: 135534
2011-07-19 22:59:41 +00:00
Devang Patel
65afdd27d0 Distinguish between two copies of one inlined variable.
llvm-svn: 135528
2011-07-19 22:31:15 +00:00
Jay Foad
bbbf29aab7 Convert SimplifyGEPInst to use ArrayRef.
llvm-svn: 135482
2011-07-19 15:07:52 +00:00
Jay Foad
0974b71f17 Convert TargetData::getIndexedOffset to use ArrayRef.
llvm-svn: 135478
2011-07-19 14:01:37 +00:00
Jay Foad
ae5894c5cc Use ArrayRef in ConstantFoldInstOperands and ConstantFoldCall.
llvm-svn: 135477
2011-07-19 13:32:40 +00:00
Andrew Trick
ff306f7c8b Compiler warning.
llvm-svn: 135426
2011-07-18 21:15:03 +00:00
Andrew Trick
ba37b6516a indvars: LinearFunctionTestReplace for non-canonical IVs.
For -disable-iv-rewrite, perform LFTR without generating a new
"canonical" induction variable. Instead find the "best" existing
induction variable for use in the loop exit test and compute the final
value of that IV for use in the new loop exit test. In short,
convert to a simple eq/ne exit test as long as it's cheap to do so.

llvm-svn: 135420
2011-07-18 20:32:31 +00:00
Andrew Trick
40113d052b indvars: Added verification that LFTR and other indvars goodness does
not interfere with BackedgeTakenCount computation.

llvm-svn: 135412
2011-07-18 18:44:20 +00:00
Andrew Trick
111d0bc134 indvars: Added isHighCostExpansion. Avoid generating extra ops in the
preheader for the sole purpose of LFTR, since LFTR itself is usually not
a clear optimization.

llvm-svn: 135409
2011-07-18 18:21:35 +00:00
Frits van Bommel
6c24f9c277 Migrate LLVM and Clang to use the new makeArrayRef(...) functions where previously explicit non-default constructors were used.
Mostly mechanical with some manual reformatting.

llvm-svn: 135390
2011-07-18 12:00:32 +00:00
Chris Lattner
e1fe7061ce land David Blaikie's patch to de-constify Type, with a few tweaks.
llvm-svn: 135375
2011-07-18 04:54:35 +00:00
Chris Lattner
04b988a1c0 fix a warning in TinyPtrVector, adopt it in SSAUpdater, saving some
mallocs.

llvm-svn: 135366
2011-07-18 01:43:58 +00:00
Andrew Trick
3300087d49 indvars: fix a pass-sensitivity issue that would hit the SCEVExpander
assertion I added in r135333. Check for the existence of a preheader
before expanding a recurrence.

llvm-svn: 135335
2011-07-16 01:18:53 +00:00
Andrew Trick
3b06e51b87 indvars: remove ExprToIVMap because it won't be needed by LFTR.
llvm-svn: 135334
2011-07-16 01:06:48 +00:00
Chris Lattner
b09652e74d fix rdar://9776316 - type remapping needed for inline asm blobs,
fixing some objc llvm-test crashes with LTO.

llvm-svn: 135324
2011-07-15 23:18:40 +00:00
Chad Rosier
bdf65ac132 Disable loop idiom recognition of memset/memcpy if the function being compiled
is named after a common idiom (i.e., memset/memcpy).  Otherwise, we can run into 
infinite recursion.  Ideally, the user should use the correct -fno-builtin flag,
but in case they don't we should play nicely.
rdar://9763412

llvm-svn: 135286
2011-07-15 18:25:04 +00:00
Frits van Bommel
6427dc44b9 No need to explicitly invoke the ArrayRef constructor here.
llvm-svn: 135281
2011-07-15 17:13:23 +00:00
Jay Foad
c826df8fb7 Convert CallInst and InvokeInst APIs to use ArrayRef.
llvm-svn: 135265
2011-07-15 08:37:34 +00:00
Chris Lattner
a3a07274c9 start using the new helper methods a bit.
llvm-svn: 135251
2011-07-15 06:08:15 +00:00
Devang Patel
e9962ef77f Undo r135191 (i.e. reapply Chris's patch. Now linker maps NamedMDNodes first, so there is not any need to map DebugLoc).
llvm-svn: 135205
2011-07-14 22:14:06 +00:00
Chris Lattner
77acb69e12 revert r135172 until Devang and I figure out the right answer.
llvm-svn: 135191
2011-07-14 21:25:42 +00:00
Chris Lattner
f9d3b2a8c3 Stop the ValueMapper from calling getAllMetadata, which unpacks DebugLoc into
an MDNode.  This saves a bunch of time and memory in the IR linker, e.g. when 
doing LTO of files with debug info.

llvm-svn: 135172
2011-07-14 18:53:50 +00:00
Benjamin Kramer
a6129829fa Change Intrinsic::getDeclaration and friends to take an ArrayRef.
llvm-svn: 135154
2011-07-14 17:45:39 +00:00
Evan Cheng
ba4a50f10c It's not safe to fold (fptrunc (sqrt (fpext x))) to (sqrtf x) if there is another use of sqrt. rdar://9763193
llvm-svn: 135058
2011-07-13 19:08:16 +00:00
Jay Foad
88fb4f4597 Convert InsertValueInst and ExtractValueInst APIs to use ArrayRef.
llvm-svn: 135040
2011-07-13 10:26:04 +00:00
Jay Foad
cbe48cd2ac Second attempt at de-constifying LLVM Types in FunctionType::get(),
StructType::get() and TargetData::getIntPtrType().

llvm-svn: 134982
2011-07-12 14:06:48 +00:00
Bill Wendling
6bcdd65b95 Revert r134893 and r134888 (and related patches in other trees). It was causing
an assert on Darwin llvm-gcc builds.

Assertion failed: (castIsValid(op, S, Ty) && "Invalid cast!"), function Create, file /Users/buildslave/zorg/buildbot/smooshlab/slave-0.8/build.llvm-gcc-i386-darwin9-RA/llvm.src/lib/VMCore/Instructions.cpp, li\
ne 2067.
etc.

http://smooshlab.apple.com:8013/builders/llvm-gcc-i386-darwin9-RA/builds/2354

--- Reverse-merging r134893 into '.':
U    include/llvm/Target/TargetData.h
U    include/llvm/DerivedTypes.h
U    tools/bugpoint/ExtractFunction.cpp
U    unittests/Support/TypeBuilderTest.cpp
U    lib/Target/ARM/ARMGlobalMerge.cpp
U    lib/Target/TargetData.cpp
U    lib/VMCore/Constants.cpp
U    lib/VMCore/Type.cpp
U    lib/VMCore/Core.cpp
U    lib/Transforms/Utils/CodeExtractor.cpp
U    lib/Transforms/Instrumentation/ProfilingUtils.cpp
U    lib/Transforms/IPO/DeadArgumentElimination.cpp
U    lib/CodeGen/SjLjEHPrepare.cpp
--- Reverse-merging r134888 into '.':
G    include/llvm/DerivedTypes.h
U    include/llvm/Support/TypeBuilder.h
U    include/llvm/Intrinsics.h
U    unittests/Analysis/ScalarEvolutionTest.cpp
U    unittests/ExecutionEngine/JIT/JITTest.cpp
U    unittests/ExecutionEngine/JIT/JITMemoryManagerTest.cpp
U    unittests/VMCore/PassManagerTest.cpp
G    unittests/Support/TypeBuilderTest.cpp
U    lib/Target/MBlaze/MBlazeIntrinsicInfo.cpp
U    lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp
U    lib/VMCore/IRBuilder.cpp
G    lib/VMCore/Type.cpp
U    lib/VMCore/Function.cpp
G    lib/VMCore/Core.cpp
U    lib/VMCore/Module.cpp
U    lib/AsmParser/LLParser.cpp
U    lib/Transforms/Utils/CloneFunction.cpp
G    lib/Transforms/Utils/CodeExtractor.cpp
U    lib/Transforms/Utils/InlineFunction.cpp
U    lib/Transforms/Instrumentation/GCOVProfiling.cpp
U    lib/Transforms/Scalar/ObjCARC.cpp
U    lib/Transforms/Scalar/SimplifyLibCalls.cpp
U    lib/Transforms/Scalar/MemCpyOptimizer.cpp
G    lib/Transforms/IPO/DeadArgumentElimination.cpp
U    lib/Transforms/IPO/ArgumentPromotion.cpp
U    lib/Transforms/InstCombine/InstCombineCompares.cpp
U    lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
U    lib/Transforms/InstCombine/InstCombineCalls.cpp
U    lib/CodeGen/DwarfEHPrepare.cpp
U    lib/CodeGen/IntrinsicLowering.cpp
U    lib/Bitcode/Reader/BitcodeReader.cpp

llvm-svn: 134949
2011-07-12 01:15:52 +00:00
Andrew Trick
15eeae110f indvars: Code reorganization in preparation for
LinearFunctionTestReplace rewrite. No functionality.

I've been wanting to group the indvar subphases into sections and
order them by their logical sequence. My next checkin adds functions
related to LFTR, and doing the reorg now should help reviewers. Since,
most of the code in IndVarSimplify.cpp has recently been replaced or
will be replaced soon, obscuring blame should not be an issue. This
seems like an ideal time to shuffle the code around.

I'm happy to take more suggestions for cleaning up the code. Or if
you've been wanting to cleanup anything in this file yourself, now is
a good time.

llvm-svn: 134941
2011-07-12 00:08:50 +00:00
Jay Foad
0ec904296e De-constify Types in StructType::get() and TargetData::getIntPtrType().
llvm-svn: 134893
2011-07-11 09:56:20 +00:00
Jay Foad
d618fa83b7 De-constify Types in FunctionType::get().
llvm-svn: 134888
2011-07-11 07:56:41 +00:00
Rafael Espindola
b42084315a Don't duplicate the work done by a gep into a "bitcast" if the gep has
more than one use.

Fixes PR10322.

llvm-svn: 134883
2011-07-11 03:43:47 +00:00
Chris Lattner
6680365bc0 remove the DerivedType which isn't adding value anymore.
llvm-svn: 134832
2011-07-09 17:59:15 +00:00
Chris Lattner
a106725fc5 Land the long talked about "type system rewrite" patch. This
patch brings numerous advantages to LLVM.  One way to look at it
is through diffstat:
 109 files changed, 3005 insertions(+), 5906 deletions(-)

Removing almost 3K lines of code is a good thing.  Other advantages
include:

1. Value::getType() is a simple load that can be CSE'd, not a mutating
   union-find operation.
2. Types a uniqued and never move once created, defining away PATypeHolder.
3. Structs can be "named" now, and their name is part of the identity that
   uniques them.  This means that the compiler doesn't merge them structurally
   which makes the IR much less confusing.
4. Now that there is no way to get a cycle in a type graph without a named
   struct type, "upreferences" go away.
5. Type refinement is completely gone, which should make LTO much MUCH faster
   in some common cases with C++ code.
6. Types are now generally immutable, so we can use "Type *" instead 
   "const Type *" everywhere.

Downsides of this patch are that it removes some functions from the C API,
so people using those will have to upgrade to (not yet added) new API.  
"LLVM 3.0" is the right time to do this.

There are still some cleanups pending after this, this patch is large enough
as-is.

llvm-svn: 134829
2011-07-09 17:41:24 +00:00
Lang Hames
725c115f6f Added recognition for signed add/sub/mul with overflow intrinsics to GVN as per Chris and Frits suggestion.
llvm-svn: 134777
2011-07-09 00:25:11 +00:00
Bob Wilson
d5c5f63f43 Reapply a fixed version of r133285.
This tightens up checking for overflow in alloca sizes, based on feedback
from Duncan and John about the change in r132926.

llvm-svn: 134749
2011-07-08 22:09:33 +00:00
Benjamin Kramer
453e9c4d19 Remove unused copy of UpdateInlinedAtInfo.
llvm-svn: 134720
2011-07-08 19:32:06 +00:00
Devang Patel
91599d726c Refactor. It is inliner's responsibility to update line number information.
llvm-svn: 134708
2011-07-08 18:01:31 +00:00
Lang Hames
841a1fce67 Make GVN look through extractvalues for recognised intrinsics. GVN can then CSE ops that match values produced by the intrinsics.
llvm-svn: 134677
2011-07-08 01:50:54 +00:00
Devang Patel
4011cc12b8 Use DBG_VALUE location while inserting DBG_VALUE during alloca promotion.
llvm-svn: 134568
2011-07-07 00:05:58 +00:00
Jakub Staszak
7f9c0d5ac8 Fix a bug in the "expect" intrinsic lowering.
llvm-svn: 134566
2011-07-06 23:50:16 +00:00
Devang Patel
47d505f9ef Handle cases where multiple dbg.declare and dbg.value intrinsics are tied to one alloca.
llvm-svn: 134549
2011-07-06 22:06:11 +00:00
Devang Patel
214fa1739f Simplify. Consolidate dbg.declare handling in AllocaPromoter.
llvm-svn: 134538
2011-07-06 21:09:55 +00:00
Andrew Trick
f80318e090 indvars -disable-iv-rewrite: ExprToMap lives in Pass data, so be more
careful about referencing values.

llvm-svn: 134537
2011-07-06 21:07:10 +00:00
Andrew Trick
641b6e4222 indvars -disable-iv-rewrite: Added SimplifyCongruentIVs.
llvm-svn: 134530
2011-07-06 20:50:43 +00:00
Tobias Grosser
eda1c1a7ce LICM: Remove trailing white spaces
llvm-svn: 134521
2011-07-06 19:20:02 +00:00
Tobias Grosser
97b1ec50e3 LICM: Do not loose alignment on promotion
The promotion code lost any alignment information, when hoisting loads and
stores out of the loop. This lead to incorrect aligned memory accesses. We now
use the largest alignment we can prove to be correct.

llvm-svn: 134520
2011-07-06 19:19:55 +00:00
Jakub Staszak
28bcc8673e Introduce "expect" intrinsic instructions.
llvm-svn: 134516
2011-07-06 18:22:43 +00:00
Devang Patel
bfd474b954 Preserve debug loc.
llvm-svn: 134441
2011-07-05 21:48:22 +00:00
Andrew Trick
8823fc0040 indvars -disable-iv-rewrite: avoid multiple IVs in weird cases.
Putting back the helper that I removed on 7/1 to do this right.

llvm-svn: 134423
2011-07-05 18:19:39 +00:00
Benjamin Kramer
2d266249a6 PR10267: Don't combine an equality compare with an AND into an inequality compare when the AND has more than one use.
This can pessimize code, inequalities are generally more expensive.

llvm-svn: 134379
2011-07-04 20:16:36 +00:00
Andrew Trick
ac38d56661 indvars -disable-iv-rewrite: bug fix involving weird geps and related cleanup.
llvm-svn: 134306
2011-07-02 02:34:25 +00:00
Owen Anderson
dccc4e4b9a Generalize @llvm.ctlz, @llvm.cttz, and @llvm.ctpop to work on vectors of integers, and fix the one optimization pass that I'm aware of that needs updating for this. At least one current target, ARM NEON, can implement these operations on vectors directly.
llvm-svn: 134265
2011-07-01 21:52:38 +00:00
Nick Lewycky
465651fe6e Fix likely typo, reduce number of instruction name collisions.
llvm-svn: 134235
2011-07-01 06:27:03 +00:00
Rafael Espindola
03cd7c7b76 Add r134057 back, but splice the predecessor after the successors phi
nodes.

Original message:
Let simplify cfg simplify bb with only debug and lifetime intrinsics.

llvm-svn: 134182
2011-06-30 20:14:24 +00:00
Andrew Trick
bcaaa0ae73 indvars -disable-iv-rewrite: handle cloning binary operators that cannot overflow.
llvm-svn: 134177
2011-06-30 19:02:17 +00:00
Andrew Trick
b074aa9e26 indvars -disable-iv-rewrite: handle an edge case involving identity phis.
llvm-svn: 134124
2011-06-30 01:27:23 +00:00
Andrew Trick
a79ebc3dbd indvars -disable-iv-rewrite: insert new trunc instructions carefully.
llvm-svn: 134112
2011-06-29 23:03:57 +00:00
Chad Rosier
fc7dc596a4 Temporarily revert r134057: "Let simplify cfg simplify bb with only debug and
lifetime intrinsics" due to buildbot failures.

llvm-svn: 134071
2011-06-29 16:22:11 +00:00
Rafael Espindola
e9e560eb37 Let simplify cfg simplify bb with only debug and lifetime intrinsics.
llvm-svn: 134057
2011-06-29 05:25:47 +00:00
Andrew Trick
bc666880ad indvars -disable-iv-rewrite: just because SCEV ignores casts doesn't
mean they can be removed.

llvm-svn: 134054
2011-06-29 03:13:40 +00:00
Andrew Trick
db3349cc0b cleanup: misleading comment.
llvm-svn: 134010
2011-06-28 16:45:04 +00:00
Andrew Trick
4ac5dd5154 SCEVExpander: give new insts a name that identifies the reponsible pass.
llvm-svn: 133992
2011-06-28 05:07:32 +00:00
Andrew Trick
c7b3d222cf whitespace
llvm-svn: 133991
2011-06-28 05:04:16 +00:00
Nick Lewycky
8bdfa54742 Fix typo in comment.
llvm-svn: 133990
2011-06-28 03:57:31 +00:00
Andrew Trick
eb9ed2c82e indvars --disable-iv-rewrite: sever ties with IVUsers.
llvm-svn: 133988
2011-06-28 03:01:46 +00:00
Andrew Trick
9f6946c3a1 indvars --disable-iv-rewrite: Defer evaluating s/zext until SCEV
evaluates all other IV exprs.

llvm-svn: 133982
2011-06-28 02:49:20 +00:00
Andrew Trick
a2083f5887 indvars -disable-iv-rewrite: run RLEV after SimplifyIVUsers for
a bit more control over the order SCEVs are evaluated.

llvm-svn: 133959
2011-06-27 23:17:44 +00:00
Jakub Staszak
995dfdf6ab Calculate GetBestDestForJumpOnUndef correctly.
llvm-svn: 133946
2011-06-27 21:51:12 +00:00
Nick Lewycky
0a59da4c5f Teach one piece of scalarrepl to handle lifetime markers. When transforming an
alloca that only holds a copy of a global and we're going to replace the users
of the alloca with that global, just nuke the lifetime intrinsics. Part of
PR10121.

llvm-svn: 133905
2011-06-27 05:40:02 +00:00
Nick Lewycky
4a0f5218f2 Move onlyUsedByLifetimeMarkers to ValueTracking so that it can be used by other
passes as well.

llvm-svn: 133904
2011-06-27 04:20:45 +00:00
Eli Friedman
8f3af361ac PR10180: Fix a instcombine crash with FP vectors.
llvm-svn: 133756
2011-06-23 20:40:23 +00:00
Jay Foad
75b709336d Reinstate r133513 (reverted in r133700) with an additional fix for a
-Wshorten-64-to-32 warning in Instructions.h.

llvm-svn: 133708
2011-06-23 09:09:15 +00:00
Eric Christopher
d38d7f3300 Revert r133513:
"Reinstate r133435 and r133449 (reverted in r133499) now that the clang
self-hosted build failure has been fixed (r133512)."

Due to some additional warnings.

llvm-svn: 133700
2011-06-23 06:24:52 +00:00
Devang Patel
6e79e59260 Set debug loc.
llvm-svn: 133636
2011-06-22 19:52:36 +00:00
Jay Foad
888cd746b8 Replace the existing forms of ConstantArray::get() with a single form
that takes an ArrayRef.

llvm-svn: 133615
2011-06-22 09:24:39 +00:00
Andrew Trick
04c3bb47ce IVUsers no longer needs to record the phis.
llvm-svn: 133518
2011-06-21 15:43:52 +00:00
Benjamin Kramer
02bc17d36d Remove unused variables.
llvm-svn: 133514
2011-06-21 14:58:30 +00:00
Jay Foad
2691fd9891 Reinstate r133435 and r133449 (reverted in r133499) now that the clang
self-hosted build failure has been fixed (r133512).

llvm-svn: 133513
2011-06-21 10:33:19 +00:00
Jay Foad
d7276856c6 Don't use PN->replaceUsesOfWith() to change a PHINode's incoming blocks,
because it won't work after my phi operand changes, because the incoming
blocks will no longer be Uses.

llvm-svn: 133512
2011-06-21 10:02:43 +00:00
Andrew Trick
0f76c6afe8 indvars -disable-iv-rewrite: Adds support for eliminating identity
ops.

This is a rewrite of the IV simplification algorithm used by
-disable-iv-rewrite. To avoid perturbing the default mode, I
temporarily split the driver and created SimplifyIVUsersNoRewrite. The
idea is to avoid doing opcode/pattern matching inside
IndVarSimplify. SCEV already does it. We want to optimize with the
full generality of SCEV, but optimize def-use chains top down on-demand rather
than rewriting the entire expression bottom-up. This was easy to do
for operations that SCEV can prove are identity function. So we're now
eliminating bitmasks and zero extends this way.

A result of this rewrite is that indvars -disable-iv-rewrite no longer
requires IVUsers.

llvm-svn: 133502
2011-06-21 03:22:38 +00:00
Chad Rosier
16a86e04cf Revert r133435 and r133449 to appease buildbots.
llvm-svn: 133499
2011-06-21 02:09:03 +00:00
Dan Gohman
d8baa3f8ce Completely short-circuit out ARC optimization if the ARC runtime
functions do not appear in the module.

llvm-svn: 133478
2011-06-20 23:20:43 +00:00
Jay Foad
c465a95fb4 Change how PHINodes store their operands.
Change PHINodes to store simple pointers to their incoming basic blocks,
instead of full-blown Uses.

Note that this loses an optimization in SplitCriticalEdge(), because we
can no longer walk the use list of a BasicBlock to find phi nodes. See
the comment I removed starting "However, the foreach loop is slow for
blocks with lots of predecessors".

Extend replaceAllUsesWith() on a BasicBlock to also update any phi
nodes in the block's successors. This mimics what would have happened
when PHINodes were proper Users of their incoming blocks. (Note that
this only works if OldBB->replaceAllUsesWith(NewBB) is called when
OldBB still has a terminator instruction, so it still has some
successors.)

llvm-svn: 133435
2011-06-20 14:38:01 +00:00
Jay Foad
85fe93df5e Make better use of the PHINode API.
Change various bits of code to make better use of the existing PHINode
API, to insulate them from forthcoming changes in how PHINodes store
their operands.

llvm-svn: 133434
2011-06-20 14:18:48 +00:00
Chris Lattner
d456ff35d1 Revamp the "ConstantStruct::get" methods. Previously, these were scattered
all over the place in different styles and variants.  Standardize on two
preferred entrypoints: one that takes a StructType and ArrayRef, and one that
takes StructType and varargs.

In cases where there isn't a struct type convenient, we now add a
ConstantStruct::getAnon method (whose name will make more sense after a few
more patches land).  

It would be "really really nice" if the ConstantStruct::get and 
ConstantVector::get methods didn't make temporary std::vectors.

llvm-svn: 133412
2011-06-20 04:01:31 +00:00
Chris Lattner
c247005424 fix the varargs version of StructType::get to not require an LLVMContext, making usage
much cleaner.

llvm-svn: 133364
2011-06-18 22:48:56 +00:00
Hans Wennborg
e1d53b6e2b Fix PR10103: Less code for enum type translation.
In cases such as the attached test, where the case value for a switch
destination is used in a phi node that follows the destination, it
might be better to replace that value with the condition value of the
switch, so that more blocks can be folded away with
TryToSimplifyUncondBranchFromEmptyBlock because there are less
conflicts in the phi node.

llvm-svn: 133344
2011-06-18 10:28:47 +00:00
Cameron Zwarich
09c312acad When scalar replacement returns a vector type, only accept it if the vector
type's bitwidth matches the (allocated) size of the alloca. This severely
pessimizes vector scalar replacement when the only vector type being used is
something like <3 x float> on x86 or ARM whose allocated size matches a
<4 x float>.

I hope to fix some of the flawed assumptions about allocated size throughout
scalar replacement and reenable this in most cases.

llvm-svn: 133338
2011-06-18 06:17:51 +00:00
Cameron Zwarich
00255ad84e Fix an invalid bitcast crash that occurs when doing a partial memset of a vector
alloca. Fixes part of <rdar://problem/9580800>.

llvm-svn: 133336
2011-06-18 05:47:49 +00:00
Cameron Zwarich
d6e767ca48 Remove a pointless assignment. Nothing checks the value of VectorTy anymore now
unless ScalarKind is Vector.

llvm-svn: 133335
2011-06-18 05:47:45 +00:00
Chad Rosier
0dc865af56 Revert r133285. Causing odd failures on Dragonegg.
llvm-svn: 133301
2011-06-17 22:08:25 +00:00
Devang Patel
65e272ee15 Set debug loc for new preheader's terminator.
llvm-svn: 133298
2011-06-17 21:36:44 +00:00
Stuart Hastings
03f59f5916 Relocate NUW test to cover all binary ops in a dynamic alloca expr.
Followup to 132926.  rdar://problem/9265821

llvm-svn: 133285
2011-06-17 20:21:52 +00:00
Nick Lewycky
9bfe06b4d6 When promoting an alloca to registers discard any lifetime intrinsics.
llvm-svn: 133251
2011-06-17 10:09:00 +00:00
Dan Gohman
c9b4620575 Fix ARCOpt to insert releases on both successors of an invoke rather
than trying to insert them immediately after the invoke.

llvm-svn: 133188
2011-06-16 20:57:14 +00:00
John McCall
519c63cdeb The ARC language-specific optimizer. Credit to Dan Gohman.
llvm-svn: 133108
2011-06-15 23:37:01 +00:00
Eli Friedman
e6d7c767f9 Simplify; no significant functionality change.
llvm-svn: 133086
2011-06-15 21:08:25 +00:00
Rafael Espindola
7e3acf17a2 Fix cmake build.
llvm-svn: 133085
2011-06-15 21:03:04 +00:00
Eli Friedman
33a3b6d488 Remove unused code.
llvm-svn: 133078
2011-06-15 19:58:09 +00:00
Eli Friedman
a45cbb1743 Stop using memdep for a check that didn't really make sense with memdep. In terms of specific issues, using memdep here checks irrelevant instructions and won't work properly once we start returning "unknown" more aggressively from memdep.
llvm-svn: 133035
2011-06-15 01:25:56 +00:00
Eli Friedman
47b3cd9fff Add "unknown" results for memdep, which mean "I don't know whether a dependence for the given instruction exists in the given block". This cleans up all the existing hacks in memdep which represent this concept by returning clobber with various unrelated instructions.
llvm-svn: 133031
2011-06-15 00:47:34 +00:00
Cameron Zwarich
77f6a2d09e Be more obvious about what is being tested.
llvm-svn: 132982
2011-06-14 06:33:51 +00:00
John McCall
fb32cfb402 Use IRBuilder to make our intrinsic calls in the inliner so that we pick up
line info correctly.

llvm-svn: 132961
2011-06-14 02:51:53 +00:00
Nick Lewycky
c473e8f0e2 Use Value::stripPointerCasts instead of reinventing part of the wheel.
llvm-svn: 132954
2011-06-14 00:59:24 +00:00
Cameron Zwarich
5b03baf002 Fix grammar.
llvm-svn: 132952
2011-06-13 23:39:23 +00:00
Cameron Zwarich
c122dc4050 Rename MergeInType to MergeInTypeForLoadOrStore.
llvm-svn: 132940
2011-06-13 21:44:43 +00:00
Cameron Zwarich
e2e3fc3fe2 Remove the HadAVector instance variable and replace it with a use of ScalarKind.
llvm-svn: 132939
2011-06-13 21:44:40 +00:00
Cameron Zwarich
3614d9bec8 Remove a vacuous check.
llvm-svn: 132938
2011-06-13 21:44:38 +00:00
Cameron Zwarich
934fdc5aba Have SRoA explicitly track the kind of scalar it is promoting. This is pretty
spartan right now, but I plan to encode more information in this enum to improve
the correctness and reliability of SRoA. At least this first pass makes it
possible to make VectorTy an actual VectorType.

llvm-svn: 132937
2011-06-13 21:44:35 +00:00
Cameron Zwarich
ab21bb23b9 Remove an argument that is always true.
llvm-svn: 132936
2011-06-13 21:44:31 +00:00
Stuart Hastings
65d0bc94b4 Avoid fusing bitcasts with dynamic allocas if the amount-to-allocate
might overflow.  Re-typing the alloca to a larger type (e.g. double)
hoists a shift into the alloca, potentially exposing overflow in the
expression.  rdar://problem/9265821

llvm-svn: 132926
2011-06-13 18:48:49 +00:00
Benjamin Kramer
5079b61657 InstCombine: Fold A-b == C --> b == A-C if A and C are constants.
The backend already knew this trick.

llvm-svn: 132915
2011-06-13 15:24:24 +00:00