On Wednesday, May 9, 2001, at 04:05 PM, Chan, Sun C wrote:
The other possibility is that since "a" is global, it could be modified
by a shared library. If you mark "a" as static, the statement should go
away. If not, it is back to your conjecture.
BTW, thx for pointing out the obvious.
Sun
O.K., if 'a' is declared static, then it is immune from tampering by a
shared library. However, I was hoping that IPA would be able to tell
that neither glarp() nor any of its callees reference variable 'a'. If a
shared library was going to reference 'a', then glarp() or one of its
callees would be invoking an external function somewhere; they don't,
and IPA should know that.
% sgicc -O3 -IPA:inline=no -v -o test test.c >& log ; objdump -S
test > test.dump ; more test.dump
Please recall the commandline; I have explicitly disabled the inliner.
If I allow SGICC to inline everything, functions glarp() and bling() are
inlined, their bodies disappear, and the store to 'a' is deleted. If
SGICC was worried about a dynamic library referencing 'a', then why is
it so bold to delete global functions glarp() and bling()? By the same
reasoning, functions glarp() and bling() could be invoked by a dynamic
library.
The current test program is a simplified case; the original program was
three different modules. If I split the program into three files, keep
variable 'a' as a global, and allow SGICC to inline everything,
functions glarp() and bling() still disappear, and so does the dead
store to 'a'.
By-the-way, declaring 'a' static in the given testcase makes no
difference; SGICC still doesn't delete the store to 'a'.
Is there anything I can do to allow IPA to delete this store? (Other
than enabling the inliner :-)
stuart hastings
-----------------------------------------
int a, b ;
main( int xx)
{
a = 2 ;
glarp( xx) ;
a++ ;
return a + b ;
}
glarp( int j)
{
extern int a ;
if (j < 10)
bling( j-1) ;
}
bling( int k)
{
extern int b ;
b = k ;
}
|