mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-12 13:30:51 +00:00
uselistorder: Pull the bit through PrintModulePass
Now the callers of `PrintModulePass()` (etc.) that care about use-list order in assembly pass in the flag. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234969 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
8b376eb892
commit
2c7f24d654
@ -34,7 +34,8 @@ 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,
|
ModulePass *createPrintModulePass(raw_ostream &OS,
|
||||||
const std::string &Banner = "");
|
const std::string &Banner = "",
|
||||||
|
bool ShouldPreserveUseListOrder = false);
|
||||||
|
|
||||||
/// \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.
|
||||||
@ -53,10 +54,12 @@ BasicBlockPass *createPrintBasicBlockPass(raw_ostream &OS,
|
|||||||
class PrintModulePass {
|
class PrintModulePass {
|
||||||
raw_ostream &OS;
|
raw_ostream &OS;
|
||||||
std::string Banner;
|
std::string Banner;
|
||||||
|
bool ShouldPreserveUseListOrder;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PrintModulePass();
|
PrintModulePass();
|
||||||
PrintModulePass(raw_ostream &OS, const std::string &Banner = "");
|
PrintModulePass(raw_ostream &OS, const std::string &Banner = "",
|
||||||
|
bool ShouldPreserveUseListOrder = false);
|
||||||
|
|
||||||
PreservedAnalyses run(Module &M);
|
PreservedAnalyses run(Module &M);
|
||||||
|
|
||||||
|
@ -15,19 +15,20 @@
|
|||||||
#include "llvm/IR/Function.h"
|
#include "llvm/IR/Function.h"
|
||||||
#include "llvm/IR/Module.h"
|
#include "llvm/IR/Module.h"
|
||||||
#include "llvm/IR/PassManager.h"
|
#include "llvm/IR/PassManager.h"
|
||||||
#include "llvm/IR/UseListOrder.h"
|
|
||||||
#include "llvm/Pass.h"
|
#include "llvm/Pass.h"
|
||||||
#include "llvm/Support/Debug.h"
|
#include "llvm/Support/Debug.h"
|
||||||
#include "llvm/Support/raw_ostream.h"
|
#include "llvm/Support/raw_ostream.h"
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
PrintModulePass::PrintModulePass() : OS(dbgs()) {}
|
PrintModulePass::PrintModulePass() : OS(dbgs()) {}
|
||||||
PrintModulePass::PrintModulePass(raw_ostream &OS, const std::string &Banner)
|
PrintModulePass::PrintModulePass(raw_ostream &OS, const std::string &Banner,
|
||||||
: OS(OS), Banner(Banner) {}
|
bool ShouldPreserveUseListOrder)
|
||||||
|
: OS(OS), Banner(Banner),
|
||||||
|
ShouldPreserveUseListOrder(ShouldPreserveUseListOrder) {}
|
||||||
|
|
||||||
PreservedAnalyses PrintModulePass::run(Module &M) {
|
PreservedAnalyses PrintModulePass::run(Module &M) {
|
||||||
OS << Banner;
|
OS << Banner;
|
||||||
M.print(OS, nullptr, shouldPreserveAssemblyUseListOrder());
|
M.print(OS, nullptr, ShouldPreserveUseListOrder);
|
||||||
return PreservedAnalyses::all();
|
return PreservedAnalyses::all();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,8 +49,9 @@ class PrintModulePassWrapper : public ModulePass {
|
|||||||
public:
|
public:
|
||||||
static char ID;
|
static char ID;
|
||||||
PrintModulePassWrapper() : ModulePass(ID) {}
|
PrintModulePassWrapper() : ModulePass(ID) {}
|
||||||
PrintModulePassWrapper(raw_ostream &OS, const std::string &Banner)
|
PrintModulePassWrapper(raw_ostream &OS, const std::string &Banner,
|
||||||
: ModulePass(ID), P(OS, Banner) {}
|
bool ShouldPreserveUseListOrder)
|
||||||
|
: ModulePass(ID), P(OS, Banner, ShouldPreserveUseListOrder) {}
|
||||||
|
|
||||||
bool runOnModule(Module &M) override {
|
bool runOnModule(Module &M) override {
|
||||||
P.run(M);
|
P.run(M);
|
||||||
@ -114,8 +116,9 @@ 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,
|
||||||
const std::string &Banner) {
|
const std::string &Banner,
|
||||||
return new PrintModulePassWrapper(OS, Banner);
|
bool ShouldPreserveUseListOrder) {
|
||||||
|
return new PrintModulePassWrapper(OS, Banner, ShouldPreserveUseListOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
FunctionPass *llvm::createPrintFunctionPass(llvm::raw_ostream &OS,
|
FunctionPass *llvm::createPrintFunctionPass(llvm::raw_ostream &OS,
|
||||||
|
@ -270,7 +270,8 @@ int main(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (OutputAssembly)
|
if (OutputAssembly)
|
||||||
Passes.add(createPrintModulePass(Out.os()));
|
Passes.add(createPrintModulePass(Out.os(), "",
|
||||||
|
shouldPreserveAssemblyUseListOrder()));
|
||||||
else if (Force || !CheckBitcodeOutputToConsole(Out.os(), true))
|
else if (Force || !CheckBitcodeOutputToConsole(Out.os(), true))
|
||||||
Passes.add(
|
Passes.add(
|
||||||
createBitcodeWriterPass(Out.os(), shouldPreserveBitcodeUseListOrder()));
|
createBitcodeWriterPass(Out.os(), shouldPreserveBitcodeUseListOrder()));
|
||||||
|
@ -40,6 +40,7 @@ bool llvm::runPassPipeline(StringRef Arg0, LLVMContext &Context, Module &M,
|
|||||||
TargetMachine *TM, tool_output_file *Out,
|
TargetMachine *TM, tool_output_file *Out,
|
||||||
StringRef PassPipeline, OutputKind OK,
|
StringRef PassPipeline, OutputKind OK,
|
||||||
VerifierKind VK,
|
VerifierKind VK,
|
||||||
|
bool ShouldPreserveAssemblyUseListOrder,
|
||||||
bool ShouldPreserveBitcodeUseListOrder) {
|
bool ShouldPreserveBitcodeUseListOrder) {
|
||||||
PassBuilder PB(TM);
|
PassBuilder PB(TM);
|
||||||
|
|
||||||
@ -78,7 +79,8 @@ bool llvm::runPassPipeline(StringRef Arg0, LLVMContext &Context, Module &M,
|
|||||||
case OK_NoOutput:
|
case OK_NoOutput:
|
||||||
break; // No output pass needed.
|
break; // No output pass needed.
|
||||||
case OK_OutputAssembly:
|
case OK_OutputAssembly:
|
||||||
MPM.addPass(PrintModulePass(Out->os()));
|
MPM.addPass(
|
||||||
|
PrintModulePass(Out->os(), "", ShouldPreserveAssemblyUseListOrder));
|
||||||
break;
|
break;
|
||||||
case OK_OutputBitcode:
|
case OK_OutputBitcode:
|
||||||
MPM.addPass(
|
MPM.addPass(
|
||||||
|
@ -52,6 +52,7 @@ bool runPassPipeline(StringRef Arg0, LLVMContext &Context, Module &M,
|
|||||||
TargetMachine *TM, tool_output_file *Out,
|
TargetMachine *TM, tool_output_file *Out,
|
||||||
StringRef PassPipeline, opt_tool::OutputKind OK,
|
StringRef PassPipeline, opt_tool::OutputKind OK,
|
||||||
opt_tool::VerifierKind VK,
|
opt_tool::VerifierKind VK,
|
||||||
|
bool ShouldPreserveAssemblyUseListOrder,
|
||||||
bool ShouldPreserveBitcodeUseListOrder);
|
bool ShouldPreserveBitcodeUseListOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -432,6 +432,7 @@ int main(int argc, char **argv) {
|
|||||||
// layer.
|
// layer.
|
||||||
return runPassPipeline(argv[0], Context, *M, TM.get(), Out.get(),
|
return runPassPipeline(argv[0], Context, *M, TM.get(), Out.get(),
|
||||||
PassPipeline, OK, VK,
|
PassPipeline, OK, VK,
|
||||||
|
shouldPreserveAssemblyUseListOrder(),
|
||||||
shouldPreserveBitcodeUseListOrder())
|
shouldPreserveBitcodeUseListOrder())
|
||||||
? 0
|
? 0
|
||||||
: 1;
|
: 1;
|
||||||
@ -556,7 +557,8 @@ int main(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (PrintEachXForm)
|
if (PrintEachXForm)
|
||||||
Passes.add(createPrintModulePass(errs()));
|
Passes.add(createPrintModulePass(errs(), "",
|
||||||
|
shouldPreserveAssemblyUseListOrder()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (StandardLinkOpts) {
|
if (StandardLinkOpts) {
|
||||||
@ -593,7 +595,8 @@ 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(), "",
|
||||||
|
shouldPreserveAssemblyUseListOrder()));
|
||||||
else
|
else
|
||||||
Passes.add(createBitcodeWriterPass(Out->os(),
|
Passes.add(createBitcodeWriterPass(Out->os(),
|
||||||
shouldPreserveBitcodeUseListOrder()));
|
shouldPreserveBitcodeUseListOrder()));
|
||||||
|
Loading…
Reference in New Issue
Block a user