summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
Commit message (Collapse)AuthorAgeFilesLines
...
* Start removing the use of an ad-hoc 'never inline' set and insteadChandler Carruth2012-03-163-34/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | directly query the function information which this set was representing. This simplifies the interface of the inline cost analysis, and makes the always-inline pass significantly more efficient. Previously, always-inline would first make a single set of every function in the module *except* those marked with the always-inline attribute. It would then query this set at every call site to see if the function was a member of the set, and if so, refuse to inline it. This is quite wasteful. Instead, simply check the function attribute directly when looking at the callsite. The normal inliner also had similar redundancy. It added every function in the module with the noinline attribute to its set to ignore, even though inside the cost analysis function we *already tested* the noinline attribute and produced the same result. The only tricky part of removing this is that we have to be able to correctly remove only the functions inlined by the always-inline pass when finalizing, which requires a bit of a hack. Still, much less of a hack than the set of all non-always-inline functions was. While I was touching this function, I switched a heavy-weight set to a vector with sort+unique. The algorithm already had a two-phase insert and removal pattern, we were just needlessly paying the uniquing cost on every insert. This probably speeds up some compiles by a small amount (-O0 compiles with lots of always-inline, so potentially heavy libc++ users), but I've not tried to measure it. I believe there is no functional change here, but yell if you spot one. None are intended. Finally, the direction this is going in is to greatly simplify the inline cost query interface so that we can replace its implementation with a much more clever one. Along the way, all the APIs get simplified, so it seems incrementally good. llvm-svn: 152903
* LSR fix: Add isSimplifiedLoopNest to IVUsers analysis.Andrew Trick2012-03-163-12/+22
| | | | | | | | | | | | | | Only record IVUsers that are dominated by simplified loop headers. Otherwise SCEVExpander will crash while looking for a preheader. I previously tried to work around this in LSR itself, but that was insufficient. This way, LSR can continue to run if some uses are not in simple loops, as long as we don't attempt to analyze those users. Fixes <rdar://problem/11049788> Segmentation fault: 11 in LoopStrengthReduce llvm-svn: 152892
* In InstCombiner::visitOr, make sure we reverse the operand swap used for ↵Eli Friedman2012-03-161-1/+7
| | | | | | checking for or-of-xor operations after those checks; a later check expects that any constant will be in Op1. PR12234. llvm-svn: 152884
* Short term fix for pr12270 before we change dominates to handle unreachableRafael Espindola2012-03-151-29/+33
| | | | | | | code. While here, reduce indentation. llvm-svn: 152803
* Use an iterator instead of calling .size() on the worklist every time, which ↵Bill Wendling2012-03-151-2/+2
| | | | | | is wasteful. llvm-svn: 152794
* Remove the basic inliner. This was added in 2007, and hasn't reallyChandler Carruth2012-03-152-183/+0
| | | | | | | changed since. No one was using it. It is yet another consumer of the InlineCost interface that I'd like to change. llvm-svn: 152769
* This pass didn't want the inline cost per-se, it just wants generic codeChandler Carruth2012-03-151-1/+1
| | | | | | metrics. llvm-svn: 152760
* Fixed a transform crash when setting a negative size value for memset. ↵Aaron Ballman2012-03-151-2/+6
| | | | | | Fixes PR12202. llvm-svn: 152756
* [tsan] use FunctionBlackListKostya Serebryany2012-03-141-0/+9
| | | | llvm-svn: 152755
* [asan] rename class BlackList to FunctionBlackList and move it into a ↵Kostya Serebryany2012-03-144-70/+120
| | | | | | separate file -- we will need the same functionality in ThreadSanitizer llvm-svn: 152753
* When an invoke is marked with metadata indicating its unwind edgeDan Gohman2012-03-141-1/+2
| | | | | | | should be ignored by ARC optimization, don't insert new ARC runtime calls in the unwind destination. llvm-svn: 152748
* Change where we enable the heuristic that delays inlining into functionsChandler Carruth2012-03-141-7/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | which are small enough to themselves be inlined. Delaying in this manner can be harmful if the function is inelligible for inlining in some (or many) contexts as it pessimizes the code of the function itself in the event that inlining does not eventually happen. Previously the check was written to only do this delaying of inlining for static functions in the hope that they could be entirely deleted and in the knowledge that all callers of static functions will have the opportunity to inline if it is in fact profitable. However, with C++ we get two other important sources of functions where the definition is always available for inlining: inline functions and templated functions. This patch generalizes the inliner to allow linkonce-ODR (the linkage such C++ routines receive) to also qualify for this delay-based inlining. Benchmarking across a range of large real-world applications shows roughly 2% size increase across the board, but an average speedup of about 0.5%. Some benhcmarks improved over 2%, and the 'clang' binary itself (when bootstrapped with this feature) shows a 1% -O0 performance improvement when run over all Sema, Lex, and Parse source code smashed into a single file. A clean re-build of Clang+LLVM with a bootstrapped Clang shows approximately 2% improvement, but that measurement is often noisy. llvm-svn: 152737
* Target override to allow CodeGenPrepare to sink address operands to ↵Pete Cooper2012-03-131-0/+9
| | | | | | intrinsics in the same way it current does for loads and stores llvm-svn: 152666
* enhance jump threading to preserve TBAA information when PRE'ing loads,Chris Lattner2012-03-131-1/+12
| | | | | | | fixing rdar://11039258, an issue that came up when inspecting clang's bootstrapped codegen. llvm-svn: 152635
* Teach globalopt how to evaluate an invoke with a non-void return type.Dan Gohman2012-03-131-5/+6
| | | | llvm-svn: 152634
* When inlining a function and adding its inner call sites to theChandler Carruth2012-03-121-1/+35
| | | | | | | | | | | | | | candidate set for subsequent inlining, try to simplify the arguments to the inner call site now that inlining has been performed. The goal here is to propagate and fold constants through deeply nested call chains. Without doing this, we loose the inliner bonus that should be applied because the arguments don't match the exact pattern the cost estimator uses. Reviewed on IRC by Benjamin Kramer. llvm-svn: 152556
* llvm::SwitchInstStepan Dyatkovskiy2012-03-119-27/+27
| | | | | | | Renamed methods caseBegin, caseEnd and caseDefault with case_begin, case_end, and case_default. Added some notes relative to case iterators. llvm-svn: 152532
* Add statistics on removed switch cases, and fix the phi statisticDuncan Sands2012-03-091-1/+5
| | | | | | to count the number of phis changed, not the number visited. llvm-svn: 152425
* When identifying exit nodes for the reverse-CFG reverse-post-orderDan Gohman2012-03-091-2/+8
| | | | | | | | | traversal, consider nodes for which the only successors are backedges which the traversal is ignoring to be exit nodes. This fixes a problem where the bottom-up traversal was failing to visit split blocks along split loop backedges. This fixes rdar://10989035. llvm-svn: 152421
* Eliminate switch cases that can never match, for example removes allDuncan Sands2012-03-091-0/+86
| | | | | | | negative switch cases if the branch condition is known to be positive. Inspired by a recent improvement to GCC's VRP. llvm-svn: 152405
* Taken into account Duncan's comments for r149481 dated by 2nd Feb 2012:Stepan Dyatkovskiy2012-03-0812-89/+92
| | | | | | | | | | | | | | | | | | | | | | | | | | | http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20120130/136146.html Implemented CaseIterator and it solves almost all described issues: we don't need to mix operand/case/successor indexing anymore. Base iterator class is implemented as a template since it may be initialized either from "const SwitchInst*" or from "SwitchInst*". ConstCaseIt is just a read-only iterator. CaseIt is read-write iterator; it allows to change case successor and case value. Usage of iterator allows totally remove resolveXXXX methods. All indexing convertions done automatically inside the iterator's getters. Main way of iterator usage looks like this: SwitchInst *SI = ... // intialize it somehow for (SwitchInst::CaseIt i = SI->caseBegin(), e = SI->caseEnd(); i != e; ++i) { BasicBlock *BB = i.getCaseSuccessor(); ConstantInt *V = i.getCaseValue(); // Do something. } If you want to convert case number to TerminatorInst successor index, just use getSuccessorIndex iterator's method. If you want initialize iterator from TerminatorInst successor index, use CaseIt::fromSuccessorIndex(...) method. There are also related changes in llvm-clients: klee and clang. llvm-svn: 152297
* fix typosSebastian Pop2012-03-051-7/+7
| | | | llvm-svn: 152035
* remove spaces on empty linesSebastian Pop2012-03-051-9/+9
| | | | llvm-svn: 152034
* This is not a common case, in fact it never happens!Duncan Sands2012-03-051-4/+0
| | | | llvm-svn: 152027
* Switch mem2reg to use the new hashing infrastructure.Chandler Carruth2012-03-051-1/+3
| | | | llvm-svn: 152026
* Replace the ad-hoc hashing in GVN with the new hashing infrastructure.Chandler Carruth2012-03-051-10/+13
| | | | | | | | | | | | | | | | | This implicitly fixes a nasty bug in the GVN hashing (that thankfully could only manifest as a performance bug): actually include the opcode in the hash. The old code started the hash off with the opcode, but then overwrote it with the type pointer. Since this is likely to be pretty hot (GVN being already pretty expensive) I've included a micro-optimization to just not bother with the varargs hashing if they aren't present. I can't measure any change in GVN performance due to this, even with a big test case like Duncan's sqlite one. Everything I see is in the noise floor. That said, this closes a loop hole for a potential scaling problem due to collisions if the opcode were the differentiating aspect of the expression. llvm-svn: 152025
* Nick pointed out on IRC that GVN's propagateEquality wasn't propagatingDuncan Sands2012-03-041-1/+11
| | | | | | | | | | equalities into phi node operands for which the equality is known to hold in the incoming basic block. That's because replaceAllDominatedUsesWith wasn't handling phi nodes correctly in general (that this didn't give wrong results was just luck: the specific way GVN uses replaceAllDominatedUsesWith precluded wrong changes to phi nodes). llvm-svn: 152006
* Do trivial CSE of dead BBs during codegen preparation.Bill Wendling2012-03-041-1/+20
| | | | | | | | Some BBs can become dead after codegen preparation. If we delete them here, it could help enable tail-call optimizations later on. <rdar://problem/10256573> llvm-svn: 152002
* ASan: use getTypeAllocSize instead of getTypeStoreSize.Evgeniy Stepanov2012-03-021-1/+1
| | | | | | | | | | | | | | | | This change replaces getTypeStoreSize with getTypeAllocSize in AddressSanitizer instrumentation for stack allocations. One case where old behaviour produced undesired results is an optimization in InstCombine pass (PromoteCastOfAllocation), which can replace alloca(T) with alloca(S), where S has the same AllocSize, but a smaller StoreSize. Another case is memcpy(long double => long double), where ASan will poison bytes 10-15 of a stack-allocated long double (StoreSize 10, AllocSize 16, sizeof(long double) = 16). See http://llvm.org/bugs/show_bug.cgi?id=12047 for more context. llvm-svn: 151887
* Fix an iterator invalidation problem. operator[] on a DenseMapDan Gohman2012-03-021-8/+28
| | | | | | | can insert a new element, invalidating iterators. Use find instead, and handle the case where the key is not found explicitly. llvm-svn: 151871
* Misc micro-optimizations.Dan Gohman2012-03-021-10/+12
| | | | llvm-svn: 151869
* Have GVN also do condition propagation when the right-hand side is notDuncan Sands2012-02-291-11/+20
| | | | | | a constant. This fixes PR1768. llvm-svn: 151713
* Restrict this transformation to equality conditions.Bill Wendling2012-02-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This transformation is not correct for not-equal conditions: (trunc x) != C1 & (and x, CA) != C2 -> (and x, CA|CMAX) != C1|C2 Let C1 == 0 C2 == 0 CA == 0xFF0000 CMAX == 0xFF and truncating to i8. The original truth table: x | A: trunc x != 0 | B: x & 0xFF0000 != 0 | A & B != 0 -------------------------------------------------------------- 0x00000 | 0 | 0 | 0 0x00001 | 1 | 0 | 0 0x10000 | 0 | 1 | 0 0x10001 | 1 | 1 | 1 The truth table of the replacement: x | x & 0xFF00FF != 0 ---------------------------- 0x00000 | 0 0x00001 | 1 0x10000 | 1 0x10001 | 1 So they are different. llvm-svn: 151691
* Reverted r152620 - DSE: Shorten memset when a later store overwrites the ↵Pete Cooper2012-02-281-66/+2
| | | | | | start of it. There were all sorts of buildbot issues llvm-svn: 151621
* DSE: Shorten memset when a later store overwrites the start of itPete Cooper2012-02-281-2/+66
| | | | llvm-svn: 151620
* Plog a memleak in GlobalOpt.Benjamin Kramer2012-02-271-1/+1
| | | | | | Found by valgrind. llvm-svn: 151525
* Micro-optimization, no functionality change.Duncan Sands2012-02-271-7/+12
| | | | llvm-svn: 151524
* The value numbering function is recursive, so it is possible for multiple newDuncan Sands2012-02-271-2/+2
| | | | | | | | value numbers to be assigned when calculating any particular value number. Enhance the logic that detects new value numbers to take this into account, for a tiny compile time speedup. Fix a comment typo while there. llvm-svn: 151522
* When performing a conditional branch depending on the value of a comparisonDuncan Sands2012-02-271-4/+62
| | | | | | | | | %cmp (eg: A==B) we already replace %cmp with "true" under the true edge, and with "false" under the false edge. This change enhances this to replace the negated compare (A!=B) with "false" under the true edge and "true" under the false edge. Reported to improve perlbench results by 1%. llvm-svn: 151517
* Add comment.Chad Rosier2012-02-252-2/+3
| | | | llvm-svn: 151431
* Add support for disabling llvm.lifetime intrinsics in the AlwaysInliner. TheseChad Rosier2012-02-254-14/+23
| | | | | | | | are optimization hints, but at -O0 we're not optimizing. This becomes a problem when the alwaysinline attribute is abused. rdar://10921594 llvm-svn: 151429
* Fix indentation.Chad Rosier2012-02-251-2/+1
| | | | llvm-svn: 151420
* Teach GVN that x+y is the same as y+x and that x<y is the same as y>x.Duncan Sands2012-02-241-1/+16
| | | | llvm-svn: 151365
* Reflow code, no functionality change.Benjamin Kramer2012-02-231-17/+12
| | | | llvm-svn: 151262
* GCC fails to understand that NextBB is always initialized if EvaluateBlockDuncan Sands2012-02-231-1/+1
| | | | | | returns 'true' and emits a warning. Help it out. llvm-svn: 151242
* Use the target-aware constant folder on expressions to improve the chanceNick Lewycky2012-02-211-2/+9
| | | | | | | | | | | | | they'll be simple enough to simulate, and to reduce the chance we'll encounter equal but different simple pointer constants. This removes the symptoms from PR11352 but is not a full fix. A proper fix would either require a guarantee that two constant objects we simulate are folded when equal, or a different way of handling equal pointers (ie., trying a constantexpr icmp on them to see whether we know they're equal or non-equal or unsure). llvm-svn: 151093
* Fix unsigned off-by-one in comment.Benjamin Kramer2012-02-211-1/+1
| | | | llvm-svn: 151056
* InstCombine: Don't transform a signed icmp of two GEPs into a signed compare ↵Benjamin Kramer2012-02-211-0/+8
| | | | | | | | | | | of the indices. This transformation is not safe in some pathological cases (signed icmp of pointers should be an extremely rare thing, but it's valid IR!). Add an explanatory comment. Kudos to Duncan for pointing out this edge case (and not giving up explaining it until I finally got it). llvm-svn: 151055
* Check for the correct size in the invariant marker.Nick Lewycky2012-02-201-4/+7
| | | | llvm-svn: 151003
* Fix 80-column violation.Chad Rosier2012-02-201-1/+2
| | | | llvm-svn: 150998
OpenPOWER on IntegriCloud