This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: How to avoid constant propagation into functions?

* Segher Boessenkool:

> On Wed, Dec 07, 2016 at 06:27:56PM +0100, Florian Weimer wrote:
>> >> > When I am writing a test with noinline + noclone then my
>> >> > expectation is that no such propagation happens, because
>> >> > otherwise a test might turn trivial...
>> >> 
>> >> The usual ways to prevent that are to add some volatile, or an
>> >> asm("" : "+g"(some_var));   etc.
>> >
>> > No, that doesn't sound right.  As far as I can tell from looking
>> > that the GCC testsuite, the prevailing way is actually the
>> > noinline+noclone combo, not the per-argument asms or volatiles.
>> Agreed, that's what I've been using in the past for glibc test cases.
>> If that doesn't work, we'll need something else.  Separate compilation
>> of test cases just to thwart compiler optimizations is a significant
>> burden, and will stop working once we have LTO anyway.
>> What about making the function definitions weak?  Would that be more
>> reliable?
> It depends a lot on what you want the test to actually test.

The most recent case was about constructing the expected call stack
for an unwinder test.

In another test, I needed to perform free (malloc (1)).

> Just sprinkling noinline,noclone everywhere as a poor man's "DWIM"
> just does not work.

Maybe we should compile all glibc tests twice, once with
-ffreestanding, and once without, so that we test both the
implementation and what an application would do.  But I don't know if
-ffreestanding would even work this way.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]