1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 11:02:59 +02:00
Commit Graph

173 Commits

Author SHA1 Message Date
Bob Wilson
42ef17e8b6 Stop trying to merge identical jump tables. This had been inadvertently
disabled for several months (since svn r88806) and no one noticed.  My fix
for pr6543 yesterday reenabled it, but broke the ARM port's code for using
TBB/TBH.  Rather than adding a target hook to disable merging for Thumb2 only,
I'm just taking this out.  It is not common to have identical jump tables,
the code we used to merge them was O(N^2), and it only helps code size, not
performance.

llvm-svn: 98977
2010-03-19 19:05:41 +00:00
Bob Wilson
7a9bf0aa55 Remove a check that can no longer be true, after r84803.
llvm-svn: 98694
2010-03-16 23:40:32 +00:00
Chris Lattner
de49dbc188 eliminate InvalidateLabel and LabelIDList from MMI and replace
them with a counter.

llvm-svn: 98462
2010-03-14 02:24:55 +00:00
Dale Johannesen
5edf11aad3 Fix another place where DEBUG_VALUE affected codegen.
llvm-svn: 98181
2010-03-10 19:57:56 +00:00
Dale Johannesen
c9611b6d0a This survived a bootstrap, so let's try 98104 again.
llvm-svn: 98137
2010-03-10 05:45:47 +00:00
Dale Johannesen
3800f76c1a Speculatively revert 98104; could be what's causing crashes
llvm-svn: 98108
2010-03-10 00:11:34 +00:00
Dale Johannesen
02f3bfbecc Ever more complicated DEBUG_VALUE fixes for branch folding.
llvm-svn: 98104
2010-03-09 23:52:37 +00:00
Dale Johannesen
d610f0a82a Fix dbg value handling in tail merging.
llvm-svn: 97938
2010-03-08 05:38:13 +00:00
Dale Johannesen
b1fd546dd0 Fix some more places where dbg_value affected codegen.
llvm-svn: 97765
2010-03-05 00:02:59 +00:00
Chris Lattner
7acf9be6c4 move target-independent opcodes out of TargetInstrInfo
into TargetOpcodes.h.  #include the new TargetOpcodes.h
into MachineInstr.  Add new inline accessors (like isPHI())
to MachineInstr, and start using them throughout the 
codebase.

llvm-svn: 95687
2010-02-09 19:54:29 +00:00
Chris Lattner
efdc572e44 Rearrange handling of jump tables. Highlights:
1. MachineJumpTableInfo is now created lazily for a function the first time
   it actually makes a jump table instead of for every function.
2. The encoding of jump table entries is now described by the
   MachineJumpTableInfo::JTEntryKind enum.  This enum is determined by the
   TLI::getJumpTableEncoding() hook, instead of by lots of code scattered
   throughout the compiler that "knows" that jump table entries are always
   32-bits in pic mode (for example).
3. The size and alignment of jump table entries is now calculated based on
   their kind, instead of at machinefunction creation time.

Future work includes using the EntryKind in more places in the compiler,
eliminating other logic that "knows" the layout of jump tables in various
situations.

llvm-svn: 94470
2010-01-25 23:26:13 +00:00
David Greene
48aa5efa78 Change errs() to dbgs().
llvm-svn: 92097
2009-12-24 00:34:21 +00:00
Bill Wendling
92b5353278 Initialize uninitialized variables.
llvm-svn: 91477
2009-12-16 00:01:27 +00:00
Bill Wendling
e2df6b28f4 Initialize uninitialized variables.
llvm-svn: 91475
2009-12-16 00:00:18 +00:00
Bill Wendling
d2e25c606e Revert these. They may have been causing 483_xalancbmk to fail:
$ svn merge -c -91161 https://llvm.org/svn/llvm-project/llvm/trunk
--- Reverse-merging r91161 into '.':
U    lib/CodeGen/BranchFolding.cpp
U    lib/CodeGen/MachineBasicBlock.cpp
$ svn merge -c -91113 https://llvm.org/svn/llvm-project/llvm/trunk
--- Reverse-merging r91113 into '.':
G    lib/CodeGen/MachineBasicBlock.cpp
$ svn merge -c -91101 https://llvm.org/svn/llvm-project/llvm/trunk
--- Reverse-merging r91101 into '.':
U    include/llvm/CodeGen/MachineBasicBlock.h
G    lib/CodeGen/MachineBasicBlock.cpp
$ svn merge -c -91092 https://llvm.org/svn/llvm-project/llvm/trunk
--- Reverse-merging r91092 into '.':
G    include/llvm/CodeGen/MachineBasicBlock.h
G    lib/CodeGen/MachineBasicBlock.cpp

