libgccjit: Clear pending_assemble_externals_processed

Message ID 7185cf6ab672b0dd4aa7a29bfca1aa14632975e7.camel@zoho.com
State Accepted
Headers
Series libgccjit: Clear pending_assemble_externals_processed |

Checks

Context Check Description
snail/gcc-patch-check success Github commit url

Commit Message

Antoni Boucher Feb. 8, 2024, 10:09 p.m. UTC
  Hi.
This patch fixes the bug 113842.
I cannot yet add a test with this patch since it requires using
try/catch which is not yet merged in master.
Thanks for the review.
  

Comments

Antoni Boucher Feb. 15, 2024, 2:33 p.m. UTC | #1
David: Ping.

On Thu, 2024-02-08 at 17:09 -0500, Antoni Boucher wrote:
> Hi.
> This patch fixes the bug 113842.
> I cannot yet add a test with this patch since it requires using
> try/catch which is not yet merged in master.
> Thanks for the review.
  
David Malcolm Feb. 15, 2024, 3:35 p.m. UTC | #2
On Thu, 2024-02-08 at 17:09 -0500, Antoni Boucher wrote:
> Hi.
> This patch fixes the bug 113842.
> I cannot yet add a test with this patch since it requires using
> try/catch which is not yet merged in master.
> Thanks for the review.

Thanks; patch looks good for trunk, assuming you've tested it on a
target that defines ASM_OUTPUT_EXTERNAL.

Dave
  
Antoni Boucher Feb. 15, 2024, 7:14 p.m. UTC | #3
It's OK to merge even though it touches files outside of the jit
directory and we're in stage 4?
Or do we need some kind of approval?

On Thu, 2024-02-15 at 10:35 -0500, David Malcolm wrote:
> On Thu, 2024-02-08 at 17:09 -0500, Antoni Boucher wrote:
> > Hi.
> > This patch fixes the bug 113842.
> > I cannot yet add a test with this patch since it requires using
> > try/catch which is not yet merged in master.
> > Thanks for the review.
> 
> Thanks; patch looks good for trunk, assuming you've tested it on a
> target that defines ASM_OUTPUT_EXTERNAL.
> 
> Dave
>
  
David Malcolm Feb. 15, 2024, 7:23 p.m. UTC | #4
On Thu, 2024-02-15 at 14:14 -0500, Antoni Boucher wrote:
> It's OK to merge even though it touches files outside of the jit
> directory and we're in stage 4?
> Or do we need some kind of approval?

I think this patch is sufficiently low-risk that you can go ahead and
merge it.

Dave

> 
> On Thu, 2024-02-15 at 10:35 -0500, David Malcolm wrote:
> > On Thu, 2024-02-08 at 17:09 -0500, Antoni Boucher wrote:
> > > Hi.
> > > This patch fixes the bug 113842.
> > > I cannot yet add a test with this patch since it requires using
> > > try/catch which is not yet merged in master.
> > > Thanks for the review.
> > 
> > Thanks; patch looks good for trunk, assuming you've tested it on a
> > target that defines ASM_OUTPUT_EXTERNAL.
> > 
> > Dave
> > 
>
  

Patch

From 71f5f5fa8e68594454d5511b6d0c795bc6a8c37a Mon Sep 17 00:00:00 2001
From: Antoni Boucher <bouanto@zoho.com>
Date: Fri, 26 Jan 2024 11:31:47 -0500
Subject: [PATCH] libgccjit: Clear pending_assemble_externals_processed

Without this patch, code using exception handling will fail the
following assert in the function assemble_external_libcall in varasm.cc:

    gcc_assert (!pending_assemble_externals_processed)

gcc/ChangeLog:
	PR jit/113842
	* toplev.cc (toplev::finalize): Call varasm_cc_finalize.
	* varasm.cc (varasm_cc_finalize): New function to clear
	pending_assemble_externals_processed.
	* varasm.h (varasm_cc_finalize): New function.
---
 gcc/toplev.cc | 1 +
 gcc/varasm.cc | 8 ++++++++
 gcc/varasm.h  | 2 ++
 3 files changed, 11 insertions(+)

diff --git a/gcc/toplev.cc b/gcc/toplev.cc
index 175d4cd18fa..eca8ba292b4 100644
--- a/gcc/toplev.cc
+++ b/gcc/toplev.cc
@@ -2372,6 +2372,7 @@  toplev::finalize (void)
   ira_costs_cc_finalize ();
   tree_cc_finalize ();
   reginfo_cc_finalize ();
+  varasm_cc_finalize ();
 
   /* save_decoded_options uses opts_obstack, so these must
      be cleaned up together.  */
diff --git a/gcc/varasm.cc b/gcc/varasm.cc
index fa17eff551e..2aa46b498e4 100644
--- a/gcc/varasm.cc
+++ b/gcc/varasm.cc
@@ -8661,4 +8661,12 @@  handle_vtv_comdat_section (section *sect, const_tree decl ATTRIBUTE_UNUSED)
   switch_to_comdat_section(sect, DECL_NAME (decl));
 }
 
+void
+varasm_cc_finalize (void)
+{
+#ifdef ASM_OUTPUT_EXTERNAL
+  pending_assemble_externals_processed = false;
+#endif
+}
+
 #include "gt-varasm.h"
diff --git a/gcc/varasm.h b/gcc/varasm.h
index d9311dc370b..26e6fab8601 100644
--- a/gcc/varasm.h
+++ b/gcc/varasm.h
@@ -81,4 +81,6 @@  extern rtx assemble_trampoline_template (void);
 
 extern void switch_to_comdat_section (section *, tree);
 
+extern void varasm_cc_finalize (void);
+
 #endif  // GCC_VARASM_H
-- 
2.43.0