Skip to content

Commit

Permalink
Make the verify pass on by default
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
SeanTAllen committed Feb 23, 2022
1 parent bdea439 commit ad740c1
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
7 changes: 7 additions & 0 deletions .release-notes/always-verify-ir.md
Original file line number Diff line number Diff line change
@@ -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.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 {} {}
Expand Down
8 changes: 4 additions & 4 deletions make.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down
11 changes: 7 additions & 4 deletions src/libponyc/options/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ enum
OPT_TRACE,
OPT_WIDTH,
OPT_IMMERR,
OPT_VERIFY,
OPT_NOVERIFY,
OPT_FILENAMES,
OPT_CHECKTREE,
OPT_EXTFUN,
Expand Down Expand Up @@ -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},
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit ad740c1

Please sign in to comment.