Hi,

I'm attempting to enable more flags in Ofast, but I've encountered some issues.

For instance, if I want to add -flto-partition=one to Ofast, here is
the modification I made to opts.cc

/* -Ofast adds optimizations to -O3.  */
{ OPT_LEVELS_FAST, OPT_ffast_math, NULL, 1 },
{ OPT_LEVELS_FAST, OPT_fallow_store_data_races, NULL, 1 },
{ OPT_LEVELS_FAST, OPT_fsemantic_interposition, NULL, 0 },
++ { OPT_LEVELS_FAST, OPT_flto_partition_, NULL, LTO_PARTITION_ONE },

However, when I run the tests (make -k check), I encounter some
problems. One of the failed test files is gcc.dg/pr89342.c:

/* PR other/89342 */
/* { dg-do compile } */
/* { dg-options "-O0" } */

__attribute__((optimize("Ofast")))
void foo (void)
{
  __attribute__((optimize("no-inline")))
  void bar (void) {}
  bar ();
}

The error message is as follows:

../gcc/testsuite/gcc.dg/pr89342.c:7:1: internal compiler error:
‘global_options’ are modified in local context
    7 | {
      | ^
0x9e8cf4 handle_optimize_attribute
        ../../gcc/c-family/c-attribs.cc:5568
0x8e0902 decl_attributes(tree_node**, tree_node*, int, tree_node*)
        ../../gcc/attribs.cc:872
0x8fe39c start_function(c_declspecs*, c_declarator*, tree_node*)
        ../../gcc/c/c-decl.cc:9519
0x962336 c_parser_declaration_or_fndef
        ../../gcc/c/c-parser.cc:2445
0x96b803 c_parser_external_declaration
        ../../gcc/c/c-parser.cc:1779
0x96c263 c_parser_translation_unit
        ../../gcc/c/c-parser.cc:1652
0x96c263 c_parse_file()
        ../../gcc/c/c-parser.cc:23372
0x9cf4a5 c_common_parse_file()
        ../../gcc/c-family/c-opts.cc:1240

Upon debugging, I found that the error occurs in the
cl_optimization_compare(gcc_options *ptr1, gcc_options *ptr2) function
in options-save.cc. Specifically, the discrepancy is here:

ptr1->x_flag_lto_partition: 2, ptr2->x_flag_lto_partition: 1

This discrepancy leads to the error. Could you advise on how to
resolve this issue?

(Note: My ultimate goal is not to add the -flto-partition=one flag.
This is just an example to illustrate the problem.)

Thank you for your assistance.

Thanks
Hanke Zhang

Reply via email to