[llvm-branch-commits] [llvm-branch] r253227 - Merging r243461:

Tom Stellard via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Nov 16 09:23:17 PST 2015


Author: tstellar
Date: Mon Nov 16 11:23:17 2015
New Revision: 253227

URL: http://llvm.org/viewvc/llvm-project?rev=253227&view=rev
Log:
Merging r243461:

------------------------------------------------------------------------
r243461 | Matthew.Arsenault | 2015-07-28 14:29:14 -0400 (Tue, 28 Jul 2015) | 5 lines

AMDGPU: Fix crash if called function is a bitcast

getCalledFunction() is null, so this would crash. Replace
crash with an error on unsupported call.

------------------------------------------------------------------------

Added:
    llvm/branches/release_37/test/CodeGen/AMDGPU/promote-alloca-bitcast-function.ll
Modified:
    llvm/branches/release_37/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp

Modified: llvm/branches/release_37/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_37/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp?rev=253227&r1=253226&r2=253227&view=diff
==============================================================================
--- llvm/branches/release_37/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp (original)
+++ llvm/branches/release_37/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp Mon Nov 16 11:23:17 2015
@@ -240,7 +240,12 @@ static bool collectUsesWithPtrTypes(Valu
   for (User *User : Val->users()) {
     if(std::find(WorkList.begin(), WorkList.end(), User) != WorkList.end())
       continue;
-    if (isa<CallInst>(User)) {
+    if (CallInst *CI = dyn_cast<CallInst>(User)) {
+      // TODO: We might be able to handle some cases where the callee is a
+      // constantexpr bitcast of a function.
+      if (!CI->getCalledFunction())
+        return false;
+
       WorkList.push_back(User);
       continue;
     }

Added: llvm/branches/release_37/test/CodeGen/AMDGPU/promote-alloca-bitcast-function.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_37/test/CodeGen/AMDGPU/promote-alloca-bitcast-function.ll?rev=253227&view=auto
==============================================================================
--- llvm/branches/release_37/test/CodeGen/AMDGPU/promote-alloca-bitcast-function.ll (added)
+++ llvm/branches/release_37/test/CodeGen/AMDGPU/promote-alloca-bitcast-function.ll Mon Nov 16 11:23:17 2015
@@ -0,0 +1,22 @@
+; RUN: not llc -march=amdgcn < %s 2>&1 | FileCheck %s
+
+; Make sure that AMDGPUPromoteAlloca doesn't crash if the called
+; function is a constantexpr cast of a function.
+
+declare void @foo(float*) #0
+declare void @foo.varargs(...) #0
+
+; CHECK: error: unsupported call to function foo in crash_call_constexpr_cast
+define void @crash_call_constexpr_cast() #0 {
+  %alloca = alloca i32
+  call void bitcast (void (float*)* @foo to void (i32*)*)(i32* %alloca) #0
+  ret void
+}
+
+define void @crash_call_constexpr_cast_varargs() #0 {
+  %alloca = alloca i32
+  call void bitcast (void (...)* @foo.varargs to void (i32*)*)(i32* %alloca) #0
+  ret void
+}
+
+attributes #0 = { nounwind }




More information about the llvm-branch-commits mailing list