From: Alan Modra <amodra@gmail.com>
To: gcc-patches@gcc.gnu.org
Subject: [RFC] PR64703, glibc sysdeps/powerpc/powerpc64/dl-machine.h miscompile
Date: Sat, 24 Jan 2015 02:37:00 -0000 [thread overview]
Message-ID: <20150123232339.GS12931@bubble.grove.modra.org> (raw)
How does this look as a potential fix for PR64703? I haven't made
many forays into gimple code, so even though this patch passes
bootstrap and regression testing on powerpc64-linux it's quite
possible this is the wrong place to change. If it does look to be OK,
then I'll fill out the targetm changes, include a testcase etc.
PR target/64703
* tree-ssa-alias.c (pt_solution_includes_base): New function,
extracted from..
(ref_maybe_used_by_call_p_1): ..here. Delete dead code checking
for NULL return from ao_ref_base. Handle potential memory
reference by indirect calls on targets using function descriptors.
Index: gcc/tree-ssa-alias.c
===================================================================
--- gcc/tree-ssa-alias.c (revision 220025)
+++ gcc/tree-ssa-alias.c (working copy)
@@ -1532,6 +1532,23 @@ refs_output_dependent_p (tree store1, tree store2)
return refs_may_alias_p_1 (&r1, &r2, false);
}
+static bool
+pt_solution_includes_base (struct pt_solution *pt, tree base)
+{
+ if (DECL_P (base))
+ return pt_solution_includes (pt, base);
+
+ if ((TREE_CODE (base) == MEM_REF
+ || TREE_CODE (base) == TARGET_MEM_REF)
+ && TREE_CODE (TREE_OPERAND (base, 0)) == SSA_NAME)
+ {
+ struct ptr_info_def *pi = SSA_NAME_PTR_INFO (TREE_OPERAND (base, 0));
+ if (pi)
+ return pt_solutions_intersect (pt, &pi->pt);
+ }
+ return true;
+}
+
/* If the call CALL may use the memory reference REF return true,
otherwise return false. */
@@ -1542,15 +1559,24 @@ ref_maybe_used_by_call_p_1 (gcall *call, ao_ref *r
unsigned i;
int flags = gimple_call_flags (call);
+ base = ao_ref_base (ref);
+ callee = gimple_call_fn (call);
+ if (callee && TREE_CODE (callee) == SSA_NAME
+ /* && targetm.function_descriptors */)
+ {
+ /* Handle indirect call. When a target defines the address of a
+ function as that of a function descriptor, then dereferencing
+ a function pointer implicitly references memory. */
+ struct ptr_info_def *pi = SSA_NAME_PTR_INFO (callee);
+ if (pi && pt_solution_includes_base (&pi->pt, base))
+ return true;
+ }
+
/* Const functions without a static chain do not implicitly use memory. */
if (!gimple_call_chain (call)
&& (flags & (ECF_CONST|ECF_NOVOPS)))
goto process_args;
- base = ao_ref_base (ref);
- if (!base)
- return true;
-
/* A call that is not without side-effects might involve volatile
accesses and thus conflicts with all other volatile accesses. */
if (ref->volatile_p)
@@ -1564,7 +1590,7 @@ ref_maybe_used_by_call_p_1 (gcall *call, ao_ref *r
&& !is_global_var (base))
goto process_args;
- callee = gimple_call_fndecl (call);
+ callee = gimple_call_addr_fndecl (callee);
/* Handle those builtin functions explicitly that do not act as
escape points. See tree-ssa-structalias.c:find_func_aliases
@@ -1803,23 +1829,7 @@ ref_maybe_used_by_call_p_1 (gcall *call, ao_ref *r
}
/* Check if the base variable is call-used. */
- if (DECL_P (base))
- {
- if (pt_solution_includes (gimple_call_use_set (call), base))
- return true;
- }
- else if ((TREE_CODE (base) == MEM_REF
- || TREE_CODE (base) == TARGET_MEM_REF)
- && TREE_CODE (TREE_OPERAND (base, 0)) == SSA_NAME)
- {
- struct ptr_info_def *pi = SSA_NAME_PTR_INFO (TREE_OPERAND (base, 0));
- if (!pi)
- return true;
-
- if (pt_solutions_intersect (gimple_call_use_set (call), &pi->pt))
- return true;
- }
- else
+ if (pt_solution_includes_base (gimple_call_use_set (call), base))
return true;
/* Inspect call arguments for passed-by-value aliases. */
--
Alan Modra
Australia Development Lab, IBM
next reply other threads:[~2015-01-23 23:23 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-24 2:37 Alan Modra [this message]
2015-01-26 9:56 ` Richard Biener
2015-01-27 14:27 ` Alan Modra
2015-01-29 15:06 ` Alan Modra
2015-01-29 16:30 ` Richard Biener
2015-01-29 16:31 ` Richard Biener
2015-01-29 16:32 ` Richard Biener
2015-01-29 17:48 ` Jakub Jelinek
2015-01-30 6:00 ` Alan Modra
2015-01-30 6:11 ` Alan Modra
2015-01-30 8:52 ` Alan Modra
2015-01-30 10:23 ` Richard Biener
2015-01-30 11:00 ` Jakub Jelinek
2015-02-02 9:29 ` Alan Modra
2015-01-29 20:35 ` Segher Boessenkool
2015-01-29 20:36 ` Jakub Jelinek
2015-01-29 20:44 ` Segher Boessenkool
2015-01-29 16:35 David Edelsohn
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150123232339.GS12931@bubble.grove.modra.org \
--to=amodra@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).