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 C++11 constant eval builtin issues, te…
Browse files Browse the repository at this point in the history
…st may need to be moved.
  • Loading branch information
wmaxey authored and brycelelbach committed Oct 2, 2020
1 parent 5d7b818 commit d098a95
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 5 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;
}
9 changes: 4 additions & 5 deletions libcxx/include/__config
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,8 @@ typedef __char32_t char32_t;
#define _LIBCUDACXX_ATOMIC_ALWAYS_LOCK_FREE(...) __atomic_always_lock_free(__VA_ARGS__)
#endif

#if __has_builtin(__builtin_is_constant_evaluated)
// NVCC in C++11 mode freaks out about `__builtin_is_constant_evaluated`.
#if __has_builtin(__builtin_is_constant_evaluated) && !(defined(_LIBCUDACXX_COMPILER_NVCC) && _LIBCUDACXX_STD_VER < 14)
#define _LIBCUDACXX_IS_CONSTANT_EVALUATED(...) __builtin_is_constant_evaluated(__VA_ARGS__)
#endif

Expand Down Expand Up @@ -784,12 +785,10 @@ typedef __char32_t char32_t;
#define _LIBCUDACXX_ATOMIC_ALWAYS_LOCK_FREE(...) __atomic_always_lock_free(__VA_ARGS__)
#endif

#if _GNUC_VER >= 900
// TODO: figure out why NVCC is unhappy with the builtin, but _only_ in C++11 mode.
#if __cplusplus > 201103L
// NVCC in C++11 mode freaks out about `__builtin_is_constant_evaluated`.
#if _GNUC_VER >= 900 && !(defined(_LIBCUDACXX_COMPILER_NVCC) && _LIBCUDACXX_STD_VER < 14)
#define _LIBCUDACXX_IS_CONSTANT_EVALUATED(...) __builtin_is_constant_evaluated(__VA_ARGS__)
#endif
#endif

#define _LIBCUDACXX_ALWAYS_INLINE __attribute__ ((__always_inline__))

Expand Down

0 comments on commit d098a95

Please sign in to comment.