[llvm] r369852 - Hack around a GCC ICE that was fixed in GCC 6.2

Benjamin Kramer via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 24 09:19:32 PDT 2019


Author: d0k
Date: Sat Aug 24 09:19:32 2019
New Revision: 369852

URL: http://llvm.org/viewvc/llvm-project?rev=369852&view=rev
Log:
Hack around a GCC ICE that was fixed in GCC 6.2

lib/Target/X86/AsmParser/X86AsmParser.cpp: In member function ‘void {anonymous}::X86AsmParser::SwitchMode(unsigned int)’:
lib/Target/X86/AsmParser/X86AsmParser.cpp:927:76:   in constexpr expansion of ‘AllModes.llvm::FeatureBitset::FeatureBitset(std::initializer_list<unsigned int>{((const unsigned int*)(& ._157)), 3u})’
include/llvm/MC/SubtargetFeature.h:56:12:   in constexpr expansion of ‘llvm::FeatureBitset::set(I)’
lib/Target/X86/AsmParser/X86AsmParser.cpp:927:76: internal compiler error: in fold_binary_loc, at fold-const.c:9921
     FeatureBitset AllModes({X86::Mode64Bit, X86::Mode32Bit, X86::Mode16Bit});
                                                                            ^

Modified:
    llvm/trunk/include/llvm/MC/SubtargetFeature.h

Modified: llvm/trunk/include/llvm/MC/SubtargetFeature.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/SubtargetFeature.h?rev=369852&r1=369851&r2=369852&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/SubtargetFeature.h (original)
+++ llvm/trunk/include/llvm/MC/SubtargetFeature.h Sat Aug 24 09:19:32 2019
@@ -62,17 +62,23 @@ public:
   }
 
   constexpr FeatureBitset &set(unsigned I) {
-    Bits[I / 64] |= uint64_t(1) << (I % 64);
+    // GCC <6.2 crashes if this is written in a single statement.
+    uint64_t NewBits = Bits[I / 64] | (uint64_t(1) << (I % 64));
+    Bits[I / 64] = NewBits;
     return *this;
   }
 
   constexpr FeatureBitset &reset(unsigned I) {
-    Bits[I / 64] &= ~(uint64_t(1) << (I % 64));
+    // GCC <6.2 crashes if this is written in a single statement.
+    uint64_t NewBits = Bits[I / 64] & ~(uint64_t(1) << (I % 64));
+    Bits[I / 64] = NewBits;
     return *this;
   }
 
   constexpr FeatureBitset &flip(unsigned I) {
-    Bits[I / 64] ^= uint64_t(1) << (I % 64);
+    // GCC <6.2 crashes if this is written in a single statement.
+    uint64_t NewBits = Bits[I / 64] ^ (uint64_t(1) << (I % 64));
+    Bits[I / 64] = NewBits;
     return *this;
   }
 




More information about the llvm-commits mailing list