From ad740c17c0581b715fa8eecef28663a6ab61fb7b Mon Sep 17 00:00:00 2001 From: "Sean T. Allen" Date: Tue, 22 Feb 2022 22:43:18 -0500 Subject: [PATCH] Make the `verify` pass on by default As we slowly move towards Pony 1.0.0, fixing issues in LLVM IR generation is an important consideration. We've turned on LLVM IR generation verification as a default in the compiler. Hopefully this will generate reports for failures that are currently hidden in the wild. --- .release-notes/always-verify-ir.md | 7 +++++++ Makefile | 4 ++-- make.ps1 | 8 ++++---- src/libponyc/options/options.c | 11 +++++++---- 4 files changed, 20 insertions(+), 10 deletions(-) create mode 100644 .release-notes/always-verify-ir.md diff --git a/.release-notes/always-verify-ir.md b/.release-notes/always-verify-ir.md new file mode 100644 index 0000000000..fd3a90801b --- /dev/null +++ b/.release-notes/always-verify-ir.md @@ -0,0 +1,7 @@ +## Turn on `verify` pass by default + +The `verify` compiler pass will check the LLVM IR generated for the program being compiled for errors. Previously, you had to turn verify on. It is now on by default and can be turned off using the new `--noverify` option. + +We decided to turn on the pass for two reasons. The first is that it adds very little overhead to normal compilation times. The second is it will help generate error reports from Pony users for lurking bugs in our code generation. + +The errors reported don't generally result in incorrect programs, but could under the right circumstance. We feel that turning on the reports will allow us to find and fix bugs quicker and help move us closer to Pony version 1. diff --git a/Makefile b/Makefile index 68f428068b..c179116a92 100644 --- a/Makefile +++ b/Makefile @@ -196,10 +196,10 @@ test-core: all $(SILENT)cd '$(outDir)' && $(buildDir)/test/libponyc-run/runner/runner --sequential=true --exclude=runner --ponyc=$(outDir)/ponyc --output=$(outDir) --test_lib=$(outDir)/test_lib $(srcDir)/test/libponyc-run test-stdlib-release: all - $(SILENT)cd '$(outDir)' && PONYPATH=.:$(PONYPATH) ./ponyc -b stdlib-release --pic --checktree --verify $(cross_args) ../../packages/stdlib && echo Built `pwd`/stdlib-release && $(cross_runner) ./stdlib-release --sequential + $(SILENT)cd '$(outDir)' && PONYPATH=.:$(PONYPATH) ./ponyc -b stdlib-release --pic --checktree $(cross_args) ../../packages/stdlib && echo Built `pwd`/stdlib-release && $(cross_runner) ./stdlib-release --sequential test-stdlib-debug: all - $(SILENT)cd '$(outDir)' && PONYPATH=.:$(PONYPATH) ./ponyc -d -b stdlib-debug --pic --strip --checktree --verify $(cross_args) ../../packages/stdlib && echo Built `pwd`/stdlib-debug && $(cross_runner) ./stdlib-debug --sequential + $(SILENT)cd '$(outDir)' && PONYPATH=.:$(PONYPATH) ./ponyc -d -b stdlib-debug --pic --strip --checktree $(cross_args) ../../packages/stdlib && echo Built `pwd`/stdlib-debug && $(cross_runner) ./stdlib-debug --sequential test-examples: all $(SILENT)cd '$(outDir)' && PONYPATH=.:$(PONYPATH) find ../../examples/*/* -name '*.pony' -print | xargs -n 1 dirname | sort -u | grep -v ffi- | xargs -n 1 -I {} ./ponyc -d -s --checktree -o {} {} diff --git a/make.ps1 b/make.ps1 index 15313dbeee..dfe3a55a30 100644 --- a/make.ps1 +++ b/make.ps1 @@ -254,8 +254,8 @@ switch ($Command.ToLower()) # stdlib-debug $numTestSuitesRun += 1; - Write-Output "$outDir\ponyc.exe -d --checktree --verify -b stdlib-debug -o $outDir $srcDir\packages\stdlib" - & $outDir\ponyc.exe -d --checktree --verify -b stdlib-debug -o $outDir $srcDir\packages\stdlib + Write-Output "$outDir\ponyc.exe -d --checktree -b stdlib-debug -o $outDir $srcDir\packages\stdlib" + & $outDir\ponyc.exe -d --checktree -b stdlib-debug -o $outDir $srcDir\packages\stdlib if ($LastExitCode -eq 0) { Write-Output "$outDir\stdlib-debug.exe" @@ -270,8 +270,8 @@ switch ($Command.ToLower()) # stdlib-release $numTestSuitesRun += 1; - Write-Output "$outDir\ponyc.exe --checktree --verify -b stdlib-release -o $outDir $srcDir\packages\stdlib" - & $outDir\ponyc.exe --checktree --verify -b stdlib-release -o $outDir $srcDir\packages\stdlib + Write-Output "$outDir\ponyc.exe --checktree -b stdlib-release -o $outDir $srcDir\packages\stdlib" + & $outDir\ponyc.exe --checktree -b stdlib-release -o $outDir $srcDir\packages\stdlib if ($LastExitCode -eq 0) { Write-Output "$outDir\stdlib-release.exe" diff --git a/src/libponyc/options/options.c b/src/libponyc/options/options.c index cfa08656aa..52a8abf2eb 100644 --- a/src/libponyc/options/options.c +++ b/src/libponyc/options/options.c @@ -53,7 +53,7 @@ enum OPT_TRACE, OPT_WIDTH, OPT_IMMERR, - OPT_VERIFY, + OPT_NOVERIFY, OPT_FILENAMES, OPT_CHECKTREE, OPT_EXTFUN, @@ -99,7 +99,7 @@ static opt_arg_t std_args[] = {"trace", 't', OPT_ARG_NONE, OPT_TRACE}, {"width", 'w', OPT_ARG_REQUIRED, OPT_WIDTH}, {"immerr", '\0', OPT_ARG_NONE, OPT_IMMERR}, - {"verify", '\0', OPT_ARG_NONE, OPT_VERIFY}, + {"noverify", '\0', OPT_ARG_NONE, OPT_NOVERIFY}, {"files", '\0', OPT_ARG_NONE, OPT_FILENAMES}, {"checktree", '\0', OPT_ARG_NONE, OPT_CHECKTREE}, {"extfun", '\0', OPT_ARG_NONE, OPT_EXTFUN}, @@ -184,7 +184,7 @@ static void usage(void) " =columns Defaults to the terminal width.\n" " --immerr Report errors immediately rather than deferring.\n" " --checktree Verify AST well-formedness.\n" - " --verify Verify LLVM IR.\n" + " --noverify Don't verify LLVM IR.\n" " --extfun Set function default linkage to external.\n" " --files Print source file names as each is processed.\n" " --bnf Print out the Pony grammar as human readable BNF.\n" @@ -271,6 +271,9 @@ ponyc_opt_process_t ponyc_opt_process(opt_state_t* s, pass_opt_t* opt, bool wants_help = false; + // default to running verify pass. require it to be turned off. + opt->verify = true; + while((id = ponyint_opt_next(s)) != -1) { switch(id) @@ -339,7 +342,7 @@ ponyc_opt_process_t ponyc_opt_process(opt_state_t* s, pass_opt_t* opt, case OPT_TRACE: opt->parse_trace = true; break; case OPT_WIDTH: opt->ast_print_width = atoi(s->arg_val); break; case OPT_IMMERR: errors_set_immediate(opt->check.errors, true); break; - case OPT_VERIFY: opt->verify = true; break; + case OPT_NOVERIFY: opt->verify = false; break; case OPT_EXTFUN: opt->extfun = true; break; case OPT_FILENAMES: opt->print_filenames = true; break; case OPT_CHECKTREE: opt->check_tree = true; break;