Commit Graph

287 Commits

Author SHA1 Message Date
Chris Lattner
8581c260d3 fix PR6940: sitofp(undef) folds to 0.0, not undef.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@102358 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-26 18:21:23 +00:00
Chris Lattner
8829cec25f fix a SCCP miscompilation that could happen when a
forced constant is changed to a constant, we would end
up adding the instruction to the wrong worklist, 
preventing it from being properly revisited.  This fixes
rdar://7832370


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100837 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-09 01:14:31 +00:00
Chris Lattner
e597f00e1a fix a really nasty bug that Evan was tracking in SCCP. When resolving
undefs in branches/switches, we have two cases: a branch on a literal
undef or a branch on a symbolic value which is undef.  If we have a
literal undef, the code was correct: forcing it to a constant is the
right thing to do.

If we have a branch on a symbolic value that is undef, we should force
the symbolic value to a constant, which then makes the successor block
live.  Forcing the condition of the branch to being a constant isn't 
safe if later paths become live and the value becomes overdefined.  This
is the case that 'forcedconstant' is designed to handle, so just use it.

This fixes rdar://7765019 but there is no good testcase for this, the
one I have is too insane to be useful in the future.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100478 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-05 22:14:48 +00:00
Gabor Greif
c8b82ccbcf Introduce ImmutableCallSite, useful for contexts where no mutation
is necessary. Inherits from new templated baseclass CallSiteBase<>
which is highly customizable. Base CallSite on it too, in a configuration
that allows full mutation.
Adapt some call sites in analyses to employ ImmutableCallSite.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100100 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-01 08:21:08 +00:00
Gabor Greif
60ad781c61 rename use_const_iterator to const_use_iterator for consistency's sake
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99564 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-25 23:06:16 +00:00
Gabor Greif
c9f7500d17 Finally land the InvokeInst operand reordering.
I have audited all getOperandNo calls now, fixing
hidden assumptions. CallSite related uglyness will
be eliminated successively.

Note this patch has a long and griveous history,
for all the back-and-forths have a look at
CallSite.h's log.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99399 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-24 13:21:49 +00:00
Gabor Greif
bd1f99341e increase const goodness and remove pointless getUser() calls
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99395 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-24 10:29:52 +00:00
Chris Lattner
9fcd72b71a fix grammaro's pointed out by daniel
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97313 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-27 07:50:40 +00:00
Chris Lattner
d38cdb020e fix PR6414, a nondeterminism issue in IPSCCP which was because
of a subtle interation in a loop operating in densemap order.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97288 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-27 00:07:42 +00:00
Duncan Sands
1df9859c40 There are two ways of checking for a given type, for example isa<PointerType>(T)
and T->isPointerTy().  Convert most instances of the first form to the second form.
Requested by Chris.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96344 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-16 11:11:14 +00:00
David Greene
971cc7e883 Change errs() to dbgs().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92612 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 01:27:15 +00:00
Dan Gohman
8f3817f505 Fix a use of an invalidated iterator in the case where there are multiple
adjacent uses of a dead basic block from the same user. This fixes PR5596.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89658 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-23 16:13:39 +00:00
Dan Gohman
6a2392131e Fix IPSCCP's code for deleting dead blocks to tolerate outstanding
blockaddress users. This fixes PR5569.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89483 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-20 20:19:14 +00:00
Chris Lattner
103f2434b8 fix a crash in SCCP handling extractvalue of an array, pointed out and
tracked down by Stephan Reiter!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86726 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-10 22:02:09 +00:00
Benjamin Kramer
bcaa2157dd Do map insert+find in one step. TODO -= 2.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86133 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-05 14:33:27 +00:00
Chris Lattner
0fb7e18edd Fix an iterator invalidation bug that happens when a hashtable
resizes in IPSCCP.  This fixes PR5394.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86036 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-04 18:57:42 +00:00
Chris Lattner
fc36a562ae reimplement multiple return value handling in IPSCCP, making it
more aggressive an correct.  This survives building llvm in 64-bit
mode with optimizations and the built llvm passes make check.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85973 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-03 23:40:48 +00:00
Chris Lattner
abf67ef548 finish half thunk thought
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85937 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-03 20:52:57 +00:00
Chris Lattner
2396cc37ae fix an IPSCCP bug I introduced when I changed IPSCCP to start working on
functions that don't have local linkage.  Basically, we need to be more
careful about propagating argument information to functions whose results
we aren't tracking.  This fixes a miscompilation of 
LLVMCConfigurationEmitter.cpp when built with an llvm-gcc that has ipsccp
enabled.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85923 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-03 19:24:51 +00:00
Chris Lattner
c175e5de2d fix a subtle bug I introduced when refactoring SCCP. Testcase
to follow.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85903 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-03 16:50:11 +00:00
Chris Lattner
14532d03a1 turn IPSCCP back on now that the iterator invalidation bug is fixed.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85858 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-03 03:42:51 +00:00
Chris Lattner
5cc66d979d fix a nasty iterator invalidation bug from my conversion from
std::map to DenseMap, exposed on release llvm-gcc bootstrap.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85840 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-02 23:25:39 +00:00
Chris Lattner
3774c91854 revert r8579[56], which are causing unhappiness in buildbot land.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85818 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-02 19:31:10 +00:00
Chris Lattner
2bbbbd6ac8 disable IPSCCP support for multiple return values, it is buggy, so just
disable it until I can fix it.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85810 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-02 18:22:51 +00:00
Chris Lattner
12c8d5f5fe improve IPSCCP to be able to propagate the result of "!mayBeOverridden"
function to calls of that function, regardless of whether it has local
linkage or has its address taken.  Not escaping should only affect 
whether we make an aggressive assumption about the arguments to a 
function, not whether we can track the result of it.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85795 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-02 07:33:59 +00:00
Chris Lattner
ff3ca15951 don't mark the arguments of prototype overdefined, they will never be queried.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85793 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-02 06:34:04 +00:00
Chris Lattner
e01985c95f restore some code I removed in r85788, refactor it into
a shared place instead of duplicating it 4 times.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85792 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-02 06:28:16 +00:00
Chris Lattner
574fa9e83c remove some confused code that dates from when we had
"multiple return values" but not "first class aggregates"


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85791 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-02 06:17:06 +00:00
Chris Lattner
09275299e2 avoid redundant lookups in BBExecutable, and make it a SmallPtrSet.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85790 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-02 06:11:23 +00:00
Chris Lattner
5638dc618a Use the libanalysis 'ConstantFoldLoadFromConstPtr' function
instead of reinventing SCCP-specific logic.  This gives us
new powers.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85789 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-02 06:06:14 +00:00
Chris Lattner
2a0433beea switch the main 'ValueState' map from being an std::map to being
a DenseMap.  Doing this required being aware of subtle iterator
invalidation issues, but it provides a big speedup.  In a 
release-asserts build, this sped up optimizing 403.gcc from
1.34s -> 0.79s (IPSCCP) and 1.11s -> 0.44s (SCCP).

