Re: Correct way to express to the compiler "this does not get clobbered"?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



David Brown <david.brown@xxxxxxxxxxxx> writes:

> On 04/12/2020 00:00, Andrea Corallo wrote:
>> David Brown <david.brown@xxxxxxxxxxxx> writes:
>> Hi David,
>> 
>>> As "f()" runs, the value of "y->fun_ptr" changes with each step as you
>>> get alternating "foo1", "foo2" outputs.  Thus it is clear (I hope) that
>>> the compiler cannot assume that "y->fun_ptr" is not clobbered by the
>>> function call.
>> Indeed that's clear.  The question is more if there's some way to
>> express
>> this to the compiler qualifying the variables in discussion without
>> changing the structure of the code.  This because as I wrote may be not
>> trivial to modify the code generator for optimal results.
>> I understand this is probably not possible and there's no magic
>> attribute or qualifier to express this.
>> 
>
> In order to add a qualifier or attribute, you'd still need to change
> the code in some way.  Is it possible to make /some/ changes to the
> code generator, but not others?

What I said is that is possible to change the code generator, but adding
a qualifier or similar would be trivial, adding the local copy no.

I have many of these functions called through function pointer, each of
these can appear more then once in the code and I have non trivial
control flows (nested loops etc).  I could just emit all these copies at
the beginning of each function but this is suboptimal as non necessarly
they all will be used depending on the execution path, also for
scheduling reasons this would be not good.  The right thing would be to
load these pointers in the first common dominator of each basic block
requiring the use of each function pointer.  I can do it but is not a
good definition of trivial.

Thanks

  Andrea



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux