summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2015-04-15 02:12:41 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2015-04-15 02:12:41 +0000
commitc4f0a325a7a1dde8780a740bca06705df3d7f58e (patch)
tree1542ebdb0ccae60ad9dabd78806c87f85f69ee5f /llvm
parent89010d8356507e5ed6cf6d67d8327530d01499ff (diff)
downloadbcm5719-llvm-c4f0a325a7a1dde8780a740bca06705df3d7f58e.tar.gz
bcm5719-llvm-c4f0a325a7a1dde8780a740bca06705df3d7f58e.zip
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. llvm-svn: 234968
Diffstat (limited to 'llvm')
-rw-r--r--llvm/include/llvm/IR/Module.h7
-rw-r--r--llvm/lib/IR/AsmWriter.cpp6
-rw-r--r--llvm/lib/IR/IRPrintingPasses.cpp4
-rw-r--r--llvm/tools/llvm-dis/llvm-dis.cpp3
-rw-r--r--llvm/tools/llvm-link/llvm-link.cpp2
-rw-r--r--llvm/tools/verify-uselistorder/verify-uselistorder.cpp10
6 files changed, 16 insertions, 16 deletions
diff --git a/llvm/include/llvm/IR/Module.h b/llvm/include/llvm/IR/Module.h
index ac60c8e885e..dbaf322263d 100644
--- a/llvm/include/llvm/IR/Module.h
+++ b/llvm/include/llvm/IR/Module.h
@@ -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;
diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp
index 6f4d99767d0..a2eb545f8b1 100644
--- a/llvm/lib/IR/AsmWriter.cpp
+++ b/llvm/lib/IR/AsmWriter.cpp
@@ -3071,11 +3071,11 @@ void Function::print(raw_ostream &ROS, AssemblyAnnotationWriter *AAW) 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);
}
diff --git a/llvm/lib/IR/IRPrintingPasses.cpp b/llvm/lib/IR/IRPrintingPasses.cpp
index 91ccfbb2f46..e872387022f 100644
--- a/llvm/lib/IR/IRPrintingPasses.cpp
+++ b/llvm/lib/IR/IRPrintingPasses.cpp
@@ -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_ostream &OS, const std::string &Banner)
: OS(OS), Banner(Banner) {}
PreservedAnalyses PrintModulePass::run(Module &M) {
- OS << Banner << M;
+ OS << Banner;
+ M.print(OS, nullptr, shouldPreserveAssemblyUseListOrder());
return PreservedAnalyses::all();
}
diff --git a/llvm/tools/llvm-dis/llvm-dis.cpp b/llvm/tools/llvm-dis/llvm-dis.cpp
index f914df54cf3..106fc18ebf5 100644
--- a/llvm/tools/llvm-dis/llvm-dis.cpp
+++ b/llvm/tools/llvm-dis/llvm-dis.cpp
@@ -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();
diff --git a/llvm/tools/llvm-link/llvm-link.cpp b/llvm/tools/llvm-link/llvm-link.cpp
index daffec9371d..9d5369df66d 100644
--- a/llvm/tools/llvm-link/llvm-link.cpp
+++ b/llvm/tools/llvm-link/llvm-link.cpp
@@ -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());
diff --git a/llvm/tools/verify-uselistorder/verify-uselistorder.cpp b/llvm/tools/verify-uselistorder/verify-uselistorder.cpp
index 9d297fa030c..795d035d3df 100644
--- a/llvm/tools/verify-uselistorder/verify-uselistorder.cpp
+++ b/llvm/tools/verify-uselistorder/verify-uselistorder.cpp
@@ -144,7 +144,7 @@ bool TempFile::writeAssembly(const Module &M) const {
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);
OpenPOWER on IntegriCloud