mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
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
33 lines
823 B
C++
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;
|
|
}
|