llvm.org GIT mirror llvm / 6a6b791
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. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_37@253227 91177308-0d34-0410-b5e6-96231b3b80d8 Tom Stellard 3 years ago
2 changed file(s) with 28 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
239239 for (User *User : Val->users()) {
240240 if(std::find(WorkList.begin(), WorkList.end(), User) != WorkList.end())
241241 continue;
242 if (isa(User)) {
242 if (CallInst *CI = dyn_cast(User)) {
243 // TODO: We might be able to handle some cases where the callee is a
244 // constantexpr bitcast of a function.
245 if (!CI->getCalledFunction())
246 return false;
247
243248 WorkList.push_back(User);
244249 continue;
245250 }
0 ; RUN: not llc -march=amdgcn < %s 2>&1 | FileCheck %s
1
2 ; Make sure that AMDGPUPromoteAlloca doesn't crash if the called
3 ; function is a constantexpr cast of a function.
4
5 declare void @foo(float*) #0
6 declare void @foo.varargs(...) #0
7
8 ; CHECK: error: unsupported call to function foo in crash_call_constexpr_cast
9 define void @crash_call_constexpr_cast() #0 {
10 %alloca = alloca i32
11 call void bitcast (void (float*)* @foo to void (i32*)*)(i32* %alloca) #0
12 ret void
13 }
14
15 define void @crash_call_constexpr_cast_varargs() #0 {
16 %alloca = alloca i32
17 call void bitcast (void (...)* @foo.varargs to void (i32*)*)(i32* %alloca) #0
18 ret void
19 }
20
21 attributes #0 = { nounwind }