[llvm] r234968 - uselistorder: Pull the assembly bit up out of the printer

Duncan P. N. Exon Smith dexonsmith at apple.com
Tue Apr 14 19:12:42 PDT 2015


Author: dexonsmith
Date: Tue Apr 14 21:12:41 2015
New Revision: 234968

URL: http://llvm.org/viewvc/llvm-project?rev=234968&view=rev
Log:
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.

Modified:
    llvm/trunk/include/llvm/IR/Module.h
    llvm/trunk/lib/IR/AsmWriter.cpp
    llvm/trunk/lib/IR/IRPrintingPasses.cpp
    llvm/trunk/tools/llvm-dis/llvm-dis.cpp
    llvm/trunk/tools/llvm-link/llvm-link.cpp
    llvm/trunk/tools/verify-uselistorder/verify-uselistorder.cpp

Modified: llvm/trunk/include/llvm/IR/Module.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Module.h?rev=234968&r1=234967&r2=234968&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/Module.h (original)
+++ llvm/trunk/include/llvm/IR/Module.h Tue Apr 14 21:12:41 2015
@@ -642,8 +642,11 @@ public:
 /// @{
 
   /// Print the module to an output stream with an optional
-  /// AssemblyAnnotationWriter.
-  void print(raw_ostream &OS, AssemblyAnnotationWriter *AAW) const;
+  /// AssemblyAnnotationWriter.  If \c ShouldPreserveUseListOrder, then include
+  /// uselistorder directives so that use-lists can be recreated when reading
+  /// the assembly.
+  void print(raw_ostream &OS, AssemblyAnnotationWriter *AAW,
+             bool ShouldPreserveUseListOrder = false) const;
 
   /// Dump the module to stderr (for debugging).
   void dump() const;

Modified: llvm/trunk/lib/IR/AsmWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/AsmWriter.cpp?rev=234968&r1=234967&r2=234968&view=diff
==============================================================================
--- llvm/trunk/lib/IR/AsmWriter.cpp (original)
+++ llvm/trunk/lib/IR/AsmWriter.cpp Tue Apr 14 21:12:41 2015
@@ -3071,11 +3071,11 @@ void Function::print(raw_ostream &ROS, A
   W.printFunction(this);
 }
 
-void Module::print(raw_ostream &ROS, AssemblyAnnotationWriter *AAW) const {
+void Module::print(raw_ostream &ROS, AssemblyAnnotationWriter *AAW,
+                   bool ShouldPreserveUseListOrder) const {
   SlotTracker SlotTable(this);
   formatted_raw_ostream OS(ROS);
-  AssemblyWriter W(OS, SlotTable, this, AAW,
-                   shouldPreserveAssemblyUseListOrder());
+  AssemblyWriter W(OS, SlotTable, this, AAW, ShouldPreserveUseListOrder);
   W.printModule(this);
 }
 

Modified: llvm/trunk/lib/IR/IRPrintingPasses.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/IRPrintingPasses.cpp?rev=234968&r1=234967&r2=234968&view=diff
==============================================================================
--- llvm/trunk/lib/IR/IRPrintingPasses.cpp (original)
+++ llvm/trunk/lib/IR/IRPrintingPasses.cpp Tue Apr 14 21:12:41 2015
@@ -15,6 +15,7 @@
 #include "llvm/IR/Function.h"
 #include "llvm/IR/Module.h"
 #include "llvm/IR/PassManager.h"
+#include "llvm/IR/UseListOrder.h"
 #include "llvm/Pass.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/raw_ostream.h"
@@ -25,7 +26,8 @@ PrintModulePass::PrintModulePass(raw_ost
     : OS(OS), Banner(Banner) {}
 
 PreservedAnalyses PrintModulePass::run(Module &M) {
-  OS << Banner << M;
+  OS << Banner;
+  M.print(OS, nullptr, shouldPreserveAssemblyUseListOrder());
   return PreservedAnalyses::all();
 }
 

Modified: llvm/trunk/tools/llvm-dis/llvm-dis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-dis/llvm-dis.cpp?rev=234968&r1=234967&r2=234968&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-dis/llvm-dis.cpp (original)
+++ llvm/trunk/tools/llvm-dis/llvm-dis.cpp Tue Apr 14 21:12:41 2015
@@ -25,6 +25,7 @@
 #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"
@@ -189,7 +190,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());
+    M->print(Out->os(), Annotator.get(), shouldPreserveAssemblyUseListOrder());
 
   // Declare success.
   Out->keep();

Modified: llvm/trunk/tools/llvm-link/llvm-link.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-link/llvm-link.cpp?rev=234968&r1=234967&r2=234968&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-link/llvm-link.cpp (original)
+++ llvm/trunk/tools/llvm-link/llvm-link.cpp Tue Apr 14 21:12:41 2015
@@ -150,7 +150,7 @@ int main(int argc, char **argv) {
 
   if (Verbose) errs() << "Writing bitcode...\n";
   if (OutputAssembly) {
-    Out.os() << *Composite;
+    Composite->print(Out.os(), nullptr, shouldPreserveAssemblyUseListOrder());
   } else if (Force || !CheckBitcodeOutputToConsole(Out.os(), true))
     WriteBitcodeToFile(Composite.get(), Out.os(),
                        shouldPreserveBitcodeUseListOrder());

Modified: llvm/trunk/tools/verify-uselistorder/verify-uselistorder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/verify-uselistorder/verify-uselistorder.cpp?rev=234968&r1=234967&r2=234968&view=diff
==============================================================================
--- llvm/trunk/tools/verify-uselistorder/verify-uselistorder.cpp (original)
+++ llvm/trunk/tools/verify-uselistorder/verify-uselistorder.cpp Tue Apr 14 21:12:41 2015
@@ -144,7 +144,7 @@ bool TempFile::writeAssembly(const Modul
     return true;
   }
 
-  OS << M;
+  M.print(OS, nullptr, /* ShouldPreserveUseListOrder */ true);
   return false;
 }
 
@@ -540,14 +540,8 @@ int main(int argc, char **argv) {
     return 1;
   }
 
-  outs() << "*** verify-uselistorder ***\n";
-  // Can't verify if order isn't preserved.
-  if (!shouldPreserveAssemblyUseListOrder()) {
-    errs() << "warning: forcing -preserve-ll-uselistorder\n";
-    setPreserveAssemblyUseListOrder(true);
-  }
-
   // Verify the use lists now and after reversing them.
+  outs() << "*** verify-uselistorder ***\n";
   verifyUseListOrder(*M);
   outs() << "reverse\n";
   reverseUseLists(*M);





More information about the llvm-commits mailing list