Skip to content

Instantly share code, notes, and snippets.

@Artem-B

Artem-B/D80450-repro.cc

Last active Jun 11, 2020
Embed
What would you like to do?
Reproducer for D80450 regression
class b;
int f;
namespace c {
template <typename> struct d {};
namespace cuda {
namespace detail {
struct e {};
template <typename, typename> struct g : d<g<int, int>> {};
template <typename h, typename i> g<h, i> j(h, i);
} // namespace detail
} // namespace cuda
class D {
public:
D(int);
};
template <typename, typename> class k {
public:
template <typename l>
__attribute__((host)) __attribute__((device)) D m(l, l, D);
int t;
};
namespace ad {
template <typename ae, typename l, typename af>
__attribute__((host)) __attribute__((device)) af ag(d<ae>, l, l, af);
}
namespace cuda {
namespace detail {
template <typename h, typename i, typename l, typename af>
void ag(g<h, i>, l, l, af);
}
} // namespace cuda
template <typename ae, typename l, typename af>
__attribute__((host)) __attribute__((device)) af ag(d<ae>, l ah, l ai, af aj) {
using ad::ag;
ae o;
ag(o, ah, ai, aj);
}
int ak;
cuda::detail::e u;
template <typename h, typename i, typename l, typename af>
void q(h, i, l ah, l ai, af aj) {
cuda::detail::g r = j(ak, u);
c::ag(r, ah, ai, aj);
}
namespace s {
template <typename al, typename am, typename l, typename an>
void ao(al ap, am a, l ah, l ai, an aj) {
q(ap, a, ah, ai, aj);
}
} // namespace s
template <typename ar, typename am, typename l, typename an>
void ao(ar ap, am a, l ah, l ai, an aj) {
s::ao(ap, a, ah, ai, aj);
}
template <typename as, typename p>
template <typename l>
__attribute__((host)) __attribute__((device)) D k<as, p>::m(l ah, l ai, D) {
ao(f, t, ah, ai, 0);
}
template <typename, typename> class at {
public:
at(long);
template <typename av, typename aw> at(const at<av, aw> &);
k<int, int> ax;
template <typename l> void ay(l, l);
};
template <typename as, typename p>
template <typename av, typename aw>
at<as, p>::at(const at<av, aw> &) {
D az = 0, ba = 0;
ay(az, ba);
}
template <typename as, typename p>
template <typename l>
void at<as, p>::ay(l ah, l ai) {
ax.m(ah, ai, 0);
}
template <typename, typename = b> class G : public at<int, b> {
public:
G(long n) : at(n) {}
};
template <typename, typename = int> class H : at<int, int> {
public:
template <typename av, typename aw> H(const G<av, aw> &);
};
template <typename as, typename p>
template <typename av, typename aw>
H<as, p>::H(const G<av, aw> &v) : at(v) {}
} // namespace c
void be() {
long n;
c::G<int> bf(n);
c::H<int> bg = bf;
}
#!/bin/bash
# creduce test script
CLANG_OLD=clang-no-D80450/usr/local/bin/clang++
CLANG_NEW=clang-D80450/usr/local/bin/clang++
SRC=D80450-repro.cc
OPTS=("-cc1" "-triple" "nvptx64-nvidia-cuda" "-aux-triple" "x86_64-grtev4-linux-gnu" "-emit-llvm-bc" "-disable-free" "-disable-llvm-verifier" "-aux-target-cpu" "x86-64" "-aux-target-feature" "+aes" "-aux-target-feature" "+cx16" "-aux-target-feature" "+sse4.2" "-aux-target-feature" "+pclmul" "-fno-use-init-array" "-fcuda-is-device" "-target-feature" "+ptx64" "-target-sdk-version=10.1" "-target-cpu" "sm_60" "-dwarf-column-info" "-fno-split-dwarf-inlining" "-debugger-tuning=gdb" "-v" "-ffunction-sections" "-fdata-sections" "-fno-unique-section-names" "-O3" "-std=gnu++17" "-pthread" "-fno-signed-char" "-fcxx-exceptions" "-fexceptions" "-fsized-deallocation" "-faligned-allocation" "-fnew-alignment=8" "-disable-llvm-passes" "-o" /dev/null "-x" "cuda-cpp-output" -ferror-limit 1 $SRC)
echo "${OPTS[@]}"
$CLANG_NEW "${OPTS[@]}" 2>err.new && exit 1
E1=$?
# If it's the new error, skip it.
#grep -Pq "error: reference to __(host|device)__ variable" err.new && exit 1
# Must have the ambiguous error.
#grep -q "error: call to 'copysign' is ambiguous" err.new || exit 1
$CLANG_OLD "${OPTS[@]}" 2>err.old
E2=$?
#If new compiler gives the same result, it's not interesting.
[ $E1 = $E2 ] && exit 1
exit 0
clang -cc1 version 11.0.0 based upon LLVM 11.0.0git default target x86_64-unknown-linux-gnu
#include "..." search starts here:
End of search list.
thrust.cui.cc:59:1: warning: non-void function does not return a value [-Wreturn-type]
}
^
thrust.cui.cc:76:6: note: in instantiation of function template specialization 'c::k<int, int>::m<c::D>' requested here
ax.m(ah, ai, 0);
^
thrust.cui.cc:71:3: note: in instantiation of function template specialization 'c::at<int, int>::ay<c::D>' requested here
ay(az, ba);
^
thrust.cui.cc:88:35: note: in instantiation of function template specialization 'c::at<int, int>::at<int, b>' requested here
H<as, p>::H(const G<av, aw> &v) : at(v) {}
^
thrust.cui.cc:93:18: note: in instantiation of function template specialization 'c::H<int, int>::H<int, b>' requested here
c::H<int> bg = bf;
^
thrust.cui.cc:36:3: error: call to 'ag' is ambiguous
ag(o, ah, ai, aj);
^~
thrust.cui.cc:43:6: note: in instantiation of function template specialization 'c::ag<c::cuda::detail::g<int, int>, c::D, int>' requested here
c::ag(r, ah, ai, aj);
^
thrust.cui.cc:48:3: note: in instantiation of function template specialization 'c::q<int, int, c::D, int>' requested here
q(ap, a, ah, ai, aj);
^
thrust.cui.cc:53:6: note: in instantiation of function template specialization 'c::s::ao<int, int, c::D, int>' requested here
s::ao(ap, a, ah, ai, aj);
^
thrust.cui.cc:58:3: note: in instantiation of function template specialization 'c::ao<int, int, c::D, int>' requested here
ao(f, t, ah, ai, 0);
^
thrust.cui.cc:76:6: note: in instantiation of function template specialization 'c::k<int, int>::m<c::D>' requested here
ax.m(ah, ai, 0);
^
thrust.cui.cc:71:3: note: in instantiation of function template specialization 'c::at<int, int>::ay<c::D>' requested here
ay(az, ba);
^
thrust.cui.cc:88:35: note: in instantiation of function template specialization 'c::at<int, int>::at<int, b>' requested here
H<as, p>::H(const G<av, aw> &v) : at(v) {}
^
thrust.cui.cc:93:18: note: in instantiation of function template specialization 'c::H<int, int>::H<int, b>' requested here
c::H<int> bg = bf;
^
thrust.cui.cc:24:50: note: candidate function [with ae = c::cuda::detail::g<int, int>, l = c::D, af = int]
__attribute__((host)) __attribute__((device)) af ag(d<ae>, l, l, af);
^
thrust.cui.cc:33:50: note: candidate function [with ae = c::cuda::detail::g<int, int>, l = c::D, af = int]
__attribute__((host)) __attribute__((device)) af ag(d<ae>, l ah, l ai, af aj) {
^
1 warning and 1 error generated when compiling for sm_60.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment