[PATCH] D55987: [CodeGen] Skip over dbg-instr in twoaddr pass
Markus Lavin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 21 01:08:12 PST 2018
markus created this revision.
markus added a reviewer: MatzeB.
A DBG_VALUE between a two-address instruction and a following COPY would prevent rescheduleMIBelowKill optimization inside TwoAddressInstructionPass.
Repository:
rL LLVM
https://reviews.llvm.org/D55987
Files:
lib/CodeGen/TwoAddressInstructionPass.cpp
test/CodeGen/X86/twoaddr-dbg-value.mir
Index: test/CodeGen/X86/twoaddr-dbg-value.mir
===================================================================
--- /dev/null
+++ test/CodeGen/X86/twoaddr-dbg-value.mir
@@ -0,0 +1,27 @@
+# RUN: llc -run-pass=livevars,twoaddressinstruction -mtriple=x86_64-- -o - %s | FileCheck %s
+---
+name: foo
+tracksRegLiveness: true
+body: |
+ bb.0:
+ liveins: $edi
+
+ %0:gr32 = COPY killed $edi
+ %1:gr32 = COPY killed %0
+ %4:gr32 = XOR32ri8 %1, 1, implicit-def dead $eflags
+ DBG_VALUE %4
+ %5:gr32 = COPY %4
+ PUSH32r killed %1, implicit-def $esp, implicit $esp
+ $eax = COPY killed %5
+ RETQ implicit killed $eax
+
+...
+
+# Verify that the DBG_VALUE instruction does not inhibit
+# TwoAddressInstructionPass::rescheduleMIBelowKill optimization
+
+# CHECK: PUSH32r %1, implicit-def $esp, implicit $esp
+# CHECK-NEXT: %2:gr32 = COPY killed %1
+# CHECK-NEXT: %2:gr32 = XOR32ri8 %2, 1, implicit-def dead $eflags
+# CHECK-NEXT: DBG_VALUE %2
+# CHECK-NEXT: %3:gr32 = COPY killed %2
Index: lib/CodeGen/TwoAddressInstructionPass.cpp
===================================================================
--- lib/CodeGen/TwoAddressInstructionPass.cpp
+++ lib/CodeGen/TwoAddressInstructionPass.cpp
@@ -929,9 +929,11 @@
MachineBasicBlock::iterator Begin = MI;
MachineBasicBlock::iterator AfterMI = std::next(Begin);
MachineBasicBlock::iterator End = AfterMI;
- while (End->isCopy() &&
- regOverlapsSet(Defs, End->getOperand(1).getReg(), TRI)) {
- Defs.push_back(End->getOperand(0).getReg());
+ while (End->isDebugInstr() ||
+ (End->isCopy() &&
+ regOverlapsSet(Defs, End->getOperand(1).getReg(), TRI))) {
+ if (!End->isDebugInstr())
+ Defs.push_back(End->getOperand(0).getReg());
++End;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55987.179246.patch
Type: text/x-patch
Size: 1780 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181221/13d8d522/attachment.bin>
More information about the llvm-commits
mailing list