<html>
<head>
<base href="https://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - Macro protected __device__ function and identical host function collide in global"
href="https://llvm.org/bugs/show_bug.cgi?id=27270">27270</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Macro protected __device__ function and identical host function collide in global
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>CUDA
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>crtrott@sandia.gov
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=16183" name="attach_16183" title="Reproducer">attachment 16183</a> <a href="attachment.cgi?id=16183&action=edit" title="Reproducer">[details]</a></span>
Reproducer
If I have a __device__ function and a __host__ function with only one of them
visible at the time through protection of __CUDACC__ && __CUDA_ARCH__ the
compile will stop on global functions because it thinks I want to call the
__host__ function. My current suspicion is that during the host compilation
pass it still sees the global function, and it sees the __host__ function and
thinks I call the latter from the former. Here is the simplified pattern:
#ifdef __CUDA_ARCH__
__device__ inline void foo() {}
#else
inline void foo() {}
#endif
__global__ bar() {
foo();
}
In the attached reproducer this produces the following error with clang (while
it works with nvcc):
/////////////
main.cpp:21:43: error: no matching function for call to 'c_func'
a[blockIdx.x*blockDim.x+threadIdx.x] = c_func();
^~~~~~
main.cpp:11:12: note: candidate function not viable: call to __host__ function
from __global__ function
inline int c_func() {return 1;}
^
1 error generated.
////////////
The attached reproducer has two workaround solutions in it. To use them build
with
./build_clang -DWORKAROUND=1
./build_clang -DWORKAROUND=2
otherwise just use
./build_clang
to get the error. You will need to change the paths in the build script though.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>