[llvm] r287310 - AMDGPU: Fix crash on illegal type for inlineasm

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 17 20:42:57 PST 2016


Author: arsenm
Date: Thu Nov 17 22:42:57 2016
New Revision: 287310

URL: http://llvm.org/viewvc/llvm-project?rev=287310&view=rev
Log:
AMDGPU: Fix crash on illegal type for inlineasm

There are still crashes on non-MVT types in other
places.

Added:
    llvm/trunk/test/CodeGen/AMDGPU/inlineasm-illegal-type.ll
Modified:
    llvm/trunk/lib/Target/AMDGPU/SIISelLowering.cpp

Modified: llvm/trunk/lib/Target/AMDGPU/SIISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/SIISelLowering.cpp?rev=287310&r1=287309&r2=287310&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/SIISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/AMDGPU/SIISelLowering.cpp Thu Nov 17 22:42:57 2016
@@ -4172,6 +4172,8 @@ std::pair<unsigned, const TargetRegister
 SITargetLowering::getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI,
                                                StringRef Constraint,
                                                MVT VT) const {
+  if (!isTypeLegal(VT))
+    return TargetLowering::getRegForInlineAsmConstraint(TRI, Constraint, VT);
 
   if (Constraint.size() == 1) {
     switch (Constraint[0]) {

Added: llvm/trunk/test/CodeGen/AMDGPU/inlineasm-illegal-type.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AMDGPU/inlineasm-illegal-type.ll?rev=287310&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/AMDGPU/inlineasm-illegal-type.ll (added)
+++ llvm/trunk/test/CodeGen/AMDGPU/inlineasm-illegal-type.ll Thu Nov 17 22:42:57 2016
@@ -0,0 +1,83 @@
+; RUN: not llc -march=amdgcn -mcpu=bonaire -verify-machineinstrs < %s 2>&1 | FileCheck -check-prefix=GCN -check-prefix=CI %s
+; RUN: not llc -march=amdgcn -mcpu=tonga -verify-machineinstrs < %s 2>&1 | FileCheck -check-prefix=GCN -check-prefix=VI %s
+
+; GCN: error: couldn't allocate output register for constraint 's'
+; GCN: error: couldn't allocate input reg for constraint 's'
+define void @s_input_output_i8() {
+  %v = tail call i8 asm sideeffect "s_mov_b32 $0, -1", "=s"()
+  tail call void asm sideeffect "; use $0", "s"(i8 %v)
+  ret void
+}
+
+; GCN: error: couldn't allocate output register for constraint 'v'
+; GCN: error: couldn't allocate input reg for constraint 'v'
+define void @v_input_output_i8() {
+  %v = tail call i8 asm sideeffect "v_mov_b32 $0, -1", "=v"()
+  tail call void asm sideeffect "; use $0", "v"(i8 %v)
+  ret void
+}
+
+; GCN: error: couldn't allocate output register for constraint 's'
+; GCN: error: couldn't allocate input reg for constraint 's'
+define void @s_input_output_i128() {
+  %v = tail call i128 asm sideeffect "s_mov_b32 $0, -1", "=s"()
+  tail call void asm sideeffect "; use $0", "s"(i128 %v)
+  ret void
+}
+
+; GCN: error: couldn't allocate output register for constraint 's'
+; GCN: error: couldn't allocate input reg for constraint 's'
+define void @s_input_output_v8f16() {
+  %v = tail call <8 x half> asm sideeffect "s_mov_b32 $0, -1", "=s"()
+  tail call void asm sideeffect "; use $0", "s"(<8 x half> %v)
+  ret void
+}
+
+; CI: error: couldn't allocate output register for constraint 's'
+; CI: error: couldn't allocate input reg for constraint 's'
+; VI-NOT: error
+define void @s_input_output_f16() {
+  %v = tail call half asm sideeffect "s_mov_b32 $0, -1", "=s"()
+  tail call void asm sideeffect "; use $0", "s"(half %v)
+  ret void
+}
+
+; GCN: error: couldn't allocate output register for constraint 's'
+; GCN: error: couldn't allocate input reg for constraint 's'
+define void @s_input_output_v2f16() {
+  %v = tail call <2 x half> asm sideeffect "s_mov_b32 $0, -1", "=s"()
+  tail call void asm sideeffect "; use $0", "s"(<2 x half> %v)
+  ret void
+}
+
+; GCN: error: couldn't allocate output register for constraint 'v'
+; GCN: error: couldn't allocate input reg for constraint 'v'
+define void @v_input_output_v2f16() {
+  %v = tail call <2 x half> asm sideeffect "v_mov_b32 $0, -1", "=v"()
+  tail call void asm sideeffect "; use $0", "v"(<2 x half> %v)
+  ret void
+}
+
+; CI: error: couldn't allocate output register for constraint 's'
+; CI: error: couldn't allocate input reg for constraint 's'
+; VI-NOT: error
+define void @s_input_output_i16() {
+  %v = tail call i16 asm sideeffect "s_mov_b32 $0, -1", "=s"()
+  tail call void asm sideeffect "; use $0", "s"(i16 %v)
+  ret void
+}
+
+; GCN: error: couldn't allocate output register for constraint 's'
+; GCN: error: couldn't allocate input reg for constraint 's'
+define void @s_input_output_v2i16() {
+  %v = tail call <2 x i16> asm sideeffect "s_mov_b32 $0, -1", "=s"()
+  tail call void asm sideeffect "; use $0", "s"(<2 x i16> %v)
+  ret void
+}
+
+; FIXME: Crash in codegen prepare
+; define void @s_input_output_i3() {
+;   %v = tail call i3 asm sideeffect "s_mov_b32 $0, -1", "=s"()
+;   tail call void asm sideeffect "; use $0", "s"(i3 %v)
+;   ret void
+; }




More information about the llvm-commits mailing list