#3 Fix inlining bug in BCC 3.3.4

open
nobody
None
5
2014-09-03
2004-08-02
No

Patch for Bounds-checking gcc 3.3.4
-----------------------------

Abhishek Rai <abba@cs.sunysb.edu>
File Systems and Storage Lab
Stony Brook University

Purpose:
--------

Patch to fix a bug in bounds-checking GCC version 3.3.4
which prevents function calls from
getting inlined when they should be.

Details:
--------

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
they should.

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
C_CLEANUP_STMT first
(__bounds_pop_function() in this case). As a result,
function calls don't get inlined
at all.

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-
common.c gcc-3.3.4/gcc/c-common.c
--- gcc-3.3.4.buggy/gcc/c-common.c 2004-07-30
18:28:42.000000000 -0400
+++ gcc-3.3.4/gcc/c-common.c 2004-07-30
18:18:44.000000000 -0400
@@ -4560,6 +4560,7 @@ statement_code_p (code)
{
switch (code)
{
+ case C_CLEANUP_STMT:
case CLEANUP_STMT:
case EXPR_STMT:
case COMPOUND_STMT:

Discussion

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks