[llvm] [CodeGen] Stop exporting cl::opts. NFC (PR #228728)

via llvm-commits llvm-commits at lists.llvm.org
Sat Oct 3 08:56:39 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-regalloc

Author: Fangrui Song (MaskRay)

<details>
<summary>Changes</summary>

AMDGPU reads -misched-prera-direction and -verify-misched, every
target's TTI reads -partial-unrolling-threshold through BasicTTIImpl.h,
and AsmPrinter reads -emit-bb-hash through extern declarations. Add
getters for them, move inline code that reads options (LiveIntervals,
MachinePipeliner, MIR2Vec) out of line, and let unittests use default
weights, so that the options can be file-local.

Aided by Opus 5.5

---

<sub>Stack created with <a href="https://github.com/github/gh-stack">GitHub Stacks CLI</a> • <a href="https://gh.io/stacks-feedback">Give Feedback 💬</a></sub>

---

Patch is 29.49 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/228728.diff


20 Files Affected:

- (modified) llvm/include/llvm/CodeGen/BasicTTIImpl.h (+4-3) 
- (modified) llvm/include/llvm/CodeGen/LiveIntervals.h (+2-5) 
- (modified) llvm/include/llvm/CodeGen/MIR2Vec.h (+1-6) 
- (modified) llvm/include/llvm/CodeGen/MachineBlockHashInfo.h (+3) 
- (modified) llvm/include/llvm/CodeGen/MachinePipeliner.h (+3-25) 
- (modified) llvm/include/llvm/CodeGen/MachineScheduler.h (+4-2) 
- (modified) llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (+2-4) 
- (modified) llvm/lib/CodeGen/BasicTargetTransformInfo.cpp (+10-6) 
- (modified) llvm/lib/CodeGen/LiveIntervals.cpp (+7-3) 
- (modified) llvm/lib/CodeGen/MIR2Vec.cpp (+12-5) 
- (modified) llvm/lib/CodeGen/MachineBlockHashInfo.cpp (+9) 
- (modified) llvm/lib/CodeGen/MachinePipeliner.cpp (+36-5) 
- (modified) llvm/lib/CodeGen/MachineScheduler.cpp (+5-2) 
- (modified) llvm/lib/CodeGen/RegAllocScore.cpp (+10-12) 
- (modified) llvm/lib/CodeGen/TargetPassConfig.cpp (+2-7) 
- (modified) llvm/lib/CodeGen/VLIWMachineScheduler.cpp (+2-2) 
- (modified) llvm/lib/Target/AMDGPU/AMDGPUCoExecSchedStrategy.cpp (+2-2) 
- (modified) llvm/lib/Target/AMDGPU/GCNSchedStrategy.cpp (+2-2) 
- (modified) llvm/unittests/CodeGen/MIR2VecTest.cpp (+18-14) 
- (modified) llvm/unittests/CodeGen/RegAllocScoreTest.cpp (+4-9) 


``````````diff
diff --git a/llvm/include/llvm/CodeGen/BasicTTIImpl.h b/llvm/include/llvm/CodeGen/BasicTTIImpl.h
index 742251de3c242..0d9b361e95ad5 100644
--- a/llvm/include/llvm/CodeGen/BasicTTIImpl.h
+++ b/llvm/include/llvm/CodeGen/BasicTTIImpl.h
@@ -68,7 +68,8 @@ class ScalarEvolution;
 class SCEV;
 class TargetMachine;
 
-extern LLVM_ABI cl::opt<unsigned> PartialUnrollingThreshold;
+/// Returns -partial-unrolling-threshold if specified.
+LLVM_ABI std::optional<unsigned> getPartialUnrollingThreshold();
 
 /// Base class which can be used to help build a TTI implementation.
 ///
@@ -763,8 +764,8 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
 
     unsigned MaxOps;
     const TargetSubtargetInfo *ST = getST();
-    if (PartialUnrollingThreshold.getNumOccurrences() > 0)
-      MaxOps = PartialUnrollingThreshold;
+    if (std::optional<unsigned> Threshold = getPartialUnrollingThreshold())
+      MaxOps = *Threshold;
     else if (ST->getSchedModel().LoopMicroOpBufferSize > 0)
       MaxOps = ST->getSchedModel().LoopMicroOpBufferSize;
     else
diff --git a/llvm/include/llvm/CodeGen/LiveIntervals.h b/llvm/include/llvm/CodeGen/LiveIntervals.h
index acb6faf13e791..966c38692d004 100644
--- a/llvm/include/llvm/CodeGen/LiveIntervals.h
+++ b/llvm/include/llvm/CodeGen/LiveIntervals.h
@@ -39,8 +39,6 @@
 
 namespace llvm {
 
-LLVM_ABI extern cl::opt<bool> UseSegmentSetForPhysRegs;
-
 class BitVector;
 class MachineBlockFrequencyInfo;
 class MachineDominatorTree;
@@ -439,9 +437,7 @@ class LiveIntervals {
     LiveRange *LR = RegUnitRanges[static_cast<unsigned>(Unit)];
     if (!LR) {
       // Compute missing ranges on demand.
-      // Use segment set to speed-up initial computation of the live range.
-      RegUnitRanges[static_cast<unsigned>(Unit)] = LR =
-          new LiveRange(UseSegmentSetForPhysRegs);
+      RegUnitRanges[static_cast<unsigned>(Unit)] = LR = createRegUnitRange();
       computeRegUnitRange(*LR, Unit);
     }
     return *LR;
@@ -520,6 +516,7 @@ class LiveIntervals {
                          SmallVectorImpl<MachineInstr *> *dead);
 
   LLVM_ABI static LiveInterval *createInterval(Register Reg);
+  LLVM_ABI static LiveRange *createRegUnitRange();
 
   void printInstrs(raw_ostream &O) const;
   void dumpInstrs() const;
diff --git a/llvm/include/llvm/CodeGen/MIR2Vec.h b/llvm/include/llvm/CodeGen/MIR2Vec.h
index 7d936c6d3c8f5..815836ae957da 100644
--- a/llvm/include/llvm/CodeGen/MIR2Vec.h
+++ b/llvm/include/llvm/CodeGen/MIR2Vec.h
@@ -75,7 +75,6 @@ class MIREmbedder;
 class SymbolicMIREmbedder;
 
 LLVM_ABI extern llvm::cl::OptionCategory MIR2VecCategory;
-LLVM_ABI extern cl::opt<float> OpcWeight, CommonOperandWeight, RegOperandWeight;
 
 using Embedding = ir2vec::Embedding;
 using MachineInstEmbeddingsMap = DenseMap<const MachineInstr *, Embedding>;
@@ -307,11 +306,7 @@ class MIREmbedder {
   /// Weight for opcode embeddings
   const float OpcWeight, CommonOperandWeight, RegOperandWeight;
 
-  MIREmbedder(const MachineFunction &MF, const MIRVocabulary &Vocab)
-      : MF(MF), Vocab(Vocab), Dimension(Vocab.getDimension()),
-        OpcWeight(mir2vec::OpcWeight),
-        CommonOperandWeight(mir2vec::CommonOperandWeight),
-        RegOperandWeight(mir2vec::RegOperandWeight) {}
+  LLVM_ABI MIREmbedder(const MachineFunction &MF, const MIRVocabulary &Vocab);
 
   /// Function to compute embeddings.
   LLVM_ABI Embedding computeEmbeddings() const;
diff --git a/llvm/include/llvm/CodeGen/MachineBlockHashInfo.h b/llvm/include/llvm/CodeGen/MachineBlockHashInfo.h
index c7e7054361701..2e4c839060ca5 100644
--- a/llvm/include/llvm/CodeGen/MachineBlockHashInfo.h
+++ b/llvm/include/llvm/CodeGen/MachineBlockHashInfo.h
@@ -18,6 +18,9 @@
 
 namespace llvm {
 
+/// Returns whether -emit-bb-hash is set.
+LLVM_ABI bool shouldEmitBBHash();
+
 /// An object wrapping several components of a basic block hash. The combined
 /// (blended) hash is represented and stored as one uint64_t, while individual
 /// components are of smaller size (e.g., uint16_t or uint8_t).
diff --git a/llvm/include/llvm/CodeGen/MachinePipeliner.h b/llvm/include/llvm/CodeGen/MachinePipeliner.h
index cfc69bb1be018..6c72d98723ef3 100644
--- a/llvm/include/llvm/CodeGen/MachinePipeliner.h
+++ b/llvm/include/llvm/CodeGen/MachinePipeliner.h
@@ -62,9 +62,6 @@ class LiveIntervals;
 class NodeSet;
 class SMSchedule;
 
-extern LLVM_ABI cl::opt<bool> SwpEnableCopyToPhi;
-extern LLVM_ABI cl::opt<int> SwpForceIssueWidth;
-
 /// Software pipelining policy for a loop, which a target can customize by
 /// implementing TargetSubtargetInfo::overridePipelinerPolicy.
 struct MachinePipelinerPolicy {
@@ -367,16 +364,7 @@ class LLVM_ABI SwingSchedulerDAG : public ScheduleDAGInstrs {
                     MachineOptimizationRemarkEmitter *ORE, MachineLoop &L,
                     LiveIntervals &lis, const RegisterClassInfo &rci,
                     unsigned II, TargetInstrInfo::PipelinerLoopInfo *PLI,
-                    AliasAnalysis *AA)
-      : ScheduleDAGInstrs(MF, MLI, false), ORE(ORE), Loop(L), LIS(lis),
-        RegClassInfo(rci), II_setByPragma(II), LoopPipelinerInfo(PLI),
-        Topo(SUnits, &ExitSU), AA(AA), BAA(*AA) {
-    initPolicy();
-    MF.getSubtarget().getSMSMutations(Mutations);
-    if (SwpEnableCopyToPhi)
-      Mutations.push_back(std::make_unique<CopyToPhiMutation>());
-    BAA.enableCrossIterationMode();
-  }
+                    AliasAnalysis *AA);
 
   void schedule() override;
   void finishBlock() override;
@@ -678,18 +666,8 @@ class ResourceManager {
 #endif
 
 public:
-  ResourceManager(const TargetSubtargetInfo *ST, ScheduleDAGInstrs *DAG)
-      : STI(ST), SM(ST->getSchedModel()), ST(ST), TII(ST->getInstrInfo()),
-        DAG(DAG), UseDFA(ST->useDFAforSMS()),
-        ProcResourceMasks(SM.getNumProcResourceKinds(), 0),
-        IssueWidth(SM.IssueWidth) {
-    initProcResourceVectors(SM, ProcResourceMasks);
-    if (IssueWidth <= 0)
-      // If IssueWidth is not specified, set a sufficiently large value
-      IssueWidth = 100;
-    if (SwpForceIssueWidth > 0)
-      IssueWidth = SwpForceIssueWidth;
-  }
+  LLVM_ABI ResourceManager(const TargetSubtargetInfo *ST,
+                           ScheduleDAGInstrs *DAG);
 
   LLVM_ABI void initProcResourceVectors(const MCSchedModel &SM,
                                         SmallVectorImpl<uint64_t> &Masks);
diff --git a/llvm/include/llvm/CodeGen/MachineScheduler.h b/llvm/include/llvm/CodeGen/MachineScheduler.h
index 5280a2376c34a..a9eac924aa7f3 100644
--- a/llvm/include/llvm/CodeGen/MachineScheduler.h
+++ b/llvm/include/llvm/CodeGen/MachineScheduler.h
@@ -117,8 +117,10 @@ enum Direction {
 };
 } // namespace MISched
 
-LLVM_ABI extern cl::opt<MISched::Direction> PreRADirection;
-LLVM_ABI extern cl::opt<bool> VerifyScheduling;
+/// Returns -misched-prera-direction.
+LLVM_ABI MISched::Direction getPreRADirection();
+/// Returns whether -verify-misched is set.
+LLVM_ABI bool shouldVerifyScheduling();
 
 #ifndef NDEBUG
 extern cl::opt<bool> ViewMISchedDAGs;
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index ae8d8fbe84c03..37de384df866f 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -195,8 +195,6 @@ static cl::opt<std::string>
                    cl::desc("Output filename for stack usage information"),
                    cl::value_desc("filename"), cl::Hidden);
 
-extern cl::opt<bool> EmitBBHash;
-
 STATISTIC(EmittedInsts, "Number of machine instrs printed");
 
 char AsmPrinter::ID = 0;
@@ -512,7 +510,7 @@ void AsmPrinter::getAnalysisUsage(AnalysisUsage &AU) const {
   AU.addRequired<GCModuleInfo>();
   AU.addRequired<LazyMachineBlockFrequencyInfoPass>();
   AU.addRequired<MachineBranchProbabilityInfoWrapperPass>();
-  if (EmitBBHash)
+  if (shouldEmitBBHash())
     AU.addRequired<MachineBlockHashInfo>();
   AU.addUsedIfAvailable<BasicBlockSectionsProfileReaderWrapperPass>();
 }
@@ -1516,7 +1514,7 @@ getBBAddrMapFeature(const MachineFunction &MF, int NumMBBSectionRanges,
           MF.hasBBSections() && NumMBBSectionRanges > 1,
           // Use static_cast to avoid breakage of tests on windows.
           static_cast<bool>(BBAddrMapSkipEmitBBEntries), HasCalls,
-          static_cast<bool>(EmitBBHash), PostLinkCfgEnabled};
+          shouldEmitBBHash(), PostLinkCfgEnabled};
 }
 
 void AsmPrinter::emitBBAddrMapSection(const MachineFunction &MF) {
diff --git a/llvm/lib/CodeGen/BasicTargetTransformInfo.cpp b/llvm/lib/CodeGen/BasicTargetTransformInfo.cpp
index 80a4eb86cf9ef..73fb78fe296f8 100644
--- a/llvm/lib/CodeGen/BasicTargetTransformInfo.cpp
+++ b/llvm/lib/CodeGen/BasicTargetTransformInfo.cpp
@@ -22,12 +22,16 @@
 
 using namespace llvm;
 
-// This flag is used by the template base class for BasicTTIImpl, and here to
-// provide a definition.
-cl::opt<unsigned>
-llvm::PartialUnrollingThreshold("partial-unrolling-threshold", cl::init(0),
-                                cl::desc("Threshold for partial unrolling"),
-                                cl::Hidden);
+static cl::opt<unsigned>
+    PartialUnrollingThreshold("partial-unrolling-threshold", cl::init(0),
+                              cl::desc("Threshold for partial unrolling"),
+                              cl::Hidden);
+
+std::optional<unsigned> llvm::getPartialUnrollingThreshold() {
+  if (PartialUnrollingThreshold.getNumOccurrences())
+    return PartialUnrollingThreshold;
+  return std::nullopt;
+}
 
 BasicTTIImpl::BasicTTIImpl(const TargetMachine *TM, const Function &F)
     : BaseT(TM, F.getDataLayout()), ST(TM->getSubtargetImpl(F)),
diff --git a/llvm/lib/CodeGen/LiveIntervals.cpp b/llvm/lib/CodeGen/LiveIntervals.cpp
index 0e4435ddc2c0d..b0c18d5d5fe5d 100644
--- a/llvm/lib/CodeGen/LiveIntervals.cpp
+++ b/llvm/lib/CodeGen/LiveIntervals.cpp
@@ -104,7 +104,7 @@ static cl::opt<bool> EnablePrecomputePhysRegs(
 static bool EnablePrecomputePhysRegs = false;
 #endif // NDEBUG
 
-cl::opt<bool> llvm::UseSegmentSetForPhysRegs(
+static cl::opt<bool> UseSegmentSetForPhysRegs(
     "use-segment-set-for-physregs", cl::Hidden, cl::init(true),
     cl::desc(
         "Use segment set for the computation of the live ranges of physregs."));
@@ -224,6 +224,11 @@ LiveInterval *LiveIntervals::createInterval(Register reg) {
   return new LiveInterval(reg, Weight);
 }
 
+LiveRange *LiveIntervals::createRegUnitRange() {
+  // Use segment set to speed-up initial computation of the live range.
+  return new LiveRange(UseSegmentSetForPhysRegs);
+}
+
 /// Compute the live interval of a virtual register, based on defs and uses.
 bool LiveIntervals::computeVirtRegInterval(LiveInterval &LI) {
   assert(LICalc && "LICalc not initialized.");
@@ -411,9 +416,8 @@ void LiveIntervals::computeLiveInRegUnits() {
       for (MCRegUnit Unit : TRI->regunits(LI.PhysReg)) {
         LiveRange *LR = RegUnitRanges[static_cast<unsigned>(Unit)];
         if (!LR) {
-          // Use segment set to speed-up initial computation of the live range.
           LR = RegUnitRanges[static_cast<unsigned>(Unit)] =
-              new LiveRange(UseSegmentSetForPhysRegs);
+              createRegUnitRange();
           NewRanges.push_back(Unit);
         }
         VNInfo *VNI = LR->createDeadDef(Begin, getVNInfoAllocator());
diff --git a/llvm/lib/CodeGen/MIR2Vec.cpp b/llvm/lib/CodeGen/MIR2Vec.cpp
index 30f30ec57020d..945acdc07584b 100644
--- a/llvm/lib/CodeGen/MIR2Vec.cpp
+++ b/llvm/lib/CodeGen/MIR2Vec.cpp
@@ -41,14 +41,15 @@ static cl::opt<std::string>
     VocabFile("mir2vec-vocab-path",
               cl::desc("Path to the vocabulary file for MIR2Vec"), cl::init(""),
               cl::cat(MIR2VecCategory));
-cl::opt<float> OpcWeight("mir2vec-opc-weight", cl::init(1.0),
-                         cl::desc("Weight for machine opcode embeddings"),
-                         cl::cat(MIR2VecCategory));
-cl::opt<float>
+static cl::opt<float>
+    OpcWeight("mir2vec-opc-weight", cl::init(1.0),
+              cl::desc("Weight for machine opcode embeddings"),
+              cl::cat(MIR2VecCategory));
+static cl::opt<float>
     CommonOperandWeight("mir2vec-common-operand-weight", cl::init(1.0),
                         cl::desc("Weight for common operand embeddings"),
                         cl::cat(MIR2VecCategory));
-cl::opt<float>
+static cl::opt<float>
     RegOperandWeight("mir2vec-reg-operand-weight", cl::init(1.0),
                      cl::desc("Weight for register operand embeddings"),
                      cl::cat(MIR2VecCategory));
@@ -549,6 +550,12 @@ std::unique_ptr<MIREmbedder> MIREmbedder::create(MIR2VecKind Mode,
   return nullptr;
 }
 
+MIREmbedder::MIREmbedder(const MachineFunction &MF, const MIRVocabulary &Vocab)
+    : MF(MF), Vocab(Vocab), Dimension(Vocab.getDimension()),
+      OpcWeight(mir2vec::OpcWeight),
+      CommonOperandWeight(mir2vec::CommonOperandWeight),
+      RegOperandWeight(mir2vec::RegOperandWeight) {}
+
 Embedding MIREmbedder::computeEmbeddings(const MachineBasicBlock &MBB) const {
   Embedding MBBVector(Dimension, 0);
 
diff --git a/llvm/lib/CodeGen/MachineBlockHashInfo.cpp b/llvm/lib/CodeGen/MachineBlockHashInfo.cpp
index cf284ada5b710..f7d1729629bf3 100644
--- a/llvm/lib/CodeGen/MachineBlockHashInfo.cpp
+++ b/llvm/lib/CodeGen/MachineBlockHashInfo.cpp
@@ -15,11 +15,20 @@
 #include "llvm/CodeGen/MachineStableHash.h"
 #include "llvm/CodeGen/Passes.h"
 #include "llvm/InitializePasses.h"
+#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Target/TargetMachine.h"
 
 using namespace llvm;
 
+static cl::opt<bool> EmitBBHash(
+    "emit-bb-hash",
+    cl::desc(
+        "Emit the hash of basic block in the SHT_LLVM_BB_ADDR_MAP section."),
+    cl::init(false));
+
+bool llvm::shouldEmitBBHash() { return EmitBBHash; }
+
 // Frozen mixer; the block hashes computed below are serialized into BB
 // section profile data, so this function's exact output is part of the
 // on-disk format. Do not change without versioning that format.
diff --git a/llvm/lib/CodeGen/MachinePipeliner.cpp b/llvm/lib/CodeGen/MachinePipeliner.cpp
index 8bf7b804ddc75..3d7c1f1f8a9e5 100644
--- a/llvm/lib/CodeGen/MachinePipeliner.cpp
+++ b/llvm/lib/CodeGen/MachinePipeliner.cpp
@@ -203,14 +203,14 @@ static cl::opt<unsigned> SwpMaxNumStores(
     cl::init(200));
 
 // A command line option to enable the CopyToPhi DAG mutation.
-cl::opt<bool>
-    llvm::SwpEnableCopyToPhi("pipeliner-enable-copytophi", cl::ReallyHidden,
-                             cl::init(true),
-                             cl::desc("Enable CopyToPhi DAG Mutation"));
+static cl::opt<bool>
+    SwpEnableCopyToPhi("pipeliner-enable-copytophi", cl::ReallyHidden,
+                       cl::init(true),
+                       cl::desc("Enable CopyToPhi DAG Mutation"));
 
 /// A command line argument to force pipeliner to use specified issue
 /// width.
-cl::opt<int> llvm::SwpForceIssueWidth(
+static cl::opt<int> SwpForceIssueWidth(
     "pipeliner-force-issue-width",
     cl::desc("Force pipeliner to use specified issue width."), cl::Hidden,
     cl::init(-1));
@@ -867,6 +867,23 @@ void SwingSchedulerDAG::setMAX_II() {
     MAX_II = MII + SwpIISearchRange;
 }
 
+SwingSchedulerDAG::SwingSchedulerDAG(MachineFunction &MF,
+                                     const MachineLoopInfo *MLI,
+                                     MachineOptimizationRemarkEmitter *ORE,
+                                     MachineLoop &L, LiveIntervals &lis,
+                                     const RegisterClassInfo &rci, unsigned II,
+                                     TargetInstrInfo::PipelinerLoopInfo *PLI,
+                                     AliasAnalysis *AA)
+    : ScheduleDAGInstrs(MF, MLI, false), ORE(ORE), Loop(L), LIS(lis),
+      RegClassInfo(rci), II_setByPragma(II), LoopPipelinerInfo(PLI),
+      Topo(SUnits, &ExitSU), AA(AA), BAA(*AA) {
+  initPolicy();
+  MF.getSubtarget().getSMSMutations(Mutations);
+  if (SwpEnableCopyToPhi)
+    Mutations.push_back(std::make_unique<CopyToPhiMutation>());
+  BAA.enableCrossIterationMode();
+}
+
 /// We override the schedule function in ScheduleDAGInstrs to implement the
 /// scheduling part of the Swing Modulo Scheduling algorithm.
 void SwingSchedulerDAG::schedule() {
@@ -3997,6 +4014,20 @@ void ResourceManager::dumpMRT() const {
 }
 #endif
 
+ResourceManager::ResourceManager(const TargetSubtargetInfo *ST,
+                                 ScheduleDAGInstrs *DAG)
+    : STI(ST), SM(ST->getSchedModel()), ST(ST), TII(ST->getInstrInfo()),
+      DAG(DAG), UseDFA(ST->useDFAforSMS()),
+      ProcResourceMasks(SM.getNumProcResourceKinds(), 0),
+      IssueWidth(SM.IssueWidth) {
+  initProcResourceVectors(SM, ProcResourceMasks);
+  if (IssueWidth <= 0)
+    // If IssueWidth is not specified, set a sufficiently large value
+    IssueWidth = 100;
+  if (SwpForceIssueWidth > 0)
+    IssueWidth = SwpForceIssueWidth;
+}
+
 void ResourceManager::initProcResourceVectors(
     const MCSchedModel &SM, SmallVectorImpl<uint64_t> &Masks) {
   unsigned ProcResourceID = 0;
diff --git a/llvm/lib/CodeGen/MachineScheduler.cpp b/llvm/lib/CodeGen/MachineScheduler.cpp
index facf741f12400..5272931d6c5f3 100644
--- a/llvm/lib/CodeGen/MachineScheduler.cpp
+++ b/llvm/lib/CodeGen/MachineScheduler.cpp
@@ -176,7 +176,7 @@ STATISTIC(NumNodeOrderPostRA,
 STATISTIC(NumFirstValidPostRA,
           "Number of scheduling units chosen for FirstValid heuristic post-RA");
 
-cl::opt<MISched::Direction> llvm::PreRADirection(
+static cl::opt<MISched::Direction> PreRADirection(
     "misched-prera-direction", cl::Hidden,
     cl::desc("Pre reg-alloc list scheduling direction"),
     cl::init(MISched::Unspecified),
@@ -204,10 +204,13 @@ static cl::opt<bool>
     DumpCriticalPathLength("misched-dcpl", cl::Hidden,
                            cl::desc("Print critical path length to stdout"));
 
-cl::opt<bool> llvm::VerifyScheduling(
+static cl::opt<bool> VerifyScheduling(
     "verify-misched", cl::Hidden,
     cl::desc("Verify machine instrs before and after machine scheduling"));
 
+MISched::Direction llvm::getPreRADirection() { return PreRADirection; }
+bool llvm::shouldVerifyScheduling() { return VerifyScheduling; }
+
 #ifndef NDEBUG
 cl::opt<bool> llvm::ViewMISchedDAGs(
     "view-misched-dags", cl::Hidden,
diff --git a/llvm/lib/CodeGen/RegAllocScore.cpp b/llvm/lib/CodeGen/RegAllocScore.cpp
index 280946bb0d0b3..114decec7e5f0 100644
--- a/llvm/lib/CodeGen/RegAllocScore.cpp
+++ b/llvm/lib/CodeGen/RegAllocScore.cpp
@@ -24,18 +24,16 @@
 
 using namespace llvm;
 
-namespace llvm {
-LLVM_ABI cl::opt<double> CopyWeight("regalloc-copy-weight", cl::init(0.2),
-                                    cl::Hidden);
-LLVM_ABI cl::opt<double> LoadWeight("regalloc-load-weight", cl::init(4.0),
-                                    cl::Hidden);
-LLVM_ABI cl::opt<double> StoreWeight("regalloc-store-weight", cl::init(1.0),
-                                     cl::Hidden);
-LLVM_ABI cl::opt<double> CheapRematWeight("regalloc-cheap-remat-weight",
-                                          cl::init(0.2), cl::Hidden);
-LLVM_ABI cl::opt<double> ExpensiveRematWeight("regalloc-expensive-remat-weight",
-                                              cl::init(1.0), cl::Hidden);
-} // end namespace llvm
+static cl::opt<double> CopyWeight("regalloc-copy-weight", cl::init(0.2),
+                                  cl::Hidden);
+static cl::opt<double> LoadWeight("regalloc-load-weight", cl::init(4.0),
+                                  cl::Hidden);
+static cl::opt<double> StoreWeight("regalloc-store-weight", cl::init(1.0),
+                                   cl::Hidden);
+static cl::opt<double> CheapRematWeight("regalloc-cheap-remat-weight",
+                                        cl::init(0.2), cl::Hidden);
+static cl::opt<double> ExpensiveRematWeight("regalloc-expensive-remat-weight",
+                                            cl::init(1.0), cl::Hidden);
 
 #define DEBUG_TYPE "regalloc-score"
 
diff --git a/llvm/lib/CodeGen/TargetPassConfig.cpp b/llvm/lib/CodeGen/TargetPassConfig.cpp
index d7bb131c97256..9683d988e8084 100644
--- a/llvm/lib/CodeGen/TargetPassConfig.cpp
+++ b/llvm/lib/CodeGen/TargetPassConfig.cpp
@@ -23,6 +23,7 @@
 #include "llvm/CodeGen/BasicBlockSectionsProfileReader.h"
 #include "llvm/CodeGen/CSEConfigBase.h"
 #include "llvm/CodeGen/CodeGenTargetMachineImpl.h"
+#include "llvm/CodeGen/MachineBlockHashInfo.h"
 #include "llvm/CodeGen/MachineFunctionPass.h"
 #include "llvm/CodeGen/M...
[truncated]

``````````

</details>


https://github.com/llvm/llvm-project/pull/228728


More information about the llvm-commits mailing list