AMDGPU: Fix crash with dispatch.ptr intrinsic with non-HSA target
authorMatt Arsenault <Matthew.Arsenault@amd.com>
Mon, 11 Jan 2016 21:18:33 +0000 (21:18 +0000)
committerMatt Arsenault <Matthew.Arsenault@amd.com>
Mon, 11 Jan 2016 21:18:33 +0000 (21:18 +0000)
It might be better to let this be a select failure instead.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@257386 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/AMDGPU/SIISelLowering.cpp
test/CodeGen/AMDGPU/llvm.amdgcn.dispatch.ptr.ll

index e85d78a..c251752 100644 (file)
@@ -1157,6 +1157,13 @@ SDValue SITargetLowering::LowerINTRINSIC_WO_CHAIN(SDValue Op,
 
   switch (IntrinsicID) {
   case Intrinsic::amdgcn_dispatch_ptr:
+    if (!Subtarget->isAmdHsaOS()) {
+      DiagnosticInfoUnsupported BadIntrin(*MF.getFunction(),
+                                          "hsa intrinsic without hsa target");
+      DAG.getContext()->diagnose(BadIntrin);
+      return DAG.getUNDEF(VT);
+    }
+
     return CreateLiveInRegister(DAG, &AMDGPU::SReg_64RegClass,
       TRI->getPreloadedValue(MF, SIRegisterInfo::DISPATCH_PTR), VT);
 
index dc95cd1..d96ea74 100644 (file)
@@ -1,4 +1,7 @@
 ; RUN: llc -mtriple=amdgcn--amdhsa -mcpu=kaveri -verify-machineinstrs < %s | FileCheck -check-prefix=GCN %s
+; RUN: not llc -mtriple=amdgcn-unknown-unknown -mcpu=kaveri -verify-machineinstrs < %s 2>&1 | FileCheck -check-prefix=ERROR %s
+
+; ERROR: error: unsupported hsa intrinsic without hsa target in test
 
 ; GCN-LABEL: {{^}}test:
 ; GCN: enable_sgpr_dispatch_ptr = 1