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

13294 Commits

Author SHA1 Message Date
Jakob Stoklund Olesen
55ff251cc1 Move the operand iterator into MachineInstrBundle.h where it belongs.
Extract a base class and provide four specific sub-classes for iterating
over const/non-const bundles/instructions.

This eliminates the mystery bool constructor argument.

llvm-svn: 151684
2012-02-29 00:33:41 +00:00
Lang Hames
61e76ce0cf Kill off LiveRangeEdit::getNewVRegs and LiveRangeEdit::getUselessVRegs. These
methods are no longer needed now that LinearScan has gone away.

(Contains tweaks trivialSpillEverywhere to enable the removal of getNewVRegs).

llvm-svn: 151658
2012-02-28 22:07:24 +00:00
Evan Cheng
c5ead6c49e Re-commit r151623 with fix. Only issue special no-return calls if it's a direct call.
llvm-svn: 151645
2012-02-28 18:51:51 +00:00
Benjamin Kramer
9bff93fd22 Fix off-by one in comment.
llvm-svn: 151644
2012-02-28 18:37:06 +00:00
Benjamin Kramer
daa291f4fd LegalizeIntegerTypes: Reenable the large shift with small amount optimization.
To avoid problems with zero shifts when getting the bits that move between words
we use a trick: first shift the by amount-1, then do another shift by one. When
amount is 0 (and size 32) we first shift by 31, then by one, instead of by 32.

Also fix a latent bug that emitted the low and high words in the wrong order
when shifting right.

Fixes PR12113.

llvm-svn: 151637
2012-02-28 17:58:00 +00:00
Daniel Dunbar
b448d31a6b Revert r151623 "Some ARM implementaions, e.g. A-series, does return stack prediction. ...", it is breaking the Clang build during the Compiler-RT part.
llvm-svn: 151630
2012-02-28 15:36:07 +00:00
Nadav Rotem
9c1789a96c Code cleanup following CR by Duncan.
llvm-svn: 151627
2012-02-28 14:13:19 +00:00
Nadav Rotem
75b36e6716 Fix a bug in the code that builds SDNodes from vector GEPs.
When the GEP index is a vector of pointers, the code that calculated the size
of the element started from the vector type, and not the contained pointer type.
As a result, instead of looking at the data element pointed by the vector, this
code used the size of the vector. This works for 32bit members (on 32bit
systems), but not for other types. Added code to peel the vector type and
added a test.

llvm-svn: 151626
2012-02-28 11:54:05 +00:00
Evan Cheng
d29a22e4b0 Some ARM implementaions, e.g. A-series, does return stack prediction. That is,
the processor keeps a return addresses stack (RAS) which stores the address
and the instruction execution state of the instruction after a function-call
type branch instruction.

Calling a "noreturn" function with normal call instructions (e.g. bl) can
corrupt RAS and causes 100% return misprediction so LLVM should use a
unconditional branch instead. i.e.
mov lr, pc
b _foo
The "mov lr, pc" is issued in order to get proper backtrace.

rdar://8979299

llvm-svn: 151623
2012-02-28 06:42:03 +00:00
Jakob Stoklund Olesen
c74b7b271e Handle regmasks in MachineCSE.
Don't attempt to extend physreg live ranges across calls.

<rdar://problem/10942095>

llvm-svn: 151610
2012-02-28 02:08:50 +00:00
Jakob Stoklund Olesen
e3a308c116 Handle regmasks in the machine code verifier.
llvm-svn: 151607
2012-02-28 01:42:41 +00:00
Chad Rosier
2eec1f2ac0 Fix 80-column violation.
llvm-svn: 151599
2012-02-28 00:23:01 +00:00
Evan Cheng
9627003887 Fix for PR12090: clear def maps of aliases when visiting a copy. e.g.
%S5<def> = COPY %S0<kill>
First clear def map of Q1, etc.

No small test case available.

llvm-svn: 151574
2012-02-27 21:46:42 +00:00
Jakob Stoklund Olesen
edc3446412 Update machine code verifier.
After the SlotIndex slot names were updated, it is possible to apply
stricter checks to live intervals.

Also treat bundles as bags of operands when checking live intervals.

llvm-svn: 151531
2012-02-27 18:24:30 +00:00
Lang Hames
25553028ff Make the peephole optimizer clear kill flags on a vreg if it's about to add new
uses of the vreg, since the old kills may no longer be valid.  This was causing
-verify-machineinstrs to complain about uses after kills, and could potentially
have been causing subtle register allocation issues, but I haven't come across a
test case yet.

llvm-svn: 151425
2012-02-25 02:01:00 +00:00
Lang Hames
6ec3b488f8 Fixed typo.
llvm-svn: 151417
2012-02-25 00:46:38 +00:00
Jakob Stoklund Olesen
090f01cde9 Add missing static
llvm-svn: 151396
2012-02-24 21:52:44 +00:00
Jakob Stoklund Olesen
c077e0f945 Add a -stress-regalloc=<N> option.
This will limit all register classes to N registers in order to stress
test register allocation.

