Hi! As the pass doesn't want to insert into empty bbs and also copies locus from the stmt it is inserted before, we have to make sure we insert it before non-debug stmt (and as empty bb also consider blocks with just labels and debug stmts).
Bootstrapped/regtested on x86_64-linux and i686-linux, committed as obvious. 2017-04-18 Jakub Jelinek <ja...@redhat.com> PR sanitizer/80444 * sancov.c (sancov_pass): Use gsi_start_nondebug_after_labels_bb instead of gsi_after_labels. * gcc.dg/sancov/pr80444.c: New test. --- gcc/sancov.c.jj 2017-01-01 12:45:38.000000000 +0100 +++ gcc/sancov.c 2017-04-18 09:14:58.567233552 +0200 @@ -46,7 +46,7 @@ sancov_pass (function *fun) basic_block bb; FOR_EACH_BB_FN (bb, fun) { - gimple_stmt_iterator gsi = gsi_after_labels (bb); + gimple_stmt_iterator gsi = gsi_start_nondebug_after_labels_bb (bb); if (gsi_end_p (gsi)) continue; gimple *stmt = gsi_stmt (gsi); --- gcc/testsuite/gcc.dg/sancov/pr80444.c.jj 2017-04-18 09:16:34.480933807 +0200 +++ gcc/testsuite/gcc.dg/sancov/pr80444.c 2017-04-18 09:17:24.322256958 +0200 @@ -0,0 +1,9 @@ +/* PR sanitizer/80444 */ +/* { dg-do compile } */ +/* { dg-options "-fsanitize-coverage=trace-pc -fcompare-debug" } */ + +void +foo (void) +{ + int a = 0; +} Jakub