Skip to content
  1. Apr 30, 2012
    • Bill Wendling's avatar
      Second attempt at PR12573: · bf4b9afb
      Bill Wendling authored
      Allow the "SplitCriticalEdge" function to split the edge to a landing pad. If
      the pass is *sure* that it thinks it knows what it's doing, then it may go ahead
      and specify that the landing pad can have its critical edge split. The loop
      unswitch pass is one of these passes. It will split the critical edges of all
      edges coming from a loop to a landing pad not within the loop. Doing so will
      retain important loop analysis information, such as loop simplify.
      
      llvm-svn: 155817
      bf4b9afb
    • Bill Wendling's avatar
      Use an ArrayRef instead of explicit vector type. · 325e6cd9
      Bill Wendling authored
      llvm-svn: 155816
      325e6cd9
  2. Apr 10, 2012
  3. Apr 06, 2012
    • Chandler Carruth's avatar
      Sink the collection of return instructions until after *all* · 49da9339
      Chandler Carruth authored
      simplification has been performed. This is a bit less efficient
      (requires another ilist walk of the basic blocks) but shouldn't matter
      in practice. More importantly, it's just too much work to keep track of
      all the various ways the return instructions can be mutated while
      simplifying them. This fixes yet another crasher, reported by Daniel
      Dunbar.
      
      llvm-svn: 154179
      49da9339
    • Chandler Carruth's avatar
      Sink the return instruction collection until after we're done deleting · e41f6f41
      Chandler Carruth authored
      dead code, including dead return instructions in some cases. Otherwise,
      we end up having a bogus poniter to a return instruction that blows up
      much further down the road.
      
      It turns out that this pattern is both simpler to code, easier to update
      in the face of enhancements to the inliner cleanup, and likely cheaper
      given that it won't add dead instructions to the list.
      
      Thanks to John Regehr's numerous test cases for teasing this out.
      
      llvm-svn: 154157
      e41f6f41
  4. Apr 04, 2012
    • Rafael Espindola's avatar
      Always compute all the bits in ComputeMaskedBits. · ba0a6cab
      Rafael Espindola authored
      This allows us to keep passing reduced masks to SimplifyDemandedBits, but
      know about all the bits if SimplifyDemandedBits fails. This allows instcombine
      to simplify cases like the one in the included testcase.
      
      llvm-svn: 154011
      ba0a6cab
  5. Mar 28, 2012
  6. Mar 26, 2012
  7. Mar 25, 2012
    • Chandler Carruth's avatar
      Teach the function cloner (and thus the inliner) to simplify PHINodes · ef82cf5b
      Chandler Carruth authored
      aggressively. There are lots of dire warnings about this being expensive
      that seem to predate switching to the TrackingVH-based value remapper
      that is automatically updated on RAUW. This makes it easy to not just
      prune single-entry PHIs, but to fully simplify PHIs, and to recursively
      simplify the newly inlined code to propagate PHINode simplifications.
      
      This introduces a bit of a thorny problem though. We may end up
      simplifying a branch condition to a constant when we fold PHINodes, and
      we would like to nuke any dead blocks resulting from this so that time
      isn't wasted continually analyzing them, but this isn't easy. Deleting
      basic blocks *after* they are fully cloned and mapped into the new
      function currently requires manually updating the value map. The last
      piece of the simplification-during-inlining puzzle will require either
      switching to WeakVH mappings or some other piece of refactoring. I've
      left a FIXME in the testcase about this.
      
      llvm-svn: 153410
      ef82cf5b
    • Chandler Carruth's avatar
      Move the instruction simplification of callsite arguments in the inliner · 21211992
      Chandler Carruth authored
      to instead rely on much more generic and powerful instruction
      simplification in the function cloner (and thus inliner).
      
      This teaches the pruning function cloner to use instsimplify rather than
      just the constant folder to fold values during cloning. This can
      simplify a large number of things that constant folding alone cannot
      begin to touch. For example, it will realize that 'or' and 'and'
      instructions with certain constant operands actually become constants
      regardless of what their other operand is. It also can thread back
      through the caller to perform simplifications that are only possible by
      looking up a few levels. In particular, GEPs and pointer testing tend to
      fold much more heavily with this change.
      
      This should (in some cases) have a positive impact on compile times with
      optimizations on because the inliner itself will simply avoid cloning
      a great deal of code. It already attempted to prune proven-dead code,
      but now it will be use the stronger simplifications to prove more code
      dead.
      
      llvm-svn: 153403
      21211992
    • Chandler Carruth's avatar
      Add an asserting ValueHandle to the block simplification code which will · 0c72e3f4
      Chandler Carruth authored
      fire if anything ever invalidates the assumption of a terminator
      instruction being unchanged throughout the routine.
      
      I've convinced myself that the current definition of simplification
      precludes such a transformation, so I think getting some asserts
      coverage that we don't violate this agreement is sufficient to make this
      code safe for the foreseeable future.
      
      Comments to the contrary or other suggestions are of course welcome. =]
      The bots are now happy with this code though, so it appears the bug here
      has indeed been fixed.
      
      llvm-svn: 153401
      0c72e3f4
    • Chandler Carruth's avatar
      Don't form a WeakVH around the sentinel node in the instructions BB · 17fc6ef2
      Chandler Carruth authored
      list. This is a bad idea. ;] I'm hopeful this is the bug that's showing
      up with the MSVC bots, but we'll see.
      
      It is definitely unnecessary. InstSimplify won't do anything to
      a terminator instruction, we don't need to even include it in the
      iteration range. We can also skip the now dead terminator check,
      although I've made it an assert to help document that this is an
      important invariant.
      
      I'm still a bit queasy about this because there is an implicit
      assumption that the terminator instruction cannot be RAUW'ed by the
      simplification code. While that appears to be true at the moment, I see
      no guarantee that would ensure it remains true in the future. I'm
      looking at the cleanest way to solve that...
      
      llvm-svn: 153399
      17fc6ef2
  8. Mar 24, 2012
    • Chandler Carruth's avatar
      Refactor the interface to recursively simplifying instructions to be tad · cf1b585f
      Chandler Carruth authored
      bit simpler by handling a common case explicitly.
      
      Also, refactor the implementation to use a worklist based walk of the
      recursive users, rather than trying to use value handles to detect and
      recover from RAUWs during the recursive descent. This fixes a very
      subtle bug in the previous implementation where degenerate control flow
      structures could cause mutually recursive instructions (PHI nodes) to
      collapse in just such a way that From became equal to To after some
      amount of recursion. At that point, we hit the inf-loop that the assert
      at the top attempted to guard against. This problem is defined away when
      not using value handles in this manner. There are lots of comments
      claiming that the WeakVH will protect against just this sort of error,
      but they're not accurate about the actual implementation of WeakVHs,
      which do still track RAUWs.
      
      I don't have any test case for the bug this fixes because it requires
      running the recursive simplification on unreachable phi nodes. I've no
      way to either run this or easily write an input that triggers it. It was
      found when using instruction simplification inside the inliner when
      running over the nightly test-suite.
      
      llvm-svn: 153393
      cf1b585f
  9. Mar 22, 2012
  10. Mar 21, 2012
  11. Mar 20, 2012
  12. Mar 16, 2012
    • Andrew Trick's avatar
      LSR fix: Add isSimplifiedLoopNest to IVUsers analysis. · 070e540a
      Andrew Trick authored
      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
      070e540a
  13. Mar 15, 2012
  14. Mar 11, 2012
    • Stepan Dyatkovskiy's avatar
      llvm::SwitchInst · 97b02fc1
      Stepan Dyatkovskiy authored
      Renamed methods caseBegin, caseEnd and caseDefault with case_begin, case_end, and case_default.
      Added some notes relative to case iterators.
      
      llvm-svn: 152532
      97b02fc1
  15. Mar 08, 2012
    • Stepan Dyatkovskiy's avatar
      Taken into account Duncan's comments for r149481 dated by 2nd Feb 2012: · 5b648afb
      Stepan Dyatkovskiy authored
      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
      5b648afb
  16. Mar 05, 2012
  17. Feb 25, 2012
  18. Feb 21, 2012
  19. Feb 17, 2012
  20. Feb 07, 2012
  21. Feb 06, 2012
  22. Feb 01, 2012
    • Stepan Dyatkovskiy's avatar
      SwitchInst refactoring. · 513aaa56
      Stepan Dyatkovskiy authored
      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
      513aaa56
  23. Jan 31, 2012
Loading