llvm-svn: 151379
2012-02-24 18:34:20 +00:00
Hal Finkel
8c2c90c035 Don't crash when a glue node contains an internal CopyToReg
This is necessary to support the existing ppc lowering code for indirect calls.
Fixes PR12071.

llvm-svn: 151373
2012-02-24 17:53:59 +00:00
Benjamin Kramer
993a8a86dd SDAGBuilder: Remove register sets that were never read and prune dead code surrounding it.
llvm-svn: 151364
2012-02-24 14:01:17 +00:00
Nick Lewycky
04735e1180 ScheduleDAGInstrs.h:155: warning: suggest parentheses around &&' within ||'.
llvm-svn: 151355
2012-02-24 07:59:05 +00:00
Andrew Trick
5c9371d10f PostRA sched: speed up physreg tracking by not abusing SparseSet.
llvm-svn: 151348
2012-02-24 07:04:55 +00:00
Pete Cooper
135769381b Turn avx insert intrinsic calls into INSERT_SUBVECTOR DAG nodes and remove duplicate patterns for selecting the intrinsics
llvm-svn: 151342
2012-02-24 03:51:49 +00:00
Eric Christopher
ea7403bfe2 If the Address of a variable is an argument then treat the entire
variable declaration as an argument because we want that address
anyhow for our debug information.

This seems to fix rdar://9965111, at least we have more debug
information than before and from reading the assembly it appears
to be the correct location.

llvm-svn: 151335
2012-02-24 01:59:08 +00:00
Eric Christopher
a4f94b0c3e Tabs, formatting and long lines oh my!
llvm-svn: 151334
2012-02-24 01:59:01 +00:00
Bill Wendling
1a35321235 Allow an integer to be converted into an MMX type when it's used in an inline
asm.
<rdar://problem/10106006>

llvm-svn: 151303
2012-02-23 23:25:25 +00:00
Benjamin Kramer
386c7b5901 BitVectorize loop.
llvm-svn: 151274
2012-02-23 19:29:25 +00:00
Benjamin Kramer
33ba1e7f2b post-ra-sched: Turn the KillIndices vector into a bitvector, it only stored two meaningful states.
Rename it to LiveRegs to make it more clear what's stored inside.

llvm-svn: 151273
2012-02-23 19:15:40 +00:00
Benjamin Kramer
d18bd5e885 post-ra-sched: Replace a std::set of regs with a bitvector.
Assuming that a single std::set node adds 3 control words, a bitvector
can store (3*8+4)*8=224 registers in the allocated memory of a single
element in the std::set (x86_64). Also we don't have to call malloc
for every register added.

llvm-svn: 151269
2012-02-23 18:28:32 +00:00
Jakob Stoklund Olesen
030f090aee Make calls scheduling boundaries post-ra.
Before register allocation, instructions can be moved across calls in
order to reduce register pressure.  After register allocation, we don't
gain a lot by moving callee-saved defs across calls.  In fact, since the
scheduler doesn't have a good idea how registers are used in the callee,
it can't really make good scheduling decisions.

This changes the schedule in two ways: 1. Latencies to call uses and
defs are no longer accounted for, causing some random shuffling around
calls.  This isn't really a problem since those uses and defs are
inaccurate proxies for what happens inside the callee.  They don't
represent registers used by the call instruction itself.

2. Instructions are no longer moved across calls.  This didn't happen
very often, and the scheduling decision was made on dubious information
anyway.

As with any scheduling change, benchmark numbers shift around a bit,
but there is no positive or negative trend from this change.

This makes the post-ra scheduler 5% faster for ARM targets.

The secret motivation for this patch is the introduction of register
mask operands representing call clobbers.  The most efficient way of
handling regmasks in ScheduleDAGInstrs is to model them as barriers for
physreg live ranges, but not for virtreg live ranges.  That's fine
pre-ra, but post-ra it would have the same effect as this patch.

llvm-svn: 151265
2012-02-23 17:54:21 +00:00
Benjamin Kramer
3839bfa8d6 Strip a layer of boilerplate from the VLIWPacketizer by storing the scheduler as an opaque pointer.
llvm-svn: 151252
2012-02-23 13:39:13 +00:00
Anton Korobeynikov
fb863cd279 Fix to make sure that a comdat group gets generated correctly for a static member
of instantiated C++ templates.

Patch by Kristof Beyls!

llvm-svn: 151250
2012-02-23 10:36:04 +00:00
Eric Christopher
11256ac91b More newline cleanups.
llvm-svn: 151235
2012-02-23 03:39:43 +00:00
Eric Christopher
ab73f1be35 Add some handy-dandy newlines.
llvm-svn: 151234
2012-02-23 03:39:39 +00:00
Andrew Trick
913f302a31 misched: cleanup reaching def computation
Ignore undef uses completely.
Use a more explicit SlotIndex API.
Add more explicit comments.

