Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#2 Fix inlining bug in BCC 3.3.3

open
nobody
None
5
2004-08-02
2004-08-02
Abhishek Rai
No

Patch for Bounds-checking gcc 3.3.3
-----------------------------

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.3
which prevents function calls from
getting inlined when they should be.

Details:
--------

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
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).

Discussion

  • Abhishek Rai
    Abhishek Rai
    2004-08-02

    Logged In: YES
    user_id=1088721

    The above post didn't have the actual fix :), here it is:-

    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.2.buggy/gcc/c-common.c
    gcc-3.3.2/gcc/c-common.c
    --- gcc-3.3.2.buggy/gcc/c-common.c 2004-07-30
    18:35:24.000000000 -0400
    +++ gcc-3.3.2/gcc/c-common.c 2004-07-30
    15:23:37.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:

     
  • Abhishek Rai
    Abhishek Rai
    2004-08-02

    Logged In: YES
    user_id=1088721

    The fix above was for 3.3.2, and not for 3.3.3, which is
    presented here, sorry for the redundant posts.

    diff -rupN -x tags -x 'c-parse.[cy]' -x 'objc-parse.[cy]' -
    x 'parse.[ch]' -x '*.info*' gcc-3.3.3.buggy/gcc/c-common.c
    gcc-3.3.3/gcc/c-common.c
    --- gcc-3.3.3.buggy/gcc/c-common.c 2004-07-30
    18:27:01.000000000 -0400
    +++ gcc-3.3.3/gcc/c-common.c 2004-07-30
    17:31:04.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: