]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
final: Fix call to INSN_LOCATION on a NOTE rtl
authorLewis Hyatt <lhyatt@gmail.com>
Sat, 7 Dec 2024 00:01:32 +0000 (19:01 -0500)
committerLewis Hyatt <lhyatt@gcc.gnu.org>
Sat, 7 Dec 2024 00:01:32 +0000 (19:01 -0500)
This function has a code path that calls INSN_LOCATION on an rtl note. For a
note, this returns the note type enum rather than a location, but it runs
without complaint even with --enable-checking=rtl because both are stored in
the rt_int member of the rtunion. A subsequent commit will add a new rtl
format code specifically for locations, in which case attempting to call
INSN_LOCATION on a note will trigger an error. Fix it up by handling the
case of a note missing a location separately.

gcc/ChangeLog:

* final.cc (reemit_insn_block_notes): Don't try to call
INSN_LOCATION on a NOTE rtl object. Don't call change_scope () for a
NOTE missing a location.

gcc/final.cc

index 4d3d056cb56e325115ed595109da451b83611878..a6936963f9959537f337ecccded8e23e2d733955 100644 (file)
@@ -1513,6 +1513,8 @@ reemit_insn_block_notes (void)
          case NOTE_INSN_BEGIN_STMT:
          case NOTE_INSN_INLINE_ENTRY:
            this_block = LOCATION_BLOCK (NOTE_MARKER_LOCATION (insn));
+           if (!this_block)
+             continue;
            goto set_cur_block_to_this_block;
 
          default:
@@ -1538,7 +1540,6 @@ reemit_insn_block_notes (void)
            this_block = choose_inner_scope (this_block,
                                             insn_scope (body->insn (i)));
        }
-    set_cur_block_to_this_block:
       if (! this_block)
        {
          if (INSN_LOCATION (insn) == UNKNOWN_LOCATION)
@@ -1547,6 +1548,7 @@ reemit_insn_block_notes (void)
            this_block = DECL_INITIAL (cfun->decl);
        }
 
+    set_cur_block_to_this_block:
       if (this_block != cur_block)
        {
          change_scope (insn, cur_block, this_block);