This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
problem with inline functions in bounds-checking patch for gcc
- From: Abhishek Rai <abba at cs dot sunysb dot edu>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 21 Jul 2004 19:55:41 -0400 (EDT)
- Subject: problem with inline functions in bounds-checking patch for gcc
Hi,
I've been playing around with the bounds-checking patch to gcc
for a while.
Here is something I've found which I think needs to be fixed.
I've been using bounds-checking patch for gcc-3.3.2. It seems that
function inlining is not taking place at all.
I performed the following experiment:
File: 1.c
extern inline int hi() { return 20; }
main () { printf("%d", hi() ); }
File: 2.c
int hi() {return 10; }
According to gcc source code [gcc/c-decl.c], extern inline acts like a
declaration and would ordinarily be linked against an external definition
of the function. However, if it were to be inlined, the compiler should
inline it as shown. At lower optimization levels (below O2), inlining
doesn't take place and the external reference is used. However, for -O2
and beyond, inlining does take place, and regular gcc does use the local
definition (I know which one is used, cause the the two versions of hi()
return different values).
On the other hand gcc -fbounds-checking always uses only the
external definition for all optimization levels. This makes me doubt if
any inlining is taking place at all.
I am concerned about this, as I am trying to compile Linux kernel
with this, and they use a lot of extern inlines.
thanks,
Abhishek
Abhishek Rai
Department of Computer Science
Stony Brook University
http://www.cs.sunysb.edu/~abba