commit 2509b7bdabbc9ec4edaf6dc49c051c6c5f72a355
Author: Richard Biener <rguenther@suse.de>
Date:   Thu Apr 21 10:12:46 2022 +0200

    Update BASE-VER to 11.3.1
    
    This updates BASE-VER to 11.3.1 after the 11.3 release.
    
    2022-04-21  Richard Biener  <rguenther@suse.de>
    
            * BASE-VER: Set to 11.3.1

diff --git a/gcc/BASE-VER b/gcc/BASE-VER
index f628d2eafc5..0a47c95bb14 100644
--- a/gcc/BASE-VER
+++ b/gcc/BASE-VER
@@ -1 +1 @@
-11.3.0
+11.3.1

commit 1eee4e08a64f6e931b0c5dd1bb854a2b7ad3d58f
Author: Matthias Kretz <m.kretz@gsi.de>
Date:   Wed Dec 15 09:45:06 2021 +0100

    c++: don't ICE on NAMESPACE_DECL inside FUNCTION_DECL
    
    Code like
      void swap() {
        namespace __variant = __detail::__variant;
        ...
      }
    create a NAMESPACE_DECL where the CP_DECL_CONTEXT is a FUNCTION_DECL.
    DECL_TEMPLATE_INFO fails on NAMESPACE_DECL and therefore must be handled
    first in the assertion.
    
    Signed-off-by: Matthias Kretz <m.kretz@gsi.de>
    
    gcc/cp/ChangeLog:
    
            * module.cc (trees_out::get_merge_kind): NAMESPACE_DECLs also
            cannot have a DECL_TEMPLATE_INFO.
    
    (cherry picked from commit 6bcb6ed5a44b6f271891246ef7ae568bfdc14e9c)

diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc
index b97b1bcb2f8..6cb926c044a 100644
--- a/gcc/cp/module.cc
+++ b/gcc/cp/module.cc
@@ -10059,9 +10059,10 @@ trees_out::get_merge_kind (tree decl, depset *dep)
       tree ctx = CP_DECL_CONTEXT (decl);
       if (TREE_CODE (ctx) == FUNCTION_DECL)
 	{
-	  /* USING_DECLs cannot have DECL_TEMPLATE_INFO -- this isn't
-	     permitting them to have one.   */
+	  /* USING_DECLs and NAMESPACE_DECLs cannot have DECL_TEMPLATE_INFO --
+	     this isn't permitting them to have one.   */
 	  gcc_checking_assert (TREE_CODE (decl) == USING_DECL
+			       || TREE_CODE (decl) == NAMESPACE_DECL
 			       || !DECL_LANG_SPECIFIC (decl)
 			       || !DECL_TEMPLATE_INFO (decl));
 

commit 7b879564ec2bda6b5441fbaf231d70ec6359db01
Author: Sergei Trofimovich <siarheit@google.com>
Date:   Fri Apr 15 08:35:27 2022 +0100

    gcov-profile: Allow negative counts of indirect calls [PR105282]
    
    TOPN metrics are histograms that contain overall count and per-bucket
    count. Overall count can be negative when two profiles merge and some
    of per-bucket metrics are disacarded.
    
    Noticed as an ICE on python PGO build where gcc crashes as:
    
        during IPA pass: modref
        a.c:36:1: ICE: in stream_out_histogram_value, at value-prof.cc:340
           36 | }
              | ^
        stream_out_histogram_value(output_block*, histogram_value_t*)
                gcc/value-prof.c:340
    
    gcc/ChangeLog:
    
            PR gcov-profile/105282
            * value-prof.c (stream_out_histogram_value): Allow negative counts
            on HIST_TYPE_INDIR_CALL.
    
    (cherry picked from commit 90a29845bfe7d6002e6c2fd49a97820b00fbc4a3)

diff --git a/gcc/value-prof.c b/gcc/value-prof.c
index 42748771192..688089b04d2 100644
--- a/gcc/value-prof.c
+++ b/gcc/value-prof.c
@@ -336,6 +336,10 @@ stream_out_histogram_value (struct output_block *ob, histogram_value hist)
 	/* Note that the IOR counter tracks pointer values and these can have
 	   sign bit set.  */
 	;
+      else if (hist->type == HIST_TYPE_INDIR_CALL && i == 0)
+	/* 'all' counter overflow is stored as a negative value. Individual
+	   counters and values are expected to be non-negative.  */
+	;
       else
 	gcc_assert (value >= 0);
 

commit 141b66c4becfa2f2c09b4a6cc0411d995ea5153a
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Thu Apr 21 09:43:30 2022 +0200

    emit-rtl: Fix -fcompare-debug bug with label references in debug insns [PR105203]
    
    When we compute LABEL_NUSES from scratch, mark_all_labels doesn't call
    mark_jump_label on DEBUG_INSNs:
                  if (NONDEBUG_INSN_P (insn))
                    mark_jump_label (PATTERN (insn), insn, 0);
    and so doesn't increment LABEL_NUSES from references in DEBUG_INSNs.
    But, when we call emit_copy_of_insn_after e.g. when duplicating some
    DEBUG_INSNs, we call it even on those, which then results in LABEL_NUSES
    differences and -fcompare-debug failures.
    
    The following patch makes sure we don't call it on DEBUG_INSNs.
    
    2022-04-21  Jakub Jelinek  <jakub@redhat.com>
    
            PR debug/105203
            * emit-rtl.c (emit_copy_of_insn_after): Don't call mark_jump_label
            on DEBUG_INSNs.
    
            * gfortran.dg/g77/pr105203.f: New test.
    
    (cherry picked from commit 504b02c70abcc31e0e9b56e69f82f85b5261bca9)

diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c
index 07e908624a0..0dc51220682 100644
--- a/gcc/emit-rtl.c
+++ b/gcc/emit-rtl.c
@@ -6465,7 +6465,8 @@ emit_copy_of_insn_after (rtx_insn *insn, rtx_insn *after)
     }
 
   /* Update LABEL_NUSES.  */
-  mark_jump_label (PATTERN (new_rtx), new_rtx, 0);
+  if (NONDEBUG_INSN_P (insn))
+    mark_jump_label (PATTERN (new_rtx), new_rtx, 0);
 
   INSN_LOCATION (new_rtx) = INSN_LOCATION (insn);
 
diff --git a/gcc/testsuite/gfortran.dg/g77/pr105203.f b/gcc/testsuite/gfortran.dg/g77/pr105203.f
new file mode 100644
index 00000000000..3b47210fb40
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/g77/pr105203.f
@@ -0,0 +1,20 @@
+C Test case for PR debug/105203
+C Origin: kmccarty@princeton.edu
+C
+C { dg-do compile }
+C { dg-options "-O2 -fcompare-debug -ftracer -w" }
+C { dg-additional-options "-fPIC" { target fpic } }
+      SUBROUTINE FOO (B)
+
+  10  CALL BAR (A)
+      ASSIGN 20 TO M
+      IF (100.LT.A) GOTO 10
+      GOTO 40
+C
+  20  IF (B.LT.ABS(A)) GOTO 10
+      ASSIGN 30 TO M
+      GOTO 40
+C
+  30  ASSIGN 10 TO M
+  40  GOTO M,(10,20,30)
+      END

commit dfe099b4b5c0077a6bd699912fe9442431239e39
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Tue Apr 19 18:58:59 2022 +0200

    sparc: Preserve ORIGINAL_REGNO in epilogue_renumber [PR105257]
    
    The following testcase ICEs, because the pic register is
    (reg:DI 24 %i0 [109]) and is used in the delay slot of a return.
    We invoke epilogue_renumber and that changes it to
    (reg:DI 8 %o0) which no longer satisfies sparc_pic_register_p
    predicate, so we don't recognize the insn anymore.
    
    The following patch fixes that by preserving ORIGINAL_REGNO if
    specified, so we get (reg:DI 8 %o0 [109]) instead.
    
    2022-04-19  Jakub Jelinek  <jakub@redhat.com>
    
            PR target/105257
            * config/sparc/sparc.c (epilogue_renumber): If ORIGINAL_REGNO,
            use gen_raw_REG instead of gen_rtx_REG and copy over also
            ORIGINAL_REGNO.  Use return 0; instead of /* fallthrough */.
    
            * gcc.dg/pr105257.c: New test.
    
    (cherry picked from commit eeca2b8bd03f57c59c6cf48bf6b9bd6dc86924f6)

diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c
index 7c8a1f18c39..0ef91935c1e 100644
--- a/gcc/config/sparc/sparc.c
+++ b/gcc/config/sparc/sparc.c
@@ -8956,8 +8956,20 @@ epilogue_renumber (rtx *where, int test)
       if (REGNO (*where) >= 8 && REGNO (*where) < 24)      /* oX or lX */
 	return 1;
       if (! test && REGNO (*where) >= 24 && REGNO (*where) < 32)
-	*where = gen_rtx_REG (GET_MODE (*where), OUTGOING_REGNO (REGNO(*where)));
-      /* fallthrough */
+	{
+	  if (ORIGINAL_REGNO (*where))
+	    {
+	      rtx n = gen_raw_REG (GET_MODE (*where),
+				   OUTGOING_REGNO (REGNO (*where)));
+	      ORIGINAL_REGNO (n) = ORIGINAL_REGNO (*where);
+	      *where = n;
+	    }
+	  else
+	    *where = gen_rtx_REG (GET_MODE (*where),
+				  OUTGOING_REGNO (REGNO (*where)));
+	}
+      return 0;
+
     case SCRATCH:
     case CC0:
     case PC:
diff --git a/gcc/testsuite/gcc.dg/pr105257.c b/gcc/testsuite/gcc.dg/pr105257.c
new file mode 100644
index 00000000000..4232942d791
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr105257.c
@@ -0,0 +1,16 @@
+/* PR target/105257 */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+/* { dg-additional-options "-fpic" { target fpic } } */
+
+extern int sigsetjmp (void **, int);
+void *buf[32];
+void (*fn) (void);
+
+const char *
+bar (void)
+{
+  sigsetjmp (buf, 0);
+  fn ();
+  return "";
+}
