Skip to content

Commit 059cead

Browse files
committed
Mark rematerialized super/sub registers as dead.
When we're rematerializing into a not-quite-right register we already add the real definition as an imp-def, but we should also be marking the "official" register as dead, since nothing else is going to use it as a result of this remat. Not doing this can affect pressure tracking. rdar://problem/14158833 llvm-svn: 184002
1 parent 8ca899c commit 059cead

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

llvm/lib/CodeGen/RegisterCoalescer.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -843,6 +843,7 @@ bool RegisterCoalescer::reMaterializeTrivialDef(CoalescerPair &CP,
843843
// been asked for. If so it must implicitly define the whole thing.
844844
assert(TargetRegisterInfo::isPhysicalRegister(DstReg) &&
845845
"Only expect virtual or physical registers in remat");
846+
NewMI->getOperand(0).setIsDead(true);
846847
NewMI->addOperand(MachineOperand::CreateReg(CopyDstReg,
847848
true /*IsDef*/,
848849
true /*IsImp*/,
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
; REQUIRES: asserts
2+
; RUN: llc -mtriple=x86_64-apple-darwin -debug -o /dev/null < %s 2>&1 | FileCheck %s
3+
4+
; We need to make sure that rematerialization into a physical register marks the
5+
; super- or sub-register as dead after this rematerialization since only the
6+
; original register is actually used later. Largely irrelevant for a trivial
7+
; example like this, since EAX is never used again, but easy to test.
8+
9+
define i8 @test_remat() {
10+
ret i8 0
11+
; CHECK: REGISTER COALESCING
12+
; CHECK: Remat: %EAX<def,dead> = MOV32r0 %EFLAGS<imp-def,dead>, %AL<imp-def>
13+
}
14+
15+
; On the other hand, if it's already the correct width, we really shouldn't be
16+
; marking the definition register as dead.
17+
18+
define i32 @test_remat32() {
19+
ret i32 0
20+
; CHECK: REGISTER COALESCING
21+
; CHECK: Remat: %EAX<def> = MOV32r0 %EFLAGS<imp-def,dead>
22+
}
23+

0 commit comments

Comments
 (0)