llvm.org GIT mirror llvm / 8d61ee9
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234973 91177308-0d34-0410-b5e6-96231b3b80d8 Duncan P. N. Exon Smith 4 years ago
12 changed file(s) with 62 addition(s) and 108 deletion(s). Raw diff Collapse all Expand all
5050
5151 typedef std::vector UseListOrderStack;
5252
53 /// \brief Whether to preserve use-list ordering.
54 bool shouldPreserveBitcodeUseListOrder();
55 bool shouldPreserveAssemblyUseListOrder();
56 void setPreserveBitcodeUseListOrder(bool ShouldPreserve);
57 void setPreserveAssemblyUseListOrder(bool ShouldPreserve);
58
5953 } // end namespace llvm
6054
6155 #endif
1414 #include "llvm/Bitcode/ReaderWriter.h"
1515 #include "llvm/IR/Module.h"
1616 #include "llvm/IR/PassManager.h"
17 #include "llvm/IR/UseListOrder.h"
1817 #include "llvm/Pass.h"
1918 using namespace llvm;
2019
4040 Type.cpp
4141 TypeFinder.cpp
4242 Use.cpp
43 UseListOrder.cpp
4443 User.cpp
4544 Value.cpp
4645 ValueSymbolTable.cpp
+0
-43
lib/IR/UseListOrder.cpp less more
None //===- UseListOrder.cpp - Implement Use List Order ------------------------===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // Implement structures and command-line options for preserving use-list order.
10 //
11 //===----------------------------------------------------------------------===//
12
13 #include "llvm/IR/UseListOrder.h"
14 #include "llvm/Support/CommandLine.h"
15
16 using namespace llvm;
17
18 static cl::opt PreserveBitcodeUseListOrder(
19 "preserve-bc-uselistorder",
20 cl::desc("Preserve use-list order when writing LLVM bitcode."),
21 cl::init(false), cl::Hidden);
22
23 static cl::opt PreserveAssemblyUseListOrder(
24 "preserve-ll-uselistorder",
25 cl::desc("Preserve use-list order when writing LLVM assembly."),
26 cl::init(false), cl::Hidden);
27
28 bool llvm::shouldPreserveBitcodeUseListOrder() {
29 return PreserveBitcodeUseListOrder;
30 }
31
32 bool llvm::shouldPreserveAssemblyUseListOrder() {
33 return PreserveAssemblyUseListOrder;
34 }
35
36 void llvm::setPreserveBitcodeUseListOrder(bool ShouldPreserve) {
37 PreserveBitcodeUseListOrder = ShouldPreserve;
38 }
39
40 void llvm::setPreserveAssemblyUseListOrder(bool ShouldPreserve) {
41 PreserveAssemblyUseListOrder = ShouldPreserve;
42 }
2828 #include "llvm/IR/LegacyPassManager.h"
2929 #include "llvm/IR/Mangler.h"
3030 #include "llvm/IR/Module.h"
31 #include "llvm/IR/UseListOrder.h"
3231 #include "llvm/IR/Verifier.h"
3332 #include "llvm/InitializePasses.h"
3433 #include "llvm/LTO/LTOModule.h"
215214
216215 // write bitcode to it
217216 WriteBitcodeToFile(IRLinker.getModule(), Out.os(),
218 shouldPreserveBitcodeUseListOrder());
217 /* ShouldPreserveUseListOrder */ true);
219218 Out.os().close();
220219
221220 if (Out.os().has_error()) {
605604 }
606605
607606 void LTOCodeGenerator::parseCodeGenDebugOptions() {
608 // Turn on -preserve-bc-uselistorder by default, but let the command-line
609 // override it.
610 setPreserveBitcodeUseListOrder(true);
611
612607 // if options were requested, set them
613608 if (!CodegenOptions.empty())
614609 cl::ParseCommandLineOptions(CodegenOptions.size(),
1919 #include "llvm/IR/DataLayout.h"
2020 #include "llvm/IR/LegacyPassManager.h"
2121 #include "llvm/IR/Module.h"
22 #include "llvm/IR/UseListOrder.h"
2322 #include "llvm/IR/Verifier.h"
2423 #include "llvm/Support/CommandLine.h"
2524 #include "llvm/Support/Debug.h"
4241 extern cl::opt OutputPrefix;
4342 }
4443
44 static cl::opt PreserveBitcodeUseListOrder(
45 "preserve-bc-uselistorder",
46 cl::desc("Preserve use-list order when writing LLVM bitcode."),
47 cl::init(true), cl::Hidden);
48
4549 namespace {
4650 // ChildOutput - This option captures the name of the child output file that
4751 // is set up by the parent bugpoint process
5559 /// file. If an error occurs, true is returned.
5660 ///
5761 static bool writeProgramToFileAux(tool_output_file &Out, const Module *M) {
58 WriteBitcodeToFile(M, Out.os(), shouldPreserveBitcodeUseListOrder());
62 WriteBitcodeToFile(M, Out.os(), PreserveBitcodeUseListOrder);
5963 Out.os().close();
6064 if (!Out.os().has_error()) {
6165 Out.keep();
151155
152156 tool_output_file InFile(InputFilename, InputFD);
153157
154 WriteBitcodeToFile(Program, InFile.os(), shouldPreserveBitcodeUseListOrder());
158 WriteBitcodeToFile(Program, InFile.os(), PreserveBitcodeUseListOrder);
155159 InFile.os().close();
156160 if (InFile.os().has_error()) {
157161 errs() << "Error writing bitcode file: " << InputFilename << "\n";
1717 #include "llvm/IR/LLVMContext.h"
1818 #include "llvm/IR/LegacyPassManager.h"
1919 #include "llvm/IR/LegacyPassNameParser.h"
20 #include "llvm/IR/UseListOrder.h"
2120 #include "llvm/LinkAllIR.h"
2221 #include "llvm/LinkAllPasses.h"
2322 #include "llvm/Support/CommandLine.h"
136135 polly::initializePollyPasses(Registry);
137136 #endif
138137
139 // Turn on -preserve-bc-uselistorder by default, but let the command-line
140 // override it.
141 setPreserveBitcodeUseListOrder(true);
142
143138 cl::ParseCommandLineOptions(argc, argv,
144139 "LLVM automatic testcase reducer. See\nhttp://"
145140 "llvm.org/cmds/bugpoint.html"
1818 #include "llvm/AsmParser/Parser.h"
1919 #include "llvm/Bitcode/ReaderWriter.h"
2020 #include "llvm/IR/Module.h"
21 #include "llvm/IR/UseListOrder.h"
2221 #include "llvm/IR/Verifier.h"
2322 #include "llvm/Support/CommandLine.h"
2423 #include "llvm/Support/FileSystem.h"
5150 DisableVerify("disable-verify", cl::Hidden,
5251 cl::desc("Do not run verifier on input LLVM (dangerous!)"));
5352
53 static cl::opt PreserveBitcodeUseListOrder(
54 "preserve-bc-uselistorder",
55 cl::desc("Preserve use-list order when writing LLVM bitcode."),
56 cl::init(true), cl::Hidden);
57
5458 static void WriteOutputFile(const Module *M) {
5559 // Infer the output filename if needed.
5660 if (OutputFilename.empty()) {
7882 }
7983
8084 if (Force || !CheckBitcodeOutputToConsole(Out->os(), true))
81 WriteBitcodeToFile(M, Out->os(), shouldPreserveBitcodeUseListOrder());
85 WriteBitcodeToFile(M, Out->os(), PreserveBitcodeUseListOrder);
8286
8387 // Declare success.
8488 Out->keep();
9094 PrettyStackTraceProgram X(argc, argv);
9195 LLVMContext &Context = getGlobalContext();
9296 llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
93
94 // Turn on -preserve-bc-uselistorder by default, but let the command-line
95 // override it.
96 setPreserveBitcodeUseListOrder(true);
97
9897 cl::ParseCommandLineOptions(argc, argv, "llvm .ll -> .bc assembler\n");
9998
10099 // Parse the file now...
2424 #include "llvm/IR/IntrinsicInst.h"
2525 #include "llvm/IR/Module.h"
2626 #include "llvm/IR/Type.h"
27 #include "llvm/IR/UseListOrder.h"
2827 #include "llvm/Support/CommandLine.h"
2928 #include "llvm/Support/DataStream.h"
3029 #include "llvm/Support/FileSystem.h"
5352 static cl::opt
5453 ShowAnnotations("show-annotations",
5554 cl::desc("Add informational comments to the .ll file"));
55
56 static cl::opt PreserveAssemblyUseListOrder(
57 "preserve-ll-uselistorder",
58 cl::desc("Preserve use-list order when writing LLVM assembly."),
59 cl::init(false), cl::Hidden);
5660
5761 namespace {
5862
189193
190194 // All that llvm-dis does is write the assembly to a file.
191195 if (!DontPrint)
192 M->print(Out->os(), Annotator.get(), shouldPreserveAssemblyUseListOrder());
196 M->print(Out->os(), Annotator.get(), PreserveAssemblyUseListOrder);
193197
194198 // Declare success.
195199 Out->keep();
1818 #include "llvm/IR/IRPrintingPasses.h"
1919 #include "llvm/IR/LLVMContext.h"
2020 #include "llvm/IR/Module.h"
21 #include "llvm/IR/UseListOrder.h"
2221 #include "llvm/IRReader/IRReader.h"
2322 #include "llvm/IR/LegacyPassManager.h"
2423 #include "llvm/Support/CommandLine.h"
9089 OutputAssembly("S",
9190 cl::desc("Write output as LLVM assembly"), cl::Hidden);
9291
92 static cl::opt PreserveBitcodeUseListOrder(
93 "preserve-bc-uselistorder",
94 cl::desc("Preserve use-list order when writing LLVM bitcode."),
95 cl::init(true), cl::Hidden);
96
97 static cl::opt PreserveAssemblyUseListOrder(
98 "preserve-ll-uselistorder",
99 cl::desc("Preserve use-list order when writing LLVM assembly."),
100 cl::init(false), cl::Hidden);
101
93102 int main(int argc, char **argv) {
94103 // Print a stack trace if we signal out.
95104 sys::PrintStackTraceOnErrorSignal();
97106
98107 LLVMContext &Context = getGlobalContext();
99108 llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
100
101 // Turn on -preserve-bc-uselistorder by default, but let the command-line
102 // override it.
103 setPreserveBitcodeUseListOrder(true);
104
105109 cl::ParseCommandLineOptions(argc, argv, "llvm extractor\n");
106110
107111 // Use lazy loading, since we only care about selected global values.
269273 }
270274
271275 if (OutputAssembly)
272 Passes.add(createPrintModulePass(Out.os(), "",
273 shouldPreserveAssemblyUseListOrder()));
276 Passes.add(
277 createPrintModulePass(Out.os(), "", PreserveAssemblyUseListOrder));
274278 else if (Force || !CheckBitcodeOutputToConsole(Out.os(), true))
275 Passes.add(
276 createBitcodeWriterPass(Out.os(), shouldPreserveBitcodeUseListOrder()));
279 Passes.add(createBitcodeWriterPass(Out.os(), PreserveBitcodeUseListOrder));
277280
278281 Passes.run(*M.get());
279282
1919 #include "llvm/IR/DiagnosticPrinter.h"
2020 #include "llvm/IR/LLVMContext.h"
2121 #include "llvm/IR/Module.h"
22 #include "llvm/IR/UseListOrder.h"
2322 #include "llvm/IR/Verifier.h"
2423 #include "llvm/IRReader/IRReader.h"
2524 #include "llvm/Support/CommandLine.h"
5857 static cl::opt
5958 SuppressWarnings("suppress-warnings", cl::desc("Suppress all linking warnings"),
6059 cl::init(false));
60
61 static cl::opt PreserveBitcodeUseListOrder(
62 "preserve-bc-uselistorder",
63 cl::desc("Preserve use-list order when writing LLVM bitcode."),
64 cl::init(true), cl::Hidden);
65
66 static cl::opt PreserveAssemblyUseListOrder(
67 "preserve-ll-uselistorder",
68 cl::desc("Preserve use-list order when writing LLVM assembly."),
69 cl::init(false), cl::Hidden);
6170
6271 // Read the specified bitcode file in and return it. This routine searches the
6372 // link path for the specified file to try to find it...
104113
105114 LLVMContext &Context = getGlobalContext();
106115 llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
107
108 // Turn on -preserve-bc-uselistorder by default, but let the command-line
109 // override it.
110 setPreserveBitcodeUseListOrder(true);
111
112116 cl::ParseCommandLineOptions(argc, argv, "llvm linker\n");
113117
114118 auto Composite = make_unique("llvm-link", Context);
149153
150154 if (Verbose) errs() << "Writing bitcode...\n";
151155 if (OutputAssembly) {
152 Composite->print(Out.os(), nullptr, shouldPreserveAssemblyUseListOrder());
156 Composite->print(Out.os(), nullptr, PreserveAssemblyUseListOrder);
153157 } else if (Force || !CheckBitcodeOutputToConsole(Out.os(), true))
154 WriteBitcodeToFile(Composite.get(), Out.os(),
155 shouldPreserveBitcodeUseListOrder());
158 WriteBitcodeToFile(Composite.get(), Out.os(), PreserveBitcodeUseListOrder);
156159
157160 // Declare success.
158161 Out.keep();
2929 #include "llvm/IR/LLVMContext.h"
3030 #include "llvm/IR/LegacyPassNameParser.h"
3131 #include "llvm/IR/Module.h"
32 #include "llvm/IR/UseListOrder.h"
3332 #include "llvm/IR/Verifier.h"
3433 #include "llvm/IRReader/IRReader.h"
3534 #include "llvm/InitializePasses.h"
180179 cl::desc("data layout string to use if not specified by module"),
181180 cl::value_desc("layout-string"), cl::init(""));
182181
183
182 static cl::opt PreserveBitcodeUseListOrder(
183 "preserve-bc-uselistorder",
184 cl::desc("Preserve use-list order when writing LLVM bitcode."),
185 cl::init(true), cl::Hidden);
186
187 static cl::opt PreserveAssemblyUseListOrder(
188 "preserve-ll-uselistorder",
189 cl::desc("Preserve use-list order when writing LLVM assembly."),
190 cl::init(false), cl::Hidden);
184191
185192 static inline void addPass(legacy::PassManagerBase &PM, Pass *P) {
186193 // Add the pass to the pass manager...
344351 polly::initializePollyPasses(Registry);
345352 #endif
346353
347 // Turn on -preserve-bc-uselistorder by default, but let the command-line
348 // override it.
349 setPreserveBitcodeUseListOrder(true);
350
351354 cl::ParseCommandLineOptions(argc, argv,
352355 "llvm .bc -> .bc modular optimizer and analysis printer\n");
353356
430433 // string. Hand off the rest of the functionality to the new code for that
431434 // layer.
432435 return runPassPipeline(argv[0], Context, *M, TM.get(), Out.get(),
433 PassPipeline, OK, VK,
434 shouldPreserveAssemblyUseListOrder(),
435 shouldPreserveBitcodeUseListOrder())
436 PassPipeline, OK, VK, PreserveAssemblyUseListOrder,
437 PreserveBitcodeUseListOrder)
436438 ? 0
437439 : 1;
438440 }
556558 }
557559
558560 if (PrintEachXForm)
559 Passes.add(createPrintModulePass(errs(), "",
560 shouldPreserveAssemblyUseListOrder()));
561 Passes.add(
562 createPrintModulePass(errs(), "", PreserveAssemblyUseListOrder));
561563 }
562564
563565 if (StandardLinkOpts) {
594596 // Write bitcode or assembly to the output as the last step...
595597 if (!NoOutput && !AnalyzeOnly) {
596598 if (OutputAssembly)
597 Passes.add(createPrintModulePass(Out->os(), "",
598 shouldPreserveAssemblyUseListOrder()));
599 Passes.add(
600 createPrintModulePass(Out->os(), "", PreserveAssemblyUseListOrder));
599601 else
600 Passes.add(createBitcodeWriterPass(Out->os(),
601 shouldPreserveBitcodeUseListOrder()));
602 Passes.add(
603 createBitcodeWriterPass(Out->os(), PreserveBitcodeUseListOrder));
602604 }
603605
604606 // Before executing passes, print the final values of the LLVM options.