public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] rtl-ssa: Fix updates to call clobbers [PR98403]
@ 2020-12-21 16:32 Richard Sandiford
  2021-01-04 21:13 ` Jeff Law
  0 siblings, 1 reply; 2+ messages in thread
From: Richard Sandiford @ 2020-12-21 16:32 UTC (permalink / raw)
  To: gcc-patches

In the PR, fwprop was changing a call instruction and tripped
an assert when trying to update a list of call clobbers.
There are two ways we could handle this: remove the call clobber
and then add it back, or assume that the clobber will stay in its
current place.

At the moment we don't have enough information to safely move
calls around, so the second approach seems simpler and more
efficient.

Tested on x86_64-linux-gnu and aarch64-linux-gnu.  OK to install?

Richard


gcc/
	PR rtl-optimization/98403
	* rtl-ssa/changes.cc (function_info::finalize_new_accesses): Explain
	why we don't remove call clobbers.
	(function_info::apply_changes_to_insn): Don't attempt to add
	call clobbers here.

gcc/testsuite/
	PR rtl-optimization/98403
	* g++.dg/opt/pr98403.C: New test.
---
 gcc/rtl-ssa/changes.cc             |   9 +-
 gcc/testsuite/g++.dg/opt/pr98403.C | 195 +++++++++++++++++++++++++++++
 2 files changed, 200 insertions(+), 4 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/opt/pr98403.C

diff --git a/gcc/rtl-ssa/changes.cc b/gcc/rtl-ssa/changes.cc
index 1885a80e2e9..aac64a00d07 100644
--- a/gcc/rtl-ssa/changes.cc
+++ b/gcc/rtl-ssa/changes.cc
@@ -423,7 +423,8 @@ function_info::finalize_new_accesses (insn_change &change)
       }
 
   // Also keep any explicitly-recorded call clobbers, which are deliberately
-  // excluded from the vec_rtx_properties.
+  // excluded from the vec_rtx_properties.  Calls shouldn't move, so we can
+  // keep the definitions in their current position.
   for (def_info *def : change.new_defs)
     if (def->m_has_been_superceded && def->is_call_clobber ())
       {
@@ -533,10 +534,10 @@ function_info::apply_changes_to_insn (insn_change &change)
   // Copy the cost.
   insn->set_cost (change.new_cost);
 
-  // Add all clobbers.  Sets never moved relative to other definitions,
-  // so are OK as-is.
+  // Add all clobbers.  Sets and call clobbers never move relative to
+  // other definitions, so are OK as-is.
   for (def_info *def : change.new_defs)
-    if (is_a<clobber_info *> (def))
+    if (is_a<clobber_info *> (def) && !def->is_call_clobber ())
       add_def (def);
 
   // Add all uses, now that their position is final.
diff --git a/gcc/testsuite/g++.dg/opt/pr98403.C b/gcc/testsuite/g++.dg/opt/pr98403.C
new file mode 100644
index 00000000000..25522958112
--- /dev/null
+++ b/gcc/testsuite/g++.dg/opt/pr98403.C
@@ -0,0 +1,195 @@
+// { dg-options "-Og -fcse-follow-jumps -fipa-ra" }
+// { dg-require-effective-target c++11 }
+// { dg-additional-options "-march=goldmont -fPIC -mforce-indirect-call" { target { { i?86-*-* x86_64-*-* } && fpic } } }
+
+enum WindowClass { WC_NONE, WC_AI_SETTINGS, WC_AI_LIST };
+enum { AWV_DECREASE, AWV_INCREASE };
+enum WidgetType {
+  WWT_PANEL,
+  WWT_TEXT,
+  WWT_MATRIX,
+  WWT_FRAME,
+  WWT_CAPTION,
+  WWT_DEFSIZEBOX,
+  WWT_RESIZEBOX,
+  WWT_CLOSEBOX,
+  NWID_HORIZONTAL,
+  NWID_VERTICAL,
+  NWID_SPACER,
+  NWID_VSCROLLBAR,
+  WWT_PUSHTXTBTN,
+  WWT_PUSHARROWBTN
+};
+enum NWidContainerFlags { NC_NONE };
+struct NWidgetPartPIP {
+  char prepost;
+};
+struct NWidgetPart {
+  NWidgetPartPIP pip;
+} __trans_tmp_1;
+static NWidgetPart SetResize(short, short) {
+  NWidgetPart part;
+  return part;
+}
+NWidgetPart SetMinimalSize(short, short);
+static NWidgetPart SetFill(int, int) {
+  NWidgetPart part;
+  return part;
+}
+static NWidgetPart EndContainer() {
+  NWidgetPart part;
+  return part;
+}
+static NWidgetPart SetDataTip(int, int) {
+  NWidgetPart part;
+  return part;
+}
+static NWidgetPart SetMatrixDataTip(char, char, int) { return __trans_tmp_1; }
+NWidgetPart SetPadding();
+NWidgetPart SetScrollbar(int);
+NWidgetPart NWidget(WidgetType, NWidContainerFlags = NC_NONE);
+struct WindowDesc {
+  WindowDesc(const char *, short, short, WindowClass, WindowClass, int,
+             const NWidgetPart *, short, int * = nullptr);
+  ~WindowDesc();
+};
+class CommandCost {
+public:
+  CommandCost(int);
+} const CMD_ERROR(5);
+enum { WID_AIC_SCROLLBAR };
+const NWidgetPart _nested_ai_list_widgets[]{NWidget(NWID_HORIZONTAL),
+                                            NWidget(WWT_CLOSEBOX),
+                                            NWidget(WWT_CAPTION),
+                                            SetDataTip(8, 4),
+                                            NWidget(WWT_DEFSIZEBOX),
+                                            NWidget(NWID_HORIZONTAL),
+                                            NWidget(WWT_MATRIX),
+                                            SetMinimalSize(8, 2),
+                                            SetFill(1, 1),
+                                            SetResize(1, 1),
+                                            SetMatrixDataTip(1, 0, 1),
+                                            EndContainer(),
+                                            NWidget(WWT_PANEL),
+                                            EndContainer(),
+                                            NWidget(NWID_HORIZONTAL),
+                                            NWidget(NWID_HORIZONTAL),
+                                            NWidget(WWT_PUSHTXTBTN),
+                                            SetResize(1, 0),
+                                            SetFill(1, 0),
+                                            SetDataTip(5, 0),
+                                            NWidget(WWT_PUSHTXTBTN),
+                                            SetResize(1, 0),
+                                            SetFill(1, 0),
+                                            SetDataTip(1, 2),
+                                            EndContainer(),
+                                            NWidget(WWT_RESIZEBOX),
+                                            EndContainer()};
+static WindowDesc _ai_list_desc("", 0, 4, WC_AI_LIST, WC_NONE, 0,
+                                _nested_ai_list_widgets, 0);
+const NWidgetPart _nested_ai_settings_widgets[]{NWidget(NWID_HORIZONTAL),
+                                                NWidget(WWT_CLOSEBOX),
+                                                NWidget(WWT_CAPTION),
+                                                SetDataTip(0, 4),
+                                                NWidget(WWT_DEFSIZEBOX),
+                                                EndContainer(),
+                                                NWidget(NWID_HORIZONTAL),
+                                                NWidget(WWT_MATRIX),
+                                                SetMinimalSize(8, 2),
+                                                SetResize(1, 1),
+                                                SetFill(1, 0),
+                                                SetMatrixDataTip(1, 0, 0),
+                                                EndContainer(),
+                                                NWidget(NWID_HORIZONTAL),
+                                                NWidget(NWID_HORIZONTAL),
+                                                NWidget(WWT_PUSHTXTBTN),
+                                                SetResize(1, 0),
+                                                SetDataTip(3, 0),
+                                                NWidget(WWT_PUSHTXTBTN),
+                                                SetResize(1, 0),
+                                                SetDataTip(4, 0),
+                                                EndContainer(),
+                                                NWidget(WWT_RESIZEBOX),
+                                                EndContainer()};
+static WindowDesc _ai_settings_desc("", 0, 208, WC_AI_SETTINGS, WC_NONE, 0,
+                                    _nested_ai_settings_widgets, 0);
+NWidgetPart _nested_ai_config_widgets[]{NWidget(NWID_HORIZONTAL),
+                                        NWidget(WWT_CLOSEBOX),
+                                        NWidget(WWT_CAPTION),
+                                        SetDataTip(5, 4),
+                                        EndContainer(),
+                                        NWidget(WWT_PANEL),
+                                        NWidget(NWID_VERTICAL),
+                                        SetPadding(),
+                                        NWidget(NWID_HORIZONTAL),
+                                        SetPadding(),
+                                        NWidget(WWT_PUSHARROWBTN),
+                                        SetFill(0, 1),
+                                        SetDataTip(AWV_DECREASE, 0),
+                                        NWidget(WWT_PUSHARROWBTN),
+                                        SetFill(0, 1),
+                                        SetDataTip(AWV_INCREASE, 0),
+                                        NWidget(NWID_SPACER),
+                                        SetMinimalSize(6, 0),
+                                        NWidget(WWT_TEXT),
+                                        SetDataTip(3, 0),
+                                        SetFill(1, 0),
+                                        SetPadding(),
+                                        EndContainer(),
+                                        NWidget(NWID_HORIZONTAL),
+                                        SetPadding(),
+                                        NWidget(WWT_PUSHTXTBTN),
+                                        SetResize(1, 0),
+                                        SetFill(1, 0),
+                                        SetDataTip(1, 2),
+                                        NWidget(WWT_PUSHTXTBTN),
+                                        SetResize(1, 0),
+                                        SetFill(1, 0),
+                                        SetDataTip(3, 4),
+                                        EndContainer(),
+                                        EndContainer(),
+                                        SetPadding(),
+                                        NWidget(NWID_HORIZONTAL),
+                                        NWidget(WWT_MATRIX),
+                                        SetMinimalSize(1, 0),
+                                        SetMatrixDataTip(1, 8, 7),
+                                        SetScrollbar(WID_AIC_SCROLLBAR),
+                                        NWidget(NWID_VSCROLLBAR),
+                                        EndContainer(),
+                                        EndContainer(),
+                                        NWidget(NWID_SPACER),
+                                        SetMinimalSize(0, 9),
+                                        NWidget(WWT_FRAME),
+                                        SetDataTip(5, 0),
+                                        SetPadding(),
+                                        NWidget(WWT_MATRIX),
+                                        SetMinimalSize(1, 0),
+                                        SetMatrixDataTip(1, 1, 6),
+                                        EndContainer(),
+                                        NWidget(NWID_HORIZONTAL),
+                                        SetPadding(),
+                                        NWidget(WWT_PUSHTXTBTN),
+                                        SetFill(1, 0),
+                                        SetMinimalSize(3, 2),
+                                        SetDataTip(1, 5),
+                                        NWidget(WWT_PUSHTXTBTN),
+                                        SetFill(1, 0),
+                                        SetMinimalSize(3, 2),
+                                        SetDataTip(6, 7),
+                                        NWidget(WWT_PUSHTXTBTN),
+                                        SetFill(1, 0),
+                                        SetMinimalSize(3, 2),
+                                        SetDataTip(3, 0),
+                                        EndContainer(),
+                                        NWidget(WWT_PUSHTXTBTN),
+                                        SetFill(1, 0),
+                                        SetResize(1, 0),
+                                        SetDataTip(6, 0),
+                                        NWidget(WWT_PUSHTXTBTN),
+                                        SetFill(1, 0),
+                                        SetResize(1, 0),
+                                        SetDataTip(7, 0),
+                                        NWidget(WWT_PUSHTXTBTN),
+                                        SetFill(1, 0),
+                                        SetResize(1, 0),
+                                        SetDataTip(2, 3)};

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

* Re: [PATCH] rtl-ssa: Fix updates to call clobbers [PR98403]
  2020-12-21 16:32 [PATCH] rtl-ssa: Fix updates to call clobbers [PR98403] Richard Sandiford
@ 2021-01-04 21:13 ` Jeff Law
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff Law @ 2021-01-04 21:13 UTC (permalink / raw)
  To: gcc-patches, richard.sandiford



On 12/21/20 9:32 AM, Richard Sandiford wrote:
> In the PR, fwprop was changing a call instruction and tripped
> an assert when trying to update a list of call clobbers.
> There are two ways we could handle this: remove the call clobber
> and then add it back, or assume that the clobber will stay in its
> current place.
>
> At the moment we don't have enough information to safely move
> calls around, so the second approach seems simpler and more
> efficient.
>
> Tested on x86_64-linux-gnu and aarch64-linux-gnu.  OK to install?
>
> Richard
>
>
> gcc/
> 	PR rtl-optimization/98403
> 	* rtl-ssa/changes.cc (function_info::finalize_new_accesses): Explain
> 	why we don't remove call clobbers.
> 	(function_info::apply_changes_to_insn): Don't attempt to add
> 	call clobbers here.
>
> gcc/testsuite/
> 	PR rtl-optimization/98403
> 	* g++.dg/opt/pr98403.C: New test.
OK
jeff


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

end of thread, other threads:[~2021-01-04 21:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-21 16:32 [PATCH] rtl-ssa: Fix updates to call clobbers [PR98403] Richard Sandiford
2021-01-04 21:13 ` Jeff Law

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).