llvm-svn: 151233
2012-02-23 03:16:24 +00:00
Andrew Trick
2cb2c4c487 PostRASched: Convert physreg def/use tracking to Jakob's SparseSet.
Added array subscript to SparseSet for convenience.
Slight reorg to make it easier to manage the def/use sets.

llvm-svn: 151228
2012-02-23 01:52:38 +00:00
Jakob Stoklund Olesen
160ff15f26 Handle regmasks in FixupKills.
llvm-svn: 151226
2012-02-23 01:22:15 +00:00
Jakob Stoklund Olesen
7888265c63 Handle regmasks in CriticalAntiDepBreaker.
llvm-svn: 151223
2012-02-23 01:15:26 +00:00
Jakob Stoklund Olesen
1ef46c1866 Track reserved registers separately from RegsAvailable.
The bulk masking operations from register mask operands don't account
for reserved registers.

llvm-svn: 151222
2012-02-23 01:13:32 +00:00
Jakob Stoklund Olesen
ff8fc50831 Don't compute latencies for regmask operands.
llvm-svn: 151211
2012-02-22 22:52:52 +00:00
Jakob Stoklund Olesen
d9600dff1c Handle regmasks in RegisterScavenging.
llvm-svn: 151210
2012-02-22 22:50:14 +00:00
Andrew Trick
1caa19b613 misched: Use SparseSet for VRegDegs for constant time clear().
llvm-svn: 151205
2012-02-22 21:59:00 +00:00
Hal Finkel
cfc8c850f6 Allow the use of an alternate symbol for calculating a function's size.
The standard function epilog includes a .size directive, but ppc64 uses
an alternate local symbol to tag the actual start of each function.

Until recently, binutils accepted the .size directive as:
 .size	test1, .Ltmp0-test1
however, using this directive with recent binutils will result in the error:
 .size expression for XXX does not evaluate to a constant
so we must use the label which actually tags the start of the function.

llvm-svn: 151200
2012-02-22 21:11:47 +00:00
Michael J. Spencer
24f6d49962 Properly emit _fltused with FastISel. Refactor to share code with SDAG.
Patch by Joe Groff!

llvm-svn: 151183
2012-02-22 19:06:13 +00:00
Andrew Trick
8827848788 Comment from code review
llvm-svn: 151178
2012-02-22 18:34:49 +00:00
Chad Rosier
3703a1917a Remove extra semi-colons.
llvm-svn: 151169
2012-02-22 17:25:00 +00:00
Jakob Stoklund Olesen
c68efb4311 80 col.
llvm-svn: 151167
2012-02-22 16:50:46 +00:00
Eric Christopher
9f47c92b48 Only add DW_AT_prototyped if we're working with a C-like language.
Worth another 45k (1%) off of a large C++ testcase.

rdar://10909458

llvm-svn: 151144
2012-02-22 08:46:21 +00:00
Eric Christopher
32802595f6 Add the source language into the compile unit.
llvm-svn: 151143
2012-02-22 08:46:13 +00:00
Eric Christopher
61c6749e44 Remove extra semi-colon.
llvm-svn: 151142
2012-02-22 08:46:02 +00:00
Andrew Trick
98a6abc9f6 misched: DAG builder should not track dependencies for SSA defs.
The vast majority of virtual register definitions don't need an entry
in the DAG builder's VRegDefs set.

llvm-svn: 151136
2012-02-22 06:08:13 +00:00
Andrew Trick
5c61d0befc Initialize SUnits before DAG building.
Affect on SD scheduling and postRA scheduling:
Printing the DAG will display the nodes in top-down topological order.
This matches the order within the MBB and makes my life much easier in general.

Affect on misched:
We don't need to track virtual register uses at all. This is awesome.
I also intend to rely on the SUnit ID as a topo-sort index. So if A < B then we cannot have an edge B -> A.

llvm-svn: 151135
2012-02-22 06:08:11 +00:00
Craig Topper
3ed929de0a Make all pointers to TargetRegisterClass const since they are all pointers to static data that should not be modified.
llvm-svn: 151134
2012-02-22 05:59:10 +00:00
Jakob Stoklund Olesen
a1db1a4669 Use SparseSet for the RAFast live virtual register map.
This makes RAFast 4% faster, and it gets rid of the dodgy DenseMap
iteration.

This also revealed that RAFast would sometimes dereference DenseMap
iterators after erasing other elements from the map. That does seem to
work in the current DenseMap implementation, but SparseSet doesn't allow
it.

llvm-svn: 151111
2012-02-22 01:02:37 +00:00
Lang Hames
15c7539a46 Add API "handleMoveIntoBundl" for updating liveness when moving instructions into
bundles. This method takes a bundle start and an MI being bundled, and makes
the intervals for the MI's operands appear to start/end on the bundle start.

