clang

Clang generates worse code for 7 comparisons than for 8 comparisons

半城伤御伤魂 提交于 2019-12-23 10:54:52
问题 I was intrigued by clang's ability to convert many == comparisons of small integers to to one big SIMD instruction, but then I noticed something strange. Clang generated "worse" code(in my amateur evaluation) when I had 7 comparisons compared to the code when I had 8 comparisons. bool f1(short x){ return (x==-1) | (x == 150) | (x==5) | (x==64) | (x==15) | (x==223) | (x==42) | (x==47); } bool f2(short x){ return (x==-1) | (x == 150) | (x==5) | (x==64) | (x==15) | (x==223) | (x==42); } My

Segmentation fault with array of __m256i when using clang/g++

孤者浪人 提交于 2019-12-23 10:23:08
问题 I'm attempting to generate arrays of __m256i 's to reuse in another computation. When I attempt to do that (even with a minimal testcase), I get a segmentation fault - but only if the code is compiled with g++ or clang. If I compile the code with the Intel compiler (version 16.0), no segmentation fault occurs. Here is a test case I created: int main() { __m256i *table = new __m256i[10000]; __m256i zeroes = _mm256_set_epi64x(0, 0, 0, 0); table[99] = zeroes; } When compiling the above with

Work around lack of Yz machine constraint under Clang?

旧巷老猫 提交于 2019-12-23 10:10:52
问题 We use inline assembly to make SHA instructions available if __SHA__ is not defined. Under GCC we use: GCC_INLINE __m128i GCC_INLINE_ATTRIB MM_SHA256RNDS2_EPU32(__m128i a, const __m128i b, const __m128i c) { asm ("sha256rnds2 %2, %1, %0" : "+x"(a) : "xm"(b), "Yz" (c)); return a; } Clang does not consume GCC's Yz constraint (see Clang 3.2 Issue 13199 and Clang 3.9 Issue 32727), which is required by the sha256rnds2 instruction: Yz First SSE register (%xmm0). We added a mov for Clang: asm ("mov

What is the clang analogue of ldd?

守給你的承諾、 提交于 2019-12-23 09:43:01
问题 How do I find out what DLLs an executable depends on? On systems with the GNU development toolchain ( gcc &c) I use ldd for that, but what about the clang systems, like, e.g., Mac OS X (which does not have ldd )? 回答1: On Mac OSX, you'd use otool -L instead of ldd . This works regardless of the compiler you used. Other operating systems may have yet other tools; e.g. on Windows you'd use Dependency Walker . 来源: https://stackoverflow.com/questions/23697641/what-is-the-clang-analogue-of-ldd

ADL does not work in constexpr functions (clang only)

我与影子孤独终老i 提交于 2019-12-23 09:20:03
问题 The following code compiles with MSVC and gcc, but not with clang. Why is that so? It seems like if ADL would not work if CallFoo () is constexpr . See the comment. template <class T> constexpr void CallFoo () // Remove constexpr to fix clang compilation error. { Foo (T ()); } class Apple {}; int main () { CallFoo<Apple> (); } constexpr void Foo (Apple) { } Clang error message (see on godbolt.org): <source>:4:5: error: use of undeclared identifier 'Foo' Foo (T ()); ^ <source>:13:5: note: in

How can I prevent Xcode 4.2 from filling my boot drive with preamble.pch files?

时光怂恿深爱的人放手 提交于 2019-12-23 09:17:47
问题 There's an issue in Xcode 4.2, where Xcode will fill my boot drive with tens of GB of preamble.pch-****** files, someplace within /private/var/folders/ . Does anybody know how to prevent this from happening? This means I have to manually empty these files every few hours (quitting/restarting Xcode if necessary), to prevent my boot drive from filling up. I'd (likely) rather revert to the old behavior than create some script or program to systematically remove these every hour, if possible.

Lambdas, local types, and global namespace

不羁岁月 提交于 2019-12-23 08:54:04
问题 This minimal program template <typename X> void foo (X x) { bar (x); } template <typename X> void bar (X x) { } int main () { foo ([]{}); } compiles with gcc (4.8.5 and 5.3) and fails to compile with clang (3.7) My analysis is as follows. bar is used in foo and declared after foo , so it is not visible at foo definition point. The only way bar can be found at foo instantiation point is via argument-dependent lookup. The only argument to both foo and bar is a lambda defined in main .

Who is failing, boost, clang, or gcc? Issue with std::chrono used with boost::asio

删除回忆录丶 提交于 2019-12-23 08:53:57
问题 As noted by this question, boost::asio now can use the C++11 chrono objects if they are available. However, the following code compiles with but not with clang 3.6.0-svn223366-1~exp1 #include <iostream> #include <boost/chrono.hpp> #include <boost/bind.hpp> #include <boost/asio.hpp> #include <boost/asio/steady_timer.hpp> #include <chrono> #include <thread> #include <functional> boost::asio::io_service ioservice; boost::asio::steady_timer timer(ioservice); void function() { std::cout <<

What predefined macro can I use to detect the target architecture in Clang?

半腔热情 提交于 2019-12-23 08:48:09
问题 I would like to write code depending on whether the target architecture is e.g. armv7, armv7s, or arm64. The reason that I can't use sysctlbyname is that this would give me the underlying architecture at runtime, but when arm64 e.g. simulates armv7, sysctl (seemingly) still reports arm64. 回答1: clang --target=... -mcpu=... -E - -dM </dev/null will output all the pre-defined preprocessor macros (similar works for gcc, too) I don't see single macro that provides the answer, but you can probably

cmake generated Xcode-project - release-build works but archive fails on linker errors

旧街凉风 提交于 2019-12-23 08:36:51
问题 Using Xcode 6.3.1, CMake 3.2.2 I have a project which links with a library. This library is included in the xcode-project as code, compiled and then linked with the main executable. The project is generated with cmake. Some extracts of the CMakeLists.txt: add_library(mylib ${mylib_HEADERS} pch.cpp source/mylib/xxx.cpp) ... add_executable(${MAIN_BINARY_NAME} MACOSX_BUNDLE ${MAIN_HEADERS} ${MAIN_CODE_FILES} ${MAIN_ICON_FILES} ${MAIN_DYLIBS} ) target_link_libraries (${MAIN_BINARY_NAME} mylib)