summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar
Commit message (Collapse)AuthorAgeFilesLines
* Remove dead code. Improve llvm_unreachable text. Simplify some control flow.Ahmed Charles2012-02-191-1/+0
| | | | llvm-svn: 150918
* Calls and invokes with the new clang.arc.no_objc_arc_exceptionsDan Gohman2012-02-171-6/+47
| | | | | | | | metadata may still unwind, but only in ways that the ARC optimizer doesn't need to consider. This permits more aggressive optimization. llvm-svn: 150829
* loop-rotate shouldn't hoist alloca instructions out of a loop. Patch by ↵Eli Friedman2012-02-161-1/+2
| | | | | | Patrik Hägglund, with slightly modified test. Issue reported by Patrik Hägglund on llvmdev. llvm-svn: 150642
* Add simplifyLoopLatch to LoopRotate pass.Andrew Trick2012-02-141-0/+103
| | | | | | This folds a simple loop tail into a loop latch. It covers the common (in fortran) case of postincrement loops. It's a "free" way to expose this type of loop to downstream loop optimizations that bail out on non-canonical loops (getLoopLatch is a heavily used check). llvm-svn: 150439
* whitespaceAndrew Trick2012-02-141-30/+30
| | | | llvm-svn: 150438
* Just like in regular escape analysis, loads and stores throughDan Gohman2012-02-131-0/+10
| | | | | | | (but not of) a block pointer do not cause the block pointer to escape. This fixes rdar://10803830. llvm-svn: 150424
* Fix various issues (or do cleanups) found by enabling certain MSVC warnings.Ahmed Charles2012-02-132-5/+4
| | | | | | | | | - Use unsigned literals when the desired result is unsigned. This mostly allows unsigned/signed mismatch warnings to be less noisy even if they aren't on by default. - Remove misplaced llvm_unreachable. - Add static to a declaration of a function on MSVC x86 only. - Change some instances of calling a static function through a variable to simply calling that function while removing the unused variable. llvm-svn: 150364
* Use Use::set rather than finding the operand number of the useDuncan Sands2012-02-081-6/+3
| | | | | | and setting that. llvm-svn: 150074
* Convert assert(0) to llvm_unreachableCraig Topper2012-02-071-2/+2
| | | | llvm-svn: 149967
* Neaten up this method. Check that if there is only oneDuncan Sands2012-02-051-3/+3
| | | | | | predecessor then it's Src. llvm-svn: 149843
* Fix a thinko pointed out by Eli and the buildbots.Duncan Sands2012-02-051-1/+1
| | | | llvm-svn: 149839
* Reduce the number of dom queries made by GVN's conditional propagationDuncan Sands2012-02-051-31/+9
| | | | | | | | | | | | logic by half: isOnlyReachableViaThisEdge was trying to be clever and handle the case of a branch to a basic block which is contained in a loop. This costs a domtree lookup and is completely useless due to GVN's position in the pass pipeline: all loops have preheaders at this point, which means it is enough for isOnlyReachableViaThisEdge to check that Dst has only one predecessor. (I checked this theoretical argument by running over the entire nightly testsuite, and indeed it is so!). llvm-svn: 149838
* Reduce the number of non-trivial domtree queries by about 1% whenDuncan Sands2012-02-051-15/+17
| | | | | | | compiling sqlite3, by only doing dom queries after the cheap check rather than interleaved with it. llvm-svn: 149836
* reapply the patches reverted in r149470 that reenable ConstantDataArray,Chris Lattner2012-02-051-56/+60
| | | | | | | | | but with a critical fix to the SelectionDAG code that optimizes copies from strings into immediate stores: the previous code was stopping reading string data at the first nul. Address this by adding a new argument to llvm::getConstantStringInfo, preserving the behavior before the patch. llvm-svn: 149800
* SwitchInst refactoring.Stepan Dyatkovskiy2012-02-014-22/+24
| | | | | | | | | | | | | | | | | The purpose of refactoring is to hide operand roles from SwitchInst user (programmer). If you want to play with operands directly, probably you will need lower level methods than SwitchInst ones (TerminatorInst or may be User). After this patch we can reorganize SwitchInst operands and successors as we want. What was done: 1. Changed semantics of index inside the getCaseValue method: getCaseValue(0) means "get first case", not a condition. Use getCondition() if you want to resolve the condition. I propose don't mix SwitchInst case indexing with low level indexing (TI successors indexing, User's operands indexing), since it may be dangerous. 2. By the same reason findCaseValue(ConstantInt*) returns actual number of case value. 0 means first case, not default. If there is no case with given value, ErrorIndex will returned. 3. Added getCaseSuccessor method. I propose to avoid usage of TerminatorInst::getSuccessor if you want to resolve case successor BB. Use getCaseSuccessor instead, since internal SwitchInst organization of operands/successors is hidden and may be changed in any moment. 4. Added resolveSuccessorIndex and resolveCaseIndex. The main purpose of these methods is to see how case successors are really mapped in TerminatorInst. 4.1 "resolveSuccessorIndex" was created if you need to level down from SwitchInst to TerminatorInst. It returns TerminatorInst's successor index for given case successor. 4.2 "resolveCaseIndex" converts low level successors index to case index that curresponds to the given successor. Note: There are also related compatability fix patches for dragonegg, klee, llvm-gcc-4.0, llvm-gcc-4.2, safecode, clang. llvm-svn: 149481
* Revert Chris' commits up to r149348 that started causing VMCoreTests unit ↵Argyrios Kyrtzidis2012-02-011-60/+56
| | | | | | | | | | | | | | | | | | | test to fail. These are: r149348 r149351 r149352 r149354 r149356 r149357 r149361 r149362 r149364 r149365 llvm-svn: 149470
* bz11794 : EarlyCSE stack overflow on long functions.Lenny Maiorani2012-01-311-22/+117
| | | | | | Make the EarlyCSE optimizer not use recursion to do a depth first iteration. llvm-svn: 149445
* Increase the initial vector size to be equivalent to the size of the DepsBill Wendling2012-01-311-2/+2
| | | | | | vector. This potentially saves a resizing. llvm-svn: 149369
* Cache the size of the vector instead of calling .size() all over the place.Bill Wendling2012-01-311-5/+5
| | | | llvm-svn: 149368
* eliminate the last uses of GetConstantStringInfo from this file, I didn't ↵Chris Lattner2012-01-311-7/+7
| | | | | | realize I was that close... llvm-svn: 149354
* start moving SimplifyLibcalls over to getConstantStringInfo, which isChris Lattner2012-01-311-49/+53
| | | | | | dramatically more efficient than GetConstantStringInfo. llvm-svn: 149352
* Typo.Chad Rosier2012-01-301-1/+1
| | | | llvm-svn: 149289
* Typo.Chad Rosier2012-01-301-1/+1
| | | | llvm-svn: 149275
* Fix typo.Nick Lewycky2012-01-281-2/+2
| | | | llvm-svn: 149185
* Continue improving support for ConstantDataAggregate, and use theChris Lattner2012-01-261-8/+7
| | | | | | new methods recently added to (sometimes greatly!) simplify code. llvm-svn: 149024
* use ConstantVector::getSplat in a few places.Chris Lattner2012-01-251-2/+1
| | | | llvm-svn: 148929
* More dead code removal (using -Wunreachable-code)David Blaikie2012-01-202-3/+1
| | | | llvm-svn: 148578
* Handle a corner case with IV chain collection with bailout instead of assert.Andrew Trick2012-01-201-2/+6
| | | | | | Fixes PR11783: bad cast to AddRecExpr. llvm-svn: 148572
* Extend Attributes to 64 bitsKostya Serebryany2012-01-201-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | Problem: LLVM needs more function attributes than currently available (32 bits). One such proposed attribute is "address_safety", which shows that a function is being checked for address safety (by AddressSanitizer, SAFECode, etc). Solution: - extend the Attributes from 32 bits to 64-bits - wrap the object into a class so that unsigned is never erroneously used instead - change "unsigned" to "Attributes" throughout the code, including one place in clang. - the class has no "operator uint64 ()", but it has "uint64_t Raw() " to support packing/unpacking. - the class has "safe operator bool()" to support the common idiom: if (Attributes attr = getAttrs()) useAttrs(attr); - The CTOR from uint64_t is marked explicit, so I had to add a few explicit CTOR calls - Add the new attribute "address_safety". Doing it in the same commit to check that attributes beyond first 32 bits actually work. - Some of the functions from the Attribute namespace are worth moving inside the class, but I'd prefer to have it as a separate commit. Tested: "make check" on Linux (32-bit and 64-bit) and Mac (10.6) built/run spec CPU 2006 on Linux with clang -O2. This change will break clang build in lib/CodeGen/CGCall.cpp. The following patch will fix it. llvm-svn: 148553
* SCEVExpander fixes. Affects LSR and indvars.Andrew Trick2012-01-202-11/+23
| | | | | | | | | | | | | | | | LSR has gradually been improved to more aggressively reuse existing code, particularly existing phi cycles. This exposed problems with the SCEVExpander's sloppy treatment of its insertion point. I applied some rigor to the insertion point problem that will hopefully avoid an endless bug cycle in this area. Changes: - Always used properlyDominates to check safe code hoisting. - The insertion point provided to SCEV is now considered a lower bound. This is usually a block terminator or the use itself. Under no cirumstance may SCEVExpander insert below this point. - LSR is reponsible for finding a "canonical" insertion point across expansion of different expressions. - Robust logic to determine whether IV increments are in "expanded" form and/or can be safely hoisted above some insertion point. Fixes PR11783: SCEVExpander assert. llvm-svn: 148535
* Set the "tail" flag on pattern-matched objc_storeStrong calls.Dan Gohman2012-01-191-0/+32
| | | | | | rdar://10531041. llvm-svn: 148490
* Add a depth limit to avoid runaway recursion.Dan Gohman2012-01-181-3/+7
| | | | llvm-svn: 148419
* Use llvm.global_ctors to locate global constructors insteadDan Gohman2012-01-181-6/+19
| | | | | | of recognizing them by name. llvm-svn: 148416
* Remove trailing spaces and unneeded includes.Jakub Staszak2012-01-181-134/+131
| | | | llvm-svn: 148415
* Add a new ObjC ARC optimization pass to eliminate unneededDan Gohman2012-01-172-1/+118
| | | | | | autorelease push+pop pairs. llvm-svn: 148330
* LSR fix: broaden the check for loop preheaders.Andrew Trick2012-01-171-5/+13
| | | | | | | It's becoming clear that LoopSimplify needs to unconditionally create loop preheaders. But that is a bigger fix. For now, continuing to hack LSR. Fixes rdar://10701050 "Cannot split an edge from an IndirectBrInst" assert. llvm-svn: 148288
* Remove unreachable code. (replace with llvm_unreachable to help GCC where ↵David Blaikie2012-01-171-1/+0
| | | | | | necessary) llvm-svn: 148284
* Fixed comment in loop-unswitch.Stepan Dyatkovskiy2012-01-161-1/+1
| | | | llvm-svn: 148252
* Cosmetic patch for r148215.Stepan Dyatkovskiy2012-01-151-13/+0
| | | | llvm-svn: 148216
* Fixup for r148132. Type replacement for LoopsProperties: from DenseMap to ↵Stepan Dyatkovskiy2012-01-151-114/+180
| | | | | | | | | std::map, since we need to keep a valid pointer to properties of current loop. Message for r148132: LoopUnswitch: All helper data that is collected during loop-unswitch iterations was moved to separated class (LUAnalysisCache). llvm-svn: 148215
* Fix an unused variable warning that Chad noticed.Dan Gohman2012-01-141-1/+1
| | | | llvm-svn: 148164
* Speculatively revert r148132+r148133 to try and fix a buildbot failure.Eli Friedman2012-01-131-166/+115
| | | | llvm-svn: 148149
* Cosmetic patch for r148132.Stepan Dyatkovskiy2012-01-131-13/+1
| | | | llvm-svn: 148133
* LoopUnswitch: All helper data that is collected during loop-unswitch ↵Stepan Dyatkovskiy2012-01-131-112/+175
| | | | | | iterations was moved to separated class (LUAnalysisCache). llvm-svn: 148132
* Implement proper ObjC ARC objc_retainBlock "escape" analysis, so thatDan Gohman2012-01-131-45/+63
| | | | | | | | the optimizer doesn't eliminate objc_retainBlock calls which are needed for their side effect of copying blocks onto the heap. This implements rdar://10361249. llvm-svn: 148076
* Improved compile time:Stepan Dyatkovskiy2012-01-111-38/+98
| | | | | | | | | | | | 1. Size heuristics changed. Now we calculate number of unswitching branches only once per loop. 2. Some checks was moved from UnswitchIfProfitable to processCurrentLoop, since it is not changed during processCurrentLoop iteration. It allows decide to skip some loops at an early stage. Extended statistics: - Added total number of instructions analyzed. llvm-svn: 147935
* Enable LSR IV Chains with sufficient heuristics.Andrew Trick2012-01-101-5/+210
| | | | | | | | | | | | | | | | | | | | | | | | | These heuristics are sufficient for enabling IV chains by default. Performance analysis has been done for i386, x86_64, and thumbv7. The optimization is rarely important, but can significantly speed up certain cases by eliminating spill code within the loop. Unrolled loops are prime candidates for IV chains. In many cases, the final code could still be improved with more target specific optimization following LSR. The goal of this feature is for LSR to make the best choice of induction variables. Instruction selection may not completely take advantage of this feature yet. As a result, there could be cases of slight code size increase. Code size can be worse on x86 because it doesn't support postincrement addressing. In fact, when chains are formed, you may see redundant address plus stride addition in the addressing mode. GenerateIVChains tries to compensate for the common cases. On ARM, code size increase can be mitigated by using postincrement addressing, but downstream codegen currently misses some opportunities. llvm-svn: 147826
* Adding IV chain generation to LSR.Andrew Trick2012-01-091-5/+228
| | | | | | | | | | | | | | | | | | After collecting chains, check if any should be materialized. If so, hide the chained IV users from the LSR solver. LSR will only solve for the head of the chain. GenerateIVChains will then materialize the chained IV users by computing the IV relative to its previous value in the chain. In theory, chained IV users could be exposed to LSR's solver. This would be considerably complicated to implement and I'm not aware of a case where we need it. In practice it's more important to intelligently prune the search space of nontrivial loops before running the solver, otherwise the solver is often forced to prune the most optimal solutions. Hiding the chained users does this well, so that LSR is more likely to find the best IV for the chain as a whole. llvm-svn: 147801
* Adding collection of IV chains to LSR.Andrew Trick2012-01-091-0/+242
| | | | | | | | This collects a set of IV uses within the loop whose values can be computed relative to each other in a sequence. Following checkins will make use of this information. llvm-svn: 147797
* "Minor LSR debugging stuff"Andrew Trick2012-01-091-1/+4
| | | | llvm-svn: 147785
OpenPOWER on IntegriCloud