Dan Gohman
041e2dbad1
Merge the enhancements from LoopUnroll's FoldBlockIntoPredecessor into
...
MergeBlockIntoPredecessor. This makes SimplifyCFG slightly more aggressive,
and makes it unnecessary for LoopUnroll to have its own copy of this code.
llvm-svn: 85667
2009-10-31 16:08:00 +00:00
Dan Gohman
fa8969f70e
Simplify this code.
...
llvm-svn: 85662
2009-10-31 14:46:50 +00:00
Dan Gohman
f35b6640f6
Update CMakeLists for recent renames.
...
llvm-svn: 85660
2009-10-31 14:38:25 +00:00
Dan Gohman
f70e76c435
Rename UnrollLoop.cpp to LoopUnroll.cpp, and LoopUnroll.cpp to
...
LoopUnrollPass.cpp, for consistency with other passes which are
similarly split.
llvm-svn: 85659
2009-10-31 14:37:31 +00:00
Dan Gohman
7f7d97eb73
Add a comment about a missed opportunity.
...
llvm-svn: 85635
2009-10-30 23:15:43 +00:00
Dan Gohman
1a95106602
Teach SimplifyCFG how to eliminate duplicate PHI nodes within a block.
...
This reduces codesize on a variety of codes by 1-2% on x86-64. It also
helps clean up after SSAUpdater.
llvm-svn: 85626
2009-10-30 22:39:04 +00:00
Chris Lattner
ee8b951e73
teach various passes about blockaddress. We no longer
...
crash on any clang tests.
llvm-svn: 85465
2009-10-29 01:21:20 +00:00
Chris Lattner
be060382e9
teach ValueMapper about BlockAddress', making bugpoint a lot more useful.
...
llvm-svn: 85458
2009-10-29 00:31:02 +00:00
Chris Lattner
cf5a47d63d
unindent massive blocks, no functionality change.
...
llvm-svn: 85457
2009-10-29 00:28:30 +00:00
Devang Patel
11cf3f4a27
Factor out redundancy from clone() implementations.
...
llvm-svn: 85327
2009-10-27 22:16:29 +00:00
Victor Hernandez
f390e04a47
Rename MallocFreeHelper as MemoryBuiltins
...
llvm-svn: 85286
2009-10-27 20:05:49 +00:00
Chris Lattner
c6b3b25f94
Fix a pretty serious misfeature of the inliner: if it inlines a function
...
with multiple return values it inserts a PHI to merge them all together.
However, if the return values are all the same, it ends up with a pointless
PHI and this pointless PHI happens to really block SRoA from happening in
at least a silly C++ example written by Doug, but probably others. This
fixes rdar://7339069.
llvm-svn: 85206
2009-10-27 05:39:41 +00:00
Victor Hernandez
762195bd01
Rename MallocHelper as MallocFreeHelper, since it now also identifies calls to free()
...
llvm-svn: 85181
2009-10-26 23:58:56 +00:00
Victor Hernandez
de5ad42aa1
Remove FreeInst.
...
Remove LowerAllocations pass.
Update some more passes to treate free calls just like they were treating FreeInst.
llvm-svn: 85176
2009-10-26 23:43:48 +00:00
Nick Lewycky
974e12b2d3
Remove includes of Support/Compiler.h that are no longer needed after the
...
VISIBILITY_HIDDEN removal.
llvm-svn: 85043
2009-10-25 06:57:41 +00:00
Nick Lewycky
02d5f77d26
Remove VISIBILITY_HIDDEN from class/struct found inside anonymous namespaces.
...
Chris claims we should never have visibility_hidden inside any .cpp file but
that's still not true even after this commit.
llvm-svn: 85042
2009-10-25 06:33:48 +00:00
Dan Gohman
ef41a1ce3c
MapValue doesn't needs its LLVMContext argument.
...
llvm-svn: 85020
2009-10-24 23:37:16 +00:00
Victor Hernandez
e297149e26
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.
llvm-svn: 84987
2009-10-24 04:23:03 +00:00
Chris Lattner
7f903681ac
alternate fix for PR5258 which avoids worklist problems, with reduced testcase.
...
llvm-svn: 84667
2009-10-20 20:27:49 +00:00
Torok Edwin
cf10ec951d
Fix PR5258, jump-threading creating invalid PHIs.
...
When an incoming value for a PHI is updated, we must also updated all other
incoming values for the same BB to match, otherwise we create invalid PHIs.
llvm-svn: 84638
2009-10-20 15:42:00 +00:00
Dan Gohman
8f986672a1
Fix SplitBlockPredecessors' LoopInfo updating code to handle the case
...
where a loop's header is being split and it has predecessors which are not
contained by the most-nested loop which contains the loop.
This fixes PR5235.
llvm-svn: 84505
2009-10-19 16:04:50 +00:00
Dan Gohman
511d2e26dd
Change instnamer to name arguments "arg" instead of "tmp" for clarity, and
...
to name basic blocks "bb" instead of "BB", for consistency.
llvm-svn: 84502
2009-10-19 14:47:32 +00:00
Chris Lattner
88b36f1140
Simplify some code (first hunk) and fix PR5208 (second hunk) by
...
updating the callgraph when introducing a call.
llvm-svn: 84310
2009-10-17 05:39:39 +00:00
Victor Hernandez
a3aaf85e23
Remove MallocInst from LLVM Instructions.
...
llvm-svn: 84299
2009-10-17 01:18:07 +00:00
Duncan Sands
0058c7bcb0
Strip trailing white space.
...
llvm-svn: 84256
2009-10-16 15:20:13 +00:00
Ted Kremenek
113d959f1b
Update CMake file.
...
llvm-svn: 84001
2009-10-13 18:48:07 +00:00
Dan Gohman
54463e837a
Commit the removal of this file, which is now moved to lib/Analysis.
...
llvm-svn: 83999
2009-10-13 18:37:20 +00:00
Dan Gohman
5b3e05bcaa
Start refactoring the inline cost estimation code so that it can be used
...
for purposes other than inlining.
llvm-svn: 83997
2009-10-13 18:24:11 +00:00
Chris Lattner
19788ca686
change simplifycfg to not duplicate 'unwind' instructions. Hopefully
...
this will increase the likelihood of common code getting sunk towards
the unwind.
llvm-svn: 83996
2009-10-13 18:13:05 +00:00
Chris Lattner
71d353dd48
rewrite LCSSA to use SSAUpdate, to only return true if it modifies
...
the IR, and to implement the FIXME'd optimization.
llvm-svn: 83748
2009-10-11 02:53:37 +00:00
Chris Lattner
101dde30ed
clean up and simplify some code. Don't use setvector when things will be
...
inserted only once, just use vector. Don't compute ExitBlocks unless we
need it, change std::sort to array_pod_sort.
llvm-svn: 83747
2009-10-11 01:07:15 +00:00
Chris Lattner
9c382cebc5
add a simple helper method.
...
llvm-svn: 83745
2009-10-10 23:41:48 +00:00
Chris Lattner
249265de06
add ability for clients of SSAUpdater to find out about the
...
PHI nodes inserted.
llvm-svn: 83744
2009-10-10 23:15:24 +00:00
Chris Lattner
67cdd8b567
add the ability to get a rewritten value from the middle of a block,
...
not just at the end. Add a big comment explaining when this could
be useful (which never happens for jump threading).
llvm-svn: 83741
2009-10-10 23:00:11 +00:00
Chris Lattner
e474a8d3a7
rename GetValueInBlock -> GetValueAtEndOfBlock to better reflect
...
what it does.
llvm-svn: 83740
2009-10-10 22:41:58 +00:00
Chris Lattner
65e69a77e1
use a typedef instead of spelling out an insane type. Yay for auto someday.
...
llvm-svn: 83707
2009-10-10 09:09:20 +00:00
Chris Lattner
60d4e69c81
Implement an efficient and fully general SSA update mechanism that
...
works on unstructured CFGs. This implements PR217, our oldest open PR.
llvm-svn: 83705
2009-10-10 09:04:27 +00:00
Chris Lattner
f30a2b0c86
random tidying
...
llvm-svn: 83701
2009-10-10 06:22:45 +00:00
Dale Johannesen
96a5b87ae2
Use names instead of numbers for some of the magic
...
constants used in inlining heuristics (especially
those used in more than one file). No functional change.
llvm-svn: 83675
2009-10-09 21:42:02 +00:00
Eric Christopher
e666bc9f64
Add FreeInst to the "is a call" check for Insts that are calls, but
...
not intrinsics.
llvm-svn: 83441
2009-10-07 00:54:08 +00:00
Eric Christopher
6ba26317ce
While we still have a MallocInst treat it as a call like any other
...
for inlining.
When MallocInst goes away this code will be subsumed as part of
calls and work just fine...
llvm-svn: 83434
2009-10-07 00:02:18 +00:00
Duncan Sands
9ed7b16bf3
Introduce and use convenience methods for getting pointer types
...
where the element is of a basic builtin type. For example, to get
an i8* use getInt8PtrTy.
llvm-svn: 83379
2009-10-06 15:40:36 +00:00
Dan Gohman
e525d9ddc0
Remove an unnnecessary LLVMContext argument in
...
ConstantFoldLoadThroughGEPConstantExpr.
llvm-svn: 83311
2009-10-05 16:36:26 +00:00
Owen Anderson
b5049bebb3
Do away with the strange use of BitVectors in SSI, and just use normal sets. This makes the code much more C++/LLVM-ish.
...
llvm-svn: 83286
2009-10-04 18:49:55 +00:00
Owen Anderson
286feb16a9
Fix a typo in the comment.
...
llvm-svn: 83283
2009-10-04 17:52:13 +00:00
Owen Anderson
a62bf10651
SSI needs to require DT and DF transitively, since it uses them outside of its runOnFunction.
...
Similarly, it can be marked setPreservesAll, since it does no work in its runOnFunction.
llvm-svn: 83282
2009-10-04 17:47:39 +00:00
Dan Gohman
ea0bb8f555
Fix this code so that it doesn't try to iterate through a std::vector
...
while calling changeImmediateDominator, which removes elements from the
vector. This fixes PR5097.
llvm-svn: 83166
2009-09-30 20:54:16 +00:00
Dan Gohman
7d3b0be05b
Remove a redundant #ifndef and add an assertion string.
...
llvm-svn: 82991
2009-09-28 14:38:19 +00:00
Dan Gohman
9a7320c711
Convert LoopSimplify and LoopExtractor from FunctionPass to LoopPass.
...
llvm-svn: 82990
2009-09-28 14:37:51 +00:00
Chris Lattner
5abb1e4cd2
calls are already handled, malloc doesn't need a special case.
...
llvm-svn: 82931
2009-09-27 21:33:46 +00:00
Nick Lewycky
42fb7452df
Instruction::clone does not need to take an LLVMContext&. Remove that and
...
update all the callers.
llvm-svn: 82889
2009-09-27 07:38:41 +00:00
Dale Johannesen
fb1b55bc9c
A minor improvment in accuracy to inline cost
...
computation, and some cosmetics.
llvm-svn: 82660
2009-09-23 22:05:24 +00:00
Chris Lattner
e3ce1e2a37
tidy up
...
llvm-svn: 82488
2009-09-21 22:26:02 +00:00
Victor Hernandez
5d034499ad
Enhance transform passes so that they apply the same tranforms to malloc calls as to MallocInst.
...
Reviewed by Dan Gohman.
llvm-svn: 82300
2009-09-18 22:35:49 +00:00
Victor Hernandez
788eaabd18
Update malloc call creation code (AllocType is now the element type of the malloc, not the resulting type).
...
In getMallocArraySize(), fix bug in the case that array size is the product of 2 constants.
Extend isArrayMalloc() and getMallocArraySize() to handle case where malloc is used as char array.
Ensure that ArraySize in LowerAllocations::runOnBasicBlock() is correct type.
Extend Instruction::isSafeToSpeculativelyExecute() to handle malloc calls.
Add verification for malloc calls.
Reviewed by Dan Gohman.
llvm-svn: 82257
2009-09-18 19:20:02 +00:00
Andreas Neustifter
f8cb758ba8
Preserve ProfileInfo during CodeGenPrepare.
...
llvm-svn: 82034
2009-09-16 09:26:52 +00:00
Nick Lewycky
dddf5dcdaf
Correctly handle the case where a comparison is created in one BasicBlock and
...
used by a terminator in another.
llvm-svn: 81437
2009-09-10 07:02:09 +00:00
Evan Cheng
1d9d4bdc99
Add malloc call utility functions. Patch by Victor Hernandez.
...
llvm-svn: 81426
2009-09-10 04:36:43 +00:00
Dan Gohman
ec4557f324
Fix SplitCriticalEdge to properly update LCSSA form when splitting a
...
loop exit edge -- new PHIs may be needed not only for the additional
splits that are made to preserve LoopSimplify form, but also for the
original split. Factor out the code that inserts new PHIs so that it
can be used for both. Remove LoopRotation.cpp's code for manually
updating LCSSA form, as it is now redundant. This fixes PR4934.
llvm-svn: 81363
2009-09-09 18:18:18 +00:00
Andreas Neustifter
4c0b2847ef
Preserve ProfileInfo.
...
llvm-svn: 81360
2009-09-09 17:53:39 +00:00
Dan Gohman
3ddbc242fb
Re-apply r80926, with fixes: keep the domtree informed of new blocks
...
that get created during loop unswitching, and fix SplitBlockPredecessors'
LCSSA updating code to create new PHIs instead of trying to just move
existing ones.
Also, optimize Loop::verifyLoop, since it gets called a lot. Use
searches on a sorted list of blocks instead of calling the "contains"
function, as is done in other places in the Loop class, since "contains"
does a linear search. Also, don't call verifyLoop from LoopSimplify or
LCSSA, as the PassManager is already calling verifyLoop as part of
LoopInfo's verifyAnalysis.
llvm-svn: 81221
2009-09-08 15:45:00 +00:00
Eric Christopher
66d8555f7e
Fix comment.
...
llvm-svn: 81138
2009-09-06 22:20:54 +00:00
Evan Cheng
904199547b
Revert r80926. It causes loop unswitch assertion and slow down some JIT tests significantly.
...
llvm-svn: 81101
2009-09-06 02:26:10 +00:00
Dan Gohman
4c1bdcf5d7
Add a verifyAnalysis to LoopInfo, LoopSimplify, and LCSSA form that verify
...
that these passes are properly preserved.
Fix several transformation passes that claimed to preserve LoopSimplify
form but weren't.
llvm-svn: 80926
2009-09-03 16:31:42 +00:00
Dan Gohman
22571485b3
Change PHINode::hasConstantValue to have a DominatorTree argument
...
instead of a bool argument, and to do the dominator check itself.
This makes it eaiser to use when DominatorTree information is
available.
llvm-svn: 80920
2009-09-03 15:34:35 +00:00
Gabor Greif
2d60e1ec0c
back out my recent commit (r80858), it seems to break self-hosting buildbot's stage 2 configure
...
llvm-svn: 80871
2009-09-03 02:02:59 +00:00
Gabor Greif
14dfba6d66
re-commit r66920 (which has been backed out in r66953) I may have more luck this time. I'll back out if needed...
...
llvm-svn: 80858
2009-09-03 00:18:58 +00:00
Chris Lattner
8900f3ec57
remove a bunch of explicit code previously needed to update the
...
callgraph. This is now dead because RAUW does the job.
llvm-svn: 80703
2009-09-01 18:44:06 +00:00
Chris Lattner
063d06527e
Change CallGraphNode to maintain it's Function as an AssertingVH
...
for sanity. This didn't turn up any bugs.
Change CallGraphNode to maintain its "callsite" information in the
call edges list as a WeakVH instead of as an instruction*. This fixes
a broad class of dangling pointer bugs, and makes CallGraph have a number
of useful invariants again. This fixes the class of problem indicated
by PR4029 and PR3601.
llvm-svn: 80663
2009-09-01 06:31:31 +00:00
Devang Patel
80ae34974b
Reapply 79977.
...
Use MDNodes to encode debug info in llvm IR.
llvm-svn: 80406
2009-08-28 23:24:31 +00:00
Chris Lattner
1ce61b82ac
unbreak the build, yay for symlinks + makefiles. :(
...
llvm-svn: 80205
2009-08-27 04:43:05 +00:00
Chris Lattner
b1cba3f91e
enhance InlineFunction to be able to optionally return
...
a the list of static allocas that it inlined.
llvm-svn: 80203
2009-08-27 04:20:52 +00:00
Chris Lattner
d84dbb3443
smallvectorize the list of returns built by CloneAndPruneFunctionInto.
...
llvm-svn: 80202
2009-08-27 04:02:30 +00:00
Chris Lattner
9d0235dc6b
remove CloneTrace, which appears to be dead since 2004.
...
llvm-svn: 80201
2009-08-27 03:56:43 +00:00
Chris Lattner
5eef6ad6a9
reduce inlining factor some stuff out to a static helper function,
...
and other code cleanups. No functionality change.
llvm-svn: 80199
2009-08-27 03:51:50 +00:00
Devang Patel
f08e35d9dc
Revert 79977. It causes llvm-gcc bootstrap failures on some platforms.
...
llvm-svn: 80073
2009-08-26 05:01:18 +00:00
Dan Gohman
ad1f0a1101
Eliminate the unused Context argument on one of the ICmpInst and FCmpInst
...
constructors.
llvm-svn: 80049
2009-08-25 23:17:54 +00:00
Dan Gohman
c8a27f2a5c
Rename Instruction::isIdenticalTo to Instruction::isIdenticalToWhenDefined,
...
and introduce a new Instruction::isIdenticalTo which tests for full
identity, including the SubclassOptionalData flags. Also, fix the
Instruction::clone implementations to preserve the SubclassOptionalData
flags. Finally, teach several optimizations how to handle
SubclassOptionalData correctly, given these changes.
This fixes the counterintuitive behavior of isIdenticalTo not comparing
the full value, and clone not returning an identical clone, as well as
some subtle bugs that could be caused by these.
Thanks to Nick Lewycky for reporting this, and for an initial patch!
llvm-svn: 80038
2009-08-25 22:11:20 +00:00
Owen Anderson
4e9ac2a34b
Comment-ify.
...
llvm-svn: 80009
2009-08-25 17:42:07 +00:00
Owen Anderson
f18cae4979
Switch to SmallVector.
...
llvm-svn: 80007
2009-08-25 17:35:37 +00:00
Owen Anderson
5e39d1deec
Pull out this predicate loop into a helper function.
...
llvm-svn: 80006
2009-08-25 17:26:32 +00:00
Devang Patel
02aac922b4
Update DebugInfo interface to use metadata, instead of special named llvm.dbg.... global variables, to encode debugging information in llvm IR. This is mostly a mechanical change that tests metadata support very well.
...
This change speeds up llvm-gcc by more then 6% at "-O0 -g" (measured by compiling InstructionCombining.cpp!)
llvm-svn: 79977
2009-08-25 05:24:07 +00:00
Owen Anderson
34e6148dc8
Handle a corner case when extracing code regions where one of the immediate successor
...
of an extracted block contains a PHI using a value defined in the extracted region.
With this patch, the partial inliner now passes MultiSource/Applications.
llvm-svn: 79963
2009-08-25 00:54:39 +00:00
Owen Anderson
b4aa5b1511
When extracting SEME regions of code, the extractor needs to update the dominator tree for split return blocks.
...
llvm-svn: 79957
2009-08-24 23:32:14 +00:00
Daniel Dunbar
5e0a58bef4
Fix -Asserts warnings.
...
llvm-svn: 79849
2009-08-23 10:29:55 +00:00
Chris Lattner
1362602eb2
Change Pass::print to take a raw ostream instead of std::ostream,
...
update all code that this affects.
llvm-svn: 79830
2009-08-23 06:03:38 +00:00
Chris Lattner
b25de3ff60
eliminate the "Value" printing methods that print to a std::ostream.
...
This required converting a bunch of stuff off DOUT and other cleanups.
llvm-svn: 79819
2009-08-23 04:37:46 +00:00
Nick Lewycky
cbfe9b195c
Fix up PHI nodes correctly in the presence of unreachable BBs, part two. Also
...
delete a newed pointer, and improve readability a little bit.
llvm-svn: 79411
2009-08-19 07:16:57 +00:00
Nick Lewycky
9ddc52d5b8
Be more careful when modifying PHI nodes. Patch by Andre Tavares.
...
llvm-svn: 79407
2009-08-19 06:24:33 +00:00
Dan Gohman
7cb92a1e3d
Update comments to new-style syntax.
...
llvm-svn: 79263
2009-08-17 18:45:31 +00:00
Nick Lewycky
4c737147e1
Don't crash on critical edge. Patch by Andre Tavares.
...
llvm-svn: 79252
2009-08-17 17:00:57 +00:00
Eli Friedman
d56fca4708
Fix for PR3016: detect the tricky case, where there are
...
unfoldable references to a PHI node in the block being folded, and disable
the transformation in that case. The correct transformation of such PHI
nodes depends on whether BB dominates Succ, and dominance is expensive
to compute here. (Alternatively, it's possible to check whether any
uses are live, but that's also essentially a dominance calculation.
Another alternative is to use reg2mem, but it probably isn't a good idea to
use that in simplifycfg.)
Also, remove some incorrect code from CanPropagatePredecessorsForPHIs
which is made unnecessary with this patch: it didn't consider the case
where a PHI node in BB has multiple uses.
llvm-svn: 79174
2009-08-16 04:23:49 +00:00
Nick Lewycky
dd0e74ceee
SSI construction should just go ahead and ignore instructions in unreachable
...
blocks.
llvm-svn: 79132
2009-08-15 20:12:18 +00:00
Owen Anderson
a42ac6953b
Actually privatize a IntegerTypes, and fix a few bugs exposed by this.
...
llvm-svn: 78955
2009-08-13 23:27:32 +00:00
Owen Anderson
55f1c09e31
Push LLVMContexts through the IntegerType APIs.
...
llvm-svn: 78948
2009-08-13 21:58:54 +00:00
Dan Gohman
5476cfdb15
Remove a bunch more now-unnecessary Context arguments.
...
llvm-svn: 78809
2009-08-12 16:23:25 +00:00
Dan Gohman
38484ceec9
Remove unnecessary casts.
...
llvm-svn: 78664
2009-08-11 15:15:10 +00:00
Dan Gohman
a6d0afcb74
Fix a bunch of namespace pollution.
...
llvm-svn: 78363
2009-08-07 01:32:21 +00:00
Owen Anderson
03cb69fbd1
Privatize the StructType table, which unfortunately involves routing contexts through a number of APIs.
...
llvm-svn: 78258
2009-08-05 23:16:16 +00:00
Owen Anderson
5a1acd9912
Move a few more APIs back to 2.5 forms. The only remaining ones left to change back are
...
metadata related, which I'm waiting on to avoid conflicting with Devang.
llvm-svn: 77721
2009-07-31 20:28:14 +00:00