Dear LLVM NVPTX maintainers,<br><br>Just to have the issue recorded, I don't know how important it is:<br><br>clang generates linkonce_odr out of
__inline__, and NVPTX generates .weak out of linkonce_odr (how it
happens - a big question, btw, because I can't find anything related in
NVPTX asm printer - does it chain to some other printer?), and finally
ptxas (both 4.2 and 5) fails to compile it to cubin. Below is the test case:<br>
<br>> cat <a href="http://test3.cu/" target="_blank">test3.cu</a><br><br>__inline__ __attribute__((device)) __attribute__((used)) void test()<br>{<br> return;<br>}<br><br>> clang -cc1 -emit-llvm -triple ptx64-unknown-unknown -fcuda-is-device <a href="http://test3.cu/" target="_blank">test3.cu</a> -o test3.ll<br>
> cat test3.ll<br>; ModuleID = '<a href="http://test3.cu/" target="_blank">test3.cu</a>'<br>target datalayout = "e-p:64:64-i64:64:64-f64:64:<div>64-n1:8:16:32:64"<br>target triple = "ptx64-unknown-unknown"<br>
<br>
@llvm.used = appending global [1 x i8*] [i8* bitcast (void ()* @_Z4testv to i8*)], section "llvm.metadata"<br><br>define linkonce_odr ptx_device void @_Z4testv() nounwind inlinehint {<br>entry:<br> ret void<br>
}<br><br>> llc -march=nvptx64 -mcpu=sm_20 test3.ll -o test3.ptx<br>> cat test3.ptx<br><br>//<br>// Generated by LLVM NVPTX Back-End<br>//<br><br>.version 3.0<br>.target sm_20, texmode_independent<br>.address_size 64<br>
<br><br> .weak _Z4testv<br>.func _Z4testv(<br><br>) // @_Z4testv<br>{<br> .reg .pred %p<396>;<br> .reg .s16 %rc<396>;<br> .reg .s16 %rs<396>;<br> .reg .s32 %r<396>;<br>
.reg .s64 %rl<396>;<br> .reg .f32 %f<396>;<br> .reg .f64 %fl<396>;<br><br>// BB#0: // %entry<br> ret;<br>}<br><br>1) ptxas @ CUDA 4.2:<br><br>> ptxas -arch=sm_20 -m64 test3.ptx -o -<br>
<br>ptxas test3.ptx, line 10; fatal : Parsing error near '.weak': syntax error<br>ptxas fatal : Ptx assembly aborted due to errors<br><br>2) ptxas @ CUDA 5:<br><br>> ~/cuda/bin/ptxas -arch=sm_20 -m64 test3.ptx -o -<br>
<br>ptxas test3.ptx, line 10; error : Feature '.weak directive' requires PTX ISA .version 3.1 or later<br>ptxas test3.ptx, line 10; fatal : Parsing error near '_Z4testv': syntax error<br>ptxas fatal : Ptx assembly aborted due to errors<br>
<br>3) ptxas @ CUDA 5, changed .version to 3.1: still error, because according to 3.1 PTX spec, .weak must be followed by .func:<br><br>> ~/cuda/bin/ptxas -arch=sm_20 -m64 test3.ptx -o -<br><br>ptxas test3.ptx, line 10; fatal : Parsing error near '_Z4testv': syntax error<br>
ptxas fatal : Ptx assembly aborted due to errors<br>
<br>Best,<br>- Dima.</div>