Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

Commit

Permalink
Added a test for and WAR'd the clang&C++11 constant eval builtin, tes…
Browse files Browse the repository at this point in the history
…t may need to be moved.
  • Loading branch information
wmaxey committed Sep 23, 2020
1 parent 879aa11 commit fae861b
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This test serves as a canary for when this issue is fixed in NVCC
//
// UNSUPPORTED: windows, icc, pgi
// XFAIL: clang-9 && c++11
// XFAIL: clang-10 && c++11
// XFAIL: gcc-9 && c++11
// XFAIL: gcc-10 && c++11


#if defined(__has_builtin)
#if __has_builtin(__builtin_is_constant_evaluated)
#define BUILTIN_CONSTANT_EVAL() __builtin_is_constant_evaluated()
#endif
#endif

#ifndef BUILTIN_CONSTANT_EVAL
#define BUILTIN_CONSTANT_EVAL() true
#endif

__device__ __host__ inline constexpr bool constant_eval() {
return BUILTIN_CONSTANT_EVAL();
}

int main(int, char**) {
static_assert(constant_eval(), "");
return 0;
}
8 changes: 8 additions & 0 deletions libcxx/include/__config
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,14 @@ typedef __char32_t char32_t;
#define _LIBCUDACXX_IS_CONSTANT_EVALUATED(...) __builtin_is_constant_evaluated(__VA_ARGS__)
#endif

// TODO: Builtin is not constexpr, this can be tested with an integral_constant
// but _only_ in C++11 mode. (fix for NVCC+clang-9 and up)
#if defined(__CUDACC__)
#if __cplusplus < 201402L
#undef _LIBCUDACXX_IS_CONSTANT_EVALUATED
#endif
#endif

#if __has_builtin(__builtin_addressof)
#define _LIBCUDACXX_ADDRESSOF(...) __builtin_addressof(__VA_ARGS__)
#endif
Expand Down

0 comments on commit fae861b

Please sign in to comment.