public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Cope with NULL dw_cfi_cfa_loc
@ 2022-02-23 22:45 Alexandre Oliva
  2022-02-24 10:33 ` Richard Biener
  2022-02-25 17:54 ` [committed] testsuite: Move pr104540.C test to g++.target/i386/ Jakub Jelinek
  0 siblings, 2 replies; 3+ messages in thread
From: Alexandre Oliva @ 2022-02-23 22:45 UTC (permalink / raw)
  To: gcc-patches


In def_cfa_0, we may set the 2nd operand's dw_cfi_cfa_loc to NULL, but
then cfi_oprnd_equal_p calls cfa_equal_p with a NULL dw_cfa_location*.
This patch aranges for us to tolerate NULL dw_cfi_cfa_loc.

Regstrapped on x86_64-linux-gnu.  Ok to install?


for  gcc/ChangeLog

	PR middle-end/104540
	* dwarf2cfi.cc (cfi_oprnd_equal_p): Cope with NULL
	dw_cfi_cfa_loc.

for  gcc/testsuite/ChangeLog

	PR middle-end/104540
	* g++.dg/PR104540.C: New.
---
 gcc/dwarf2cfi.cc                |    3 +++
 gcc/testsuite/g++.dg/pr104540.C |   21 +++++++++++++++++++++
 2 files changed, 24 insertions(+)
 create mode 100644 gcc/testsuite/g++.dg/pr104540.C

diff --git a/gcc/dwarf2cfi.cc b/gcc/dwarf2cfi.cc
index 9ca97d7a3bf56..ab7c5cc5b27b5 100644
--- a/gcc/dwarf2cfi.cc
+++ b/gcc/dwarf2cfi.cc
@@ -788,6 +788,9 @@ cfi_oprnd_equal_p (enum dw_cfi_oprnd_type t, dw_cfi_oprnd *a, dw_cfi_oprnd *b)
     case dw_cfi_oprnd_loc:
       return loc_descr_equal_p (a->dw_cfi_loc, b->dw_cfi_loc);
     case dw_cfi_oprnd_cfa_loc:
+      /* If any of them is NULL, don't dereference either.  */
+      if (!a->dw_cfi_cfa_loc || !b->dw_cfi_cfa_loc)
+	return a->dw_cfi_cfa_loc == b->dw_cfi_cfa_loc;
       return cfa_equal_p (a->dw_cfi_cfa_loc, b->dw_cfi_cfa_loc);
     }
   gcc_unreachable ();
diff --git a/gcc/testsuite/g++.dg/pr104540.C b/gcc/testsuite/g++.dg/pr104540.C
new file mode 100644
index 0000000000000..a86ecbfd088c3
--- /dev/null
+++ b/gcc/testsuite/g++.dg/pr104540.C
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fharden-conditional-branches -mforce-drap -mstackrealign --param=max-grow-copy-bb-insns=125" } */
+
+char c;
+int i;
+
+void bar(int);
+
+struct S {
+  int mi;
+  long ml;
+  S(int);
+};
+
+
+void foo() {
+  int s = c == 0 ? 1 : 2;
+  bar(s);
+  if (i)
+    S s(0);
+}


-- 
Alexandre Oliva, happy hacker                https://FSFLA.org/blogs/lxo/
   Free Software Activist                       GNU Toolchain Engineer
Disinformation flourishes because many people care deeply about injustice
but very few check the facts.  Ask me about <https://stallmansupport.org>

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

* Re: Cope with NULL dw_cfi_cfa_loc
  2022-02-23 22:45 Cope with NULL dw_cfi_cfa_loc Alexandre Oliva
@ 2022-02-24 10:33 ` Richard Biener
  2022-02-25 17:54 ` [committed] testsuite: Move pr104540.C test to g++.target/i386/ Jakub Jelinek
  1 sibling, 0 replies; 3+ messages in thread
From: Richard Biener @ 2022-02-24 10:33 UTC (permalink / raw)
  To: Alexandre Oliva; +Cc: GCC Patches

On Wed, Feb 23, 2022 at 11:46 PM Alexandre Oliva via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
>
> In def_cfa_0, we may set the 2nd operand's dw_cfi_cfa_loc to NULL, but
> then cfi_oprnd_equal_p calls cfa_equal_p with a NULL dw_cfa_location*.
> This patch aranges for us to tolerate NULL dw_cfi_cfa_loc.
>
> Regstrapped on x86_64-linux-gnu.  Ok to install?

OK.

