aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Analysis
Commit message (Collapse)AuthorAgeFilesLines
* Make helper static, so it can be inlined into its sole caller.Benjamin Kramer2012-03-101-3/+3
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152515 91177308-0d34-0410-b5e6-96231b3b80d8
* As Duncan pointed out, pointers tend not to be in floating point ↵Bill Wendling2012-03-101-6/+6
| | | | | | format...for now. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152499 91177308-0d34-0410-b5e6-96231b3b80d8
* Make this transformation slightly less agressive and more correct.Bill Wendling2012-03-101-8/+18
| | | | | | | | | | | | The 'CmpInst::isFalseWhenEqual' function returns 'false' for values other than simply equality. For instance, it returns 'false' for <= or >=. This isn't the correct behavior for this transformation, which is checking for strict equality and non-equality. It was causing the gcc.c-torture/execute/frame-address.c test to fail because it would completely (and incorrectly) optimize a whole function into a 'ret i32 0'. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152497 91177308-0d34-0410-b5e6-96231b3b80d8
* Refactor some methods to look through bitcasts and GEPs on pointers intoChandler Carruth2012-03-101-25/+3
| | | | | | | | | | a common collection of methods on Value, and share their implementation. We had two variations in two different places already, and I need the third variation for inline cost estimation. Reviewed by Duncan Sands on IRC, but further comments here welcome. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152490 91177308-0d34-0410-b5e6-96231b3b80d8
* Factor out the analysis of addition and subtraction in ComputeMaskedBits. ReuseNick Lewycky2012-03-091-83/+123
| | | | | | | it to analyze extractvalue(llvm.[us](add|sub).with.overflow.*) intrinsics! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152398 91177308-0d34-0410-b5e6-96231b3b80d8
* Undo a previous restriction on the inline cost calculation which NickChandler Carruth2012-03-091-107/+146
| | | | | | | | | | | | | | | | | | | | | | introduced. Specifically, there are cost reductions for all constant-operand icmp instructions against an alloca, regardless of whether the alloca will in fact be elligible for SROA. That means we don't want to abort the icmp reduction computation when we abort the SROA reduction computation. That in turn frees us from the need to keep a separate worklist and defer the ICmp calculations. Use this new-found freedom and some judicious function boundaries to factor the innards of computing the cost factor of any given instruction out of the loop over the instructions and into static helper functions. This greatly simplifies the code, and hopefully makes it more clear what is happening here. Reviewed by Eric Christopher. There is some concern that we'd like to ensure this doesn't get out of hand, and I plan to benchmark the effects of this change over the next few days along with some further fixes to the inline cost. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152368 91177308-0d34-0410-b5e6-96231b3b80d8
* Taken into account Duncan's comments for r149481 dated by 2nd Feb 2012:Stepan Dyatkovskiy2012-03-082-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152297 91177308-0d34-0410-b5e6-96231b3b80d8
* Rotate two of the functions used to count bonuses for the inline costChandler Carruth2012-03-081-14/+10
| | | | | | | | | | | | | analysis to be methods on the cost analysis's function info object instead of the code metrics object. These really are just users of the code metrics, they're building the information for the function's analysis. This is the first step of growing the amount of information we collect about a function in order to cope with pair-wise simplifications due to allocas. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152283 91177308-0d34-0410-b5e6-96231b3b80d8
* No functionality change. Type::isSized() can be expensive, so avoid calling itNick Lewycky2012-03-071-8/+10
| | | | | | | until after other inexpensive tests. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152195 91177308-0d34-0410-b5e6-96231b3b80d8
* A few more cases of missing masking in ComputeMaskedBits; found by inspection.Eli Friedman2012-03-051-3/+3
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152070 91177308-0d34-0410-b5e6-96231b3b80d8
* Make sure we don't return bits outside the mask in ComputeMaskedBits. PR12189.Eli Friedman2012-03-051-2/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152066 91177308-0d34-0410-b5e6-96231b3b80d8
* LVI: Recognize the form instcombine canonicalizes range checks into when ↵Benjamin Kramer2012-03-021-4/+16
| | | | | | | | | | forming constant ranges. This could probably be made a lot smarter, but this is a common case and doesn't require LVI to scan a lot of code. With this change CVP can optimize away the "shift == 0" case in Hashing.h that only gets hit when "shift" is in a range not containing 0. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151919 91177308-0d34-0410-b5e6-96231b3b80d8
* Duncan pointed out that if the alignment isn't explicitly specified, it ↵Eli Friedman2012-02-271-4/+4
| | | | | | defaults to the ABI alignment. Given that, make this code a bit more aggressive in such cases. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151584 91177308-0d34-0410-b5e6-96231b3b80d8
* Teach BasicAA about the LLVM IR rules that allow reading past the end of an ↵Eli Friedman2012-02-271-9/+26
| | | | | | object given sufficient alignment. Fixes PR12098. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151553 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix this assert. IP can point to an instruction with strange dominanceRafael Espindola2012-02-271-15/+20
| | | | | | | properties (invoke). Just assert that the instruction we return dominates the insertion point. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151511 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't call dominates on unreachable instructions. Should fix the dragoneggRafael Espindola2012-02-261-2/+6
| | | | | | build. Testcase is still reducing. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151474 91177308-0d34-0410-b5e6-96231b3b80d8
* And update the comment...Rafael Espindola2012-02-261-1/+0
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151472 91177308-0d34-0410-b5e6-96231b3b80d8
* Enable the assert that got all this dominator work started.Rafael Espindola2012-02-261-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151471 91177308-0d34-0410-b5e6-96231b3b80d8
* Change the implementation of dominates(inst, inst) to one based on what theRafael Espindola2012-02-261-6/+5
| | | | | | | | verifier does. This correctly handles invoke. Thanks to Duncan, Andrew and Chris for the comments. Thanks to Joerg for the early testing. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151469 91177308-0d34-0410-b5e6-96231b3b80d8
* Reinstate the optimization from r151449 with a fix to not turn 'gep %x' intoNick Lewycky2012-02-261-11/+51
| | | | | | | 'gep null' when the icmp predicate is unsigned (or is signed without inbounds). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151467 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't call dominates on unreachable instructions.Rafael Espindola2012-02-261-1/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151466 91177308-0d34-0410-b5e6-96231b3b80d8
* Roll these back to r151448 until I figure out how they're breakingNick Lewycky2012-02-251-42/+10
| | | | | | | MultiSource/Applications/lua. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151463 91177308-0d34-0410-b5e6-96231b3b80d8
* An argument and a local identified object (eg. a noalias call) could turn outNick Lewycky2012-02-251-12/+13
| | | | | | | | equal if both are null. In the test, scope type %t and global @y by adding a 'gep' prefix to them. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151452 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix five-letter typo in comment.Nick Lewycky2012-02-251-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151450 91177308-0d34-0410-b5e6-96231b3b80d8
* Teach instsimplify to be more aggressive when analyzing comparisons of pointersNick Lewycky2012-02-251-10/+41
| | | | | | | | by using llvm::isIdentifiedObject. Also teach it to handle GEPs that have the same base pointer and constant operands. Fixes PR11238! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151449 91177308-0d34-0410-b5e6-96231b3b80d8
* Move isKnownNonNull from private implementation detail of BasicAA to a publicNick Lewycky2012-02-252-16/+16
| | | | | | | function that others can use, next to llvm::isIdentifiedObject. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151446 91177308-0d34-0410-b5e6-96231b3b80d8
* fix PR12075, a regression in a recent transform I added. In unreachable ↵Chris Lattner2012-02-241-4/+18
| | | | | | code, gep chains can be infinite. Just like "stripPointerCasts", use a set to keep track of visited instructions so we don't recurse infinitely. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151383 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix typo.Rafael Espindola2012-02-231-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151238 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove extra semi-colons.Chad Rosier2012-02-221-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151169 91177308-0d34-0410-b5e6-96231b3b80d8
* Improve comment. Thanks for Andrew for the suggestion.Rafael Espindola2012-02-221-2/+3
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151127 91177308-0d34-0410-b5e6-96231b3b80d8
* Semantically revert 151015. Add a comment on why we should be able to assertRafael Espindola2012-02-221-7/+17
| | | | | | | | the dominance once the dominates method is fixed and why we can use the builder's insertion point. Fixes pr12048. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151125 91177308-0d34-0410-b5e6-96231b3b80d8
* s/the the/the/Rafael Espindola2012-02-211-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151079 91177308-0d34-0410-b5e6-96231b3b80d8
* Use more idiomatic assert.Rafael Espindola2012-02-211-2/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151026 91177308-0d34-0410-b5e6-96231b3b80d8
* Avoid warning on non assert builds.Rafael Espindola2012-02-211-2/+3
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151025 91177308-0d34-0410-b5e6-96231b3b80d8
* It turns out that with the current scev organization ReuseOrCreateCast cannotRafael Espindola2012-02-211-9/+9
| | | | | | | | | | | | | | know where users will be added. Because of this, it cannot use Builder.GetInsertPoint at all. This patch * removes the FIXME about adding the assert. * adds a comment explaining hy we don't have one. * removes a broken logic that only works for some callers and is not needed since r150884. * adds an assert to caller that would have caught the bug fixed by r150884. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151015 91177308-0d34-0410-b5e6-96231b3b80d8
* Make this a bit prettier and more obvious when a derived type isn'tEric Christopher2012-02-201-1/+3
| | | | | | derived from anything. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150975 91177308-0d34-0410-b5e6-96231b3b80d8
* If a derived type is also a composite type, print that informationEric Christopher2012-02-201-2/+7
| | | | | | too. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150974 91177308-0d34-0410-b5e6-96231b3b80d8
* Add support for runtime languages on our forward declarations.Eric Christopher2012-02-201-2/+5
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150973 91177308-0d34-0410-b5e6-96231b3b80d8
* fold comparisons of gep'd alloca points with null to false,Chris Lattner2012-02-201-4/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | implementing PR12013. We now compile the testcase to: __Z4testv: ## @_Z4testv ## BB#0: ## %_ZN4llvm15SmallVectorImplIiE9push_backERKi.exit pushq %rbx subq $64, %rsp leaq 32(%rsp), %rbx movq %rbx, (%rsp) leaq 64(%rsp), %rax movq %rax, 16(%rsp) movl $1, 32(%rsp) leaq 36(%rsp), %rax movq %rax, 8(%rsp) leaq (%rsp), %rdi callq __Z1gRN4llvm11SmallVectorIiLj8EEE movq (%rsp), %rdi cmpq %rbx, %rdi je LBB0_2 ## BB#1: callq _free LBB0_2: ## %_ZN4llvm11SmallVectorIiLj8EED1Ev.exit addq $64, %rsp popq %rbx ret instead of: __Z4testv: ## @_Z4testv ## BB#0: pushq %rbx subq $64, %rsp xorl %eax, %eax leaq (%rsp), %rbx addq $32, %rbx movq %rbx, (%rsp) movq %rbx, 8(%rsp) leaq 64(%rsp), %rcx movq %rcx, 16(%rsp) je LBB0_2 ## BB#1: movl $1, 32(%rsp) movq %rbx, %rax LBB0_2: ## %_ZN4llvm15SmallVectorImplIiE9push_backERKi.exit addq $4, %rax movq %rax, 8(%rsp) leaq (%rsp), %rdi callq __Z1gRN4llvm11SmallVectorIiLj8EEE movq (%rsp), %rdi cmpq %rbx, %rdi je LBB0_4 ## BB#3: callq _free LBB0_4: ## %_ZN4llvm11SmallVectorIiLj8EED1Ev.exit addq $64, %rsp popq %rbx ret This doesn't shrink clang noticably though. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150944 91177308-0d34-0410-b5e6-96231b3b80d8
* Temporarily disable this assert. Looks like it found a similar issue whenRafael Espindola2012-02-181-1/+3
| | | | | | building bullet. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150885 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't skip debug instructions when looking for the insertion point ofRafael Espindola2012-02-181-5/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | the cast. If we do, we can end up with inst1 --------------- < Insertion point dbg inst new inst instead of the desired inst1 new inst --------------- < Insertion point dbg inst Another option would be for InsertNoopCastOfTo (or its callers) to move the insertion point and we would end up with inst1 dbg inst new inst --------------- < Insertion point but that complicates the callers. This fixes PR12018 (and firefox's build). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150884 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a rather nasty regression from r150690: LHS != RHS does not imply ↵Eli Friedman2012-02-181-1/+2
| | | | | | LHS->stripPointerCasts() != RHS->stripPointerCasts(). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150863 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove a comment about an alternative approach that wouldn'tDan Gohman2012-02-171-4/+1
| | | | | | | | | actually work, at least as described. LLVM Metadata is not intended to suppress LLVM IR rules, as it can be stripped at any time. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150821 91177308-0d34-0410-b5e6-96231b3b80d8
* Typo in variable name.Eric Christopher2012-02-171-2/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150796 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert "InstSimplify: Strip pointer casts early."Benjamin Kramer2012-02-161-6/+5
| | | | | | | Turns out this isn't safe, because the code below depends on LHS and RHS having the same type. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150695 91177308-0d34-0410-b5e6-96231b3b80d8
* InstSimplify: Strip pointer casts early.Benjamin Kramer2012-02-161-5/+6
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150694 91177308-0d34-0410-b5e6-96231b3b80d8
* InstSimplify: Ignore pointer casts when constant folding compares between ↵Benjamin Kramer2012-02-161-2/+5
| | | | | | pointers. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150690 91177308-0d34-0410-b5e6-96231b3b80d8
* Have AliasSet::aliasesUnknownInst use pointer TBAA info when availableHal Finkel2012-02-101-1/+3
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150249 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix PR11948: the result type of an icmp may be a vector of boolean -Duncan Sands2012-02-101-0/+5
| | | | | | | don't assume it is a boolean. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150247 91177308-0d34-0410-b5e6-96231b3b80d8
* Add support for a temporary forward decl type. We want this so weEric Christopher2012-02-081-0/+22
| | | | | | | | can rauw forward declarations if we decide to emit the full type. Part of rdar://10809898 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150024 91177308-0d34-0410-b5e6-96231b3b80d8