aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorAlexandre Oliva <oliva@adacore.com>2022-02-24 22:03:34 -0300
committerAlexandre Oliva <oliva@gnu.org>2022-02-24 22:03:34 -0300
commita026b67f8f70d6cf35daf42a4b0909f78c9d7f40 (patch)
tree5919e9a5d44357ab3440937fcafe2f3c5b499189 /gcc
parente53bb1965db9c7882ded4a70296340d8db52053a (diff)
downloadgcc-a026b67f8f70d6cf35daf42a4b0909f78c9d7f40.zip
gcc-a026b67f8f70d6cf35daf42a4b0909f78c9d7f40.tar.gz
gcc-a026b67f8f70d6cf35daf42a4b0909f78c9d7f40.tar.bz2
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.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/dwarf2cfi.cc3
-rw-r--r--gcc/testsuite/g++.dg/pr104540.C21
2 files changed, 24 insertions, 0 deletions
diff --git a/gcc/dwarf2cfi.cc b/gcc/dwarf2cfi.cc
index 9ca97d7..ab7c5cc 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 0000000..a86ecbf
--- /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);
+}