mirror of
https://github.com/llvm/llvm-project.git
synced 2025-05-17 02:36:07 +00:00

The X86-64 ABI code didn't handle the case when a struct would get classified and turn up as "NoClass INTEGER" for example. This is perfectly possible when the first slot is all padding (e.g. due to empty base classes). In this situation, the first 8-byte doesn't take a register at all, only the second 8-byte does. This fixes this by enhancing the x86-64 abi stuff to allow and handle this case, reverts the broken fix for PR5831, and enhances the target independent stuff to be able to handle an argument value in registers being accessed at an offset from the memory value. This is the last x86-64 calling convention related miscompile that I'm aware of. llvm-svn: 109848
45 lines
1.4 KiB
C++
45 lines
1.4 KiB
C++
// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin9 | FileCheck %s
|
|
|
|
template < bool condition, typename T = void >
|
|
struct enable_if { typedef T type; };
|
|
|
|
template< typename T >
|
|
struct enable_if< false, T > {};
|
|
|
|
// PR5876
|
|
namespace Casts {
|
|
template< unsigned O >
|
|
void implicit(typename enable_if< O <= 4 >::type* = 0) {
|
|
}
|
|
|
|
template< unsigned O >
|
|
void cstyle(typename enable_if< O <= (unsigned)4 >::type* = 0) {
|
|
}
|
|
|
|
template< unsigned O >
|
|
void functional(typename enable_if< O <= unsigned(4) >::type* = 0) {
|
|
}
|
|
|
|
template< unsigned O >
|
|
void static_(typename enable_if< O <= static_cast<unsigned>(4) >::type* = 0) {
|
|
}
|
|
|
|
// FIXME: Test const_cast, reinterpret_cast, dynamic_cast, which are
|
|
// a bit harder to use in template arguments.
|
|
template <unsigned N> struct T {};
|
|
|
|
template <int N> T<N> f() { return T<N>(); }
|
|
|
|
// CHECK: define weak_odr void @_ZN5Casts8implicitILj4EEEvPN9enable_ifIXleT_Li4EEvE4typeE
|
|
template void implicit<4>(void*);
|
|
// CHECK: define weak_odr void @_ZN5Casts6cstyleILj4EEEvPN9enable_ifIXleT_cvjLi4EEvE4typeE
|
|
template void cstyle<4>(void*);
|
|
// CHECK: define weak_odr void @_ZN5Casts10functionalILj4EEEvPN9enable_ifIXleT_cvjLi4EEvE4typeE
|
|
template void functional<4>(void*);
|
|
// CHECK: define weak_odr void @_ZN5Casts7static_ILj4EEEvPN9enable_ifIXleT_cvjLi4EEvE4typeE
|
|
template void static_<4>(void*);
|
|
|
|
// CHECK: define weak_odr void @_ZN5Casts1fILi6EEENS_1TIXT_EEEv
|
|
template T<6> f<6>();
|
|
}
|