This patch changes the visiblity of variables declared within a declare
target directive. Variable declarations within a declare target
directive need to be externally visible to the plugin for initialization
or reading. Previously this would cause runtime errors where the named
global could not be found because it was not included in the symbol
table.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Changing method to use an early exit, previously visibility would still be hidden for some constructs.
Updating again, wasn't handling static variables declared in a record context
properly.
If I'm following correctly, this broke the amdgpu buildbot and it has been moved into staging as a workaround. I haven't debugged what breaks but 'DefaultVisibility' is relatively likely to behave differently on cuda vs hsa systems so that's my first guess.
clang/lib/AST/Decl.cpp | ||
---|---|---|
792 | Would this change static variables to non-static and thus introduce multiple definition errors? Not immediately obvious to me that the variables have to be directly visible to other translation units |
Yes, this patch is necessary because of the different handling of hidden visibility by NVIDIA and AMDGPU. Without this patch we cannot run any code that uses #pragma omp declare target on AMDGPU because they are all hidden. The runtime will try to load it and fail so we will crash.
clang/lib/AST/Decl.cpp | ||
---|---|---|
792 | That was my first guess, I had @ronlieb run an alternate approach where we run everything as normal, but at the end we inherit the linkage but set the visibility to default. he said it still caused problems. |
clang/lib/AST/Decl.cpp | ||
---|---|---|
1080 | Possibly address space dependent. I'm not confident shared or thread local variables will behave sensibly if annotated with elf visibility flags. |
Would this change static variables to non-static and thus introduce multiple definition errors? Not immediately obvious to me that the variables have to be directly visible to other translation units