Skip to content
  1. Mar 26, 2012
  2. Mar 25, 2012
    • Chandler Carruth's avatar
      Teach instsimplify how to simplify comparisons of pointers which are · 8059c84a
      Chandler Carruth authored
      constant-offsets of a common base using the generic GEP-walking logic
      I added for computing pointer differences in the same situation.
      
      llvm-svn: 153419
      8059c84a
    • Chandler Carruth's avatar
      Switch the pointer-difference simplification logic to only work with · 2741aae8
      Chandler Carruth authored
      inbounds GEPs. This isn't really necessary for simplifying pointer
      differences, but I'm planning to re-use the same code to simplify
      pointer comparisons where it is necessary. Since real code almost
      exclusively uses inbounds GEPs, it doesn't seem worth it to support the
      extra complexity of turning it on and off. If anyone would like that
      back, feel free to shout. Note that instcombine will still catch any of
      these patterns.
      
      llvm-svn: 153418
      2741aae8
    • Craig Topper's avatar
      Prune some includes and forward declarations. · d4a964cd
      Craig Topper authored
      llvm-svn: 153415
      d4a964cd
    • 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
  3. Mar 24, 2012
    • Chandler Carruth's avatar
      Try to harden the recursive simplification still further. This is again · 77e8bfbb
      Chandler Carruth authored
      spotted by inspection, and I've crafted no test case that triggers it on
      my machine, but some of the windows builders are hitting what looks like
      memory corruption, so *something* is amiss here.
      
      This patch takes a more generalized approach to eliminating
      double-visits. Imagine code such as:
      
        %x = ...
        %y = add %x, 1
        %z = add %x, %y
      
      You can imagine that if we simplify %x, we would add %y and %z to the
      list. If the use-chain order happens to cause us to add them in reverse
      order, we could pull %y off first, and simplify it, adding %z to the
      list. We now have %z on the list twice, and will reference it after it
      is deleted.
      
      Currently, all my test cases happen to not trigger this, likely due to
      the use-chain ordering, but there seems no guarantee that such
      a situation could not occur, so we should handle it correctly.
      
      Again, if anyone knows how to craft a testcase that actually triggers
      this, please let me know.
      
      llvm-svn: 153397
      77e8bfbb
    • Chandler Carruth's avatar
      Don't add the instruction about to be RAUW'ed and erased to the · e41fc73f
      Chandler Carruth authored
      worklist. This can happen in theory when an instruction uses itself,
      such as a PHI node. This was spotted by inspection, and unfortunately
      I've not been able to come up with a test case that would trigger it. If
      anyone has ideas, let me know...
      
      llvm-svn: 153396
      e41fc73f
    • Jean-Daniel Dupas's avatar
      Fix null to integer conversion warnings. · a573b220
      Jean-Daniel Dupas authored
      llvm-svn: 153395
      a573b220
    • 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
    • Rafael Espindola's avatar
      Remove always true variable. · 8e5b40eb
      Rafael Espindola authored
      llvm-svn: 153392
      8e5b40eb
    • Hal Finkel's avatar
      Fix small-integer VAARG on SVR4 ABI PPC64. · e44eb288
      Hal Finkel authored
      The PPC64 SVR4 ABI requires integer stack arguments, and thus the var. args., that
      are smaller than 64 bits be zero extended to 64 bits.
      
      llvm-svn: 153373
      e44eb288
    • Hal Finkel's avatar
    • Francois Pichet's avatar
      Fix the MSVC build. · 4b9ab746
      Francois Pichet authored
      llvm-svn: 153366
      4b9ab746
    • Justin Holewinski's avatar
      PTX: Fix predicate logic bug · a84577dc
      Justin Holewinski authored
      Code such as:
      
      %vreg100 = setcc %vreg10, -1, SETNE
      brcond %vreg10, %tgt
      
      was being incorrectly morphed into
      
      %vreg100 = and %vreg10, 1
      brcond %vreg10, %tgt
      
      where the 'and' instruction could be eliminated since
      such logic is on 1-bit types in the PTX back-end, leaving
      us with just:
      
      brcond %vreg10, %tgt
      
      which essentially gives us inverted branch conditions.
      
      llvm-svn: 153364
      a84577dc
    • Andrew Trick's avatar
      More IndVarSimplify cleanup. · 25553ab5
      Andrew Trick authored
      llvm-svn: 153362
      25553ab5
    • Rafael Espindola's avatar
      First part of PR12251. Add documentation and verifier support for the range · ef9f5504
      Rafael Espindola authored
      metadata.
      
      llvm-svn: 153359
      ef9f5504
    • Kostya Serebryany's avatar
      add EP_OptimizerLast extension point · e505a5ab
      Kostya Serebryany authored
      llvm-svn: 153353
      e505a5ab
    • Bill Wendling's avatar
      It's possible for two types, which are isomorphic, to be added to the · 8737480d
      Bill Wendling authored
      destination module, but one of them isn't used in the destination module. If
      another module comes along and the uses the unused type, there could be type
      conflicts when the modules are finally linked together. (This happened when
      building LLVM.)
      
      The test that was reduced is:
      
      Module A:
      
      %Z = type { %A }
      %A = type { %B.1, [7 x x86_fp80] }
      %B.1 = type { %C }
      %C = type { i8* }
      
      declare void @func_x(%C*, i64, i64)
      declare void @func_z(%Z* nocapture)
      
      Module B:
      
      %B = type { %C.1 }
      %C.1 = type { i8* }
      %A.2 = type { %B.3, [5 x x86_fp80] }
      %B.3 = type { %C.1 }
      
      define void @func_z() {
        %x = alloca %A.2, align 16
        %y = getelementptr inbounds %A.2* %x, i64 0, i32 0, i32 0
        call void @func_x(%C.1* %y, i64 37, i64 927) nounwind
        ret void
      }
      
      declare void @func_x(%C.1*, i64, i64)
      declare void @func_y(%B* nocapture)
      
      (Unfortunately, this test doesn't fail under llvm-link, only during an LTO
      linking.) The '%C' and '%C.1' clash. The destination module gets the '%C'
      declaration. When merging Module B, it looks at the '%C.1' subtype of the '%B'
      structure. It adds that in, because that's cool. And when '%B.3' is processed,
      it uses the '%C.1'. But the '%B' has used '%C' and we prefer to use '%C'. So the
      '@func_x' type is changed to 'void (%C*, i64, i64)', but the type of '%x' in
      '@func_z' remains '%A.2'. The GEP resolves to a '%C.1', which conflicts with the
      '@func_x' signature.
      
      We can resolve this situation by making sure that the type is used in the
      destination before saying that it should be used in the module being merged in.
      
      With this fix, LLVM and Clang both compile under LTO.
      <rdar://problem/10913281>
      
      llvm-svn: 153351
      8737480d
    • Jim Grosbach's avatar
      ARM tidy up ARMConstantIsland.cpp. · 190e7b6e
      Jim Grosbach authored
      No functional change, just tidy up the code and nomenclature a bit.
      
      llvm-svn: 153347
      190e7b6e
Loading