forked from OSchip/llvm-project
uselistorder: Remove the global bits
Remove all the global bits to do with preserving use-list order by moving the `cl::opt`s to the individual tools that want them. There's a minor functionality change to `libLTO`, in that you can't send in `-preserve-bc-uselistorder=false`, but making that bit settable (if it's worth doing) should be through explicit LTO API. As a drive-by fix, I removed some includes of `UseListOrder.h` that were made unnecessary by recent commits. llvm-svn: 234973
This commit is contained in:
parent
fda02091e6
commit
8a7b84b4d0
|
@ -51,12 +51,6 @@ private:
|
|||
|
||||
typedef std::vector<UseListOrder> UseListOrderStack;
|
||||
|
||||
/// \brief Whether to preserve use-list ordering.
|
||||
bool shouldPreserveBitcodeUseListOrder();
|
||||
bool shouldPreserveAssemblyUseListOrder();
|
||||
void setPreserveBitcodeUseListOrder(bool ShouldPreserve);
|
||||
void setPreserveAssemblyUseListOrder(bool ShouldPreserve);
|
||||
|
||||
} // end namespace llvm
|
||||
|
||||
#endif
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
#include "llvm/Bitcode/ReaderWriter.h"
|
||||
#include "llvm/IR/Module.h"
|
||||
#include "llvm/IR/PassManager.h"
|
||||
#include "llvm/IR/UseListOrder.h"
|
||||
#include "llvm/Pass.h"
|
||||
using namespace llvm;
|
||||
|
||||
|
|
|
@ -41,7 +41,6 @@ add_llvm_library(LLVMCore
|
|||
Type.cpp
|
||||
TypeFinder.cpp
|
||||
Use.cpp
|
||||
UseListOrder.cpp
|
||||
User.cpp
|
||||
Value.cpp
|
||||
ValueSymbolTable.cpp
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
//===- UseListOrder.cpp - Implement Use List Order ------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Implement structures and command-line options for preserving use-list order.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "llvm/IR/UseListOrder.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
static cl::opt<bool> PreserveBitcodeUseListOrder(
|
||||
"preserve-bc-uselistorder",
|
||||
cl::desc("Preserve use-list order when writing LLVM bitcode."),
|
||||
cl::init(false), 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);
|
||||
|
||||
bool llvm::shouldPreserveBitcodeUseListOrder() {
|
||||
return PreserveBitcodeUseListOrder;
|
||||
}
|
||||
|
||||
bool llvm::shouldPreserveAssemblyUseListOrder() {
|
||||
return PreserveAssemblyUseListOrder;
|
||||
}
|
||||
|
||||
void llvm::setPreserveBitcodeUseListOrder(bool ShouldPreserve) {
|
||||
PreserveBitcodeUseListOrder = ShouldPreserve;
|
||||
}
|
||||
|
||||
void llvm::setPreserveAssemblyUseListOrder(bool ShouldPreserve) {
|
||||
PreserveAssemblyUseListOrder = ShouldPreserve;
|
||||
}
|
|
@ -29,7 +29,6 @@
|
|||
#include "llvm/IR/LegacyPassManager.h"
|
||||
#include "llvm/IR/Mangler.h"
|
||||
#include "llvm/IR/Module.h"
|
||||
#include "llvm/IR/UseListOrder.h"
|
||||
#include "llvm/IR/Verifier.h"
|
||||
#include "llvm/InitializePasses.h"
|
||||
#include "llvm/LTO/LTOModule.h"
|
||||
|
@ -216,7 +215,7 @@ bool LTOCodeGenerator::writeMergedModules(const char *path,
|
|||
|
||||
// write bitcode to it
|
||||
WriteBitcodeToFile(IRLinker.getModule(), Out.os(),
|
||||
shouldPreserveBitcodeUseListOrder());
|
||||
/* ShouldPreserveUseListOrder */ true);
|
||||
Out.os().close();
|
||||
|
||||
if (Out.os().has_error()) {
|
||||
|
@ -606,10 +605,6 @@ void LTOCodeGenerator::setCodeGenDebugOptions(const char *options) {
|
|||
}
|
||||
|
||||
void LTOCodeGenerator::parseCodeGenDebugOptions() {
|
||||
// Turn on -preserve-bc-uselistorder by default, but let the command-line
|
||||
// override it.
|
||||
setPreserveBitcodeUseListOrder(true);
|
||||
|
||||
// if options were requested, set them
|
||||
if (!CodegenOptions.empty())
|
||||
cl::ParseCommandLineOptions(CodegenOptions.size(),
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
#include "llvm/IR/DataLayout.h"
|
||||
#include "llvm/IR/LegacyPassManager.h"
|
||||
#include "llvm/IR/Module.h"
|
||||
#include "llvm/IR/UseListOrder.h"
|
||||
#include "llvm/IR/Verifier.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
#include "llvm/Support/Debug.h"
|
||||
|
@ -43,6 +42,11 @@ 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);
|
||||
|
||||
namespace {
|
||||
// ChildOutput - This option captures the name of the child output file that
|
||||
// is set up by the parent bugpoint process
|
||||
|
@ -56,7 +60,7 @@ namespace {
|
|||
/// file. If an error occurs, true is returned.
|
||||
///
|
||||
static bool writeProgramToFileAux(tool_output_file &Out, const Module *M) {
|
||||
WriteBitcodeToFile(M, Out.os(), shouldPreserveBitcodeUseListOrder());
|
||||
WriteBitcodeToFile(M, Out.os(), PreserveBitcodeUseListOrder);
|
||||
Out.os().close();
|
||||
if (!Out.os().has_error()) {
|
||||
Out.keep();
|
||||
|
@ -152,7 +156,7 @@ bool BugDriver::runPasses(Module *Program,
|
|||
|
||||
tool_output_file InFile(InputFilename, InputFD);
|
||||
|
||||
WriteBitcodeToFile(Program, InFile.os(), shouldPreserveBitcodeUseListOrder());
|
||||
WriteBitcodeToFile(Program, InFile.os(), PreserveBitcodeUseListOrder);
|
||||
InFile.os().close();
|
||||
if (InFile.os().has_error()) {
|
||||
errs() << "Error writing bitcode file: " << InputFilename << "\n";
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
#include "llvm/IR/LLVMContext.h"
|
||||
#include "llvm/IR/LegacyPassManager.h"
|
||||
#include "llvm/IR/LegacyPassNameParser.h"
|
||||
#include "llvm/IR/UseListOrder.h"
|
||||
#include "llvm/LinkAllIR.h"
|
||||
#include "llvm/LinkAllPasses.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
|
@ -137,10 +136,6 @@ int main(int argc, char **argv) {
|
|||
polly::initializePollyPasses(Registry);
|
||||
#endif
|
||||
|
||||
// Turn on -preserve-bc-uselistorder by default, but let the command-line
|
||||
// override it.
|
||||
setPreserveBitcodeUseListOrder(true);
|
||||
|
||||
cl::ParseCommandLineOptions(argc, argv,
|
||||
"LLVM automatic testcase reducer. See\nhttp://"
|
||||
"llvm.org/cmds/bugpoint.html"
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#include "llvm/AsmParser/Parser.h"
|
||||
#include "llvm/Bitcode/ReaderWriter.h"
|
||||
#include "llvm/IR/Module.h"
|
||||
#include "llvm/IR/UseListOrder.h"
|
||||
#include "llvm/IR/Verifier.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
#include "llvm/Support/FileSystem.h"
|
||||
|
@ -52,6 +51,11 @@ static cl::opt<bool>
|
|||
DisableVerify("disable-verify", cl::Hidden,
|
||||
cl::desc("Do not run verifier on input LLVM (dangerous!)"));
|
||||
|
||||
static cl::opt<bool> PreserveBitcodeUseListOrder(
|
||||
"preserve-bc-uselistorder",
|
||||
cl::desc("Preserve use-list order when writing LLVM bitcode."),
|
||||
cl::init(true), cl::Hidden);
|
||||
|
||||
static void WriteOutputFile(const Module *M) {
|
||||
// Infer the output filename if needed.
|
||||
if (OutputFilename.empty()) {
|
||||
|
@ -79,7 +83,7 @@ static void WriteOutputFile(const Module *M) {
|
|||
}
|
||||
|
||||
if (Force || !CheckBitcodeOutputToConsole(Out->os(), true))
|
||||
WriteBitcodeToFile(M, Out->os(), shouldPreserveBitcodeUseListOrder());
|
||||
WriteBitcodeToFile(M, Out->os(), PreserveBitcodeUseListOrder);
|
||||
|
||||
// Declare success.
|
||||
Out->keep();
|
||||
|
@ -91,11 +95,6 @@ int main(int argc, char **argv) {
|
|||
PrettyStackTraceProgram X(argc, argv);
|
||||
LLVMContext &Context = getGlobalContext();
|
||||
llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
|
||||
|
||||
// Turn on -preserve-bc-uselistorder by default, but let the command-line
|
||||
// override it.
|
||||
setPreserveBitcodeUseListOrder(true);
|
||||
|
||||
cl::ParseCommandLineOptions(argc, argv, "llvm .ll -> .bc assembler\n");
|
||||
|
||||
// Parse the file now...
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
#include "llvm/IR/IntrinsicInst.h"
|
||||
#include "llvm/IR/Module.h"
|
||||
#include "llvm/IR/Type.h"
|
||||
#include "llvm/IR/UseListOrder.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
#include "llvm/Support/DataStream.h"
|
||||
#include "llvm/Support/FileSystem.h"
|
||||
|
@ -55,6 +54,11 @@ static cl::opt<bool>
|
|||
ShowAnnotations("show-annotations",
|
||||
cl::desc("Add informational comments to the .ll file"));
|
||||
|
||||
static cl::opt<bool> PreserveAssemblyUseListOrder(
|
||||
"preserve-ll-uselistorder",
|
||||
cl::desc("Preserve use-list order when writing LLVM assembly."),
|
||||
cl::init(false), cl::Hidden);
|
||||
|
||||
namespace {
|
||||
|
||||
static void printDebugLoc(const DebugLoc &DL, formatted_raw_ostream &OS) {
|
||||
|
@ -190,7 +194,7 @@ int main(int argc, char **argv) {
|
|||
|
||||
// All that llvm-dis does is write the assembly to a file.
|
||||
if (!DontPrint)
|
||||
M->print(Out->os(), Annotator.get(), shouldPreserveAssemblyUseListOrder());
|
||||
M->print(Out->os(), Annotator.get(), PreserveAssemblyUseListOrder);
|
||||
|
||||
// Declare success.
|
||||
Out->keep();
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#include "llvm/IR/IRPrintingPasses.h"
|
||||
#include "llvm/IR/LLVMContext.h"
|
||||
#include "llvm/IR/Module.h"
|
||||
#include "llvm/IR/UseListOrder.h"
|
||||
#include "llvm/IRReader/IRReader.h"
|
||||
#include "llvm/IR/LegacyPassManager.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
|
@ -91,6 +90,16 @@ static cl::opt<bool>
|
|||
OutputAssembly("S",
|
||||
cl::desc("Write output as LLVM assembly"), cl::Hidden);
|
||||
|
||||
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);
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
// Print a stack trace if we signal out.
|
||||
sys::PrintStackTraceOnErrorSignal();
|
||||
|
@ -98,11 +107,6 @@ int main(int argc, char **argv) {
|
|||
|
||||
LLVMContext &Context = getGlobalContext();
|
||||
llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
|
||||
|
||||
// Turn on -preserve-bc-uselistorder by default, but let the command-line
|
||||
// override it.
|
||||
setPreserveBitcodeUseListOrder(true);
|
||||
|
||||
cl::ParseCommandLineOptions(argc, argv, "llvm extractor\n");
|
||||
|
||||
// Use lazy loading, since we only care about selected global values.
|
||||
|
@ -270,11 +274,10 @@ int main(int argc, char **argv) {
|
|||
}
|
||||
|
||||
if (OutputAssembly)
|
||||
Passes.add(createPrintModulePass(Out.os(), "",
|
||||
shouldPreserveAssemblyUseListOrder()));
|
||||
else if (Force || !CheckBitcodeOutputToConsole(Out.os(), true))
|
||||
Passes.add(
|
||||
createBitcodeWriterPass(Out.os(), shouldPreserveBitcodeUseListOrder()));
|
||||
createPrintModulePass(Out.os(), "", PreserveAssemblyUseListOrder));
|
||||
else if (Force || !CheckBitcodeOutputToConsole(Out.os(), true))
|
||||
Passes.add(createBitcodeWriterPass(Out.os(), PreserveBitcodeUseListOrder));
|
||||
|
||||
Passes.run(*M.get());
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
#include "llvm/IR/DiagnosticPrinter.h"
|
||||
#include "llvm/IR/LLVMContext.h"
|
||||
#include "llvm/IR/Module.h"
|
||||
#include "llvm/IR/UseListOrder.h"
|
||||
#include "llvm/IR/Verifier.h"
|
||||
#include "llvm/IRReader/IRReader.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
|
@ -60,6 +59,16 @@ static cl::opt<bool>
|
|||
SuppressWarnings("suppress-warnings", cl::desc("Suppress all linking warnings"),
|
||||
cl::init(false));
|
||||
|
||||
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);
|
||||
|
||||
// Read the specified bitcode file in and return it. This routine searches the
|
||||
// link path for the specified file to try to find it...
|
||||
//
|
||||
|
@ -105,11 +114,6 @@ int main(int argc, char **argv) {
|
|||
|
||||
LLVMContext &Context = getGlobalContext();
|
||||
llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
|
||||
|
||||
// Turn on -preserve-bc-uselistorder by default, but let the command-line
|
||||
// override it.
|
||||
setPreserveBitcodeUseListOrder(true);
|
||||
|
||||
cl::ParseCommandLineOptions(argc, argv, "llvm linker\n");
|
||||
|
||||
auto Composite = make_unique<Module>("llvm-link", Context);
|
||||
|
@ -150,10 +154,9 @@ int main(int argc, char **argv) {
|
|||
|
||||
if (Verbose) errs() << "Writing bitcode...\n";
|
||||
if (OutputAssembly) {
|
||||
Composite->print(Out.os(), nullptr, shouldPreserveAssemblyUseListOrder());
|
||||
Composite->print(Out.os(), nullptr, PreserveAssemblyUseListOrder);
|
||||
} else if (Force || !CheckBitcodeOutputToConsole(Out.os(), true))
|
||||
WriteBitcodeToFile(Composite.get(), Out.os(),
|
||||
shouldPreserveBitcodeUseListOrder());
|
||||
WriteBitcodeToFile(Composite.get(), Out.os(), PreserveBitcodeUseListOrder);
|
||||
|
||||
// Declare success.
|
||||
Out.keep();
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
#include "llvm/IR/LLVMContext.h"
|
||||
#include "llvm/IR/LegacyPassNameParser.h"
|
||||
#include "llvm/IR/Module.h"
|
||||
#include "llvm/IR/UseListOrder.h"
|
||||
#include "llvm/IR/Verifier.h"
|
||||
#include "llvm/IRReader/IRReader.h"
|
||||
#include "llvm/InitializePasses.h"
|
||||
|
@ -181,7 +180,15 @@ DefaultDataLayout("default-data-layout",
|
|||
cl::desc("data layout string to use if not specified by module"),
|
||||
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 inline void addPass(legacy::PassManagerBase &PM, Pass *P) {
|
||||
// Add the pass to the pass manager...
|
||||
|
@ -345,10 +352,6 @@ int main(int argc, char **argv) {
|
|||
polly::initializePollyPasses(Registry);
|
||||
#endif
|
||||
|
||||
// Turn on -preserve-bc-uselistorder by default, but let the command-line
|
||||
// override it.
|
||||
setPreserveBitcodeUseListOrder(true);
|
||||
|
||||
cl::ParseCommandLineOptions(argc, argv,
|
||||
"llvm .bc -> .bc modular optimizer and analysis printer\n");
|
||||
|
||||
|
@ -431,9 +434,8 @@ int main(int argc, char **argv) {
|
|||
// string. Hand off the rest of the functionality to the new code for that
|
||||
// layer.
|
||||
return runPassPipeline(argv[0], Context, *M, TM.get(), Out.get(),
|
||||
PassPipeline, OK, VK,
|
||||
shouldPreserveAssemblyUseListOrder(),
|
||||
shouldPreserveBitcodeUseListOrder())
|
||||
PassPipeline, OK, VK, PreserveAssemblyUseListOrder,
|
||||
PreserveBitcodeUseListOrder)
|
||||
? 0
|
||||
: 1;
|
||||
}
|
||||
|
@ -557,8 +559,8 @@ int main(int argc, char **argv) {
|
|||
}
|
||||
|
||||
if (PrintEachXForm)
|
||||
Passes.add(createPrintModulePass(errs(), "",
|
||||
shouldPreserveAssemblyUseListOrder()));
|
||||
Passes.add(
|
||||
createPrintModulePass(errs(), "", PreserveAssemblyUseListOrder));
|
||||
}
|
||||
|
||||
if (StandardLinkOpts) {
|
||||
|
@ -595,11 +597,11 @@ int main(int argc, char **argv) {
|
|||
// Write bitcode or assembly to the output as the last step...
|
||||
if (!NoOutput && !AnalyzeOnly) {
|
||||
if (OutputAssembly)
|
||||
Passes.add(createPrintModulePass(Out->os(), "",
|
||||
shouldPreserveAssemblyUseListOrder()));
|
||||
Passes.add(
|
||||
createPrintModulePass(Out->os(), "", PreserveAssemblyUseListOrder));
|
||||
else
|
||||
Passes.add(createBitcodeWriterPass(Out->os(),
|
||||
shouldPreserveBitcodeUseListOrder()));
|
||||
Passes.add(
|
||||
createBitcodeWriterPass(Out->os(), PreserveBitcodeUseListOrder));
|
||||
}
|
||||
|
||||
// Before executing passes, print the final values of the LLVM options.
|
||||
|
|
Loading…
Reference in New Issue