This commit also conflates in a bunch of general cleanups, sorry.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85788 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-02 05:55:40 +00:00
Chris Lattner
89112b608f only IPSCCP incoming arguments if the function is executable, this fixes
an assertion on the buildbot.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85784 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-02 03:25:55 +00:00
Chris Lattner
36c9952b1b add a new ValueState::getConstantInt() helper, use it to
simplify some code.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85783 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-02 03:21:36 +00:00
Chris Lattner
38871e4c3b tidy up some more: remove some extraneous inline specifiers, return harder.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85780 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-02 03:03:42 +00:00
Chris Lattner
8db50122a4 eliminate the SCCPSolver::getValueMapping method.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85778 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-02 02:54:24 +00:00
Chris Lattner
301a2792be fix failures introduced in r85774
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85777 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-02 02:48:17 +00:00
Chris Lattner
cc4f60b113 factor duplicated code into a new DeleteInstructionInBlock
function, eliminate temporary (and pointless) smallvector.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85776 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-02 02:47:51 +00:00
Chris Lattner
2f09625a9f Chris used to use '...' instead of proper grammar.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85775 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-02 02:33:50 +00:00
Chris Lattner
ea0db070a1 remove some extraneous llvmcontext stuff.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85774 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-02 02:30:06 +00:00
Chris Lattner
7927220aef change LatticeVal to use PointerIntPair to save some space.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85773 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-02 02:20:32 +00:00
Chris Lattner
b2710041fb teach ipsccp and ipconstprop that a blockaddress doesn't 'take the address' of a function
in a way that should prevent ip constprop.  This allows clang/test/CodeGen/indirect-goto.c
to pass with the new indirect goto lowering.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85709 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-01 06:11:53 +00:00
Chris Lattner
4c0236fd8b teach various passes about blockaddress. We no longer
crash on any clang tests.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85465 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-29 01:21:20 +00:00
Victor Hernandez
f006b183e2 Rename MallocFreeHelper as MemoryBuiltins
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85286 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-27 20:05:49 +00:00
Victor Hernandez
f2becca90b Rename MallocHelper as MallocFreeHelper, since it now also identifies calls to free()
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85181 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-26 23:58:56 +00:00
Victor Hernandez
046e78ce55 Remove FreeInst.
Remove LowerAllocations pass.
Update some more passes to treate free calls just like they were treating FreeInst.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85176 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-26 23:43:48 +00:00
Victor Hernandez
66284e063a Auto-upgrade free instructions to calls to the builtin free function.
Update all analysis passes and transforms to treat free calls just like FreeInst.
Remove RaiseAllocations and all its tests since FreeInst no longer needs to be raised.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84987 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-24 04:23:03 +00:00
Victor Hernandez
7b929dad59 Remove AllocationInst. Since MallocInst went away, AllocaInst is the only subclass of AllocationInst, so it no longer is necessary.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84969 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-23 21:09:37 +00:00
Torok Edwin
2b6183d254 Fix PR4313: IPSCCP was not setting the lattice value for the invoke instruction
when the invoke had multiple return values: it set the lattice value only on the
extractvalue.
This caused the invoke's lattice value to remain the default (undefined), and
later propagated to extractvalue's operand, which incorrectly introduces
undefined behavior.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84637 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-20 15:15:09 +00:00
Dan Gohman
c6f69e94fa Remove an unnnecessary LLVMContext argument in
ConstantFoldLoadThroughGEPConstantExpr.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83311 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-05 16:36:26 +00:00
Chris Lattner
cf0fe8d813 strength reduce a ton of type equality tests to check the typeid (Through
the new predicates I added) instead of going through a context and doing a
pointer comparison.  Besides being cheaper, this allows a smart compiler
to turn the if sequence into a switch.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83297 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-05 05:54:46 +00:00