Patch for Bounds-checking gcc 3.3.3
Abhishek Rai <firstname.lastname@example.org>
File Systems and Storage Lab
Stony Brook University
Patch to fix a bug in bounds-checking GCC version 3.3.3
which prevents function calls from
getting inlined when they should be.
This small patch, solves a big problem with the 3.3.3
version of bounds-checking gcc.
In this version of bounds-checking gcc,
functions declared as 'inline' never get inlined, even
when they should be getting inlined.
It turns out that, BCC uses a variant of CLEANUP_STMT
called C_CLEANUP_STMT to add
specific functions to the program to perform certain
cleanup when a scope is exited.
However, the current implementation seems
incomplete/incorrect in its use of
C_CLEANUP_STMT: In c-common.c/statement_code_p
(), the type C_CLEANUP_STMT is not
recognized as a statement (whereas CLEANUP_STMT
from which it was derived for a special
prupose, is recognized as a statement). As a result, in
walk_tree(), the siblings may
not be visited at all when the call to statement_code_p
() with a C_CLEANUP_STMT class
argument returns 0. As a result, while many things might
fail. For example,
expand_calls_inline() which uses walk_tree() does not
traverse other statements in the
same scope when it is called with a statement of type
(__bounds_pop_function() in this case). As a result,
function calls don't get inlined
Non-inlining in itself is undesirable although some
programs may compile completely and run fine.
However, in certain cases, extern inlines may not
compile at all (which are widely used in
Linux kernel, and glibc).