It currently fails because GCC changed the mangling of templates, which affects std::atomic using __attribute__((vector(X))). The bot using GCC 4.9 generates the following message:
In file included from /home/llvm-builder/llvm-buildslave-root/libcxx-libcxxabi-x86_64-linux-ubuntu-gcc49-cxx11/llvm/projects/libcxx/test/libcxx/atomics/atomics.align/align.pass.sh.cpp:24:0:
/home/llvm-builder/llvm-buildslave-root/libcxx-libcxxabi-x86_64-linux-ubuntu-gcc49-cxx11/llvm/projects/libcxx/include/atomic: In instantiation of 'atomic_test<T>::atomic_test() [with T = __vector(2) int]':
/home/llvm-builder/llvm-buildslave-root/libcxx-libcxxabi-x86_64-linux-ubuntu-gcc49-cxx11/llvm/projects/libcxx/test/libcxx/atomics/atomics.align/align.pass.sh.cpp:66:3: required from here
/home/llvm-builder/llvm-buildslave-root/libcxx-libcxxabi-x86_64-linux-ubuntu-gcc49-cxx11/llvm/projects/libcxx/include/atomic:583:5: error: 'std::__1::__gcc_atomic::__gcc_atomic_t<_Tp>::__gcc_atomic_t() [with _Tp = __vector(2) int]' conflicts with a previous declaration
__gcc_atomic_t() _NOEXCEPT = default;
^
/home/llvm-builder/llvm-buildslave-root/libcxx-libcxxabi-x86_64-linux-ubuntu-gcc49-cxx11/llvm/projects/libcxx/include/atomic:583:5: note: previous declaration 'std::__1::__gcc_atomic::__gcc_atomic_t<_Tp>::__gcc_atomic_t() [with _Tp = __vector(1) int]'
/home/llvm-builder/llvm-buildslave-root/libcxx-libcxxabi-x86_64-linux-ubuntu-gcc49-cxx11/llvm/projects/libcxx/include/atomic:583:5: note: -fabi-version=6 (or =0) avoids this error with a change in mangling
/home/llvm-builder/llvm-buildslave-root/libcxx-libcxxabi-x86_64-linux-ubuntu-gcc49-cxx11/llvm/projects/libcxx/include/atomic:583:5: error: 'std::__1::__gcc_atomic::__gcc_atomic_t<_Tp>::__gcc_atomic_t() [with _Tp = __vector(2) int]' conflicts with a previous declaration
/home/llvm-builder/llvm-buildslave-root/libcxx-libcxxabi-x86_64-linux-ubuntu-gcc49-cxx11/llvm/projects/libcxx/include/atomic:583:5: note: previous declaration 'std::__1::__gcc_atomic::__gcc_atomic_t<_Tp>::__gcc_atomic_t() [with _Tp = __vector(1) int]'
/home/llvm-builder/llvm-buildslave-root/libcxx-libcxxabi-x86_64-linux-ubuntu-gcc49-cxx11/llvm/projects/libcxx/include/atomic:583:5: note: -fabi-version=6 (or =0) avoids this error with a change in mangling
/home/llvm-builder/llvm-buildslave-root/libcxx-libcxxabi-x86_64-linux-ubuntu-gcc49-cxx11/llvm/projects/libcxx/include/atomic:939:5: note: synthesized method 'std::__1::__gcc_atomic::__gcc_atomic_t<_Tp>::__gcc_atomic_t() [with _Tp = __vector(2) int]' first required here
__atomic_base() _NOEXCEPT = default;
^
GCC's docs say the following about ABI version 6:
Version 6, which first appeared in G++ 4.7, corrects the promotion behavior of C++11 scoped enums and the mangling of template argument packs, const/static_cast, prefix ++ and –, and a class scope function used as a template argument.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@277380 91177308-0d34-0410-b5e6-96231b3b80d8
94 lines
3.9 KiB
C++
94 lines
3.9 KiB
C++
//===----------------------------------------------------------------------===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is dual licensed under the MIT and the University of Illinois Open
|
|
// Source Licenses. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// UNSUPPORTED: libcpp-has-no-threads, c++98, c++03
|
|
// REQUIRES: libatomic
|
|
// RUN: %build -latomic
|
|
// RUN: %run
|
|
//
|
|
// GCC currently fails because it needs -fabi-version=6 to fix mangling of
|
|
// std::atomic when used with __attribute__((vector(X))).
|
|
// XFAIL: gcc
|
|
|
|
// <atomic>
|
|
|
|
// Verify that the content of atomic<T> is properly aligned if the type is
|
|
// lock-free. This can't be observed through the atomic<T> API. It is
|
|
// nonetheless required for correctness of the implementation: lock-free implies
|
|
// that ISA instructions are used, and these instructions assume "suitable
|
|
// alignment". Supported architectures all require natural alignment for
|
|
// lock-freedom (e.g. load-linked / store-conditional, or cmpxchg).
|
|
|
|
#include <atomic>
|
|
#include <cassert>
|
|
|
|
template <typename T> struct atomic_test : public std::__atomic_base<T> {
|
|
atomic_test() {
|
|
if (this->is_lock_free())
|
|
assert(alignof(this->__a_) >= sizeof(this->__a_) &&
|
|
"expected natural alignment for lock-free type");
|
|
}
|
|
};
|
|
|
|
int main() {
|
|
|
|
// structs and unions can't be defined in the template invocation.
|
|
// Work around this with a typedef.
|
|
#define CHECK_ALIGNMENT(T) \
|
|
do { \
|
|
typedef T type; \
|
|
atomic_test<type> t; \
|
|
} while (0)
|
|
|
|
CHECK_ALIGNMENT(bool);
|
|
CHECK_ALIGNMENT(char);
|
|
CHECK_ALIGNMENT(signed char);
|
|
CHECK_ALIGNMENT(unsigned char);
|
|
CHECK_ALIGNMENT(char16_t);
|
|
CHECK_ALIGNMENT(char32_t);
|
|
CHECK_ALIGNMENT(wchar_t);
|
|
CHECK_ALIGNMENT(short);
|
|
CHECK_ALIGNMENT(unsigned short);
|
|
CHECK_ALIGNMENT(int);
|
|
CHECK_ALIGNMENT(unsigned int);
|
|
CHECK_ALIGNMENT(long);
|
|
CHECK_ALIGNMENT(unsigned long);
|
|
CHECK_ALIGNMENT(long long);
|
|
CHECK_ALIGNMENT(unsigned long long);
|
|
CHECK_ALIGNMENT(std::nullptr_t);
|
|
CHECK_ALIGNMENT(void *);
|
|
CHECK_ALIGNMENT(float);
|
|
CHECK_ALIGNMENT(double);
|
|
CHECK_ALIGNMENT(long double);
|
|
CHECK_ALIGNMENT(int __attribute__((vector_size(1 * sizeof(int)))));
|
|
CHECK_ALIGNMENT(int __attribute__((vector_size(2 * sizeof(int)))));
|
|
CHECK_ALIGNMENT(int __attribute__((vector_size(4 * sizeof(int)))));
|
|
CHECK_ALIGNMENT(int __attribute__((vector_size(16 * sizeof(int)))));
|
|
CHECK_ALIGNMENT(int __attribute__((vector_size(32 * sizeof(int)))));
|
|
CHECK_ALIGNMENT(float __attribute__((vector_size(1 * sizeof(float)))));
|
|
CHECK_ALIGNMENT(float __attribute__((vector_size(2 * sizeof(float)))));
|
|
CHECK_ALIGNMENT(float __attribute__((vector_size(4 * sizeof(float)))));
|
|
CHECK_ALIGNMENT(float __attribute__((vector_size(16 * sizeof(float)))));
|
|
CHECK_ALIGNMENT(float __attribute__((vector_size(32 * sizeof(float)))));
|
|
CHECK_ALIGNMENT(double __attribute__((vector_size(1 * sizeof(double)))));
|
|
CHECK_ALIGNMENT(double __attribute__((vector_size(2 * sizeof(double)))));
|
|
CHECK_ALIGNMENT(double __attribute__((vector_size(4 * sizeof(double)))));
|
|
CHECK_ALIGNMENT(double __attribute__((vector_size(16 * sizeof(double)))));
|
|
CHECK_ALIGNMENT(double __attribute__((vector_size(32 * sizeof(double)))));
|
|
CHECK_ALIGNMENT(struct Empty {});
|
|
CHECK_ALIGNMENT(struct OneInt { int i; });
|
|
CHECK_ALIGNMENT(struct IntArr2 { int i[2]; });
|
|
CHECK_ALIGNMENT(struct LLIArr2 { long long int i[2]; });
|
|
CHECK_ALIGNMENT(struct LLIArr4 { long long int i[4]; });
|
|
CHECK_ALIGNMENT(struct LLIArr8 { long long int i[8]; });
|
|
CHECK_ALIGNMENT(struct LLIArr16 { long long int i[16]; });
|
|
CHECK_ALIGNMENT(struct Padding { char c; /* padding */ long long int i; });
|
|
CHECK_ALIGNMENT(union IntFloat { int i; float f; });
|
|
}
|