Commit Graph

12459 Commits

Author SHA1 Message Date
Benjamin Kramer
76f58d2031 Namespacify.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139892 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-16 00:35:06 +00:00
Jakob Stoklund Olesen
ebac0c1747 Spill mode: Hoist back-copies locally.
The leaveIntvAfter() function normally inserts a back-copy after the
requested instruction, making the back-copy kill the live range.

In spill mode, try to insert the back-copy before the last use instead.
That means the last use becomes the kill instead of the back-copy.  This
lowers the register pressure because the last use can now redefine the
same register it was reading.

This will also improve compile time: The back-copy isn't a kill, so
hoisting it in hoistCopiesForSize() won't force a recomputation of the
source live range.  Similarly, if the back-copy isn't hoisted by the
splitter, the spiller will not attempt hoisting it locally.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139883 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-16 00:03:35 +00:00
Jakob Stoklund Olesen
69cf1cac3f Disable local spill hoisting for non-killing copies.
If the source register is live after the copy being spilled, there is no
point to hoisting it.  Hoisting inside a basic block only serves to
resolve interferences by shortening the live range of the source.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139882 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-16 00:03:33 +00:00
Eli Friedman
331120b1a4 Some legalization fixes for atomic load and store.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139851 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-15 21:20:49 +00:00
Jakob Stoklund Olesen
b9edad0163 Add an option to disable spill hoisting.
When -split-spill-mode is enabled, spill hoisting is performed by
SplitKit instead of by InlineSpiller.  This hidden command line option
is for testing the splitter spill mode.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139845 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-15 21:06:00 +00:00
Jakob Stoklund Olesen
01afdb3a45 VirtRegMap is counting spill slots, not register spills.
Fix the stats counters to reflect that.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139819 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-15 18:31:13 +00:00
Jakob Stoklund Olesen
d205f7a940 Count correctly when a COPY turns into a spill or reload.
The number of spills could go negative since a folded COPY is just a
spill, and it may be eliminated.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139815 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-15 18:22:52 +00:00
Jakob Stoklund Olesen
79c40a011b Count inserted spills and reloads more accurately.
Adjust counters when removing spill and reload instructions.

We still don't account for reloads being removed by eliminateDeadDefs().

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139806 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-15 17:54:28 +00:00
Jakob Stoklund Olesen
6b6e32d954 Trace through sibling PHIs in bulk.
When traceSiblingValue() encounters a PHI-def value created by live
range splitting, don't look at all the predecessor blocks.  That can be
very expensive in a complicated CFG.

Instead, consider that all the non-PHI defs jointly dominate all the
PHI-defs.  Tracing directly to all the non-PHI defs is much faster that
zipping around in the CFG when there are many PHIs with many
predecessors.

This significantly improves compile time for indirectbr interpreters.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139797 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-15 16:41:12 +00:00
Jakob Stoklund Olesen
031432f9ad Speed up LiveIntervals::shrinkToUse with some caching.
Blocks with multiple PHI successors only need to go on the worklist
once.  Use a SmallPtrSet to track the live-out blocks that have already
been handled.  This is a lot faster than the two live range check we
would otherwise do.

Also stop recomputing hasPHIKill flags.  Like RenumberValues(), it is
conservatively correct to leave them in, and they are not used for
anything important.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139792 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-15 15:24:16 +00:00
Jakob Stoklund Olesen
9b82d50d20 Revert r139782, "RemoveCopyByCommutingDef doesn't need hasPHIKill()."
It does, after all.

RemoveCopyByCommutingDef rewrites the uses of one particular value
number in A. It doesn't know how to rewrite phi uses, so there can't be
any.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139787 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-15 06:27:32 +00:00
Jakob Stoklund Olesen
df8412c4c1 Stop verifying hasPHIKill() flags.
There is only one legitimate use remaining, in addIntervalsForSpills().
All other calls to hasPHIKill() are only used to update PHIKill flags.

The addIntervalsForSpills() function is part of the old spilling
framework, only used by linearscan.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139783 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-15 05:16:30 +00:00
Jakob Stoklund Olesen
de07abe35d RemoveCopyByCommutingDef doesn't need hasPHIKill().
Instead, let HasOtherReachingDefs() test for defs in B that overlap any
phi-defs in A as well.  This test is slightly different, but almost
identical.

A perfectly precise test would only check those phi-defs in A that are
reachable from AValNo.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139782 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-15 05:03:50 +00:00
Jakob Stoklund Olesen
4ea24e993f It is safe to remat a value killed by phis.
The source live range is recomputed using shrinkToUses() which does
handle phis correctly.  The hasPHIKill() condition was relevant in the
old days when ReMaterializeTrivialDef() tried to recompute the live
range itself.

The shrinkToUses() function will mark the original def as dead when no
more uses and phi kills remain.  It is then removed by
runOnMachineFunction().

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139781 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-15 04:52:06 +00:00
Jakob Stoklund Olesen
573a32d487 Leave hasPHIKill flags alone in LiveInterval::RenumberValues.
It is conservatively correct to keep the hasPHIKill flags, even after
deleting PHI-defs.

The calculation can be very expensive after taildup has created a
quadratic number of indirectbr edges in the CFG, and the hasPHIKill flag
isn't used for anything after RenumberValues().

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139780 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-15 04:37:18 +00:00
Andrew Trick
b1afbac64b [regcoalescing] bug fix for RegistersDefinedFromSameValue.
An improper SlotIndex->VNInfo lookup was leading to unsafe copy removal.
Fixes PR10920 401.bzip2 miscompile with no IV rewrite.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139765 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-15 01:09:33 +00:00
Devang Patel
734a67cda5 Add support to emit debug info for C++0x nullptr type.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139751 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-14 23:13:28 +00:00
Jakob Stoklund Olesen
0d4fea7866 Ignore the cloning of unknown registers.
THe LRE_DidCloneVirtReg callback may be called with vitual registers
that RAGreedy doesn't even know about yet.  In that case, there are no
data structures to update.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139702 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-14 17:34:37 +00:00
Jakob Stoklund Olesen
c4c633852f Hoist back-copies to the least busy dominator.
When a back-copy is hoisted to the nearest common dominator, keep
looking up the dominator tree for a less loopy dominator, and place the
back-copy there instead.

Don't do this when a single existing back-copy dominates all the others.
Assume the client knows what he is doing, and keep the dominating
back-copy.

This prevents us from hoisting back-copies into loops in most cases.  If
a value is defined in a loop with multiple exits, we may still hoist
back-copies into that loop.  That is the speed/size tradeoff.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139698 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-14 16:45:39 +00:00
Nadav Rotem
436fe8498a Add integer promotion support for vselect
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139692 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-14 14:42:15 +00:00
Jakob Stoklund Olesen
393bfcb263 Distinguish complex mapped values from forced recomputation.
When a ParentVNI maps to multiple defs in a new interval, its live range
may still be derived directly from RegAssign by transferValues().

On the other hand, when instructions have been rematerialized or
hoisted, it may be necessary to completely recompute live ranges using
LiveRangeCalc::extend() to all uses.

Use a bit in the value map to indicate that a live range must be
recomputed.  Rename markComplexMapped() to forceRecompute().

This fixes some live range verification errors when
-split-spill-mode=size hoists back-copies by recomputing source ranges
when RegAssign kills can't be moved.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139660 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-13 23:09:04 +00:00
Jakob Stoklund Olesen
b21abfed81 Implement -split-spill-mode=size.
Whenever the complement interval is defined by multiple copies of the
same value, hoist those back-copies to the nearest common dominator.

This ensures that at most one copy is inserted per value in the
complement inteval, and no phi-defs are needed.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139651 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-13 22:22:39 +00:00
Eli Friedman
596f447467 Fix check for unaligned load/store so it doesn't catch over-aligned load/store.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139649 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-13 22:19:59 +00:00
Eli Friedman
fe731214d2 Error out on CodeGen of unaligned load/store. Fix test so it isn't accidentally testing that case.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139641 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-13 20:50:54 +00:00
Nadav Rotem
8f28aaf72c Fix the assertion which checks the size of the input operand.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139633 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-13 20:03:38 +00:00
Nadav Rotem
aec5861bb6 Add vselect target support for targets that do not support blend but do support
xor/and/or (For example SSE2).



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139623 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-13 19:17:42 +00:00
Devang Patel
3a2d80df88 Use a cache to maintain list of machine basic blocks for a given UserValue.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139616 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-13 18:40:53 +00:00
Jakob Stoklund Olesen
e5a2e36632 Add SplitEditor::markOverlappedComplement().
This function is used to flag values where the complement interval may
overlap other intervals.  Call it from overlapIntv, and use the flag to
fully recompute those live ranges in transferValues().

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139612 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-13 18:05:29 +00:00
Jakob Stoklund Olesen
abcc73e8ba Eliminate the extendRange() wrapper.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139608 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-13 17:38:57 +00:00
Jakob Stoklund Olesen
ee5655dca4 Switch extendInBlock() to take a kill slot instead of the last use slot.
Three out of four clients prefer this interface which is consistent with
extendIntervalEndTo() and LiveRangeCalc::extend().

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139604 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-13 16:47:56 +00:00
Jakob Stoklund Olesen
c1c622ef0d Use a separate LiveRangeCalc for the complement in spill modes.
The complement interval may overlap the other intervals created, so use
a separate LiveRangeCalc instance to compute its live range.

A LiveRangeCalc instance can only be shared among non-overlapping
intervals.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139603 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-13 16:47:53 +00:00
NAKAMURA Takumi
edd4f8ba4b Unbreak msvc.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139581 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-13 03:58:34 +00:00
Jakob Stoklund Olesen
b5a457c4cb Extract live range calculations from SplitKit.
SplitKit will soon need two copies of these data structures, and the
algorithms will also be useful when LiveIntervalAnalysis becomes
independent of LiveVariables.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139572 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-13 01:34:21 +00:00
Bill Wendling
3669915c6d Introduce a bit of a hack.
Splitting a landing pad takes considerable care because of PHIs and other
nasties. The problem is that the jump table needs to jump to the landing pad
block. However, the landing pad block can be jumped to only by an invoke
instruction. So we clone the landingpad instruction into its own basic block,
have the invoke jump to there. The landingpad instruction's basic block's
successor is now the target for the jump table.

But because of PHI nodes, we need to create another basic block for the jump
table to jump to. This is definitely a hack, because the values for the PHI
nodes may not be defined on the edge from the jump table. But that's okay,
because the jump table is simply a construct to mimic what is happening in the
CFG. So the values are mysteriously there, even though there is no value for the
PHI from the jump table's edge (hence calling this a hack).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139545 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-12 21:56:59 +00:00
Jakob Stoklund Olesen
a16a25ddea Remove the -compact-regions flag.
It has been enabled by default for a while, it was only there to allow
performance comparisons.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139501 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-12 16:54:42 +00:00
Jakob Stoklund Olesen
708d06f7fb Add an interface for SplitKit complement spill modes.
SplitKit always computes a complement live range to cover the places
where the original live range was live, but no explicit region has been
allocated.

Currently, the complement live range is created to be as small as
possible - it never overlaps any of the regions.  This minimizes
register pressure, but if the complement is going to be spilled anyway,
that is not very important.  The spiller will eliminate redundant
spills, and hoist others by making the spill slot live range overlap
some of the regions created by splitting.  Stack slots are cheap.

This patch adds the interface to enable spill modes in SplitKit.  In
spill mode, SplitKit will assume that the complement is going to spill,
so it will allow it to overlap regions in order to avoid back-copies.
By doing some of the spiller's work early, the complement live range
becomes simpler.  In some cases, it can become much simpler because no
extra PHI-defs are required.  This will speed up both splitting and
spilling.

This is only the interface to enable spill modes, no implementation yet.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139500 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-12 16:49:21 +00:00
Jakob Stoklund Olesen
3d4ec14ffc Update comments to reflect some (not so) recent changes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139498 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-12 16:03:26 +00:00
Richard Trieu
2e3734e2d9 Fix asserts in CodeGen from:
assert("error");

to:

  assert(0 && "error");



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139449 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-10 01:07:54 +00:00
Chris Lattner
c3ab388ba9 tidy up a bit
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139419 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-09 22:06:59 +00:00
Eli Friedman
9db817fd0c Make the SelectionDAG verify that all the operands of BUILD_VECTOR have the same type. Teach DAGCombiner::visitINSERT_VECTOR_ELT not to make invalid BUILD_VECTORs. Fixes PR10897.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139407 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-09 21:04:06 +00:00
Jakob Stoklund Olesen
1ab7c8ea03 Reapply r139247: Cache intermediate results during traceSiblingValue.
In some cases such as interpreters using indirectbr, the CFG can be very
complicated, and live range splitting may be forced to insert a large
number of phi-defs.  When that happens, traceSiblingValue can spend a
lot of time zipping around in the CFG looking for defs and reloads.

This patch causes more information to be cached in SibValues, and the
cached values are used to terminate searches early.  This speeds up
spilling by 20x in one interpreter test case.  For more typical code,
this is just a 10% speedup of spilling.

The previous version had bugs that caused miscompilations. They have
been fixed.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139378 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-09 18:11:41 +00:00
Devang Patel
9aee335c23 Directly point debug info to the stack slot of the arugment, instead of trying to keep track of vreg in which it the arugment is copied. The LiveDebugVariable can keep track of variable's ranges.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139330 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-08 22:59:09 +00:00
Jakob Stoklund Olesen
0472e040cb Revert r139247 "Cache intermediate results during traceSiblingValue."
It broke the self host and clang-x86_64-darwin10-RA.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139259 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-07 21:43:52 +00:00
Jakob Stoklund Olesen
2c207a0f67 Cache intermediate results during traceSiblingValue.
In some cases such as interpreters using indirectbr, the CFG can be very
complicated, and live range splitting may be forced to insert a large
number of phi-defs.  When that happens, traceSiblingValue can spend a
lot of time zipping around in the CFG looking for defs and reloads.

This patch causes more information to be cached in SibValues, and the
cached values are used to terminate searches early.  This speeds up
spilling by 20x in one interpreter test case.  For more typical code,
this is just a 10% speedup of spilling.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139247 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-07 19:07:31 +00:00
James Molloy
b950585cc5 Refactor instprinter and mcdisassembler to take a SubtargetInfo. Add -mattr= handling to llvm-mc. Reviewed by Owen Anderson.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139237 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-07 17:24:38 +00:00
Eli Friedman
981a010c09 Relax the MemOperands on atomics a bit. Fixes -verify-machineinstrs failures for atomic laod/store on ARM.
(The fix for the related failures on x86 is going to be nastier because we actually need Acquire memoperands attached to the atomic load instrs, etc.)



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139221 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-07 02:23:42 +00:00
Devang Patel
541a81cc2b While sinking machine instructions, sink matching DBG_VALUEs also otherwise live debug variable pass will drop DBG_VALUEs on the floor.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139208 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-07 00:07:58 +00:00
Duncan Sands
28b77e968d Add codegen support for vector select (in the IR this means a select
with a vector condition); such selects become VSELECT codegen nodes.
This patch also removes VSETCC codegen nodes, unifying them with SETCC
nodes (codegen was actually often using SETCC for vector SETCC already).
This ensures that various DAG combiner optimizations kick in for vector
comparisons.  Passes dragonegg bootstrap with no testsuite regressions
(nightly testsuite as well as "make check-all").  Patch mostly by
Nadav Rotem.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139159 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-06 19:07:46 +00:00
Duncan Sands
4a544a79bd Split the init.trampoline intrinsic, which currently combines GCC's
init.trampoline and adjust.trampoline intrinsics, into two intrinsics
like in GCC.  While having one combined intrinsic is tempting, it is
not natural because typically the trampoline initialization needs to
be done in one function, and the result of adjust trampoline is needed
in a different (nested) function.  To get around this llvm-gcc hacks the
nested function lowering code to insert an additional parent variable
holding the adjust.trampoline result that can be accessed from the child
function.  Dragonegg doesn't have the luxury of tweaking GCC code, so it
stored the result of adjust.trampoline in the memory GCC set aside for
the trampoline itself (this is always available in the child function),
and set up some new memory (using an alloca) to hold the trampoline.
Unfortunately this breaks Go which allocates trampoline memory on the
heap and wants to use it even after the parent has exited (!).  Rather
than doing even more hacks to get Go working, it seemed best to just use
two intrinsics like in GCC.  Patch mostly by Sanjoy Das.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139140 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-06 13:37:06 +00:00
Owen Anderson
7ab15f6d4b Fix a truly heinous bug in DAGCombine related to AssertZext.
If we have a chain of zext -> assert_zext -> zext -> use, the first zext would get simplified away because of the later zext, and then the later zext would get simplified away because of the assert.  The solution is to teach SimplifyDemandedBits that assert_zext demands all of the high bits of its input, rather than only those demanded by its users.  No testcase because the only example I have manifests as llvm-gcc miscompiling LLVM, and I haven't found a smaller case that reproduces this problem.
Fixes <rdar://problem/10063365>.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139059 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-03 00:26:49 +00:00