[llvm] ee57469 - [X86] Remove EFLAGS from live-in lists in X86FlagsCopyLowering.
Jonas Paulsson via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 8 16:37:10 PST 2020
Author: Jonas Paulsson
Date: 2020-01-08T16:36:03-08:00
New Revision: ee57469a5128a5cd4f8b13945c873d3421a4b3d0
URL: https://github.com/llvm/llvm-project/commit/ee57469a5128a5cd4f8b13945c873d3421a4b3d0
DIFF: https://github.com/llvm/llvm-project/commit/ee57469a5128a5cd4f8b13945c873d3421a4b3d0.diff
LOG: [X86] Remove EFLAGS from live-in lists in X86FlagsCopyLowering.
When EFLAGS is no longer live into a basic block, remove it from the live-in
list.
Fixes https://bugs.llvm.org/show_bug.cgi?id=44462.
Review: Craig Topper
Differential Revision: https://reviews.llvm.org/D71375
Added:
llvm/test/CodeGen/X86/copy-eflags-liveinlists.mir
Modified:
llvm/lib/Target/X86/X86FlagsCopyLowering.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/X86/X86FlagsCopyLowering.cpp b/llvm/lib/Target/X86/X86FlagsCopyLowering.cpp
index 0915a1532df9..b1d2de29c896 100644
--- a/llvm/lib/Target/X86/X86FlagsCopyLowering.cpp
+++ b/llvm/lib/Target/X86/X86FlagsCopyLowering.cpp
@@ -702,6 +702,9 @@ bool X86FlagsCopyLoweringPass::runOnMachineFunction(MachineFunction &MF) {
}
Blocks.push_back(SuccMBB);
+
+ // After this, EFLAGS will be recreated before each use.
+ SuccMBB->removeLiveIn(X86::EFLAGS);
}
} while (!Blocks.empty());
diff --git a/llvm/test/CodeGen/X86/copy-eflags-liveinlists.mir b/llvm/test/CodeGen/X86/copy-eflags-liveinlists.mir
new file mode 100644
index 000000000000..54454fe0017f
--- /dev/null
+++ b/llvm/test/CodeGen/X86/copy-eflags-liveinlists.mir
@@ -0,0 +1,92 @@
+# RUN: llc -mtriple=i686-unknown-unknown -run-pass=x86-flags-copy-lowering \
+# RUN: -print-after=x86-flags-copy-lowering %s -o - | FileCheck %s
+#
+# Check that $eflags is removed from live-in lists of successor blocks.
+#
+# CHECK-NOT: liveins: $eflags
+
+--- |
+ define void @fun(i16 %arg, i64 %arg1, i8 %arg2, i8* %arg3, i32 %arg4) { ret void}
+...
+---
+name: fun
+alignment: 16
+tracksRegLiveness: true
+registers:
+ - { id: 0, class: gr16 }
+ - { id: 1, class: gr16 }
+ - { id: 2, class: gr16 }
+ - { id: 3, class: gr32 }
+ - { id: 4, class: gr32 }
+ - { id: 5, class: gr8 }
+ - { id: 6, class: gr32 }
+ - { id: 7, class: gr32 }
+ - { id: 8, class: gr32 }
+ - { id: 9, class: gr32 }
+ - { id: 10, class: gr32 }
+ - { id: 11, class: gr32 }
+ - { id: 12, class: gr32 }
+ - { id: 13, class: gr8 }
+ - { id: 14, class: gr32 }
+ - { id: 15, class: gr32 }
+ - { id: 16, class: gr32_abcd }
+ - { id: 17, class: gr8 }
+ - { id: 18, class: gr8 }
+ - { id: 19, class: gr32 }
+ - { id: 20, class: gr32 }
+frameInfo:
+ maxAlignment: 4
+fixedStack:
+ - { id: 0, offset: 20, size: 4, alignment: 4, isImmutable: true }
+ - { id: 1, offset: 16, size: 4, alignment: 4, isImmutable: true }
+ - { id: 2, offset: 12, size: 1, alignment: 4, isImmutable: true }
+ - { id: 3, offset: 8, size: 4, alignment: 4, isImmutable: true }
+ - { id: 4, offset: 4, size: 4, alignment: 4, isImmutable: true }
+ - { id: 5, size: 2, alignment: 4, isImmutable: true }
+machineFunctionInfo: {}
+body: |
+ bb.0:
+ %4:gr32 = MOV32rm %fixed-stack.3, 1, $noreg, 0, $noreg :: (load 4 from %fixed-stack.3)
+ %3:gr32 = MOV32rm %fixed-stack.4, 1, $noreg, 0, $noreg :: (load 4 from %fixed-stack.4)
+ %7:gr32 = MOV32rm %fixed-stack.0, 1, $noreg, 0, $noreg :: (load 4 from %fixed-stack.0)
+ %6:gr32 = MOV32rm %fixed-stack.1, 1, $noreg, 0, $noreg :: (load 4 from %fixed-stack.1)
+ %5:gr8 = MOV8rm %fixed-stack.2, 1, $noreg, 0, $noreg :: (load 1 from %fixed-stack.2, align 4)
+ %9:gr32 = IMPLICIT_DEF
+ %11:gr32 = IMPLICIT_DEF
+
+ bb.1:
+ successors: %bb.2, %bb.3
+
+ CMP32rr %3, %9, implicit-def $eflags
+ %10:gr32 = SBB32rr %4, %11, implicit-def $eflags, implicit $eflags
+ %12:gr32 = COPY $eflags
+ %13:gr8 = SETCCr 12, implicit $eflags
+ %14:gr32 = MOVZX32rr8 killed %13
+ %15:gr32 = NEG32r %14, implicit-def dead $eflags
+ %16:gr32_abcd = MOV32r0 implicit-def dead $eflags
+ $eflags = COPY %12
+ %17:gr8 = COPY %16.sub_8bit
+ JCC_1 %bb.3, 12, implicit $eflags
+
+ bb.2:
+ liveins: $eflags
+
+
+ bb.3:
+ successors: %bb.4, %bb.5
+ liveins: $eflags
+
+ %18:gr8 = PHI %5, %bb.2, %17, %bb.1
+ MOV8mr %6, 1, $noreg, 0, $noreg, killed %18 :: (volatile store 1 into %ir.arg3)
+ JCC_1 %bb.5, 12, implicit $eflags
+
+ bb.4:
+
+ bb.5:
+ %19:gr32 = PHI %16, %bb.4, %15, %bb.3
+ $eax = COPY %7
+ CDQ implicit-def $eax, implicit-def $edx, implicit $eax
+ IDIV32r killed %19, implicit-def dead $eax, implicit-def $edx, implicit-def dead $eflags, implicit $eax, implicit $edx
+ JMP_1 %bb.1
+
+...
More information about the llvm-commits
mailing list