public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Relax assertion in profile.cc
@ 2022-10-24  8:25 Eric Botcazou
  2022-10-24 12:32 ` Richard Biener
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Botcazou @ 2022-10-24  8:25 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 813 bytes --]

Hi,

this assertion in branch_prob:

  if (bb == ENTRY_BLOCK_PTR_FOR_FN (cfun)->next_bb)
    {
      location_t loc = DECL_SOURCE_LOCATION (current_function_decl);
      gcc_checking_assert (!RESERVED_LOCATION_P (loc));

had been correct until:

2021-08-11  Bernd Edlinger  <bernd.edlinger@hotmail.de>

	PR debug/101598
	* gcc-interface/trans.c (Subprogram_Body_to_gnu): Set the
	DECL_SOURCE_LOCATION of DECL_IGNORED_P gnu_subprog_decl to
	UNKNOWN_LOCATION.

was installed.

Tested on x86-64/Linux, OK for mainline and 12 branch?


2022-10-24  Eric Botcazou  <ebotcazou@adacore.com>

	* profile.cc (branch_prob): Be prepared for ignored functions with
	DECL_SOURCE_LOCATION set to UNKNOWN_LOCATION.


2022-10-24  Eric Botcazou  <ebotcazou@adacore.com>

	* gnat.dg/specs/coverage1.ads: New test.

-- 
Eric Botcazou

[-- Attachment #2: p.diff --]
[-- Type: text/x-patch, Size: 920 bytes --]

diff --git a/gcc/profile.cc b/gcc/profile.cc
index 96121d60711..1527a04124f 100644
--- a/gcc/profile.cc
+++ b/gcc/profile.cc
@@ -1457,11 +1457,13 @@ branch_prob (bool thunk)
 	  if (bb == ENTRY_BLOCK_PTR_FOR_FN (cfun)->next_bb)
 	    {
 	      location_t loc = DECL_SOURCE_LOCATION (current_function_decl);
-	      gcc_checking_assert (!RESERVED_LOCATION_P (loc));
-	      seen_locations.add (loc);
-	      expanded_location curr_location = expand_location (loc);
-	      output_location (&streamed_locations, curr_location.file,
-			       MAX (1, curr_location.line), &offset, bb);
+	      if (!RESERVED_LOCATION_P (loc))
+		{
+		  seen_locations.add (loc);
+		  expanded_location curr_location = expand_location (loc);
+		  output_location (&streamed_locations, curr_location.file,
+				   MAX (1, curr_location.line), &offset, bb);
+		}
 	    }
 
 	  for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))

[-- Attachment #3: coverage1.ads --]
[-- Type: text/x-adasrc, Size: 153 bytes --]

-- { dg-do compile }
-- { dg-options "-ftest-coverage" }

package Coverage1 is

  type Rec is record
    I : Integer := 0;
  end record;

end Coverage1;

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Relax assertion in profile.cc
  2022-10-24  8:25 [PATCH] Relax assertion in profile.cc Eric Botcazou
@ 2022-10-24 12:32 ` Richard Biener
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2022-10-24 12:32 UTC (permalink / raw)
  To: Eric Botcazou; +Cc: gcc-patches

On Mon, Oct 24, 2022 at 10:26 AM Eric Botcazou via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> Hi,
>
> this assertion in branch_prob:
>
>   if (bb == ENTRY_BLOCK_PTR_FOR_FN (cfun)->next_bb)
>     {
>       location_t loc = DECL_SOURCE_LOCATION (current_function_decl);
>       gcc_checking_assert (!RESERVED_LOCATION_P (loc));
>
> had been correct until:
>
> 2021-08-11  Bernd Edlinger  <bernd.edlinger@hotmail.de>
>
>         PR debug/101598
>         * gcc-interface/trans.c (Subprogram_Body_to_gnu): Set the
>         DECL_SOURCE_LOCATION of DECL_IGNORED_P gnu_subprog_decl to
>         UNKNOWN_LOCATION.
>
> was installed.
>
> Tested on x86-64/Linux, OK for mainline and 12 branch?

OK.

>
> 2022-10-24  Eric Botcazou  <ebotcazou@adacore.com>
>
>         * profile.cc (branch_prob): Be prepared for ignored functions with
>         DECL_SOURCE_LOCATION set to UNKNOWN_LOCATION.
>
>
> 2022-10-24  Eric Botcazou  <ebotcazou@adacore.com>
>
>         * gnat.dg/specs/coverage1.ads: New test.
>
> --
> Eric Botcazou

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-10-24 12:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-24  8:25 [PATCH] Relax assertion in profile.cc Eric Botcazou
2022-10-24 12:32 ` Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).