<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - Greedy regalloc doesn't reinsert phys reg kill flags"
href="https://bugs.llvm.org/show_bug.cgi?id=32677">32677</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Greedy regalloc doesn't reinsert phys reg kill flags
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Register Allocator
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>jacobly.alt@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>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
...</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>