aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms
Commit message (Collapse)AuthorAgeFilesLines
...
* Change CallGraphNode to maintain it's Function as an AssertingVHChris Lattner2009-09-012-8/+4
| | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80663 91177308-0d34-0410-b5e6-96231b3b80d8
* fix some cases where instcombine would change hte IR but not return trueChris Lattner2009-08-311-8/+10
| | | | | | | from runOnFunction git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80562 91177308-0d34-0410-b5e6-96231b3b80d8
* comment and simplify some code.Chris Lattner2009-08-311-19/+14
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80540 91177308-0d34-0410-b5e6-96231b3b80d8
* add -debug outputChris Lattner2009-08-311-0/+4
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80539 91177308-0d34-0410-b5e6-96231b3b80d8
* improve -debug output, so that -debug is more likely to print whenChris Lattner2009-08-311-3/+6
| | | | | | | instcombine is changing stuff. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80538 91177308-0d34-0410-b5e6-96231b3b80d8
* fix a bug I introduced with my 'instcombine builder' refactoring Chris Lattner2009-08-311-2/+6
| | | | | | | | | changes: SimplifyDemandedBits can't use the builder yet because it has the wrong insertion point. This fixes a crash building MultiSource/Benchmarks/PAQ8p git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80537 91177308-0d34-0410-b5e6-96231b3b80d8
* simplify some code by making the SCCNodes set contain Function*'sChris Lattner2009-08-311-12/+9
| | | | | | | | | | | | | | | instead of CallGraphNode*'s. This also papers over a callgraph problem where a pass (in this case, MemCpyOpt) introduces a new function into the module (llvm.memset.i64) but doesn't add it to the call graph (nor should it, since it is a function pass). While it might be a good idea for MemCpyOpt to not synthesize functions in a runOnFunction(), there is no need for FunctionAttrs to be boneheaded, so fix it there. This fixes an assertion building 176.gcc. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80535 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix PR4834, a tricky case where the inliner would resolve anChris Lattner2009-08-311-6/+9
| | | | | | | | | | | | | | | | indirect function pointer, inline it, then go to delete the body. The problem is that the callgraph had other references to the function, though the inliner had no way to know it, so we got a dangling pointer and an invalid iterator out of the deal. The fix to this is pretty simple: stop the inliner from deleting the function by knowing that there are references to it. Do this by making CallGraphNodes contain a refcount. This requires moving deletion of available_externally functions to the module-level cleanup sweep where it belongs. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80533 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix some nasty callgraph dangling pointer problems in Chris Lattner2009-08-315-54/+75
| | | | | | | | | | | | | | | | | | | | | | | | | | | argpromotion and structretpromote. Basically, when replacing a function, they used the 'changeFunction' api which changes the entry in the function map (and steals/reuses the callgraph node). This has some interesting effects: first, the problem is that it doesn't update the "callee" edges in any callees of the function in the call graph. Second, this covers for a major problem in all the CGSCC pass stuff, which is that it is completely broken when functions are deleted if they *don't* reuse a CGN. (there is a cute little fixme about this though :). This patch changes the protocol that CGSCC passes must obey: now the CGSCC pass manager copies the SCC and preincrements its iterator to avoid passes invalidating it. This allows CGSCC passes to mutate the current SCC. However multiple passes may be run on that SCC, so if passes do this, they are now required to *update* the SCC to be current when they return. Other less interesting parts of this patch are that it makes passes update the CG more directly, eliminates changeFunction, and requires clients of replaceCallSite to specify the new callee CGN if they are changing it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80527 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix PR4748: don't fold gep(bitcast(x)) into bitcast(gep) when x Chris Lattner2009-08-301-0/+7
| | | | | | | | | | is itself a bitcast. Since we have gep(bitcast(bitcast(y))) in this case, just wait for the two bitcasts to get zapped. This prevents instcombine from confusing some aliasing stuff, and allows it to directly eliminate the load in the testcase. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80508 91177308-0d34-0410-b5e6-96231b3b80d8
* misc cleanupChris Lattner2009-08-301-13/+13
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80507 91177308-0d34-0410-b5e6-96231b3b80d8
* add getPointerAddressSpace() to GEP instruction, use the methodChris Lattner2009-08-303-9/+6
| | | | | | | in a few scalar xforms to simplify things. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80506 91177308-0d34-0410-b5e6-96231b3b80d8
* eliminate InsertCastBefore, use the builder instead.Chris Lattner2009-08-301-50/+19
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80505 91177308-0d34-0410-b5e6-96231b3b80d8
* eliminate InsertBitCastBefore, just use the builder instead.Chris Lattner2009-08-301-27/+24
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80504 91177308-0d34-0410-b5e6-96231b3b80d8
* convert a bunch more calls to InsertNewInstBefore to useChris Lattner2009-08-301-205/+137
| | | | | | | the new Instcombine builder. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80501 91177308-0d34-0410-b5e6-96231b3b80d8
* fix typoChris Lattner2009-08-301-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80500 91177308-0d34-0410-b5e6-96231b3b80d8
* give instcombine a custom IRBuilder that adds new instructions to theChris Lattner2009-08-301-304/+193
| | | | | | | | | | | workslist and is set to insert new instructions before the current one. Convert a bunch of stuff that used to call InsertNewInstBefore over to use it, greatly simplifying code and making it more natural. There is still a lot more to go, but this is a good start. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80492 91177308-0d34-0410-b5e6-96231b3b80d8
* add a new InstCombineWorklist::AddValue method that works evenChris Lattner2009-08-301-16/+13
| | | | | | | | | | if the operand is not an instruction. Simplify most uses of AddOperandsToWorkList to use AddValue and inline it into the one remaining callsite. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80488 91177308-0d34-0410-b5e6-96231b3b80d8
* move AddUsersToWorkList to the worklist processing class, make theChris Lattner2009-08-301-16/+16
| | | | | | | argument stronger typed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80487 91177308-0d34-0410-b5e6-96231b3b80d8
* rename AddUsesToWorkList -> AddOperandsToWorkList. The Chris Lattner2009-08-301-31/+13
| | | | | | | | | | | former looks too much like AddUsersToWorkList and keeps confusing me. Remove AddSoonDeadInstToWorklist and change its two callers to do the same thing in a simpler way. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80486 91177308-0d34-0410-b5e6-96231b3b80d8
* inline the trivial AddToWorkList/RemoveFromWorkList methodsChris Lattner2009-08-301-104/+65
| | | | | | | | | | | | | | | into their callers. simplify ReplaceInstUsesWith. Make EraseInstFromFunction only add operands to the worklist if there aren't too many of them (this was a scalability win for crazy programs that was only infrequently enforced). Switch more code to using EraseInstFromFunction instead of duplicating it inline. Change some fcmp/icmp optimizations to modify fcmp/icmp in place instead of creating a new one and deleting the old one just to change the predicate. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80483 91177308-0d34-0410-b5e6-96231b3b80d8
* fix a bug I introduced in r80478 found by the build bot.Chris Lattner2009-08-301-1/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80482 91177308-0d34-0410-b5e6-96231b3b80d8
* refactor instcombine's worklist processing stuff out to its own class.Chris Lattner2009-08-301-26/+58
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80481 91177308-0d34-0410-b5e6-96231b3b80d8
* more cleanups: remove some redundant code, and simplify someChris Lattner2009-08-301-49/+15
| | | | | | | other places. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80478 91177308-0d34-0410-b5e6-96231b3b80d8
* eliminate the temporary SrcGEPOperands smallvector.Chris Lattner2009-08-301-18/+15
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80477 91177308-0d34-0410-b5e6-96231b3b80d8
* simplify/detangle some control flow.Chris Lattner2009-08-301-20/+15
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80476 91177308-0d34-0410-b5e6-96231b3b80d8
* simplify and cleanup some code, remove some code that just Chris Lattner2009-08-301-75/+29
| | | | | | | | | | does constant folding of gep's: this is already handled in a more general way. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80475 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove an unnecessary Context argument.Dan Gohman2009-08-291-5/+3
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80454 91177308-0d34-0410-b5e6-96231b3b80d8
* Inline empty destructor.Benjamin Kramer2009-08-292-4/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80431 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix warning about non-virtual destructor.Bill Wendling2009-08-292-0/+4
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80429 91177308-0d34-0410-b5e6-96231b3b80d8
* Reapply 79977.Devang Patel2009-08-283-122/+11
| | | | | | | Use MDNodes to encode debug info in llvm IR. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80406 91177308-0d34-0410-b5e6-96231b3b80d8
* Preparation for Optimal Edge Profiling:Andreas Neustifter2009-08-282-0/+171
| | | | | | | | | This implements the maximum spanning tree algorithm on CFGs according to weights given by the ProfileEstimator. This is then used to implement Optimal Edge Profiling. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80358 91177308-0d34-0410-b5e6-96231b3b80d8
* finish a half formed thought :)Chris Lattner2009-08-281-1/+4
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80334 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix PR3913, patch by Jakub Staszak!Chris Lattner2009-08-281-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80327 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement a new optimization in the inliner: if inlining multipleChris Lattner2009-08-271-25/+125
| | | | | | | | | | | | | | | | | | | | | calls into a function and if the calls bring in arrays, try to merge them together to reduce stack size. For example, in the testcase we'd previously end up with 4 allocas, now we end up with 2 allocas. As described in the comments, this is not really the ideal solution to this problem, but it is surprisingly effective. For example, on 176.gcc, we end up eliminating 67 arrays at "gccas" time and another 24 at "llvm-ld" time. One piece of concern that I didn't look into: at -O0 -g with forced inlining this will almost certainly result in worse debug info. I think this is acceptable though given that this is a case of "debugging optimized code", and we don't want debug info to prevent the optimizer from doing things anyway. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80215 91177308-0d34-0410-b5e6-96231b3b80d8
* unbreak the build, yay for symlinks + makefiles. :(Chris Lattner2009-08-271-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80205 91177308-0d34-0410-b5e6-96231b3b80d8
* reduce header #include'ageChris Lattner2009-08-271-1/+4
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80204 91177308-0d34-0410-b5e6-96231b3b80d8
* enhance InlineFunction to be able to optionally returnChris Lattner2009-08-271-6/+15
| | | | | | | | a the list of static allocas that it inlined. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80203 91177308-0d34-0410-b5e6-96231b3b80d8
* smallvectorize the list of returns built by CloneAndPruneFunctionInto.Chris Lattner2009-08-273-8/+8
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80202 91177308-0d34-0410-b5e6-96231b3b80d8
* remove CloneTrace, which appears to be dead since 2004.Chris Lattner2009-08-272-120/+0
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80201 91177308-0d34-0410-b5e6-96231b3b80d8
* reduce inlining factor some stuff out to a static helper function,Chris Lattner2009-08-272-213/+259
| | | | | | | and other code cleanups. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80199 91177308-0d34-0410-b5e6-96231b3b80d8
* Make this into a static method.Owen Anderson2009-08-261-15/+13
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80170 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert 79977. It causes llvm-gcc bootstrap failures on some platforms.Devang Patel2009-08-263-11/+122
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80073 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove unused variables.Dan Gohman2009-08-262-5/+0
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80058 91177308-0d34-0410-b5e6-96231b3b80d8
* Eliminate the unused Context argument on one of the ICmpInst and FCmpInstDan Gohman2009-08-254-141/+137
| | | | | | | constructors. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80049 91177308-0d34-0410-b5e6-96231b3b80d8
* Rename Instruction::isIdenticalTo to Instruction::isIdenticalToWhenDefined,Dan Gohman2009-08-254-6/+17
| | | | | | | | | | | | | | | | | 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! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80038 91177308-0d34-0410-b5e6-96231b3b80d8
* Special-case static allocas in IndVarSimplify's loop invariantDan Gohman2009-08-251-0/+5
| | | | | | | | | sinking code, since they are special. If the loop preheader happens to be the entry block of a function, don't sink static allocas out of it. This fixes PR4775. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80010 91177308-0d34-0410-b5e6-96231b3b80d8
* Comment-ify.Owen Anderson2009-08-251-0/+3
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80009 91177308-0d34-0410-b5e6-96231b3b80d8
* Switch to SmallVector.Owen Anderson2009-08-251-2/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80007 91177308-0d34-0410-b5e6-96231b3b80d8
* Pull out this predicate loop into a helper function.Owen Anderson2009-08-251-11/+15
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80006 91177308-0d34-0410-b5e6-96231b3b80d8