14#include "llvm/IR/Module.h"
16#include "llvm/Support/Debug.h"
17#include "llvm/Support/FileSystem.h"
18#include "llvm/Support/Path.h"
19#include "llvm/Support/ToolOutputFile.h"
21#define DEBUG_TYPE "polly-dump-module"
28static void runDumpModule(llvm::Module &
M, StringRef Filename,
bool IsSuffix) {
31 StringRef ModuleName =
M.getName();
32 StringRef Stem = sys::path::stem(ModuleName);
33 Dumpfile = (Twine(Stem) + Filename +
".ll").
str();
35 Dumpfile = Filename.str();
37 LLVM_DEBUG(dbgs() <<
"Dumping module to " << Dumpfile <<
'\n');
39 std::unique_ptr<ToolOutputFile> Out;
41 Out.reset(
new ToolOutputFile(Dumpfile, EC, sys::fs::OF_None));
43 errs() << EC.message() <<
'\n';
47 M.print(Out->os(),
nullptr);
51class DumpModuleWrapperPass final :
public ModulePass {
53 DumpModuleWrapperPass(
const DumpModuleWrapperPass &) =
delete;
54 const DumpModuleWrapperPass &
55 operator=(
const DumpModuleWrapperPass &) =
delete;
66 explicit DumpModuleWrapperPass()
67 : ModulePass(ID), Filename(
"-dump"), IsSuffix(
true) {}
69 explicit DumpModuleWrapperPass(std::string Filename,
bool IsSuffix)
70 : ModulePass(ID), Filename(std::move(Filename)), IsSuffix(IsSuffix) {}
74 void getAnalysisUsage(llvm::AnalysisUsage &AU)
const override {
78 bool runOnModule(llvm::Module &
M)
override {
79 runDumpModule(
M, Filename, IsSuffix);
85char DumpModuleWrapperPass::ID;
90 return new DumpModuleWrapperPass(std::move(Filename), IsSuffix);
94 llvm::ModuleAnalysisManager &AM) {
96 return PreservedAnalyses::all();
100 "Polly - Dump Module",
false,
false)
INITIALIZE_PASS_BEGIN(DependenceInfo, "polly-dependences", "Polly - Calculate dependences", false, false)
INITIALIZE_PASS_END(DependenceInfo, "polly-dependences", "Polly - Calculate dependences", false, false) namespace
static RegisterPass< ScopPrinterWrapperPass > M("dot-scops", "Polly - Print Scops of function")
This file contains the declaration of the PolyhedralInfo class, which will provide an interface to ex...
llvm::ModulePass * createDumpModuleWrapperPass(std::string Filename, bool IsSuffix)
Create a pass that prints the module into a file.
llvm::PreservedAnalyses run(llvm::Module &M, llvm::ModuleAnalysisManager &AM)