Skip to content
  1. Sep 16, 2011
    • Jakob Stoklund Olesen's avatar
      Spill mode: Hoist back-copies locally. · e2c92a31
      Jakob Stoklund Olesen authored
      The leaveIntvAfter() function normally inserts a back-copy after the
      requested instruction, making the back-copy kill the live range.
      
      In spill mode, try to insert the back-copy before the last use instead.
      That means the last use becomes the kill instead of the back-copy.  This
      lowers the register pressure because the last use can now redefine the
      same register it was reading.
      
      This will also improve compile time: The back-copy isn't a kill, so
      hoisting it in hoistCopiesForSize() won't force a recomputation of the
      source live range.  Similarly, if the back-copy isn't hoisted by the
      splitter, the spiller will not attempt hoisting it locally.
      
      llvm-svn: 139883
      e2c92a31
  2. Sep 14, 2011
    • Jakob Stoklund Olesen's avatar
      Hoist back-copies to the least busy dominator. · a98af398
      Jakob Stoklund Olesen authored
      When a back-copy is hoisted to the nearest common dominator, keep
      looking up the dominator tree for a less loopy dominator, and place the
      back-copy there instead.
      
      Don't do this when a single existing back-copy dominates all the others.
      Assume the client knows what he is doing, and keep the dominating
      back-copy.
      
      This prevents us from hoisting back-copies into loops in most cases.  If
      a value is defined in a loop with multiple exits, we may still hoist
      back-copies into that loop.  That is the speed/size tradeoff.
      
      llvm-svn: 139698
      a98af398
    • Jakob Stoklund Olesen's avatar
      Distinguish complex mapped values from forced recomputation. · 5d4277dd
      Jakob Stoklund Olesen authored
      When a ParentVNI maps to multiple defs in a new interval, its live range
      may still be derived directly from RegAssign by transferValues().
      
      On the other hand, when instructions have been rematerialized or
      hoisted, it may be necessary to completely recompute live ranges using
      LiveRangeCalc::extend() to all uses.
      
      Use a bit in the value map to indicate that a live range must be
      recomputed.  Rename markComplexMapped() to forceRecompute().
      
      This fixes some live range verification errors when
      -split-spill-mode=size hoists back-copies by recomputing source ranges
      when RegAssign kills can't be moved.
      
      llvm-svn: 139660
      5d4277dd
    • Jakob Stoklund Olesen's avatar
      Implement -split-spill-mode=size. · a25330f0
      Jakob Stoklund Olesen authored
      Whenever the complement interval is defined by multiple copies of the
      same value, hoist those back-copies to the nearest common dominator.
      
      This ensures that at most one copy is inserted per value in the
      complement inteval, and no phi-defs are needed.
      
      llvm-svn: 139651
      a25330f0
  3. Sep 13, 2011
  4. Sep 12, 2011
    • Jakob Stoklund Olesen's avatar
      Add an interface for SplitKit complement spill modes. · eecb2fb1
      Jakob Stoklund Olesen authored
      SplitKit always computes a complement live range to cover the places
      where the original live range was live, but no explicit region has been
      allocated.
      
      Currently, the complement live range is created to be as small as
      possible - it never overlaps any of the regions.  This minimizes
      register pressure, but if the complement is going to be spilled anyway,
      that is not very important.  The spiller will eliminate redundant
      spills, and hoist others by making the spill slot live range overlap
      some of the regions created by splitting.  Stack slots are cheap.
      
      This patch adds the interface to enable spill modes in SplitKit.  In
      spill mode, SplitKit will assume that the complement is going to spill,
      so it will allow it to overlap regions in order to avoid back-copies.
      By doing some of the spiller's work early, the complement live range
      becomes simpler.  In some cases, it can become much simpler because no
      extra PHI-defs are required.  This will speed up both splitting and
      spilling.
      
      This is only the interface to enable spill modes, no implementation yet.
      
      llvm-svn: 139500
      eecb2fb1
  5. Aug 06, 2011
    • Jakob Stoklund Olesen's avatar
      Delete getMultiUseBlocks and splitSingleBlocks. · cdf9ad91
      Jakob Stoklund Olesen authored
      These functions are no longer used, and they are easily replaced with a
      loop calling shouldSplitSingleBlock and splitSingleBlock.
      
      llvm-svn: 136993
      cdf9ad91
    • Jakob Stoklund Olesen's avatar
      Split around single instructions to enable register class inflation. · 8627ea91
      Jakob Stoklund Olesen authored
      Normally, we don't create a live range for a single instruction in a
      basic block, the spiller does that anyway. However, when splitting a
      live range that belongs to a proper register sub-class, inserting these
      extra COPY instructions completely remove the constraints from the
      remainder interval, and it may be allocated from the larger super-class.
      
      The spiller will mop up these small live ranges if we end up spilling
      anyway. It calls them snippets.
      
      llvm-svn: 136989
      8627ea91
  6. Aug 03, 2011
  7. Jul 24, 2011
  8. Jul 23, 2011
  9. Jul 18, 2011
  10. Jul 16, 2011
  11. Jul 15, 2011
    • Jakob Stoklund Olesen's avatar
      Extract parts of RAGreedy::splitAroundRegion as SplitKit methods. · 795da1c1
      Jakob Stoklund Olesen authored
      This gets rid of some of the gory splitting details in RAGreedy and
      makes them available to future SplitKit clients.
      
      Slightly generalize the functionality to support multi-way splitting.
      Specifically, SplitEditor::splitLiveThroughBlock() supports switching
      between different register intervals in a block.
      
      llvm-svn: 135307
      795da1c1
  12. Jun 30, 2011
    • Jakob Stoklund Olesen's avatar
      Reapply r134047 now that the world is ready for it. · adc6a4ca
      Jakob Stoklund Olesen authored
      This patch will sometimes choose live range split points next to
      interference instead of always splitting next to a register point. That
      means spill code can now appear almost anywhere, and it was necessary
      to fix code that didn't expect that.
      
      The difficult places were:
      
      - Between a CALL returning a value on the x87 stack and the
        corresponding FpPOP_RETVAL (was FpGET_ST0). Probably also near x87
        inline assembly, but that didn't actually show up in testing.
      
      - Between a CALL popping arguments off the stack and the corresponding
        ADJCALLSTACKUP.
      
      Both are fixed now. The only place spill code can't appear is after
      terminators, see SplitAnalysis::getLastSplitPoint.
      
      Original commit message:
      
      Rewrite RAGreedy::splitAroundRegion, now with cool ASCII art.
      
      This function has to deal with a lot of special cases, and the old
      version got it wrong sometimes. In particular, it would sometimes leave
      multiple uses in the stack interval in a single block. That causes bad
      code with multiple reloads in the same basic block.
      
      The new version handles block entry and exit in a single pass. It first
      eliminates all the easy cases, and then goes on to create a local
      interval for the blocks with difficult interference. Previously, we
      would only create the local interval for completely isolated blocks.
      
      It can happen that the stack interval becomes completely empty because
      we could allocate a register in all edge bundles, and the new local
      intervals deal with the interference. The empty stack interval is
      harmless, but we need to remove a SplitKit assertion that checks for
      empty intervals.
      
      llvm-svn: 134125
      adc6a4ca
  13. Jun 29, 2011
    • Jakob Stoklund Olesen's avatar
      Revert r134047 while investigating a llvm-gcc-i386-linux-selfhost · 8628435c
      Jakob Stoklund Olesen authored
      miscompile.
      
      llvm-svn: 134053
      8628435c
    • Jakob Stoklund Olesen's avatar
      Rewrite RAGreedy::splitAroundRegion, now with cool ASCII art. · ffbc05b7
      Jakob Stoklund Olesen authored
      This function has to deal with a lot of special cases, and the old
      version got it wrong sometimes. In particular, it would sometimes leave
      multiple uses in the stack interval in a single block. That causes bad
      code with multiple reloads in the same basic block.
      
      The new version handles block entry and exit in a single pass. It first
      eliminates all the easy cases, and then goes on to create a local
      interval for the blocks with difficult interference. Previously, we
      would only create the local interval for completely isolated blocks.
      
      It can happen that the stack interval becomes completely empty because
      we could allocate a register in all edge bundles, and the new local
      intervals deal with the interference. The empty stack interval is
      harmless, but we need to remove a SplitKit assertion that checks for
      empty intervals.
      
      llvm-svn: 134047
      ffbc05b7
  14. Jun 28, 2011
  15. Jun 27, 2011
  16. May 30, 2011
  17. May 29, 2011
  18. May 28, 2011
    • Jakob Stoklund Olesen's avatar
      Create two BlockInfo entries when a live range is discontinuous through a block. · fd3f71ef
      Jakob Stoklund Olesen authored
      Delete the Kill and Def markers in BlockInfo. They are no longer
      necessary when BlockInfo describes a continuous live range.
      
      This only affects the relatively rare kind of basic block where a live
      range looks like this:
      
       |---x   o---|
      
      Now live range splitting can pretend that it is looking at two blocks:
      
       |---x
               o---|
      
      This allows the code to be simplified a bit.
      
      llvm-svn: 132245
      fd3f71ef
    • Jakob Stoklund Olesen's avatar
      Add SplitAnalysis::getNumLiveBlocks(). · 5cc91b26
      Jakob Stoklund Olesen authored
      It is important that this function returns the same number of live blocks as
      countLiveBlocks(CurLI) because live range splitting uses the number of live
      blocks to ensure it is making progress.
      
      This is in preparation of supporting duplicate UseBlock entries for basic blocks
      that have a virtual register live-in and live-out, but not live-though.
      
      llvm-svn: 132244
      5cc91b26
  19. May 10, 2011
  20. May 05, 2011
  21. May 03, 2011
    • Jakob Stoklund Olesen's avatar
      Gracefully handle invalid live ranges. Fix PR9831. · eaa6ed1a
      Jakob Stoklund Olesen authored
      Register coalescing can sometimes create live ranges that end in the middle of a
      basic block without any killing instruction. When SplitKit detects this, it will
      repair the live range by shrinking it to its uses.
      
      Live range splitting also needs to know about this. When the range shrinks so
      much that it becomes allocatable, live range splitting fails because it can't
      find a good split point. It is paranoid about making progress, so an allocatable
      range is considered an error.
      
      The coalescer should really not be creating these bad live ranges. They appear
      when coalescing dead copies.
      
      llvm-svn: 130787
      eaa6ed1a
  22. May 02, 2011
    • Jakob Stoklund Olesen's avatar
      Minimize the slot indexes spanned by register ranges created when splitting. · 7d406793
      Jakob Stoklund Olesen authored
      When an interfering live range ends at a dead slot index between two
      instructions, make sure that the inserted copy instruction gets a slot index
      after the dead ones. This makes it possible to avoid the interference.
      
      Ideally, there shouldn't be interference ending at a deleted instruction, but
      physical register coalescing can sometimes do that to sub-registers.
      
      This fixes PR9823.
      
      llvm-svn: 130687
      7d406793
  23. Apr 27, 2011
  24. Apr 21, 2011
    • Matt Beaumont-Gay's avatar
      Don't recycle loop variables. · 70597d4e
      Matt Beaumont-Gay authored
      llvm-svn: 129928
      70597d4e
    • Jakob Stoklund Olesen's avatar
      Allow allocatable ranges from global live range splitting to be split again. · 6a663b8d
      Jakob Stoklund Olesen authored
      These intervals are allocatable immediately after splitting, but they may be
      evicted because of later splitting. This is rare, but when it happens they
      should be split again.
      
      The remainder intervals that cannot be allocated after splitting still move
      directly to spilling.
      
      SplitEditor::finish can optionally provide a mapping from new live intervals
      back to the original interval indexes returned by openIntv().
      
      Each original interval index can map to multiple new intervals after connected
      components have been separated. Dead code elimination may also add existing
      intervals to the list.
      
      The reverse mapping allows the SplitEditor client to treat the new intervals
      differently depending on the split region they came from.
      
      llvm-svn: 129925
      6a663b8d
  25. Apr 16, 2011
  26. Apr 15, 2011
    • Jakob Stoklund Olesen's avatar
      Teach the SplitKit blitter to handle multiply defined values as well. · 1af8b4dc
      Jakob Stoklund Olesen authored
      The transferValues() function can now handle both singly and multiply defined
      values, as long as the resulting live range is known. Only rematerialized values
      have their live range recomputed by extendRange().
      
      The updateSSA() function can now insert PHI values in bulk across multiple
      values in multiple target registers in one pass. The list of blocks received
      from transferValues() is in layout order which seems to work well for the
      iterative algorithm. Blocks from extendRange() are still in reverse BFS order,
      but this function is used so rarely now that it doesn't matter.
      
      llvm-svn: 129580
      1af8b4dc
Loading