Richard.

>
> for  gcc/ChangeLog
>
>         PR middle-end/104540
>         * dwarf2cfi.cc (cfi_oprnd_equal_p): Cope with NULL
>         dw_cfi_cfa_loc.
>
> for  gcc/testsuite/ChangeLog
>
>         PR middle-end/104540
>         * g++.dg/PR104540.C: New.
> ---
>  gcc/dwarf2cfi.cc                |    3 +++
>  gcc/testsuite/g++.dg/pr104540.C |   21 +++++++++++++++++++++
>  2 files changed, 24 insertions(+)
>  create mode 100644 gcc/testsuite/g++.dg/pr104540.C
>
> diff --git a/gcc/dwarf2cfi.cc b/gcc/dwarf2cfi.cc
> index 9ca97d7a3bf56..ab7c5cc5b27b5 100644
> --- a/gcc/dwarf2cfi.cc
> +++ b/gcc/dwarf2cfi.cc
> @@ -788,6 +788,9 @@ cfi_oprnd_equal_p (enum dw_cfi_oprnd_type t, dw_cfi_oprnd *a, dw_cfi_oprnd *b)
>      case dw_cfi_oprnd_loc:
>        return loc_descr_equal_p (a->dw_cfi_loc, b->dw_cfi_loc);
>      case dw_cfi_oprnd_cfa_loc:
> +      /* If any of them is NULL, don't dereference either.  */
> +      if (!a->dw_cfi_cfa_loc || !b->dw_cfi_cfa_loc)
> +       return a->dw_cfi_cfa_loc == b->dw_cfi_cfa_loc;
>        return cfa_equal_p (a->dw_cfi_cfa_loc, b->dw_cfi_cfa_loc);
>      }
>    gcc_unreachable ();
> diff --git a/gcc/testsuite/g++.dg/pr104540.C b/gcc/testsuite/g++.dg/pr104540.C
> new file mode 100644
> index 0000000000000..a86ecbfd088c3
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/pr104540.C
> @@ -0,0 +1,21 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O2 -fharden-conditional-branches -mforce-drap -mstackrealign --param=max-grow-copy-bb-insns=125" } */
> +
> +char c;
> +int i;
> +
> +void bar(int);
> +
> +struct S {
> +  int mi;
> +  long ml;
> +  S(int);
> +};
> +
> +
> +void foo() {
> +  int s = c == 0 ? 1 : 2;
> +  bar(s);
> +  if (i)
> +    S s(0);
> +}
>
>
> --
> Alexandre Oliva, happy hacker                https://FSFLA.org/blogs/lxo/
>    Free Software Activist                       GNU Toolchain Engineer
> Disinformation flourishes because many people care deeply about injustice
> but very few check the facts.  Ask me about <https://stallmansupport.org>

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

* [committed] testsuite: Move pr104540.C test to g++.target/i386/
  2022-02-23 22:45 Cope with NULL dw_cfi_cfa_loc Alexandre Oliva
  2022-02-24 10:33 ` Richard Biener
@ 2022-02-25 17:54 ` Jakub Jelinek
  1 sibling, 0 replies; 3+ messages in thread
From: Jakub Jelinek @ 2022-02-25 17:54 UTC (permalink / raw)
  To: Alexandre Oliva; +Cc: gcc-patches

On Wed, Feb 23, 2022 at 07:45:20PM -0300, Alexandre Oliva via Gcc-patches wrote:
> 	PR middle-end/104540
> 	* g++.dg/PR104540.C: New.

Both -mforce-drap and -mstackrealign options are x86 specific.

Tested on x86_64-linux, i686-linux and powerpc64le-linux, committed to
trunk.

2022-02-25  Jakub Jelinek  <jakub@redhat.com>

        * g++.dg/pr104540.C: Move to ...
        * g++.target/i386/pr104540.C: ... here.

diff --git a/gcc/testsuite/g++.dg/pr104540.C b/gcc/testsuite/g++.target/i386/pr104540.C
similarity index 100%
rename from gcc/testsuite/g++.dg/pr104540.C
rename to gcc/testsuite/g++.target/i386/pr104540.C

	Jakub


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

end of thread, other threads:[~2022-02-25 17:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-23 22:45 Cope with NULL dw_cfi_cfa_loc Alexandre Oliva
2022-02-24 10:33 ` Richard Biener
2022-02-25 17:54 ` [committed] testsuite: Move pr104540.C test to g++.target/i386/ Jakub Jelinek

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