For any test-case, that includes arm_neon.h, for instance: #include <arm_neon.h> void f() {} Passing incompatible fp16 format seems to result in ICE. For example, passing -mfp16-format=alternative resulted in: In file included from test.c:1: ../arm-stage1-build/gcc/include/arm_neon.h:18122:9: error: selected fp16 options are incompatible 18122 | #pragma GCC target ("arch=armv8.2-a+fp16fml") | ^~~ ../arm-stage1-build/gcc/include/arm_neon.h:18324:9: internal compiler error: ‘global_options’ are modified in local context 18324 | #pragma GCC pop_options | ^~~ 0xdcb103 cl_optimization_compare(gcc_options*, gcc_options*) /home/bilbo/gnu-toolchain/gcc/vfma/arm-stage1-build/gcc/options-save.c:12555 0x97d54d handle_pragma_pop_options ../../gcc/gcc/c-family/c-pragma.c:1092 0x8f3cbb c_parser_pragma ../../gcc/gcc/c/c-parser.c:12525 0x91aab5 c_parser_external_declaration ../../gcc/gcc/c/c-parser.c:1758 0x91b269 c_parser_translation_unit ../../gcc/gcc/c/c-parser.c:1650 0x91b269 c_parse_file() ../../gcc/gcc/c/c-parser.c:21935 0x97b045 c_common_parse_file() ../../gcc/gcc/c-family/c-opts.c:1211 My built version is configured as: Using built-in specs. COLLECT_GCC=../arm-stage1-build/gcc/xgcc Target: arm-linux-gnueabihf Configured with: ../gcc/configure --enable-languages=c,c++ --disable-bootstrap --target=arm-linux-gnueabihf --with-arch=armv7-a --with-fpu=neon --with-float=hard --with-mode=thumb --with-sysroot=/home/bilbo/gnu-toolchain/sysroots/arm-linux-gnueabihf --disable-werror Thread model: posix Supported LTO compression algorithms: zlib gcc version 11.0.0 20210111 (experimental) (GCC) Thanks, Prathamesh
Can you please attach a pre-processed source file and output of --verbose?
Created attachment 49953 [details] Preprocessed test-case
Created attachment 49954 [details] Output of passing --verbose Command line option used to compile: ../arm-stage1-build/gcc/xgcc -B ../arm-stage1-build/gcc -mfp16-format=alternative test.c -S -save-temps --verbose >verbose_output.txt 2>&1
Thanks, with cross compiler I only see the error (not the internal compiler error). Anyway, can you please test it with g:e91910d3576eeac714c93ec25ea3b15012007903?
Hi, Unfortunately I am still getting the same ICE with g:e91910d3576eeac714c93ec25ea3b15012007903. Thanks, Prathamesh
I see. Is the 'error: selected fp16 options are incompatible' valid or not in this case?
I think the error is correct. CCing Kyrill -- could you please confirm if the error is valid for above case ? Thanks!
(In reply to prathamesh3492 from comment #7) > I think the error is correct. > CCing Kyrill -- could you please confirm if the error is valid for > above case ? > Thanks! Yes, -mfp16-format=alternative is incompatible with the intrinsics
All right. @Prathamesh: Can you run that in debugger and show what option foo is causing the internal_error: void cl_optimization_compare (gcc_options *ptr1, gcc_options *ptr2) { ... if (ptr1->x_foo != ptr2->x_help_foo) internal_error ("%<global_options%> are modified in local context");
Created attachment 49997 [details] untested fix Hi, Sorry for late response. The option that seemed to be causing the issue was arm_fp16_format. The attached patch fixes the issue by excluding it from checks in cl_optimization_compare, which prevents the ICE for me. Does this look OK ? Thanks, Prathamesh
> Sorry for late response. The option that seemed to be causing the issue was > arm_fp16_format. How do the string values differ? Are they also different string pointers but having a same value? > The attached patch fixes the issue by excluding it from > checks in cl_optimization_compare, which prevents the ICE for me. > Does this look OK ? Can you please attach options-save.c file first?
Created attachment 50003 [details] options-save.c
IIUC, the issue comes from the following mismatch in cl_optimization_compare: if (ptr1->x_arm_fp16_format != ptr2->x_arm_fp16_format) internal_error ("%<global_options%> are modified in local context"); x_arm_fp16_format is of following type defined in arm-opts.h: /* Which __fp16 format to use. The enumeration values correspond to the numbering for the Tag_ABI_FP_16bit_format attribute. */ enum arm_fp16_format_type { ARM_FP16_FORMAT_NONE = 0, ARM_FP16_FORMAT_IEEE = 1, ARM_FP16_FORMAT_ALTERNATIVE = 2 }; For the test-case passing -mfp16-format=alternative results in: ptr1->x_arm_fp16_format == ARM_FP16_FORMAT_ALTERNATIVE and ptr2->x_arm_fp16_format == ARM_FP16_FORMAT_IEEE, and the mismatch results in ICE. Thanks, Prathamesh
I just ran into the same problem, with a slightly different testcase: > cat crash.c #pragma GCC push_options #pragma GCC target ("arch=armv8.2-a+fp16") #pragma GCC pop_options results in the same crash: crash.c:3:9: internal compiler error: 'global_options' are modified in local context 3 | #pragma GCC pop_options | ^~~ 0x1199c6d cl_optimization_compare(gcc_options*, gcc_options*) build-arm-none-eabi/obj/gcc2/gcc/options-save.c:14897 0xb38463 handle_pragma_pop_options src/gcc/gcc/c-family/c-pragma.c:1092 0xb38eef c_invoke_pragma_handler(unsigned int) src/gcc/gcc/c-family/c-pragma.c:1515 0xa80622 c_parser_pragma src/gcc/gcc/c/c-parser.c:12525 0xa63dc6 c_parser_external_declaration src/gcc/gcc/c/c-parser.c:1758 0xa63938 c_parser_translation_unit src/gcc/gcc/c/c-parser.c:1650 0xaa6139 c_parse_file() src/gcc/gcc/c/c-parser.c:21990 0xb322f2 c_common_parse_file() src/gcc/gcc/c-family/c-opts.c:1211
I see, so it's a real issue and I support the workaround mentioned in Comment 10. Please send it to the mailing list.
(In reply to Tamar Christina from comment #14) > I just ran into the same problem, with a slightly different testcase: This is a better one to reproduce the issue, thanks! I verified the patch in comment 10 resolves the ICE for this test-case. Thanks, Prathamesh > > > cat crash.c > > #pragma GCC push_options > #pragma GCC target ("arch=armv8.2-a+fp16") > #pragma GCC pop_options > > results in the same crash: > > crash.c:3:9: internal compiler error: 'global_options' are modified in local > context > 3 | #pragma GCC pop_options > | ^~~ > 0x1199c6d cl_optimization_compare(gcc_options*, gcc_options*) > build-arm-none-eabi/obj/gcc2/gcc/options-save.c:14897 > 0xb38463 handle_pragma_pop_options > src/gcc/gcc/c-family/c-pragma.c:1092 > 0xb38eef c_invoke_pragma_handler(unsigned int) > src/gcc/gcc/c-family/c-pragma.c:1515 > 0xa80622 c_parser_pragma > src/gcc/gcc/c/c-parser.c:12525 > 0xa63dc6 c_parser_external_declaration > src/gcc/gcc/c/c-parser.c:1758 > 0xa63938 c_parser_translation_unit > src/gcc/gcc/c/c-parser.c:1650 > 0xaa6139 c_parse_file() > src/gcc/gcc/c/c-parser.c:21990 > 0xb322f2 c_common_parse_file() > src/gcc/gcc/c-family/c-opts.c:1211
(In reply to Martin Liška from comment #15) > I see, so it's a real issue and I support the workaround mentioned in > Comment 10. > Please send it to the mailing list. Patch posted: https://gcc.gnu.org/pipermail/gcc-patches/2021-January/563848.html Thanks, Prathamesh
The master branch has been updated by Prathamesh Kulkarni <prathamesh3492@gcc.gnu.org>: https://gcc.gnu.org/g:4e3beaca15cab2de88a68d76f0aabc68e68f678a commit r11-6850-g4e3beaca15cab2de88a68d76f0aabc68e68f678a Author: Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org> Date: Fri Jan 22 14:14:20 2021 +0530 arm: Fix ICE with incompatible values for -mfp16-format [PR98636]. gcc/ 2021-01-22 Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org> PR target/98636 * optc-save-gen.awk: Add arm_fp16_format to checked_options. gcc/testsuite/ 2021-01-22 Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org> PR target/98636 * gcc.target/arm/pr98636.c: New test.
Fixed now.
Recently unfixed. $ /home/dcb/raspberrypi/results/bin/arm-linux-gnueabihf-gcc -c ./gcc.target/arm/pr98636.c ./gcc.target/arm/pr98636.c:6:9: internal compiler error: ‘global_options’ are mo dified in local context 6 | #pragma GCC pop_options | ^~~ 0xe063eb cl_optimization_compare(gcc_options*, gcc_options*) /home/dcb/raspberrypi/build-gcc/gcc/options-save.c:12621 0x94b2ad handle_pragma_pop_options /home/dcb/gcc/trunk.git/gcc/c-family/c-pragma.c:1100 0x8c1ad1 c_parser_pragma /home/dcb/gcc/trunk.git/gcc/c/c-parser.c:12519 0x8e9c05 c_parser_external_declaration /home/dcb/gcc/trunk.git/gcc/c/c-parser.c:1758
Let me assign it.
The master branch has been updated by Martin Liska <marxin@gcc.gnu.org>: https://gcc.gnu.org/g:371c1992624c9269e2d5747561a8b27b30e485ee commit r12-1745-g371c1992624c9269e2d5747561a8b27b30e485ee Author: Martin Liska <mliska@suse.cz> Date: Wed Jun 23 15:30:17 2021 +0200 arm: Revert partially ebd5e86c0f41dc1d692f9b2b68a510b1f6835a3e PR target/98636 gcc/ChangeLog: * optc-save-gen.awk: Put back arm_fp16_format to checked_options.
Fixed again.
The test case gcc.target/arm/pr98636.c fails for Cortex-M55 as the error is emitted during the process_options step in toplev.c rather than do_compile step. In arm_option_reconfigure_globals, the following line can be found: arm_fp16_inst = bitmap_bit_p (arm_active_target.isa, isa_bit_fp16); For Cortex-A7 (just an example where the test case passes), the above statement results in arm_fp16_inst=0 when the call tree contains process_options. When the call tree contains do_compile, it's instead arm_fp16_inst=1 and the expected error is emitted. For Cortex-M55, the above statement results in arm_fp16_inst=1 when the call tree contains process_options. As a result, the expected error is emitted, but at this point, input_location is 0, so there is no context and the test case fail. I've debugged the above using the following command: cc1 -quiet -D__USES_INITFINI__ gcc/testsuite/gcc.target/arm/pr98636.c -quiet -mthumb -mcpu=cortex-m55 -mfloat-abi=hard -mfpu=auto -mfp16-format=alternative -o /dev/null Output with -mcpu=cortex-a7: gcc/testsuite/gcc.target/arm/pr98636.c:6:10: error: selected fp16 options are incompatible 6 | # pragma GCC target ("arch=armv8.2-a+fp16") /* { dg-error "selected fp16 options are incompatible" } */ | ^~~ Output with -mcpu=cortex-m55: cc1: error: selected fp16 options are incompatible Should the test case be updated to be this instead as it would allow both cases to pass? # pragma GCC target ("arch=armv8.2-a+fp16") /* { dg-error "selected fp16 options are incompatible" "" { target *-*-* } 0 } */