[llvm-bugs] [Bug 32677] New: Greedy regalloc doesn't reinsert phys reg kill flags

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Apr 16 11:34:58 PDT 2017


https://bugs.llvm.org/show_bug.cgi?id=32677

            Bug ID: 32677
           Summary: Greedy regalloc doesn't reinsert phys reg kill flags
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Register Allocator
          Assignee: unassignedbugs at nondot.org
          Reporter: jacobly.alt at gmail.com
                CC: llvm-bugs at lists.llvm.org

When greedy regalloc tries to assign a reg with reg unit interference,
LiveRangeCalc::extendToUses removes kill flags from aliasing phys regs with the
comment "Clear all kill flags. They will be reinserted after register
allocation by LiveIntervalAnalysis::addKillFlags()." However,
LiveIntervalAnalysis::addKillFlags appears to only add kill flags to virt regs
but not phys regs.

These exhibit different kill flags on both %cl and the args to func coming from
very similar ir.

$ cat no-kill.ll
target triple = "x86_64"

declare void @func(i32, i32, i32, i32)

define void @test(i32 %cl) {
  %ecx = shl i32 1, %cl
  call void @func(i32 0, i32 0, i32 0, i32 %ecx)
  ret void
}
$ llc -stop-after=greedy no-kill.ll -o -
<snip>
    %0 = COPY %edi
    %3 = MOV32ri 1
    %cl = COPY %0.sub_8bit
    %3 = SHL32rCL %3, implicit-def dead %eflags, implicit %cl
    ADJCALLSTACKDOWN64 0, 0, implicit-def dead %rsp, implicit-def dead %eflags,
implicit %rsp
    %edi = MOV32r0 implicit-def dead %eflags
    %esi = MOV32r0 implicit-def dead %eflags
    %edx = MOV32r0 implicit-def dead %eflags
    %ecx = COPY %3
    CALL64pcrel32 @func, csr_64, implicit %rsp, implicit %edi, implicit killed
%esi, implicit killed %edx, implicit %ecx, implicit-def %rsp
    ADJCALLSTACKUP64 0, 0, implicit-def dead %rsp, implicit-def dead %eflags,
implicit %rsp
    RET 0

...
$ cat kill.ll
target triple = "x86_64"

declare void @func(i32, i32, i32, i32)

define void @test(i32 %cl) {
  %edx = shl i32 1, %cl
  call void @func(i32 0, i32 0, i32 %edx, i32 0)
  ret void
}
$ llc -stop-after=greedy kill.ll -o -
<snip>
    %0 = COPY %edi
    %3 = MOV32ri 1
    %cl = COPY %0.sub_8bit
    %3 = SHL32rCL %3, implicit-def dead %eflags, implicit killed %cl
    ADJCALLSTACKDOWN64 0, 0, implicit-def dead %rsp, implicit-def dead %eflags,
implicit %rsp
    %edi = MOV32r0 implicit-def dead %eflags
    %esi = MOV32r0 implicit-def dead %eflags
    %ecx = MOV32r0 implicit-def dead %eflags
    %edx = COPY %3
    CALL64pcrel32 @func, csr_64, implicit %rsp, implicit %edi, implicit killed
%esi, implicit %edx, implicit killed %ecx, implicit-def %rsp
    ADJCALLSTACKUP64 0, 0, implicit-def dead %rsp, implicit-def dead %eflags,
implicit %rsp
    RET 0

...

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170416/37037c9b/attachment.html>


More information about the llvm-bugs mailing list