From bd0b681bbd0977986ee9b76d203db4e3be7a27ec Mon Sep 17 00:00:00 2001 From: Nicolai Haehnle Date: Wed, 6 Jan 2016 22:01:04 +0000 Subject: [PATCH] AMDGPU/SI: Fix crash when inline assembly is used in a graphics shader 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 | 3 +++ test/CodeGen/AMDGPU/inline-asm.ll | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/lib/Target/AMDGPU/SITypeRewriter.cpp b/lib/Target/AMDGPU/SITypeRewriter.cpp index dbdc76b917f..d36c5d29b12 100644 --- a/lib/Target/AMDGPU/SITypeRewriter.cpp +++ b/lib/Target/AMDGPU/SITypeRewriter.cpp @@ -98,6 +98,9 @@ void SITypeRewriter::visitCallInst(CallInst &I) { SmallVector 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); diff --git a/test/CodeGen/AMDGPU/inline-asm.ll b/test/CodeGen/AMDGPU/inline-asm.ll index efc2292de3a..9c8d3534f8a 100644 --- a/test/CodeGen/AMDGPU/inline-asm.ll +++ b/test/CodeGen/AMDGPU/inline-asm.ll @@ -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" } -- 2.34.1