[llvm] r323667 - [AccelTable] Workaround for MSVC bug
Jonas Devlieghere via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 29 09:28:51 PST 2018
Author: jdevlieghere
Date: Mon Jan 29 09:28:51 2018
New Revision: 323667
URL: http://llvm.org/viewvc/llvm-project?rev=323667&view=rev
Log:
[AccelTable] Workaround for MSVC bug
Microsoft Visual Studio rejects the static constexpr static list of
atoms even though it's valid C++. This provides a workaround to unbreak
the bots.
Modified:
llvm/trunk/include/llvm/CodeGen/AccelTable.h
llvm/trunk/lib/CodeGen/AsmPrinter/AccelTable.cpp
Modified: llvm/trunk/include/llvm/CodeGen/AccelTable.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/AccelTable.h?rev=323667&r1=323666&r2=323667&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/AccelTable.h (original)
+++ llvm/trunk/include/llvm/CodeGen/AccelTable.h Mon Jan 29 09:28:51 2018
@@ -153,10 +153,18 @@ private:
/// base is used to describe the offset for all forms in the list of atoms.
uint32_t DieOffsetBase;
- SmallVector<Atom, 3> Atoms;
+ const SmallVector<Atom, 4> Atoms;
+#ifndef _MSC_VER
+ // See the `static constexpr` below why we need an alternative
+ // implementation for MSVC.
HeaderData(ArrayRef<Atom> AtomList, uint32_t Offset = 0)
: DieOffsetBase(Offset), Atoms(AtomList.begin(), AtomList.end()) {}
+#else
+ // FIXME: Erase this path once the minimum MSCV version has been bumped.
+ HeaderData(const SmallVectorImpl<Atom> &Atoms, uint32_t Offset = 0)
+ : DieOffsetBase(Offset), Atoms(Atoms.begin(), Atoms.end()) {}
+#endif
#ifndef NDEBUG
void print(raw_ostream &OS) const {
@@ -174,8 +182,16 @@ private:
public:
/// The length of the header data is always going to be 4 + 4 + 4*NumAtoms.
+#ifndef _MSC_VER
+ // See the `static constexpr` below why we need an alternative implementation
+ // for MSVC.
AppleAccelTableHeader(ArrayRef<AppleAccelTableHeader::Atom> Atoms)
: Header(8 + (Atoms.size() * 4)), HeaderData(Atoms) {}
+#else
+ // FIXME: Erase this path once the minimum MSCV version has been bumped.
+ AppleAccelTableHeader(const SmallVectorImpl<Atom> &Atoms)
+ : Header(8 + (Atoms.size() * 4)), HeaderData(Atoms) {}
+#endif
/// Update header with hash and bucket count.
void setBucketAndHashCount(uint32_t HashCount);
@@ -270,8 +286,16 @@ protected:
using BucketList = std::vector<HashList>;
BucketList Buckets;
+#ifndef _MSC_VER
+ // See the `static constexpr` below why we need an alternative implementation
+ // for MSVC.
AppleAccelTableBase(ArrayRef<AppleAccelTableHeader::Atom> Atoms)
: Header(Atoms), Entries(Allocator) {}
+#else
+ // FIXME: Erase this path once the minimum MSCV version has been bumped.
+ AppleAccelTableBase(const SmallVectorImpl<AppleAccelTableHeader::Atom> &Atoms)
+ : Header(Atoms), Entries(Allocator) {}
+#endif
private:
/// Emits the header for the table via the AsmPrinter.
@@ -368,9 +392,15 @@ public:
void emit(AsmPrinter *Asm) const override;
- static constexpr const AppleAccelTableHeader::Atom Atoms[] = {
+#ifndef _MSC_VER
+ // The line below is rejected by older versions (TBD) of MSVC.
+ static constexpr AppleAccelTableHeader::Atom Atoms[] = {
AppleAccelTableHeader::Atom(dwarf::DW_ATOM_die_offset,
dwarf::DW_FORM_data4)};
+#else
+ // FIXME: Erase this path once the minimum MSCV version has been bumped.
+ static const SmallVector<AppleAccelTableHeader::Atom, 4> Atoms;
+#endif
#ifndef NDEBUG
void print(raw_ostream &OS) const override {
@@ -391,12 +421,18 @@ public:
void emit(AsmPrinter *Asm) const override;
- static constexpr const AppleAccelTableHeader::Atom Atoms[] = {
+#ifndef _MSC_VER
+ // The line below is rejected by older versions (TBD) of MSVC.
+ static constexpr AppleAccelTableHeader::Atom Atoms[] = {
AppleAccelTableHeader::Atom(dwarf::DW_ATOM_die_offset,
dwarf::DW_FORM_data4),
AppleAccelTableHeader::Atom(dwarf::DW_ATOM_die_tag, dwarf::DW_FORM_data2),
AppleAccelTableHeader::Atom(dwarf::DW_ATOM_type_flags,
dwarf::DW_FORM_data1)};
+#else
+ // FIXME: Erase this path once the minimum MSCV version has been bumped.
+ static const SmallVector<AppleAccelTableHeader::Atom, 4> Atoms;
+#endif
#ifndef NDEBUG
void print(raw_ostream &OS) const override {
@@ -414,9 +450,15 @@ public:
void emit(AsmPrinter *Asm) const override;
- static constexpr const AppleAccelTableHeader::Atom Atoms[] = {
+#ifndef _MSC_VER
+ // The line below is rejected by older versions (TBD) of MSVC.
+ static constexpr AppleAccelTableHeader::Atom Atoms[] = {
AppleAccelTableHeader::Atom(dwarf::DW_ATOM_die_offset,
dwarf::DW_FORM_data4)};
+#else
+ // FIXME: Erase this path once the minimum MSCV version has been bumped.
+ static const SmallVector<AppleAccelTableHeader::Atom, 4> Atoms;
+#endif
#ifndef NDEBUG
void print(raw_ostream &OS) const override {
@@ -443,12 +485,18 @@ public:
void emit(AsmPrinter *Asm) const override;
- static constexpr const AppleAccelTableHeader::Atom Atoms[] = {
+#ifndef _MSC_VER
+ // The line below is rejected by older versions (TBD) of MSVC.
+ static constexpr AppleAccelTableHeader::Atom Atoms[] = {
AppleAccelTableHeader::Atom(dwarf::DW_ATOM_die_offset,
dwarf::DW_FORM_data4),
AppleAccelTableHeader::Atom(dwarf::DW_ATOM_die_tag, dwarf::DW_FORM_data2),
AppleAccelTableHeader::Atom(5, dwarf::DW_FORM_data1),
AppleAccelTableHeader::Atom(6, dwarf::DW_FORM_data4)};
+#else
+ // FIXME: Erase this path once the minimum MSCV version has been bumped.
+ static const SmallVector<AppleAccelTableHeader::Atom, 4> Atoms;
+#endif
#ifndef NDEBUG
void print(raw_ostream &OS) const override {
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AccelTable.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AccelTable.cpp?rev=323667&r1=323666&r2=323667&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/AccelTable.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AccelTable.cpp Mon Jan 29 09:28:51 2018
@@ -70,11 +70,6 @@ void AppleAccelTableHeader::setBucketAnd
Header.HashCount = HashCount;
}
-constexpr const AppleAccelTableHeader::Atom AppleAccelTableTypeData::Atoms[];
-constexpr const AppleAccelTableHeader::Atom AppleAccelTableOffsetData::Atoms[];
-constexpr const AppleAccelTableHeader::Atom AppleAccelTableStaticOffsetData::Atoms[];
-constexpr const AppleAccelTableHeader::Atom AppleAccelTableStaticTypeData::Atoms[];
-
void AppleAccelTableBase::emitHeader(AsmPrinter *Asm) { Header.emit(Asm); }
void AppleAccelTableBase::emitBuckets(AsmPrinter *Asm) {
@@ -233,3 +228,35 @@ void AppleAccelTableStaticTypeData::emit
: 0);
Asm->EmitInt32(QualifiedNameHash);
}
+
+#ifndef _MSC_VER
+// The lines below are rejected by older versions (TBD) of MSVC.
+constexpr AppleAccelTableHeader::Atom AppleAccelTableTypeData::Atoms[];
+constexpr AppleAccelTableHeader::Atom AppleAccelTableOffsetData::Atoms[];
+constexpr AppleAccelTableHeader::Atom AppleAccelTableStaticOffsetData::Atoms[];
+constexpr AppleAccelTableHeader::Atom AppleAccelTableStaticTypeData::Atoms[];
+#else
+// FIXME: Erase this path once the minimum MSCV version has been bumped.
+const SmallVector<AppleAccelTableHeader::Atom, 4>
+ AppleAccelTableOffsetData::Atoms = {AppleAccelTableHeader::Atom(
+ dwarf::DW_ATOM_die_offset, dwarf::DW_FORM_data4)};
+const SmallVector<AppleAccelTableHeader::Atom, 4>
+ AppleAccelTableTypeData::Atoms = {
+ AppleAccelTableHeader::Atom(dwarf::DW_ATOM_die_offset,
+ dwarf::DW_FORM_data4),
+ AppleAccelTableHeader::Atom(dwarf::DW_ATOM_die_tag,
+ dwarf::DW_FORM_data2),
+ AppleAccelTableHeader::Atom(dwarf::DW_ATOM_type_flags,
+ dwarf::DW_FORM_data1)};
+const SmallVector<AppleAccelTableHeader::Atom, 4>
+ AppleAccelTableStaticOffsetData::Atoms = {AppleAccelTableHeader::Atom(
+ dwarf::DW_ATOM_die_offset, dwarf::DW_FORM_data4)};
+const SmallVector<AppleAccelTableHeader::Atom, 4>
+ AppleAccelTableStaticTypeData::Atoms = {
+ AppleAccelTableHeader::Atom(dwarf::DW_ATOM_die_offset,
+ dwarf::DW_FORM_data4),
+ AppleAccelTableHeader::Atom(dwarf::DW_ATOM_die_tag,
+ dwarf::DW_FORM_data2),
+ AppleAccelTableHeader::Atom(5, dwarf::DW_FORM_data1),
+ AppleAccelTableHeader::Atom(6, dwarf::DW_FORM_data4)};
+#endif
More information about the llvm-commits
mailing list