Issue 234140
Summary [AMDGPU] Segfault in GCNTTIImpl::getCallerAllocaCost on indirect call
Labels new issue
Assignees
Reporter ahueck
    Null dereference of `CB->getCalledFunction()` in `GCNTTIImpl::getCallerAllocaCost` (`AMDGPUTargetTransformInfo.cpp`) when an indirect call is passed under certain conditions:
 - An indirect call whose target is known, with alloca args totalling more than `-amdgpu-inline-arg-alloca-cutoff` (256 bytes).

Tested with commit 0778292bd9f2.

## Reproducer
- `[256 x i8]` alloca OK vs. `[257 x i8]`, or higher, crashes.
- No crash without an AMDGPU triple.
- See godbolt: https://godbolt.org/z/8hMbK5fe5

```llvm
// RUN: opt -mtriple=amdgcn-amd-amdhsa -passes=inline -disable-output %s
define void @take(ptr addrspace(5) %p) {
  ret void
}

define void @caller() {
 call void @wrapper(ptr @take)
  ret void
}

define void @wrapper(ptr %fn) {
  %buf = alloca [257 x i8], addrspace(5)
  call void %fn(ptr addrspace(5) %buf)
  ret void
}
``` 
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to