| 192 | unique_ptr<Cache> cache; |
| 193 | |
| 194 | int 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: |
| 202 | version )EOF"; |
| 203 | Usage += alive_version; |
| 204 | Usage += R"EOF( |
| 205 | see alive-exec --version for LLVM version info, |
| 206 | |
| 207 | This program takes an LLVM IR file as a command-line argument. |
| 208 | Both .bc and .ll files are supported. |
| 209 | |
| 210 | If one or more functions are specified (as a comma-separated list) |
| 211 | using the --funcs command line option, alive-exec will attempt to |
| 212 | execute them using Alive2 as an interpreter. |
| 213 | |
| 214 | If no functions are specified on the command line, then alive-exec |
| 215 | will attempt to execute the 'main' function. |
| 216 | If 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(); |
nothing calls this directly
no test coverage detected