Commit Graph

5376 Commits

Author SHA1 Message Date
Owen Anderson
8b477ed579 Add a pointer to the owning LLVMContext to Module. This requires threading LLVMContext through a lot
of the bitcode reader and ASM parser APIs, as well as supporting it in all of the tools.

Patches for Clang and LLVM-GCC to follow.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74614 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-01 16:58:40 +00:00
Chris Lattner
0fd38069cb improve the APIs for creating struct and function types with no arguments/elements
to not have to create a temporary vector (in the API at least).  Patch by Jay Foad!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74584 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-01 04:13:31 +00:00
Dan Gohman
2aa93efa0c Minor code simplification.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74491 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-30 01:24:43 +00:00
Dan Gohman
f7ca1611e2 Don't try to split a loop when the controlling icmp instruction
doesn't have an IV-based operand. This fixes PR4471.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74399 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-27 22:58:27 +00:00
Dan Gohman
a1baee20c4 Remove the block from the LoopInfo, rather than just the Loop.
LoopInfo will handle removing it from the Loop, as well as updating
its own tables.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74398 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-27 22:32:36 +00:00
Dan Gohman
4b35f83b91 Teach LoopSimplify how to merge multiple loop exits into a single exit,
when one of them can be converted to a trivial icmp and conditional
branch.

This addresses what is essentially a phase ordering problem.
SimplifyCFG knows how to do this transformation, but it doesn't do so
if the primary block has any instructions in it other than an icmp and
a branch. In the given testcase, the block contains other instructions,
however they are loop-invariant and can be hoisted. SimplifyCFG doesn't
have LoopInfo though, so it can't hoist them. And, it's important that
the blocks be merged before LoopRotation, as it doesn't support
multiple-exit loops.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74396 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-27 21:30:38 +00:00
Dan Gohman
cfb32203bc More minor code simplifications.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74395 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-27 21:23:40 +00:00
Dan Gohman
de53dc03f5 When a value is used multiple times within a single PHI, instructions
inserted to replace that value must dominate all of of the basic
blocks associated with the uses of the value in the PHI, not just
one of them.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74376 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-27 05:16:57 +00:00
Dan Gohman
667d787c0a Incorporate the insertion point into the key of SCEVExpander's CSE map.
This helps it avoid reusing an instruction that doesn't dominate all
of the users, in cases where the original instruction was inserted
before all of the users were known.  This may result in redundant
expansions of sub-expressions that depend on loop-unpredictable values
in some cases, however this isn't very common, and it primarily impacts
IndVarSimplify, so GVN can be expected to clean these up.

This eliminates the need for IndVarSimplify's FixUsesBeforeDefs,
which fixes several bugs.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74352 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-26 22:53:46 +00:00
Devang Patel
acec7b35aa Remove unused routines.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74351 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-26 22:53:22 +00:00
Owen Anderson
afe0a083c1 Constify this value.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74330 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-26 21:39:56 +00:00
Douglas Gregor
8947881444 Fix linking of llvm-ld and lli with CMake, from Xerxes Rånby
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74285 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-26 15:37:00 +00:00
Devang Patel
13e16b65dd Remove debug info anchors - llvm.dbg.compile_units, llvm.dbg.subprograms
and llvm.dbg.global_variables.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74251 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-26 01:49:18 +00:00
Dan Gohman
e1047fbb97 Change this code to a form about which VC++ reportedly isn't unhappy.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74243 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-26 00:35:12 +00:00
Dan Gohman
6b9c959c61 Fix LCSSA to avoid emitting a PHI node for the unwind destination of
an invoke instruction, since the value isn't really live across that
edge.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74242 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-26 00:31:13 +00:00
Dan Gohman
30d670f51f Minor code simplification.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74240 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-26 00:26:03 +00:00
Dan Gohman
cc4e605721 Reword a few comments.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74146 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-25 00:22:44 +00:00
Dan Gohman
32a81a3f6d When inserting code into a loop preheader, insert it before the
terminator, instead of after the last phi. This fixes a bug
exposed by ScalarEvolution analyzing more kinds of loops.
This fixes PR4436.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74072 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-24 14:31:06 +00:00
Dan Gohman
40a5a1b39e Extend ScalarEvolution's multiple-exit support to compute exact
trip counts in more cases.

Generalize ScalarEvolution's isLoopGuardedByCond code to recognize
And and Or conditions, splitting the code out into an
isNecessaryCond helper function so that it can evaluate Ands and Ors
recursively, and make SCEVExpander be much more aggressive about
hoisting instructions out of loops.

test/CodeGen/X86/pr3495.ll has an additional instruction now, but
it appears to be due to an arbitrary register allocation difference.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74048 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-24 01:18:18 +00:00
Dan Gohman
ea080be986 Don't emit a redundant BitCastInst if the value to be defined in the
preheader is already an instruction.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74031 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-24 00:28:59 +00:00
Dan Gohman
469f3cdc13 Fix a few minor issues that were exposed by the removal of SCEVHandle.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73910 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-22 22:08:45 +00:00
Owen Anderson
372b46cad9 SCEVHandle is no more!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73906 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-22 21:39:50 +00:00
Dan Gohman
03ad6982c4 Fix this code to correctly handle loops with multiple exits. Until
now, this hasn't mattered, because ScalarEvolution hasn't been able
to compute trip counts for loops with multiple exits. But it will
soon.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73864 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-22 00:15:15 +00:00
Dan Gohman
5392dce881 Rename a variable for consistency with the ExitBlock vs ExitingBlock
terminology that LoopInfo uses.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73863 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-21 23:48:38 +00:00
Dan Gohman
224a19c490 Fix a typo in a comment that Frits von Bommel noticed.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73796 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-19 23:41:37 +00:00
Dan Gohman
2781f30eac Re-apply r73718, now that the fix in r73787 is in, and add a
hand-crafted testcase which demonstrates the bug that was exposed
in 254.gap.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73793 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-19 23:23:27 +00:00
Dan Gohman
4d1c1efd80 Fix LSR's OptimizeSMax to ignore max operators with more than 2 operands,
which it isn't prepared to handle.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73787 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-19 23:03:46 +00:00
Evan Cheng
73a76736fb Revert 73718. It's breaking 254.gap.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73783 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-19 21:15:06 +00:00
Chris Lattner
79c740ff47 make jump threading handle lexically identical compare instructions
as if they were multiple uses of the same instruction.  This interacts
well with the existing loadpre that j-t does to open up many new jump
threads earlier.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73768 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-19 16:27:56 +00:00
Nick Lewycky
9683f18174 Teach jump threading to look at comparisons between phi nodes and non-constants.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73755 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-19 04:56:29 +00:00
Chris Lattner
6a35b40250 Improve tail call elim to move loads above readonly calls
when it allows forming a tail call.  Patch by Frits van
Bommel.  This implements PR4323.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73752 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-19 04:22:16 +00:00
Chris Lattner
849832c0fb part of PR4405: disable a contentious optimization for
strcmp -> memcmp when the lengths of the strings are unknown.

Patch by Nick Lewycky!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73751 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-19 04:17:36 +00:00
Dan Gohman
4658c9b4ea Generalize LSR's OptimizeSMax to handle unsigned max tests as well
as signed max tests. Along with r73717, this helps CodeGen avoid
emitting code for a maximum operation for this class of loop.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73718 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-18 20:23:18 +00:00
Anton Korobeynikov
9547cdfa35 Revert IRBuilder CC propagation. Fix SimplifyLibCalls instead.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73715 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-18 20:05:31 +00:00
Dan Gohman
4e8a98519e Remove the code from IVUsers that attempted to handle
casted induction variables in cases where the cast
isn't foldable. It ended up being a pessimization in
many cases. This could be fixed, but it would require
a bunch of complicated code in IVUsers' clients. The
advantages of this approach aren't visible enough to
justify it at this time.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73706 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-18 16:54:06 +00:00
Dan Gohman
fd3daa74c2 Generalize the zext(trunc(t) & C) instcombine to work even with
C is not a low-bits mask, and add a similar instcombine for
zext((trunc(t) & C) ^ C).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73705 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-18 16:30:21 +00:00
Dan Gohman
a392c788be Instcombine zext(trunc(x) & mask) to x&mask, even if the trunc has
multiple users.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73656 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-17 23:17:05 +00:00
Dale Johannesen
42c3f554f4 This fixes a bug introduced in 72661, which can
move loads back past a check that the load address
is valid, see new testcase.  The test that went
in with 72661 has exactly this case, except that
the conditional it's moving past is checking
something else; I've settled for changing that
test to reference a global, not a pointer.  It
may be possible to scan all the tests you pass and
make sure none of them are checking any component
of the address, but it's not trivial and I'm not
trying to do that here.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73632 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-17 20:48:23 +00:00
Torok Edwin
4306b1a329 Add debug message about non-local loads being clobbered.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73625 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-17 18:48:18 +00:00
Dan Gohman
e3a6165423 Update comments to use doxygen syntax.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73621 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-17 17:51:33 +00:00
Sanjiv Gupta
059aa8c604 >> What if my global variable was into a different address space than stack?
>>     
>
> It doesn't matter in terms of semantics: because AnalyzeGlobal
> returned false, we're guaranteed the address of the global is never
> taken.  I wouldn't be surprised if we end up generating invalid IR in
> some cases, though, because of the semantics of replaceAllUsesWith.
> Do you have a testcase that breaks?
>
>   
The problem is replaceAllUsesWith asserts for type mismatch here. Try attached .bc with llvm-ld.

