[PATCH] D58463: [CUDA]Delayed diagnostics for the asm instructions.
Alexey Bataev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 26 11:06:20 PST 2019
ABataev added a comment.
In D58463#1410900 <https://reviews.llvm.org/D58463#1410900>, @tra wrote:
> There's a new quirk we've ran into after this patch landed. Consider this code:
>
> int foo() {
> int prev;
> __asm__ __volatile__("mov %0, 0" : "=a" (prev)::);
> return prev;
> }
>
>
> When we compile for device, asm constraint is not valid for NVPTX, we emit delayed diag and move on. The function is never code-gen'ed so the diag never shows up. So far so good.
>
> Now we add `-Werror -Wininitialized` and things break -- because we bail out early, `prev` is left uninitialized and is reported as such.
>
> $ bin/clang++ -c --cuda-gpu-arch=sm_35 asm.cu -nocudainc --cuda-device-only -Wuninitialized -Werror
> asm.cu:4:10: error: variable 'prev' is uninitialized when used here [-Werror,-Wuninitialized]
> return prev;
> ^~~~
> asm.cu:2:11: note: initialize the variable 'prev' to silence this warning
> int prev;
> ^
> = 0
> 1 error generated when compiling for sm_35.
>
>
>
> I think this should also show up in the test case in this patch, too, if you add -Wuninitialized
Hi Artem, I think we can just delay emission of this warning to solve this problem.
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D58463/new/
https://reviews.llvm.org/D58463
More information about the llvm-commits
mailing list