<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Apr 14, 2015 at 11:46 AM, Duncan P. N. Exon Smith <span dir="ltr"><<a href="mailto:dexonsmith@apple.com" target="_blank">dexonsmith@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br>
> On 2015-Apr-14, at 11:42, David Blaikie <<a href="mailto:dblaikie@gmail.com">dblaikie@gmail.com</a>> wrote:<br>
><br>
><br>
><br>
> On Tue, Apr 14, 2015 at 11:33 AM, Duncan P. N. Exon Smith <<a href="mailto:dexonsmith@apple.com">dexonsmith@apple.com</a>> wrote:<br>
> Author: dexonsmith<br>
> Date: Tue Apr 14 13:33:00 2015<br>
> New Revision: 234921<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=234921&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=234921&view=rev</a><br>
> Log:<br>
> IR: Set -preserve-bc-uselistorder=false by default<br>
><br>
> But keep it on by default in `llvm-as`, `opt`, `bugpoint`, `llvm-link`,<br>
> `llvm-extract`, and `LTOCodeGenerator`.<br>
><br>
> Hmm - what's LTOCodeGenerator used for? If it's a standard library utility used in production pipelines it might make more sense for it to default-off & users can opt-in when necessary?<br>
<br>
</span>The usual flow for libLTO.dylib is "read bitcode, link, optimize, codegen,<br>
write object". Writing bitcode is used, e.g., by `ld -save-temps`.<br></blockquote><div><br>LTOCodeGenerator is only used to actually generating bitcode from LTO-merged modules?<br><br>Also, what's the deal with global state? (just realizing now that the "setPreserveBitcodeUseListOrder" is just a global function, not LLVMContext, etc) - that seems like the sort of thing I'd be even more inclined to push up into the actual utilities very directly, so there's no libraries quietly tweaking this global state in surprising ways. Not sure what sort of ideas on exceptions to the "avoid global state because we're a library" we have for these sort of things & how to limit their creep.<br><br>- David<br><br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5"><br>
><br>
> Part of PR5680.<br>
><br>
> Modified:<br>
> llvm/trunk/lib/IR/UseListOrder.cpp<br>
> llvm/trunk/lib/LTO/LTOCodeGenerator.cpp<br>
> llvm/trunk/tools/bugpoint/bugpoint.cpp<br>
> llvm/trunk/tools/llvm-as/llvm-as.cpp<br>
> llvm/trunk/tools/llvm-extract/llvm-extract.cpp<br>
> llvm/trunk/tools/llvm-link/llvm-link.cpp<br>
> llvm/trunk/tools/opt/opt.cpp<br>
><br>
> Modified: llvm/trunk/lib/IR/UseListOrder.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/UseListOrder.cpp?rev=234921&r1=234920&r2=234921&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/UseListOrder.cpp?rev=234921&r1=234920&r2=234921&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/lib/IR/UseListOrder.cpp (original)<br>
> +++ llvm/trunk/lib/IR/UseListOrder.cpp Tue Apr 14 13:33:00 2015<br>
> @@ -19,7 +19,7 @@ using namespace llvm;<br>
> static cl::opt<bool> PreserveBitcodeUseListOrder(<br>
> "preserve-bc-uselistorder",<br>
> cl::desc("Preserve use-list order when writing LLVM bitcode."),<br>
> - cl::init(true), cl::Hidden);<br>
> + cl::init(false), cl::Hidden);<br>
><br>
> static cl::opt<bool> PreserveAssemblyUseListOrder(<br>
> "preserve-ll-uselistorder",<br>
><br>
> Modified: llvm/trunk/lib/LTO/LTOCodeGenerator.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/LTO/LTOCodeGenerator.cpp?rev=234921&r1=234920&r2=234921&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/LTO/LTOCodeGenerator.cpp?rev=234921&r1=234920&r2=234921&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/lib/LTO/LTOCodeGenerator.cpp (original)<br>
> +++ llvm/trunk/lib/LTO/LTOCodeGenerator.cpp Tue Apr 14 13:33:00 2015<br>
> @@ -29,6 +29,7 @@<br>
> #include "llvm/IR/LegacyPassManager.h"<br>
> #include "llvm/IR/Mangler.h"<br>
> #include "llvm/IR/Module.h"<br>
> +#include "llvm/IR/UseListOrder.h"<br>
> #include "llvm/IR/Verifier.h"<br>
> #include "llvm/InitializePasses.h"<br>
> #include "llvm/LTO/LTOModule.h"<br>
> @@ -603,6 +604,10 @@ void LTOCodeGenerator::setCodeGenDebugOp<br>
> }<br>
><br>
> void LTOCodeGenerator::parseCodeGenDebugOptions() {<br>
> + // Turn on -preserve-bc-uselistorder by default, but let the command-line<br>
> + // override it.<br>
> + setPreserveBitcodeUseListOrder(true);<span style="color:rgb(34,34,34)"> </span></div></div></blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">
> +<br>
> // if options were requested, set them<br>
> if (!CodegenOptions.empty())<br>
> cl::ParseCommandLineOptions(CodegenOptions.size(),<br>
><br>
> Modified: llvm/trunk/tools/bugpoint/bugpoint.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint/bugpoint.cpp?rev=234921&r1=234920&r2=234921&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint/bugpoint.cpp?rev=234921&r1=234920&r2=234921&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/tools/bugpoint/bugpoint.cpp (original)<br>
> +++ llvm/trunk/tools/bugpoint/bugpoint.cpp Tue Apr 14 13:33:00 2015<br>
> @@ -18,6 +18,7 @@<br>
> #include "llvm/IR/LLVMContext.h"<br>
> #include "llvm/IR/LegacyPassManager.h"<br>
> #include "llvm/IR/LegacyPassNameParser.h"<br>
> +#include "llvm/IR/UseListOrder.h"<br>
> #include "llvm/LinkAllIR.h"<br>
> #include "llvm/LinkAllPasses.h"<br>
> #include "llvm/Support/CommandLine.h"<br>
> @@ -136,6 +137,10 @@ int main(int argc, char **argv) {<br>
> polly::initializePollyPasses(Registry);<br>
> #endif<br>
><br>
> + // Turn on -preserve-bc-uselistorder by default, but let the command-line<br>
> + // override it.<br>
> + setPreserveBitcodeUseListOrder(true);<br>
> +<br>
> cl::ParseCommandLineOptions(argc, argv,<br>
> "LLVM automatic testcase reducer. See\nhttp://"<br>
> "<a href="http://llvm.org/cmds/bugpoint.html" target="_blank">llvm.org/cmds/bugpoint.html</a>"<br>
><br>
> Modified: llvm/trunk/tools/llvm-as/llvm-as.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-as/llvm-as.cpp?rev=234921&r1=234920&r2=234921&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-as/llvm-as.cpp?rev=234921&r1=234920&r2=234921&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/tools/llvm-as/llvm-as.cpp (original)<br>
> +++ llvm/trunk/tools/llvm-as/llvm-as.cpp Tue Apr 14 13:33:00 2015<br>
> @@ -19,6 +19,7 @@<br>
> #include "llvm/AsmParser/Parser.h"<br>
> #include "llvm/Bitcode/ReaderWriter.h"<br>
> #include "llvm/IR/Module.h"<br>
> +#include "llvm/IR/UseListOrder.h"<br>
> #include "llvm/IR/Verifier.h"<br>
> #include "llvm/Support/CommandLine.h"<br>
> #include "llvm/Support/FileSystem.h"<br>
> @@ -90,6 +91,11 @@ int main(int argc, char **argv) {<br>
> PrettyStackTraceProgram X(argc, argv);<br>
> LLVMContext &Context = getGlobalContext();<br>
> llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.<br>
> +<br>
> + // Turn on -preserve-bc-uselistorder by default, but let the command-line<br>
> + // override it.<br>
> + setPreserveBitcodeUseListOrder(true);<br>
> +<br>
> cl::ParseCommandLineOptions(argc, argv, "llvm .ll -> .bc assembler\n");<br>
><br>
> // Parse the file now...<br>
><br>
> Modified: llvm/trunk/tools/llvm-extract/llvm-extract.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-extract/llvm-extract.cpp?rev=234921&r1=234920&r2=234921&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-extract/llvm-extract.cpp?rev=234921&r1=234920&r2=234921&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/tools/llvm-extract/llvm-extract.cpp (original)<br>
> +++ llvm/trunk/tools/llvm-extract/llvm-extract.cpp Tue Apr 14 13:33:00 2015<br>
> @@ -19,6 +19,7 @@<br>
> #include "llvm/IR/IRPrintingPasses.h"<br>
> #include "llvm/IR/LLVMContext.h"<br>
> #include "llvm/IR/Module.h"<br>
> +#include "llvm/IR/UseListOrder.h"<br>
> #include "llvm/IRReader/IRReader.h"<br>
> #include "llvm/IR/LegacyPassManager.h"<br>
> #include "llvm/Support/CommandLine.h"<br>
> @@ -97,6 +98,11 @@ int main(int argc, char **argv) {<br>
><br>
> LLVMContext &Context = getGlobalContext();<br>
> llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.<br>
> +<br>
> + // Turn on -preserve-bc-uselistorder by default, but let the command-line<br>
> + // override it.<br>
> + setPreserveBitcodeUseListOrder(true);<br>
> +<br>
> cl::ParseCommandLineOptions(argc, argv, "llvm extractor\n");<br>
><br>
> // Use lazy loading, since we only care about selected global values.<br>
><br>
> Modified: llvm/trunk/tools/llvm-link/llvm-link.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-link/llvm-link.cpp?rev=234921&r1=234920&r2=234921&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-link/llvm-link.cpp?rev=234921&r1=234920&r2=234921&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/tools/llvm-link/llvm-link.cpp (original)<br>
> +++ llvm/trunk/tools/llvm-link/llvm-link.cpp Tue Apr 14 13:33:00 2015<br>
> @@ -20,6 +20,7 @@<br>
> #include "llvm/IR/DiagnosticPrinter.h"<br>
> #include "llvm/IR/LLVMContext.h"<br>
> #include "llvm/IR/Module.h"<br>
> +#include "llvm/IR/UseListOrder.h"<br>
> #include "llvm/IR/Verifier.h"<br>
> #include "llvm/IRReader/IRReader.h"<br>
> #include "llvm/Support/CommandLine.h"<br>
> @@ -104,6 +105,11 @@ int main(int argc, char **argv) {<br>
><br>
> LLVMContext &Context = getGlobalContext();<br>
> llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.<br>
> +<br>
> + // Turn on -preserve-bc-uselistorder by default, but let the command-line<br>
> + // override it.<br>
> + setPreserveBitcodeUseListOrder(true);<br>
> +<br>
> cl::ParseCommandLineOptions(argc, argv, "llvm linker\n");<br>
><br>
> auto Composite = make_unique<Module>("llvm-link", Context);<br>
><br>
> Modified: llvm/trunk/tools/opt/opt.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/opt/opt.cpp?rev=234921&r1=234920&r2=234921&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/opt/opt.cpp?rev=234921&r1=234920&r2=234921&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/tools/opt/opt.cpp (original)<br>
> +++ llvm/trunk/tools/opt/opt.cpp Tue Apr 14 13:33:00 2015<br>
> @@ -30,6 +30,7 @@<br>
> #include "llvm/IR/LLVMContext.h"<br>
> #include "llvm/IR/LegacyPassNameParser.h"<br>
> #include "llvm/IR/Module.h"<br>
> +#include "llvm/IR/UseListOrder.h"<br>
> #include "llvm/IR/Verifier.h"<br>
> #include "llvm/IRReader/IRReader.h"<br>
> #include "llvm/InitializePasses.h"<br>
> @@ -344,6 +345,10 @@ int main(int argc, char **argv) {<br>
> polly::initializePollyPasses(Registry);<br>
> #endif<br>
><br>
> + // Turn on -preserve-bc-uselistorder by default, but let the command-line<br>
> + // override it.<br>
> + setPreserveBitcodeUseListOrder(true);<br>
> +<br>
> cl::ParseCommandLineOptions(argc, argv,<br>
> "llvm .bc -> .bc modular optimizer and analysis printer\n");<br>
><br>
><br>
><br>
> _______________________________________________<br>
> llvm-commits mailing list<br>
> <a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
><br>
<br>
</div></div></blockquote></div><br></div></div>