public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Eric Botcazou <ebotcazou@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r13-3485] Relax assertion in profiler
Date: Tue, 25 Oct 2022 10:24:33 +0000 (GMT)	[thread overview]
Message-ID: <20221025102433.76C753858435@sourceware.org> (raw)

https://gcc.gnu.org/g:cb21297f9259ceedd5f5dd7c3973535f14124d6d

commit r13-3485-gcb21297f9259ceedd5f5dd7c3973535f14124d6d
Author: Eric Botcazou <ebotcazou@adacore.com>
Date:   Tue Oct 25 12:20:33 2022 +0200

    Relax assertion in profiler
    
    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 the fix for PR debug/101598 was installed.
    
    gcc/
            * profile.cc (branch_prob): Be prepared for ignored functions with
            DECL_SOURCE_LOCATION set to UNKNOWN_LOCATION.
    
    gcc/testsuite:
            * gnat.dg/specs/coverage1.ads: New test.
            * gnat.dg/specs/variant_part.ads: Minor tweak.
            * gnat.dg/specs/weak1.ads: Add dg directive.

Diff:
---
 gcc/profile.cc                               | 12 +++++++-----
 gcc/testsuite/gnat.dg/specs/coverage1.ads    | 10 ++++++++++
 gcc/testsuite/gnat.dg/specs/variant_part.ads |  1 +
 gcc/testsuite/gnat.dg/specs/weak1.ads        |  2 ++
 4 files changed, 20 insertions(+), 5 deletions(-)

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))
diff --git a/gcc/testsuite/gnat.dg/specs/coverage1.ads b/gcc/testsuite/gnat.dg/specs/coverage1.ads
new file mode 100644
index 00000000000..af7b61ce4e6
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/specs/coverage1.ads
@@ -0,0 +1,10 @@
+-- { dg-do compile }
+-- { dg-options "-ftest-coverage" }
+
+package Coverage1 is
+
+  type Rec is record
+    I : Integer := 0;
+  end record;
+
+end Coverage1;
diff --git a/gcc/testsuite/gnat.dg/specs/variant_part.ads b/gcc/testsuite/gnat.dg/specs/variant_part.ads
index afc92cde5d7..72da4108588 100644
--- a/gcc/testsuite/gnat.dg/specs/variant_part.ads
+++ b/gcc/testsuite/gnat.dg/specs/variant_part.ads
@@ -1,4 +1,5 @@
 -- { dg-do compile }
+
 package Variant_Part is
    type T1(b: boolean) is record
      case (b) is    -- { dg-error "discriminant name may not be parenthesized" }
diff --git a/gcc/testsuite/gnat.dg/specs/weak1.ads b/gcc/testsuite/gnat.dg/specs/weak1.ads
index 82cddc09ac2..ece05ea68a7 100644
--- a/gcc/testsuite/gnat.dg/specs/weak1.ads
+++ b/gcc/testsuite/gnat.dg/specs/weak1.ads
@@ -1,3 +1,5 @@
+-- { dg-do compile }
+
 package Weak1 is
 
    Myconst : constant Integer := 1234;

                 reply	other threads:[~2022-10-25 10:24 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221025102433.76C753858435@sourceware.org \
    --to=ebotcazou@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).