This is the mail archive of the gcc-patches@gcc.gnu.org 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]

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


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