- `externally_initialized variables would be initialized or modified elsewhere. Particularly, CUDA or HIP may have host code to initialize or modify externally_initialized` device variables, which may not be explicitly referenced on the device side but may still be used through the host side interfaces. Not preserving them triggers the elimination of them in the GlobalDCE and breaks the user code.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
clang/test/CodeGenCUDA/host-used-device-var.cu | ||
---|---|---|
20 | BTW, as clang codegen tests, those checks should not rely on middle-end optimizations to work correctly. | |
clang/test/CodeGenCUDA/unused-global-var.cu | ||
20 | BTW, as clang codegen tests, those checks should not rely on middle-end optimizations to work correctly. |
clang/test/CodeGenCUDA/host-used-device-var.cu | ||
---|---|---|
20 | What happens if you remove -O3? | |
21–24 | These should be changed to positive checks to verify that they are emitted. |
LGTM. Pls change the negative tests to positive tests as Artem suggested.
clang/test/CodeGenCUDA/host-used-device-var.cu | ||
---|---|---|
20 | These tests were introduced with -O3 since they can only be tested with clang and -O3. (https://reviews.llvm.org/D98783) Clang may emit IR containing unused LLVM constants. Saving the IR as a file will cause such unused LLVM constants to disappear, therefore unable to reproduce the issue. | |
20 | If -O3 is removed, those unused variables will not be internalized and removed. |
BTW, as clang codegen tests, those checks should not rely on middle-end optimizations to work correctly.