This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PR 71234] Avoid valgrind warning in ipa-cp


Hi,

ipa_find_agg_cst_for_param can leave from_global_constant as it is
when it returns NULL.  It's user ipa_get_indirect_edge_target_1 then
reads that uninitialized value when it tests whether it should NULLify
the result itself, which was caught by valgrind.

Fixed by the patch below, which checks whether
ipa_find_agg_cst_for_param returned non-NULL before loading
from_global_constant.  I decided to address it here rather than in
ipa_find_agg_cst_for_param because that would require a check that
from_global_constant in not NULL there and because it is consistent
with how by_ref is returned in other functions in ipa-prop.

Bootstrapped and tested on x86_64-linux, I will go ahead and commit it
as obvious.

Martin


2016-05-23  Martin Jambor  <mjambor@suse.cz>

	PR ipa/71234
	* ipa-cp.c (ipa_get_indirect_edge_target_1): Only check value of
	from_global_constant if t is not NULL.
---
 gcc/ipa-cp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c
index 8caa973..4b7f6bb 100644
--- a/gcc/ipa-cp.c
+++ b/gcc/ipa-cp.c
@@ -2027,7 +2027,8 @@ ipa_get_indirect_edge_target_1 (struct cgraph_edge *ie,
 					      ie->indirect_info->offset,
 					      ie->indirect_info->by_ref,
 					      &from_global_constant);
-	      if (!from_global_constant
+	      if (t
+		  && !from_global_constant
 		  && !ie->indirect_info->guaranteed_unmodified)
 		t = NULL_TREE;
 	    }
-- 
2.8.2


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]