This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] PR rtl-optimization/32219: optimizer causees wrong code in pic/hidden/weak symbol checking
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Richard Henderson <rth at redhat dot com>
- Cc: Jack Howarth <howarth dot at dot gcc at gmail dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>, Mike Stump <mikestump at comcast dot net>, Iain Sandoe <iain at codesourcery dot com>, Jan Hubicka <hubicka at ucw dot cz>
- Date: Thu, 12 Feb 2015 15:04:03 -0800
- Subject: Re: [PATCH] PR rtl-optimization/32219: optimizer causees wrong code in pic/hidden/weak symbol checking
- Authentication-results: sourceware.org; auth=none
- References: <20150206162314 dot GA12597 at intel dot com> <CAJMcOU9UbX=C2t=6X+DOTynkCurczbGNG3dqZRwjmRe8_U1fCg at mail dot gmail dot com> <CAMe9rOqHHZFHS4YMOAdN16aNyn4hi6eyzxGUrMue2uDn76ydGg at mail dot gmail dot com> <CAJMcOU9+x47s7jwRL4uniLs2z9EHR_Ajfk==HX1mObm97qytCg at mail dot gmail dot com> <CAMe9rOr5Ktk_yhfFX9DHAb6Sq=v2SORaY6TbahSiKF9dB1LNSQ at mail dot gmail dot com> <CAJMcOU-hPQYF1k58CXP4E5K2_-3F50RaMV_rHm3f5R_hXxivWQ at mail dot gmail dot com> <20150207122739 dot GA25185 at gmail dot com> <CAJMcOU-Bk1i9LeaHLpZGspWjDcY_n2qFcNgnCbbEsq30ZPTipA at mail dot gmail dot com> <20150207155606 dot GA14159 at gmail dot com> <20150207164507 dot GA19402 at gmail dot com> <54DA75D2 dot 40402 at redhat dot com> <54DC46BF dot 5060503 at redhat dot com> <CAMe9rOo+qukAAFFG=3xdu1z8GnX_k-ELY+=0Ym-f0YdfymTuYA at mail dot gmail dot com> <CAMe9rOrFdRqFXxw-ASFasb8M+UaaT4NNKrWUZ+D-CjpFGvOuNA at mail dot gmail dot com> <54DCFE10 dot 3050906 at redhat dot com>
On Thu, Feb 12, 2015 at 11:25 AM, Richard Henderson <rth@redhat.com> wrote:
> On 02/12/2015 10:58 AM, H.J. Lu wrote:
>> if (DECL_VISIBILITY_SPECIFIED (exp)
>> + && (resolved_locally
>> + || !flag_pic
>
> Yes, this essentially goes back to your original patch, which I claim still
> conflates issues.
>
> In particular, I believe mentioning flag_pic here is a serious error.
>
> There are two problems that I see so far,
>
> (1) node->definition isn't set for this symbol. This is because you
> only fixed varpool_node::finalize_decl, and not
> cgraph_node::finalize_function.
>
> (2) The weak test should probably be split into two pieces, like the
> visibility test: exclude undefined weak, include specified visibility,
> exclude non-dominant weak, exclude external, include implied visibility.
>
How about this patch?
--
H.J.
From 3b516badec25151acd4a96fa4ef07b3f88e3f053 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Thu, 12 Feb 2015 10:55:55 -0800
Subject: [PATCH] A variable is local if specified by user
And it is resolved or defined locally, not compiling for PIC or not weak.
---
gcc/varasm.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/gcc/varasm.c b/gcc/varasm.c
index 9f79416..b14f2d3 100644
--- a/gcc/varasm.c
+++ b/gcc/varasm.c
@@ -6838,15 +6838,21 @@ default_binds_local_p_2 (const_tree exp, bool shlib, bool weak_dominate)
resolved_locally = true;
}
- /* Undefined (or non-dominant) weak symbols are not defined locally. */
- if (DECL_WEAK (exp) && !resolved_locally)
- return false;
-
- /* A variable is local if the user has said explicitly that it will be. */
+ /* A variable is local if the user has said explicitly that it will
+ be and it is resolved or defined locally, not compiling for PIC or
+ not weak. */
if (DECL_VISIBILITY_SPECIFIED (exp)
+ && (resolved_locally
+ || !flag_pic
+ || !DECL_EXTERNAL (exp)
+ || !DECL_WEAK (exp))
&& DECL_VISIBILITY (exp) != VISIBILITY_DEFAULT)
return true;
+ /* Undefined (or non-dominant) weak symbols are not defined locally. */
+ if (DECL_WEAK (exp) && !resolved_locally)
+ return false;
+
/* Variables defined outside this object might not be local. */
if (DECL_EXTERNAL (exp) && !resolved_locally)
return false;
--
1.9.3