]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-cfg: Fix call to next_discriminator_for_locus()
authorLewis Hyatt <lhyatt@gmail.com>
Fri, 25 Oct 2024 18:55:09 +0000 (14:55 -0400)
committerLewis Hyatt <lhyatt@gcc.gnu.org>
Wed, 20 Nov 2024 23:08:57 +0000 (18:08 -0500)
While testing future 64-bit location_t support, I ran into an
-fcompare-debug issue that was traced back here. Despite the name,
next_discriminator_for_locus() is meant to take an integer line number
argument, not a location_t. There is one call site which has been passing a
location_t instead. For the most part that is harmless, although in case
there are two CALL stmts on the same line with different location_t, it may
fail to generate a unique discriminator where it should. If/when location_t
changes to be 64-bit, however, it will produce an -fcompare-debug
failure. Fix it by passing the line number rather than the location_t.

I am not aware of a testcase that demonstrates any observable wrong
behavior, but the file debug/pr53466.C is an example where the discriminator
assignment is indeed different before and after this change.

gcc/ChangeLog:

* tree-cfg.cc (assign_discriminators): Fix incorrect value passed to
next_discriminator_for_locus().

gcc/tree-cfg.cc

index 3eede0d61cdcd60e9c0251f0188e179131e4201b..c2100a51a7a56dce2075ee2729440934d1c1ddeb 100644 (file)
@@ -1251,7 +1251,7 @@ assign_discriminators (void)
            }
          /* Allocate a new discriminator for CALL stmt.  */
          if (gimple_code (stmt) == GIMPLE_CALL)
-           curr_discr = next_discriminator_for_locus (curr_locus);
+           curr_discr = next_discriminator_for_locus (curr_locus_e.line);
        }
 
       gimple *last = last_nondebug_stmt (bb);