Skip to content

Commit 1ce7137

Browse files
author
Serguei Katkov
committed
[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 llvm-svn: 323497
1 parent 3a667b9 commit 1ce7137

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

llvm/lib/Target/X86/X86FixupLEAs.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,8 @@ FixupLEAPass::processInstrForSlow3OpLEA(MachineInstr &MI,
548548

549549
// lea (%base,%index,1), %dst => mov %base,%dst; add %index,%dst
550550
if (IsScale1 && !hasLEAOffset(Offset)) {
551-
TII->copyPhysReg(*MFI, MI, DL, DstR, BaseR, Base.isKill());
551+
bool BIK = Base.isKill() && BaseR != IndexR;
552+
TII->copyPhysReg(*MFI, MI, DL, DstR, BaseR, BIK);
552553
DEBUG(MI.getPrevNode()->dump(););
553554

554555
MachineInstr *NewMI =

llvm/test/CodeGen/X86/leaFixup32.mir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ body: |
354354
; CHECK: %ebx = MOV32rr %ebp
355355
; CHECK: %ebx = ADD32rr %ebx, %ebp
356356
357-
%ebx = LEA32r %ebp, 1, %ebp, 0, %noreg
357+
%ebx = LEA32r killed %ebp, 1, %ebp, 0, %noreg
358358
RETQ %ebx
359359
360360
...

llvm/test/CodeGen/X86/leaFixup64.mir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,7 @@ body: |
810810
; CHECK: %rbx = MOV64rr %rbp
811811
; CHECK: %rbx = ADD64rr %rbx, %rbp
812812
813-
%rbx = LEA64r %rbp, 1, %rbp, 0, %noreg
813+
%rbx = LEA64r killed %rbp, 1, %rbp, 0, %noreg
814814
RETQ %ebx
815815
816816
...

0 commit comments

Comments
 (0)