summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2014-01-12 11:30:46 +0000
committerChandler Carruth <chandlerc@gmail.com>2014-01-12 11:30:46 +0000
commita5ced5ed37b3a742e958506ce133387b3313fe3a (patch)
tree49fd532c2cfab7f8e7b65606d01b2e3755174340
parent2ad3b87c4e1dfb8a49537ef51be5a13ea244f867 (diff)
downloadllvm-a5ced5ed37b3a742e958506ce133387b3313fe3a.tar.gz
llvm-a5ced5ed37b3a742e958506ce133387b3313fe3a.tar.bz2
llvm-a5ced5ed37b3a742e958506ce133387b3313fe3a.tar.xz
[PM] Simplify the interface exposed for IR printing passes.
Nothing was using the ability of the pass to delete the raw_ostream it printed to, and nothing was trying to pass it a pointer to the raw_ostream. Also, the function variant had a different order of arguments from all of the others which was just really confusing. Now the interface accepts a reference, doesn't offer to delete it, and uses a consistent order. The implementation of the printing passes haven't been updated with this simplification, this is just the API switch. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199044 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/IR/IRPrintingPasses.h17
-rw-r--r--include/llvm/LinkAllPasses.h6
-rw-r--r--lib/CodeGen/LLVMTargetMachine.cpp2
-rw-r--r--lib/CodeGen/Passes.cpp7
-rw-r--r--lib/IR/IRPrintingPasses.cpp17
-rw-r--r--lib/IR/LegacyPassManager.cpp6
-rw-r--r--lib/IR/Pass.cpp6
-rw-r--r--tools/llvm-extract/llvm-extract.cpp2
-rw-r--r--tools/opt/opt.cpp4
9 files changed, 34 insertions, 33 deletions
diff --git a/include/llvm/IR/IRPrintingPasses.h b/include/llvm/IR/IRPrintingPasses.h
index 45d3c7a120..67a6e62952 100644
--- a/include/llvm/IR/IRPrintingPasses.h
+++ b/include/llvm/IR/IRPrintingPasses.h
@@ -29,21 +29,26 @@ class raw_ostream;
/// \brief Create and return a pass that writes the module to the specified
/// \c raw_ostream.
-ModulePass *createPrintModulePass(raw_ostream *OS, bool DeleteStream = false,
+ModulePass *createPrintModulePass(raw_ostream &OS,
const std::string &Banner = "");
/// \brief Create and return a pass that prints functions to the specified
/// \c raw_ostream as they are processed.
-FunctionPass *createPrintFunctionPass(const std::string &Banner,
- raw_ostream *OS,
- bool DeleteStream = false);
+FunctionPass *createPrintFunctionPass(raw_ostream &OS,
+ const std::string &Banner = "");
/// \brief Create and return a pass that writes the BB to the specified
/// \c raw_ostream.
-BasicBlockPass *createPrintBasicBlockPass(raw_ostream *OS,
- bool DeleteStream = false,
+BasicBlockPass *createPrintBasicBlockPass(raw_ostream &OS,
const std::string &Banner = "");
+/// \brief Pass for printing a Module as LLVM's text IR assembly.
+///
+/// NOTE: This pass is for use with the new pass manager. Use the create...Pass
+/// functions above to create passes for use with the legacy pass manager.
+class AOEUPrintModulePass {
+};
+
} // End llvm namespace
#endif
diff --git a/include/llvm/LinkAllPasses.h b/include/llvm/LinkAllPasses.h
index 6c8c5f7ffd..e1d788e6e0 100644
--- a/include/llvm/LinkAllPasses.h
+++ b/include/llvm/LinkAllPasses.h
@@ -139,9 +139,9 @@ namespace {
(void) llvm::createMetaRenamerPass();
(void) llvm::createFunctionAttrsPass();
(void) llvm::createMergeFunctionsPass();
- (void) llvm::createPrintModulePass(0);
- (void) llvm::createPrintFunctionPass("", 0);
- (void) llvm::createPrintBasicBlockPass(0);
+ (void) llvm::createPrintModulePass(*(llvm::raw_ostream*)0);
+ (void) llvm::createPrintFunctionPass(*(llvm::raw_ostream*)0);
+ (void) llvm::createPrintBasicBlockPass(*(llvm::raw_ostream*)0);
(void) llvm::createModuleDebugInfoPrinterPass();
(void) llvm::createPartialInliningPass();
(void) llvm::createLintPass();
diff --git a/lib/CodeGen/LLVMTargetMachine.cpp b/lib/CodeGen/LLVMTargetMachine.cpp
index be90d5d4bd..9a7697e537 100644
--- a/lib/CodeGen/LLVMTargetMachine.cpp
+++ b/lib/CodeGen/LLVMTargetMachine.cpp
@@ -154,7 +154,7 @@ bool LLVMTargetMachine::addPassesToEmitFile(PassManagerBase &PM,
// machine-level pass), and whatever other information is needed to
// deserialize the code and resume compilation. For now, just write the
// LLVM IR.
- PM.add(createPrintModulePass(&Out));
+ PM.add(createPrintModulePass(Out));
return false;
}
diff --git a/lib/CodeGen/Passes.cpp b/lib/CodeGen/Passes.cpp
index dd9cb55b33..1ad9b73f41 100644
--- a/lib/CodeGen/Passes.cpp
+++ b/lib/CodeGen/Passes.cpp
@@ -389,7 +389,7 @@ void TargetPassConfig::addIRPasses() {
if (getOptLevel() != CodeGenOpt::None && !DisableLSR) {
addPass(createLoopStrengthReducePass());
if (PrintLSR)
- addPass(createPrintFunctionPass("\n\n*** Code after LSR ***\n", &dbgs()));
+ addPass(createPrintFunctionPass(dbgs(), "\n\n*** Code after LSR ***\n"));
}
addPass(createGCLoweringPass());
@@ -440,9 +440,8 @@ void TargetPassConfig::addISelPrepare() {
addPass(createStackProtectorPass(TM));
if (PrintISelInput)
- addPass(createPrintFunctionPass("\n\n"
- "*** Final LLVM Code input to ISel ***\n",
- &dbgs()));
+ addPass(createPrintFunctionPass(
+ dbgs(), "\n\n*** Final LLVM Code input to ISel ***\n"));
// All passes which modify the LLVM IR are now complete; run the verifier
// to ensure that the IR is valid.
diff --git a/lib/IR/IRPrintingPasses.cpp b/lib/IR/IRPrintingPasses.cpp
index 4398a9cfd2..242dcff795 100644
--- a/lib/IR/IRPrintingPasses.cpp
+++ b/lib/IR/IRPrintingPasses.cpp
@@ -113,20 +113,17 @@ char PrintBasicBlockPass::ID = 0;
INITIALIZE_PASS(PrintBasicBlockPass, "print-bb", "Print BB to stderr", false,
false)
-ModulePass *llvm::createPrintModulePass(llvm::raw_ostream *OS,
- bool DeleteStream,
+ModulePass *llvm::createPrintModulePass(llvm::raw_ostream &OS,
const std::string &Banner) {
- return new PrintModulePass(Banner, OS, DeleteStream);
+ return new PrintModulePass(Banner, &OS, false);
}
-FunctionPass *llvm::createPrintFunctionPass(const std::string &Banner,
- llvm::raw_ostream *OS,
- bool DeleteStream) {
- return new PrintFunctionPass(Banner, OS, DeleteStream);
+FunctionPass *llvm::createPrintFunctionPass(llvm::raw_ostream &OS,
+ const std::string &Banner) {
+ return new PrintFunctionPass(Banner, &OS, false);
}
-BasicBlockPass *llvm::createPrintBasicBlockPass(llvm::raw_ostream *OS,
- bool DeleteStream,
+BasicBlockPass *llvm::createPrintBasicBlockPass(llvm::raw_ostream &OS,
const std::string &Banner) {
- return new PrintBasicBlockPass(Banner, OS, DeleteStream);
+ return new PrintBasicBlockPass(Banner, &OS, false);
}
diff --git a/lib/IR/LegacyPassManager.cpp b/lib/IR/LegacyPassManager.cpp
index ae94f05dcf..f9fca321fa 100644
--- a/lib/IR/LegacyPassManager.cpp
+++ b/lib/IR/LegacyPassManager.cpp
@@ -235,7 +235,7 @@ public:
/// createPrinterPass - Get a function printer pass.
Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const {
- return createPrintFunctionPass(Banner, &O);
+ return createPrintFunctionPass(O, Banner);
}
// Prepare for running an on the fly pass, freeing memory if needed
@@ -304,7 +304,7 @@ public:
/// createPrinterPass - Get a module printer pass.
Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const {
- return createPrintModulePass(&O, false, Banner);
+ return createPrintModulePass(O, Banner);
}
/// run - Execute all of the passes scheduled for execution. Keep track of
@@ -404,7 +404,7 @@ public:
/// createPrinterPass - Get a module printer pass.
Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const {
- return createPrintModulePass(&O, false, Banner);
+ return createPrintModulePass(O, Banner);
}
/// run - Execute all of the passes scheduled for execution. Keep track of
diff --git a/lib/IR/Pass.cpp b/lib/IR/Pass.cpp
index dc8eee5338..3782e2d7be 100644
--- a/lib/IR/Pass.cpp
+++ b/lib/IR/Pass.cpp
@@ -35,7 +35,7 @@ ModulePass::~ModulePass() { }
Pass *ModulePass::createPrinterPass(raw_ostream &O,
const std::string &Banner) const {
- return createPrintModulePass(&O, false, Banner);
+ return createPrintModulePass(O, Banner);
}
PassManagerType ModulePass::getPotentialPassManagerType() const {
@@ -130,7 +130,7 @@ void ImmutablePass::initializePass() {
Pass *FunctionPass::createPrinterPass(raw_ostream &O,
const std::string &Banner) const {
- return createPrintFunctionPass(Banner, &O);
+ return createPrintFunctionPass(O, Banner);
}
PassManagerType FunctionPass::getPotentialPassManagerType() const {
@@ -143,7 +143,7 @@ PassManagerType FunctionPass::getPotentialPassManagerType() const {
Pass *BasicBlockPass::createPrinterPass(raw_ostream &O,
const std::string &Banner) const {
- return createPrintBasicBlockPass(&O, false, Banner);
+ return createPrintBasicBlockPass(O, Banner);
}
bool BasicBlockPass::doInitialization(Function &) {
diff --git a/tools/llvm-extract/llvm-extract.cpp b/tools/llvm-extract/llvm-extract.cpp
index ecea00530d..4962151e56 100644
--- a/tools/llvm-extract/llvm-extract.cpp
+++ b/tools/llvm-extract/llvm-extract.cpp
@@ -272,7 +272,7 @@ int main(int argc, char **argv) {
}
if (OutputAssembly)
- Passes.add(createPrintModulePass(&Out.os()));
+ Passes.add(createPrintModulePass(Out.os()));
else if (Force || !CheckBitcodeOutputToConsole(Out.os(), true))
Passes.add(createBitcodeWriterPass(Out.os()));
diff --git a/tools/opt/opt.cpp b/tools/opt/opt.cpp
index 44b3f13b54..92b63bd830 100644
--- a/tools/opt/opt.cpp
+++ b/tools/opt/opt.cpp
@@ -823,7 +823,7 @@ int main(int argc, char **argv) {
}
if (PrintEachXForm)
- Passes.add(createPrintModulePass(&errs()));
+ Passes.add(createPrintModulePass(errs()));
}
// If -std-compile-opts was specified at the end of the pass list, add them.
@@ -866,7 +866,7 @@ int main(int argc, char **argv) {
// Write bitcode or assembly to the output as the last step...
if (!NoOutput && !AnalyzeOnly) {
if (OutputAssembly)
- Passes.add(createPrintModulePass(&Out->os()));
+ Passes.add(createPrintModulePass(Out->os()));
else
Passes.add(createBitcodeWriterPass(Out->os()));
}