Commit Graph

13566 Commits

Author SHA1 Message Date
Andrew Trick 79d3eecbb4 misched: Trace regpressure.
llvm-svn: 157429
2012-05-24 22:11:14 +00:00
Andrew Trick a8ad5f7c7b misched: Give each ReadyQ a unique ID
llvm-svn: 157428
2012-05-24 22:11:12 +00:00
Andrew Trick 61f1a278b8 misched: Added ScoreboardHazardRecognizer.
The Hazard checker implements in-order contraints, or interlocked
resources. Ready instructions with hazards do not enter the available
queue and are not visible to other heuristics.

The major code change is the addition of SchedBoundary to encapsulate
the state at the top or bottom of the schedule, including both a
pending and available queue.

The scheduler now counts cycles in sync with the hazard checker. These
are minimum cycle counts based on known hazards.

Targets with no itinerary (x86_64) currently remain at cycle 0. To fix
this, we need to provide some maximum issue width for all targets. We
also need to add the concept of expected latency vs. minimum latency.

llvm-svn: 157427
2012-05-24 22:11:09 +00:00
Andrew Trick ca47335461 misched: Release bottom roots in reverse order.
llvm-svn: 157426
2012-05-24 22:11:05 +00:00
Andrew Trick dd375dd34a misched: rename ReadyQ class
llvm-svn: 157425
2012-05-24 22:11:03 +00:00
Andrew Trick f378617773 misched: copy comments so compareRPDelta is readable by itself.
llvm-svn: 157424
2012-05-24 22:11:01 +00:00
Andrew Trick d5326aea81 regpressure: Added RegisterPressure::dump
llvm-svn: 157423
2012-05-24 22:10:59 +00:00
Andrew Trick b2c172e20a regpressure: physreg livein/out fix
llvm-svn: 157422
2012-05-24 22:10:57 +00:00
Craig Topper 9520719b9b Mark some static arrays as const.
llvm-svn: 157377
2012-05-24 06:35:32 +00:00
Jakob Stoklund Olesen 0ce90494e6 Add a last resort tryInstructionSplit() to RAGreedy.
Live ranges with a constrained register class may benefit from splitting
around individual uses. It allows the remaining live range to use a
larger register class where it may allocate. This is like spilling to a
different register class.

This is only attempted on constrained register classes.

<rdar://problem/11438902>

llvm-svn: 157354
2012-05-23 22:37:27 +00:00
Bill Wendling e351e8c52d Forgot to reverse conditional.
llvm-svn: 157349
2012-05-23 22:12:50 +00:00
Bill Wendling 041793c452 Reduce indentation by early detection of 'continue'. No functionality change.
llvm-svn: 157348
2012-05-23 22:09:50 +00:00
Jakob Stoklund Olesen 5b8f476037 Correctly deal with identity copies in RegisterCoalescer.
Now that the coalescer keeps live intervals and machine code in sync at
all times, it needs to deal with identity copies differently.

When merging two virtual registers, all identity copies are removed
right away. This means that other identity copies must come from
somewhere else, and they are going to have a value number.

Deal with such copies by merging the value numbers before erasing the
copy instruction. Otherwise, we leave dangling value numbers in the live
interval.

This fixes PR12927.

llvm-svn: 157340
2012-05-23 20:21:06 +00:00
Patrik Hägglund 94537c2a06 Small fix for the debug output from PBQP (PR12822).
llvm-svn: 157319
2012-05-23 12:12:58 +00:00
Eric Christopher c49643586b Add support for C++11 enum classes in llvm.
Part of rdar://11496790

llvm-svn: 157303
2012-05-23 00:09:20 +00:00
Eric Christopher d42b92f5c3 Untabify and 80-col.
llvm-svn: 157274
2012-05-22 18:45:24 +00:00
Eric Christopher 775cbd2b47 Formatting consistency.
llvm-svn: 157273
2012-05-22 18:45:18 +00:00
Jakob Stoklund Olesen 924279ca0e Only erase virtregs with no uses left.
Also make sure registers aren't erased twice if the dead def mentions
the register twice.

This fixes PR12911.

llvm-svn: 157254
2012-05-22 14:52:12 +00:00
Owen Anderson f2118ea826 Fix use of an unitialized value in the LegalizeOps expansion for ISD::SUB. No in-tree targets exercise this path.
Patch by Micah Villmow.

llvm-svn: 157215
2012-05-21 22:39:20 +00:00
Chad Rosier 5d1f5d2be3 Typo.
llvm-svn: 157195
2012-05-21 17:13:41 +00:00
Jakob Stoklund Olesen 29268b50f2 Give a small negative bias to giant edge bundles.
This helps compile time when the greedy register allocator splits live
ranges in giant functions. Without the bias, we would try to grow
regions through the giant edge bundles, usually to find out that the
region became too big and expensive.

If a live range has many uses in blocks near the giant bundle, the small
negative bias doesn't make a big difference, and we still consider
regions including the giant edge bundle.

Giant edge bundles are usually connected to landing pads or indirect
branches.

llvm-svn: 157174
2012-05-21 03:11:23 +00:00
Jakob Stoklund Olesen a7c3d2f902 Clear kill flags on the fly when joining intervals.
With physreg joining out of the way, it is easy to recognize the
instructions that need their kill flags cleared while testing for
interference.

This allows us to skip the final scan of all instructions for an 11%
speedup of the coalescer pass.

llvm-svn: 157169
2012-05-20 21:41:05 +00:00
Jakob Stoklund Olesen 2f06a6579c Constrain regclasses in PeepholeOptimizer.
It can be necessary to restrict to a sub-class before accessing
sub-registers.

llvm-svn: 157164
2012-05-20 18:42:55 +00:00
Jakob Stoklund Olesen 00f07dec0c Constrain register classes in TailDup.
When rewriting operands, make sure the new registers have a compatible
register class.

llvm-svn: 157163
2012-05-20 18:42:51 +00:00
Peter Collingbourne 8eb05fd093 When legalising shifts, do not pre-build a list of operands which
may be RAUW'd by the recursive call to LegalizeOps; instead, retrieve
the other operands when calling UpdateNodeOperands.  Fixes PR12889.

llvm-svn: 157162
2012-05-20 18:36:15 +00:00
Benjamin Kramer 76004e69a6 Plug a leak when using MCJIT.
Found by valgrind.

llvm-svn: 157160
2012-05-20 17:24:08 +00:00
Benjamin Kramer a7c2c41c3c Use TargetMachine's register info instead of creating a new one and leaking it.
llvm-svn: 157155
2012-05-20 11:24:27 +00:00
Jakob Stoklund Olesen 1f1c6add10 Properly constrain register classes for sub-registers.
Not all GR64 registers have sub_8bit sub-registers.

llvm-svn: 157150
2012-05-20 06:38:37 +00:00
Jakob Stoklund Olesen a103a516c6 Properly constrain register classes in 2-addr.
X86 has 2-addr instructions with different constraints on the tied def
and use operands. One is GR32, one is GR32_NOSP.

llvm-svn: 157149
2012-05-20 06:38:32 +00:00
Jakob Stoklund Olesen b8f950650b Missed a push_back in r157147.
llvm-svn: 157148
2012-05-20 05:28:53 +00:00
Jakob Stoklund Olesen d0a38a8daa Avoid deleting extra copies when RegistersDefinedFromSameValue is true.
This function adds copies to be erased to DupCopies, avoid also adding
them to DeadCopies.

llvm-svn: 157147
2012-05-20 04:52:48 +00:00
Jakob Stoklund Olesen 64d82b74dd Fix build bots.
Avoid looking at the operands of a potentially erased instruction.

llvm-svn: 157146
2012-05-20 03:57:12 +00:00
Jakob Stoklund Olesen 02d83e3b8b LiveRangeQuery simplifies shrinkToUses().
llvm-svn: 157145
2012-05-20 02:54:52 +00:00
Jakob Stoklund Olesen abc8c3d3ce Use LiveRangeQuery in ScheduleDAGInstrs.
llvm-svn: 157144
2012-05-20 02:44:38 +00:00
Jakob Stoklund Olesen 58165b92e6 Eliminate some uses of struct LiveRange.
That struct ought to be a LiveInterval implementation detail.

llvm-svn: 157143
2012-05-20 02:44:36 +00:00
Jakob Stoklund Olesen 2aeead4bf6 Use LiveRangeQuery instead of getLiveRangeContaining().
llvm-svn: 157142
2012-05-20 02:44:33 +00:00
Jakob Stoklund Olesen 4e1e43a355 Simplify overlap check.
llvm-svn: 157137
2012-05-19 23:59:27 +00:00
Jakob Stoklund Olesen a34a69ce0c Fix 12892.
Dead code elimination during coalescing could cause a virtual register
to be split into connected components. The following rewriting would be
confused about the already joined copies present in the code, but
without a corresponding value number in the live range.

Erase all joined copies instantly when joining intervals such that the
MI and LiveInterval representations are always in sync.

