[PATCH] D52613: [ADT] Change the `IntervalMap` alignment assert for x86 MSVC

Aleksandr Urakov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 28 05:46:45 PDT 2018


aleksandr.urakov updated this revision to Diff 167456.
aleksandr.urakov added a comment.

Yes, you are right, both `clang` and `MinGW` align both `S0` and `S1` (x86 `MinGW` aligns the stack on 16 byte in the `main` function, so `foo0` and `foo1` become identical). I've updated the diff, thanks.

This one was hit during testing https://reviews.llvm.org/D52618, when running `lldb-test ir-memory-map`. I build LLVM with MSVC compiler, so the assert hits for `IntervalMap<addr_t, unsigned, 8, IntervalMapHalfOpenInfo<addr_t>>`.


https://reviews.llvm.org/D52613

Files:
  include/llvm/ADT/IntervalMap.h


Index: include/llvm/ADT/IntervalMap.h
===================================================================
--- include/llvm/ADT/IntervalMap.h
+++ include/llvm/ADT/IntervalMap.h
@@ -1040,8 +1040,17 @@
 
 public:
   explicit IntervalMap(Allocator &a) : height(0), rootSize(0), allocator(a) {
+#if defined(_MSC_VER) && !defined(_WIN64)
+    // x86 MSVC doesn't apply automatically (without `__declspec(align(...))`)
+    // alignments more than 4 bytes, even if `alignof` has returned so.
+    // The explanation:
+    // https://docs.microsoft.com/en-us/cpp/build/conflicts-with-the-x86-compiler
+    assert((uintptr_t(data.buffer) & (alignof(RootLeaf) - 1) & 3) == 0 &&
+           "Insufficient alignment");
+#else
     assert((uintptr_t(data.buffer) & (alignof(RootLeaf) - 1)) == 0 &&
            "Insufficient alignment");
+#endif
     new(&rootLeaf()) RootLeaf();
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52613.167456.patch
Type: text/x-patch
Size: 873 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180928/1a927c70/attachment.bin>


More information about the llvm-commits mailing list