[PATCH] D42522: [X86] Fix killed flag handling in X86FixupLea pass
Serguei Katkov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 25 00:52:33 PST 2018
skatkov created this revision.
skatkov added reviewers: lsaba, zvi, zansari, aaboud.
When pass creates a MOV instruction for
lea (%base,%index,1), %dst => mov %base,%dst; add %index,%dst
modification it should clean the killed flag for base if base is equal to index.
Otherwise verifier complains about usage of killed register in add instruction.
https://reviews.llvm.org/D42522
Files:
lib/Target/X86/X86FixupLEAs.cpp
test/CodeGen/X86/leaFixup32.mir
test/CodeGen/X86/leaFixup64.mir
Index: test/CodeGen/X86/leaFixup64.mir
===================================================================
--- test/CodeGen/X86/leaFixup64.mir
+++ test/CodeGen/X86/leaFixup64.mir
@@ -810,7 +810,7 @@
; CHECK: %rbx = MOV64rr %rbp
; CHECK: %rbx = ADD64rr %rbx, %rbp
- %rbx = LEA64r %rbp, 1, %rbp, 0, %noreg
+ %rbx = LEA64r killed %rbp, 1, %rbp, 0, %noreg
RETQ %ebx
...
Index: test/CodeGen/X86/leaFixup32.mir
===================================================================
--- test/CodeGen/X86/leaFixup32.mir
+++ test/CodeGen/X86/leaFixup32.mir
@@ -354,7 +354,7 @@
; CHECK: %ebx = MOV32rr %ebp
; CHECK: %ebx = ADD32rr %ebx, %ebp
- %ebx = LEA32r %ebp, 1, %ebp, 0, %noreg
+ %ebx = LEA32r killed %ebp, 1, %ebp, 0, %noreg
RETQ %ebx
...
Index: lib/Target/X86/X86FixupLEAs.cpp
===================================================================
--- lib/Target/X86/X86FixupLEAs.cpp
+++ lib/Target/X86/X86FixupLEAs.cpp
@@ -548,7 +548,8 @@
// lea (%base,%index,1), %dst => mov %base,%dst; add %index,%dst
if (IsScale1 && !hasLEAOffset(Offset)) {
- TII->copyPhysReg(*MFI, MI, DL, DstR, BaseR, Base.isKill());
+ bool BIK = Base.isKill() && BaseR != IndexR;
+ TII->copyPhysReg(*MFI, MI, DL, DstR, BaseR, BIK);
DEBUG(MI.getPrevNode()->dump(););
MachineInstr *NewMI =
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42522.131393.patch
Type: text/x-patch
Size: 1338 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180125/13f24e2a/attachment.bin>
More information about the llvm-commits
mailing list