Skip to content

Commit 6acb0e9

Browse files
committed
Revert "Use cl::opt<std::optional<bool>> for preserve-{bc,ll}-uselistorder options"
This reverts commit 5b05667.
1 parent a96a3a3 commit 6acb0e9

File tree

3 files changed

+12
-40
lines changed

3 files changed

+12
-40
lines changed

llvm/include/llvm/IR/UseListOrder.h

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#ifndef LLVM_IR_USELISTORDER_H
1515
#define LLVM_IR_USELISTORDER_H
1616

17-
#include "llvm/Support/CommandLine.h"
1817
#include <cstddef>
1918
#include <vector>
2019

@@ -39,27 +38,6 @@ struct UseListOrder {
3938

4039
using UseListOrderStack = std::vector<UseListOrder>;
4140

42-
class PreserveUseListOrderOptionParser
43-
: public cl::parser<std::optional<bool>> {
44-
public:
45-
PreserveUseListOrderOptionParser(cl::Option &O)
46-
: cl::parser<std::optional<bool>>(O) {}
47-
48-
bool parse(cl::Option &O, StringRef ArgName, StringRef Arg,
49-
std::optional<bool> &V) {
50-
if (Arg == "" || Arg == "true" || Arg == "TRUE" || Arg == "True" ||
51-
Arg == "1") {
52-
V = true;
53-
return false;
54-
}
55-
if (Arg == "false" || Arg == "FALSE" || Arg == "False" || Arg == "0") {
56-
V = false;
57-
return false;
58-
}
59-
return O.error("Invalid argument '" + Arg + "', Try 0 or 1");
60-
}
61-
};
62-
6341
} // end namespace llvm
6442

6543
#endif // LLVM_IR_USELISTORDER_H

llvm/lib/Bitcode/Writer/BitcodeWriter.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,10 @@ static cl::opt<bool>
118118
#endif
119119
cl::desc(""));
120120

121-
static cl::opt<std::optional<bool>, /*ExternalStorage=*/false,
122-
PreserveUseListOrderOptionParser>
123-
PreserveBitcodeUseListOrder(
124-
"preserve-bc-uselistorder",
125-
cl::desc("Preserve use-list order when writing LLVM bitcode."),
126-
cl::init(std::nullopt), cl::Hidden, cl::ValueOptional);
121+
static cl::opt<bool> PreserveBitcodeUseListOrder(
122+
"preserve-bc-uselistorder",
123+
cl::desc("Preserve use-list order when writing LLVM bitcode."),
124+
cl::init(false), cl::Hidden);
127125

128126
namespace llvm {
129127
extern FunctionSummary::ForceSummaryHotnessType ForceSummaryEdgesCold;
@@ -224,7 +222,7 @@ class ModuleBitcodeWriterBase : public BitcodeWriterBase {
224222
bool ShouldPreserveUseListOrder,
225223
const ModuleSummaryIndex *Index)
226224
: BitcodeWriterBase(Stream, StrtabBuilder), M(M),
227-
VE(M, PreserveBitcodeUseListOrder.value_or(ShouldPreserveUseListOrder)),
225+
VE(M, ShouldPreserveUseListOrder || PreserveBitcodeUseListOrder),
228226
Index(Index) {
229227
// Assign ValueIds to any callee values in the index that came from
230228
// indirect call profiles and were recorded as a GUID not a Value*

llvm/lib/IR/AsmWriter.cpp

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@
6363
#include "llvm/IR/TypeFinder.h"
6464
#include "llvm/IR/TypedPointerType.h"
6565
#include "llvm/IR/Use.h"
66-
#include "llvm/IR/UseListOrder.h"
6766
#include "llvm/IR/User.h"
6867
#include "llvm/IR/Value.h"
6968
#include "llvm/Support/AtomicOrdering.h"
@@ -103,12 +102,10 @@ static cl::opt<bool> PrintProfData(
103102
"print-prof-data", cl::Hidden,
104103
cl::desc("Pretty print perf data (branch weights, etc) when dumping"));
105104

106-
static cl::opt<std::optional<bool>, /*ExternalStorage=*/false,
107-
PreserveUseListOrderOptionParser>
108-
PreserveAssemblyUseListOrder(
109-
"preserve-ll-uselistorder",
110-
cl::desc("Preserve use-list order when writing LLVM assembly."),
111-
cl::init(std::nullopt), cl::Hidden, cl::ValueOptional);
105+
static cl::opt<bool> PreserveAssemblyUseListOrder(
106+
"preserve-ll-uselistorder",
107+
cl::desc("Preserve use-list order when writing LLVM assembly."),
108+
cl::init(false), cl::Hidden);
112109

113110
// Make virtual table appear in this compilation unit.
114111
AssemblyAnnotationWriter::~AssemblyAnnotationWriter() = default;
@@ -2941,8 +2938,8 @@ AssemblyWriter::AssemblyWriter(formatted_raw_ostream &o, SlotTracker &Mac,
29412938
bool IsForDebug, bool ShouldPreserveUseListOrder)
29422939
: Out(o), TheModule(M), Machine(Mac), TypePrinter(M), AnnotationWriter(AAW),
29432940
IsForDebug(IsForDebug),
2944-
ShouldPreserveUseListOrder(
2945-
PreserveAssemblyUseListOrder.value_or(ShouldPreserveUseListOrder)) {
2941+
ShouldPreserveUseListOrder(ShouldPreserveUseListOrder ||
2942+
PreserveAssemblyUseListOrder) {
29462943
if (!TheModule)
29472944
return;
29482945
for (const GlobalObject &GO : TheModule->global_objects())
@@ -2954,8 +2951,7 @@ AssemblyWriter::AssemblyWriter(formatted_raw_ostream &o, SlotTracker &Mac,
29542951
const ModuleSummaryIndex *Index, bool IsForDebug)
29552952
: Out(o), TheIndex(Index), Machine(Mac), TypePrinter(/*Module=*/nullptr),
29562953
IsForDebug(IsForDebug),
2957-
ShouldPreserveUseListOrder(PreserveAssemblyUseListOrder.value_or(false)) {
2958-
}
2954+
ShouldPreserveUseListOrder(PreserveAssemblyUseListOrder) {}
29592955

29602956
void AssemblyWriter::writeOperand(const Value *Operand, bool PrintType) {
29612957
if (!Operand) {

0 commit comments

Comments
 (0)