assert(New->getType() == getType() &&
        "replaceAllUses of value with new value of different type!");

Since stack is always on address space zero, I don't think that type of GV in a different address space is ever going to match.
The other way is to allow replaceAllUsesWith to ignore address spaces while comparing types. (do we have  a way to do that ?).
But then such an optimization may fail the entire idea of user wanting to place a variable into different memory space. The original idea of user might be to save on the stack space (data memory) and hence he asked the variable to be placed into different memory space (program memory). So the best bet here is to deny this optimization by checking

GV->getType()->getAddressSpace() == 0. 


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73605 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-17 06:47:15 +00:00
Eli Friedman
a999a511f7 PR3439: Correct a silly mistake in the SimplifyDemandedUseBits code for
SRem.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73598 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-17 02:57:36 +00:00
Dan Gohman
c6ac322c1c Generalize a few more instcombines to be vector/scalar-independent.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73541 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-16 19:55:29 +00:00
Chris Lattner
6cc8a93c48 Generalize instcombine's isSafeToLoadUnconditionally() function
to ignore readonly calls, and factor it out of instcombine so
that it can be used by other passes.  Patch by Frits van Bommel!



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73506 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-16 17:23:12 +00:00
Dan Gohman
44118f0e25 Use Type::getScalarType.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73451 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-16 00:20:26 +00:00
Dan Gohman
6de29f8d96 Support vector casts in more places, fixing a variety of assertion
failures.

To support this, add some utility functions to Type to help support
vector/scalar-independent code. Change ConstantInt::get and
ConstantFP::get to support vector types, and add an overload to
ConstantInt::get that uses a static IntegerType type, for
convenience.

Introduce a new getConstant method for ScalarEvolution, to simplify
common use cases.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73431 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-15 22:12:54 +00:00
Dale Johannesen
c1f104054d Fix the crash in this test. This is basically the same
problem addressed in 31284, but the patch there only
addressed the case where an invoke is the first thing in
a block.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73416 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-15 20:59:27 +00:00
Owen Anderson
636768458f Merge PartialInliner changes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73412 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-15 20:50:26 +00:00
Dan Gohman
c915c95978 Make the EnableLoadPRE variable static.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73398 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-15 18:30:15 +00:00
Dan Gohman
a119de86a0 Fix old-style type names in comments.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73362 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-14 23:30:43 +00:00
Dan Gohman
a82752c9eb Convert several parts of the ScalarEvolution framework to use
SmallVector instead of std::vector.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73357 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-14 22:47:23 +00:00
Dan Gohman
ea73f3c2e1 Add another item to the list of things that indvars does.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73355 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-14 22:38:41 +00:00
Torok Edwin
caf6b2bbaf Fix CMake build. Patch from Ingmar Vanhassel.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73342 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-14 13:39:56 +00:00
Owen Anderson
ca399021d4 Add an early implementation of a partial inlining pass. The idea behind this
is that, for functions whose bodies are entirely guarded by an if-statement, it
can be profitable to pull the test out of the callee and into the caller.

This code has had some cursory testing, but still has a number of known issues
on the LLVM test suite.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73338 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-14 08:26:32 +00:00
Nick Lewycky
a142c9302b Unlike the other instructions, GEP really does need to look at the type of a
pointer. This fixes kimwitu++. Pointed out by Frits van Bommel on review!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73299 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-13 19:09:52 +00:00
Dan Gohman
4d8414f420 Teach SCEVExpander's visitAddRecExpr to reuse an existing canonical
induction variable when the addrec to be expanded does not require
a wider type. This eliminates the need for IndVarSimplify to
micro-manage SCEV expansions, because SCEVExpander now
automatically expands them in the form that IndVarSimplify considers
to be canonical. (LSR still micro-manages its SCEV expansions,
because it's optimizing for the target, rather than for
other optimizations.)

