Skip to content
  1. Oct 02, 2012
  2. Oct 01, 2012
    • Chandler Carruth's avatar
      Make this plural. Spotted by Duncan in review (and a very old typo, this · d71ef3a0
      Chandler Carruth authored
      is the second time I've moved this comment around...)
      
      llvm-svn: 164939
      d71ef3a0
    • Chandler Carruth's avatar
      Prune some unnecessary includes. · d325f802
      Chandler Carruth authored
      llvm-svn: 164938
      d325f802
    • Chandler Carruth's avatar
      Fix several issues with alignment. We weren't always accounting for type · 176ca71a
      Chandler Carruth authored
      alignment requirements of the new alloca. As one consequence which was
      reported as a bug by Duncan, we overaligned memcpy calls to ranges of
      allocas after they were rewritten to types with lower alignment
      requirements. Other consquences are possible, but I don't have any test
      cases for them.
      
      llvm-svn: 164937
      176ca71a
    • Benjamin Kramer's avatar
      SimplifyCFG: Don't crash when forming a switch bitmap with an undef default value. · 9fc3dc77
      Benjamin Kramer authored
      Fixes PR13985.
      
      llvm-svn: 164934
      9fc3dc77
    • Chandler Carruth's avatar
      Factor the PHI and select speculation into a separate rewriter. This · 82a57543
      Chandler Carruth authored
      could probably be factored still further to hoist this logic into
      a generic helper, but currently I don't have particularly clean ideas
      about how to handle that.
      
      This at least allows us to drop custom load rewriting from the
      speculation logic, which in turn allows the existing load rewriting
      logic to fire. In theory, this could enable vector promotion or other
      tricks after speculation occurs, but I've not dug into such issues. This
      is primarily just cleaning up the factoring of the code and the
      resulting logic.
      
      llvm-svn: 164933
      82a57543
    • Chandler Carruth's avatar
      Refactor the PartitionUse structure to actually use the Use* instead of · 54e8f0b4
      Chandler Carruth authored
      a pair of instructions, one for the used pointer and the second for the
      user. This simplifies the representation and also makes it more dense.
      
      This was noticed because of the miscompile in PR13926. In that case, we
      were running up against a fundamental "bad idea" in the speculation of
      PHI and select instructions: the speculation and rewriting are
      interleaved, which requires phi speculation to also perform load
      rewriting! This is bad, and causes us to miss opportunities to do (for
      example) vector rewriting only exposed after PHI speculation, etc etc.
      It also, in the old system, required us to insert *new* load uses into
      the current partition's use list, which would then be ignored during
      rewriting because we had already extracted an end iterator for the use
      list. The appending behavior (and much of the other oddities) stem from
      the strange de-duplication strategy in the PartitionUse builder.
      Amusingly, all this went without notice for so long because it could
      only be triggered by having *different* GEPs into the same partition of
      the same alloca, where both different GEPs were operands of a single
      PHI, and where the GEP which was not encountered first also had multiple
      uses within that same PHI node... Hence the insane steps required to
      reproduce.
      
      So, step one in fixing this fundamental bad idea is to make the
      PartitionUse actually contain a Use*, and to make the builder do proper
      deduplication instead of funky de-duplication. This is enough to remove
      the appending behavior, and fix the miscompile in PR13926, but there is
      more work to be done here. Subsequent commits will lift the speculation
      into its own visitor. It'll be a useful step toward potentially
      extracting all of the speculation logic into a generic utility
      transform.
      
      The existing PHI test case for repeated operands has been made more
      extreme to catch even these issues. This test case, run through the old
      pass, will exactly reproduce the miscompile from PR13926. ;] We were so
      close here!
      
      llvm-svn: 164925
      54e8f0b4
  3. Sep 30, 2012
  4. Sep 29, 2012
    • Chandler Carruth's avatar
      Fix a somewhat surprising miscompile where code relying on an ABI · 903790ef
      Chandler Carruth authored
      alignment could lose it due to the alloca type moving down to a much
      smaller alignment guarantee.
      
      Now SROA will actively compute a proper alignment, factoring the target
      data, any explicit alignment, and the offset within the struct. This
      will in some cases lower the alignment requirements, but when we lower
      them below those of the type, we drop the alignment entirely to give
      freedom to the code generator to align it however is convenient.
      
      Thanks to Duncan for the lovely test case that pinned this down. =]
      
      llvm-svn: 164891
      903790ef
    • Evan Cheng's avatar
      Do not delete BBs if their addresses are taken. rdar://12396696 · 64a223ae
      Evan Cheng authored
      llvm-svn: 164866
      64a223ae
  5. Sep 28, 2012
  6. Sep 27, 2012
  7. Sep 26, 2012
    • Bill Wendling's avatar
      Remove the `hasFnAttr' method from Function. · 863bab68
      Bill Wendling authored
      The hasFnAttr method has been replaced by querying the Attributes explicitly. No
      intended functionality change.
      
      llvm-svn: 164725
      863bab68
    • Hans Wennborg's avatar
      Address Duncan's comments on r164684: · cd3a11f7
      Hans Wennborg authored
      - Put statistics in alphabetical order
      - Don't use getZextValue when building TableInt, just use APInts
      - Introduce Create{Z,S}ExtOrTrunc in IRBuilder.
      
      llvm-svn: 164696
      cd3a11f7
    • Hans Wennborg's avatar
      Address Duncan's comments on r164682: · f2e2c108
      Hans Wennborg authored
      - Finish assert messages with exclamation mark
      - Move overflow checking into ShouldBuildLookupTable.
      
      llvm-svn: 164692
      f2e2c108
    • Chandler Carruth's avatar
      Analogous fix to memset and memcpy rewriting. Don't have a test case · 208124f5
      Chandler Carruth authored
      contrived for these yet, as I spotted them by inspection and the test
      cases are a bit more tricky to phrase.
      
      llvm-svn: 164691
      208124f5
    • Chandler Carruth's avatar
      When rewriting the pointer operand to a load or store which has · 3e4273dd
      Chandler Carruth authored
      alignment guarantees attached, re-compute the alignment so that we
      consider offsets which impact alignment.
      
      llvm-svn: 164690
      3e4273dd
    • Chandler Carruth's avatar
      Teach all of the loads, stores, memsets and memcpys created by the · 871ba724
      Chandler Carruth authored
      rewriter in SROA to carry a proper alignment. This involves
      interrogating various sources of alignment, etc. This is a more complete
      and principled fix to PR13920 as well as related bugs pointed out by Eli
      in review and by inspection in the area.
      
      Also by inspection fix the integer and vector promotion paths to create
      aligned loads and stores. I still need to work up test cases for
      these... Sorry for the delay, they were found purely by inspection.
      
      llvm-svn: 164689
      871ba724
    • Hans Wennborg's avatar
      SimplifyCFG: Make the switch-to-lookup table transformation store the · 39583b88
      Hans Wennborg authored
      tables in bitmaps when they fit in a target-legal register.
      
      This saves some space, and it also allows for building tables that would
      otherwise be deemed too sparse.
      
      One interesting case that this hits is example 7 from
      http://blog.regehr.org/archives/320. We currently generate good code
      for this when lowering the switch to the selection DAG: we build a
      bitmask to decide whether to jump to one block or the other. My patch
      will result in the same bitmask, but it removes the need for the jump,
      as the return value can just be retrieved from the mask.
      
      llvm-svn: 164684
      39583b88
    • Hans Wennborg's avatar
      SimplifyCFG: Refactor the switch-to-lookup table transformation by · 776d7126
      Hans Wennborg authored
      breaking out the building of lookup tables into a separate class.
      
      llvm-svn: 164682
      776d7126
    • Chandler Carruth's avatar
      Revert the business end of r164636 and try again. I'll come in again. ;] · 4bd8f66e
      Chandler Carruth authored
      This should really, really fix PR13916. For real this time. The
      underlying bug is... a bit more subtle than I had imagined.
      
      The setup is a code pattern that leads to an @llvm.memcpy call with two
      equal pointers to an alloca in the source and dest. Now, not any pattern
      will do. The alloca needs to be formed just so, and both pointers should
      be wrapped in different bitcasts etc. When this precise pattern hits,
      a funny sequence of events transpires. First, we correctly detect the
      potential for overlap, and correctly optimize the memcpy. The first
      time. However, we do simplify the set of users of the alloca, and that
      causes us to run the alloca back through the SROA pass in case there are
      knock-on simplifications. At this point, a curious thing has happened.
      If we happen to have an i8 alloca, we have direct i8 pointer values. So
      we don't bother creating a cast, we rewrite the arguments to the memcpy
      to dircetly refer to the alloca.
      
      Now, in an unrelated area of the pass, we have clever logic which
      ensures that when visiting each User of a particular pointer derived
      from an alloca, we only visit that User once, and directly inspect all
      of its operands which refer to that particular pointer value. However,
      the mechanism used to detect memcpy's with the potential to overlap
      relied upon getting visited once per *Use*, not once per *User*. This is
      always true *unless* the same exact value is both source and dest. It
      turns out that almost nothing actually produces that pattern though.
      
      We can hand craft test cases that more directly test this behavior of
      course, and those are included. Also, note that there is a significant
      missed optimization here -- we prove in many cases that there is
      a non-volatile memcpy call with identical source and dest addresses. We
      shouldn't prevent splitting the alloca in that case, and in fact we
      should just remove such memcpy calls eagerly. I'll address that in
      a subsequent commit.
      
      llvm-svn: 164669
      4bd8f66e
    • Craig Topper's avatar
    • Michael Ilseman's avatar
      Expansions for u/srem, using the udiv expansion. More unit tests for udiv and u/srem. · a398d4cf
      Michael Ilseman authored
      Fixed issue with Release build.
      
      llvm-svn: 164654
      a398d4cf
    • Nick Lewycky's avatar
      Don't drop the alignment on a memcpy intrinsic when producing a store. This is · d9f79106
      Nick Lewycky authored
      only a missed optimization opportunity if the store is over-aligned, but a
      miscompile if the store's new type has a higher natural alignment than the
      memcpy did. Fixes PR13920!
      
      llvm-svn: 164641
      d9f79106
  8. Sep 25, 2012
Loading