[cfe-users] Clang/LLVM detection on Windows
Is there a macro defined by Clang that helps to distinguish between Clang/LLVM is called under MinGW/Cygwin and Clang/LLVM with/from MSVC? Have a good day, degski ___ cfe-users mailing list cfe-users@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users
Re: [cfe-users] cfe-users Digest, Vol 63, Issue 2
On 2 April 2018 at 14:00, via cfe-users wrote: > > > Date: Sat, 31 Mar 2018 23:51:22 -0400 > > From: Jeffrey Walton via cfe-users > > To: "CFE-Users (Clang)" > > Subject: [cfe-users] Problems with hexadecimal constant, > >_mm_set_epi64x and sign conversion > > Message-ID: > > > > Content-Type: text/plain; charset="UTF-8" > > > > I'm having trouble with Travis during testing. The failed test is > > available at https://travis-ci.org/Tarsnap/scrypt/jobs/360781179. > > > > Clang has rejected my attempts to use the constant (no suffix, ULL and > LL): > > > > MSG = _mm_add_epi32(MSG0, _mm_set_epi64x(0xE9B5DBA5B5C0FBCF, > > 0x71374491428A2F98)); > > > > MSG = _mm_add_epi32(MSG0, _mm_set_epi64x(0xE9B5DBA5B5C0FBCFULL, > > 0x71374491428A2F98ULL)); > > > > MSG = _mm_add_epi32(MSG0, _mm_set_epi64x(0xE9B5DBA5B5C0FBCFLL, > > 0x71374491428A2F98LL)); > > > > The message the compiler provides is: > > > > crypto_sha256_shani.c:50:44: error: implicit conversion changes > > signedness: 'unsigned long' to 'long long' [-Werror,-Wsign-conversion] > > > > The code came from Intel and I doubt it is defective. > > > > How do I trick Clang to accept the hexadecimal value? > A hex value is unsigned by definition, so attaching "LL" to the end won't work. The prototype of _mm_add_epi32 (a.o.) has the ints as signed. So, the answer is to just c-cast the hex values to long long (AFAICS), or suppress the warning. degski ___ cfe-users mailing list cfe-users@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users
[cfe-users] Error calling _mm256_cvtps_ph intrinsic on Windows
When calling the _mm256_cvtps_ph instruction [1] using Clang [2] the following error manifests itself: 1>-- Build started: Project: CRoaringTest, Configuration: Debug x64 -- 1>main.c(19): error : '__builtin_ia32_vcvtps2ph256' needs target feature f16c 1>C:\Program Files\LLVM\lib\clang\7.0.0\include\immintrin.h(100): note: expanded from macro '_mm256_cvtps_ph' 1>Done building project "CRoaringTest.vcxproj" -- FAILED. == Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped == I'm trying to call the following function: __declspec ( noinline ) void float2half ( float * floats, short * halfs ) { _mm_store_si128 ( ( __m128i* ) halfs, _mm256_cvtps_ph ( _mm256_load_ps ( floats ), 0 ) ); } int main () { float test [ 8 ] = { -0.0f, -1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f }; short rest [ 8 ] = { 0 }; float2half ( test, rest ); for ( int32_t i = 0; i < 8; ++i ) { printf ( "%i ", ( int ) rest [ i ] ); } printf ( "\n" ); return 0; } I have a Broadwell CPU (i.e. it should work) and VS 15.6.6 compiles this just fine. In Debug the error is shown as per above, in Release, no error, but crashes. degski [1] https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_mm256_cvtps_ph&expand=1711 [2] http://prereleases.llvm.org/win-snapshots/LLVM-7.0.0-r325576-win64.exe ___ cfe-users mailing list cfe-users@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users
[cfe-users] -Wcast-align
I have the following code (C11): #define vector_grow(vec, count) \ do { \ if(!(vec)) { \ size_t *__p = (size_t*) malloc ((size_t)(count) * sizeof(*(vec)) + (sizeof(size_t) * 2)); \ assert(__p); \ (vec) = (void *)(&__p[2]); \ vector_set_capacity((vec), (count));\ vector_set_size((vec), 0); \ } else { \ size_t *__p1 = &((size_t *)(vec))[-2]; \ << size_t *__p2 = realloc(__p1, ((size_t)(count) * sizeof(*(vec))+ (sizeof(size_t) * 2))); \ assert(__p2); \ (vec) = (void *)(&__p2[2]); \ vector_set_capacity((vec), (count));\ } \ } while(0) With -Wall it generates the following warning: cast from 'float *' to 'size_t *' (aka 'unsigned long long *') increases required alignment from 4 to 8 [-Wcast-align], triggered by the indicated line, in case the type of pointer is smaller than size_t. I get the gist of it, but reading the std (taking cppreference.com's word for it), this seems un-necessary. malloc: "If allocation succeeds, returns a pointer to the lowest (first) byte in the allocated memory block *that is suitably aligned for any object type*.". and aligned_alloc: "Regular malloc aligns memory suitable for any object type (which, in practice, *means that it is aligned to alignof(max_align_t))*.", which means long double. It appears that even on Windows (without a real long double), alignment *is* at least 16. No warning on this issue from VS 15.6.6. ___ cfe-users mailing list cfe-users@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users
[cfe-users] Snapshot Updates
Thumbs up to the person updating the Windows LLVM Snapshot Builds. degski -- *“If something cannot go on forever, it will stop" - Herbert Stein* ___ cfe-users mailing list cfe-users@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users
[cfe-users] (no subject)
Hi Андре, You need to install "the integration" (with VS) correctly. For VS14 you'll need to use 'old style' integration: https://github.com/degski/Clang.Props . This is a copy job. For VS15, use the plugin on: https://marketplace.visualstudio.com/items?itemName=LLVMExtensions.llvm-toolchain . The latter don't work for VS19, use this instead: https://github.com/degski/llvm2019 . For the latter, you'll need to install the components to build a VS plugin-in. Just open and build the (llvm2019) project and VC will install the components to build the project. The resulting binary is unsigned and can only be used on your machine. If you go this route (the only counts for llvm2019), you'll (possibly) need a fix to Windows (to build and run unsigned plugins), I'll point it out to you if you need it and just ask. In all 'integrations' the tool-chain' (vc/clang-cl) can be selected from the pull-down menu in VS. degski PS: please refrain from nastiness if you haven't yet researched the problem and are unaware that your solution simply possibly does not cut the mustard. Done properly the use of clang with VS is seamless. -- @realdegski https://brave.com/google-gdpr-workaround/ "We value your privacy, click here!" Sod off! - degski "Anyone who believes that exponential growth can go on forever in a finite world is either a madman or an economist" - Kenneth E. Boulding "Growth for the sake of growth is the ideology of the cancer cell" - Edward P. Abbey ___ cfe-users mailing list cfe-users@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users