Skip to content
  1. Jul 23, 2011
    • Jakob Stoklund Olesen's avatar
      Add RAGreedy::calcCompactRegion. · ecad62f9
      Jakob Stoklund Olesen authored
      This method computes the edge bundles that should be live when splitting
      around a compact region. This is independent of interference.
      
      The function returns false if the live range was already a compact
      region, or the compact region doesn't have any live bundles - it would
      be the same as splitting around basic blocks.
      
      Compact regions are computed using the normal spill placement code. We
      pretend there is interference in all live-through blocks that don't use
      the live range. This removes all edges from the Hopfield network used
      for spill placement, so it converges instantly.
      
      llvm-svn: 135847
      ecad62f9
    • Jakob Stoklund Olesen's avatar
      Prepare RAGreedy::growRegion for compact regions. · a953bf13
      Jakob Stoklund Olesen authored
      A split candidate can have a null PhysReg which means that it doesn't
      map to a real interference pattern. Instead, pretend that all through
      blocks have interference.
      
      This makes it possible to generate compact regions where the live range
      doesn't go through blocks that don't use it. The live range will still
      be live between directly connected blocks with uses.
      
      Splitting around a compact region tends to produce a live range with a
      high spill weight, so it may evict a less dense live range.
      
      llvm-svn: 135845
      a953bf13
  2. Jul 18, 2011
  3. Jul 16, 2011
  4. 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
  5. Jul 14, 2011
    • Jakob Stoklund Olesen's avatar
      Reapply r135121 with a fixed copy constructor. · a153ca58
      Jakob Stoklund Olesen authored
      Original commit message:
      
      Count references to interference cache entries.
      
      Each InterferenceCache::Cursor instance references a cache entry. A
      non-zero reference count guarantees that the entry won't be reused for a
      new register.
      
      This makes it possible to have multiple live cursors examining
      interference for different physregs.
      
      The total number of live cursors into a cache must be kept below
      InterferenceCache::getMaxCursors().
      
      Code generation should be unaffected by this change, and it doesn't seem
      to affect the cache replacement strategy either.
      
      llvm-svn: 135130
      a153ca58
    • Jakob Stoklund Olesen's avatar
      Revert r135121 which broke a gcc-4.2 builder. · 1d4badae
      Jakob Stoklund Olesen authored
      llvm-svn: 135122
      1d4badae
    • Jakob Stoklund Olesen's avatar
      Count references to interference cache entries. · c270cb6e
      Jakob Stoklund Olesen authored
      Each InterferenceCache::Cursor instance references a cache entry. A
      non-zero reference count guarantees that the entry won't be reused for a
      new register.
      
      This makes it possible to have multiple live cursors examining
      interference for different physregs.
      
      The total number of live cursors into a cache must be kept below
      InterferenceCache::getMaxCursors().
      
      Code generation should be unaffected by this change, and it doesn't seem
      to affect the cache replacement strategy either.
      
      llvm-svn: 135121
      c270cb6e
    • Jakob Stoklund Olesen's avatar
      Reapply r135074 and r135080 with a fix. · d7e99371
      Jakob Stoklund Olesen authored
      The cache entry referenced by the best split candidate could become
      clobbered by an unsuccessful candidate.
      
      The correct fix here is to use reference counts on the cache entries.
      Coming up.
      
      llvm-svn: 135113
      d7e99371
    • Jakob Stoklund Olesen's avatar
      Revert r135074 and r135080. They broke clamscan. · fae30b24
      Jakob Stoklund Olesen authored
      llvm-svn: 135096
      fae30b24
  6. Jul 13, 2011
  7. Jul 08, 2011
    • Jakob Stoklund Olesen's avatar
      Be more aggressive about following hints. · 4931bbc6
      Jakob Stoklund Olesen authored
      RAGreedy::tryAssign will now evict interference from the preferred
      register even when another register is free.
      
      To support this, add the EvictionCost struct that counts how many hints
      are broken by an eviction. We don't want to break one hint just to
      satisfy another.
      
      Rename canEvict to shouldEvict, and add the first bit of eviction policy
      that doesn't depend on spill weights: Always make room in the preferred
      register as long as the evictees can be split and aren't already
      assigned to their preferred register.
      
      Also make the CSR avoidance more accurate. When looking for a cheaper
      register it is OK to use a new volatile register. Only CSR aliases that
      have never been used before should be avoided.
      
      llvm-svn: 134735
      4931bbc6
  8. Jul 05, 2011
  9. Jul 04, 2011
    • Jakob Stoklund Olesen's avatar
      Fix PR10244. · 71a3a003
      Jakob Stoklund Olesen authored
      A split point inserted in a block with a landing pad successor may be
      hoisted above the call to ensure that it dominates all successors. The
      code that handles the rest of the basic block must take this into
      account.
      
      I am not including a test case, it would be very fragile. PR10244 comes
      from building clang with exceptions enabled.
      
      llvm-svn: 134369
      71a3a003
  10. Jul 02, 2011
    • Jakob Stoklund Olesen's avatar
      Use a new strategy for preventing eviction loops in RAGreedy. · 30a8563a
      Jakob Stoklund Olesen authored
      Every live range is assigned a cascade number the first time it is
      involved in an eviction. As the evictor, it gets a new cascade number.
      Every evictee is assigned the same cascade number as the evictor.
      
      Eviction is prohibited if the evictor has a lower assigned cascade
      number than the evictee.
      
      This means that assigned cascade numbers are monotonically increasing
      with every eviction, yet they are bounded by NextCascade which can only
      be incremented by new live ranges. Thus, infinite loops cannot happen,
      but eviction cascades can still be triggered by new live ranges as we
      want.
      
      Thanks to Andy for explaining this to me.
      
      llvm-svn: 134303
      30a8563a
  11. 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
  12. 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
  13. Jun 27, 2011
  14. Jun 26, 2011
  15. Jun 07, 2011
    • Jakob Stoklund Olesen's avatar
      Simplify local live range splitting's safeguard to fix PR10070. · df476270
      Jakob Stoklund Olesen authored
      When local live range splitting creates a live range with the same
      number of instructions as the old range, mark it as RS_Local. When such
      a range is seen again, require that it be split in a way that reduces
      the number of instructions. That guarantees we are making progress while
      still being able to perform 3 -> 2+3 splits as required by PR10070.
      
      This also means that the PrevSlot map is no longer needed. This was also
      used to estimate new spill weights, but that is no longer necessary
      after slotIndexes::insertMachineInstrInMaps() got the extra Late
      insertion argument.
      
      llvm-svn: 132697
      df476270
  16. Jun 03, 2011
  17. Jun 01, 2011
  18. May 31, 2011
    • Jakob Stoklund Olesen's avatar
      Simplify the eviction policy by making the failsafe explicit. · 73e18b7a
      Jakob Stoklund Olesen authored
      When assigned ranges are evicted, they are put in the RS_Evicted stage and are
      not allowed to evict anything else. That prevents looping automatically.
      
      When evicting ranges just to get a cheaper register, use only spill weights to
      find the possible candidates. Avoid breaking hints for this purpose, it is not
      worth it.
      
      Start implementing more complex eviction heuristics, guarded by the temporary
      -complex-eviction flag. The initial version permits a heavier range to be
      evicted if it doesn't have any uses where the evicting range is live. This makes
      it a good candidate for live ranfge splitting.
      
      llvm-svn: 132358
      73e18b7a
  19. May 30, 2011
  20. May 29, 2011
  21. 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
  22. May 26, 2011
    • Jakob Stoklund Olesen's avatar
      Add a RAGreedy::canEvict function. · 25d5745c
      Jakob Stoklund Olesen authored
      This doesn't change functionality (much), but it allows for a more fine-grained
      eviction policy. The current policy only compares spill weights, and that is not
      always the best thing to do.  Spill weights are designed to serve linear scan,
      and they don't consider live range splitting.
      
      Add a mechanism so canEvict() can request that a live range be evicted and
      split/spilled. This is to avoid infinite eviction loops.
      
      llvm-svn: 132101
      25d5745c
  23. May 10, 2011
  24. May 06, 2011
  25. 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
  26. Apr 30, 2011
  27. Apr 27, 2011
  28. Apr 23, 2011
  29. Apr 21, 2011
    • 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
  30. Apr 20, 2011
    • Jakob Stoklund Olesen's avatar
      Prefer cheap registers for busy live ranges. · 0e34c1df
      Jakob Stoklund Olesen authored
      On the x86-64 and thumb2 targets, some registers are more expensive to encode
      than others in the same register class.
      
      Add a CostPerUse field to the TableGen register description, and make it
      available from TRI->getCostPerUse. This represents the cost of a REX prefix or a
      32-bit instruction encoding required by choosing a high register.
      
      Teach the greedy register allocator to prefer cheap registers for busy live
      ranges (as indicated by spill weight).
      
      llvm-svn: 129864
      0e34c1df
Loading