{"thread":{"id":"37200","subject":"[PATCH/RFC] sparse: avoid sse2 code which renders sparse useless","startedAt":"2014-07-23T19:09:31Z","lastAt":"2014-07-23T19:09:31Z","messageCount":1,"participants":["Ramsay Jones"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"246593","messageId":"53D0086B.4090309@ramsay1.demon.co.uk","threadId":"37200","inReplyTo":null,"subject":"[PATCH/RFC] sparse: avoid sse2 code which renders sparse useless","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsay1.demon.co.uk","sentAt":"2014-07-23T19:09:31Z","receivedAt":"2014-07-23T19:09:31Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"\nCommit 745224e0 (\"refs.c: SSE2 optimizations for check_refname_\\\ncomponent\", 18-06-2014) introduces (on x86_64) the use of sse2\ncode, and associated header files, to optimize some reference\nhandling code. This causes sparse to implode and exit with \"too\nmany errors\", among other things, while attempting to parse the\ncode contained in those headers. For example, the following shows\njust the last few messages:\n\n    $ make abspath.sp\n    ...\n    /usr/lib/gcc/x86_64-pc-cygwin/4.8.3//include/mmintrin.h:724:38: error:\n    attribute '__gnu_inline__': unknown attribute\n    /usr/lib/gcc/x86_64-pc-cygwin/4.8.3//include/mmintrin.h:732:38: error:\n    too many errors\n    /usr/lib/gcc/x86_64-pc-cygwin/4.8.3//include/xmmintrin.h:91:34: error:\n    constant 0.0f is not a valid number\n    Makefile:2297: recipe for target 'abspath.sp' failed\n    make: *** [abspath.sp] Error 1\n    $\n\nThe most numerous errors (about 100 for the above file) relate to\nthe use of the __gnu_inline__ attribute. A simple 'one line' patch\nto sparse (actually it is three lines), can fix this up without too\nmuch problem. However, the final error above is not as simple (and\nquick) to fix. The code in question (.../xmmintrin.h:91), looks\nlike this:\n\n    return __extension__ (__m128){ 0.0f, 0.0f, 0.0f, 0.0f };\n\nUntil sparse learns to parse this gcc extension (if ever), we can avoid\nthe issue by simply not attempting to parse this code. In order to do\nthis, use the preprocessor symbol __CHECKER__, automatically defined by\nsparse, in the #if conditional already used to guard the code.\n\nSigned-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>\n---\n\nHi Junio,\n\nI've been sitting on this patch for some time, while I try to\ngauge how long it would take to fix sparse to cope with this\nvectorised code. Unfortunately, it would probably require adding\na considerable amount of code to add the same level of support\nfor __SSE__, __SSE2__, __MMX__, etc, that gcc provides.\n\nThis is marked RFC, because this would be the first use of\n__CHECKER__ in the git code-base. I have been cherry-picking\nthis on top of any branch I want to check. At first this\nwasn't too much of a hassle, but now commit 745224e0 has\nprogressed to master ... (last night I cherry-picked this\npatch approx a dozen times, so I was getting a little\nirritated! :D ).\n\nATB,\nRamsay Jones\n\n git-compat-util.h | 2 +-\n refs.c            | 2 +-\n 2 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex 26e92f1..1aae883 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -731,7 +731,7 @@ void git_qsort(void *base, size_t nmemb, size_t size,\n #endif\n #endif\n \n-#if defined(__GNUC__) && defined(__x86_64__)\n+#if defined(__GNUC__) && defined(__x86_64__) && !defined(__CHECKER__)\n #include <emmintrin.h>\n /*\n  * This is the system memory page size; it's used so that we can read\ndiff --git a/refs.c b/refs.c\nindex 84b9070..ffd4016 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -124,7 +124,7 @@ static int check_refname_format_bytewise(const char *refname, int flags)\n \treturn 0;\n }\n \n-#if defined(__GNUC__) && defined(__x86_64__)\n+#if defined(__GNUC__) && defined(__x86_64__) && !defined(__CHECKER__)\n #define SSE_VECTOR_BYTES 16\n \n /* Vectorized version of check_refname_format. */\n-- \n2.0.0\n"}]}