Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ static cl::opt<bool>
#endif
cl::desc(""));

static cl::opt<bool> PreserveBitcodeUseListOrder(
"preserve-bc-uselistorder", cl::Hidden, cl::init(true),
cl::desc("Preserve use-list order when writing LLVM bitcode."));

namespace llvm {
extern FunctionSummary::ForceSummaryHotnessType ForceSummaryEdgesCold;
}
Expand Down Expand Up @@ -217,7 +221,10 @@ class ModuleBitcodeWriterBase : public BitcodeWriterBase {
bool ShouldPreserveUseListOrder,
const ModuleSummaryIndex *Index)
: BitcodeWriterBase(Stream, StrtabBuilder), M(M),
VE(M, ShouldPreserveUseListOrder), Index(Index) {
VE(M, PreserveBitcodeUseListOrder.getNumOccurrences()
? PreserveBitcodeUseListOrder
: ShouldPreserveUseListOrder),
Index(Index) {
// Assign ValueIds to any callee values in the index that came from
// indirect call profiles and were recorded as a GUID not a Value*
// (which would have been assigned an ID by the ValueEnumerator).
Expand Down
12 changes: 10 additions & 2 deletions llvm/lib/IR/AsmWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ static cl::opt<bool> PrintProfData(
"print-prof-data", cl::Hidden,
cl::desc("Pretty print perf data (branch weights, etc) when dumping"));

static cl::opt<bool> PreserveAssemblyUseListOrder(
"preserve-ll-uselistorder", cl::Hidden, cl::init(false),
cl::desc("Preserve use-list order when writing LLVM assembly."));

// Make virtual table appear in this compilation unit.
AssemblyAnnotationWriter::~AssemblyAnnotationWriter() = default;

Expand Down Expand Up @@ -2933,7 +2937,10 @@ AssemblyWriter::AssemblyWriter(formatted_raw_ostream &o, SlotTracker &Mac,
bool IsForDebug, bool ShouldPreserveUseListOrder)
: Out(o), TheModule(M), Machine(Mac), TypePrinter(M), AnnotationWriter(AAW),
IsForDebug(IsForDebug),
ShouldPreserveUseListOrder(ShouldPreserveUseListOrder) {
ShouldPreserveUseListOrder(
PreserveAssemblyUseListOrder.getNumOccurrences()
? PreserveAssemblyUseListOrder
: ShouldPreserveUseListOrder) {
if (!TheModule)
return;
for (const GlobalObject &GO : TheModule->global_objects())
Expand All @@ -2944,7 +2951,8 @@ AssemblyWriter::AssemblyWriter(formatted_raw_ostream &o, SlotTracker &Mac,
AssemblyWriter::AssemblyWriter(formatted_raw_ostream &o, SlotTracker &Mac,
const ModuleSummaryIndex *Index, bool IsForDebug)
: Out(o), TheIndex(Index), Machine(Mac), TypePrinter(/*Module=*/nullptr),
IsForDebug(IsForDebug), ShouldPreserveUseListOrder(false) {}
IsForDebug(IsForDebug),
ShouldPreserveUseListOrder(PreserveAssemblyUseListOrder) {}

void AssemblyWriter::writeOperand(const Value *Operand, bool PrintType) {
if (!Operand) {
Expand Down
11 changes: 3 additions & 8 deletions llvm/tools/bugpoint/OptimizerDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@ namespace llvm {
extern cl::opt<std::string> OutputPrefix;
}

static cl::opt<bool> PreserveBitcodeUseListOrder(
"preserve-bc-uselistorder",
cl::desc("Preserve use-list order when writing LLVM bitcode."),
cl::init(true), cl::Hidden);

static cl::opt<std::string>
OptCmd("opt-command", cl::init(""),
cl::desc("Path to opt. (default: search path "
Expand All @@ -51,7 +46,7 @@ static cl::opt<std::string>
/// This writes the current "Program" to the named bitcode file. If an error
/// occurs, true is returned.
static bool writeProgramToFileAux(ToolOutputFile &Out, const Module &M) {
WriteBitcodeToFile(M, Out.os(), PreserveBitcodeUseListOrder);
WriteBitcodeToFile(M, Out.os(), /* ShouldPreserveUseListOrder */ true);
Out.os().close();
if (!Out.os().has_error()) {
Out.keep();
Expand All @@ -68,7 +63,7 @@ bool BugDriver::writeProgramToFile(const std::string &Filename, int FD,

bool BugDriver::writeProgramToFile(int FD, const Module &M) const {
raw_fd_ostream OS(FD, /*shouldClose*/ false);
WriteBitcodeToFile(M, OS, PreserveBitcodeUseListOrder);
WriteBitcodeToFile(M, OS, /* ShouldPreserveUseListOrder */ true);
OS.flush();
if (!OS.has_error())
return false;
Expand Down Expand Up @@ -155,7 +150,7 @@ bool BugDriver::runPasses(Module &Program,
DiscardTemp Discard{*Temp};
raw_fd_ostream OS(Temp->FD, /*shouldClose*/ false);

WriteBitcodeToFile(Program, OS, PreserveBitcodeUseListOrder);
WriteBitcodeToFile(Program, OS, /* ShouldPreserveUseListOrder */ true);
OS.flush();
if (OS.has_error()) {
errs() << "Error writing bitcode file: " << Temp->TmpName << "\n";
Expand Down
7 changes: 1 addition & 6 deletions llvm/tools/llvm-as/llvm-as.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,6 @@ static cl::opt<bool>
cl::desc("Do not run verifier on input LLVM (dangerous!)"),
cl::cat(AsCat));

static cl::opt<bool> PreserveBitcodeUseListOrder(
"preserve-bc-uselistorder",
cl::desc("Preserve use-list order when writing LLVM bitcode."),
cl::init(true), cl::Hidden, cl::cat(AsCat));

static cl::opt<std::string> ClDataLayout("data-layout",
cl::desc("data layout string to use"),
cl::value_desc("layout-string"),
Expand Down Expand Up @@ -100,7 +95,7 @@ static void WriteOutputFile(const Module *M, const ModuleSummaryIndex *Index) {
// any non-null Index along with it as a per-module Index.
// If both are empty, this will give an empty module block, which is
// the expected behavior.
WriteBitcodeToFile(*M, Out->os(), PreserveBitcodeUseListOrder,
WriteBitcodeToFile(*M, Out->os(), /* ShouldPreserveUseListOrder */ true,
IndexToWrite, EmitModuleHash);
else
// Otherwise, with an empty Module but non-empty Index, we write a
Expand Down
8 changes: 2 additions & 6 deletions llvm/tools/llvm-dis/llvm-dis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,6 @@ static cl::opt<bool>
cl::desc("Add informational comments to the .ll file"),
cl::cat(DisCategory));

static cl::opt<bool> PreserveAssemblyUseListOrder(
"preserve-ll-uselistorder",
cl::desc("Preserve use-list order when writing LLVM assembly."),
cl::init(false), cl::Hidden, cl::cat(DisCategory));

static cl::opt<bool>
MaterializeMetadata("materialize-metadata",
cl::desc("Load module without materializing metadata, "
Expand Down Expand Up @@ -255,7 +250,8 @@ int main(int argc, char **argv) {
if (!DontPrint) {
if (M) {
M->removeDebugIntrinsicDeclarations();
M->print(Out->os(), Annotator.get(), PreserveAssemblyUseListOrder);
M->print(Out->os(), Annotator.get(),
/* ShouldPreserveUseListOrder */ false);
}
if (Index)
Index->print(Out->os());
Expand Down
16 changes: 4 additions & 12 deletions llvm/tools/llvm-extract/llvm-extract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,16 +129,6 @@ static cl::opt<bool> OutputAssembly("S",
cl::desc("Write output as LLVM assembly"),
cl::Hidden, cl::cat(ExtractCat));

static cl::opt<bool> PreserveBitcodeUseListOrder(
"preserve-bc-uselistorder",
cl::desc("Preserve use-list order when writing LLVM bitcode."),
cl::init(true), cl::Hidden, cl::cat(ExtractCat));

static cl::opt<bool> PreserveAssemblyUseListOrder(
"preserve-ll-uselistorder",
cl::desc("Preserve use-list order when writing LLVM assembly."),
cl::init(false), cl::Hidden, cl::cat(ExtractCat));

int main(int argc, char **argv) {
InitLLVM X(argc, argv);

Expand Down Expand Up @@ -421,9 +411,11 @@ int main(int argc, char **argv) {
}

if (OutputAssembly)
PM.addPass(PrintModulePass(Out.os(), "", PreserveAssemblyUseListOrder));
PM.addPass(
PrintModulePass(Out.os(), "", /* ShouldPreserveUseListOrder */ false));
else if (Force || !CheckBitcodeOutputToConsole(Out.os()))
PM.addPass(BitcodeWriterPass(Out.os(), PreserveBitcodeUseListOrder));
PM.addPass(
BitcodeWriterPass(Out.os(), /* ShouldPreserveUseListOrder */ true));

PM.run(*M, MAM);

Expand Down
15 changes: 3 additions & 12 deletions llvm/tools/llvm-link/llvm-link.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,6 @@ static cl::opt<bool> SuppressWarnings("suppress-warnings",
cl::desc("Suppress all linking warnings"),
cl::init(false), cl::cat(LinkCategory));

static cl::opt<bool> PreserveBitcodeUseListOrder(
"preserve-bc-uselistorder",
cl::desc("Preserve use-list order when writing LLVM bitcode."),
cl::init(true), cl::Hidden, cl::cat(LinkCategory));

static cl::opt<bool> PreserveAssemblyUseListOrder(
"preserve-ll-uselistorder",
cl::desc("Preserve use-list order when writing LLVM assembly."),
cl::init(false), cl::Hidden, cl::cat(LinkCategory));

static cl::opt<bool> NoVerify("disable-verify",
cl::desc("Do not run the verifier"), cl::Hidden,
cl::cat(LinkCategory));
Expand Down Expand Up @@ -525,9 +515,10 @@ int main(int argc, char **argv) {
errs() << "Writing bitcode...\n";
Composite->removeDebugIntrinsicDeclarations();
if (OutputAssembly) {
Composite->print(Out.os(), nullptr, PreserveAssemblyUseListOrder);
Composite->print(Out.os(), nullptr, /* ShouldPreserveUseListOrder */ false);
} else if (Force || !CheckBitcodeOutputToConsole(Out.os())) {
WriteBitcodeToFile(*Composite, Out.os(), PreserveBitcodeUseListOrder);
WriteBitcodeToFile(*Composite, Out.os(),
/* ShouldPreserveUseListOrder */ true);
}

// Declare success.
Expand Down
22 changes: 7 additions & 15 deletions llvm/tools/opt/optdriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,16 +232,6 @@ static cl::opt<std::string> ClDataLayout("data-layout",
cl::value_desc("layout-string"),
cl::init(""));

static cl::opt<bool> PreserveBitcodeUseListOrder(
"preserve-bc-uselistorder",
cl::desc("Preserve use-list order when writing LLVM bitcode."),
cl::init(true), cl::Hidden);

static cl::opt<bool> PreserveAssemblyUseListOrder(
"preserve-ll-uselistorder",
cl::desc("Preserve use-list order when writing LLVM assembly."),
cl::init(false), cl::Hidden);

static cl::opt<bool> RunTwice("run-twice",
cl::desc("Run all passes twice, re-using the "
"same pass manager (legacy PM only)."),
Expand Down Expand Up @@ -753,9 +743,9 @@ extern "C" int optMain(
return runPassPipeline(
argv[0], *M, TM.get(), &TLII, Out.get(), ThinLinkOut.get(),
RemarksFile.get(), Pipeline, PluginList, PassBuilderCallbacks,
OK, VK, PreserveAssemblyUseListOrder,
PreserveBitcodeUseListOrder, EmitSummaryIndex, EmitModuleHash,
EnableDebugify, VerifyDebugInfoPreserve,
OK, VK, /* ShouldPreserveAssemblyUseListOrder */ false,
/* ShouldPreserveBitcodeUseListOrder */ true, EmitSummaryIndex,
EmitModuleHash, EnableDebugify, VerifyDebugInfoPreserve,
EnableProfileVerification, UnifiedLTO)
? 0
: 1;
Expand Down Expand Up @@ -877,9 +867,11 @@ extern "C" int optMain(
OS = BOS.get();
}
if (OutputAssembly)
Passes.add(createPrintModulePass(*OS, "", PreserveAssemblyUseListOrder));
Passes.add(createPrintModulePass(
*OS, "", /* ShouldPreserveAssemblyUseListOrder */ false));
else
Passes.add(createBitcodeWriterPass(*OS, PreserveBitcodeUseListOrder));
Passes.add(createBitcodeWriterPass(
*OS, /* ShouldPreserveBitcodeUseListOrder */ true));
}

// Before executing passes, print the final values of the LLVM options.
Expand Down