Fix testsuite for inlining
Jan Hubicka
jh@suse.cz
Tue Jan 21 21:35:00 GMT 2003
> On Tue, Jan 21, 2003 at 08:28:37PM +0100, Jan Hubicka wrote:
> > for string/stdio my code actually overwrote builtins by the actual
> > functions so even with noinlining they didn't simplify.
>
> This would be a bug in _your_ code, not the test case.
>
> Don't apply these changes.
I've already done so, but I believe they are not bogus - the testcase
fails without noinlines even after fixing the code. I just wanted to
menion I possibly left in some extra noinlines in some of testcases (I
reviewed patch for these but perhaps I didn't caught all of them), but
all testcases still needs at least some noinlines. For instance testcase reads:
/* Copyright (C) 2000 Free Software Foundation.
Ensure all expected transformations of builtin strstr occur and
perform correctly.
Written by Kaveh R. Ghazi, 11/6/2000. */
extern void abort(void);
extern char *strstr (const char *, const char *);
int main()
{
const char *const foo = "hello world";
if (strstr (foo, "") != foo)
abort();
if (strstr (foo + 4, "") != foo + 4)
abort();
if (strstr (foo, "h") != foo)
abort();
if (strstr (foo, "w") != foo + 6)
abort();
if (strstr (foo + 6, "o") != foo + 7)
abort();
if (strstr (foo + 1, "world") != foo + 6)
abort();
/* Test at least one instance of the __builtin_ style. We do this
to ensure that it works and that the prototype is correct. */
if (__builtin_strstr (foo + 1, "world") != foo + 6)
abort();
return 0;
}
#ifdef __OPTIMIZE__
/* When optimizing, all the above cases should be transformed into
something else. So any remaining calls to the original function
should abort. */
__attribute__ ((noinline))
static char *
strstr(const char *s1, const char *s2)
{
abort();
}
#endif
It does expect compiler to not take into account the body of strstr and
optimize strstr as builtin. I am really not sure what should be the
behaviour here. When the code is writen other way around it is common
practice to expect that compiler will inline strstr. In unit-at-time
complation compiler should inline strstr then as well. That is what I
am using inline for.
I can revert the changes to those particular testcases. In the other
testcases I believe it is clear that noinline should be present.
These usually relies on incorrectly marked pure/const functions and
similar tricks that are uncovered by inlining.
Honza
More information about the Gcc-patches
mailing list