llvm-svn: 157135
2012-05-19 23:34:59 +00:00
Jakob Stoklund Olesen e59d0c3252 Remove the late DCE in RegisterCoalescer.
Dead code and joined copies are now eliminated on the fly, and there is
no need for a post pass.

This makes the coalescer work like other modern register allocator
passes: Code is changed on the fly, there is no pending list of changes
to be committed.

llvm-svn: 157132
2012-05-19 21:02:31 +00:00
Jakob Stoklund Olesen 25ced18407 Erase joined copies immediately.
The late dead code elimination is no longer necessary.

The test changes are cause by a register hint that can be either %rdi or
%rax. The choice depends on the use list order, which this patch changes.

llvm-svn: 157131
2012-05-19 20:54:07 +00:00
Jakob Stoklund Olesen 1b707c8817 Fix an ancient bug in removeCopyByCommutingDef().
Before rewriting uses of one value in A to register B, check that there
are no tied uses. That would require multiple A values to be rewritten.

This bug can't bite in the current version of the code for a fairly
subtle reason: A tied use would have caused 2-addr to insert a copy
before the use. If the copy has been coalesced, it will be found by the
same loop changed by this patch, and the optimization is aborted.

This was exposed by 400.perlbench and lua after applying a patch that
deletes joined copies aggressively.

llvm-svn: 157130
2012-05-19 20:54:03 +00:00
Jakob Stoklund Olesen d05148ba89 Collect inflatable virtual registers on the fly.
There is no reason to defer the collection of virtual registers whose
register class may be replaced with a larger class.

llvm-svn: 157125
2012-05-19 19:25:00 +00:00
Jakob Stoklund Olesen 900f58441d Eliminate dead code after remat.
This will remove the original def once it has no more uses.

llvm-svn: 157104
2012-05-19 05:25:59 +00:00
Jakob Stoklund Olesen dcffc626c0 Don't remat during updateRegDefsUses().
Remaining virtreg->physreg copies were rematerialized during
updateRegDefsUses(), but we already do the same thing in joinCopy() when
visiting the physreg copy instruction.

Eliminate the preserveSrcInt argument to reMaterializeTrivialDef(). It
is now always true.

llvm-svn: 157103
2012-05-19 05:25:56 +00:00
Jakob Stoklund Olesen 06dc721203 Immediately erase trivially useless copies.
There is no need for these instructions to stick around since they are
known to be not dead.

llvm-svn: 157102
2012-05-19 05:25:53 +00:00
Jakob Stoklund Olesen 82d77e8145 Run proper recursive dead code elimination during coalescing.
Dead copies cause problems because they are trivial to coalesce, but
removing them gived the live range a dangling end point. This patch
enables full dead code elimination which trims live ranges to their uses
so end points don't dangle.

DCE may erase multiple instructions. Put the pointers in an ErasedInstrs
set so we never risk visiting erased instructions in the work list.

There isn't supposed to be any dead copies entering RegisterCoalescer,
but they do slip by as evidenced by test/CodeGen/X86/coalescer-dce.ll.

llvm-svn: 157101
2012-05-19 05:25:50 +00:00
Jakob Stoklund Olesen e5bbe37950 Allow LiveRangeEdit to be created with a NULL parent.
The dead code elimination with callbacks is still useful.

llvm-svn: 157100
2012-05-19 05:25:46 +00:00
Jakob Stoklund Olesen 3834dae65d Modernize naming convention for class members.
No functional change.

llvm-svn: 157079
2012-05-18 22:10:15 +00:00
Jakob Stoklund Olesen b686a2cebd Move all work list processing to copyCoalesceWorkList().
This will make it possible to filter out erased instructions later.

llvm-svn: 157073
2012-05-18 21:09:40 +00:00
Jim Grosbach 4b63d2ae1d Refactor data-in-code annotations.
Use a dedicated MachO load command to annotate data-in-code regions.
This is the same format the linker produces for final executable images,
allowing consistency of representation and use of introspection tools
for both object and executable files.

Data-in-code regions are annotated via ".data_region"/".end_data_region"
directive pairs, with an optional region type.

data_region_directive := ".data_region" { region_type }
region_type := "jt8" | "jt16" | "jt32" | "jta32"
end_data_region_directive := ".end_data_region"

The previous handling of ARM-style "$d.*" labels was broken and has
been removed. Specifically, it didn't handle ARM vs. Thumb mode when
marking the end of the section.

rdar://11459456

llvm-svn: 157062
2012-05-18 19:12:01 +00:00