On 01/10/2015 10:03 AM, Chen Gang S wrote: > The related commit is "275e275 IPA ICF: target and optimization flags > comparison.". For sem_function::equals_private(), fix the typo issue, > and for target_opts_for_fn(), fix access NULL issue. > > For cross compiling h8300, it will cause the issue below: > > [root@localhost h8300]# cat fp-bit.i > __inline__ static int a (int x) > { > return __builtin_expect (x == 0, 0); > } > > __inline__ static int b (int x) > { > return __builtin_expect (x == 1, 0); > } > > __attribute__ ((__always_inline__)) int c (int x, int y) > { > if (a (x)) > return x; > if (b (x)) > return x; > return y; > } > [root@localhost h8300]# /upstream/build-gcc-h8300/gcc/cc1 -O2 fp-bit.i -o > test.s > a b c > Analyzing compilation unit > > fp-bit.i:11:41: warning: always_inline function might not be inlinable > [-Wattributes] > __attribute__ ((__always_inline__)) int c (int x, int y) > ^ > Performing interprocedural optimizations > <*free_lang_data> <visibility> <build_ssa_passes> <chkp_passes> > <opt_local_passes> <free-inline-summary> <emutls> <whole-program> > <profile_estimate> <icf>fp-bit.i:18:1: internal compiler error: Segmentation > fault > } > ^ > 0xa11f0e crash_signal > ../../gcc/gcc/toplev.c:372 > 0xda33e7 tree_check > ../../gcc/gcc/tree.h:2769 > 0xda33e7 target_opts_for_fn > ../../gcc/gcc/tree.h:4643 > 0xda33e7 ipa_icf::sem_function::equals_private(ipa_icf::sem_item*, > hash_map<symtab_node*, ipa_icf::sem_item*, default_hashmap_traits>&) > ../../gcc/gcc/ipa-icf.c:438 > 0xda4023 ipa_icf::sem_function::equals(ipa_icf::sem_item*, > hash_map<symtab_node*, ipa_icf::sem_item*, default_hashmap_traits>&) > ../../gcc/gcc/ipa-icf.c:393 > 0xda6472 ipa_icf::sem_item_optimizer::subdivide_classes_by_equality(bool) > ../../gcc/gcc/ipa-icf.c:1900 > 0xdaad3c ipa_icf::sem_item_optimizer::execute() > ../../gcc/gcc/ipa-icf.c:1719 > 0xdab961 ipa_icf_driver > ../../gcc/gcc/ipa-icf.c:2448 > 0xdab961 ipa_icf::pass_ipa_icf::execute(function*) > ../../gcc/gcc/ipa-icf.c:2496 > Please submit a full bug report, > with preprocessed source if appropriate. > Please include the complete backtrace with any bug report. > See <http://gcc.gnu.org/bugs.html> for instructions. > > This issue can be found for cross compiling gcc "make all-target-libgcc" > under h8300, after fix this issue, it can continue to cross compiling to > meet the next building issue for h8300. > > 2015-01-10 Chen Gang <gang.chen.5...@gmail.com> > > * ipa-icf.c (sem_function::equals_private): Use '&&' instead of > '||' to fix typo issue. > > * gcc/tree.h (target_opts_for_fn): Check NULL_TREE since it can > accept and return NULL. > --- > gcc/ipa-icf.c | 2 +- > gcc/tree.h | 2 +- > 2 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c > index 1b76a1d..4ccaf8c 100644 > --- a/gcc/ipa-icf.c > +++ b/gcc/ipa-icf.c > @@ -438,7 +438,7 @@ sem_function::equals_private (sem_item *item, > cl_target_option *tar1 = target_opts_for_fn (decl); > cl_target_option *tar2 = target_opts_for_fn (m_compared_func->decl); > > - if (tar1 != NULL || tar2 != NULL) > + if (tar1 != NULL && tar2 != NULL) > { > if (!cl_target_option_eq (tar1, tar2)) > { > diff --git a/gcc/tree.h b/gcc/tree.h > index fc8c8fe..ac27268 100644 > --- a/gcc/tree.h > +++ b/gcc/tree.h > @@ -4640,7 +4640,7 @@ target_opts_for_fn (const_tree fndecl) > tree fn_opts = DECL_FUNCTION_SPECIFIC_TARGET (fndecl); > if (fn_opts == NULL_TREE) > fn_opts = target_option_default_node; > - return TREE_TARGET_OPTION (fn_opts); > + return fn_opts == NULL_TREE ? NULL : TREE_TARGET_OPTION (fn_opts); > } > > /* opt flag for function FNDECL, e.g. opts_for_fn (fndecl, optimize) is >
Hello. Thank you for the fix! Martin