MCPcopy Create free account
hub / github.com/AliveToolkit/alive2 / main

Function main

tools/alive-exec.cpp:194–263  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

192unique_ptr<Cache> cache;
193
194int main(int argc, char **argv) {
195 llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
196 llvm::InitLLVM X(argc, argv);
197 llvm::EnableDebugBuffering = true;
198 llvm::LLVMContext Context;
199
200 std::string Usage =
201 R"EOF(Alive2 stand-alone translation validator:
202version )EOF";
203 Usage += alive_version;
204 Usage += R"EOF(
205see alive-exec --version for LLVM version info,
206
207This program takes an LLVM IR file as a command-line argument.
208Both .bc and .ll files are supported.
209
210If one or more functions are specified (as a comma-separated list)
211using the --funcs command line option, alive-exec will attempt to
212execute them using Alive2 as an interpreter.
213
214If no functions are specified on the command line, then alive-exec
215will attempt to execute the 'main' function.
216If it doesn't exist, alive-exec executes every function in the bitcode file.
217)EOF";
218
219 llvm::cl::HideUnrelatedOptions(alive_cmdargs);
220 llvm::cl::ParseCommandLineOptions(argc, argv, Usage);
221
222 auto M = openInputFile(Context, opt_file);
223 if (!M.get()) {
224 cerr << "Could not read bitcode from '" << opt_file << "'\n";
225 return -1;
226 }
227
228#define ARGS_MODULE_VAR M
229# include "llvm_util/cmd_args_def.h"
230
231 auto &DL = M.get()->getDataLayout();
232 llvm::Triple targetTriple(M.get()->getTargetTriple());
233 llvm::TargetLibraryInfoWrapperPass TLI(targetTriple);
234
235 llvm_util::initializer llvm_util_init(cerr, DL);
236 smt::smt_initializer smt_init;
237
238 auto *main_fn = findFunction(*M, "main");
239 optional<StateValue> ret_val;
240
241 if (main_fn && func_names.empty()) {
242 State::resetGlobals();
243 ret_val = exec(*main_fn, TLI);
244 } else {
245 for (auto &F : *M) {
246 if (F.isDeclaration())
247 continue;
248 if (!func_names.empty() && !func_names.count(F.getName().str()))
249 continue;
250 State::resetGlobals();
251 smt_init.reset();

Callers

nothing calls this directly

Calls 8

openInputFileFunction · 0.85
findFunctionFunction · 0.85
execFunction · 0.85
strMethod · 0.80
getMethod · 0.45
emptyMethod · 0.45
resetMethod · 0.45
isIntMethod · 0.45

Tested by

no test coverage detected