Skip to content
  1. Apr 22, 2014
    • Chandler Carruth's avatar
      [Modules] Fix potential ODR violations by sinking the DEBUG_TYPE · 964daaaf
      Chandler Carruth authored
      definition below all of the header #include lines, lib/Transforms/...
      edition.
      
      This one is tricky for two reasons. We again have a couple of passes
      that define something else before the includes as well. I've sunk their
      name macros with the DEBUG_TYPE.
      
      Also, InstCombine contains headers that need DEBUG_TYPE, so now those
      headers #define and #undef DEBUG_TYPE around their code, leaving them
      well formed modular headers. Fixing these headers was a large motivation
      for all of these changes, as "leaky" macros of this form are hard on the
      modules implementation.
      
      llvm-svn: 206844
      964daaaf
  2. Apr 18, 2014
    • Nuno Lopes's avatar
      remove some dead code · 9ced19ab
      Nuno Lopes authored
       lib/Analysis/IPA/InlineCost.cpp         |   18 ------------------
       lib/Analysis/RegionPass.cpp             |    1 -
       lib/Analysis/TypeBasedAliasAnalysis.cpp |    1 -
       lib/Transforms/Scalar/LoopUnswitch.cpp  |   21 ---------------------
       lib/Transforms/Utils/LCSSA.cpp          |    2 --
       lib/Transforms/Utils/LoopSimplify.cpp   |    6 ------
       utils/TableGen/AsmWriterEmitter.cpp     |   13 -------------
       utils/TableGen/DFAPacketizerEmitter.cpp |    7 -------
       utils/TableGen/IntrinsicEmitter.cpp     |    2 --
       9 files changed, 71 deletions(-)
      
      llvm-svn: 206506
      9ced19ab
  3. Mar 09, 2014
    • Chandler Carruth's avatar
      [C++11] Add range based accessors for the Use-Def chain of a Value. · cdf47884
      Chandler Carruth authored
      This requires a number of steps.
      1) Move value_use_iterator into the Value class as an implementation
         detail
      2) Change it to actually be a *Use* iterator rather than a *User*
         iterator.
      3) Add an adaptor which is a User iterator that always looks through the
         Use to the User.
      4) Wrap these in Value::use_iterator and Value::user_iterator typedefs.
      5) Add the range adaptors as Value::uses() and Value::users().
      6) Update *all* of the callers to correctly distinguish between whether
         they wanted a use_iterator (and to explicitly dig out the User when
         needed), or a user_iterator which makes the Use itself totally
         opaque.
      
      Because #6 requires churning essentially everything that walked the
      Use-Def chains, I went ahead and added all of the range adaptors and
      switched them to range-based loops where appropriate. Also because the
      renaming requires at least churning every line of code, it didn't make
      any sense to split these up into multiple commits -- all of which would
      touch all of the same lies of code.
      
      The result is still not quite optimal. The Value::use_iterator is a nice
      regular iterator, but Value::user_iterator is an iterator over User*s
      rather than over the User objects themselves. As a consequence, it fits
      a bit awkwardly into the range-based world and it has the weird
      extra-dereferencing 'operator->' that so many of our iterators have.
      I think this could be fixed by providing something which transforms
      a range of T&s into a range of T*s, but that *can* be separated into
      another patch, and it isn't yet 100% clear whether this is the right
      move.
      
      However, this change gets us most of the benefit and cleans up
      a substantial amount of code around Use and User. =]
      
      llvm-svn: 203364
      cdf47884
  4. Mar 05, 2014
  5. Mar 04, 2014
  6. Feb 10, 2014
    • Chandler Carruth's avatar
      [LPM] A terribly simple fix to a terribly complex bug: PR18773. · 756c22cd
      Chandler Carruth authored
      The crux of the issue is that LCSSA doesn't preserve stateful alias
      analyses. Before r200067, LICM didn't cause LCSSA to run in the LTO pass
      manager, where LICM runs essentially without any of the other loop
      passes. As a consequence the globalmodref-aa pass run before that loop
      pass manager was able to survive the loop pass manager and be used by
      DSE to eliminate stores in the function called from the loop body in
      Adobe-C++/loop_unroll (and similar patterns in other benchmarks).
      
      When LICM was taught to preserve LCSSA it had to require it as well.
      This caused it to be run in the loop pass manager and because it did not
      preserve AA, the stateful AA was lost. Most of LLVM's AA isn't stateful
      and so this didn't manifest in most cases. Also, in most cases LCSSA was
      already running, and so there was no interesting change.
      
      The real kicker is that LCSSA by its definition (injecting PHI nodes
      only) trivially preserves AA! All we need to do is mark it, and then
      everything goes back to working as intended. It probably was blocking
      some other weird cases of stateful AA but the only one I have is
      a 1000-line IR test case from loop_unroll, so I don't really have a good
      test case here.
      
      Hopefully this fixes the regressions on performance that have been seen
      since that revision.
      
      llvm-svn: 201104
      756c22cd
  7. Jan 28, 2014
    • Chandler Carruth's avatar
      [LPM] Fix PR18616 where the shifts to the loop pass manager to extract · d84f776e
      Chandler Carruth authored
      LCSSA from it caused a crasher with the LoopUnroll pass.
      
      This crasher is really nasty. We destroy LCSSA form in a suprising way.
      When unrolling a loop into an outer loop, we not only need to restore
      LCSSA form for the outer loop, but for all children of the outer loop.
      This is somewhat obvious in retrospect, but hey!
      
      While this seems pretty heavy-handed, it's not that bad. Fundamentally,
      we only do this when we unroll a loop, which is already a heavyweight
      operation. We're unrolling all of these hypothetical inner loops as
      well, so their size and complexity is already on the critical path. This
      is just adding another pass over them to re-canonicalize.
      
      I have a test case from PR18616 that is great for reproducing this, but
      pretty useless to check in as it relies on many 10s of nested empty
      loops that get unrolled and deleted in just the right order. =/ What's
      worse is that investigating this has exposed another source of failure
      that is likely to be even harder to test. I'll try to come up with test
      cases for these fixes, but I want to get the fixes into the tree first
      as they're causing crashes in the wild.
      
      llvm-svn: 200273
      d84f776e
  8. Jan 25, 2014
    • Chandler Carruth's avatar
      [LPM] Make LCSSA a utility with a FunctionPass that applies it to all · 8765cf70
      Chandler Carruth authored
      the loops in a function, and teach LICM to work in the presance of
      LCSSA.
      
      Previously, LCSSA was a loop pass. That made passes requiring it also be
      loop passes and unable to depend on function analysis passes easily. It
      also caused outer loops to have a different "canonical" form from inner
      loops during analysis. Instead, we go into LCSSA form and preserve it
      through the loop pass manager run.
      
      Note that this has the same problem as LoopSimplify that prevents
      enabling its verification -- loop passes which run at the end of the loop
      pass manager and don't preserve these are valid, but the subsequent loop
      pass runs of outer loops that do preserve this pass trigger too much
      verification and fail because the inner loop no longer verifies.
      
      The other problem this exposed is that LICM was completely unable to
      handle LCSSA form. It didn't preserve it and it actually would give up
      on moving instructions in many cases when they were used by an LCSSA phi
      node. I've taught LICM to support detecting LCSSA-form PHI nodes and to
      hoist and sink around them. This may actually let LICM fire
      significantly more because we put everything into LCSSA form to rotate
      the loop before running LICM. =/ Now LICM should handle that fine and
      preserve it correctly. The down side is that LICM has to require LCSSA
      in order to preserve it. This is just a fact of life for LCSSA. It's
      entirely possible we should completely remove LCSSA from the optimizer.
      
      The test updates are essentially accomodating LCSSA phi nodes in the
      output of LICM, and the fact that we now completely sink every
      instruction in ashr-crash below the loop bodies prior to unrolling.
      
      With this change, LCSSA is computed only three times in the pass
      pipeline. One of them could be removed (and potentially a SCEV run and
      a separate LoopPassManager entirely!) if we had a LoopPass variant of
      InstCombine that ran InstCombine on the loop body but refused to combine
      away LCSSA PHI nodes. Currently, this also prevents loop unrolling from
      being in the same loop pass manager is rotate, LICM, and unswitch.
      
      There is one thing that I *really* don't like -- preserving LCSSA in
      LICM is quite expensive. We end up having to re-run LCSSA twice for some
      loops after LICM runs because LICM can undo LCSSA both in the current
      loop and the parent loop. I don't really see good solutions to this
      other than to completely move away from LCSSA and using tools like
      SSAUpdater instead.
      
      llvm-svn: 200067
      8765cf70
  9. Jan 13, 2014
    • Chandler Carruth's avatar
      [PM] Split DominatorTree into a concrete analysis result object which · 73523021
      Chandler Carruth authored
      can be used by both the new pass manager and the old.
      
      This removes it from any of the virtual mess of the pass interfaces and
      lets it derive cleanly from the DominatorTreeBase<> template. In turn,
      tons of boilerplate interface can be nuked and it turns into a very
      straightforward extension of the base DominatorTree interface.
      
      The old analysis pass is now a simple wrapper. The names and style of
      this split should match the split between CallGraph and
      CallGraphWrapperPass. All of the users of DominatorTree have been
      updated to match using many of the same tricks as with CallGraph. The
      goal is that the common type remains the resulting DominatorTree rather
      than the pass. This will make subsequent work toward the new pass
      manager significantly easier.
      
      Also in numerous places things became cleaner because I switched from
      re-running the pass (!!! mid way through some other passes run!!!) to
      directly recomputing the domtree.
      
      llvm-svn: 199104
      73523021
    • Chandler Carruth's avatar
      [cleanup] Move the Dominators.h and Verifier.h headers into the IR · 5ad5f15c
      Chandler Carruth authored
      directory. These passes are already defined in the IR library, and it
      doesn't make any sense to have the headers in Analysis.
      
      Long term, I think there is going to be a much better way to divide
      these matters. The dominators code should be fully separated into the
      abstract graph algorithm and have that put in Support where it becomes
      obvious that evn Clang's CFGBlock's can use it. Then the verifier can
      manually construct dominance information from the Support-driven
      interface while the Analysis library can provide a pass which both
      caches, reconstructs, and supports a nice update API.
      
      But those are very long term, and so I don't want to leave the really
      confusing structure until that day arrives.
      
      llvm-svn: 199082
      5ad5f15c
  10. Oct 26, 2013
    • Wan Xiaofei's avatar
      Quick look-up for block in loop. · be640b28
      Wan Xiaofei authored
      This patch implements quick look-up for block in loop by maintaining a hash set for blocks.
      It improves the efficiency of loop analysis a lot, the biggest improvement could be 5-6%(458.sjeng).
      Below are the compilation time for our benchmark in llc before & after the patch.
      
      Benchmark	llc - trunk		llc - patched	
      401.bzip2	0.339081	100.00%	0.329657	102.86%
      403.gcc		19.853966	100.00%	19.605466	101.27%
      429.mcf		0.049823	100.00%	0.048451	102.83%
      433.milc	0.514898	100.00%	0.510217	100.92%
      444.namd	1.109328	100.00%	1.103481	100.53%
      445.gobmk	4.988028	100.00%	4.929114	101.20%
      456.hmmer	0.843871	100.00%	0.825865	102.18%
      458.sjeng	0.754238	100.00%	0.714095	105.62%
      464.h264ref	2.9668		100.00%	2.90612		102.09%
      471.omnetpp	4.556533	100.00%	4.511886	100.99%
      bitmnp01	0.038168	100.00%	0.0357		106.91%
      idctrn01	0.037745	100.00%	0.037332	101.11%
      libquake2	3.78689		100.00%	3.76209		100.66%
      libquake_	2.251525	100.00%	2.234104	100.78%
      linpack		0.033159	100.00%	0.032788	101.13%
      matrix01	0.045319	100.00%	0.043497	104.19%
      nbench		0.333161	100.00%	0.329799	101.02%
      tblook01	0.017863	100.00%	0.017666	101.12%
      ttsprk01	0.054337	100.00%	0.053057	102.41%
      
      Reviewer	: Andrew Trick <atrick@apple.com>, Hal Finkel <hfinkel@anl.gov>
      Approver	: Andrew Trick <atrick@apple.com>
      Test		: Pass make check-all & llvm test-suite
      
      llvm-svn: 193460
      be640b28
  11. Jan 02, 2013
    • Chandler Carruth's avatar
      Move all of the header files which are involved in modelling the LLVM IR · 9fb823bb
      Chandler Carruth authored
      into their new header subdirectory: include/llvm/IR. This matches the
      directory structure of lib, and begins to correct a long standing point
      of file layout clutter in LLVM.
      
      There are still more header files to move here, but I wanted to handle
      them in separate commits to make tracking what files make sense at each
      layer easier.
      
      The only really questionable files here are the target intrinsic
      tablegen files. But that's a battle I'd rather not fight today.
      
      I've updated both CMake and Makefile build systems (I think, and my
      tests think, but I may have missed something).
      
      I've also re-sorted the includes throughout the project. I'll be
      committing updates to Clang, DragonEgg, and Polly momentarily.
      
      llvm-svn: 171366
      9fb823bb
  12. Dec 03, 2012
    • Chandler Carruth's avatar
      Use the new script to sort the includes of every file under lib. · ed0881b2
      Chandler Carruth authored
      Sooooo many of these had incorrect or strange main module includes.
      I have manually inspected all of these, and fixed the main module
      include to be the nearest plausible thing I could find. If you own or
      care about any of these source files, I encourage you to take some time
      and check that these edits were sensible. I can't have broken anything
      (I strictly added headers, and reordered them, never removed), but they
      may not be the headers you'd really like to identify as containing the
      API being implemented.
      
      Many forward declarations and missing includes were added to a header
      files to allow them to parse cleanly when included first. The main
      module rule does in fact have its merits. =]
      
      llvm-svn: 169131
      ed0881b2
  13. Oct 31, 2012
  14. Oct 26, 2012
    • Benjamin Kramer's avatar
      Fix SCEV cache invalidation in LCSSA and LoopSimplify. · e3d821a4
      Benjamin Kramer authored
      The LoopSimplify bug is pretty harmless because the loop goes from unanalyzable
      to analyzable but the LCSSA bug is very nasty. It only comes into play with a
      specific order of the LoopPassManager worklist and can cause actual
      miscompilations, when a SCEV refers to a value that has been replaced with PHI
      node. SCEVExpander may then insert code into the wrong place, either violating
      domination or randomly miscompiling stuff.
      
      Comes with an extensive test case reduced from the test-suite with
      bugpoint+SCEVValidator.
      
      llvm-svn: 166787
      e3d821a4
  15. May 17, 2011
  16. May 05, 2011
  17. Mar 30, 2011
  18. Mar 15, 2011
  19. Jan 02, 2011
  20. Oct 19, 2010
    • Owen Anderson's avatar
      Passes do not need to recursively initialize passes that they preserve, if · a4fefc19
      Owen Anderson authored
      they do not also require them.  This allows us to reduce inter-pass linkage
      dependencies.
      
      llvm-svn: 116854
      a4fefc19
    • Owen Anderson's avatar
      Get rid of static constructors for pass registration. Instead, every pass... · 6c18d1aa
      Owen Anderson authored
      Get rid of static constructors for pass registration.  Instead, every pass exposes an initializeMyPassFunction(), which
      must be called in the pass's constructor.  This function uses static dependency declarations to recursively initialize
      the pass's dependencies.
      
      Clients that only create passes through the createFooPass() APIs will require no changes.  Clients that want to use the
      CommandLine options for passes will need to manually call the appropriate initialization functions in PassInitialization.h
      before parsing commandline arguments.
      
      I have tested this with all standard configurations of clang and llvm-gcc on Darwin.  It is possible that there are problems
      with the static dependencies that will only be visible with non-standard options.  If you encounter any crash in pass
      registration/creation, please send the testcase to me directly.
      
      llvm-svn: 116820
      6c18d1aa
  21. Oct 12, 2010
  22. Oct 08, 2010
  23. Sep 02, 2010
    • Duncan Sands's avatar
      Reapply commit 112699, speculatively reverted by echristo, since · 6778149f
      Duncan Sands authored
      I'm sure it is harmless.  Original commit message:
      If PrototypeValue is erased in the middle of using the SSAUpdator
      then the SSAUpdator may access freed memory.  Instead, simply pass
      in the type and name explicitly, which is all that was used anyway.
      
      llvm-svn: 112810
      6778149f
  24. Sep 01, 2010
  25. Aug 23, 2010
  26. Aug 06, 2010
  27. Jul 26, 2010
    • Dan Gohman's avatar
      Remove LCSSA's bogus dependence on LoopSimplify and LoopSimplify's bogus · 0141c13b
      Dan Gohman authored
      dependence on DominanceFrontier. Instead, add an explicit DominanceFrontier
      pass in StandardPasses.h to ensure that it gets scheduled at the right
      time.
      
      Declare that loop unrolling preserves ScalarEvolution, and shuffle some
      getAnalysisUsages.
      
      This eliminates one LoopSimplify and one LCCSA run in the standard
      compile opts sequence.
      
      llvm-svn: 109413
      0141c13b
  28. Jul 16, 2010
  29. Jul 09, 2010
  30. Mar 10, 2010
  31. Nov 09, 2009
  32. Nov 05, 2009
Loading