Also, this uses the new getAnyExtendExpr, which has more clever
expression simplification logic than the IndVarSimplify code it
replaces, and this cleans up some ugly expansions in code such as
the included masked-iv.ll testcase.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73294 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-13 16:25:49 +00:00
Chris Lattner
69074a51f9 second half of fix for PR4366: don't zap store to null of
non-default addrspaces.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73253 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-12 21:01:07 +00:00
Dan Gohman
e54aba5fa9 Don't do (x - (y - z)) --> (x + (z - y)) on floating-point types, because
it may round differently. This fixes PR4374.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73243 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-12 19:23:25 +00:00
Dan Gohman
194ae785e1 Give Instruction::isSameOperationAs a corresponding comment to note
the relationship with MergeFunctions.cpp's isEquivalentOperation,
and make a trivial code reordering so that the two functions are
easier to compare.

Fix the name of Instruction::isSameOperationAs in MergeFunction.cpp's
isEquivalentOperation's comment, and fix a nearby 80-column violation.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73241 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-12 19:03:05 +00:00
Nick Lewycky
93531e4986 Keep callers of a weak function calling it, instead of the non-weak equivalent.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73235 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-12 17:16:48 +00:00
Nick Lewycky
b3c36c9c9a Don't forget to match the calling convention when producing a thunk.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73231 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-12 16:04:00 +00:00
Nick Lewycky
8728d7a3ea Given two identical weak functions, produce one internal function and two weak
thunks.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73230 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-12 15:56:56 +00:00
Nick Lewycky
287de607dc Add an "are types equivalent" operation that ignores the types that a pointer
points to while analyzing all other fields.

Use FoldingSetNodeID to produce a good hash. This dramatically decreases run
times.

Emit thunks. This means that it can look at all functions regardless of what
the linkage is or if the address is taken, but unfortunately some small
functions can be even shorter than the thunk because our backend doesn't yet
realize it can just turn these into jumps. This means that this pass will
pessimize code on average.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73222 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-12 08:04:51 +00:00
Chris Lattner
3590abfda0 Fix 4366: store to null in non-default addr space should not be
turned into unreachable.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73195 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-11 17:54:56 +00:00
Jay Foad
757068f3ba Implement and use new method Function::hasAddressTaken().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73164 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-10 08:41:11 +00:00
Jay Foad
e3acf159d9 Remove an unused function SafeToDestroyConstant(). Rename an almost
identical function ConstantIsDead() to SafeToDestroyConstant(), to
emphasise the connection with Constant::destroyConstant().

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73149 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-09 21:37:11 +00:00
Nick Lewycky
d7f20b6b98 Don't crash on multiple return value with no obvious inserted value.
Fixes PR4314.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73007 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-06 23:13:08 +00:00
Eli Friedman
b9a4cacc91 PR4340: Run SimplifyDemandedVectorElts on insertelement instructions;
sometimes it can find simplifications that won't be found otherwise.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73006 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-06 20:08:03 +00:00
Jay Foad
0906b1bf09 Use cast<> instead of dyn_cast<> for things that are known to be
Instructions.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73002 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-06 17:49:35 +00:00
Devang Patel
da634298fc Simplify.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72965 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-05 22:39:21 +00:00
Dan Gohman
ae3a0be92e Split the Add, Sub, and Mul instruction opcodes into separate
integer and floating-point opcodes, introducing
FAdd, FSub, and FMul.

For now, the AsmParser, BitcodeReader, and IRBuilder all preserve
backwards compatability, and the Core LLVM APIs preserve backwards
compatibility for IR producers. Most front-ends won't need to change
immediately.

This implements the first step of the plan outlined here:
http://nondot.org/sabre/LLVMNotes/IntegerOverflow.txt


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72897 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-04 22:49:04 +00:00
Dan Gohman
77b81fe487 Don't do the X * 0.0 -> 0.0 transformation in instcombine, because
instcombine doesn't know when it's safe. To partially compensate
for this, introduce new code to do this transformation in
dagcombine, which can use UnsafeFPMath.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72872 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-04 17:12:12 +00:00
Dan Gohman
68c9344056 Don't attempt to simplify an non-affine IV expression if it can't
be simplified to a loop-invariant value. This fixes PR4315.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72798 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-03 19:11:31 +00:00
Dan Gohman
8b0d4f61bb Fix CodeGenPrepare's address-mode sinking to handle unusual
addresses, involving Base values which do not have Pointer type.
This fixes PR4297.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72739 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-02 21:29:13 +00:00
Evan Cheng
5d16396a33 Avoid infinite looping in AllGlobalLoadUsesSimpleEnoughForHeapSRA(). This can happen when PHI uses are recursively dependent on each other.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72710 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-02 00:56:07 +00:00
Eli Friedman
41b33f437f PR4286: Make RewriteLoadUserOfWholeAlloca and
RewriteStoreUserOfWholeAlloca deal with tail padding because 
isSafeUseOfBitCastedAllocation expects them to.  Otherwise, we crash 
trying to erase the bitcast.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72688 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-01 09:14:32 +00:00
Owen Anderson
88554df4a2 Be more aggressive in doing LoadPRE by tracing backwards when a block only has
a single predecessor.

Patch by Jakub Staszak.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72661 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-31 09:03:40 +00:00
Chris Lattner
0e98e4d299 fix PR4284, a bug in simplifylibcalls handling memcmp. Patch by
Benjamin Kramer!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72625 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-30 18:43:04 +00:00
Nick Lewycky
7a0370f66a Give embedded metadata its own type instead of relying on EmptyStructTy.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72610 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-30 05:06:04 +00:00
Bill Wendling
3c04296b83 Enable GVN Load PRE.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72589 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-29 20:38:16 +00:00
Torok Edwin
70ac142560 just show the instruction, its not that slow.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72577 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-29 16:58:36 +00:00
Torok Edwin
7e55a00d06 for instructions with void type we have no choice but print the instruction as
is, otherwise we get a <badref>.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72567 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-29 10:28:44 +00:00
Torok Edwin
3f3c6d4e5b Add a DEBUG() output to GVN that prints the instruction clobbering a load.
This is useful when trying to figure out why GVN didn't eliminate redundant
loads.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72565 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-29 09:46:03 +00:00
Owen Anderson
246ddf55d1 Fix an issue where phiMap was not being updated properly when doing load PRE.
Diagnosis and patch thanks to Jakub Staszak.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72562 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-29 05:37:54 +00:00
Nick Lewycky
e3f1fb1ee8 Use Operands.data() instead of &Operands[0] where Operands is a potentially
empty SmallVector.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72512 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-28 04:08:10 +00:00
Dan Gohman
c2695eba57 Revert 72493 and replace it with a more conservative fix, for now: don't
rewrite the comparison if there is any implicit extension or truncation
on the induction variable. I'm planning for IVUsers to eventually take
over some of the work of this code, and for it to be generalized.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72496 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-27 21:10:47 +00:00
Dan Gohman
ead28bd04b In ChangeCompareStride, when the stride to be reused is truncated to
a smaller type, promoted its offset back up to the type of the new
comparison. This fixes PR4222.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72493 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-27 20:00:18 +00:00
Dan Gohman
d594e6f034 Change ScalarEvolution::getSCEVAtScope to always return the original value
in the case where a loop exit value cannot be computed, instead of only in
some cases while using SCEVCouldNotCompute in others. This simplifies
getSCEVAtScope's callers.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72375 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-24 23:25:42 +00:00
Torok Edwin
3d431384f0 Move Rewriter.clear() earlier, to avoid triggerring the AssertingVH by
one of the RecursivelyDeleteTriviallyDeadInstructions.
Add a comment explaining why the cache needs to be cleared.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72372 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-24 20:08:21 +00:00
Torok Edwin
3790fb0c03 Instead of clearing the rewriter, don't attempt to rewrite dead phi nodes.
Also fix 80 column violation.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72371 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-24 19:36:09 +00:00
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
14fba294e1 When replacing a floating-point comparison with an integer
comparison, use takeName to give the integer comparison a name.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72367 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-24 18:09:01 +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
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
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
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
Eli Friedman
f7cca7b8f8 Fix loop-index-split to correctly preserve dominance frontiers. Part of
PR4238.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72244 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-22 03:22:46 +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
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
Dan Gohman
c2c4cbf7b3 Remove an irrelevant comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72132 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-19 20:38:47 +00:00