2009-01-15 21:02:21

by Christoph Lameter

[permalink] [raw]
Subject: Re: [patch 2/8] compiler-gcc.h: add more comments to RELOC_HIDE

On Thu, 15 Jan 2009, Rusty Russell wrote:

> > The cast should cause the C compiler to drop all assumptions about size.
>
> No, and that's the point. Sorry, at this point you need to talk to a gcc expert. As I have said, I did and I believe what he told me.

The gcc expert that created this measss is cced on this thread and so
far he not spoken up. Richard?


2009-01-15 23:15:32

by Richard Henderson

[permalink] [raw]
Subject: Re: [patch 2/8] compiler-gcc.h: add more comments to RELOC_HIDE

Christoph Lameter wrote:
> On Thu, 15 Jan 2009, Rusty Russell wrote:
>
>>> The cast should cause the C compiler to drop all assumptions about size.
>> No, and that's the point. Sorry, at this point you need to talk to a gcc expert. As I have said, I did and I believe what he told me.
>
> The gcc expert that created this measss is cced on this thread and so
> far he not spoken up. Richard?

It has been a long time, and I don't recall all of the assumptions
involved from the time.

It was probably a combination of object size assumptions, as well as
problems with relocations. Stuff like "int foo" is known to be
allocated within the small data structure, and thus various types of
small-data-section relocations are valid for it. Then we do stuff like
"(void *)&foo - large_constant" which don't work with those sorts of
relocations.

I didn't explore the space of possible solutions, merely gave Rusty a
solution that I knew would work, and would never fail because the
compiler would never look through the asm.

I wouldn't be surprised if the compiler thought "(long)&foo -
large_constant" could be put back together into a small-data relocation,
simply because at the level at which that optimization is performed,
we've thrown away type data like long and void*; we only have modes.

Why are you wanting to change this at all? It works as it is.


r~

2009-01-16 20:38:33

by Christoph Lameter

[permalink] [raw]
Subject: Re: [patch 2/8] compiler-gcc.h: add more comments to RELOC_HIDE

On Thu, 15 Jan 2009, Richard Henderson wrote:

> I didn't explore the space of possible solutions, merely gave Rusty a solution
> that I knew would work, and would never fail because the compiler would never
> look through the asm.
>
> I wouldn't be surprised if the compiler thought "(long)&foo - large_constant"
> could be put back together into a small-data relocation, simply because at the
> level at which that optimization is performed, we've thrown away type data
> like long and void*; we only have modes.

We are talking about

(long)&foo + long_variable

Are you saying that the compiler will be ignoring the high bits in
variable because of the size of foo?

> Why are you wanting to change this at all? It works as it is.

It looks like its useless and more an indication of either a broken
compiler or wrong assumptions about the compiler. Removing RELOC_HIDE
should allow the compiler to freely optimize the per cpu address
calculations.

2009-01-19 16:30:46

by Richard Henderson

[permalink] [raw]
Subject: Re: [patch 2/8] compiler-gcc.h: add more comments to RELOC_HIDE

Christoph Lameter wrote:
> On Thu, 15 Jan 2009, Richard Henderson wrote:
>
>> I didn't explore the space of possible solutions, merely gave Rusty a solution
>> that I knew would work, and would never fail because the compiler would never
>> look through the asm.
>>
>> I wouldn't be surprised if the compiler thought "(long)&foo - large_constant"
>> could be put back together into a small-data relocation, simply because at the
>> level at which that optimization is performed, we've thrown away type data
>> like long and void*; we only have modes.
>
> We are talking about
>
> (long)&foo + long_variable
>
> Are you saying that the compiler will be ignoring the high bits in
> variable because of the size of foo?

No, I'm saying that all those high bits will be passed along and won't
fit in the 16-bit relocation that'll come out of the assembler, leading
to a hard linker error.

> It looks like its useless and more an indication of either a broken
> compiler or wrong assumptions about the compiler. Removing RELOC_HIDE
> should allow the compiler to freely optimize the per cpu address
> calculations.

Something I'm pretty sure we don't want the compiler to be able to do.


r~

2009-01-21 14:02:05

by Christoph Lameter

[permalink] [raw]
Subject: Re: [patch 2/8] compiler-gcc.h: add more comments to RELOC_HIDE

On Mon, 19 Jan 2009, Richard Henderson wrote:

> > We are talking about
> >
> > (long)&foo + long_variable
> >
> > Are you saying that the compiler will be ignoring the high bits in
> > variable because of the size of foo?
>
> No, I'm saying that all those high bits will be passed along and won't
> fit in the 16-bit relocation that'll come out of the assembler, leading
> to a hard linker error.

Why would a 16 bit relocation be generated if the compiler knows that a 32
bit/64 bit entity is added to the address of a variable?

> > It looks like its useless and more an indication of either a broken
> > compiler or wrong assumptions about the compiler. Removing RELOC_HIDE
> > should allow the compiler to freely optimize the per cpu address
> > calculations.
>
> Something I'm pretty sure we don't want the compiler to be able to do.

Other compilers (like icc) seem to have no problem with it. Why not?