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
/// @{
/// 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;
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);
}
#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"
: OS(OS), Banner(Banner) {}
PreservedAnalyses PrintModulePass::run(Module &M) {
- OS << Banner << M;
+ OS << Banner;
+ M.print(OS, nullptr, shouldPreserveAssemblyUseListOrder());
return PreservedAnalyses::all();
}
#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"
// 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();
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());
return true;
}
- OS << M;
+ M.print(OS, nullptr, /* ShouldPreserveUseListOrder */ true);
return false;
}
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);