Skip to content

Commit

Permalink
[X86] Fix killed flag handling in X86FixupLea pass
Browse files Browse the repository at this point in the history
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

llvm-svn: 323497
  • Loading branch information
Serguei Katkov committed Jan 26, 2018
1 parent 3a667b9 commit 1ce7137
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion llvm/lib/Target/X86/X86FixupLEAs.cpp
Expand Up @@ -548,7 +548,8 @@ FixupLEAPass::processInstrForSlow3OpLEA(MachineInstr &MI,

// 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 =
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/CodeGen/X86/leaFixup32.mir
Expand Up @@ -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
...
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/CodeGen/X86/leaFixup64.mir
Expand Up @@ -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
...
Expand Down

0 comments on commit 1ce7137

Please sign in to comment.