Statepoints: non-register values are unsupported but registers might inline to their values
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
Currently, GC statepoints only support locals, and other values appear to be silently filtered out without error. This would be workable by simply giving local names, but opt will then inline the definitions.
The point is to be able to pass extra non-moving pointers which are traced (but not relocated). It can be worked around using the id field and then attaching metadata that way.
https://godbolt.org/z/Mqc97hTvs
```llvm
define ptr addrspace(1) @f(i32 %x) local_unnamed_addr #0 gc "statepoint-example" {
%2 = getelementptr i64, ptr addrspace(1) @foo
%tok_11824 = call token (i64,i32,ptr,i32,i32,...) @llvm.experimental.gc.statepoint.p0(
i64 4, i32 0,
ptr elementtype(void (i64)) @somefunc,
i32 1,i32 0,
i64 3,
i32 0,i32 0)
["gc-statepoint" (ptr addrspace(1) %2)]
ret ptr addrspace(1) %2
}
declare void @somefunc(i64)
declare token @llvm.experimental.gc.statepoint.p0(i64,i32,ptr,i32,i32,...)
@foo = addrspace(1) global {i64} {i64 0}
```
gets optimized to
```llvm
@foo = addrspace(1) global { i64 } zeroinitializer
define noundef ptr addrspace(1) @f(i32 %x) local_unnamed_addr gc "statepoint-example" {
%tok_11824 = call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 4, i32 0, ptr nonnull elementtype(void (i64)) @somefunc, i32 1, i32 0, i64 3, i32 0, i32 0) [ "gc-statepoint"(ptr addrspace(1) @foo) ]
ret ptr addrspace(1) @foo
}
declare void @somefunc(i64)
declare token @llvm.experimental.gc.statepoint.p0(i64 immarg, i32 immarg, ptr, i32 immarg, i32 immarg, ...)
```
Which causes the global to be inlined, and thereby causes it not to be passed in the statepoint (at least as far as my testing)
Contributor guide
Assessment
This issue has not been assessed yet.