Also fixes some minor cosmetic issues (whitespace, naming convention) in the
HMEditor code.

llvm-svn: 151099
2012-02-21 22:29:38 +00:00
Eric Christopher
7b19cf8b2a There's no need for a DW_AT_byte_size on a pointer type.
Part of rdar://10493979 where it reduces by about .5% (10k)

llvm-svn: 151097
2012-02-21 22:25:53 +00:00
Andrew Trick
25ec43e9fe Clear virtual registers after they are no longer referenced.
Passes after RegAlloc should be able to rely on MRI->getNumVirtRegs() == 0.
This makes sharing code for pre/postRA passes more robust.
Now, to check if a pass is running before the RA pipeline begins, use MRI->isSSA().
To check if a pass is running after the RA pipeline ends, use !MRI->getNumVirtRegs().

PEI resets virtual regs when it's done scavenging.

PTX will either have to provide its own PEI pass or assign physregs.

llvm-svn: 151032
2012-02-21 04:51:23 +00:00
Andrew Trick
719b2521ef StackSlotColoring does not use a VirtRegMap
llvm-svn: 151031
2012-02-21 04:51:19 +00:00
Lang Hames
1b774db571 Fix some bugs in HMEditor's moveAllOperandsInto logic.
llvm-svn: 151006
2012-02-21 00:00:36 +00:00
Evan Cheng
3bffc22fc2 Fix machine-cp by having it to check sub-register indicies. e.g.
ecx = mov eax
al  = mov ch
The second copy is not a nop because the sub-indices of ecx,ch is not the
same of that of eax/al.

Re-enabled machine-cp.
PR11940

llvm-svn: 151002
2012-02-20 23:28:17 +00:00
James Molloy
9963b8be92 Teach the DAGCombiner that certain loadext nodes followed by ANDs can be converted to zeroexts.
llvm-svn: 150957
2012-02-20 12:02:38 +00:00
Evan Cheng
499c67989a Make post-ra tail duplication bundle safe. No test case as recent codegen
flow changes have already hidden the bug. rdar://10893812

llvm-svn: 150949
2012-02-20 07:51:58 +00:00
Benjamin Kramer
576a9ea6ca Silence operator precedence warning.
llvm-svn: 150921
2012-02-19 12:25:07 +00:00
Ahmed Charles
745c53c2a7 Remove dead code. Improve llvm_unreachable text. Simplify some control flow.
llvm-svn: 150918
2012-02-19 11:37:01 +00:00
Lang Hames
88e5e4d72e Add machinery for pushing live ranges onto bundle starts while bundling.
llvm-svn: 150915
2012-02-19 07:13:05 +00:00
Lang Hames
bdb4efcb20 Simplify moveEnteringDownFrom rules.
llvm-svn: 150914
2012-02-19 06:13:56 +00:00
Lang Hames
831e129c9d Skip through instructions rather than operands when looking for last use slot.
llvm-svn: 150912
2012-02-19 04:38:25 +00:00
Lang Hames
8b2e08187a Fix TODO and trailing whitespace.
llvm-svn: 150910
2012-02-19 03:09:55 +00:00
Lang Hames
b946cb5e75 Defer sanity checks on live intervals until after all have been updated. Hold (LiveInterval, LiveRange) pairs to update, rather than vregs.
llvm-svn: 150909
2012-02-19 03:00:30 +00:00
Lang Hames
095e9964bd Bring HMEditor into line with LLVM coding standards.
llvm-svn: 150851
2012-02-17 23:43:40 +00:00
Eric Christopher
325985565a Ignore the lifetime intrinsics in fast-isel.
llvm-svn: 150848
2012-02-17 23:03:39 +00:00
Jakob Stoklund Olesen
4aa0e7c7c4 Don't print out pointer values in SUnit::dump().
llvm-svn: 150842
2012-02-17 21:44:51 +00:00
Matt Beaumont-Gay
a45b6e23d0 Sink variable into assert
llvm-svn: 150841
2012-02-17 21:40:48 +00:00
Lang Hames
27171ecf20 Add support for regmask slots to HMEditor. Also fixes a comment error.
llvm-svn: 150840
2012-02-17 21:29:41 +00:00
Jakob Stoklund Olesen
bde432b917 Transfer regmasks to MRI.
MRI keeps track of which physregs have been used. Make sure it gets
updated with all the regmask-clobbered registers.

Delete the closePhysRegsUsed() function which isn't necessary.

llvm-svn: 150830
2012-02-17 19:07:56 +00:00
Lang Hames
ed9553242f Refactor 'handleMove' code in live intervals. Clients of LiveIntervals won't see
any changes.

Internally this adds a private inner class HMEditor, to LiveIntervals. HMEditor provides
an API for updating live intervals when code is moved or bundled.

