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 of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security
threats, fraudulent activity, and more. Splunk takes this data and makes
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2dcopy2
_______________________________________________
Open64-devel mailing list
Open64-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/open64-devel