From 381fc0ee3ce32583786aae1619b97cc28865015d Mon Sep 17 00:00:00 2001 From: George Burgess IV Date: Thu, 25 Aug 2016 01:05:08 +0000 Subject: [PATCH] Make some LLVM_CONSTEXPR variables const. NFC. This patch changes LLVM_CONSTEXPR variable declarations to const variable declarations, since LLVM_CONSTEXPR expands to nothing if the current compiler doesn't support constexpr. In all of the changed cases, it looks like the code intended the variable to be const instead of sometimes-constexpr sometimes-not. llvm-svn: 279696 --- llvm/lib/Analysis/AliasAnalysisSummary.cpp | 27 +++++++++++++-------------- llvm/lib/Analysis/AliasAnalysisSummary.h | 4 ++-- llvm/lib/Analysis/CFLAndersAliasAnalysis.cpp | 6 ++---- llvm/lib/Analysis/MemoryBuiltins.cpp | 2 +- llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 2 +- llvm/lib/IR/Attributes.cpp | 2 +- llvm/lib/Support/APInt.cpp | 2 +- llvm/lib/Target/AArch64/AArch64InstrInfo.cpp | 2 +- 8 files changed, 22 insertions(+), 25 deletions(-) diff --git a/llvm/lib/Analysis/AliasAnalysisSummary.cpp b/llvm/lib/Analysis/AliasAnalysisSummary.cpp index 567405d..09a6b82 100644 --- a/llvm/lib/Analysis/AliasAnalysisSummary.cpp +++ b/llvm/lib/Analysis/AliasAnalysisSummary.cpp @@ -7,25 +7,24 @@ namespace llvm { namespace cflaa { namespace { -LLVM_CONSTEXPR unsigned AttrEscapedIndex = 0; -LLVM_CONSTEXPR unsigned AttrUnknownIndex = 1; -LLVM_CONSTEXPR unsigned AttrGlobalIndex = 2; -LLVM_CONSTEXPR unsigned AttrCallerIndex = 3; -LLVM_CONSTEXPR unsigned AttrFirstArgIndex = 4; -LLVM_CONSTEXPR unsigned AttrLastArgIndex = NumAliasAttrs; -LLVM_CONSTEXPR unsigned AttrMaxNumArgs = AttrLastArgIndex - AttrFirstArgIndex; +const unsigned AttrEscapedIndex = 0; +const unsigned AttrUnknownIndex = 1; +const unsigned AttrGlobalIndex = 2; +const unsigned AttrCallerIndex = 3; +const unsigned AttrFirstArgIndex = 4; +const unsigned AttrLastArgIndex = NumAliasAttrs; +const unsigned AttrMaxNumArgs = AttrLastArgIndex - AttrFirstArgIndex; // NOTE: These aren't AliasAttrs because bitsets don't have a constexpr // ctor for some versions of MSVC that we support. We could maybe refactor, // but... using AliasAttr = unsigned; -LLVM_CONSTEXPR AliasAttr AttrNone = 0; -LLVM_CONSTEXPR AliasAttr AttrEscaped = 1 << AttrEscapedIndex; -LLVM_CONSTEXPR AliasAttr AttrUnknown = 1 << AttrUnknownIndex; -LLVM_CONSTEXPR AliasAttr AttrGlobal = 1 << AttrGlobalIndex; -LLVM_CONSTEXPR AliasAttr AttrCaller = 1 << AttrCallerIndex; -LLVM_CONSTEXPR AliasAttr ExternalAttrMask = - AttrEscaped | AttrUnknown | AttrGlobal; +const AliasAttr AttrNone = 0; +const AliasAttr AttrEscaped = 1 << AttrEscapedIndex; +const AliasAttr AttrUnknown = 1 << AttrUnknownIndex; +const AliasAttr AttrGlobal = 1 << AttrGlobalIndex; +const AliasAttr AttrCaller = 1 << AttrCallerIndex; +const AliasAttr ExternalAttrMask = AttrEscaped | AttrUnknown | AttrGlobal; } AliasAttrs getAttrNone() { return AttrNone; } diff --git a/llvm/lib/Analysis/AliasAnalysisSummary.h b/llvm/lib/Analysis/AliasAnalysisSummary.h index 18ca3a9..51a85f4 100644 --- a/llvm/lib/Analysis/AliasAnalysisSummary.h +++ b/llvm/lib/Analysis/AliasAnalysisSummary.h @@ -99,7 +99,7 @@ AliasAttrs getExternallyVisibleAttrs(AliasAttrs); //===----------------------------------------------------------------------===// /// The maximum number of arguments we can put into a summary. -LLVM_CONSTEXPR static unsigned MaxSupportedArgsInSummary = 50; +static const unsigned MaxSupportedArgsInSummary = 50; /// We use InterfaceValue to describe parameters/return value, as well as /// potential memory locations that are pointed to by parameters/return value, @@ -137,7 +137,7 @@ inline bool operator>=(InterfaceValue LHS, InterfaceValue RHS) { // We use UnknownOffset to represent pointer offsets that cannot be determined // at compile time. Note that MemoryLocation::UnknownSize cannot be used here // because we require a signed value. -static LLVM_CONSTEXPR int64_t UnknownOffset = INT64_MAX; +static const int64_t UnknownOffset = INT64_MAX; inline int64_t addOffset(int64_t LHS, int64_t RHS) { if (LHS == UnknownOffset || RHS == UnknownOffset) diff --git a/llvm/lib/Analysis/CFLAndersAliasAnalysis.cpp b/llvm/lib/Analysis/CFLAndersAliasAnalysis.cpp index d851212..b3393888 100644 --- a/llvm/lib/Analysis/CFLAndersAliasAnalysis.cpp +++ b/llvm/lib/Analysis/CFLAndersAliasAnalysis.cpp @@ -107,12 +107,10 @@ enum class MatchState : uint8_t { }; typedef std::bitset<7> StateSet; -// N.B. These are unsigned instead of StateSets because some MSVC versions -// apparently lack constexpr bitset ctors. -LLVM_CONSTEXPR unsigned ReadOnlyStateMask = +const unsigned ReadOnlyStateMask = (1U << static_cast(MatchState::FlowFromReadOnly)) | (1U << static_cast(MatchState::FlowFromMemAliasReadOnly)); -LLVM_CONSTEXPR unsigned WriteOnlyStateMask = +const unsigned WriteOnlyStateMask = (1U << static_cast(MatchState::FlowToWriteOnly)) | (1U << static_cast(MatchState::FlowToMemAliasWriteOnly)); diff --git a/llvm/lib/Analysis/MemoryBuiltins.cpp b/llvm/lib/Analysis/MemoryBuiltins.cpp index f234776..d7fcb0f 100644 --- a/llvm/lib/Analysis/MemoryBuiltins.cpp +++ b/llvm/lib/Analysis/MemoryBuiltins.cpp @@ -114,7 +114,7 @@ static Optional getAllocationData(const Value *V, AllocType AllocTy, // MallocLike is chosen here because allocsize makes no guarantees about the // nullness of the result of the function, nor does it deal with strings, nor // does it require that the memory returned is zeroed out. - LLVM_CONSTEXPR auto AllocSizeAllocTy = MallocLike; + const AllocType AllocSizeAllocTy = MallocLike; if ((AllocTy & AllocSizeAllocTy) == AllocSizeAllocTy && Callee->hasFnAttribute(Attribute::AllocSize)) { Attribute Attr = Callee->getFnAttribute(Attribute::AllocSize); diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index d2fb6fe..3077822 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -196,7 +196,7 @@ const DIType *DbgVariable::getType() const { return Ty; } -static LLVM_CONSTEXPR DwarfAccelTable::Atom TypeAtoms[] = { +static const DwarfAccelTable::Atom TypeAtoms[] = { DwarfAccelTable::Atom(dwarf::DW_ATOM_die_offset, dwarf::DW_FORM_data4), DwarfAccelTable::Atom(dwarf::DW_ATOM_die_tag, dwarf::DW_FORM_data2), DwarfAccelTable::Atom(dwarf::DW_ATOM_type_flags, dwarf::DW_FORM_data1)}; diff --git a/llvm/lib/IR/Attributes.cpp b/llvm/lib/IR/Attributes.cpp index 93b3d28..95ddc36 100644 --- a/llvm/lib/IR/Attributes.cpp +++ b/llvm/lib/IR/Attributes.cpp @@ -38,7 +38,7 @@ using namespace llvm; // // In order to do this, we need to reserve one value of the second (optional) // allocsize argument to signify "not present." -LLVM_CONSTEXPR static unsigned AllocSizeNumElemsNotPresent = -1; +static const unsigned AllocSizeNumElemsNotPresent = -1; static uint64_t packAllocSizeArgs(unsigned ElemSizeArg, const Optional &NumElemsArg) { diff --git a/llvm/lib/Support/APInt.cpp b/llvm/lib/Support/APInt.cpp index 31ffffc..318ce10 100644 --- a/llvm/lib/Support/APInt.cpp +++ b/llvm/lib/Support/APInt.cpp @@ -1495,7 +1495,7 @@ static void KnuthDiv(unsigned *u, unsigned *v, unsigned *q, unsigned* r, assert(n>1 && "n must be > 1"); // b denotes the base of the number system. In our case b is 2^32. - LLVM_CONSTEXPR uint64_t b = uint64_t(1) << 32; + const uint64_t b = uint64_t(1) << 32; DEBUG(dbgs() << "KnuthDiv: m=" << m << " n=" << n << '\n'); DEBUG(dbgs() << "KnuthDiv: original:"); diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp b/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp index e3afa89..3b1006f 100644 --- a/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp +++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp @@ -29,7 +29,7 @@ using namespace llvm; #define GET_INSTRINFO_CTOR_DTOR #include "AArch64GenInstrInfo.inc" -static LLVM_CONSTEXPR MachineMemOperand::Flags MOSuppressPair = +static const MachineMemOperand::Flags MOSuppressPair = MachineMemOperand::MOTargetFlag1; static cl::opt -- 2.7.4