Commit Graph

1793 Commits

Author SHA1 Message Date
Jay Foad
cd35e09a4a Reinstate r133435 and r133449 (reverted in r133499) now that the clang
self-hosted build failure has been fixed (r133512).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133513 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-21 10:33:19 +00:00
Chad Rosier
a88a0ca808 Revert r133435 and r133449 to appease buildbots.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133499 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-21 02:09:03 +00:00
Jay Foad
72f5f313d8 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.)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133435 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-20 14:38:01 +00:00
Hans Wennborg
448da519cc 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133344 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-18 10:28:47 +00:00
Devang Patel
c013699027 Set debug loc for new preheader's terminator.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133298 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-17 21:36:44 +00:00
Nick Lewycky
1d665c9a9f When promoting an alloca to registers discard any lifetime intrinsics.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133251 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-17 10:09:00 +00:00
Eli Friedman
b53c7937c5 Simplify; no significant functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133086 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-15 21:08:25 +00:00
Rafael Espindola
0ad2dc46d9 Fix cmake build.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133085 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-15 21:03:04 +00:00
Eli Friedman
e97c7da59d Remove unused code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133078 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-15 19:58:09 +00:00
John McCall
c975a51ac0 Use IRBuilder to make our intrinsic calls in the inliner so that we pick up
line info correctly.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132961 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-14 02:51:53 +00:00
Nick Lewycky
708c1ac077 Use Value::stripPointerCasts instead of reinventing part of the wheel.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132954 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-14 00:59:24 +00:00
Nick Lewycky
9a488a8317 It's possible that an all-zero GEP may be used as the argument to lifetime
intrinsics. In fact, we'll optimize a bitcast to that when possible. Detect it
when looking for the lifetime intrinsics.

No test case, noticed by inspection.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132906 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-13 07:52:46 +00:00
John McCall
1dd94bbfa1 SplitCriticalEdge can sometimes split the edge from an invoke to a landing
pad, separating the exception and selector calls from the new lpad.  Teaching
it not to do that, or to properly adjust the CFG afterwards, is out of
scope because it would require the other edges to the landing pad to be split
as well (effectively).  Instead, just recover from the most likely cases
during inlining.  The best long-term solution is to change the exception
representation and commit to either requiring or not requiring the more
complex edge-splitting logic;  this is just a shorter-term hack.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132799 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-09 20:06:24 +00:00
John McCall
e669d83a21 Teach the CallGraph to ignore calls to intrinsics.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132797 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-09 19:46:27 +00:00
Bill Wendling
6a648b8538 If the block that we're threading through is jumped to by an indirect branch,
then we don't want to set the destination in the indirect branch to the
destination. This is because the indirect branch needs its destinations to have
had their block addresses taken. This isn't so of the new critical edge that's
split during this process. If it turns out that the destination block has only
one predecessor, and that being a BB with an indirect branch, then it won't be
marked as 'used' and may be removed.
PR10072


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132638 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-04 09:42:04 +00:00
John McCall
1edbd6f3f0 First, do no harm -- even if we can't find a selector for an enclosing
landing pad, forward llvm.eh.resume calls to it instead of turning them
invalidly into invokes.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132382 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-01 02:17:11 +00:00
John McCall
a6d7345ec9 Fix this to work correctly with phis; test case to follow if this successfully
fixes self-host.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132275 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-29 03:01:09 +00:00
John McCall
d7c1086201 Implement and document the llvm.eh.resume intrinsic, which is
transformed by the inliner into a branch to the enclosing landing pad
(when inlined through an invoke).  If not so optimized, it is lowered
DWARF EH preparation into a call to _Unwind_Resume (or _Unwind_SjLj_Resume
as appropriate).  Its chief advantage is that it takes both the
exception value and the selector value as arguments, meaning that there
is zero effort in recovering these;  however, the frontend is required
to pass these down, which is not actually particularly difficult.

Also document the behavior of landing pads a bit better, and make it
clearer that it's okay that personality functions don't always land at
landing pads.  This is just a fact of life.  Don't write optimizations that
rely on pushing things over an unwind edge.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132253 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-28 07:45:59 +00:00
John McCall
a3de16bc8f Fix the inliner to maintain the current de facto invoke semantics:
- the selector for the landing pad must provide all available information
    about the handlers, filters, and cleanups within that landing pad
  - calls to _Unwind_Resume must be converted to branches to the enclosing
    lpad so as to avoid re-entering the unwinder when the lpad claimed it
    was going to handle the exception in some way
This is quite specific to libUnwind-based unwinding.  In an effort to not
interfere too badly with other unwinders, and with existing hacks in frontends,
this only triggers on _Unwind_Resume (not _Unwind_Resume_or_Rethrow) and does
nothing with selectors if it cannot find a selector call for either lpad.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132200 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-27 18:34:38 +00:00
Eli Friedman
1a24bf0cf9 One more debug line number miss in instcombine (although the code in question isn't actually in instcombine).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132170 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-27 01:00:36 +00:00
Cameron Zwarich
13a16083ab Clean up the lazy initialization of DIBuilder a bit.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131956 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-24 06:00:08 +00:00
Cameron Zwarich
c827939046 Make LoadAndStorePromoter preserve debug info and create llvm.dbg.values when
promoting allocas to SSA variables. Fixes <rdar://problem/9479036>.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131953 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-24 03:10:43 +00:00
Frits van Bommel
5649ba70fb Add a parameter to ConstantFoldTerminator() that callers can use to ask it to also clean up the condition of any conditional terminator it folds to be unconditional, if that turns the condition into dead code. This just means it calls RecursivelyDeleteTriviallyDeadInstructions() in strategic spots. It defaults to the old behavior.
I also changed -simplifycfg, -jump-threading and -codegenprepare to use this to produce slightly better code without any extra cleanup passes (AFAICT this was the only place in -simplifycfg where now-dead conditions of replaced terminators weren't being cleaned up). The only other user of this function is -sccp, but I didn't read that thoroughly enough to figure out whether it might be holding pointers to instructions that could be deleted by this.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131855 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-22 16:24:18 +00:00
Nick Lewycky
6d55f2269e Teach the inliner to emit llvm.lifetime.start/end, to scope the local variables
of the inlinee to the code representing the original function.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131838 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-22 05:22:10 +00:00
Devang Patel
d3a1788da1 Reapply r131605. This time with a fix, which is to use NoFolder.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131673 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-19 20:52:46 +00:00
Rafael Espindola
216dde91d1 revert 131605 to fix PR9946.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131620 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-19 02:26:30 +00:00
Devang Patel
1f5812bd99 Use IRBuilder.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131609 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-19 00:13:33 +00:00
Devang Patel
1aa89a2f91 Use IRBuilder while simplifying unreachable.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131607 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-19 00:09:21 +00:00
Devang Patel
0b4ccdc98c Use IRBuilder while simplifying conditional branch.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131605 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-18 23:59:51 +00:00
Devang Patel
02dd5418d2 Use IRBuilder while simplifying branch.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131598 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-18 23:18:47 +00:00
Devang Patel
176ec40cb1 Use IRBuilder while simplifying return instruction.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131580 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-18 21:33:11 +00:00
Devang Patel
b55d924b1e Spread use of IRBuilder even more.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131571 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-18 20:53:17 +00:00
Devang Patel
007349dafd Use IRBuilder while simplifying switch instruction.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131566 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-18 20:35:38 +00:00
Devang Patel
d46ba26a6b Use IRBuilder while simplifying unwind.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131561 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-18 20:01:18 +00:00
Devang Patel
d3372b85e6 Use IRBuilder while simplifying terminator.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131552 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-18 18:43:31 +00:00
Devang Patel
a23812cfbd Use IRBuilder while simplifying unconditional branch.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131551 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-18 18:28:48 +00:00
Devang Patel
f60364de44 Use IRBuilder while folding two entry PHINode.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131548 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-18 18:16:44 +00:00
Devang Patel
3e410c6607 Set up IRBuilder for use during simplification.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131545 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-18 18:01:27 +00:00
Matt Beaumont-Gay
f88ad9aeee fix typo
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131543 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-18 17:37:10 +00:00
Devang Patel
62fb3556ea Use IRBuiler while constant folding terminator.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131541 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-18 17:26:46 +00:00
Devang Patel
d80e8ed2fa Preseve line numbers while simplifying CFG.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131508 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-17 23:29:05 +00:00
Devang Patel
c9ea771cb8 Preserve line number information.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131480 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-17 19:43:06 +00:00
Devang Patel
a8992b3e72 There is no need to force DebugLoc on a PHI at this point.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131427 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-16 22:05:03 +00:00
Devang Patel
227dfdb3c4 Preserve debug info for unused zero extended boolean argument.
Radar 9422775.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131422 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-16 21:24:05 +00:00
Benjamin Kramer
10fcfb53fd SimplifyCFG: Use ComputeMaskedBits to prune dead cases from switch instructions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131345 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-14 15:57:25 +00:00
Devang Patel
a922ba7edc Set debug location for new PHI nodes created in exit block.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130894 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-04 23:58:22 +00:00
Devang Patel
67352b3ce7 Scanning entire basic block may be too expensive in terms of compile time. Instead, just use whatever location info first non-phi instruction has.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130729 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-02 21:57:00 +00:00
Devang Patel
40348e8d1f Assing line number info to new PHIs created by SSA updater.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130551 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-29 22:28:59 +00:00
Peter Collingbourne
57808b3da0 SimplifyCFG: Expose phi node folding cost threshold as command line parameter
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130528 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-29 18:47:38 +00:00
Peter Collingbourne
f15907fead SimplifyCFG: Add CostRemaining parameter to DominatesMergePoint
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130527 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-29 18:47:31 +00:00