mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-10-27 09:17:11 +00:00
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/trunk@243461 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -240,7 +240,12 @@ static bool collectUsesWithPtrTypes(Value *Val, std::vector<Value*> &WorkList) {
|
|||||||
for (User *User : Val->users()) {
|
for (User *User : Val->users()) {
|
||||||
if(std::find(WorkList.begin(), WorkList.end(), User) != WorkList.end())
|
if(std::find(WorkList.begin(), WorkList.end(), User) != WorkList.end())
|
||||||
continue;
|
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);
|
WorkList.push_back(User);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
22
test/CodeGen/AMDGPU/promote-alloca-bitcast-function.ll
Normal file
22
test/CodeGen/AMDGPU/promote-alloca-bitcast-function.ll
Normal file
@@ -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 }
|
||||||
Reference in New Issue
Block a user