1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 11:13:28 +01:00

[GlobalISel] Constrain the dest reg of IMPLICT_DEF.

This fixes a crash where the user is a COPY, which deliberately does not
constrain its source operands, resulting in a vreg without a reg class escaping
selection.

Differential Revision: https://reviews.llvm.org/D42697

llvm-svn: 324047
This commit is contained in:
Amara Emerson 2018-02-02 01:44:43 +00:00
parent bd15210d03
commit 3e28ce3dc2
2 changed files with 25 additions and 0 deletions

View File

@ -1407,6 +1407,12 @@ bool AArch64InstructionSelector::select(MachineInstr &I,
: selectVaStartAAPCS(I, MF, MRI);
case TargetOpcode::G_IMPLICIT_DEF:
I.setDesc(TII.get(TargetOpcode::IMPLICIT_DEF));
const LLT DstTy = MRI.getType(I.getOperand(0).getReg());
const unsigned DstReg = I.getOperand(0).getReg();
const RegisterBank &DstRB = *RBI.getRegBank(DstReg, MRI, TRI);
const TargetRegisterClass *DstRC =
getRegClassForTypeOnBank(DstTy, DstRB, RBI);
RBI.constrainGenericRegister(DstReg, *DstRC, MRI);
return true;
}

View File

@ -5,6 +5,7 @@
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
define void @implicit_def() { ret void }
define void @implicit_def_copy() { ret void }
...
---
@ -25,3 +26,21 @@ body: |
%1(s32) = G_ADD %0, %0
$w0 = COPY %1(s32)
...
---
name: implicit_def_copy
legalized: true
regBankSelected: true
registers:
- { id: 0, class: gpr }
- { id: 1, class: gpr }
body: |
bb.0:
; CHECK-LABEL: name: implicit_def_copy
; CHECK: [[DEF:%[0-9]+]]:gpr32 = IMPLICIT_DEF
; CHECK: [[COPY:%[0-9]+]]:gpr32all = COPY [[DEF]]
; CHECK: %w0 = COPY [[COPY]]
%0(s32) = G_IMPLICIT_DEF
%1(s32) = COPY %0(s32)
%w0 = COPY %1(s32)
...