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

Function main

tools/quick-fuzz.cpp:889–1041  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

887} // namespace
888
889int main(int argc, char **argv) {
890 sys::PrintStackTraceOnErrorSignal(argv[0]);
891 llvm::InitLLVM X(argc, argv);
892 EnableDebugBuffering = true;
893 LLVMContext Context;
894
895 string Usage =
896 R"EOF(Alive2 simple generative fuzzer:
897version )EOF";
898 Usage += alive_version;
899 Usage += R"EOF(
900see quick-fuzz --version for LLVM version info,
901
902This program stress-tests LLVM and Alive2 by performing randomized
903generation of LLVM functions, optimizing them, and then checking
904refinement.
905
906It currently contains two simple generators: "value," which generates
907a single basic block containing integer operations, and "bb," which
908exercises loop and control flow optimizations.
909
910The recommended workflow is to run quick-fuzz until it finds an issue,
911and then re-run with the same seed and also the --save-ir command line
912option, in order to get a standalone test case that can then be
913reduced using llvm-reduce.
914)EOF";
915
916 cl::HideUnrelatedOptions(alive_cmdargs);
917 cl::ParseCommandLineOptions(argc, argv, Usage);
918
919 unique_ptr<Cache> cache;
920 unique_ptr<Module> MDummy;
921#define ARGS_MODULE_VAR MDummy
922#include "llvm_util/cmd_args_def.h"
923
924 Module M1("fuzz", Context);
925 auto &DL = M1.getDataLayout();
926 Triple targetTriple(M1.getTargetTriple());
927 TargetLibraryInfoWrapperPass TLI(targetTriple);
928
929 llvm_util::initializer llvm_util_init(*out, DL);
930 smt::smt_initializer smt_init;
931 Verifier verifier(TLI, smt_init, *out);
932 verifier.always_verify = opt_always_verify;
933 verifier.print_dot = opt_print_dot;
934 verifier.bidirectional = opt_bidirectional;
935
936 function<unique_ptr<Fuzzer>(Module &, long)> makeFuzzer;
937 if (opt_fuzzer == "value") {
938 makeFuzzer = [](Module &M, long seed) {
939 return make_unique<ValueFuzzer>(M, seed);
940 };
941 } else if (opt_fuzzer == "bb") {
942 makeFuzzer = [](Module &M, long seed) {
943 return make_unique<BBFuzzer>(M, seed);
944 };
945 } else {
946 *out << "Available fuzzers are \"value\" and \"bb\".\n\n";

Callers

nothing calls this directly

Calls 8

optimize_moduleFunction · 0.85
solver_print_statsFunction · 0.85
goMethod · 0.80
strMethod · 0.80
compareFunctionsMethod · 0.80
emptyMethod · 0.45
printMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected