#include #include #include DIVINE_RELAX_WARNINGS #include #include #include #include #include #include DIVINE_UNRELAX_WARNINGS int main( int argc, char **argv ) { lart::Driver driver; if ( argc < 3 ) { std::cerr << "usage: lart in.bc out.bc [pass:options] ..." << std::endl << std::endl << "pass aa (alias analysis), options:" << std::endl << " andersen: andersen-style, flow- and context-insensitive" << std::endl << std::endl << "example: lart in.bc out.bc aa:andersen" << std::endl << std::endl; for ( auto pass : driver.passes() ) { pass.description( std::cerr ); std::cerr << std::endl; } return 1; } const char *from = argv[1], *to = argv[2]; assert( from ); assert( to ); llvm::LLVMContext *ctx = new llvm::LLVMContext(); std::unique_ptr< llvm::MemoryBuffer > input; input = std::move( llvm::MemoryBuffer::getFile( from ).get() ); assert( input ); llvm::Module *module; auto inputData = input->getMemBufferRef(); auto parsed = parseBitcodeFile( inputData, *ctx ); if ( !parsed ) throw std::runtime_error( "Error parsing input model; probably not a valid bitcode file." ); module = parsed.get().get(); for ( char **arg = argv + 3; *arg; ++arg ) if ( !driver.setup( *arg ) ) { std::cerr << "Unknown pass " << *arg << std::endl; return 2; } std::error_code serr; ::llvm::raw_fd_ostream outs( to, serr, ::llvm::sys::fs::OF_None ); driver.process( module ); lart::Driver::assertValid( module ); WriteBitcodeToFile( *module, outs ); }