TomTan updated this revision to Diff 185849. TomTan added a comment. Added the tests back. Clang IR should not lower these to bswap calls because they are global library functions. It might be slower to make the call to library function than bswap, but this is the same for other architectures supported by Windows. And just redefine global library function triggers link error in some scenarios.
CHANGES SINCE LAST ACTION https://reviews.llvm.org/D57915/new/ https://reviews.llvm.org/D57915 Files: lib/Headers/intrin.h test/Headers/ms-arm64-intrin.cpp Index: test/Headers/ms-arm64-intrin.cpp =================================================================== --- test/Headers/ms-arm64-intrin.cpp +++ test/Headers/ms-arm64-intrin.cpp @@ -14,16 +14,16 @@ } unsigned short check_byteswap_ushort(unsigned short val) { -// CHECK: call i16 @llvm.bswap.i16(i16 %val) +// CHECK: call i16 @_byteswap_ushort(i16 %val) return _byteswap_ushort(val); } unsigned long check_byteswap_ulong(unsigned long val) { -// CHECK: call i32 @llvm.bswap.i32(i32 %val) +// CHECK: call i32 @_byteswap_ulong(i32 %val) return _byteswap_ulong(val); } unsigned __int64 check_byteswap_uint64(unsigned __int64 val) { -// CHECK: call i64 @llvm.bswap.i64(i64 %val) +// CHECK: call i64 @_byteswap_uint64(i64 %val) return _byteswap_uint64(val); } Index: lib/Headers/intrin.h =================================================================== --- lib/Headers/intrin.h +++ lib/Headers/intrin.h @@ -557,15 +557,9 @@ int _ReadStatusReg(int); void _WriteStatusReg(int, int); -static inline unsigned short _byteswap_ushort (unsigned short val) { - return __builtin_bswap16(val); -} -static inline unsigned long _byteswap_ulong (unsigned long val) { - return __builtin_bswap32(val); -} -static inline unsigned __int64 _byteswap_uint64 (unsigned __int64 val) { - return __builtin_bswap64(val); -} +unsigned short __cdecl _byteswap_ushort(unsigned short val); +unsigned long __cdecl _byteswap_ulong (unsigned long val); +unsigned __int64 __cdecl _byteswap_uint64(unsigned __int64 val); #endif /*----------------------------------------------------------------------------*\
Index: test/Headers/ms-arm64-intrin.cpp =================================================================== --- test/Headers/ms-arm64-intrin.cpp +++ test/Headers/ms-arm64-intrin.cpp @@ -14,16 +14,16 @@ } unsigned short check_byteswap_ushort(unsigned short val) { -// CHECK: call i16 @llvm.bswap.i16(i16 %val) +// CHECK: call i16 @_byteswap_ushort(i16 %val) return _byteswap_ushort(val); } unsigned long check_byteswap_ulong(unsigned long val) { -// CHECK: call i32 @llvm.bswap.i32(i32 %val) +// CHECK: call i32 @_byteswap_ulong(i32 %val) return _byteswap_ulong(val); } unsigned __int64 check_byteswap_uint64(unsigned __int64 val) { -// CHECK: call i64 @llvm.bswap.i64(i64 %val) +// CHECK: call i64 @_byteswap_uint64(i64 %val) return _byteswap_uint64(val); } Index: lib/Headers/intrin.h =================================================================== --- lib/Headers/intrin.h +++ lib/Headers/intrin.h @@ -557,15 +557,9 @@ int _ReadStatusReg(int); void _WriteStatusReg(int, int); -static inline unsigned short _byteswap_ushort (unsigned short val) { - return __builtin_bswap16(val); -} -static inline unsigned long _byteswap_ulong (unsigned long val) { - return __builtin_bswap32(val); -} -static inline unsigned __int64 _byteswap_uint64 (unsigned __int64 val) { - return __builtin_bswap64(val); -} +unsigned short __cdecl _byteswap_ushort(unsigned short val); +unsigned long __cdecl _byteswap_ulong (unsigned long val); +unsigned __int64 __cdecl _byteswap_uint64(unsigned __int64 val); #endif /*----------------------------------------------------------------------------*\
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits