public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/aoliva/heads/testme)] Cope with NULL dw_cfi_cfa_loc
@ 2022-02-23 8:26 Alexandre Oliva
0 siblings, 0 replies; 2+ messages in thread
From: Alexandre Oliva @ 2022-02-23 8:26 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:3a5fa6adb7edd9732cbcbc88a1784ee5ad904856
commit 3a5fa6adb7edd9732cbcbc88a1784ee5ad904856
Author: Alexandre Oliva <oliva@adacore.com>
Date: Wed Feb 23 05:00:03 2022 -0300
Cope with NULL dw_cfi_cfa_loc
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.
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.
Diff:
---
gcc/dwarf2cfi.cc | 3 +++
gcc/testsuite/g++.dg/pr104540.C | 21 +++++++++++++++++++++
2 files changed, 24 insertions(+)
diff --git a/gcc/dwarf2cfi.cc b/gcc/dwarf2cfi.cc
index 9ca97d7a3bf..ab7c5cc5b27 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 00000000000..a86ecbfd088
--- /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);
+}
^ permalink raw reply [flat|nested] 2+ messages in thread
* [gcc(refs/users/aoliva/heads/testme)] Cope with NULL dw_cfi_cfa_loc
@ 2022-02-23 19:40 Alexandre Oliva
0 siblings, 0 replies; 2+ messages in thread
From: Alexandre Oliva @ 2022-02-23 19:40 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:fdd55700563537a330b86ff273398b53c4cd81b8
commit fdd55700563537a330b86ff273398b53c4cd81b8
Author: Alexandre Oliva <oliva@adacore.com>
Date: Wed Feb 23 05:00:03 2022 -0300
Cope with NULL dw_cfi_cfa_loc
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.
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.
Diff:
---
gcc/dwarf2cfi.cc | 3 +++
gcc/testsuite/g++.dg/pr104540.C | 21 +++++++++++++++++++++
2 files changed, 24 insertions(+)
diff --git a/gcc/dwarf2cfi.cc b/gcc/dwarf2cfi.cc
index 9ca97d7a3bf..ab7c5cc5b27 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 00000000000..a86ecbfd088
--- /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);
+}
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-02-23 19:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-23 8:26 [gcc(refs/users/aoliva/heads/testme)] Cope with NULL dw_cfi_cfa_loc Alexandre Oliva
2022-02-23 19:40 Alexandre Oliva
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).