[llvm] [InstCombine] Declare command line options in TableGen (PR #227948)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 30 23:10:08 PDT 2026


https://github.com/MaskRay updated https://github.com/llvm/llvm-project/pull/227948

>From eb3b08b5e1ab13d58a47cb6cc5716757b7393dc9 Mon Sep 17 00:00:00 2001
From: Fangrui Song <i at maskray.me>
Date: Wed, 30 Sep 2026 20:35:31 -0700
Subject: [PATCH 1/2] [InstCombine] Declare command line options in TableGen

Follow-up to the framework #226087:
Move the cl::opts into InstCombineCLOptions.td. The new
`OptionsStruct<prefix = "instcombine-">` strips the shared prefix from
member names: -instcombine-max-num-phis sets CLOpts.max_num_phis.
CLOpts also replaces InstCombiner::MaxArraySizeForCombine.

Options that were not cl::Hidden are now listed by -help-hidden only,
and -instcombine-lower-dbg-declare is now a bool.

Aided by Opus 5.5
---
 llvm/docs/CommandLine.md                      |  1 +
 llvm/include/llvm/Option/LibraryOptions.td    |  6 ++-
 .../Transforms/InstCombine/InstCombiner.h     |  3 --
 .../lib/Transforms/InstCombine/CMakeLists.txt |  7 +++
 .../InstCombine/InstCombineCLOptions.cpp      | 16 +++++++
 .../InstCombine/InstCombineCLOptions.h        | 15 ++++++
 .../InstCombine/InstCombineCLOptions.td       | 45 ++++++++++++++++++
 .../InstCombine/InstCombineCalls.cpp          |  9 +---
 .../InstCombine/InstCombineCompares.cpp       |  2 +-
 .../InstCombine/InstCombineInternal.h         | 17 ++++---
 .../InstCombineLoadStoreAlloca.cpp            | 29 +++++-------
 .../InstCombine/InstCombineNegator.cpp        | 22 +++------
 .../Transforms/InstCombine/InstCombinePHI.cpp |  7 +--
 .../InstCombineSimplifyDemanded.cpp           | 18 ++------
 .../InstCombine/InstructionCombining.cpp      | 46 ++++---------------
 llvm/unittests/Option/LibraryOptionsTest.cpp  | 34 +++++++-------
 llvm/unittests/Option/LibraryOpts.td          |  2 +-
 llvm/utils/TableGen/OptionParserEmitter.cpp   | 19 +++++---
 .../llvm/lib/Transforms/InstCombine/BUILD.gn  | 10 ++++
 .../llvm-project-overlay/llvm/BUILD.bazel     | 13 ++++++
 20 files changed, 186 insertions(+), 135 deletions(-)
 create mode 100644 llvm/lib/Transforms/InstCombine/InstCombineCLOptions.cpp
 create mode 100644 llvm/lib/Transforms/InstCombine/InstCombineCLOptions.h
 create mode 100644 llvm/lib/Transforms/InstCombine/InstCombineCLOptions.td

diff --git a/llvm/docs/CommandLine.md b/llvm/docs/CommandLine.md
index 13ab4b48eb9b5..844339d106021 100644
--- a/llvm/docs/CommandLine.md
+++ b/llvm/docs/CommandLine.md
@@ -1582,6 +1582,7 @@ defm : ValueField<"foo-path", "StringRef", "\"-\"", "The input path">;
 
 The struct is in namespace `llvm` unless the def names another, as in `OptionsStruct<"mlir">`.
 A member is named after its option, `enable_foo` for `-enable-foo`; a named `defm` such as `defm threshold` names it `threshold`.
+`OptionsStruct<prefix = "foo-">` drops that prefix from member names, so `-foo-path` sets `path`.
 
 The `BoolField` is set by `-enable-foo` or `-enable-foo=true|false|1|0`.
 A `ValueField`, of an integer type, `double`, or `StringRef`, is set by `-foo-threshold=8` or `-foo-threshold 8`.
diff --git a/llvm/include/llvm/Option/LibraryOptions.td b/llvm/include/llvm/Option/LibraryOptions.td
index 5f600a0a8e0ed..52af2a49c13d1 100644
--- a/llvm/include/llvm/Option/LibraryOptions.td
+++ b/llvm/include/llvm/Option/LibraryOptions.td
@@ -16,7 +16,11 @@
 
 include "llvm/Option/OptParser.td"
 
-class OptionsStruct<string namespace = "llvm"> { string Namespace = namespace; }
+// A row whose spelling starts with prefix names its member without it.
+class OptionsStruct<string namespace = "llvm", string prefix = ""> {
+  string Namespace = namespace;
+  string MemberPrefix = prefix;
+}
 
 // The member a row sets, the member's type and default value, and the value a
 // Flag assigns. Other kinds parse their argument.
diff --git a/llvm/include/llvm/Transforms/InstCombine/InstCombiner.h b/llvm/include/llvm/Transforms/InstCombine/InstCombiner.h
index 636b9a6278d87..ce9d42c58e3f2 100644
--- a/llvm/include/llvm/Transforms/InstCombine/InstCombiner.h
+++ b/llvm/include/llvm/Transforms/InstCombine/InstCombiner.h
@@ -67,9 +67,6 @@ class LLVM_LIBRARY_VISIBILITY InstCombiner {
   TargetTransformInfo &TTIForTargetIntrinsicsOnly;
 
 public:
-  /// Maximum size of array considered when transforming.
-  uint64_t MaxArraySizeForCombine = 0;
-
   /// An IRBuilder that automatically inserts new instructions into the
   /// worklist.
   using BuilderTy = IRBuilder<TargetFolder, IRBuilderInstCombineInserter>;
diff --git a/llvm/lib/Transforms/InstCombine/CMakeLists.txt b/llvm/lib/Transforms/InstCombine/CMakeLists.txt
index 6ab5e6da21cf1..399e15320a39a 100644
--- a/llvm/lib/Transforms/InstCombine/CMakeLists.txt
+++ b/llvm/lib/Transforms/InstCombine/CMakeLists.txt
@@ -1,3 +1,7 @@
+set(LLVM_TARGET_DEFINITIONS InstCombineCLOptions.td)
+tablegen(LLVM InstCombineCLOptions.inc -gen-opt-parser-defs)
+add_public_tablegen_target(InstCombineCLOptionsTableGen)
+
 add_llvm_component_library(LLVMInstCombine
   InstructionCombining.cpp
   InstCombineAddSub.cpp
@@ -5,6 +9,7 @@ add_llvm_component_library(LLVMInstCombine
   InstCombineAndOrXor.cpp
   InstCombineCalls.cpp
   InstCombineCasts.cpp
+  InstCombineCLOptions.cpp
   InstCombineCompares.cpp
   InstCombineLoadStoreAlloca.cpp
   InstCombineMulDivRem.cpp
@@ -20,11 +25,13 @@ add_llvm_component_library(LLVMInstCombine
   ${LLVM_MAIN_INCLUDE_DIR}/llvm/Transforms/InstCombine
 
   DEPENDS
+  InstCombineCLOptionsTableGen
   intrinsics_gen
 
   LINK_COMPONENTS
   Analysis
   Core
+  Option
   Support
   TransformUtils
   )
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCLOptions.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCLOptions.cpp
new file mode 100644
index 0000000000000..406394ccc2d61
--- /dev/null
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCLOptions.cpp
@@ -0,0 +1,16 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "InstCombineCLOptions.h"
+#include "llvm/Option/LibraryOptions.h"
+
+#define OPTIONS_STRUCT_DEFS
+#include "InstCombineCLOptions.inc"
+
+static llvm::opt::RegisterLibraryOptions<llvm::InstCombineCLOptions>
+    Registration;
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCLOptions.h b/llvm/lib/Transforms/InstCombine/InstCombineCLOptions.h
new file mode 100644
index 0000000000000..bd037f4eb522a
--- /dev/null
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCLOptions.h
@@ -0,0 +1,15 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIB_TRANSFORMS_INSTCOMBINE_INSTCOMBINECLOPTIONS_H
+#define LLVM_LIB_TRANSFORMS_INSTCOMBINE_INSTCOMBINECLOPTIONS_H
+
+#define OPTIONS_STRUCT_DECL
+#include "InstCombineCLOptions.inc"
+
+#endif // LLVM_LIB_TRANSFORMS_INSTCOMBINE_INSTCOMBINECLOPTIONS_H
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCLOptions.td b/llvm/lib/Transforms/InstCombine/InstCombineCLOptions.td
new file mode 100644
index 0000000000000..ef5618c9e43f8
--- /dev/null
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCLOptions.td
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+include "llvm/Option/LibraryOptions.td"
+
+def InstCombineCLOptions : OptionsStruct<prefix = "instcombine-">;
+
+defm : BoolField<"instcombine-code-sinking", "1",
+  "Enable code sinking">;
+defm : ValueField<"instcombine-guard-widening-window", "unsigned", "3",
+  "How wide an instruction window to bypass looking for another guard">;
+// FIXME: Remove this flag when it is no longer necessary to convert
+// llvm.dbg.declare to avoid inaccurate debug info. Setting this to false
+// increases variable availability at the cost of accuracy. Variables that
+// cannot be promoted by mem2reg or SROA will be described as living in memory
+// for their entire lifetime. However, passes like DSE and instcombine can
+// delete stores to the alloca, leading to misleading and inaccurate debug
+// information. This flag can be removed when those passes are fixed.
+defm : BoolField<"instcombine-lower-dbg-declare", "1",
+  "">;
+defm : ValueField<"instcombine-max-allocsite-removable-users", "unsigned", "2048",
+  "Maximum number of users to visit in alloc-site removability analysis">;
+defm : ValueField<"instcombine-max-copied-from-constant-users", "unsigned", "300",
+  "Maximum users to visit in copy from constant transform">;
+defm : ValueField<"instcombine-max-num-phis", "unsigned", "512",
+  "Maximum number phis to handle in intptr/ptrint folding">;
+defm : ValueField<"instcombine-max-sink-users", "unsigned", "32",
+  "Maximum number of undroppable users for instruction sinking">;
+defm : ValueField<"instcombine-maxarray-size", "unsigned", "1024",
+  "Maximum array size considered when doing a combine">;
+defm : BoolField<"instcombine-negator-enabled", "1",
+  "Should we attempt to sink negations?">;
+// As a default, let's assume that we want to be aggressive, and attempt to
+// traverse with no limits in attempt to sink negation.
+defm : ValueField<"instcombine-negator-max-depth", "unsigned", "~0U",
+  "What is the maximal lookup depth when trying to check for viability of negation sinking">;
+defm : ValueField<"instcombine-simplify-vector-elts-depth", "unsigned", "10",
+  "Depth limit when simplifying vector instructions and their operands">;
+defm : BoolField<"instcombine-verify-known-bits", "0",
+  "Verify that computeKnownBits() and SimplifyDemandedBits() are consistent">;
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
index 7003d23262eee..fa4df5bfd1cea 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -61,7 +61,6 @@
 #include "llvm/IR/ValueHandle.h"
 #include "llvm/Support/AtomicOrdering.h"
 #include "llvm/Support/Casting.h"
-#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/ErrorHandling.h"
@@ -89,12 +88,6 @@ using namespace PatternMatch;
 
 STATISTIC(NumSimplified, "Number of library calls simplified");
 
-static cl::opt<unsigned> GuardWideningWindow(
-    "instcombine-guard-widening-window",
-    cl::init(3),
-    cl::desc("How wide an instruction window to bypass looking for "
-             "another guard"));
-
 /// Return the specified type promoted as it would be to pass though a va_arg
 /// area.
 static Type *getPromotedType(Type *Ty) {
@@ -4080,7 +4073,7 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
     // fixed window of instructions to handle common cases with conditions
     // computed between guards.
     Instruction *NextInst = II->getNextNode();
-    for (unsigned i = 0; i < GuardWideningWindow; i++) {
+    for (unsigned i = 0; i < CLOpts.guard_widening_window; i++) {
       // Note: Using context-free form to avoid compile time blow up
       if (!isSafeToSpeculativelyExecute(NextInst))
         break;
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
index 854e12a496cc7..9cc0bef2fb06a 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -151,7 +151,7 @@ Instruction *InstCombinerImpl::foldCmpLoadFromIndexedGlobal(
   uint64_t ArrayElementCount =
       divideCeil((GlobalSize.getFixedValue() - ConstOffset.getZExtValue()),
                  Stride.getZExtValue());
-  if (ArrayElementCount > MaxArraySizeForCombine)
+  if (ArrayElementCount > CLOpts.maxarray_size)
     return nullptr;
 
   enum { Overdefined = -3, Undefined = -2 };
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineInternal.h b/llvm/lib/Transforms/InstCombine/InstCombineInternal.h
index 99c0eaa40c9b1..f4ef3d7ed99fc 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineInternal.h
+++ b/llvm/lib/Transforms/InstCombine/InstCombineInternal.h
@@ -15,6 +15,7 @@
 #ifndef LLVM_LIB_TRANSFORMS_INSTCOMBINE_INSTCOMBINEINTERNAL_H
 #define LLVM_LIB_TRANSFORMS_INSTCOMBINE_INSTCOMBINEINTERNAL_H
 
+#include "InstCombineCLOptions.h"
 #include "llvm/ADT/PostOrderIterator.h"
 #include "llvm/ADT/Statistic.h"
 #include "llvm/Analysis/InstructionSimplify.h"
@@ -35,10 +36,6 @@
 #define DEBUG_TYPE "instcombine"
 #include "llvm/Transforms/Utils/InstructionWorklist.h"
 
-// As a default, let's assume that we want to be aggressive,
-// and attempt to traverse with no limits in attempt to sink negation.
-static constexpr unsigned NegatorDefaultMaxDepth = ~0U;
-
 // Let's guesstimate that most often we will end up visiting/producing
 // fairly small number of new instructions.
 static constexpr unsigned NegatorMaxNodesSSO = 16;
@@ -77,12 +74,16 @@ class LLVM_LIBRARY_VISIBILITY InstCombinerImpl final
                    OptimizationRemarkEmitter &ORE, BlockFrequencyInfo *BFI,
                    BranchProbabilityInfo *BPI, ProfileSummaryInfo *PSI,
                    const DataLayout &DL,
-                   ReversePostOrderTraversal<BasicBlock *> &RPOT)
+                   ReversePostOrderTraversal<BasicBlock *> &RPOT,
+                   const InstCombineCLOptions &CLOpts)
       : InstCombiner(Worklist, F, AA, AC, TLI, TTI, DT, ORE, BFI, BPI, PSI, DL,
-                     RPOT) {}
+                     RPOT),
+        CLOpts(CLOpts) {}
 
   ~InstCombinerImpl() override = default;
 
+  const InstCombineCLOptions CLOpts;
+
   /// Perform early cleanup and prepare the InstCombine worklist.
   bool prepareWorklist(Function &F);
 
@@ -886,10 +887,12 @@ class Negator final {
 
   const bool IsTrulyNegation;
 
+  const unsigned MaxDepth;
+
   SmallDenseMap<Value *, Value *> NegationsCache;
 
   Negator(LLVMContext &C, const DataLayout &DL, const DominatorTree &DT,
-          bool IsTrulyNegation);
+          bool IsTrulyNegation, unsigned MaxDepth);
 
 #if LLVM_ENABLE_STATS
   unsigned NumValuesVisitedInThisNegator = 0;
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp b/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
index 7328725a59578..527ba917da3cb 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
@@ -30,11 +30,6 @@ using namespace PatternMatch;
 STATISTIC(NumDeadStore, "Number of dead stores eliminated");
 STATISTIC(NumGlobalCopies, "Number of allocas copied from constant global");
 
-static cl::opt<unsigned> MaxCopiedFromConstantUsers(
-    "instcombine-max-copied-from-constant-users", cl::init(300),
-    cl::desc("Maximum users to visit in copy from constant transform"),
-    cl::Hidden);
-
 /// isOnlyCopiedFromConstantMemory - Recursively walk the uses of a (derived)
 /// pointer to an alloca.  Ignore any reads of the pointer, return false if we
 /// see any stores or other unknown uses.  If we see pointer arithmetic, keep
@@ -42,10 +37,9 @@ static cl::opt<unsigned> MaxCopiedFromConstantUsers(
 /// the uses.  If we see a memcpy/memmove that targets an unoffseted pointer to
 /// the alloca, and if the source pointer is a pointer to a constant memory
 /// location, we can optimize this.
-static bool
-isOnlyCopiedFromConstantMemory(AAResults *AA, AllocaInst *V,
-                               MemTransferInst *&TheCopy,
-                               SmallVectorImpl<Instruction *> &ToDelete) {
+static bool isOnlyCopiedFromConstantMemory(
+    AAResults *AA, AllocaInst *V, MemTransferInst *&TheCopy,
+    SmallVectorImpl<Instruction *> &ToDelete, unsigned MaxUsers) {
   // We track lifetime intrinsics as we encounter them.  If we decide to go
   // ahead and replace the value with the memory location, this lets the caller
   // quickly eliminate the markers.
@@ -58,7 +52,7 @@ isOnlyCopiedFromConstantMemory(AAResults *AA, AllocaInst *V,
     ValueAndIsOffset Elem = Worklist.pop_back_val();
     if (!Visited.insert(Elem).second)
       continue;
-    if (Visited.size() > MaxCopiedFromConstantUsers)
+    if (Visited.size() > MaxUsers)
       return false;
 
     const auto [Value, IsOffset] = Elem;
@@ -160,11 +154,11 @@ isOnlyCopiedFromConstantMemory(AAResults *AA, AllocaInst *V,
 /// can replace any uses of the alloca with uses of the memory location
 /// directly.
 static MemTransferInst *
-isOnlyCopiedFromConstantMemory(AAResults *AA,
-                               AllocaInst *AI,
-                               SmallVectorImpl<Instruction *> &ToDelete) {
+isOnlyCopiedFromConstantMemory(AAResults *AA, AllocaInst *AI,
+                               SmallVectorImpl<Instruction *> &ToDelete,
+                               unsigned MaxUsers) {
   MemTransferInst *TheCopy = nullptr;
-  if (isOnlyCopiedFromConstantMemory(AA, AI, TheCopy, ToDelete))
+  if (isOnlyCopiedFromConstantMemory(AA, AI, TheCopy, ToDelete, MaxUsers))
     return TheCopy;
   return nullptr;
 }
@@ -553,7 +547,8 @@ Instruction *InstCombinerImpl::visitAllocaInst(AllocaInst &AI) {
   // constructs like "void foo() { int A[] = {1,2,3,4,5,6,7,8,9...}; }" if 'A'
   // is only subsequently read.
   SmallVector<Instruction *, 4> ToDelete;
-  if (MemTransferInst *Copy = isOnlyCopiedFromConstantMemory(AA, &AI, ToDelete)) {
+  if (MemTransferInst *Copy = isOnlyCopiedFromConstantMemory(
+          AA, &AI, ToDelete, CLOpts.max_copied_from_constant_users)) {
     Value *TheSrc = Copy->getSource();
     Align AllocaAlign = AI.getAlign();
     Align SourceAlign = getOrEnforceKnownAlignment(
@@ -807,7 +802,7 @@ static Instruction *unpackLoadToAggregate(InstCombinerImpl &IC, LoadInst &LI) {
     // arrays of arbitrary size but this has a terrible impact on compile time.
     // The threshold here is chosen arbitrarily, maybe needs a little bit of
     // tuning.
-    if (NumElements > IC.MaxArraySizeForCombine)
+    if (NumElements > IC.CLOpts.maxarray_size)
       return nullptr;
 
     const DataLayout &DL = IC.getDataLayout();
@@ -1414,7 +1409,7 @@ static bool unpackStoreToAggregate(InstCombinerImpl &IC, StoreInst &SI) {
     // arrays of arbitrary size but this has a terrible impact on compile time.
     // The threshold here is chosen arbitrarily, maybe needs a little bit of
     // tuning.
-    if (NumElements > IC.MaxArraySizeForCombine)
+    if (NumElements > IC.CLOpts.maxarray_size)
       return false;
 
     const DataLayout &DL = IC.getDataLayout();
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp b/llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp
index ed31a7cdab3c4..9dceeef7bbab3 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp
@@ -34,7 +34,6 @@
 #include "llvm/IR/User.h"
 #include "llvm/IR/Value.h"
 #include "llvm/Support/Casting.h"
-#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/DebugCounter.h"
 #include "llvm/Support/ErrorHandling.h"
@@ -79,24 +78,14 @@ STATISTIC(NegatorNumInstructionsNegatedSuccess,
 DEBUG_COUNTER(NegatorCounter, "instcombine-negator",
               "Controls Negator transformations in InstCombine pass");
 
-static cl::opt<bool>
-    NegatorEnabled("instcombine-negator-enabled", cl::init(true),
-                   cl::desc("Should we attempt to sink negations?"));
-
-static cl::opt<unsigned>
-    NegatorMaxDepth("instcombine-negator-max-depth",
-                    cl::init(NegatorDefaultMaxDepth),
-                    cl::desc("What is the maximal lookup depth when trying to "
-                             "check for viability of negation sinking."));
-
 Negator::Negator(LLVMContext &C, const DataLayout &DL, const DominatorTree &DT_,
-                 bool IsTrulyNegation_)
+                 bool IsTrulyNegation_, unsigned MaxDepth)
     : Builder(C, TargetFolder(DL),
               IRBuilderCallbackInserter([&](Instruction *I) {
                 ++NegatorNumInstructionsCreatedTotal;
                 NewInstructions.push_back(I);
               })),
-      DT(DT_), IsTrulyNegation(IsTrulyNegation_) {}
+      DT(DT_), IsTrulyNegation(IsTrulyNegation_), MaxDepth(MaxDepth) {}
 
 #if LLVM_ENABLE_STATS
 Negator::~Negator() {
@@ -296,7 +285,7 @@ std::array<Value *, 2> Negator::getSortedOperandsOfBinOp(Instruction *I) {
   }
 
   // Rest of the logic is recursive, so if it's time to give up then it's time.
-  if (Depth > NegatorMaxDepth) {
+  if (Depth > MaxDepth) {
     LLVM_DEBUG(dbgs() << "Negator: reached maximal allowed traversal depth in "
                       << *V << ". Giving up.\n");
     ++NegatorTimesDepthLimitReached;
@@ -555,11 +544,12 @@ std::array<Value *, 2> Negator::getSortedOperandsOfBinOp(Instruction *I) {
   LLVM_DEBUG(dbgs() << "Negator: attempting to sink negation into " << *Root
                     << "\n");
 
-  if (!NegatorEnabled || !DebugCounter::shouldExecute(NegatorCounter))
+  if (!IC.CLOpts.negator_enabled ||
+      !DebugCounter::shouldExecute(NegatorCounter))
     return nullptr;
 
   Negator N(Root->getContext(), IC.getDataLayout(), IC.getDominatorTree(),
-            LHSIsZero);
+            LHSIsZero, IC.CLOpts.negator_max_depth);
   std::optional<Result> Res = N.run(Root, IsNSW);
   if (!Res) { // Negation failed.
     LLVM_DEBUG(dbgs() << "Negator: failed to sink negation into " << *Root
diff --git a/llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp b/llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp
index ce3175c4936de..f61defa969b18 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp
@@ -17,7 +17,6 @@
 #include "llvm/Analysis/InstructionSimplify.h"
 #include "llvm/Analysis/ValueTracking.h"
 #include "llvm/IR/PatternMatch.h"
-#include "llvm/Support/CommandLine.h"
 #include "llvm/Transforms/InstCombine/InstCombiner.h"
 #include "llvm/Transforms/Utils/Local.h"
 #include <optional>
@@ -27,10 +26,6 @@ using namespace llvm::PatternMatch;
 
 #define DEBUG_TYPE "instcombine"
 
-static cl::opt<unsigned>
-MaxNumPhis("instcombine-max-num-phis", cl::init(512),
-           cl::desc("Maximum number phis to handle in intptr/ptrint folding"));
-
 STATISTIC(NumPHIsOfInsertValues,
           "Number of phi-of-insertvalue turned into insertvalue-of-phis");
 STATISTIC(NumPHIsOfExtractValues,
@@ -229,7 +224,7 @@ bool InstCombinerImpl::foldIntegerTypedPHI(PHINode &PN) {
   unsigned NumPhis = 0;
   for (PHINode &PtrPHI : BB->phis()) {
     // FIXME: consider handling this in AggressiveInstCombine
-    if (NumPhis++ > MaxNumPhis)
+    if (NumPhis++ > CLOpts.max_num_phis)
       return false;
     if (&PtrPHI == &PN || PtrPHI.getType() != IntToPtr->getType())
       continue;
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
index bcd30323ce9a3..105554ccebe6d 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
@@ -25,18 +25,6 @@ using namespace llvm::PatternMatch;
 
 #define DEBUG_TYPE "instcombine"
 
-static cl::opt<bool>
-    VerifyKnownBits("instcombine-verify-known-bits",
-                    cl::desc("Verify that computeKnownBits() and "
-                             "SimplifyDemandedBits() are consistent"),
-                    cl::Hidden, cl::init(false));
-
-static cl::opt<unsigned> SimplifyDemandedVectorEltsDepthLimit(
-    "instcombine-simplify-vector-elts-depth",
-    cl::desc(
-        "Depth limit when simplifying vector instructions and their operands"),
-    cl::Hidden, cl::init(10));
-
 /// Check to see if the specified operand of the specified instruction is a
 /// constant integer. If so, check to see if there are any bits set in the
 /// constant that are not demanded. If so, shrink the constant and return true.
@@ -1208,7 +1196,7 @@ Value *InstCombinerImpl::SimplifyDemandedUseBits(Instruction *I,
       DemandedMask.isSubsetOf(Known.Zero | Known.One))
     return Constant::getIntegerValue(VTy, Known.One);
 
-  if (VerifyKnownBits) {
+  if (CLOpts.verify_known_bits) {
     KnownBits ReferenceKnown = llvm::computeKnownBits(I, Q, Depth);
     if (Known != ReferenceKnown) {
       errs() << "Mismatched known bits for " << *I << " in "
@@ -1585,7 +1573,7 @@ Value *InstCombinerImpl::SimplifyDemandedVectorElts(Value *V,
   }
 
   // Limit search depth.
-  if (Depth == SimplifyDemandedVectorEltsDepthLimit)
+  if (Depth == CLOpts.simplify_vector_elts_depth)
     return nullptr;
 
   if (!AllowMultipleUsers) {
@@ -1663,7 +1651,7 @@ Value *InstCombinerImpl::SimplifyDemandedVectorElts(Value *V,
     break;
   }
   case Instruction::InsertElement: {
-    unsigned DepthLimit = SimplifyDemandedVectorEltsDepthLimit;
+    unsigned DepthLimit = CLOpts.simplify_vector_elts_depth;
     auto *IE = cast<InsertElementInst>(I);
     // Skip only when SDVE cannot simplify this insert chain before the limit.
     if (Depth == 0 && DemandedElts.isAllOnes() && VWidth > DepthLimit &&
diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
index 72adf311850a3..35da73d2601b8 100644
--- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -89,7 +89,6 @@
 #include "llvm/IR/ValueHandle.h"
 #include "llvm/InitializePasses.h"
 #include "llvm/Support/Casting.h"
-#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/DebugCounter.h"
@@ -133,33 +132,6 @@ STATISTIC(NumReassoc  , "Number of reassociations");
 DEBUG_COUNTER(VisitCounter, "instcombine-visit",
               "Controls which instructions are visited");
 
-static cl::opt<bool> EnableCodeSinking("instcombine-code-sinking",
-                                       cl::desc("Enable code sinking"),
-                                       cl::init(true));
-
-static cl::opt<unsigned> MaxSinkNumUsers(
-    "instcombine-max-sink-users", cl::init(32),
-    cl::desc("Maximum number of undroppable users for instruction sinking"));
-
-static cl::opt<unsigned>
-MaxArraySize("instcombine-maxarray-size", cl::init(1024),
-             cl::desc("Maximum array size considered when doing a combine"));
-
-static cl::opt<unsigned> MaxAllocSiteRemovableUsers(
-    "instcombine-max-allocsite-removable-users", cl::Hidden, cl::init(2048),
-    cl::desc("Maximum number of users to visit in alloc-site "
-             "removability analysis"));
-
-// FIXME: Remove this flag when it is no longer necessary to convert
-// llvm.dbg.declare to avoid inaccurate debug info. Setting this to false
-// increases variable availability at the cost of accuracy. Variables that
-// cannot be promoted by mem2reg or SROA will be described as living in memory
-// for their entire lifetime. However, passes like DSE and instcombine can
-// delete stores to the alloca, leading to misleading and inaccurate debug
-// information. This flag can be removed when those passes are fixed.
-static cl::opt<unsigned> ShouldLowerDbgDeclare("instcombine-lower-dbg-declare",
-                                               cl::Hidden, cl::init(true));
-
 InstCombiner::IRBuilderInstCombineInserter::~IRBuilderInstCombineInserter() =
     default;
 
@@ -3740,7 +3712,8 @@ static bool isRemovableWrite(CallBase &CB, Value *UsedV,
 
 static std::optional<ModRefInfo>
 isAllocSiteRemovable(Instruction *AI, SmallVectorImpl<Instruction *> &Users,
-                     const TargetLibraryInfo &TLI, bool KnowInit) {
+                     const TargetLibraryInfo &TLI, bool KnowInit,
+                     unsigned MaxUsers) {
   SmallVector<Instruction*, 4> Worklist;
   const std::optional<StringRef> Family = getAllocationFamily(AI, &TLI);
   Worklist.push_back(AI);
@@ -3750,7 +3723,7 @@ isAllocSiteRemovable(Instruction *AI, SmallVectorImpl<Instruction *> &Users,
     Instruction *PI = Worklist.pop_back_val();
     for (User *U : PI->users()) {
       Instruction *I = cast<Instruction>(U);
-      if (Users.size() >= MaxAllocSiteRemovableUsers)
+      if (Users.size() >= MaxUsers)
         return std::nullopt;
       switch (I->getOpcode()) {
       default:
@@ -3934,7 +3907,8 @@ Instruction *InstCombinerImpl::visitAllocSite(Instruction &MI) {
     KnowInitUndef = false;
 
   auto Removable =
-      isAllocSiteRemovable(&MI, RawUsers, TLI, KnowInitZero | KnowInitUndef);
+      isAllocSiteRemovable(&MI, RawUsers, TLI, KnowInitZero | KnowInitUndef,
+                           CLOpts.max_allocsite_removable_users);
   if (Removable) {
     SmallVector<WeakTrackingVH, 64> Users(RawUsers.begin(), RawUsers.end());
     for (WeakTrackingVH &User : Users) {
@@ -5813,7 +5787,7 @@ bool InstCombinerImpl::run() {
     // Return the UserBlock if successful.
     auto getOptionalSinkBlockForInst =
         [this](Instruction *I) -> std::optional<BasicBlock *> {
-      if (!EnableCodeSinking)
+      if (!CLOpts.code_sinking)
         return std::nullopt;
 
       BasicBlock *BB = I->getParent();
@@ -5831,7 +5805,7 @@ bool InstCombinerImpl::run() {
             continue;
         }
 
-        if (NumUsers > MaxSinkNumUsers)
+        if (NumUsers > CLOpts.max_sink_users)
           return std::nullopt;
 
         Instruction *UserInst = cast<Instruction>(User);
@@ -6191,8 +6165,9 @@ static bool combineInstructionsOverFunction(
 
   // Lower dbg.declare intrinsics otherwise their value may be clobbered
   // by instcombiner.
+  const InstCombineCLOptions &CLOpts = InstCombineCLOptions::Global;
   bool MadeIRChange = false;
-  if (ShouldLowerDbgDeclare)
+  if (CLOpts.lower_dbg_declare)
     MadeIRChange = LowerDbgDeclare(F);
 
   // Iterate while there is work to do.
@@ -6211,8 +6186,7 @@ static bool combineInstructionsOverFunction(
                       << F.getName() << "\n");
 
     InstCombinerImpl IC(Worklist, F, AA, AC, TLI, TTI, DT, ORE, BFI, BPI, PSI,
-                        DL, RPOT);
-    IC.MaxArraySizeForCombine = MaxArraySize;
+                        DL, RPOT, CLOpts);
     bool MadeChangeInThisIteration = IC.prepareWorklist(F);
     MadeChangeInThisIteration |= IC.run();
     if (!MadeChangeInThisIteration)
diff --git a/llvm/unittests/Option/LibraryOptionsTest.cpp b/llvm/unittests/Option/LibraryOptionsTest.cpp
index 4e32caf953f6b..f13147b9feab5 100644
--- a/llvm/unittests/Option/LibraryOptionsTest.cpp
+++ b/llvm/unittests/Option/LibraryOptionsTest.cpp
@@ -25,9 +25,9 @@ namespace {
 // The struct -gen-opt-parser-defs generates: every spelling sets its member.
 TEST(LibraryOptionsTest, Apply) {
   TestLibraryOptions O;
-  EXPECT_FALSE(O.lib_enable);
-  EXPECT_EQ(O.lib_count, 3u);
-  EXPECT_EQ(O.lib_ratio, 0.5);
+  EXPECT_FALSE(O.enable);
+  EXPECT_EQ(O.count, 3u);
+  EXPECT_EQ(O.ratio, 0.5);
   EXPECT_EQ(O.Path, "p");
 
   auto Apply = [&](std::initializer_list<const char *> Argv) {
@@ -42,21 +42,21 @@ TEST(LibraryOptionsTest, Apply) {
   EXPECT_THAT(Apply({"-lib-enable", "--lib-count=7", "-lib-ratio", "0.25",
                      "-lib-path=a=b"}),
               testing::Each(true));
-  EXPECT_TRUE(O.lib_enable);
-  EXPECT_EQ(O.lib_count, 7u);
-  EXPECT_EQ(O.lib_ratio, 0.25);
+  EXPECT_TRUE(O.enable);
+  EXPECT_EQ(O.count, 7u);
+  EXPECT_EQ(O.ratio, 0.25);
   EXPECT_EQ(O.Path, "a=b");
   EXPECT_THAT(Apply({"-lib-enable=false"}), testing::Each(true));
-  EXPECT_FALSE(O.lib_enable);
+  EXPECT_FALSE(O.enable);
   EXPECT_THAT(Apply({"-lib-enable=1"}), testing::Each(true));
-  EXPECT_TRUE(O.lib_enable);
+  EXPECT_TRUE(O.enable);
 
   // A rejected value leaves the member unchanged.
   EXPECT_THAT(Apply({"-lib-enable=2", "-lib-count=-1", "-lib-ratio=y"}),
               testing::Each(false));
-  EXPECT_TRUE(O.lib_enable);
-  EXPECT_EQ(O.lib_count, 7u);
-  EXPECT_EQ(O.lib_ratio, 0.25);
+  EXPECT_TRUE(O.enable);
+  EXPECT_EQ(O.count, 7u);
+  EXPECT_EQ(O.ratio, 0.25);
 }
 
 // What cl:: sees of the struct, without cl::.
@@ -82,14 +82,14 @@ TEST(LibraryOptionsTest, Parser) {
     return std::to_string(Consumed) + " " + Err;
   };
   EXPECT_EQ(Parse({"-lib-count", "5"}), "2 ");
-  EXPECT_EQ(TestLibraryOptions::Global.lib_count, 5u);
+  EXPECT_EQ(TestLibraryOptions::Global.count, 5u);
   EXPECT_EQ(Parse({"-lib-count=x", "-lib-enable"}),
             "1 invalid value 'x' in '-lib-count=x'");
   EXPECT_EQ(Parse({"-lib-count"}),
             "1 option '-lib-count' requires an argument");
   EXPECT_EQ(Parse({"-lib-other"}), "1 unknown argument '-lib-other'");
   P.reset();
-  EXPECT_EQ(TestLibraryOptions::Global.lib_count, 3u);
+  EXPECT_EQ(TestLibraryOptions::Global.count, 3u);
 }
 
 // A static RegisterLibraryOptions connects the struct's Global to cl::.
@@ -100,14 +100,14 @@ TEST(LibraryOptionsTest, Register) {
   std::string Path = "-lib-path=q";
   const char *Args[] = {"prog", "-lib-count", "5", "-lib-enable", Path.c_str()};
   EXPECT_TRUE(cl::ParseCommandLineOptions(std::size(Args), Args, "", &nulls()));
-  EXPECT_EQ(G.lib_count, 5u);
-  EXPECT_TRUE(G.lib_enable);
+  EXPECT_EQ(G.count, 5u);
+  EXPECT_TRUE(G.enable);
   // A StringRef member does not refer to the caller's argument.
   Path.assign(Path.size(), 'x');
   EXPECT_EQ(G.Path, "q");
   cl::ResetAllOptionOccurrences();
-  EXPECT_EQ(G.lib_count, 3u);
-  EXPECT_FALSE(G.lib_enable);
+  EXPECT_EQ(G.count, 3u);
+  EXPECT_FALSE(G.enable);
   EXPECT_EQ(G.Path, "p");
   cl::ResetCommandLineParser();
 }
diff --git a/llvm/unittests/Option/LibraryOpts.td b/llvm/unittests/Option/LibraryOpts.td
index 1afdda1adcb41..bee1462651db1 100644
--- a/llvm/unittests/Option/LibraryOpts.td
+++ b/llvm/unittests/Option/LibraryOpts.td
@@ -8,7 +8,7 @@
 
 include "llvm/Option/LibraryOptions.td"
 
-def TestLibraryOptions : OptionsStruct<"test">;
+def TestLibraryOptions : OptionsStruct<"test", prefix = "lib-">;
 
 defm : BoolField<"lib-enable", "0", "A bool">;
 defm : ValueField<"lib-count", "unsigned", "3", "An unsigned">;
diff --git a/llvm/utils/TableGen/OptionParserEmitter.cpp b/llvm/utils/TableGen/OptionParserEmitter.cpp
index a41ddd5872ed7..06f883e0ada71 100644
--- a/llvm/utils/TableGen/OptionParserEmitter.cpp
+++ b/llvm/utils/TableGen/OptionParserEmitter.cpp
@@ -230,9 +230,12 @@ static MarshallingInfo createMarshallingInfo(const Record &R) {
   return Ret;
 }
 
-// -foo-bar and -foo-bar= become foo_bar.
-static std::string getSpellingIdentifier(const Record &R) {
-  std::string ID = R.getValueAsString("Name").rtrim('=').str();
+// -foo-bar and -foo-bar= become foo_bar, or bar if Prefix is "foo-".
+static std::string getSpellingIdentifier(const Record &R,
+                                         StringRef Prefix = "") {
+  StringRef Spelling = R.getValueAsString("Name").rtrim('=');
+  Spelling.consume_front(Prefix);
+  std::string ID = Spelling.str();
   llvm::replace(ID, '-', '_');
   if (ID.empty() || isDigit(ID[0]) ||
       !all_of(ID, [](char C) { return isAlnum(C) || C == '_'; }))
@@ -243,9 +246,10 @@ static std::string getSpellingIdentifier(const Record &R) {
 
 // `defm : BoolField<"foo-bar", ...>` declares member foo_bar, and a named defm
 // names it.
-static std::string getMemberName(const Record &R) {
+static std::string getMemberName(const Record &R, StringRef Prefix) {
   StringRef Name = R.getValueAsString("FieldName");
-  return Name.starts_with("anonymous_") ? getSpellingIdentifier(R) : Name.str();
+  return Name.starts_with("anonymous_") ? getSpellingIdentifier(R, Prefix)
+                                        : Name.str();
 }
 
 // The OPT_ name of an option of an OptionsStruct. `defm :` rows are named
@@ -291,10 +295,11 @@ static void emitOptionsStruct(const Record &Struct,
   llvm::sort(ByID, [](const Record *A, const Record *B) {
     return A->getID() < B->getID();
   });
+  StringRef Prefix = Struct.getValueAsString("MemberPrefix");
   std::vector<Member> Members;
   StringMap<unsigned> MemberIndex;
   for (const Record *R : ByID) {
-    Member M{getMemberName(*R), R->getValueAsString("FieldType"),
+    Member M{getMemberName(*R, Prefix), R->getValueAsString("FieldType"),
              R->getValueAsString("FieldDefault"),
              R->getValueAsString("Name").rtrim('=')};
     auto [It, Inserted] = MemberIndex.try_emplace(M.Name, Members.size());
@@ -346,7 +351,7 @@ static void emitOptionsStruct(const Record &Struct,
   OS << "  switch (A.getOption().getID()) {\n";
   for (const Record *R : Fields) {
     OS << "  case OPT_" << getStructOptionID(*R) << ":\n";
-    std::string Member = getMemberName(*R);
+    std::string Member = getMemberName(*R, Prefix);
     if (!R->getValue("FieldValue"))
       OS << "    return llvm::opt::parseArgValue(A.getValue(), " << Member
          << ");\n";
diff --git a/llvm/utils/gn/secondary/llvm/lib/Transforms/InstCombine/BUILD.gn b/llvm/utils/gn/secondary/llvm/lib/Transforms/InstCombine/BUILD.gn
index 2d539e9868a5c..79f422dabbf20 100644
--- a/llvm/utils/gn/secondary/llvm/lib/Transforms/InstCombine/BUILD.gn
+++ b/llvm/utils/gn/secondary/llvm/lib/Transforms/InstCombine/BUILD.gn
@@ -1,8 +1,17 @@
+import("//llvm/utils/TableGen/tablegen.gni")
+
+tablegen("InstCombineCLOptions") {
+  visibility = [ ":InstCombine" ]
+  args = [ "-gen-opt-parser-defs" ]
+}
+
 static_library("InstCombine") {
   output_name = "LLVMInstCombine"
   deps = [
+    ":InstCombineCLOptions",
     "//llvm/lib/Analysis",
     "//llvm/lib/IR",
+    "//llvm/lib/Option",
     "//llvm/lib/Support",
     "//llvm/lib/Transforms/Utils",
   ]
@@ -10,6 +19,7 @@ static_library("InstCombine") {
     "InstCombineAddSub.cpp",
     "InstCombineAndOrXor.cpp",
     "InstCombineAtomicRMW.cpp",
+    "InstCombineCLOptions.cpp",
     "InstCombineCalls.cpp",
     "InstCombineCasts.cpp",
     "InstCombineCompares.cpp",
diff --git a/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel b/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
index 797d128f9e29b..e1dca0caeb815 100644
--- a/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
@@ -1811,6 +1811,17 @@ td_library(
     ]),
 )
 
+gentbl_cc_library(
+    name = "InstCombineCLOptionsTableGen",
+    strip_include_prefix = "lib/Transforms/InstCombine",
+    tbl_outs = {
+        "lib/Transforms/InstCombine/InstCombineCLOptions.inc": ["-gen-opt-parser-defs"],
+    },
+    tblgen = ":llvm-tblgen",
+    td_file = "lib/Transforms/InstCombine/InstCombineCLOptions.td",
+    deps = [":OptParserTdFiles"],
+)
+
 cc_library(
     name = "InstCombine",
     srcs = glob([
@@ -1822,6 +1833,8 @@ cc_library(
     deps = [
         ":Analysis",
         ":Core",
+        ":InstCombineCLOptionsTableGen",
+        ":Option",
         ":Support",
         ":Target",
         ":TransformUtils",

>From dbf70e0aab041e220c752319e4ed725c8690b10d Mon Sep 17 00:00:00 2001
From: Fangrui Song <i at maskray.me>
Date: Wed, 30 Sep 2026 23:09:50 -0700
Subject: [PATCH 2/2] use const reference; use true/false instead of 1/0

---
 llvm/docs/CommandLine.md                               |  2 +-
 llvm/lib/CGData/CGDataOptions.td                       | 10 +++++-----
 .../lib/Transforms/InstCombine/InstCombineCLOptions.td |  9 ++++-----
 llvm/lib/Transforms/InstCombine/InstCombineInternal.h  |  2 +-
 llvm/unittests/Option/LibraryOpts.td                   |  2 +-
 5 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/llvm/docs/CommandLine.md b/llvm/docs/CommandLine.md
index 844339d106021..db311101cb8d0 100644
--- a/llvm/docs/CommandLine.md
+++ b/llvm/docs/CommandLine.md
@@ -1575,7 +1575,7 @@ include "llvm/Option/LibraryOptions.td"
 
 def FooOptions : OptionsStruct;
 
-defm : BoolField<"enable-foo", "1", "Enable foo">;
+defm : BoolField<"enable-foo", "true", "Enable foo">;
 defm threshold : ValueField<"foo-threshold", "unsigned", "8", "The threshold">;
 defm : ValueField<"foo-path", "StringRef", "\"-\"", "The input path">;
 ```
diff --git a/llvm/lib/CGData/CGDataOptions.td b/llvm/lib/CGData/CGDataOptions.td
index 7dd093fd41574..025e91f5bca23 100644
--- a/llvm/lib/CGData/CGDataOptions.td
+++ b/llvm/lib/CGData/CGDataOptions.td
@@ -10,9 +10,9 @@ include "llvm/Option/LibraryOptions.td"
 
 def CGDataOptions : OptionsStruct;
 
-defm : BoolField<"codegen-data-generate", "0",
+defm : BoolField<"codegen-data-generate", "false",
   "Emit CodeGen Data into custom sections">;
-defm : BoolField<"codegen-data-thinlto-two-rounds", "0",
+defm : BoolField<"codegen-data-thinlto-two-rounds", "false",
   "Enable two-round ThinLTO code generation. "
   "The first round emits codegen data, while the second round uses the emitted codegen data for further optimizations">;
 defm : ValueField<"codegen-data-use-path", "StringRef", "",
@@ -32,11 +32,11 @@ defm : ValueField<"global-merging-min-merges", "unsigned", "2",
   "Minimum number of similar functions with the same hash required for merging">;
 defm : ValueField<"global-merging-param-overhead", "double", "2.0",
   "The overhead cost associated with each parameter when merging functions">;
-defm : BoolField<"global-merging-skip-no-params", "1",
+defm : BoolField<"global-merging-skip-no-params", "true",
   "Skip merging functions with no parameters">;
-defm : BoolField<"indexed-codegen-data-lazy-loading", "0",
+defm : BoolField<"indexed-codegen-data-lazy-loading", "false",
   "Lazily load indexed CodeGenData. "
   "Enable to save memory and time for final consumption of the indexed CodeGenData in production">;
-defm : BoolField<"indexed-codegen-data-read-function-map-names", "1",
+defm : BoolField<"indexed-codegen-data-read-function-map-names", "true",
   "Read function map names in indexed CodeGenData. "
   "Can be disabled to save memory and time for final consumption of the indexed CodeGenData in production">;
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCLOptions.td b/llvm/lib/Transforms/InstCombine/InstCombineCLOptions.td
index ef5618c9e43f8..9fc098796f9e4 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCLOptions.td
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCLOptions.td
@@ -10,7 +10,7 @@ include "llvm/Option/LibraryOptions.td"
 
 def InstCombineCLOptions : OptionsStruct<prefix = "instcombine-">;
 
-defm : BoolField<"instcombine-code-sinking", "1",
+defm : BoolField<"instcombine-code-sinking", "true",
   "Enable code sinking">;
 defm : ValueField<"instcombine-guard-widening-window", "unsigned", "3",
   "How wide an instruction window to bypass looking for another guard">;
@@ -21,8 +21,7 @@ defm : ValueField<"instcombine-guard-widening-window", "unsigned", "3",
 // for their entire lifetime. However, passes like DSE and instcombine can
 // delete stores to the alloca, leading to misleading and inaccurate debug
 // information. This flag can be removed when those passes are fixed.
-defm : BoolField<"instcombine-lower-dbg-declare", "1",
-  "">;
+defm : BoolField<"instcombine-lower-dbg-declare", "true", "">;
 defm : ValueField<"instcombine-max-allocsite-removable-users", "unsigned", "2048",
   "Maximum number of users to visit in alloc-site removability analysis">;
 defm : ValueField<"instcombine-max-copied-from-constant-users", "unsigned", "300",
@@ -33,7 +32,7 @@ defm : ValueField<"instcombine-max-sink-users", "unsigned", "32",
   "Maximum number of undroppable users for instruction sinking">;
 defm : ValueField<"instcombine-maxarray-size", "unsigned", "1024",
   "Maximum array size considered when doing a combine">;
-defm : BoolField<"instcombine-negator-enabled", "1",
+defm : BoolField<"instcombine-negator-enabled", "true",
   "Should we attempt to sink negations?">;
 // As a default, let's assume that we want to be aggressive, and attempt to
 // traverse with no limits in attempt to sink negation.
@@ -41,5 +40,5 @@ defm : ValueField<"instcombine-negator-max-depth", "unsigned", "~0U",
   "What is the maximal lookup depth when trying to check for viability of negation sinking">;
 defm : ValueField<"instcombine-simplify-vector-elts-depth", "unsigned", "10",
   "Depth limit when simplifying vector instructions and their operands">;
-defm : BoolField<"instcombine-verify-known-bits", "0",
+defm : BoolField<"instcombine-verify-known-bits", "false",
   "Verify that computeKnownBits() and SimplifyDemandedBits() are consistent">;
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineInternal.h b/llvm/lib/Transforms/InstCombine/InstCombineInternal.h
index f4ef3d7ed99fc..388530edc10da 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineInternal.h
+++ b/llvm/lib/Transforms/InstCombine/InstCombineInternal.h
@@ -82,7 +82,7 @@ class LLVM_LIBRARY_VISIBILITY InstCombinerImpl final
 
   ~InstCombinerImpl() override = default;
 
-  const InstCombineCLOptions CLOpts;
+  const InstCombineCLOptions &CLOpts;
 
   /// Perform early cleanup and prepare the InstCombine worklist.
   bool prepareWorklist(Function &F);
diff --git a/llvm/unittests/Option/LibraryOpts.td b/llvm/unittests/Option/LibraryOpts.td
index bee1462651db1..ee1a838071b9c 100644
--- a/llvm/unittests/Option/LibraryOpts.td
+++ b/llvm/unittests/Option/LibraryOpts.td
@@ -10,7 +10,7 @@ include "llvm/Option/LibraryOptions.td"
 
 def TestLibraryOptions : OptionsStruct<"test", prefix = "lib-">;
 
-defm : BoolField<"lib-enable", "0", "A bool">;
+defm : BoolField<"lib-enable", "false", "A bool">;
 defm : ValueField<"lib-count", "unsigned", "3", "An unsigned">;
 defm : ValueField<"lib-ratio", "double", "0.5", "A double">;
 defm Path : ValueField<"lib-path", "StringRef", "\"p\"", "A string">;



More information about the llvm-commits mailing list