[llvm] [LLVM][NFC] Remove some global constructors (PR #208407)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 9 02:49:55 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-platform-windows
Author: Alexis Engelke (aengelke)
<details>
<summary>Changes</summary>
Largely by converting relevant functions or variables to constexpr,
changing the type, converting to static locals, or by outright removal.
PunnedPointer assignment can never be constexpr, because std::memcpy is
not constexpr and type punning is not permitted in a constant-evaluated
context.
---
Patch is 35.07 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/208407.diff
32 Files Affected:
- (modified) llvm/include/llvm/ADT/PointerIntPair.h (+3-2)
- (modified) llvm/include/llvm/Analysis/DOTGraphTraitsPass.h (+1-2)
- (modified) llvm/include/llvm/CGData/CodeGenData.h (+1-2)
- (modified) llvm/include/llvm/CodeGen/LiveInterval.h (+1-1)
- (modified) llvm/include/llvm/CodeGen/MachineBasicBlock.h (+1-1)
- (modified) llvm/include/llvm/DebugInfo/CodeView/TypeHashing.h (-4)
- (modified) llvm/include/llvm/IR/ModuleSummaryIndex.h (+4-11)
- (modified) llvm/include/llvm/IR/ProfileSummary.h (+2-2)
- (modified) llvm/include/llvm/Passes/OptimizationLevel.h (+1-1)
- (modified) llvm/include/llvm/Support/Alignment.h (+2-2)
- (modified) llvm/lib/CGData/CodeGenData.cpp (+1-1)
- (modified) llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp (+1-1)
- (modified) llvm/lib/CodeGen/InterferenceCache.cpp (+1-1)
- (modified) llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp (+7-9)
- (modified) llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h (+11-13)
- (modified) llvm/lib/CodeGen/LiveIntervalCalc.cpp (-3)
- (modified) llvm/lib/CodeGen/LiveRangeCalc.cpp (+2-2)
- (modified) llvm/lib/CodeGen/MachineBasicBlock.cpp (+3-2)
- (modified) llvm/lib/DebugInfo/CodeView/ContinuationRecordBuilder.cpp (+4-8)
- (modified) llvm/lib/DebugInfo/CodeView/TypeHashing.cpp (-7)
- (modified) llvm/lib/DebugInfo/CodeView/TypeStreamMerger.cpp (+4-7)
- (modified) llvm/lib/IR/ModuleSummaryIndex.cpp (-4)
- (modified) llvm/lib/Object/MachOUniversalWriter.cpp (+2-4)
- (modified) llvm/lib/Passes/OptimizationLevel.cpp (+4-4)
- (modified) llvm/lib/ProfileData/ProfileSummaryBuilder.cpp (+1-1)
- (modified) llvm/lib/Target/AArch64/AArch64StackTagging.cpp (+1-1)
- (modified) llvm/lib/Target/ARM/Thumb1FrameLowering.cpp (+7-7)
- (modified) llvm/lib/Target/X86/X86LoadValueInjectionLoadHardening.cpp (+9-9)
- (modified) llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp (+1-1)
- (modified) llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp (+2-2)
- (modified) llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp (+2-2)
- (modified) llvm/unittests/CodeGen/InstrRefLDVTest.cpp (+3-3)
``````````diff
diff --git a/llvm/include/llvm/ADT/PointerIntPair.h b/llvm/include/llvm/ADT/PointerIntPair.h
index c2db63382e13f..141a5f5384ed1 100644
--- a/llvm/include/llvm/ADT/PointerIntPair.h
+++ b/llvm/include/llvm/ADT/PointerIntPair.h
@@ -34,7 +34,8 @@ template <typename Ptr> struct PunnedPointer {
static_assert(std::is_trivially_copy_constructible<Ptr>::value, "");
static_assert(std::is_trivially_move_constructible<Ptr>::value, "");
- explicit constexpr PunnedPointer(intptr_t i = 0) { *this = i; }
+ explicit constexpr PunnedPointer() : Data{} {}
+ explicit PunnedPointer(intptr_t i) { *this = i; }
constexpr intptr_t asInt() const {
intptr_t R = 0;
@@ -44,7 +45,7 @@ template <typename Ptr> struct PunnedPointer {
constexpr operator intptr_t() const { return asInt(); }
- constexpr PunnedPointer &operator=(intptr_t V) {
+ PunnedPointer &operator=(intptr_t V) {
std::memcpy(Data, &V, sizeof(Data));
return *this;
}
diff --git a/llvm/include/llvm/Analysis/DOTGraphTraitsPass.h b/llvm/include/llvm/Analysis/DOTGraphTraitsPass.h
index 4c9538d8a2cda..ec03183e24465 100644
--- a/llvm/include/llvm/Analysis/DOTGraphTraitsPass.h
+++ b/llvm/include/llvm/Analysis/DOTGraphTraitsPass.h
@@ -18,8 +18,6 @@
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/GraphWriter.h"
-static llvm::StringSet<> nameObj;
-
namespace llvm {
/// Default traits class for extracting a graph from an analysis pass.
@@ -91,6 +89,7 @@ static inline void shortenFileName(std::string &FN, unsigned char len = 250) {
FN.resize(len);
auto strLen = FN.length();
while (strLen > 0) {
+ static llvm::StringSet<> nameObj;
if (nameObj.insert(FN).second)
break;
FN.resize(--len);
diff --git a/llvm/include/llvm/CGData/CodeGenData.h b/llvm/include/llvm/CGData/CodeGenData.h
index e44497a408245..1994fe4c79703 100644
--- a/llvm/include/llvm/CGData/CodeGenData.h
+++ b/llvm/include/llvm/CGData/CodeGenData.h
@@ -119,11 +119,10 @@ class CodeGenData {
/// Or, it can be mutated with -fcodegen-data-thinlto-two-rounds.
bool EmitCGData;
- /// This is a singleton instance which is thread-safe. Unlike profile data
+ /// There is a singleton instance which is thread-safe. Unlike profile data
/// which is largely function-based, codegen data describes the whole module.
/// Therefore, this can be initialized once, and can be used across modules
/// instead of constructing the same one for each codegen backend.
- static std::unique_ptr<CodeGenData> Instance;
static std::once_flag OnceFlag;
CodeGenData() = default;
diff --git a/llvm/include/llvm/CodeGen/LiveInterval.h b/llvm/include/llvm/CodeGen/LiveInterval.h
index 34f318a9d2715..c7d518f611d78 100644
--- a/llvm/include/llvm/CodeGen/LiveInterval.h
+++ b/llvm/include/llvm/CodeGen/LiveInterval.h
@@ -62,7 +62,7 @@ namespace llvm {
SlotIndex def;
/// VNInfo constructor.
- VNInfo(unsigned i, SlotIndex d) : id(i), def(d) {}
+ constexpr VNInfo(unsigned i, SlotIndex d) : id(i), def(d) {}
/// VNInfo constructor, copies values from orig, except for the value number.
VNInfo(unsigned i, const VNInfo &orig) : id(i), def(orig.def) {}
diff --git a/llvm/include/llvm/CodeGen/MachineBasicBlock.h b/llvm/include/llvm/CodeGen/MachineBasicBlock.h
index 47430a100b3cc..da6efd6f2fd17 100644
--- a/llvm/include/llvm/CodeGen/MachineBasicBlock.h
+++ b/llvm/include/llvm/CodeGen/MachineBasicBlock.h
@@ -79,7 +79,7 @@ struct MBBSectionID {
private:
// This is only used to construct the special cold and exception sections.
- MBBSectionID(SectionType T) : Type(T), Number(0) {}
+ constexpr MBBSectionID(SectionType T) : Type(T), Number(0) {}
};
template <> struct DenseMapInfo<MBBSectionID> {
diff --git a/llvm/include/llvm/DebugInfo/CodeView/TypeHashing.h b/llvm/include/llvm/DebugInfo/CodeView/TypeHashing.h
index 0f3b551134fd9..6a7f28fa40bab 100644
--- a/llvm/include/llvm/DebugInfo/CodeView/TypeHashing.h
+++ b/llvm/include/llvm/DebugInfo/CodeView/TypeHashing.h
@@ -183,8 +183,6 @@ static_assert(std::is_trivially_copyable<GloballyHashedType>::value,
} // namespace codeview
template <> struct DenseMapInfo<codeview::LocallyHashedType> {
- LLVM_ABI static codeview::LocallyHashedType Empty;
-
static unsigned getHashValue(codeview::LocallyHashedType Val) {
return Val.Hash;
}
@@ -198,8 +196,6 @@ template <> struct DenseMapInfo<codeview::LocallyHashedType> {
};
template <> struct DenseMapInfo<codeview::GloballyHashedType> {
- LLVM_ABI static codeview::GloballyHashedType Empty;
-
static unsigned getHashValue(codeview::GloballyHashedType Val) {
return *reinterpret_cast<const unsigned *>(Val.Hash.data());
}
diff --git a/llvm/include/llvm/IR/ModuleSummaryIndex.h b/llvm/include/llvm/IR/ModuleSummaryIndex.h
index f4c5e9b40796b..4db3a8fc8268e 100644
--- a/llvm/include/llvm/IR/ModuleSummaryIndex.h
+++ b/llvm/include/llvm/IR/ModuleSummaryIndex.h
@@ -997,9 +997,6 @@ class FunctionSummary : public GlobalValueSummary {
std::vector<CallsiteInfo>(), std::vector<AllocInfo>());
}
- /// A dummy node to reference external functions that aren't in the index
- LLVM_ABI static FunctionSummary ExternalNode;
-
private:
/// Number of instructions (ignoring debug instructions, e.g.) computed
/// during the initial compile step when the summary index is first built.
@@ -2130,9 +2127,7 @@ template <> struct GraphTraits<ValueInfo> {
static ChildIteratorType child_begin(NodeRef N) {
if (!N.getSummaryList().size()) // handle external function
- return ChildIteratorType(
- FunctionSummary::ExternalNode.CallGraphEdgeList.begin(),
- &valueInfoFromEdge);
+ return ChildIteratorType(ChildEdgeIteratorType(), &valueInfoFromEdge);
FunctionSummary *F =
cast<FunctionSummary>(N.getSummaryList().front()->getBaseObject());
return ChildIteratorType(F->CallGraphEdgeList.begin(), &valueInfoFromEdge);
@@ -2140,9 +2135,7 @@ template <> struct GraphTraits<ValueInfo> {
static ChildIteratorType child_end(NodeRef N) {
if (!N.getSummaryList().size()) // handle external function
- return ChildIteratorType(
- FunctionSummary::ExternalNode.CallGraphEdgeList.end(),
- &valueInfoFromEdge);
+ return ChildIteratorType(ChildEdgeIteratorType(), &valueInfoFromEdge);
FunctionSummary *F =
cast<FunctionSummary>(N.getSummaryList().front()->getBaseObject());
return ChildIteratorType(F->CallGraphEdgeList.end(), &valueInfoFromEdge);
@@ -2150,7 +2143,7 @@ template <> struct GraphTraits<ValueInfo> {
static ChildEdgeIteratorType child_edge_begin(NodeRef N) {
if (!N.getSummaryList().size()) // handle external function
- return FunctionSummary::ExternalNode.CallGraphEdgeList.begin();
+ return ChildEdgeIteratorType();
FunctionSummary *F =
cast<FunctionSummary>(N.getSummaryList().front()->getBaseObject());
@@ -2159,7 +2152,7 @@ template <> struct GraphTraits<ValueInfo> {
static ChildEdgeIteratorType child_edge_end(NodeRef N) {
if (!N.getSummaryList().size()) // handle external function
- return FunctionSummary::ExternalNode.CallGraphEdgeList.end();
+ return ChildEdgeIteratorType();
FunctionSummary *F =
cast<FunctionSummary>(N.getSummaryList().front()->getBaseObject());
diff --git a/llvm/include/llvm/IR/ProfileSummary.h b/llvm/include/llvm/IR/ProfileSummary.h
index 34012151f729f..8dee44a765f82 100644
--- a/llvm/include/llvm/IR/ProfileSummary.h
+++ b/llvm/include/llvm/IR/ProfileSummary.h
@@ -35,8 +35,8 @@ struct ProfileSummaryEntry {
const uint64_t MinCount; ///< The minimum count for this percentile.
const uint64_t NumCounts; ///< Number of counts >= the minimum count.
- ProfileSummaryEntry(uint32_t TheCutoff, uint64_t TheMinCount,
- uint64_t TheNumCounts)
+ constexpr ProfileSummaryEntry(uint32_t TheCutoff, uint64_t TheMinCount,
+ uint64_t TheNumCounts)
: Cutoff(TheCutoff), MinCount(TheMinCount), NumCounts(TheNumCounts) {}
};
diff --git a/llvm/include/llvm/Passes/OptimizationLevel.h b/llvm/include/llvm/Passes/OptimizationLevel.h
index c74407beb8598..29380de544005 100644
--- a/llvm/include/llvm/Passes/OptimizationLevel.h
+++ b/llvm/include/llvm/Passes/OptimizationLevel.h
@@ -22,7 +22,7 @@ namespace llvm {
class OptimizationLevel final {
unsigned SpeedLevel = 2;
- OptimizationLevel(unsigned SpeedLevel) : SpeedLevel(SpeedLevel) {
+ constexpr OptimizationLevel(unsigned SpeedLevel) : SpeedLevel(SpeedLevel) {
// Check that only valid values are passed.
assert(SpeedLevel <= 3 &&
"Optimization level for speed should be 0, 1, 2, or 3");
diff --git a/llvm/include/llvm/Support/Alignment.h b/llvm/include/llvm/Support/Alignment.h
index 2345dbe62c346..ec0a4649206d3 100644
--- a/llvm/include/llvm/Support/Alignment.h
+++ b/llvm/include/llvm/Support/Alignment.h
@@ -65,10 +65,10 @@ struct Align {
constexpr Align &operator=(const Align &Other) = default;
constexpr Align &operator=(Align &&Other) = default;
- explicit Align(uint64_t Value) {
+ explicit constexpr Align(uint64_t Value) {
assert(Value > 0 && "Value must not be 0");
assert(llvm::isPowerOf2_64(Value) && "Alignment is not a power of 2");
- ShiftValue = Log2_64(Value);
+ ShiftValue = 63 - llvm::countl_zero_constexpr(Value);
assert(ShiftValue < 64 && "Broken invariant");
}
diff --git a/llvm/lib/CGData/CodeGenData.cpp b/llvm/lib/CGData/CodeGenData.cpp
index 7900dc7653c03..0da5237ed8e94 100644
--- a/llvm/lib/CGData/CodeGenData.cpp
+++ b/llvm/lib/CGData/CodeGenData.cpp
@@ -141,10 +141,10 @@ std::string getCodeGenDataSectionName(CGDataSectKind CGSK,
return SectName;
}
-std::unique_ptr<CodeGenData> CodeGenData::Instance = nullptr;
std::once_flag CodeGenData::OnceFlag;
CodeGenData &CodeGenData::getInstance() {
+ static std::unique_ptr<CodeGenData> Instance = nullptr;
std::call_once(CodeGenData::OnceFlag, []() {
Instance = std::unique_ptr<CodeGenData>(new CodeGenData());
diff --git a/llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp b/llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp
index c750f643e99e2..6f101fd086487 100644
--- a/llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp
@@ -48,7 +48,7 @@ static cl::opt<std::string>
cl::desc("Record GlobalISel rule coverage files of this "
"prefix if instrumentation was generated"));
#else
-static const std::string CoveragePrefix;
+static constexpr StringRef CoveragePrefix;
#endif
char InstructionSelect::ID = 0;
diff --git a/llvm/lib/CodeGen/InterferenceCache.cpp b/llvm/lib/CodeGen/InterferenceCache.cpp
index 466070b312b2d..9ae89619e5665 100644
--- a/llvm/lib/CodeGen/InterferenceCache.cpp
+++ b/llvm/lib/CodeGen/InterferenceCache.cpp
@@ -27,7 +27,7 @@ using namespace llvm;
#define DEBUG_TYPE "regalloc"
// Static member used for null interference cursors.
-const InterferenceCache::BlockInterference
+constexpr InterferenceCache::BlockInterference
InterferenceCache::Cursor::NoInterference;
// Initializes PhysRegEntries (instead of a SmallVector, PhysRegEntries is a
diff --git a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
index 1b760a70608dd..e94d20f54d9db 100644
--- a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
+++ b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
@@ -155,7 +155,7 @@ static cl::opt<unsigned>
cl::desc("livedebugvalues-stack-ws-limit"),
cl::init(250));
-DbgOpID DbgOpID::UndefID = DbgOpID(0xffffffff);
+constexpr DbgOpID DbgOpID::UndefID = DbgOpID(0xffffffff);
/// Tracker for converting machine value locations and variable values into
/// variable locations (the output of LiveDebugValues), recorded as DBG_VALUEs
@@ -487,7 +487,7 @@ class TransferTracker {
for (auto Location : MTracker->locations()) {
LocIdx Idx = Location.Idx;
ValueIDNum &VNum = MLocs[Idx.asU64()];
- if (VNum == ValueIDNum::EmptyValue)
+ if (VNum == ValueIDNum())
continue;
VarLocs.push_back(VNum);
@@ -832,7 +832,7 @@ class TransferTracker {
if (ActiveMLocIt == ActiveMLocs.end())
return;
- VarLocs[MLoc.asU64()] = ValueIDNum::EmptyValue;
+ VarLocs[MLoc.asU64()] = ValueIDNum();
// Examine the remaining variable locations: if we can find the same value
// again, we can recover the location.
@@ -957,7 +957,7 @@ class TransferTracker {
// XXX XXX XXX "pretend to be old LDV" means dropping all tracking data
// about the old location.
if (EmulateOldLDV)
- VarLocs[Src.asU64()] = ValueIDNum::EmptyValue;
+ VarLocs[Src.asU64()] = ValueIDNum();
}
MachineInstrBuilder emitMOLoc(const MachineOperand &MO,
@@ -982,8 +982,6 @@ class TransferTracker {
// Implementation
//===----------------------------------------------------------------------===//
-ValueIDNum ValueIDNum::EmptyValue = {UINT_MAX, UINT_MAX, UINT_MAX};
-
#ifndef NDEBUG
void ResolvedDbgOp::dump(const MLocTracker *MTrack) const {
if (IsConst) {
@@ -1032,8 +1030,8 @@ void DbgValue::dump(const MLocTracker *MTrack,
MLocTracker::MLocTracker(MachineFunction &MF, const TargetInstrInfo &TII,
const TargetRegisterInfo &TRI,
const TargetLowering &TLI)
- : MF(MF), TII(TII), TRI(TRI), TLI(TLI),
- LocIdxToIDNum(ValueIDNum::EmptyValue), LocIdxToLocID(0) {
+ : MF(MF), TII(TII), TRI(TRI), TLI(TLI), LocIdxToIDNum(ValueIDNum()),
+ LocIdxToLocID(0) {
NumRegs = TRI.getNumRegs();
reset();
LocIDToLocIdx.resize(NumRegs, LocIdx::MakeIllegalLoc());
@@ -3784,7 +3782,7 @@ bool InstrRefBasedLDV::ExtendRanges(MachineFunction &MF,
// If there is no resolved value for this live-in then it is not directly
// reachable from the entry block -- model it as a PHI on entry to this
// block, which means we leave the ValueIDNum unchanged.
- if (ResolvedValue != ValueIDNum::EmptyValue)
+ if (ResolvedValue != ValueIDNum())
Num = ResolvedValue;
}
// Later, we'll be looking up ranges of instruction numbers.
diff --git a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h
index 184f07cb9fdf8..9e1e7c79f38c4 100644
--- a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h
+++ b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h
@@ -153,9 +153,10 @@ class ValueIDNum {
static_assert(sizeof(u) == 8, "Badly packed ValueIDNum?");
public:
- // Default-initialize to EmptyValue. This is necessary to make IndexedMaps
+ // Default-initialize to an empty value. This is necessary to make IndexedMaps
// of values to work.
- ValueIDNum() { u.Value = EmptyValue.asU64(); }
+ constexpr ValueIDNum()
+ : u{{(1u << 20) - 1, (1u << 20) - 1, (1u << NUM_LOC_BITS) - 1}} {}
ValueIDNum(uint64_t Block, uint64_t Inst, uint64_t Loc) {
u.s = {Block, Inst, Loc};
@@ -199,8 +200,6 @@ class ValueIDNum {
.concat(Twine("}")))))
.str();
}
-
- LLVM_ABI_FOR_TEST static ValueIDNum EmptyValue;
};
} // End namespace LiveDebugValues
@@ -238,8 +237,7 @@ struct FuncValueTable {
FuncValueTable(int NumBBs, int NumLocs) {
Storage.reserve(NumBBs);
for (int i = 0; i != NumBBs; ++i)
- Storage.push_back(
- std::make_unique<ValueTable>(NumLocs, ValueIDNum::EmptyValue));
+ Storage.push_back(std::make_unique<ValueTable>(NumLocs, ValueIDNum()));
}
/// Returns the ValueTable associated with MBB.
@@ -350,11 +348,11 @@ struct DbgOp {
};
bool IsConst;
- DbgOp() : ID(ValueIDNum::EmptyValue), IsConst(false) {}
+ DbgOp() : ID(), IsConst(false) {}
DbgOp(ValueIDNum ID) : ID(ID), IsConst(false) {}
DbgOp(MachineOperand MO) : MO(MO), IsConst(true) {}
- bool isUndef() const { return !IsConst && ID == ValueIDNum::EmptyValue; }
+ bool isUndef() const { return !IsConst && ID == ValueIDNum(); }
#ifndef NDEBUG
void dump(const MLocTracker *MTrack) const;
@@ -409,10 +407,10 @@ struct DbgOpID {
DbgOpID() : RawID(UndefID.RawID) {
static_assert(sizeof(DbgOpID) == 4, "DbgOpID should fit within 4 bytes.");
}
- DbgOpID(uint32_t RawID) : RawID(RawID) {}
+ constexpr DbgOpID(uint32_t RawID) : RawID(RawID) {}
DbgOpID(bool IsConst, uint32_t Index) : ID({IsConst, Index}) {}
- LLVM_ABI_FOR_TEST static DbgOpID UndefID;
+ LLVM_ABI_FOR_TEST static const DbgOpID UndefID;
bool operator==(const DbgOpID &Other) const { return RawID == Other.RawID; }
bool operator!=(const DbgOpID &Other) const { return !(*this == Other); }
@@ -583,8 +581,8 @@ class DbgValue {
ArrayRef<DbgOpID> getDbgOpIDs() const { return {DbgOps, OpCount}; }
// Returns either DbgOps[Index] if this DbgValue has Debug Operands, or
- // the ID for ValueIDNum::EmptyValue otherwise (i.e. if this is an Undef,
- // NoVal, or an unjoined VPHI).
+ // the ID for ValueIDNum() otherwise (i.e. if this is an Undef, NoVal, or an
+ // unjoined VPHI).
DbgOpID getDbgOpID(unsigned Index) const {
if (!OpCount)
return DbgOpID::UndefID;
@@ -937,7 +935,7 @@ class MLocTracker {
void wipeRegister(Register R) {
unsigned ID = getLocID(R);
LocIdx Idx = LocIDToLocIdx[ID];
- LocIdxToIDNum[Idx] = ValueIDNum::EmptyValue;
+ LocIdxToIDNum[Idx] = ValueIDNum();
}
/// Determine the LocIdx of an existing register.
diff --git a/llvm/lib/CodeGen/LiveIntervalCalc.cpp b/llvm/lib/CodeGen/LiveIntervalCalc.cpp
index 34057ef05134e..6d20fd18a19ac 100644
--- a/llvm/lib/CodeGen/LiveIntervalCalc.cpp
+++ b/llvm/lib/CodeGen/LiveIntervalCalc.cpp
@@ -25,9 +25,6 @@ using namespace llvm;
#define DEBUG_TYPE "regalloc"
-// Reserve an address that indicates a value that is known to be "undef".
-static VNInfo UndefVNI(0xbad, SlotIndex());
-
static void createDeadDef(SlotIndexes &Indexes, VNInfo::Allocator &Alloc,
LiveRange &LR, const MachineOperand &MO) {
const MachineInstr &MI = *MO.getParent();
diff --git a/llvm/lib/CodeGen/LiveRangeCalc.cpp b/llvm/lib/CodeGen/LiveRangeCalc.cpp
index 0260ee2e75aa5..8538d10d238ab 100644
--- a/llvm/lib/CodeGen/LiveRangeCalc.cpp
+++ b/llvm/lib/CodeGen/LiveRangeCalc.cpp
@@ -34,7 +34,7 @@ using namespace llvm;
#define DEBUG_TYPE "regalloc"
// Reserve an address that indicates a value that is known to be "undef".
-static VNInfo UndefVNI(0xbad, SlotIndex());
+static constexpr VNInfo UndefVNI(0xbad, SlotIndex());
void LiveRangeCalc::resetLiveOutMap() {
unsigned NumBlocks = MF->getNumBlockIDs();
@@ -250,7 +250,7 @@ bool LiveRangeCalc::findReachingDefs(LiveRange &LR, MachineBasicBlock &UseMBB,
auto EP = LR.extendInBlock(Undefs, Start, End);
VNInfo *VNI = EP.first;
FoundUndef |= EP.second;
- setLiveOutValue(Pred, EP.second ? &UndefVNI : VNI);
+ setLiveOutValue(Pred, EP.second ? const_cast<VNInfo *>(&UndefVNI) : VNI);
if (VNI) {
if (TheVNI && TheVNI != VNI)
UniqueVNI = false;
diff --git a/llvm/lib/CodeGen/MachineBasicBlock.cpp b/llvm/lib/CodeGen/MachineBasicBlock.cpp
index 2870bf404644c..000a4792e4004 100644
--- a/llvm/lib/CodeGen/MachineBasicBlock.cpp
+++ b/llvm/lib/CodeGen/MachineBasicBlock.cpp
@@ -1850,6 +1850,7 @@ void MachineBasicBlock::removePHIsIncomingValuesForPredecessor(
Phi.removePHIIncomingValueFor(PredMBB);
}
-const MBBSectionID MBBSectionID::ColdSectionID(MBBSectionID::SectionType::Cold);
-const MBBSectionID
+constexpr MBBSectionID
+ MBBSectionID::ColdSectionID(MBBSectionID::SectionType::Cold);
+constexpr MBBSectionID
MBBSectionID::ExceptionSectionID(MBBSectionID::SectionType::Exception);
diff --git a/llvm/lib/DebugInfo/CodeView/ContinuationRecordBuilder.cpp b/llvm/lib/DebugInfo/CodeView/ContinuationRecordBuilder.cpp
index 3761263b283bc..70ba57c40f8fc 100644
--- a/llvm/lib/DebugInfo/CodeView/ContinuationRecordBuilder.cpp
+++ b/llvm/lib/DebugInfo/CodeView/ContinuationRecordBuilder.cpp
@@ -31,9 +31,6 @@ static void addPadding(BinaryStreamWriter &Writer) {
}
}
-static SegmentInjection InjectFieldList(TypeLeafKind::LF_FIELDLIST);
-static SegmentInjection InjectMethodOverloadList(TypeLeafKind::LF_METHODLIST);
-
static constexpr uint32_t ContinuationLength = sizeof(ContinuationRecord)...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/208407
More information about the llvm-commits
mailing list