public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jozef Lawrynowicz <jozef.l@mittosystems.com>
To: Richard Biener <richard.guenther@gmail.com>
Cc: Richard Sandiford <richard.sandiford@arm.com>,
	GCC Development <gcc@gcc.gnu.org>,
	Alexander Monakov <amonakov@ispras.ru>
Subject: Re: [RFC] Disabling ICF for interrupt functions
Date: Wed, 31 Jul 2019 12:22:00 -0000	[thread overview]
Message-ID: <20190731132242.75a9da4b@jozef-kubuntu> (raw)
In-Reply-To: <CAFiYyc1Bx+rU4UAiZDSf-dJxfe_XaoZ3dPD-KjXwZtmQCdR-Ew@mail.gmail.com>

On Wed, 31 Jul 2019 11:49:58 +0200
Richard Biener <richard.guenther@gmail.com> wrote:

> On Tue, Jul 30, 2019 at 3:41 PM Jozef Lawrynowicz
> <jozef.l@mittosystems.com> wrote:
> >
> > On Fri, 26 Jul 2019 18:39:50 +0100
> > Richard Sandiford <richard.sandiford@arm.com> wrote:
> >  
> > > [Catching up after being away, sorry if this has already been resolved.]
> > >
> > > Jozef Lawrynowicz <jozef.l@mittosystems.com> writes:  
> > > > For MSP430, the folding of identical functions marked with the "interrupt"
> > > > attribute by -fipa-icf-functions results in wrong code being generated.
> > > > Interrupts have different calling conventions than regular functions, so
> > > > inserting a CALL from one identical interrupt to another is not correct and
> > > > will result in stack corruption.
> > > >
> > > > I imagine there are other targets that also have different calling conventions
> > > > for interrupt functions compared to regular functions, and so folding them
> > > > would be undesirable.
> > > >
> > > > Therefore, I would appreciate some feedback as to whether it would be welcomed
> > > > to fix this in a generic way or if I should just keep it MSP430 specific.
> > > >
> > > > 1. MSP430 specific
> > > > Add the "no_icf" attribute to functions marked with the "interrupt" attribute
> > > > when processing them in the backend.
> > > >
> > > > 2. Target Hook
> > > > Add a DEFHOOKPOD (e.g. TARGET_NO_INTERRUPT_ICF) which controls whether ICF is
> > > > disabled for functions with the interrupt attribute (in gcc/ipa-icf.c, where
> > > > "no_icf" attribute is processed).  
> > >
> > > This sounds like it should be a question about two functions rather
> > > than one, i.e.: can functions A and B be merged together if they
> > > appear to be identical at some level?  I think for most targets,
> > > merging two identical interrupt functions would be OK.  It's merging
> > > an interrupt and non-interrupt function that's the problem.
> > >
> > > So maybe we need something like targetm.can_inline_p, but for
> > > merging rather than inlining?  The function would need to be
> > > transitive of course.
> > >
> > > Thanks,
> > > Richard  
> >
> > By "merging" are you referring to aliasing i.e. only keep one copy of the
> > function and make the addresses of the functions equal?
> >
> > The problem for me is that the properties which prevent an alias being created
> > for functions in ipa-icf.c, could be equally applicable to interrupt functions.
> > At least for MSP430, there is no specific assertion that we can disregard the
> > addresses of interrupt functions. It is feasible that a user might want to
> > compare the addresses of different interrupt functions and they would expect
> > those addresses to be different.  
> 
> But those can the use -fno-ipa-icf.
> 
> Wouldn't users prefer smaller binaries by merging identical interrupt handlers
> as well?
> 
> Richard.
> 

It seems I omitted some key information from my OP which could be why there is
some disagreement here.

Originally, I was referring to interrupt handlers which DO NOT have a vector
specified. i.e. "__attribute__((interrupt))"
I still think it is undesirable to alias different interrupt
handlers, with identical contents, which do not specify a vector. When there
is no vector specified, the user is probably remapping these handlers at
link-time or run-time, possibly into different vectors. Even though these
handlers are not directly callable, their addresses should still be considered
to "matter" (like a regular globally visible function would) and so they
shouldn't be aliased.

I would agree that interrupt handlers which have the same vector specified and
have identical contents should be aliased. They will be mapped to the same
address anyway so there really will be wasted space in the final binary.

GCC currently won't merge identical interrupt handlers with different vectors
specified in the attribute. I think this is ok.

Thanks,
Jozef

      reply	other threads:[~2019-07-31 12:22 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-19 12:45 Jozef Lawrynowicz
2019-07-19 13:32 ` Alexander Monakov
2019-07-22 17:01   ` Jozef Lawrynowicz
2019-07-22 18:50     ` Alexander Monakov
2019-07-26 17:39 ` Richard Sandiford
2019-07-30 13:41   ` Jozef Lawrynowicz
2019-07-31  9:50     ` Richard Biener
2019-07-31 12:22       ` Jozef Lawrynowicz [this message]

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=20190731132242.75a9da4b@jozef-kubuntu \
    --to=jozef.l@mittosystems.com \
    --cc=amonakov@ispras.ru \
    --cc=gcc@gcc.gnu.org \
    --cc=richard.guenther@gmail.com \
    --cc=richard.sandiford@arm.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).