aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorAlexandre Oliva <aoliva@redhat.com>2018-12-06 23:18:19 +0000
committerAlexandre Oliva <aoliva@gcc.gnu.org>2018-12-06 23:18:19 +0000
commit695be0923410ad753e9d7bc377f992406f904e94 (patch)
treeadaf137bbb4c1eb8f14668db5114718686bee04c /gcc
parent4cbb7085f078ad25f7f11855d91c143e1189e89b (diff)
downloadgcc-695be0923410ad753e9d7bc377f992406f904e94.zip
gcc-695be0923410ad753e9d7bc377f992406f904e94.tar.gz
gcc-695be0923410ad753e9d7bc377f992406f904e94.tar.bz2
avoid null ptr deref in cselib_record_sets
Jeff Law tells me h8300-elf fails gcc.c-torture/compile/pr49029.c with -O2 -g -mint32 -mh. This patch fixes it. The problem is that strict low part handling in cselib_record_sets assumes src_elt is not NULL. That src_elt is taken from a strict low part set, but it won't always have a src_elt to begin with. In this case, it's because src is a volatile MEM; we don't record values for those. Although we could fix the problem by testing for a NULL src_elt before creating the zero extends corresponding to strict low part sets of formerly const0_rtx REGs, there's no point in recording the additional set that we won't be able to use anyway. We could still record that the whole register has a zero-extend of the value stored in the narrower-mode strict low part of the register, but is that of any use? I guess not, but if we find otherwise, we can change that later. for gcc/ChangeLog * cselib.c (cselib_record_sets): Skip strict low part sets with NULL src_elt. From-SVN: r266873
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/cselib.c1
2 files changed, 6 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index dc59688..2dc7f43 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2018-12-06 Alexandre Oliva <aoliva@redhat.com>
+
+ * cselib.c (cselib_record_sets): Skip strict low part sets
+ with NULL src_elt.
+
2018-12-06 Paul A. Clarke <pc@us.ibm.com>
PR target/88316
diff --git a/gcc/cselib.c b/gcc/cselib.c
index 6d3a407..4a68439 100644
--- a/gcc/cselib.c
+++ b/gcc/cselib.c
@@ -2616,6 +2616,7 @@ cselib_record_sets (rtx_insn *insn)
preserves the upper bits that di:SI=zero_extend(flags:CCNO<=0). */
scalar_int_mode mode;
if (dest != orig
+ && sets[i].src_elt
&& cselib_record_sets_hook
&& REG_P (dest)
&& HARD_REGISTER_P (dest)