diff mbox series

late-combine: Honor targetm.cannot_copy_insn_p

Message ID mptjzidqfol.fsf@arm.com
State New
Headers show
Series late-combine: Honor targetm.cannot_copy_insn_p | expand

Commit Message

Richard Sandiford June 25, 2024, 2:07 p.m. UTC
late-combine was failing to take targetm.cannot_copy_insn_p into
account, which led to multiple definitions of PIC symbols on
arm*-*-* targets.

Currently bootstrapping & regression testing on arm-linux-gnueabihf
and aarch64-linus-gnu.  It should fix the bootstrap-lto problem
reported by Linaro's CI.  OK to install if testing passes?

Richard


gcc/
	* late-combine.cc (insn_combination::substitute_nondebug_use):
	Reject second and subsequent uses if targetm.cannot_copy_insn_p
	disallows copying.
---
 gcc/late-combine.cc | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Comments

Jeff Law June 25, 2024, 2:20 p.m. UTC | #1
On 6/25/24 8:07 AM, Richard Sandiford wrote:
> late-combine was failing to take targetm.cannot_copy_insn_p into
> account, which led to multiple definitions of PIC symbols on
> arm*-*-* targets.
> 
> Currently bootstrapping & regression testing on arm-linux-gnueabihf
> and aarch64-linus-gnu.  It should fix the bootstrap-lto problem
> reported by Linaro's CI.  OK to install if testing passes?
> 
> Richard
> 
> 
> gcc/
> 	* late-combine.cc (insn_combination::substitute_nondebug_use):
> 	Reject second and subsequent uses if targetm.cannot_copy_insn_p
> 	disallows copying.
> ---
>   gcc/late-combine.cc | 12 ++++++++++++
>   1 file changed, 12 insertions(+)
> 
> diff --git a/gcc/late-combine.cc b/gcc/late-combine.cc
> index fc75d1c56d7..b7c0bc07a8b 100644
> --- a/gcc/late-combine.cc
> +++ b/gcc/late-combine.cc
> @@ -179,6 +179,18 @@ insn_combination::substitute_nondebug_use (use_info *use)
>     if (dump_file && (dump_flags & TDF_DETAILS))
>       dump_insn_slim (dump_file, use->insn ()->rtl ());
>   
> +  // Reject second and subsequent uses if the target does not allow
> +  // the defining instruction to be copied.
> +  if (targetm.cannot_copy_insn_p
> +      && m_nondebug_changes.length () >= 2
> +      && targetm.cannot_copy_insn_p (m_def_insn->rtl ()))
> +    {
> +      if (dump_file && (dump_flags & TDF_DETAILS))
> +	fprintf (dump_file, "-- The target does not allow multiple"
> +		 " copies of insn %d\n", m_def_insn->uid ());
> +      return false;
> +    }
OK
jeff
diff mbox series

Patch

diff --git a/gcc/late-combine.cc b/gcc/late-combine.cc
index fc75d1c56d7..b7c0bc07a8b 100644
--- a/gcc/late-combine.cc
+++ b/gcc/late-combine.cc
@@ -179,6 +179,18 @@  insn_combination::substitute_nondebug_use (use_info *use)
   if (dump_file && (dump_flags & TDF_DETAILS))
     dump_insn_slim (dump_file, use->insn ()->rtl ());
 
+  // Reject second and subsequent uses if the target does not allow
+  // the defining instruction to be copied.
+  if (targetm.cannot_copy_insn_p
+      && m_nondebug_changes.length () >= 2
+      && targetm.cannot_copy_insn_p (m_def_insn->rtl ()))
+    {
+      if (dump_file && (dump_flags & TDF_DETAILS))
+	fprintf (dump_file, "-- The target does not allow multiple"
+		 " copies of insn %d\n", m_def_insn->uid ());
+      return false;
+    }
+
   // Check that we can change the instruction pattern.  Leave recognition
   // of the result till later.
   insn_propagation prop (use_rtl, m_dest, m_src);