https://bugs.llvm.org/show_bug.cgi?id=37400

            Bug ID: 37400
           Summary: MSVC and Clang use different values for _MM_HINT
                    constants; Windows SDK hardcodes MSVC values
           Product: clang
           Version: 6.0
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: Headers
          Assignee: unassignedclangb...@nondot.org
          Reporter: fabi...@radgametools.com
                CC: llvm-bugs@lists.llvm.org

With clang-cl 6.0:

// ---- begin
#include <emmintrin.h>
#include <Windows.h> // <--- only with this present!

void f(const void *p)
{
    _mm_prefetch((const char *)p, _MM_HINT_T0);
}
// ---- end

"clang-cl -c -O2 -FA prefetch.cpp" yields (only relevant parts):

# ---- begin
"?f@@YAXPEBX@Z":                        # @"\01?f@@YAXPEBX@Z"
# %bb.0:
        prefetcht2      (%rcx)
        retq
# ---- end

...huh? Some grepping later, it turns out that "um\winnt.h" in the Windows SDK
10.0.16299.0 (and presumably other versions as well, but I didn't check)
contains this:

C:\Program Files (x86)\Windows Kits\10\Include\10.0.16299.0>rg MM_HINT_T0
um\winnt.h
3266:#define _MM_HINT_T0     1
3296:#define PF_TEMPORAL_LEVEL_1 _MM_HINT_T0
7349:#define _MM_HINT_T0     1
7366:#define PF_TEMPORAL_LEVEL_1 _MM_HINT_T0

and indeed, the MSVC version of xmmintrin.h has _MM_HINT_T0 #defined to 1.

Long story short, for any translation unit that includes Windows.h, 
_MM_HINT_* end up re-#defined to MSVC-specific values, which produce the wrong
instructions with clang-cl.

If the goal is to make clang-cl be able to compile apps using unmodified
Windows headers, then Clang needs to use the same values for _MM_HINT_* as MSVC
does. (Presumably with some remapping done in the frontend.) Sigh.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to