llvm-svn: 150826
2012-02-17 18:44:18 +00:00
Jim Grosbach
f636a3204d Tidy up.
llvm-svn: 150820
2012-02-17 17:35:10 +00:00
Jakob Stoklund Olesen
355efd71af Revert r150288, "Allow Post-RA LICM to hoist reserved register reads."
This caused miscompilations on out-of-tree targets, and possibly i386 as
well.

I'll find some other way of hoisting %rip-relative loads from loops
containing calls.

llvm-svn: 150816
2012-02-17 16:40:44 +00:00
David Chisnall
d5d4804858 ... and it's probably best to use the correct alignment, rather than just guessing that it's the same as the size.
llvm-svn: 150813
2012-02-17 16:30:39 +00:00
David Chisnall
86b0f069d6 It turns out that putting an 8-byte symbol in a 4-byte section makes Solaris ld sulk. GNU ld is perfectly happy with it, which is worrying for a whole other set of reasons...
Thanks to Anton, Duncan and Rafael for helping me track this down.
Pointy hat to Rafael for introducing the bug in the first place.

llvm-svn: 150811
2012-02-17 16:05:50 +00:00
Lang Hames
a8cd3b538d Reverse iterator - should be incrementing rather than decrementing.
llvm-svn: 150778
2012-02-17 01:54:11 +00:00
Lang Hames
dd3a5d8e78 MachineScheduler shouldn't use/preserve LiveDebugVariables.
llvm-svn: 150773
2012-02-17 01:11:37 +00:00
Lang Hames
680ee0f7e0 Oops - isRegLiveIntoSuccessor is used in non-assert builds now. Remove NDEBUG guards.
llvm-svn: 150771
2012-02-17 00:51:32 +00:00
Lang Hames
99cd3c4b9e Re-enable 150652 and 150654 - Make FPSCR non-reserved, and make MachineCSE bail on reserved registers. This *should* be safe as of r150786.
llvm-svn: 150769
2012-02-17 00:27:16 +00:00
Lang Hames
89b5263016 Turn off assertion, conservatively compute liveness for live-in un-allocatable registers.
llvm-svn: 150768
2012-02-17 00:18:18 +00:00
Benjamin Kramer
814de25917 Disable machine copy propagation for now. It's known to be buggy (PR11940) and introduces subtle miscompiles in many places.
llvm-svn: 150703
2012-02-16 17:29:50 +00:00
James Molloy
29c431b327 Remove extraneous #include and spelling mistake introduced in r150669.
llvm-svn: 150670
2012-02-16 09:48:07 +00:00
James Molloy
e1a6a76cda Modify the algorithm when traversing the DAGCombiner's worklist to be O(log N) for all operations. This fixes a horrible worst case with lots of nodes where 99% of the time was being spent in std::remove.
llvm-svn: 150669
2012-02-16 09:17:04 +00:00
Lang Hames
71b9f733eb Oop - r150653 + r150654 broke one of my test cases. Backing out for now...
llvm-svn: 150655
2012-02-16 02:32:10 +00:00
Lang Hames
e47462d4a0 MachineCSE shouldn't extend the live ranges of reserved or allocatable registers.
llvm-svn: 150653
2012-02-16 02:19:35 +00:00
Jakob Stoklund Olesen
4ee75dea4e Handle register masks in branch folding.
Don't attempt to move instructions with regmask operands. They are most
likely calls anyway.

llvm-svn: 150634
2012-02-15 23:42:54 +00:00
Andrew Trick
44624077a0 Fix library visibility problems with VLIWPacketizer.
The existing framework for postra scheduling is library local. We want to keep it that way. Soon we will have a more general MachineScheduler interface. At that time, various bits will be exposed to targets. In the meantime, the VLIWPacketizer wants to use ScheduleDAGInstrs directly, so it needs to wrapped in a PIMPL to avoid exposing it to the target interface.

llvm-svn: 150633
2012-02-15 23:34:15 +00:00
Lang Hames
0e954f92c1 Make LiveIntervals::handleMove() bundle aware.
llvm-svn: 150630
2012-02-15 23:21:33 +00:00
Bill Wendling
74a684d991 Use 'getDataNoRel' for the section kind.
llvm-svn: 150628
2012-02-15 22:47:53 +00:00
Lang Hames
5edc051415 Fix assertion condition.
llvm-svn: 150627
2012-02-15 22:45:51 +00:00
Bill Wendling
d483464dd5 Modify the code that emits the module flags to use the new module flags accessor
method. This allows the target lowering code to not have to deal with MDNodes.

Also, avoid leaking memory like a sieve by not creating a global variable for
the image info section, but just emitting the code directly.

llvm-svn: 150624
2012-02-15 22:36:15 +00:00
Andrew Trick
1ab2838fa0 Don't expose DefaultVLIWScheduler
llvm-svn: 150619
2012-02-15 22:06:21 +00:00
Lang Hames
641eeb6959 Remove overly conservative assert.
llvm-svn: 150608
2012-02-15 19:04:53 +00:00
Andrew Trick
cd59a57f96 Generic "VLIW" packetizer based on a DFA generated from target itinerary.
Patch by Sundeep!

llvm-svn: 150607
2012-02-15 18:55:14 +00:00
Andrew Trick
643575d4a9 Revert r150565 again. Appears to be a stage2 failure with dragonegg.
I'll put MachineLICM back before PEI. All my arm/x86 benchmarks look good, but buildbots don't like it.

llvm-svn: 150568
2012-02-15 07:57:03 +00:00
Andrew Trick
20f1b1b978 Reapply r150565 with the typo fix properly merged.
llvm-svn: 150567
2012-02-15 05:43:27 +00:00
Andrew Trick
76c2e51912 reverting r150565. Premature push.
llvm-svn: 150566
2012-02-15 05:22:12 +00:00
Andrew Trick
5a9c67ece8 Move PostRAMachineLICM into MachineLateOptimization. It now runs after PEI!
llvm-svn: 150565
2012-02-15 05:13:47 +00:00
Andrew Trick
57f0f255cf Allow CodeGen (llc) command line options to work as expected.
The llc command line options for enabling/disabling passes are local to CodeGen/Passes.cpp. This patch associates those options with standard pass IDs so they work regardless of how the target configures the passes.

A target has two ways of overriding standard passes:
1) Redefine the pass pipeline (override TargetPassConfig::add%Stage)
2) Replace or suppress individiual passes with TargetPassConfig::substitutePass.

In both cases, the command line options associated with the pass override the target default.

For example, say a target wants to disable machine instruction scheduling by default:

- The target calls disablePass(MachineSchedulerID) but otherwise does not override any TargetPassConfig methods.

- Without any llc options, no scheduler is run.

- With -enable-misched, the standard machine scheduler is run and honors the -misched=... flag to select the scheduler variant, which may be used for performance evaluation or testing.

Sorry overridePass is ugly. I haven't thought of a better way without replacing the cl::opt framework. I hope to do that one day...

I haven't figured out why CodeGen uses char& for pass IDs. AnalysisID is much easier to use and less bug prone. I'm using it wherever I can for internal implementation. Maybe later we can change the global pass ID definitions as well.

llvm-svn: 150563
2012-02-15 03:21:51 +00:00
Andrew Trick
3a4ed52447 Added TargetPassConfig::disablePass/substitutePass as a general mechanism to override specific passes.
llvm-svn: 150562
2012-02-15 03:21:47 +00:00
Lang Hames
5c8cc9c7f0 Don't emit live ranges for physregs live-ins that are dead.
llvm-svn: 150553
2012-02-15 01:31:10 +00:00
Lang Hames
5c5532d32d Disentangle moving a machine instr from updating LiveIntervals.
llvm-svn: 150552
2012-02-15 01:23:52 +00:00
Pete Cooper
bfec627c63 Added hook to let targets custom lower splitting of illegal vectors
llvm-svn: 150550
2012-02-15 00:55:31 +00:00
Jakob Stoklund Olesen
6dfa98e1c1 Fix global live range splitting regmask accuracy.
Pretend that regmask interference ends at the 'dead' slot, even when
there is other interference ending at the 'reg' slot of the same
instruction.

llvm-svn: 150531
2012-02-14 23:53:23 +00:00
Jakob Stoklund Olesen
c1054e87e4 Fix details in local live range splitting with regmasks.
Perform all comparisons at instruction granularity, and make sure
register masks on uses count in both gaps.

llvm-svn: 150530
2012-02-14 23:51:27 +00:00
Jakob Stoklund Olesen
b1738b3c04 Handle regmasks in findRegisterDefOperandIdx().
Only accept register masks when looking for an 'overlapping' def. When
Overlap is not set, the function searches for a proper definition of
Reg.

This means MI->modifiesRegister() considers register masks, but
MI->definesRegister() doesn't.

llvm-svn: 150529
2012-02-14 23:49:37 +00:00
Jakob Stoklund Olesen
248b6c4556 Use the proper clobber check in handleLiveInRegister().
When a physreg is live in to a basic block, look for any instruction in
the block that clobbers the physreg.

The instruction doesn't have to properly redefine the register, any
overlapping clobber is OK.

This slightly changes live ranges when compiling with register masks.

llvm-svn: 150528
2012-02-14 23:46:24 +00:00
Jakob Stoklund Olesen
bf8c36fea9 Dump live intervals in numerical order.
The old DenseMap hashed order was very confusing.

llvm-svn: 150527
2012-02-14 23:46:21 +00:00
Lang Hames
3a181593ec Don't create a new copy of reserved regs - we already have one handy.
llvm-svn: 150525
2012-02-14 23:06:12 +00:00
Bill Wendling
493a72b2fe Add code to the target lowering object file module to handle module flags.
The MachO back-end needs to emit the garbage collection flags specified in the
module flags. This is a WIP, so the front-end hasn't been modified to emit these
flags just yet. Documentation and front-end switching to occur soon.

