public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
To: Richard Sandiford <Richard.Sandiford@arm.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>,
	Ramana Radhakrishnan	<Ramana.Radhakrishnan@arm.com>,
	Richard Earnshaw <Richard.Earnshaw@arm.com>,
	James Greenhalgh <James.Greenhalgh@arm.com>,
	Kyrylo Tkachov	<Kyrylo.Tkachov@arm.com>, nd <nd@arm.com>
Subject: Re: [PATCH][AArch64] Fix symbol offset limit
Date: Mon, 14 Oct 2019 15:51:00 -0000	[thread overview]
Message-ID: <VI1PR0801MB2127BB21A5A1318F74FAADED83900@VI1PR0801MB2127.eurprd08.prod.outlook.com> (raw)
In-Reply-To: <mpteezi478o.fsf@arm.com>

Hi Richard,

>> No - the testcases fail with that.
>
> Hmm, OK.  Could you give more details?  What does the motivating case
> actually look like?

Well it's now a very long time ago since I first posted this patch but the failure
was in SPEC. It did something like &array[0xffffff000 - x], presumably after some
optimization with some specific options I was using at the time. The exact details
don't matter since I've got minimal testcases.

> One of the reasons this is a hard patch to review is that it doesn't
> include a testcase for the kind of situation it's trying to fix.

There is a very simple testcase which fails before and passes with my patch.

>> It also reduces codequality by not allowing commonly used offsets as
>> part of the symbol relocation.
>
> Which kinds of cases specifically?  Although I'm guessing the problem is
> when indexing into external arrays of unknown size.

Well there are 41000 uses in SPEC2017 that fail the offset_within_block_p
test but pass my range test. There are 3 cases where the reverse is true
(a huge offset: 17694720).

Overall my range test allows 99.99% of the offsets, so we can safely conclude
my patch doesn't regress any existing code.

> So IMO we should be able to assume that the start and end + 1 addresses
> of any referenced object are within reach.  For section anchors, we can
> extend that to the containing anchor block, which is really just a
> super-sized object.

This isn't about section anchors - in many cases the array is an extern.

> The question then is what to do about symbols whose size isn't known.
> And I agree that unconditionally applying the full code-model offset
> range is too aggressive in that case.

That's very common indeed, so we need to apply some kind of reasonable
range check.

> Well, for one thing, if code quality isn't affected by using +/-64k
> for the tiny model, do we have any evidence that we need a larger offset
> for the other code models?

Certainly for SPEC +-64KB is too small, but SPEC won't build in the tiny code
model. For the tiny code model the emphasis should be on ensuring that code
that fits should build correctly rather than trying to optimize it to the max and
getting relocations that are out of range... So I believe it is reasonable to use a 
more conservative range in the tiny model.

> But more importantly, we can't say definitively that code quality isn't
> affected, only that it wasn't affected for the cases we've looked at.
> People could patch the compiler if the new ranges turn out not to strike
> the right balance for their use cases, but not everyone wants to do that.

Well if we're worried about codequality then the offset in block approach
affects it the most. Offsets larger than 1MB are extremely rare, so the chance
that there will ever be a request for a larger range is simply zero.

> Maybe we need a new command-line option.

That's way overkill... All this analysis is overcomplicating what is really a very
basic problem with a very simple solution.

Cheers,
Wilco

  parent reply	other threads:[~2019-10-14 15:41 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-28 17:27 Wilco Dijkstra
2019-07-31 17:00 ` Wilco Dijkstra
2019-08-19 15:57   ` Wilco Dijkstra
2019-09-02 12:12     ` Wilco Dijkstra
2019-09-09 17:07       ` Wilco Dijkstra
2019-10-10 17:24         ` Wilco Dijkstra
2019-10-10 18:33           ` Richard Sandiford
2019-10-11 18:31             ` Wilco Dijkstra
2019-10-12 10:20               ` Richard Sandiford
2019-10-12 11:23                 ` Richard Sandiford
2019-10-13  8:45                 ` Jeff Law
2019-10-14 15:51                 ` Wilco Dijkstra [this message]
2019-10-14 16:34                   ` Richard Sandiford
2019-10-15 18:27                     ` Wilco Dijkstra
2019-10-16  8:50                       ` Richard Sandiford
  -- strict thread matches above, loose matches on Subject: below --
2018-11-09 14:47 Wilco Dijkstra
2016-08-23 14:11 Wilco Dijkstra
2016-08-26 10:43 ` Richard Earnshaw (lists)
2016-08-26 19:07   ` Wilco Dijkstra

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=VI1PR0801MB2127BB21A5A1318F74FAADED83900@VI1PR0801MB2127.eurprd08.prod.outlook.com \
    --to=wilco.dijkstra@arm.com \
    --cc=James.Greenhalgh@arm.com \
    --cc=Kyrylo.Tkachov@arm.com \
    --cc=Ramana.Radhakrishnan@arm.com \
    --cc=Richard.Earnshaw@arm.com \
    --cc=Richard.Sandiford@arm.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=nd@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).