Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the verify pass on by default #4036

Merged
merged 3 commits into from
Oct 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -236,10 +236,10 @@ test-full-programs-debug: all
$(SILENT)cd '$(outDir)' && $(buildDir)/test/full-program-runner/full-program-runner --debugger='$(debuggercmd)' --timeout_s=120 --max_parallel=$(num_cores) --ponyc=$(outDir)/ponyc --debug --output=$(outDir)/full-program-tests/debug --test_lib=$(outDir)/test_lib $(srcDir)/test/full-program-tests

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) $(debuggercmd) ./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) $(debuggercmd) ./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) $(debuggercmd) ./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) $(debuggercmd) ./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 @@ -333,8 +333,8 @@ switch ($Command.ToLower())
if ($TestsToRun -match '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)
{
try
Expand Down Expand Up @@ -369,8 +369,8 @@ switch ($Command.ToLower())
if ($TestsToRun -match '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)
{
try
Expand Down
2 changes: 2 additions & 0 deletions src/libponyc/codegen/genopt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1043,6 +1043,8 @@ bool genopt(compile_t* c, bool pony_specific)
if(LLVMVerifyModule(c->module, LLVMPrintMessageAction, &msg) != 0)
{
errorf(errors, NULL, "Module verification failed: %s", msg);
errorf_continue(errors, NULL,
+ "Please file an issue ticket. Use --noverify to bypass this error.");
LLVMDisposeMessage(msg);
return false;
}
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 @@ -55,7 +55,7 @@ enum
OPT_TRACE,
OPT_WIDTH,
OPT_IMMERR,
OPT_VERIFY,
OPT_NOVERIFY,
OPT_FILENAMES,
OPT_CHECKTREE,
OPT_EXTFUN,
Expand Down Expand Up @@ -102,7 +102,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 @@ -189,7 +189,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 @@ -276,6 +276,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 @@ -345,7 +348,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
1 change: 0 additions & 1 deletion test/full-program-tests/with-return/expected-exit-code.txt

This file was deleted.

20 changes: 0 additions & 20 deletions test/full-program-tests/with-return/main.pony

This file was deleted.

Loading