Open Artem-B opened 3 hours ago
@darkbuck I want to replace impossible ASCs with undef
, and I see that in https://github.com/llvm/llvm-project/commit/72fc08a5412ec7ee7f0b904926db16cd86c1f876 you've added isValidAddrSpaceCast
which could be used for this purpose. Except, that, for some reason it defaults to false
which would flag all ASCs on all the back-ends that do not implement this hook. Is there a particular reason false
was used? Can it be changed to true
?
I will implement the correct hook for NVPTX, but I'm concerned about incorrectly eliminating ASCs on the targets that didn't implement the hook.
Valid CUDA code results in LLVM crash due to an attempt to generate an impossible addrspacecast in a known-false conditional branch.
Reproducer: https://godbolt.org/z/Yjjsdvj1r
Source:
IR:
The culprit is
addrspacecast (ptr addrspace(3) @shared_data to ptr addrspace(1))
here:To add insult to injury, the impossible cast is still going to be executed, and will likely result in a runtime error trying to convert the pointer in the wrong address space.
We need to make sure that
__cvta_generic_to_global()
is never executed if__isGlobal()
is false. Same for the conversions from shared and constant AS.