llvm-svn: 150507
2012-02-14 21:28:13 +00:00
Lang Hames
e470bbc589 Update MachineVerifier to check the new physreg live-in rules.
llvm-svn: 150496
2012-02-14 19:17:48 +00:00
Lang Hames
11ccc79191 Tighten physical register invariants: Allocatable physical registers can
only be live in to a block if it is the function entry point or a landing pad.

llvm-svn: 150494
2012-02-14 18:51:53 +00:00
Nadav Rotem
5da800572a Fix PR12000. Some vector operations may use scalar operands with types
that are greater than the vector element type. For example BUILD_VECTOR
of type <1 x i1> with a constant i8 operand.
This patch fixes the assertion.

llvm-svn: 150477
2012-02-14 13:06:32 +00:00
Benjamin Kramer
3c5bcdba1a Turn push_back loops into append/insert.
llvm-svn: 150471
2012-02-14 10:29:27 +00:00
Lang Hames
70bdeac646 Rename getExceptionAddressRegister() to getExceptionPointerRegister() for consistency with setExceptionPointerRegister(...).
llvm-svn: 150460
2012-02-14 04:45:49 +00:00
Lang Hames
724a5e8fe1 Use convenience function for consistency.
llvm-svn: 150457
2012-02-14 03:04:29 +00:00
Bill Wendling
e0204d6871 Don't reserve the R0 and R1 registers here. We don't use these registers, and
marking them as "live-in" into a BB ruins some invariants that the back-end
tries to maintain.

llvm-svn: 150437
2012-02-13 23:47:16 +00:00
Bill Wendling
1c47b5cbf5 Don't recalculate the size of the vector each time through the loop.
llvm-svn: 150436
2012-02-13 23:45:26 +00:00
Jakob Stoklund Olesen
41b8a28aaa Add register mask support to ScheduleDAGRRList.
The scheduler will sometimes check the implicit-def list on instructions
to properly handle pre-colored DAG edges.

Also check any register mask operands for physreg clobbers.

llvm-svn: 150428
2012-02-13 23:25:24 +00:00
Andrew Trick
b94e7e93b2 LiveIntervalAnalysis does not depend on MachineLoopInfo.
llvm-svn: 150411
2012-02-13 20:44:42 +00:00
Jakob Stoklund Olesen
52b793ba37 Check regmask interference for -join-physregs.
llvm-svn: 150404
2012-02-13 18:17:04 +00:00
Nadav Rotem
2141a8413e Fix a bug in DAGCombine for the optimization of BUILD_VECTOR. We cant generate a shuffle node from two vectors of different types.
llvm-svn: 150383
2012-02-13 12:42:26 +00:00
Nadav Rotem
ea4aecb3e5 This patch addresses the problem of poor code generation for the zext
v8i8 -> v8i32 on AVX machines. The codegen often scalarizes ANY_EXTEND nodes.
The DAGCombiner has two optimizations that can mitigate the problem. First,
if all of the operands of a BUILD_VECTOR node are extracted from an ZEXT/ANYEXT
nodes, then it is possible to create a new simplified BUILD_VECTOR which uses
UNDEFS/ZERO values to eliminate the scalar ZEXT/ANYEXT nodes.
Second, another dag combine optimization lowers BUILD_VECTOR into a shuffle
vector instruction.

In the case of zext v8i8->v8i32 on AVX, a value in an XMM register is to be
shuffled into a wide YMM register.

This patch modifes the second optimization and allows the creation of
shuffle vectors even when the newly generated vector and the original vector
from which we extract the values are of different types.

llvm-svn: 150340
2012-02-12 15:05:31 +00:00
Anton Korobeynikov
5996573d4b Add support for implicit TLS model used with MS VC runtime.
Patch by Kai Nacke!

llvm-svn: 150307
2012-02-11 17:26:53 +00:00
Andrew Trick
f8d8f89c1c Add TargetPassConfig hooks for scheduling/bundling.
In case the MachineScheduling pass I'm working on doesn't work well
for another target, they can completely override it. This also adds a
hook immediately after the RegAlloc pass to cleanup immediately after
vregs go away. We may want to fold it into the postRA hook later.

llvm-svn: 150298
2012-02-11 07:11:32 +00:00
Jakob Stoklund Olesen
a5b1e7bf64 Allow Post-RA LICM to hoist reserved register reads.
When using register masks, registers like %rip are clobbered by the
register mask. LICM should still be able to hoist instructions reading
%rip from a loop containing calls.

llvm-svn: 150288
2012-02-11 00:44:19 +00:00
Jakob Stoklund Olesen
cea998ba92 Handle register masks in local live range splitting.
Again the goal is to produce identical assembly with register mask
operands enabled.

llvm-svn: 150287
2012-02-11 00:42:18 +00:00
Jakob Stoklund Olesen
cdb77e2491 Don't read PreRegAlloc before it is initialized.
llvm-svn: 150286
2012-02-11 00:40:36 +00:00
Jakob Stoklund Olesen
b58e9ef8b1 Add a static MachineOperand::clobbersPhysReg().
It can be necessary to detach a register mask pointer from its
MachineOperand. This method is convenient for checking clobbered
physregs on a detached bitmask pointer.

llvm-svn: 150261
2012-02-10 19:23:53 +00:00
Jakob Stoklund Olesen
4fe2a13535 Add register mask support to InterferenceCache.
This makes global live range splitting behave identically with and
without register mask operands.

This is not necessarily the best way of using register masks for live
range splitting.  It would be more efficient to first split global live
ranges around calls (i.e., register masks), and reserve the fine grained
per-physreg interference guidance for global live ranges that do not
cross calls.

For now the goal is to produce identical assembly when enabling register
masks.

llvm-svn: 150259
2012-02-10 18:58:34 +00:00
Jakob Stoklund Olesen
c67bcacba1 Remove unused variable.
llvm-svn: 150258
2012-02-10 18:52:15 +00:00
Benjamin Kramer
ba4dff0d18 Put instruction names into an indexed string table on the side, removing a pointer from MCInstrDesc.
Make them accessible through MCInstrInfo. They are only used for debugging purposes so this doesn't
have an impact on performance. X86MCTargetDesc.o goes from 630K to 461K on x86_64.

llvm-svn: 150245
2012-02-10 13:18:44 +00:00
Andrew Trick
1893eb6083 comment grammar
llvm-svn: 150233
2012-02-10 07:08:25 +00:00
Andrew Trick
c3cc8fa604 RegAlloc superpass: includes phi elimination, coalescing, and scheduling.
Creates a configurable regalloc pipeline.

Ensure specific llc options do what they say and nothing more: -reglloc=... has no effect other than selecting the allocator pass itself. This patch introduces a new umbrella flag, "-optimize-regalloc", to enable/disable the optimizing regalloc "superpass". This allows for example testing coalscing and scheduling under -O0 or vice-versa.

When a CodeGen pass requires the MachineFunction to have a particular property, we need to explicitly define that property so it can be directly queried rather than naming a specific Pass. For example, to check for SSA, use MRI->isSSA, not addRequired<PHIElimination>.

CodeGen transformation passes are never "required" as an analysis

ProcessImplicitDefs does not require LiveVariables.

We have a plan to massively simplify some of the early passes within the regalloc superpass.

llvm-svn: 150226
2012-02-10 04:10:36 +00:00
Andrew Trick
f408e5a7b9 whitespace
llvm-svn: 150225
2012-02-10 04:10:26 +00:00
Lang Hames
d211d8e431 Remove unused 'isAlias' parameter.
llvm-svn: 150224
2012-02-10 03:19:36 +00:00
Jakob Stoklund Olesen
e60cd3cc02 Constrain the regmask search space for local live ranges.
When checking a local live range for interference, restrict the binary
search to the single block.

llvm-svn: 150220
2012-02-10 01:31:31 +00:00
Jakob Stoklund Olesen
4fc4d8d8ab Cache basic block boundaries for faster RegMaskSlots access.
Provide API to get a list of register mask slots and bits in a basic
block.

llvm-svn: 150219
2012-02-10 01:26:29 +00:00
Jakob Stoklund Olesen
ac14d7774a Optimize LiveIntervals::intervalIsInOneMBB().
No looping and binary searches necessary.

Return a pointer to the containing block instead of just a bool.

llvm-svn: 150218
2012-02-10 01:23:55 +00:00
Benjamin Kramer
1c602707dd Cache iterators. Some of these are expensive to create.
llvm-svn: 150214
2012-02-10 00:28:31 +00:00
Jakob Stoklund Olesen
56d323e88d Add register mask support to RAGreedy.
This only adds the interference checks required for correctness.
We still need to take advantage of register masks for the
interference driven live range splitting.

llvm-svn: 150191
2012-02-09 18:25:05 +00:00
Lang Hames
102098e4af Preserve physreg kills in MachineBasicBlock::SplitCriticalEdge.
Failure to preserve kills was causing LiveIntervals to miss some EFLAGS live
ranges. Unfortunately I've been unable to reduce a good test case yet.

llvm-svn: 150152
2012-02-09 05:59:36 +00:00
Lang Hames
4defdead69 Fix kill flags when moving instructions using LiveIntervals::moveInstr(...).
llvm-svn: 150150
2012-02-09 04:45:38 +00:00
Lang Hames
4147d04e10 Remove assertion. Not all use operands are reads.
llvm-svn: 150149
2012-02-09 04:39:48 +00:00
Andrew Trick
74c2f12214 Improve TargetPassConfig. No intended functionality.
Split CodeGen into stages.
Distinguish between optimization and correctness.

llvm-svn: 150122
2012-02-09 00:40:55 +00:00