llvm-svn: 91376
2009-12-15 00:39:24 +00:00
Bill Wendling
10e315eae4 Don't try to move a MBB into the fall-through position if it's a landing pad or
branches only to a landing pad. Without this check, the compiler would go into
an infinite loop because the branch to a landing pad is an "abnormal" edge which
wasn't being taken into account.

This is the meat of that fix:

  if (!PrevBB.canFallThrough() && !MBB->BranchesToLandingPad(MBB)) {

The other stuff is simplification of the "branches to a landing pad" code.

llvm-svn: 91161
2009-12-11 21:47:36 +00:00
Dan Gohman
f9654e9258 Remove the target hook TargetInstrInfo::BlockHasNoFallThrough in favor of
MachineBasicBlock::canFallThrough(), which is target-independent and more
thorough.

llvm-svn: 90634
2009-12-05 00:44:40 +00:00
Chris Lattner
9ce833945e improve portability to avoid conflicting with std::next in c++'0x.
Patch by Howard Hinnant!

llvm-svn: 90365
2009-12-03 00:50:42 +00:00
Bob Wilson
de012efdba Split tail duplication into a separate pass. This is needed to avoid
running tail duplication when doing branch folding for if-conversion, and
we also want to be able to run tail duplication earlier to fix some
reg alloc problems.  Move the CanFallThrough function from BranchFolding
to MachineBasicBlock so that it can be shared by TailDuplication.

llvm-svn: 89904
2009-11-26 00:32:21 +00:00
Bob Wilson
c5fa56c805 Refactor target hook for tail duplication as requested by Chris.
Make tail duplication of indirect branches much more aggressive (for targets
that indicate that it is profitable), based on further experience with
this transformation.  I compiled 3 large applications with and without
this more aggressive tail duplication and measured minimal changes in code
size.  ("size" on Darwin seems to round the text size up to the nearest
page boundary, so I can only say that any code size increase was less than
one 4k page.) Radar 7421267.

llvm-svn: 89814
2009-11-24 23:35:49 +00:00
Bob Wilson
c61bad9dc7 There should be no need to keep renumbering blocks during tail duplication.
llvm-svn: 89275
2009-11-18 23:48:57 +00:00
Bob Wilson
dccd3bdb4e Tail duplication still needs to iterate. Duplicating new instructions onto
the tail of a block may make that block a new candidate for duplication.

llvm-svn: 89264
2009-11-18 22:52:37 +00:00
Bob Wilson
5cb1da935f Add another statistic to measure code size due to tail duplication.
llvm-svn: 89254
2009-11-18 22:12:31 +00:00
Bob Wilson
39c6d5d3dd Add statistics for tail duplication.
llvm-svn: 89225
2009-11-18 19:29:37 +00:00
Bob Wilson
6b68bd153a Add a target hook to allow changing the tail duplication limit based on the
contents of the block to be duplicated.  Use this for ARM Cortex A8/9 to
be more aggressive tail duplicating indirect branches, since it makes it
much more likely that they will be predicted in the branch target buffer.
Testcase coming soon.

llvm-svn: 89187
2009-11-18 03:34:27 +00:00
Bob Wilson
fe3a0fccb9 Remove a special case for tail merging that seems to be both broken and
unnecessary.  It is broken because the "isIdenticalTo" check should be
negated.  If that is fixed, this code causes the CodeGen/X86/tail-opts.ll
test to fail, in the dont_merge_oddly function.  And, I confirmed that the
regression is real -- the generated code is worse.  As far as I can tell,
that tail-opts.ll test is checking for what this code is supposed to handle
and we're doing the right thing anyway.

llvm-svn: 89121
2009-11-17 18:30:09 +00:00
Dan Gohman
801e8e8291 Set MadeChange instead of MadeChangeThisIteration.
llvm-svn: 89114
2009-11-17 18:04:15 +00:00
Bob Wilson
84ab1a13a3 Update a comment, now that tail duplication happens after other branch
folding optimizations.

llvm-svn: 89109
2009-11-17 17:40:31 +00:00
Bob Wilson
eaa8a9aa98 Perform tail duplication only once, after tail merging is complete.
It was too difficult to keep the heuristics for merging and duplication
consistent.

llvm-svn: 89105
2009-11-17 17:06:18 +00:00
Bob Wilson
ead1392ff4 Fix a comment.
llvm-svn: 88940
2009-11-16 19:33:27 +00:00
Bob Wilson
72925c0154 Fix some comments.
llvm-svn: 88932
2009-11-16 18:54:08 +00:00
Bob Wilson
eca4a0c2e4 Whitespace: be consistent with pointer syntax.
llvm-svn: 88929
2009-11-16 18:08:46 +00:00
Bob Wilson
04825f6c4b Clean up whitespace.
llvm-svn: 88927
2009-11-16 17:56:13 +00:00
Dan Gohman
972293611d When optimizing for size, don't tail-merge unless it's likely to be a
code-size win, and not when it's only likely to be code-size neutral,
such as when only a single instruction would be eliminated and a new
branch would be required.

This fixes rdar://7392894.

llvm-svn: 88692
2009-11-13 21:02:15 +00:00
Dan Gohman
b6f852353a Make the BranchFolderPass class local to BranchFolding.cpp.
llvm-svn: 86928
2009-11-12 01:59:26 +00:00
Dan Gohman
8931850b74 Minor code cleanups.
llvm-svn: 86926
2009-11-12 01:51:28 +00:00
Dan Gohman
f8ec4856e4 Tail merge at any size when there are two potentials blocks and one
can be made to fall through into the other.

llvm-svn: 86909
2009-11-12 00:39:10 +00:00
Dan Gohman
93c57d5ff0 Promote MergePotentialsElt and SameTailElt to be regular classes
instead of typedefs for std::pair. This simplifies the type of
SameTails, which previously was std::vector<std::pair<std::vector<std::pair<unsigned, MachineBasicBlock *> >::iterator, MachineBasicBlock::iterator>

llvm-svn: 86885
2009-11-11 21:57:02 +00:00
Dan Gohman
9623ba83ce Revert this line of 86871.
llvm-svn: 86875
2009-11-11 19:56:05 +00:00
Dan Gohman
9f47de10e3 Add support for tail duplication to BranchFolding, and extend
tail merging support to handle more cases.
 - Recognize several cases where tail merging is beneficial even when
   the tail size is smaller than the generic threshold.
 - Make use of MachineInstrDesc::isBarrier to help detect
   non-fallthrough blocks.
 - Check for and avoid disrupting fall-through edges in more cases.

llvm-svn: 86871
2009-11-11 19:48:59 +00:00
Dan Gohman
b0f32c095c Fix indentation level.
llvm-svn: 86856
2009-11-11 18:42:28 +00:00
Dan Gohman
b72c986b78 Whitespace cleanups.
llvm-svn: 86855
2009-11-11 18:38:14 +00:00
Dan Gohman
60b5c20890 Prefix MBB numbers with "BB#" in debug output to make it clear what
the numbers mean.

llvm-svn: 86854
2009-11-11 18:23:17 +00:00
Dan Gohman
281338a3d2 Minor code simplification.
llvm-svn: 86853
2009-11-11 18:18:34 +00:00
Dan Gohman
ae83652ce1 Remove an unused variable.
llvm-svn: 86642
2009-11-10 01:37:57 +00:00
Dan Gohman
4d8fef974a Minor code simplification.
llvm-svn: 86641
2009-11-10 01:36:20 +00:00
Bob Wilson
8209e942a6 Fix branch folding bug for indirect branches: for a block containing only
an unconditional branch (possibly from tail merging), this code is
trying to redirect all of its predecessors to go directly to the branch
target, but that isn't feasible for indirect branches.  The other
predecessors (that don't end with indirect branches) could theoretically
still be handled, but that is not easily done right now.

The AnalyzeBranch interface doesn't currently let us distinguish jump table
branches from indirect branches, and this code is currently handling
jump tables.  To avoid punting on address-taken blocks, we would have to give
up handling jump tables.  That seems like a bad tradeoff.

llvm-svn: 85975
2009-11-03 23:44:31 +00:00
Dan Gohman
2f18203b64 Don't delete blocks which have their address taken.
llvm-svn: 85572
2009-10-30 02:13:27 +00:00
Bob Wilson
e99d5530a3 Refactor complicated predicate into a separate function.
llvm-svn: 85519
2009-10-29 18:40:06 +00:00
Bob Wilson
f13be9d41e Reimplement BranchFolding change to avoid tail merging for a 1 instruction
common tail, except when the OptimizeForSize function attribute is present.
Radar 7338114.

llvm-svn: 85441
2009-10-28 22:10:20 +00:00