[PATCH] D57961: [X86] Add explicit alignment to __m128/__m128i/__m128d/etc. to allow matching of MSVC behavior with #pragma pack.

Craig Topper via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 8 09:55:47 PST 2019


craig.topper created this revision.
craig.topper added reviewers: rnk, erichkeane, spatel, RKSimon.
Herald added a project: clang.

With MSVC, #pragma pack is ignored when there is explicit alignment. This differs from gcc. Clang emulates this difference when compiling for Windows.

It appears that MSVC and headers consider the __m128/__m128i/__m128d/etc. types to be explicitly aligned and ignores #pragma pack for them. Since we don't have explicit alignment on them in our headers, we don't match the MSVC behavior here.

This patch adds explicit alignment to match this behavior. I'm hoping this won't cause any problems when we're not emulating MSVC. But if someone knows of something that would be different we can swith to conditionally adding the alignment based on _MSC_VER.

I had to add explicitly unaligned types as well so we could use them in the loadu/storeu intrinsics which use __attribute__(__packed__). So the explicitly aligned types wouldn't produce align 1 accesses when targeting Windows.


Repository:
  rC Clang

https://reviews.llvm.org/D57961

Files:
  lib/Headers/avx512bwintrin.h
  lib/Headers/avx512fintrin.h
  lib/Headers/avx512vlbwintrin.h
  lib/Headers/avx512vlintrin.h
  lib/Headers/avxintrin.h
  lib/Headers/emmintrin.h
  lib/Headers/xmmintrin.h
  test/CodeGen/x86-vec-struct-packing.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57961.185995.patch
Type: text/x-patch
Size: 19507 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190208/72cf775a/attachment-0001.bin>


More information about the cfe-commits mailing list