X86InstrInfo::convertToThreeAddress would convert this: %1:gr32 = ADD32rr killed %0:gr32(tied-def 0), %0:gr32, implicit-def dead $eflags to this: undef %2.sub_32bit:gr64 = COPY killed %0:gr32 undef %3.sub_32bit:gr64_nosp = COPY %0:gr32 %1:gr32 = LEA64_32r killed %2:gr64, 1, killed %3:gr64_nosp, 0, $noreg Note that in the ADD32rr, %0 was used twice and the first use had a kill flag, which is what MachineInstr::addRegisterKilled does. In the converted code, each use of %0 is copied to a new reg, and the first COPY inherits the kill flag from the ADD32rr. This causes machine verification to fail (if you force it to run after TwoAddressInstructionPass) because the second COPY uses %0 after it is killed. Note that machine verification is currently disabled after TwoAddressInstructionPass but this is a step towards being able to enable it. Fix this by not inserting more than one COPY from the same source register. Differential Revision: https://reviews.llvm.org/D110829
25 lines
904 B
YAML
25 lines
904 B
YAML
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
|
|
# RUN: llc -mtriple=x86_64-unknown -mcpu=haswell -run-pass=twoaddressinstruction -verify-machineinstrs %s -o - | FileCheck %s
|
|
|
|
# Check that we don't have any uses of [[COPY]] after it is killed.
|
|
---
|
|
name: test_mul_by_2
|
|
tracksRegLiveness: true
|
|
body: |
|
|
bb.0:
|
|
liveins: $edi
|
|
|
|
; CHECK-LABEL: name: test_mul_by_2
|
|
; CHECK: liveins: $edi
|
|
; CHECK-NEXT: {{ $}}
|
|
; CHECK-NEXT: [[COPY:%[0-9]+]]:gr32 = COPY killed $edi
|
|
; CHECK-NEXT: undef %2.sub_32bit:gr64_nosp = COPY killed [[COPY]]
|
|
; CHECK-NEXT: [[LEA64_32r:%[0-9]+]]:gr32 = LEA64_32r killed %2, 1, killed %2, 0, $noreg
|
|
; CHECK-NEXT: $eax = COPY killed [[LEA64_32r]]
|
|
; CHECK-NEXT: RET 0, killed $eax
|
|
%0:gr32 = COPY killed $edi
|
|
%1:gr32 = ADD32rr killed %0, %0, implicit-def dead $eflags
|
|
$eax = COPY killed %1
|
|
RET 0, killed $eax
|
|
...
|