llvm.org GIT mirror llvm / 8b376eb
uselistorder: Pull the assembly bit up out of the printer Pull the `-preserve-ll-uselistorder` bit up through all the callers of `Module::print()`. I converted callers of `operator<<` to `Module::print()` where necessary to pull the bit through. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234968 91177308-0d34-0410-b5e6-96231b3b80d8 Duncan P. N. Exon Smith 4 years ago
6 changed file(s) with 16 addition(s) and 16 deletion(s). Raw diff Collapse all Expand all
641641 /// @{
642642
643643 /// Print the module to an output stream with an optional
644 /// AssemblyAnnotationWriter.
645 void print(raw_ostream &OS, AssemblyAnnotationWriter *AAW) const;
644 /// AssemblyAnnotationWriter. If \c ShouldPreserveUseListOrder, then include
645 /// uselistorder directives so that use-lists can be recreated when reading
646 /// the assembly.
647 void print(raw_ostream &OS, AssemblyAnnotationWriter *AAW,
648 bool ShouldPreserveUseListOrder = false) const;
646649
647650 /// Dump the module to stderr (for debugging).
648651 void dump() const;
30703070 W.printFunction(this);
30713071 }
30723072
3073 void Module::print(raw_ostream &ROS, AssemblyAnnotationWriter *AAW) const {
3073 void Module::print(raw_ostream &ROS, AssemblyAnnotationWriter *AAW,
3074 bool ShouldPreserveUseListOrder) const {
30743075 SlotTracker SlotTable(this);
30753076 formatted_raw_ostream OS(ROS);
3076 AssemblyWriter W(OS, SlotTable, this, AAW,
3077 shouldPreserveAssemblyUseListOrder());
3077 AssemblyWriter W(OS, SlotTable, this, AAW, ShouldPreserveUseListOrder);
30783078 W.printModule(this);
30793079 }
30803080
1414 #include "llvm/IR/Function.h"
1515 #include "llvm/IR/Module.h"
1616 #include "llvm/IR/PassManager.h"
17 #include "llvm/IR/UseListOrder.h"
1718 #include "llvm/Pass.h"
1819 #include "llvm/Support/Debug.h"
1920 #include "llvm/Support/raw_ostream.h"
2425 : OS(OS), Banner(Banner) {}
2526
2627 PreservedAnalyses PrintModulePass::run(Module &M) {
27 OS << Banner << M;
28 OS << Banner;
29 M.print(OS, nullptr, shouldPreserveAssemblyUseListOrder());
2830 return PreservedAnalyses::all();
2931 }
3032
2424 #include "llvm/IR/IntrinsicInst.h"
2525 #include "llvm/IR/Module.h"
2626 #include "llvm/IR/Type.h"
27 #include "llvm/IR/UseListOrder.h"
2728 #include "llvm/Support/CommandLine.h"
2829 #include "llvm/Support/DataStream.h"
2930 #include "llvm/Support/FileSystem.h"
188189
189190 // All that llvm-dis does is write the assembly to a file.
190191 if (!DontPrint)
191 M->print(Out->os(), Annotator.get());
192 M->print(Out->os(), Annotator.get(), shouldPreserveAssemblyUseListOrder());
192193
193194 // Declare success.
194195 Out->keep();
149149
150150 if (Verbose) errs() << "Writing bitcode...\n";
151151 if (OutputAssembly) {
152 Out.os() << *Composite;
152 Composite->print(Out.os(), nullptr, shouldPreserveAssemblyUseListOrder());
153153 } else if (Force || !CheckBitcodeOutputToConsole(Out.os(), true))
154154 WriteBitcodeToFile(Composite.get(), Out.os(),
155155 shouldPreserveBitcodeUseListOrder());
143143 return true;
144144 }
145145
146 OS << M;
146 M.print(OS, nullptr, /* ShouldPreserveUseListOrder */ true);
147147 return false;
148148 }
149149
539539 return 1;
540540 }
541541
542 // Verify the use lists now and after reversing them.
542543 outs() << "*** verify-uselistorder ***\n";
543 // Can't verify if order isn't preserved.
544 if (!shouldPreserveAssemblyUseListOrder()) {
545 errs() << "warning: forcing -preserve-ll-uselistorder\n";
546 setPreserveAssemblyUseListOrder(true);
547 }
548
549 // Verify the use lists now and after reversing them.
550544 verifyUseListOrder(*M);
551545 outs() << "reverse\n";
552546 reverseUseLists(*M);