From 344c4f286cbe4b6b03d584a3f8191cec892b34a8 Mon Sep 17 00:00:00 2001 From: Jonas Paulsson Date: Wed, 10 May 2017 13:03:25 +0000 Subject: [PATCH] [SystemZ] Implement getRepRegClassFor() This method must return a valid register class, or the list-ilp isel scheduler will crash. For MVT::Untyped nullptr was previously returned, but now ADDR128BitRegClass is returned instead. This is needed just as long as list-ilp (and probably also list-hybrid) is still there. Review: Ulrich Weigand, A Trick https://reviews.llvm.org/D32802 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302649 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/SystemZ/SystemZISelLowering.cpp | 9 +++++++++ lib/Target/SystemZ/SystemZISelLowering.h | 2 ++ test/CodeGen/SystemZ/list-ilp-crash.ll | 23 ++++++++++++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 test/CodeGen/SystemZ/list-ilp-crash.ll diff --git a/lib/Target/SystemZ/SystemZISelLowering.cpp b/lib/Target/SystemZ/SystemZISelLowering.cpp index ac736c25bcf..235e095f001 100644 --- a/lib/Target/SystemZ/SystemZISelLowering.cpp +++ b/lib/Target/SystemZ/SystemZISelLowering.cpp @@ -6352,3 +6352,12 @@ MachineBasicBlock *SystemZTargetLowering::EmitInstrWithCustomInserter( llvm_unreachable("Unexpected instr type to insert"); } } + +// This is only used by the isel schedulers, and is needed only to prevent +// compiler from crashing when list-ilp is used. +const TargetRegisterClass * +SystemZTargetLowering::getRepRegClassFor(MVT VT) const { + if (VT == MVT::Untyped) + return &SystemZ::ADDR128BitRegClass; + return TargetLowering::getRepRegClassFor(VT); +} diff --git a/lib/Target/SystemZ/SystemZISelLowering.h b/lib/Target/SystemZ/SystemZISelLowering.h index 1c34dc43e8b..79c8c4d9266 100644 --- a/lib/Target/SystemZ/SystemZISelLowering.h +++ b/lib/Target/SystemZ/SystemZISelLowering.h @@ -590,6 +590,8 @@ private: MachineBasicBlock *emitLoadAndTestCmp0(MachineInstr &MI, MachineBasicBlock *MBB, unsigned Opcode) const; + + const TargetRegisterClass *getRepRegClassFor(MVT VT) const override; }; } // end namespace llvm diff --git a/test/CodeGen/SystemZ/list-ilp-crash.ll b/test/CodeGen/SystemZ/list-ilp-crash.ll new file mode 100644 index 00000000000..c67ed318b93 --- /dev/null +++ b/test/CodeGen/SystemZ/list-ilp-crash.ll @@ -0,0 +1,23 @@ +; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z13 -pre-RA-sched=list-ilp | FileCheck %s +; +; Check that list-ilp scheduler does not crash due to SystemZ's current use +; of MVT::Untyped. + +define void @pr32723(i8) { +; CHECK: .text +BB: + br label %CF245 + +CF245: ; preds = %CF245, %BB + %Shuff57 = shufflevector <4 x i8> zeroinitializer, <4 x i8> zeroinitializer, <4 x i32> + %Cmp84 = icmp uge i8 %0, undef + br i1 %Cmp84, label %CF245, label %CF260 + +CF260: ; preds = %CF245 + %B156 = sdiv <4 x i8> %Shuff57, %Shuff57 + br label %CF255 + +CF255: ; preds = %CF255, %CF260 + %I186 = insertelement <4 x i8> %B156, i8 %0, i32 2 + br label %CF255 +} -- 2.50.1