Hi,
could a gatekeeper help a review? any suggestions or comments are
highly appreciated.
This is an accidentally discovered issue when I review
bug597<https://bugs.open64.net/show_bug.cgi?id=597>cases:
cat bug921 <https://bugs.open64.net/show_bug.cgi?id=921>.c
void static test(void)
{
asm("wrongthing");
}
yug@jupiter:~/work/bugs/bug921 <https://bugs.open64.net/show_bug.cgi?id=921>>
gcc -c bug921 <https://bugs.open64.net/show_bug.cgi?id=921>.c -O2
yug@jupiter:~/work/bugs/bug921 <https://bugs.open64.net/show_bug.cgi?id=921>>
gcc -c bug921 <https://bugs.open64.net/show_bug.cgi?id=921>.c -O3
yug@jupiter:~/work/bugs/bug921 <https://bugs.open64.net/show_bug.cgi?id=921>>
gcc -c bug921 <https://bugs.open64.net/show_bug.cgi?id=921>.c -O1
yug@jupiter:~/work/bugs/bug921 <https://bugs.open64.net/show_bug.cgi?id=921>>
clang -c bug921 <https://bugs.open64.net/show_bug.cgi?id=921>.c -O3
yug@jupiter:~/work/bugs/bug921 <https://bugs.open64.net/show_bug.cgi?id=921>>
clang -c bug921 <https://bugs.open64.net/show_bug.cgi?id=921>.c -O2
yug@jupiter:~/work/bugs/bug921 <https://bugs.open64.net/show_bug.cgi?id=921>>
clang -c bug921 <https://bugs.open64.net/show_bug.cgi?id=921>.c -O1
yug@jupiter:~/work/bugs/bug921 <https://bugs.open64.net/show_bug.cgi?id=921>>
clang -c bug921 <https://bugs.open64.net/show_bug.cgi?id=921>.c -O0
yug@jupiter:~/work/bugs/bug921 <https://bugs.open64.net/show_bug.cgi?id=921>>
opencc -c bug921 <https://bugs.open64.net/show_bug.cgi?id=921>.c -O3
yug@jupiter:~/work/bugs/bug921 <https://bugs.open64.net/show_bug.cgi?id=921>>
opencc -c bug921 <https://bugs.open64.net/show_bug.cgi?id=921>.c -O2
/tmp/ccspin#.Efw754.s: Assembler messages:
/tmp/ccspin#.Efw754.s:30: Error: no such instruction: `wrongthing'
yug@jupiter:~/work/bugs/bug921 <https://bugs.open64.net/show_bug.cgi?id=921>>
opencc -c bug921 <https://bugs.open64.net/show_bug.cgi?id=921>.c -O1
/tmp/ccspin#.9hLp6w.s: Assembler messages:
/tmp/ccspin#.9hLp6w.s:30: Error: no such instruction: `wrongthing'
yug@jupiter:~/work/bugs/bug921 <https://bugs.open64.net/show_bug.cgi?id=921>>
gcc -c bug921 <https://bugs.open64.net/show_bug.cgi?id=921>.c
/tmp/cczPHnnc.s: Assembler messages:
/tmp/cczPHnnc.s:11: Error: no such instruction: `wrongthing'
obviously, opencc does not delete non-callable static functions at O1/O2,
while other compilers do, clang even does more.
Investigation shows driver launches the inliner according to wgen return
value, i.e, if any function with INLINE attribute, inliner comes. At O3
phase, gcc marks all static functions a GS_DECL_INLINE flag at spin tree,
which makes the inliner always run. However, at O1/O2 level, it does not,
so the inliner unfortunately ignored.
The lwinliner actually does two things: DFE then inline. The right logic
should be:
- at O0 phase, if there are non-callable static functions declared with
inline attribute, they should be deleted by DFE, no inline. futhur if there
are inline arguments, call DFE and inline. Otherwise, silent.
- at optimisation phases, if there are functions with inline attributed, do
DFE and inline. Otherwise, we should also launch inliner for *DFE only*. At
O3, gcc can help us always call inliner, at O1 or O2, we should open
inliner ourselves and tell it only do DFE. since inline costs much.
The suggested patch below:
osprey/driver/phases.c -- 525b7d1..a47394a 100644
--- a/osprey/driver/phases.c
+++ b/osprey/driver/phases.c
@@ -3197,6 +3197,7 @@ run_compiler (int argc, char *argv[])
string_list_t *args;
boolean inst_info_updated = FALSE;
boolean cmd_line_updated = FALSE;
+ boolean dfe_only = FALSE;
buffer_t rii_file_name;
buffer_t ii_file_name;
@@ -3215,8 +3216,14 @@ run_compiler (int argc, char *argv[])
/* special case where the frontend decided that
inliner should not be run */
if (run_inline == FALSE && // bug 11325
- phase_order[i] == P_inline)
- continue;
+ phase_order[i] == P_inline) {
+ if (olevel == 0)
+ continue;
+ else {
+ dfe_only = TRUE;
+ run_inline = TRUE;
+ }
+ }
if (is_matching_phase(get_phase_mask(phase_order[i]),
P_any_ld)) {
source_kind = S_o;
@@ -3236,8 +3243,10 @@ run_compiler (int argc, char *argv[])
option_was_seen(O_inline) ||
option_was_seen(O_finline) ||
option_was_seen(O_finline_functions))) {
- prepend_option_seen
(add_string_option(O_INLINE_, "none"));
+ dfe_only = TRUE;
}
+ if (dfe_only)
+ add_string(args,"-dfe-only");
copy_phase_options (args, phase_order[i]);
if (!cmd_line_updated &&
@@ -3256,6 +3265,9 @@ run_compiler (int argc, char *argv[])
if (has_current_errors()) break;
run_phase (phase_order[i],
get_full_phase_name(phase_order[i]),
args);
+ /* clear dfe-only flag */
+ dfe_only = FALSE;
+
/* undefine the environment variable
* DEPENDENCIES_OUTPUT after the pre-processor
phase -
* bug 386.
osprey/ipa/inline/inline.cxx -- 7a2e8ad..d90abf7 100644
--- a/osprey/ipa/inline/inline.cxx
+++ b/osprey/ipa/inline/inline.cxx
@@ -177,6 +177,9 @@ SCOPE* Orig_Scope_tab;
extern IP_FILE_HDR_TABLE IP_File_header; // array of IP_FILE_HDR, which
// holds per file information
+#ifdef _LIGHTWEIGHT_INLINER
+extern BOOL DFE_Only;
+#endif // _LIGHTWEIGHT_INLINER
#ifdef _LIGHTWEIGHT_INLINER
AUX_PU_TAB Aux_Pu_Table;
@@ -1204,7 +1207,10 @@ Inliner(char* input_name, char* output_name)
fclose(f);
#endif
- Perform_inlining();
+#ifdef _LIGHTWEIGHT_INLINER
+ if (!DFE_Only)
+ Perform_inlining();
+#endif
#ifdef _LIGHTWEIGHT_INLINER
if (INLINE_Inlined_Pu_Call_Graph || INLINE_Inlined_Pu_Call_Graph2) {
osprey/ipa/inline/inline_driver.cxx -- c56f5f5..7382653 100644
--- a/osprey/ipa/inline/inline_driver.cxx
+++ b/osprey/ipa/inline/inline_driver.cxx
@@ -97,7 +97,10 @@ BOOL Verbose = FALSE;
*/
SKIPLIST *IPA_Skip_List = NULL; /* List of skip options */
-
+/* The DFE_only flag to indicate whether call lwinline
+ * for DFE only.
+ */
+BOOL DFE_Only = FALSE;
/* ====================================================================
*
@@ -211,9 +214,11 @@ Process_Command_Line (INT argc, char **argv)
break; /* ignore the -PHASE: option */
case 'd': /* accept and ignore the -dsm flags */
- if (strncmp (argv[i]+1, "dsm", 3) != 0)
- ErrMsg ( EC_Unknown_Flag, argv[i][0], argv[i] );
- break;
+ if (strncmp (argv[i] +1, "dfe-only", 8) == 0)
+ DFE_Only = TRUE;
+ else if (strncmp (argv[i]+1, "dsm", 3) != 0)
+ ErrMsg ( EC_Unknown_Flag, argv[i][0], argv[i] );
+ break;
default: /* What's this? */
ErrMsg ( EC_Unknown_Flag, argv[i][0], argv[i] );
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. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
Open64-devel mailing list
Open64-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/open64-devel