BPF: Fix misfolding subregisters (#208244)
This would end up introducing a copy between registers with mismatched sizes previously. Defends against verifier failures in a future change. The actual transform here should be deleted. Optimizations should not be trying to introduce SUBREG_TO_REG.
This commit is contained in:
parent
766161cd2f
commit
720066abc2
2 changed files with 49 additions and 1 deletions
|
|
@ -155,7 +155,11 @@ bool BPFMIPeephole::isInsnFrom32Def(MachineInstr *DefInsn)
|
|||
|
||||
bool BPFMIPeephole::isMovFrom32Def(MachineInstr *MovMI)
|
||||
{
|
||||
MachineInstr *DefInsn = MRI->getVRegDef(MovMI->getOperand(1).getReg());
|
||||
const MachineOperand &Src = MovMI->getOperand(1);
|
||||
if (Src.getSubReg())
|
||||
return false;
|
||||
|
||||
MachineInstr *DefInsn = MRI->getVRegDef(Src.getReg());
|
||||
|
||||
LLVM_DEBUG(dbgs() << " Def of Mov Src:");
|
||||
LLVM_DEBUG(DefInsn->dump());
|
||||
|
|
|
|||
44
llvm/test/CodeGen/BPF/mov32-64-subreg-source.mir
Normal file
44
llvm/test/CodeGen/BPF/mov32-64-subreg-source.mir
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 6
|
||||
# RUN: llc -mtriple=bpfel -mattr=+alu32 -run-pass=bpf-mi-zext-elim -verify-machineinstrs %s -o - | FileCheck %s
|
||||
...
|
||||
|
||||
# Make sure that folds of MOV_32_64 respect a subregister index on the
|
||||
# source operand.
|
||||
|
||||
---
|
||||
name: mov32_64_subreg_source_imm
|
||||
tracksRegLiveness: true
|
||||
body: |
|
||||
bb.0:
|
||||
liveins: $r1
|
||||
; CHECK-LABEL: name: mov32_64_subreg_source_imm
|
||||
; CHECK: liveins: $r1
|
||||
; CHECK-NEXT: {{ $}}
|
||||
; CHECK-NEXT: [[LD_imm64_:%[0-9]+]]:gpr = LD_imm64 0
|
||||
; CHECK-NEXT: [[MOV_32_64_:%[0-9]+]]:gpr = MOV_32_64 [[LD_imm64_]].sub_32
|
||||
; CHECK-NEXT: $r0 = COPY [[MOV_32_64_]]
|
||||
; CHECK-NEXT: RET implicit $r0
|
||||
%0:gpr = LD_imm64 0
|
||||
%1:gpr = MOV_32_64 %0.sub_32
|
||||
$r0 = COPY %1:gpr
|
||||
RET implicit $r0
|
||||
...
|
||||
|
||||
---
|
||||
name: mov32_64_subreg_source_copy
|
||||
tracksRegLiveness: true
|
||||
body: |
|
||||
bb.0:
|
||||
liveins: $r1
|
||||
; CHECK-LABEL: name: mov32_64_subreg_source_copy
|
||||
; CHECK: liveins: $r1
|
||||
; CHECK-NEXT: {{ $}}
|
||||
; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $r1
|
||||
; CHECK-NEXT: [[MOV_32_64_:%[0-9]+]]:gpr = MOV_32_64 [[COPY]].sub_32
|
||||
; CHECK-NEXT: $r0 = COPY [[MOV_32_64_]]
|
||||
; CHECK-NEXT: RET implicit $r0
|
||||
%0:gpr = COPY $r1
|
||||
%1:gpr = MOV_32_64 %0.sub_32
|
||||
$r0 = COPY %1:gpr
|
||||
RET implicit $r0
|
||||
...
|
||||
Loading…
Reference in a new issue