Global variables used to be printed as u64/b64 even when -nvptx-short-ptr is set.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/test/CodeGen/NVPTX/short-ptr.ll | ||
---|---|---|
18 | Ptxas doesn't like global variables in local address space, so I will remove this case. |
- Added ptxas RUN lines.
- Removed test case with .local global variable because ptxas does not support them.
Good catch. Thank you for fixing this.
llvm/test/CodeGen/NVPTX/short-ptr.ll | ||
---|---|---|
18 | We could use __const__ AS instead. For testing local vars we should probably add a function with a local variable. |
llvm/test/CodeGen/NVPTX/short-ptr.ll | ||
---|---|---|
18 |
Local variables are lowered as __local_depot followed by as a sequence of casts: mov.u64 %SPL, __local_depot0; cvta.local.u64 %SP, %SPL; add.u64 %rd1, %SP, 0; { .reg .b64 %tmp; cvta.to.local.u64 %tmp, %rd1; cvt.u32.u64 %r1, %tmp; <--- r1 is our 32-bit local pointer } So I added a test, but it fails because of a different issue: declare void @use(i8 addrspace(5)* %local) define void @test() { %v = alloca i8 %cast = addrspacecast i8* %v to i8 addrspace(5)* call void @use(i8 addrspace(5)* %cast) ret void } PTX: .extern .func use ( .param .b64 use_param_0 <--- pointer is 64-bit instead of 32 ) [...] .param .b32 param0; st.param.b32 [param0+0], %r1; <--- call assumes a 32-bit pointer call.uni use, ( param0 ); ptxas: Type of argument does not match formal parameter 'use_param_0' So either the call should pass the pointer as 64-bit, or the use function declaration is wrong. I'm not sure. Should --nvptx-short-ptr change function ABI? |
llvm/test/CodeGen/NVPTX/short-ptr.ll | ||
---|---|---|
13 | BTW, the global variables themselves can all be in the global AS. we only care about the *type* of these variables which is what we're testing -- how we lower pointers in local/const/shared AS. https://godbolt.org/z/7rx1jo18v @s = local_unnamed_addr addrspace(1) global i32 addrspace(3)* null, align 8 @c = local_unnamed_addr addrspace(1) global i32 addrspace(4)* null, align 8 @l = local_unnamed_addr addrspace(1) global i32 addrspace(5)* null, align 8 |
BTW, the global variables themselves can all be in the global AS. we only care about the *type* of these variables which is what we're testing -- how we lower pointers in local/const/shared AS.
https://godbolt.org/z/7rx1jo18v