Files
pytorch/tools/code_analyzer/analyzer.cpp
Jiakai Liu 495c1df510 [pytorch] convert code analyzer to a binary (#33102)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/33102

Add a simple main() to build code analyzer as a binary. This enables
easier integration with FB internal build environment.
ghstack-source-id: 97958658

Test Plan: - CI

Differential Revision: D19798560

Pulled By: ljk53

fbshipit-source-id: 126230e3bf7568046a309e8a6785230f820e0222
2020-02-10 14:46:29 -08:00

33 lines
823 B
C++

#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
#include "llvm/IRReader/IRReader.h"
#include "llvm/Pass.h"
#include "llvm/PassRegistry.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/SourceMgr.h"
using namespace llvm;
namespace {
cl::opt<std::string> InputFilename(
cl::Positional,
cl::desc("<input bitcode file>"),
cl::init("-"),
cl::value_desc("filename"));
} // namespace
int main(int argc, char **argv) {
LLVMContext Context;
cl::ParseCommandLineOptions(argc, argv);
SMDiagnostic Err;
std::unique_ptr<Module> M = parseIRFile(InputFilename, Err, Context);
auto opDependencyPass = PassRegistry::getPassRegistry()
->getPassInfo(StringRef("op_dependency"))
->createPass();
static_cast<ModulePass*>(opDependencyPass)->runOnModule(*M);
return 0;
}