AMDGPU/SI: Fix crash when inline assembly is used in a graphics shader
authorNicolai Haehnle <nhaehnle@gmail.com>
Wed, 6 Jan 2016 22:01:04 +0000 (22:01 +0000)
committerNicolai Haehnle <nhaehnle@gmail.com>
Wed, 6 Jan 2016 22:01:04 +0000 (22:01 +0000)
Summary:
This is admittedly something that you could only run into by manually
playing around with shader assembly because the SITypeWriter pass is
skipped for compute.

Reviewers: arsenm, tstellarAMD

Subscribers: arsenm, llvm-commits

Differential Revision: http://reviews.llvm.org/D15902

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

lib/Target/AMDGPU/SITypeRewriter.cpp
test/CodeGen/AMDGPU/inline-asm.ll

index dbdc76b917f3a968c8db69698d46801564caf338..d36c5d29b127bce7be7479d6da52d131959a8863 100644 (file)
@@ -98,6 +98,9 @@ void SITypeRewriter::visitCallInst(CallInst &I) {
   SmallVector <Type*, 8> Types;
   bool NeedToReplace = false;
   Function *F = I.getCalledFunction();
+  if (!F)
+    return;
+
   std::string Name = F->getName();
   for (unsigned i = 0, e = I.getNumArgOperands(); i != e; ++i) {
     Value *Arg = I.getArgOperand(i);
index efc2292de3a52be1ffc6f7acc51d7fd67a344543..9c8d3534f8adbcedb5ebf2a587682ded6139234e 100644 (file)
@@ -10,3 +10,14 @@ entry:
   call void asm sideeffect "s_endpgm", ""()
   ret void
 }
+
+; CHECK: {{^}}inline_asm_shader:
+; CHECK: s_endpgm
+; CHECK: s_endpgm
+define void @inline_asm_shader() #0 {
+entry:
+  call void asm sideeffect "s_endpgm", ""()
+  ret void
+}
+
+attributes #0 = { "ShaderType"="0" }