[PATCH] D35816: [Greedy RegAlloc] Add logic to greedy reg alloc to avoid bad eviction chains

Marina Yatsina via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 24 14:02:02 PDT 2017


myatsina created this revision.

This fixes bugzilla 26810
https://bugs.llvm.org/show_bug.cgi?id=26810

This is intended to prevent sequences like:
movl %ebp, 8(%esp) # 4-byte Spill
movl %ecx, %ebp
movl %ebx, %ecx
movl %edi, %ebx
movl %edx, %edi
cltd
idivl %esi
movl %edi, %edx
movl %ebx, %edi
movl %ecx, %ebx
movl %ebp, %ecx
movl 16(%esp), %ebp # 4 - byte Reload

Such sequences are created in 2 scenarios:

Scenario #1:
vreg0 is evicted from physreg0 by vreg1
Evictee vreg0 is intended for region splitting with split candidate physreg0 (the reg vreg0 was evicted from)
Region splitting creates a local interval because of interference with the evictor vreg1 (normally region spliiting creates 2 interval, the "by reg" and "by stack" intervals. Local interval created when interference occurs.)
one of the split intervals ends up evicting vreg2 from physreg1
Evictee vreg2 is intended for region splitting with split candidate physreg1
one of the split intervals ends up evicting vreg3 from physreg2 etc.. until someone spills

Scenario #2
vreg0 is evicted from physreg0 by vreg1
vreg2 is evicted from physreg2 by vreg3 etc
Evictee vreg0 is intended for region splitting with split candidate physreg1
Region splitting creates a local interval because of interference with the evictor vreg1
one of the split intervals ends up evicting back original evictor vreg1 from physreg0 (the reg vreg0 was evicted from)
Another evictee vreg2 is intended for region splitting with split candidate physreg1
one of the split intervals ends up evicting vreg3 from physreg2 etc.. until someone spills


Repository:
  rL LLVM

https://reviews.llvm.org/D35816

Files:
  include/llvm/CodeGen/CalcSpillWeights.h
  include/llvm/CodeGen/LiveIntervalAnalysis.h
  lib/CodeGen/CalcSpillWeights.cpp
  lib/CodeGen/LiveIntervalAnalysis.cpp
  lib/CodeGen/RegAllocGreedy.cpp
  test/CodeGen/X86/bug26810.ll
  test/CodeGen/X86/greedy_regalloc_bad_eviction_sequence.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D35816.107959.patch
Type: text/x-patch
Size: 287192 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170724/efa12403/attachment-0001.bin>


More information about the llvm-commits mailing list