Patch for Bounds-checking gcc 3.3.4
Abhishek Rai <email@example.com>
File Systems and Storage Lab
Stony Brook University
Patch to fix a bug in bounds-checking GCC version 3.3.4
which prevents function calls from
getting inlined when they should be.
This small patch, solves a big problem with the 3.3.4
version of bounds-checking gcc.
In this version of bounds-checking gcc, functions
declared as 'inline' do not get inlined at all, even when
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).
This fix simply adds C_CLEANUP_STMT to c-
common.c/statement_code_p() and thereby
recognizes it as a statement.
diff -rupN -x tags -x 'c-parse.[cy]' -x 'objc-parse.[cy]' -
x 'parse.[ch]' -x '*.info*' gcc-3.3.4.buggy/gcc/c-
--- gcc-3.3.4.buggy/gcc/c-common.c 2004-07-30
+++ gcc-3.3.4/gcc/c-common.c 2004-07-30
@@ -4560,6 +4560,7 @@ statement_code_p (code)
+ case C_CLEANUP_STMT: