Commit Graph

6935 Commits

Author SHA1 Message Date
Dan Gohman
95bdbfa066 When rewriting the loop exit test with the canonical induction variable,
leave the original comparison in place if it has other uses, since the
other uses won't be dominated by the new comparison instruction.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72369 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-24 19:11:38 +00:00
Dan Gohman
453aa4fbf1 Generalize SCEVExpander::visitAddRecExpr's GEP persuit, and avoid
sending SCEVUnknowns to expandAddToGEP. This avoids the need for
expandAddToGEP to bend the rules and peek into SCEVUnknown
expressions.

Factor out the code for testing whether a SCEV can be factored by
a constant for use in a GEP index. This allows it to handle
SCEVAddRecExprs, by recursing.

As a result, SCEVExpander can now put more things in GEP indices,
so it emits fewer explicit mul instructions.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72366 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-24 18:06:31 +00:00
Torok Edwin
b679de2a21 The rewriter may hold references to instructions that are deleted because they are trivially dead.
Fix by clearing the rewriter cache before deleting the trivially dead
instructions.
Also make InsertedExpressions use an AssertingVH to catch these
bugs easier.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72364 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-24 14:23:16 +00:00
Torok Edwin
6bb4958543 Fix PR4254.
The DAGCombiner created a negative shiftamount, stored in an
unsigned variable. Later the optimizer eliminated the shift entirely as being
undefined.
Example: (srl (shl X, 56) 48). ShiftAmt is 4294967288.
Fix it by checking that the shiftamount is positive, and storing in a signed
variable.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72331 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-23 17:29:48 +00:00
Torok Edwin
f5ff1d335b available_externall linkage is not local, this was confusing the codegenerator,
and it wasn't generating calls through @PLT for these functions.
hasLocalLinkage() is now false for available_externally,
I attempted to fix the inliner and dce to handle available_externally properly.
It passed make check.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72328 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-23 14:06:57 +00:00
Eli Friedman
d14ce2f1fc Fix test to account for legalization changes; I think this ends up
running an extra DAGCombine pass which improves the code a bit.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72326 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-23 13:15:11 +00:00
Evan Cheng
2ddb6f1440 Fix bug in FoldFCmp_IntToFP_Cst. If inttofp is a uintofp, use unsigned instead of signed integer constant.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72300 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-22 23:10:53 +00:00
Duncan Sands
b0f1e1780c Add a new codegen pass that normalizes dwarf exception handling
code in preparation for code generation.  The main thing it does
is handle the case when eh.exception calls (and, in a future
patch, eh.selector calls) are far away from landing pads.  Right
now in practice you only find eh.exception calls close to landing
pads: either in a landing pad (the common case) or in a landing
pad successor, due to loop passes shifting them about.  However
future exception handling improvements will result in calls far
from landing pads:
(1) Inlining of rewinds.  Consider the following case:
In function @f:
...
  invoke @g to label %normal unwind label %unwinds
...
unwinds:
  %ex = call i8* @llvm.eh.exception()
...

In function @g:
...
  invoke @something to label %continue unwind label %handler
...
handler:
  %ex = call i8* @llvm.eh.exception()
... perform cleanups ...
  "rethrow exception"

Now inline @g into @f.  Currently this is turned into:
In function @f:
...
  invoke @something to label %continue unwind label %handler
...
handler:
  %ex = call i8* @llvm.eh.exception()
... perform cleanups ...
  invoke "rethrow exception" to label %normal unwind label %unwinds
unwinds:
  %ex = call i8* @llvm.eh.exception()
...

However we would like to simplify invoke of "rethrow exception" into
a branch to the %unwinds label.  Then %unwinds is no longer a landing
pad, and the eh.exception call there is then far away from any landing
pads.

(2) Using the unwind instruction for cleanups.
It would be nice to have codegen handle the following case:
  invoke @something to label %continue unwind label %run_cleanups
...
handler:
... perform cleanups ...
  unwind

This requires turning "unwind" into a library call, which
necessarily takes a pointer to the exception as an argument
(this patch also does this unwind lowering).  But that means
you are using eh.exception again far from a landing pad.

(3) Bugpoint simplifications.  When bugpoint is simplifying
exception handling code it often generates eh.exception calls
far from a landing pad, which then causes codegen to assert.
Bugpoint then latches on to this assertion and loses sight
of the original problem.

Note that it is currently rare for this pass to actually do
anything.  And in fact it normally shouldn't do anything at
all given the code coming out of llvm-gcc!  But it does fire
a few times in the testsuite.  As far as I can see this is
almost always due to the LoopStrengthReduce codegen pass
introducing pointless loop preheader blocks which are landing
pads and only contain a branch to another block.  This other
block contains an eh.exception call.  So probably by tweaking
LoopStrengthReduce a bit this can be avoided.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72276 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-22 20:36:31 +00:00
Dan Gohman
d6d0294e35 Teach IndVarSimplify's FixUsesBeforeDefs to handle InvokeInsts by
assuming that the use of the value is in a block dominated by the
"normal" destination. LangRef.html and other documentation sources
don't explicitly guarantee this, but it seems to be assumed in
other places in LLVM at least.

This fixes an assertion failure on the included testcase, which
is derived from the Ada testsuite.

FixUsesBeforeDefs is a temporary measure which I'm looking to
replace with a more capable solution.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72266 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-22 16:47:11 +00:00
Dan Gohman
0d56b06f86 Fix a thinko in the code that adapted SCEVMulExpr operands for
use in expanding SCEVAddExprs with GEPs. The operands of a
SCEVMulExpr need to be multiplied together, not added.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72250 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-22 07:14:20 +00:00
Torok Edwin
382cb2189a Revert this. There's no way to verifiy indirect calls, and an optimizer can turn
indirect call into direct call, thus the verifier would reject something it
previously accepted.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72249 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-22 07:12:05 +00:00
Torok Edwin
9107c54693 Verify that calling conventions match function prototype.
This only rejects mismatches between target specific calling convention
and C/LLVM specific calling convention.
There are too many fastcc/C, coldcc/cc42 mismatches in the testsuite, these are
not reject by the verifier.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72248 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-22 06:41:43 +00:00
Eli Friedman
15002a2b52 Fix broken logic in DominatorTreeBase::Split. Part of PR4238.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72231 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-21 21:47:54 +00:00
Eli Friedman
0f4012ca9d Fix some incorrect logic in DominanceFrontier::splitBlock. Part of
PR4238.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72223 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-21 20:40:30 +00:00
Dan Gohman
9004c8afd4 Teach ValueTracking a new way to analyze PHI nodes, and and teach
Instcombine to be more aggressive about using SimplifyDemandedBits
on shift nodes. This allows a shift to be simplified to zero in the
included test case.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72204 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-21 02:28:33 +00:00
Eli Friedman
2ac8b324eb Fix for PR4235: to build a floating-point value from integer parts,
build an integer and cast that to a float.  This fixes a crash 
caused by trying to split an f32 into two f16's.

This changes the behavior in test/CodeGen/XCore/fneg.ll because that 
testcase now triggers a DAGCombine which converts the fneg into an integer
operation.  If someone is interested, it's probably possible to tweak 
the test to generate an actual fneg.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72162 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-20 06:02:09 +00:00
Evan Cheng
c7d167d62f Fix test on non-darwin hosts.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72161 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-20 05:45:36 +00:00
Evan Cheng
d7f666a869 Try again. Allow call to immediate address for ELF or when in static relocation mode.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72160 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-20 04:53:57 +00:00
Evan Cheng
65cdee3fd4 Cannot use immediate as call absolute target in PIC mode.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72154 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-20 01:11:00 +00:00
Dan Gohman
513fae2db5 Suppress the IV reversal transformation in the case that the RHS
of the comparison is defined inside the loop. This fixes a
use-before-def problem, because the transformation puts a use
of the RHS outside the loop.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72149 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-20 00:34:08 +00:00
Bob Wilson
04746eae49 Fix pr4058 and pr4059. Do not split i64 or double arguments between r3 and
the stack.  Patch by Sandeep Patel.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72106 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-19 10:02:36 +00:00
Bob Wilson
224c244f56 Fix pr4091: Add support for "m" constraint in ARM inline assembly.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72105 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-19 05:53:42 +00:00
Dan Gohman
5be18e8476 Teach SCEVExpander to expand arithmetic involving pointers into GEP
instructions. It attempts to create high-level multi-operand GEPs,
though in cases where this isn't possible it falls back to casting
the pointer to i8* and emitting a GEP with that. Using GEP instructions
instead of ptrtoint+arithmetic+inttoptr helps pointer analyses that
don't use ScalarEvolution, such as BasicAliasAnalysis.

Also, make the AddrModeMatcher more aggressive in handling GEPs.
Previously it assumed that operand 0 of a GEP would require a register
in almost all cases. It now does extra checking and can do more
matching if operand 0 of the GEP is foldable. This fixes a problem
that was exposed by SCEVExpander using GEPs.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72093 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-19 02:15:55 +00:00
Bill Wendling
b17e76d34a Commands beginning with '--' are converted to '-f' by gcc. Blech!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72023 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-18 18:09:36 +00:00
Dan Gohman
10978bd591 Teach ScalarEvolution to recognize x^-1 in the case where non-demanded
bits have been stripped out by instcombine.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72010 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-18 16:29:04 +00:00
Dan Gohman
859b4824ee Make ScalarEvolution::isLoopGuardedByCond work even when the edge
entering a loop is a non-split critical edge.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72004 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-18 15:36:09 +00:00
Dan Gohman
04623272d2 Add nounwind to a few tests.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72002 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-18 15:16:49 +00:00
Duncan Sands
b1014743b9 Check that the gcc front-end is not doing inlining
when not doing unit-at-a-time.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71986 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-17 19:37:02 +00:00
Anton Korobeynikov
e4fdb8b8ff Mark rotl/rotr as expand. This generates pretty ugly code, but this is better than nothing.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71976 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-17 10:16:28 +00:00
Anton Korobeynikov
aceb620de8 Typo
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71975 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-17 10:15:22 +00:00
Jakob Stoklund Olesen
f8eac02fc1 Help DejaGnu avoid pipe-jam by producing less output from certain test cases.
When a test fails with more than a pipeful of output on stdout AND stderr, one
of the DejaGnu programs blocks. The problem can be avoided by redirecting
stdout to a file.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71919 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-16 00:34:42 +00:00
David Greene
9bea7c85d7 Implement !if, analogous to $(if) in GNU make.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71815 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-14 23:26:46 +00:00
David Greene
7a57214817 Fix tests to not upset DejaGNU.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71811 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-14 23:21:40 +00:00
David Greene
5f9f9ba00b Graduate LLVM to the big leagues by embedding a LISP processor into TableGen.
Ok, not really, but do support some common LISP functions:

* car
* cdr
* null


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71805 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-14 22:38:31 +00:00
David Greene
beb31a51f6 Implement a !foreach operator analogous to GNU make's $(foreach).
Use it on dags and lists like this:

class decls {
  string name;
}

def Decls : decls;

class B<list<string> names> : A<!foreach(Decls.name, names, !strconcat(Decls.name, ", Sr."))>;


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71803 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-14 22:23:47 +00:00
David Greene
4afc509b7f Implement a !subst operation simmilar to $(subst) in GNU make to do
def/var/string substitution on generic pattern templates.  For example:

def Type;
def v4f32 : Type;
def TYPE : Type;

class GenType<Type t> {
  let type = !(subst TYPE, v4f32, t);
}

