[llvm] r323497 - [X86] Fix killed flag handling in X86FixupLea pass
Serguei Katkov via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 25 20:49:26 PST 2018
Author: skatkov
Date: Thu Jan 25 20:49:26 2018
New Revision: 323497
URL: http://llvm.org/viewvc/llvm-project?rev=323497&view=rev
Log:
[X86] Fix killed flag handling in X86FixupLea pass
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.
Reviewers: lsaba, zvi, zansari, aaboud
Reviewed By: lsaba
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D42522
Modified:
llvm/trunk/lib/Target/X86/X86FixupLEAs.cpp
llvm/trunk/test/CodeGen/X86/leaFixup32.mir
llvm/trunk/test/CodeGen/X86/leaFixup64.mir
Modified: llvm/trunk/lib/Target/X86/X86FixupLEAs.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86FixupLEAs.cpp?rev=323497&r1=323496&r2=323497&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86FixupLEAs.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86FixupLEAs.cpp Thu Jan 25 20:49:26 2018
@@ -548,7 +548,8 @@ FixupLEAPass::processInstrForSlow3OpLEA(
// 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 =
Modified: llvm/trunk/test/CodeGen/X86/leaFixup32.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/leaFixup32.mir?rev=323497&r1=323496&r2=323497&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/leaFixup32.mir (original)
+++ llvm/trunk/test/CodeGen/X86/leaFixup32.mir Thu Jan 25 20:49:26 2018
@@ -354,7 +354,7 @@ body: |
; 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
...
Modified: llvm/trunk/test/CodeGen/X86/leaFixup64.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/leaFixup64.mir?rev=323497&r1=323496&r2=323497&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/leaFixup64.mir (original)
+++ llvm/trunk/test/CodeGen/X86/leaFixup64.mir Thu Jan 25 20:49:26 2018
@@ -810,7 +810,7 @@ body: |
; 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
...
More information about the llvm-commits
mailing list