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
|
||||
/// \c raw_ostream.
|
||||
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
|
||||
/// \c raw_ostream as they are processed.
|
||||
@ -53,10 +54,12 @@ BasicBlockPass *createPrintBasicBlockPass(raw_ostream &OS,
|
||||
class PrintModulePass {
|
||||
raw_ostream &OS;
|
||||
std::string Banner;
|
||||
bool ShouldPreserveUseListOrder;
|
||||
|
||||
public:
|
||||
PrintModulePass();
|
||||
PrintModulePass(raw_ostream &OS, const std::string &Banner = "");
|
||||
PrintModulePass(raw_ostream &OS, const std::string &Banner = "",
|
||||
bool ShouldPreserveUseListOrder = false);
|
||||
|
||||
PreservedAnalyses run(Module &M);
|
||||
|
||||
|
@ -15,19 +15,20 @@
|
||||
#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"
|
||||
using namespace llvm;
|
||||
|
||||
PrintModulePass::PrintModulePass() : OS(dbgs()) {}
|
||||
PrintModulePass::PrintModulePass(raw_ostream &OS, const std::string &Banner)
|
||||
: OS(OS), Banner(Banner) {}
|
||||
PrintModulePass::PrintModulePass(raw_ostream &OS, const std::string &Banner,
|
||||
bool ShouldPreserveUseListOrder)
|
||||
: OS(OS), Banner(Banner),
|
||||
ShouldPreserveUseListOrder(ShouldPreserveUseListOrder) {}
|
||||
|
||||
PreservedAnalyses PrintModulePass::run(Module &M) {
|
||||
OS << Banner;
|
||||
M.print(OS, nullptr, shouldPreserveAssemblyUseListOrder());
|
||||
M.print(OS, nullptr, ShouldPreserveUseListOrder);
|
||||
return PreservedAnalyses::all();
|
||||
}
|
||||
|
||||
@ -48,8 +49,9 @@ class PrintModulePassWrapper : public ModulePass {
|
||||
public:
|
||||
static char ID;
|
||||
PrintModulePassWrapper() : ModulePass(ID) {}
|
||||
PrintModulePassWrapper(raw_ostream &OS, const std::string &Banner)
|
||||
: ModulePass(ID), P(OS, Banner) {}
|
||||
PrintModulePassWrapper(raw_ostream &OS, const std::string &Banner,
|
||||
bool ShouldPreserveUseListOrder)
|
||||
: ModulePass(ID), P(OS, Banner, ShouldPreserveUseListOrder) {}
|
||||
|
||||
bool runOnModule(Module &M) override {
|
||||
P.run(M);
|
||||
@ -114,8 +116,9 @@ INITIALIZE_PASS(PrintBasicBlockPass, "print-bb", "Print BB to stderr", false,
|
||||
false)
|
||||
|
||||
ModulePass *llvm::createPrintModulePass(llvm::raw_ostream &OS,
|
||||
const std::string &Banner) {
|
||||
return new PrintModulePassWrapper(OS, Banner);
|
||||
const std::string &Banner,
|
||||
bool ShouldPreserveUseListOrder) {
|
||||
return new PrintModulePassWrapper(OS, Banner, ShouldPreserveUseListOrder);
|
||||
}
|
||||
|
||||
FunctionPass *llvm::createPrintFunctionPass(llvm::raw_ostream &OS,
|
||||
|
@ -270,7 +270,8 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
|
||||
if (OutputAssembly)
|
||||
Passes.add(createPrintModulePass(Out.os()));
|
||||
Passes.add(createPrintModulePass(Out.os(), "",
|
||||
shouldPreserveAssemblyUseListOrder()));
|
||||
else if (Force || !CheckBitcodeOutputToConsole(Out.os(), true))
|
||||
Passes.add(
|
||||
createBitcodeWriterPass(Out.os(), shouldPreserveBitcodeUseListOrder()));
|
||||
|
@ -40,6 +40,7 @@ bool llvm::runPassPipeline(StringRef Arg0, LLVMContext &Context, Module &M,
|
||||
TargetMachine *TM, tool_output_file *Out,
|
||||
StringRef PassPipeline, OutputKind OK,
|
||||
VerifierKind VK,
|
||||
bool ShouldPreserveAssemblyUseListOrder,
|
||||
bool ShouldPreserveBitcodeUseListOrder) {
|
||||
PassBuilder PB(TM);
|
||||
|
||||
@ -78,7 +79,8 @@ bool llvm::runPassPipeline(StringRef Arg0, LLVMContext &Context, Module &M,
|
||||
case OK_NoOutput:
|
||||
break; // No output pass needed.
|
||||
case OK_OutputAssembly:
|
||||
MPM.addPass(PrintModulePass(Out->os()));
|
||||
MPM.addPass(
|
||||
PrintModulePass(Out->os(), "", ShouldPreserveAssemblyUseListOrder));
|
||||
break;
|
||||
case OK_OutputBitcode:
|
||||
MPM.addPass(
|
||||
|
@ -52,6 +52,7 @@ bool runPassPipeline(StringRef Arg0, LLVMContext &Context, Module &M,
|
||||
TargetMachine *TM, tool_output_file *Out,
|
||||
StringRef PassPipeline, opt_tool::OutputKind OK,
|
||||
opt_tool::VerifierKind VK,
|
||||
bool ShouldPreserveAssemblyUseListOrder,
|
||||
bool ShouldPreserveBitcodeUseListOrder);
|
||||
}
|
||||
|
||||
|
@ -432,6 +432,7 @@ int main(int argc, char **argv) {
|
||||
// layer.
|
||||
return runPassPipeline(argv[0], Context, *M, TM.get(), Out.get(),
|
||||
PassPipeline, OK, VK,
|
||||
shouldPreserveAssemblyUseListOrder(),
|
||||
shouldPreserveBitcodeUseListOrder())
|
||||
? 0
|
||||
: 1;
|
||||
@ -556,7 +557,8 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
|
||||
if (PrintEachXForm)
|
||||
Passes.add(createPrintModulePass(errs()));
|
||||
Passes.add(createPrintModulePass(errs(), "",
|
||||
shouldPreserveAssemblyUseListOrder()));
|
||||
}
|
||||
|
||||
if (StandardLinkOpts) {
|
||||
@ -593,7 +595,8 @@ 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(), "",
|
||||
shouldPreserveAssemblyUseListOrder()));
|
||||
else
|
||||
Passes.add(createBitcodeWriterPass(Out->os(),
|
||||
shouldPreserveBitcodeUseListOrder()));
|
||||
|
Loading…
Reference in New Issue
Block a user