llvm.org GIT mirror llvm / a5ced5e
[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 Chandler Carruth 6 years ago
9 changed file(s) with 34 addition(s) and 33 deletion(s). Raw diff Collapse all Expand all
2828
2929 /// \brief Create and return a pass that writes the module to the specified
3030 /// \c raw_ostream.
31 ModulePass *createPrintModulePass(raw_ostream *OS, bool DeleteStream = false,
31 ModulePass *createPrintModulePass(raw_ostream &OS,
3232 const std::string &Banner = "");
3333
3434 /// \brief Create and return a pass that prints functions to the specified
3535 /// \c raw_ostream as they are processed.
36 FunctionPass *createPrintFunctionPass(const std::string &Banner,
37 raw_ostream *OS,
38 bool DeleteStream = false);
36 FunctionPass *createPrintFunctionPass(raw_ostream &OS,
37 const std::string &Banner = "");
3938
4039 /// \brief Create and return a pass that writes the BB to the specified
4140 /// \c raw_ostream.
42 BasicBlockPass *createPrintBasicBlockPass(raw_ostream *OS,
43 bool DeleteStream = false,
41 BasicBlockPass *createPrintBasicBlockPass(raw_ostream &OS,
4442 const std::string &Banner = "");
43
44 /// \brief Pass for printing a Module as LLVM's text IR assembly.
45 ///
46 /// NOTE: This pass is for use with the new pass manager. Use the create...Pass
47 /// functions above to create passes for use with the legacy pass manager.
48 class AOEUPrintModulePass {
49 };
4550
4651 } // End llvm namespace
4752
138138 (void) llvm::createMetaRenamerPass();
139139 (void) llvm::createFunctionAttrsPass();
140140 (void) llvm::createMergeFunctionsPass();
141 (void) llvm::createPrintModulePass(0);
142 (void) llvm::createPrintFunctionPass("", 0);
143 (void) llvm::createPrintBasicBlockPass(0);
141 (void) llvm::createPrintModulePass(*(llvm::raw_ostream*)0);
142 (void) llvm::createPrintFunctionPass(*(llvm::raw_ostream*)0);
143 (void) llvm::createPrintBasicBlockPass(*(llvm::raw_ostream*)0);
144144 (void) llvm::createModuleDebugInfoPrinterPass();
145145 (void) llvm::createPartialInliningPass();
146146 (void) llvm::createLintPass();
153153 // machine-level pass), and whatever other information is needed to
154154 // deserialize the code and resume compilation. For now, just write the
155155 // LLVM IR.
156 PM.add(createPrintModulePass(&Out));
156 PM.add(createPrintModulePass(Out));
157157 return false;
158158 }
159159
388388 if (getOptLevel() != CodeGenOpt::None && !DisableLSR) {
389389 addPass(createLoopStrengthReducePass());
390390 if (PrintLSR)
391 addPass(createPrintFunctionPass("\n\n*** Code after LSR ***\n", &dbgs()));
391 addPass(createPrintFunctionPass(dbgs(), "\n\n*** Code after LSR ***\n"));
392392 }
393393
394394 addPass(createGCLoweringPass());
439439 addPass(createStackProtectorPass(TM));
440440
441441 if (PrintISelInput)
442 addPass(createPrintFunctionPass("\n\n"
443 "*** Final LLVM Code input to ISel ***\n",
444 &dbgs()));
442 addPass(createPrintFunctionPass(
443 dbgs(), "\n\n*** Final LLVM Code input to ISel ***\n"));
445444
446445 // All passes which modify the LLVM IR are now complete; run the verifier
447446 // to ensure that the IR is valid.
112112 INITIALIZE_PASS(PrintBasicBlockPass, "print-bb", "Print BB to stderr", false,
113113 false)
114114
115 ModulePass *llvm::createPrintModulePass(llvm::raw_ostream *OS,
116 bool DeleteStream,
115 ModulePass *llvm::createPrintModulePass(llvm::raw_ostream &OS,
117116 const std::string &Banner) {
118 return new PrintModulePass(Banner, OS, DeleteStream);
117 return new PrintModulePass(Banner, &OS, false);
119118 }
120119
121 FunctionPass *llvm::createPrintFunctionPass(const std::string &Banner,
122 llvm::raw_ostream *OS,
123 bool DeleteStream) {
124 return new PrintFunctionPass(Banner, OS, DeleteStream);
120 FunctionPass *llvm::createPrintFunctionPass(llvm::raw_ostream &OS,
121 const std::string &Banner) {
122 return new PrintFunctionPass(Banner, &OS, false);
125123 }
126124
127 BasicBlockPass *llvm::createPrintBasicBlockPass(llvm::raw_ostream *OS,
128 bool DeleteStream,
125 BasicBlockPass *llvm::createPrintBasicBlockPass(llvm::raw_ostream &OS,
129126 const std::string &Banner) {
130 return new PrintBasicBlockPass(Banner, OS, DeleteStream);
127 return new PrintBasicBlockPass(Banner, &OS, false);
131128 }
234234
235235 /// createPrinterPass - Get a function printer pass.
236236 Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const {
237 return createPrintFunctionPass(Banner, &O);
237 return createPrintFunctionPass(O, Banner);
238238 }
239239
240240 // Prepare for running an on the fly pass, freeing memory if needed
303303
304304 /// createPrinterPass - Get a module printer pass.
305305 Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const {
306 return createPrintModulePass(&O, false, Banner);
306 return createPrintModulePass(O, Banner);
307307 }
308308
309309 /// run - Execute all of the passes scheduled for execution. Keep track of
403403
404404 /// createPrinterPass - Get a module printer pass.
405405 Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const {
406 return createPrintModulePass(&O, false, Banner);
406 return createPrintModulePass(O, Banner);
407407 }
408408
409409 /// run - Execute all of the passes scheduled for execution. Keep track of
3434
3535 Pass *ModulePass::createPrinterPass(raw_ostream &O,
3636 const std::string &Banner) const {
37 return createPrintModulePass(&O, false, Banner);
37 return createPrintModulePass(O, Banner);
3838 }
3939
4040 PassManagerType ModulePass::getPotentialPassManagerType() const {
129129
130130 Pass *FunctionPass::createPrinterPass(raw_ostream &O,
131131 const std::string &Banner) const {
132 return createPrintFunctionPass(Banner, &O);
132 return createPrintFunctionPass(O, Banner);
133133 }
134134
135135 PassManagerType FunctionPass::getPotentialPassManagerType() const {
142142
143143 Pass *BasicBlockPass::createPrinterPass(raw_ostream &O,
144144 const std::string &Banner) const {
145 return createPrintBasicBlockPass(&O, false, Banner);
145 return createPrintBasicBlockPass(O, Banner);
146146 }
147147
148148 bool BasicBlockPass::doInitialization(Function &) {
271271 }
272272
273273 if (OutputAssembly)
274 Passes.add(createPrintModulePass(&Out.os()));
274 Passes.add(createPrintModulePass(Out.os()));
275275 else if (Force || !CheckBitcodeOutputToConsole(Out.os(), true))
276276 Passes.add(createBitcodeWriterPass(Out.os()));
277277
822822 }
823823
824824 if (PrintEachXForm)
825 Passes.add(createPrintModulePass(&errs()));
825 Passes.add(createPrintModulePass(errs()));
826826 }
827827
828828 // If -std-compile-opts was specified at the end of the pass list, add them.
865865 // Write bitcode or assembly to the output as the last step...
866866 if (!NoOutput && !AnalyzeOnly) {
867867 if (OutputAssembly)
868 Passes.add(createPrintModulePass(&Out->os()));
868 Passes.add(createPrintModulePass(Out->os()));
869869 else
870870 Passes.add(createBitcodeWriterPass(Out->os()));
871871 }