aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/ipa/pr103132.c
diff options
context:
space:
mode:
authorMartin Jambor <mjambor@suse.cz>2021-11-09 11:32:20 +0100
committerMartin Jambor <mjambor@suse.cz>2021-11-09 11:37:17 +0100
commitdf8690f28379795a44aa4b6c737df08828168b6a (patch)
tree2753929a1be7fd687d5472c67569bf8505933d8e /gcc/testsuite/gcc.dg/ipa/pr103132.c
parent77eb8c649d6dff15e63e2ea71a4a1b513a4be844 (diff)
downloadgcc-df8690f28379795a44aa4b6c737df08828168b6a.zip
gcc-df8690f28379795a44aa4b6c737df08828168b6a.tar.gz
gcc-df8690f28379795a44aa4b6c737df08828168b6a.tar.bz2
ipa: Fix segfault when remapping debug_binds with expressions (PR 103132)
My initial implementation of the method ipa_param_body_adjustments::remap_with_debug_expressions was based on the assumption that if it was asked to remap an expression (as opposed to a simple SSA_NAME), the expression would not contain an SSA_NAME operand which is to be debug-reset. While that is true for when called from ipa_param_body_adjustments::prepare_debug_expressions, it turns out it is not true when invoked from remap_gimple_stmt in tree-inline.c. This patch adds a simple logic to handle such cases and simply map the entire value to NULL_TREE in those cases. gcc/ChangeLog: 2021-11-08 Martin Jambor <mjambor@suse.cz> PR ipa/103132 * ipa-param-manipulation.c (replace_with_mapped_expr): Early return with error_mark_mode when part of expression is mapped to NULL. (ipa_param_body_adjustments::remap_with_debug_expressions): Set mapped value to NULL if walk_tree returns error_mark_mode. gcc/testsuite/ChangeLog: 2021-11-08 Martin Jambor <mjambor@suse.cz> PR ipa/103132 * gcc.dg/ipa/pr103132.c: New test.
Diffstat (limited to 'gcc/testsuite/gcc.dg/ipa/pr103132.c')
-rw-r--r--gcc/testsuite/gcc.dg/ipa/pr103132.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/ipa/pr103132.c b/gcc/testsuite/gcc.dg/ipa/pr103132.c
new file mode 100644
index 0000000..bef5649
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/pr103132.c
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -g" } */
+
+int globus_i_GLOBUS_GRIDFTP_SERVER_debug_handle_1;
+int globus_l_gfs_ipc_unpack_data__sz;
+void globus_i_GLOBUS_GRIDFTP_SERVER_debug_printf(const char *, ...);
+static void globus_l_gfs_ipc_unpack_cred(int len) {
+ if (globus_i_GLOBUS_GRIDFTP_SERVER_debug_handle_1)
+ globus_i_GLOBUS_GRIDFTP_SERVER_debug_printf("", __func__);
+}
+static void globus_l_gfs_ipc_unpack_data(int len) {
+ for (; globus_l_gfs_ipc_unpack_data__sz;)
+ len--;
+ len -= 4;
+ len -= 4;
+ globus_l_gfs_ipc_unpack_cred(len);
+}
+void globus_l_gfs_ipc_reply_read_body_cb(int len)
+{ globus_l_gfs_ipc_unpack_data(len); }