Sorry for the duplication effort on this bug, before my patch, yongchong had
also submitted a patch to the list.

I personally think my patch will be better, since patch from build system
does not solve the compability problem with gnu and -inline will do really
inline which is not a desired behavior under O0. we can add options with
-INLINE=on, -INLINE:none to work around, but this does not solve the root
cause.

Could gatekeeper on IPA or global gatekeeper help review this? it is a major
severity bug in bugzilla.

Here is his original mail:

Hi
Can a gatekeeper help review this patch, it's a bug fixed for bug#838
When building the gcc front end with opencc -g -O0,  there is some
dead functions that call other undefined functions. when building with
gcc or opencc -O1 optimization above, the compiler will eliminated the
dead function. But when building with opencc -O0, dead function would
be kept, this fact will cause the undefined reference error.
This patch will add options -INLINE when build using open64 to build
the front end with DEBUG optimization. With -O0 -INLINE, the open64
can eliminated the dead functions.
Index: configure
===================================================================
--- configure   (revision 3737)
+++ configure   (working copy)
@@ -1418,6 +1418,9 @@
   DEBUG|debug)
     BUILD_OPTIMIZE=DEBUG
     GCC_CONFIGURE_CFLAGS="-O0 -g -DIs_True_On"
+    if test "${BUILD_COMPILER}" = "OSP"; then
+      GCC_CONFIGURE_CFLAGS="${GCC_CONFIGURE_CFLAGS} -INLINE"
+    fi
     ;;
   *)
     { { echo "$as_me:$LINENO: error: \"BUILD_OPTIMIZE=$BUILD_OPTIMIZE
is not supported\"" >&5
Index: configure.ac
===================================================================
--- configure.ac        (revision 3737)
+++ configure.ac        (working copy)
@@ -88,6 +88,9 @@
   DEBUG|debug)
     BUILD_OPTIMIZE=DEBUG
     GCC_CONFIGURE_CFLAGS="-O0 -g -DIs_True_On"
+    if test "${BUILD_COMPILER}" = "OSP"; then
+      GCC_CONFIGURE_CFLAGS="${GCC_CONFIGURE_CFLAGS} -INLINE"
+    fi
     ;;
   *)
     AC_MSG_ERROR(["BUILD_OPTIMIZE=$BUILD_OPTIMIZE is not supported"])
--
yongchong


Regards
Gang


On Sat, Oct 8, 2011 at 9:26 AM, Gang Yu <yugang...@gmail.com> wrote:

> Hi,
>
>    Could a gatekeeper please help review the fix for bug838?
> http://bugs.open64.net/show_bug.cgi?id=838
>
> symptom:
>
>   opencc could not compile gcc for debug build(O0), a cutted down case as
> below:
>
> int i;
> static __inline__ void
> should_not_exist (void)
> {
>         i=1;
> }
>
> yug@jupiter:~/work/bugs/bug838> $TOOLROOT/bin/opencc -c case1.i -O0
> yug@jupiter:~/work/bugs/bug838> readelf -s case1.o | grep should_not_exist
>      4: 0000000000000000    21 FUNC    LOCAL  DEFAULT    1 should_not_exist
> yug@jupiter:~/work/bugs/bug838> gcc -c -O0 case1.i
> yug@jupiter:~/work/bugs/bug838> readelf -s case1.o | grep should_not_exist
>
> Since opencc does not do inline on O0(non-ipa) option, so no deletion
> for should_not_exit, this incompatibility causes the break.
>
> Solution:
>
>    open inline for O0, but only do dead function elimination
> for unreachable functions with inline attribute.
>
> Patch:
>
>  --- a/osprey/driver/special_options.c
> +++ b/osprey/driver/special_options.c
> @@ -360,13 +360,6 @@ add_special_options (void)
>                 turn_down_opt_level(0, "-g changes optimization to -O0
> since no optimization level is specified");
>         }
> -       /* Turn off inlining when compiling -O0.  We definitly want
> -        * this off when compiling with -g -O0, but we don't want
> -        * -g to change the generated code so we leave it off always.
> -        * See bugs 1917 and 7595.
> -        */
> -       if (olevel == 0 && inline_t == UNDEFINED)
> -         inline_t = FALSE;
>          /* In the SGI world, -g3 says to emit crippled debug info for use
>          * with optimized code. In the GNU/Pathscale world, -g3 says to
> emit
>         Modified osprey/ipa/inline/inline.cxx
> diff --git a/osprey/ipa/inline/inline.cxx b/osprey/ipa/inline/inline.cxx
> index 7a2e8ad..a41e779 100644
> --- a/osprey/ipa/inline/inline.cxx
> +++ b/osprey/ipa/inline/inline.cxx
> @@ -635,6 +635,9 @@ Perform_inlining()
>  #endif // _LIGHTWEIGHT_INLINER
>                     Write_inline_succ_pu();
>         } else {
> +#ifdef _LIGHTWEIGHT_INLINER
> +          if (Opt_Level !=0) /* O0 does not do real inline. */
> +#endif
>             Inline_callees_into_caller(caller);
>  #ifdef DEBUG_SYMTAB
>          Scope_tab = caller->Scope();
>         Modified osprey/ipa/inline/inline_driver.cxx
> diff --git a/osprey/ipa/inline/inline_driver.cxx
> b/osprey/ipa/inline/inline_driver.cxx
> index 77704bc..4aff837 100644
> --- a/osprey/ipa/inline/inline_driver.cxx
> +++ b/osprey/ipa/inline/inline_driver.cxx
> @@ -196,6 +196,10 @@ Process_Command_Line (INT argc, char **argv)
>                         Opt_Level = 2;
>                         INLINE_Enable_Split_Common = FALSE;
>                         break;
> +                    case '0': /* setup O0 for lw_inline */
> +                        Opt_Level = 0;
> +                        INLINE_Enable_Split_Common = FALSE;
> +                       break;
>                     default:
>                         Opt_Level = 1;
>                         INLINE_Enable_Split_Common = FALSE;
>         Modified osprey/ipa/main/analyze/ipa_cg.cxx
> diff --git a/osprey/ipa/main/analyze/ipa_cg.cxx
> b/osprey/ipa/main/analyze/ipa_cg.cxx
> index 5b58f01..4638977 100644
> --- a/osprey/ipa/main/analyze/ipa_cg.cxx
> +++ b/osprey/ipa/main/analyze/ipa_cg.cxx
> @@ -1848,6 +1848,14 @@ Mark_Deletable_Funcs (NODE_INDEX v, DFE_ACTION
> action, mUINT8 *visited)
>             node->Set_Undeletable();
>             action = MARK_USED;
>             visited[v] = VISITED_AND_KEEP;
> +#ifdef _LIGHTWEIGHT_INLINER
> +        /* O0 does not delete functions with no inline attrib */
> +        } else if (Opt_Level == 0 && ! node->Has_Inline_Attrib()) {
> +          node->Clear_Deletable();
> +          node->Set_Undeletable();
> +          action = MARK_USED;
> +          visited[v] = VISITED_AND_KEEP;
> +#endif
>         } else if (visited[v] == 0)
>             visited[v] = VISITED_BUT_UNDECIDED;
>         break;
>
>
> Regards
> Gang
>
------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2d-oct
_______________________________________________
Open64-devel mailing list
Open64-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/open64-devel

Reply via email to