public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Alexandre Oliva <aoliva@redhat.com>
To: Richard Biener <richard.guenther@gmail.com>
Cc: gcc-patches@gcc.gnu.org, Jan Hubicka <hubicka@ucw.cz>
Subject: Re: [PR libmudflap/53359] don't register symbols not emitted
Date: Wed, 16 Jan 2013 09:29:00 -0000	[thread overview]
Message-ID: <orhamh5vcv.fsf@livre.localdomain> (raw)
In-Reply-To: <CAFiYyc063PaXUVUPq4JNciUakjZsZ7+=erEkg2U_QLctr+Bw_A@mail.gmail.com>	(Richard Biener's message of "Mon, 7 Jan 2013 10:27:54 +0100")

On Jan  7, 2013, Richard Biener <richard.guenther@gmail.com> wrote:

> On Sun, Jan 6, 2013 at 8:47 PM, Alexandre Oliva <aoliva@redhat.com> wrote:
>> On Jan  2, 2013, Richard Biener <richard.guenther@gmail.com> wrote:
>> 
>>> On Sun, Dec 30, 2012 at 1:22 AM, Alexandre Oliva <aoliva@redhat.com> wrote:
>>>> On Dec 21, 2012, Richard Biener <richard.guenther@gmail.com> wrote:
>>>> 
>>>>> On Fri, Dec 21, 2012 at 6:33 AM, Alexandre Oliva <aoliva@redhat.com> wrote:
>>>>>> libmudflap emits a global initializer that registers memory ranges for
>>>>>> global data symbols.  However, even if IPA decides not to emit a symbol
>>>>>> because it's unused, we'd still emit registration sequences for them in
>>>>>> some cases, which, in the PR testcase, would result in TOC references to
>>>>>> the undefined symbols.
>>>> 
>>>>> Hmm, I think that at this point of the compilation you are looking for
>>>>> TREE_ASM_WRITTEN instead.
>>>> 
>>>> That doesn't work, several mudflap regressions show up because accesses
>>>> to global library symbols that are accessed by template methods compiled
>>>> with mudflap (say cout) are then verified but not registered.  We have
>>>> to register symbols that are not emitted but that referenced.
>> 
>>> Ehm, how can something be not emitted but still referenced?  You mean if
>>> it's external?
>> 
>> Yeah.
>> 
>>> if (!TREE_ASM_WRITTEN (obj) || DECL_EXTERNAL (obj))
>> 
>>> instead?
>> 
>> Then we're back to the original bug.
>> 
>> How does the test above tell whether we're actually referencing the
>> object?  Only when we are do we want to register it with mudflap.  If
>> it's referenced and we don't register it, we get mudflap runtime errors.
>> If it's not referenced but we register it, we get link-time errors if
>> the symbol is one we'd have emitted if it was referenced.

> Then the bug is that we register something but do not actually tell the
> middle-end that this is a reference.

No, the bug is that we're registering something because at an earlier
point (when we emitted checks) there were references to it.  The
references were all optimized away, we correctly decided (elsewhere) the
object was not referenced, and we removed it from the symbol table, but
mudflap still wants to register it because it pays no attention to that
decision.

This is the reason why I believe the patch I proposed initially is the
correct fix.  Now, can you please tell me why you believe this diagnosis
is incorrect, or why the fix for the diagnosed problem is incorrect, to
the point of proposing alternate (faulty) approaches?

> I suppose instead of asking for TREE_ASM_WRITTEN you may want to look
> at DECL_RTL (which should be set for all referenced decls, whether
> external or not).

I'm pretty sure the optimized-away objects that we do NOT want to
register had DECL_RTL set, but I'm not exactly excited about double
checking it without at least a hint of an explanation on what seems to
be wrong with the proposed patch.

-- 
Alexandre Oliva, freedom fighter    http://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/   FSF Latin America board member
Free Software Evangelist      Red Hat Brazil Compiler Engineer

  reply	other threads:[~2013-01-16  9:29 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-21  5:34 Alexandre Oliva
2012-12-21  9:51 ` Richard Biener
2012-12-21  9:55   ` Jakub Jelinek
2012-12-21 10:42     ` Jan Hubicka
2012-12-30  0:23   ` Alexandre Oliva
2013-01-02 14:53     ` Richard Biener
2013-01-06 19:48       ` Alexandre Oliva
2013-01-07  9:28         ` Richard Biener
2013-01-16  9:29           ` Alexandre Oliva [this message]
2013-01-16 10:24             ` Jan Hubicka
2013-01-16 13:17               ` Alexandre Oliva
2013-01-16 13:48                 ` Richard Biener
2013-01-18 11:44               ` Alexandre Oliva

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=orhamh5vcv.fsf@livre.localdomain \
    --to=aoliva@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hubicka@ucw.cz \
    --cc=richard.guenther@gmail.com \
    /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).