]> git.ipfire.org Git - thirdparty/gcc.git/commit
avoid null ptr deref in cselib_record_sets
authoraoliva <aoliva@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 6 Dec 2018 23:18:19 +0000 (23:18 +0000)
committeraoliva <aoliva@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 6 Dec 2018 23:18:19 +0000 (23:18 +0000)
commitc1212d8d1ae719996123b2ea2aca2cd3ffc8a492
treeadaf137bbb4c1eb8f14668db5114718686bee04c
parent36839963adb6a7265b4c0bed338ac0ee2046cac0
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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@266873 138bc75d-0d04-0410-961f-82ee72b054a4
gcc/ChangeLog
gcc/cselib.c