mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-05-13 17:38:39 +00:00
[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
This commit is contained in:
parent
2ad3b87c4e
commit
a5ced5ed37
@ -29,21 +29,26 @@ class raw_ostream;
|
|||||||
|
|
||||||
/// \brief Create and return a pass that writes the module to the specified
|
/// \brief Create and return a pass that writes the module to the specified
|
||||||
/// \c raw_ostream.
|
/// \c raw_ostream.
|
||||||
ModulePass *createPrintModulePass(raw_ostream *OS, bool DeleteStream = false,
|
ModulePass *createPrintModulePass(raw_ostream &OS,
|
||||||
const std::string &Banner = "");
|
const std::string &Banner = "");
|
||||||
|
|
||||||
/// \brief Create and return a pass that prints functions to the specified
|
/// \brief Create and return a pass that prints functions to the specified
|
||||||
/// \c raw_ostream as they are processed.
|
/// \c raw_ostream as they are processed.
|
||||||
FunctionPass *createPrintFunctionPass(const std::string &Banner,
|
FunctionPass *createPrintFunctionPass(raw_ostream &OS,
|
||||||
raw_ostream *OS,
|
const std::string &Banner = "");
|
||||||
bool DeleteStream = false);
|
|
||||||
|
|
||||||
/// \brief Create and return a pass that writes the BB to the specified
|
/// \brief Create and return a pass that writes the BB to the specified
|
||||||
/// \c raw_ostream.
|
/// \c raw_ostream.
|
||||||
BasicBlockPass *createPrintBasicBlockPass(raw_ostream *OS,
|
BasicBlockPass *createPrintBasicBlockPass(raw_ostream &OS,
|
||||||
bool DeleteStream = false,
|
|
||||||
const std::string &Banner = "");
|
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
|
} // End llvm namespace
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -139,9 +139,9 @@ namespace {
|
|||||||
(void) llvm::createMetaRenamerPass();
|
(void) llvm::createMetaRenamerPass();
|
||||||
(void) llvm::createFunctionAttrsPass();
|
(void) llvm::createFunctionAttrsPass();
|
||||||
(void) llvm::createMergeFunctionsPass();
|
(void) llvm::createMergeFunctionsPass();
|
||||||
(void) llvm::createPrintModulePass(0);
|
(void) llvm::createPrintModulePass(*(llvm::raw_ostream*)0);
|
||||||
(void) llvm::createPrintFunctionPass("", 0);
|
(void) llvm::createPrintFunctionPass(*(llvm::raw_ostream*)0);
|
||||||
(void) llvm::createPrintBasicBlockPass(0);
|
(void) llvm::createPrintBasicBlockPass(*(llvm::raw_ostream*)0);
|
||||||
(void) llvm::createModuleDebugInfoPrinterPass();
|
(void) llvm::createModuleDebugInfoPrinterPass();
|
||||||
(void) llvm::createPartialInliningPass();
|
(void) llvm::createPartialInliningPass();
|
||||||
(void) llvm::createLintPass();
|
(void) llvm::createLintPass();
|
||||||
|
@ -154,7 +154,7 @@ bool LLVMTargetMachine::addPassesToEmitFile(PassManagerBase &PM,
|
|||||||
// machine-level pass), and whatever other information is needed to
|
// machine-level pass), and whatever other information is needed to
|
||||||
// deserialize the code and resume compilation. For now, just write the
|
// deserialize the code and resume compilation. For now, just write the
|
||||||
// LLVM IR.
|
// LLVM IR.
|
||||||
PM.add(createPrintModulePass(&Out));
|
PM.add(createPrintModulePass(Out));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -389,7 +389,7 @@ void TargetPassConfig::addIRPasses() {
|
|||||||
if (getOptLevel() != CodeGenOpt::None && !DisableLSR) {
|
if (getOptLevel() != CodeGenOpt::None && !DisableLSR) {
|
||||||
addPass(createLoopStrengthReducePass());
|
addPass(createLoopStrengthReducePass());
|
||||||
if (PrintLSR)
|
if (PrintLSR)
|
||||||
addPass(createPrintFunctionPass("\n\n*** Code after LSR ***\n", &dbgs()));
|
addPass(createPrintFunctionPass(dbgs(), "\n\n*** Code after LSR ***\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
addPass(createGCLoweringPass());
|
addPass(createGCLoweringPass());
|
||||||
@ -440,9 +440,8 @@ void TargetPassConfig::addISelPrepare() {
|
|||||||
addPass(createStackProtectorPass(TM));
|
addPass(createStackProtectorPass(TM));
|
||||||
|
|
||||||
if (PrintISelInput)
|
if (PrintISelInput)
|
||||||
addPass(createPrintFunctionPass("\n\n"
|
addPass(createPrintFunctionPass(
|
||||||
"*** Final LLVM Code input to ISel ***\n",
|
dbgs(), "\n\n*** Final LLVM Code input to ISel ***\n"));
|
||||||
&dbgs()));
|
|
||||||
|
|
||||||
// All passes which modify the LLVM IR are now complete; run the verifier
|
// All passes which modify the LLVM IR are now complete; run the verifier
|
||||||
// to ensure that the IR is valid.
|
// to ensure that the IR is valid.
|
||||||
|
@ -113,20 +113,17 @@ char PrintBasicBlockPass::ID = 0;
|
|||||||
INITIALIZE_PASS(PrintBasicBlockPass, "print-bb", "Print BB to stderr", false,
|
INITIALIZE_PASS(PrintBasicBlockPass, "print-bb", "Print BB to stderr", false,
|
||||||
false)
|
false)
|
||||||
|
|
||||||
ModulePass *llvm::createPrintModulePass(llvm::raw_ostream *OS,
|
ModulePass *llvm::createPrintModulePass(llvm::raw_ostream &OS,
|
||||||
bool DeleteStream,
|
|
||||||
const std::string &Banner) {
|
const std::string &Banner) {
|
||||||
return new PrintModulePass(Banner, OS, DeleteStream);
|
return new PrintModulePass(Banner, &OS, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
FunctionPass *llvm::createPrintFunctionPass(const std::string &Banner,
|
FunctionPass *llvm::createPrintFunctionPass(llvm::raw_ostream &OS,
|
||||||
llvm::raw_ostream *OS,
|
const std::string &Banner) {
|
||||||
bool DeleteStream) {
|
return new PrintFunctionPass(Banner, &OS, false);
|
||||||
return new PrintFunctionPass(Banner, OS, DeleteStream);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BasicBlockPass *llvm::createPrintBasicBlockPass(llvm::raw_ostream *OS,
|
BasicBlockPass *llvm::createPrintBasicBlockPass(llvm::raw_ostream &OS,
|
||||||
bool DeleteStream,
|
|
||||||
const std::string &Banner) {
|
const std::string &Banner) {
|
||||||
return new PrintBasicBlockPass(Banner, OS, DeleteStream);
|
return new PrintBasicBlockPass(Banner, &OS, false);
|
||||||
}
|
}
|
||||||
|
@ -235,7 +235,7 @@ public:
|
|||||||
|
|
||||||
/// createPrinterPass - Get a function printer pass.
|
/// createPrinterPass - Get a function printer pass.
|
||||||
Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const {
|
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
|
// Prepare for running an on the fly pass, freeing memory if needed
|
||||||
@ -304,7 +304,7 @@ public:
|
|||||||
|
|
||||||
/// createPrinterPass - Get a module printer pass.
|
/// createPrinterPass - Get a module printer pass.
|
||||||
Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const {
|
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
|
/// run - Execute all of the passes scheduled for execution. Keep track of
|
||||||
@ -404,7 +404,7 @@ public:
|
|||||||
|
|
||||||
/// createPrinterPass - Get a module printer pass.
|
/// createPrinterPass - Get a module printer pass.
|
||||||
Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const {
|
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
|
/// run - Execute all of the passes scheduled for execution. Keep track of
|
||||||
|
@ -35,7 +35,7 @@ ModulePass::~ModulePass() { }
|
|||||||
|
|
||||||
Pass *ModulePass::createPrinterPass(raw_ostream &O,
|
Pass *ModulePass::createPrinterPass(raw_ostream &O,
|
||||||
const std::string &Banner) const {
|
const std::string &Banner) const {
|
||||||
return createPrintModulePass(&O, false, Banner);
|
return createPrintModulePass(O, Banner);
|
||||||
}
|
}
|
||||||
|
|
||||||
PassManagerType ModulePass::getPotentialPassManagerType() const {
|
PassManagerType ModulePass::getPotentialPassManagerType() const {
|
||||||
@ -130,7 +130,7 @@ void ImmutablePass::initializePass() {
|
|||||||
|
|
||||||
Pass *FunctionPass::createPrinterPass(raw_ostream &O,
|
Pass *FunctionPass::createPrinterPass(raw_ostream &O,
|
||||||
const std::string &Banner) const {
|
const std::string &Banner) const {
|
||||||
return createPrintFunctionPass(Banner, &O);
|
return createPrintFunctionPass(O, Banner);
|
||||||
}
|
}
|
||||||
|
|
||||||
PassManagerType FunctionPass::getPotentialPassManagerType() const {
|
PassManagerType FunctionPass::getPotentialPassManagerType() const {
|
||||||
@ -143,7 +143,7 @@ PassManagerType FunctionPass::getPotentialPassManagerType() const {
|
|||||||
|
|
||||||
Pass *BasicBlockPass::createPrinterPass(raw_ostream &O,
|
Pass *BasicBlockPass::createPrinterPass(raw_ostream &O,
|
||||||
const std::string &Banner) const {
|
const std::string &Banner) const {
|
||||||
return createPrintBasicBlockPass(&O, false, Banner);
|
return createPrintBasicBlockPass(O, Banner);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BasicBlockPass::doInitialization(Function &) {
|
bool BasicBlockPass::doInitialization(Function &) {
|
||||||
|
@ -272,7 +272,7 @@ int main(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (OutputAssembly)
|
if (OutputAssembly)
|
||||||
Passes.add(createPrintModulePass(&Out.os()));
|
Passes.add(createPrintModulePass(Out.os()));
|
||||||
else if (Force || !CheckBitcodeOutputToConsole(Out.os(), true))
|
else if (Force || !CheckBitcodeOutputToConsole(Out.os(), true))
|
||||||
Passes.add(createBitcodeWriterPass(Out.os()));
|
Passes.add(createBitcodeWriterPass(Out.os()));
|
||||||
|
|
||||||
|
@ -823,7 +823,7 @@ int main(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (PrintEachXForm)
|
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.
|
// 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...
|
// Write bitcode or assembly to the output as the last step...
|
||||||
if (!NoOutput && !AnalyzeOnly) {
|
if (!NoOutput && !AnalyzeOnly) {
|
||||||
if (OutputAssembly)
|
if (OutputAssembly)
|
||||||
Passes.add(createPrintModulePass(&Out->os()));
|
Passes.add(createPrintModulePass(Out->os()));
|
||||||
else
|
else
|
||||||
Passes.add(createBitcodeWriterPass(Out->os()));
|
Passes.add(createBitcodeWriterPass(Out->os()));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user