def TheType : GenType<TYPE>;


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71801 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-14 21:54:42 +00:00
David Greene
e6c27de069 Implement !cast.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71794 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-14 21:22:49 +00:00
Dan Gohman
ebde0c55ce Add nounwind to this test.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71734 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-13 22:29:12 +00:00
Bill Wendling
ead6d467fb Remove too large testcase.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71730 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-13 21:51:26 +00:00
Bill Wendling
f3cc96e1f3 Move the bookkeeping of the debug scopes back to the place where it
belonged. The variable declaration stuff wasn't happy with it where it
was. Sorry that the testcase is so big. Bugpoint wasn't able to reduce it
successfully.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71714 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-13 20:33:33 +00:00
Dale Johannesen
6f21a8f636 Testcase for 71688.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71691 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-13 18:33:24 +00:00
Chris Lattner
aab6ec49d2 calls in nothrow functions can be marked nothrow even if the callee
is not known to be nothrow.  This allows readnone/readonly functions
to be deleted even if we don't know whether the callee can throw.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71676 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-13 17:39:14 +00:00
Chris Lattner
bcc2e7dc2c Fix PR4206 - crash in simplify lib calls
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71644 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-13 06:26:11 +00:00
Evan Cheng
9d3094b38e If header of inner loop is aligned, do not align the outer loop header. We don't want to add nops in the outer loop for the sake of aligning the inner loop.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71609 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-12 23:58:14 +00:00
Evan Cheng
eca24fba3f Teach TransferDeadness to delete truly dead instructions if they do not produce side effects.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71606 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-12 23:07:00 +00:00
Evan Cheng
17114249fc Add nounwind.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71575 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-12 18:35:43 +00:00
Evan Cheng
1ea7327845 Fixed a stack slot coloring with reg bug: do not update implicit use / def when doing forward / backward propagation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71574 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-12 18:31:57 +00:00
Bob Wilson
74b0ccc577 Fix pr4195: When iterating through predecessor blocks, break out of the loop
after finding the (unique) layout predecessor.  Sometimes a block may be listed
more than once, and processing it more than once in this loop can lead to
inconsistent values for FtTBB/FtFBB, since the AnalyzeBranch method does not
clear these values.  There's no point in continuing the loop regardless.
The testcase for this is reduced from the 2003-05-02-DependentPHI SingleSource
test.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71536 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-12 03:48:10 +00:00
Dan Gohman
81db61a2e6 Factor the code for collecting IV users out of LSR into an IVUsers class,
and generalize it so that it can be used by IndVarSimplify. Implement the
base IndVarSimplify transformation code using IVUsers. This removes
TestOrigIVForWrap and associated code, as ScalarEvolution now has enough
builtin overflow detection and folding logic to handle all the same cases,
and more. Run "opt -iv-users -analyze -disable-output" on your favorite
loop for an example of what IVUsers does.

This lets IndVarSimplify eliminate IV casts and compute trip counts in
more cases. Also, this happens to finally fix the remaining testcases
in PR1301.

Now that IndVarSimplify is being more aggressive, it occasionally runs
into the problem where ScalarEvolutionExpander's code for avoiding
duplicate expansions makes it difficult to ensure that all expanded
instructions dominate all the instructions that will use them. As a
temporary measure, IndVarSimplify now uses a FixUsesBeforeDefs function
to fix up instructions inserted by SCEVExpander. Fortunately, this code
is contained, and can be easily removed once a more comprehensive
solution is available.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71535 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-12 02:17:14 +00:00
Dan Gohman
efb9fbfdab When forgetting SCEVs for loop PHIs, don't forget SCEVUnknown values.
These values aren't analyzable, so they don't care if more information
about the loop trip count can be had. Also, SCEVUnknown is used for
a PHI while the PHI itself is being analyzed, so it needs to be left
in the Scalars map. This fixes a variety of subtle issues.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71533 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-12 01:27:58 +00:00