On Mon, 26 Aug 2024, Bernd Edlinger wrote: > On 8/26/24 10:31, Richard Biener wrote: > > On Mon, 26 Aug 2024, Bernd Edlinger wrote: > > > >> This recent change triggered various bootsteap-errors, mostly on > >> x86 targets because line info advance address entries were output > >> in the wrong section table. > >> The switch to the wrong line table happened in dwarfout_set_ignored_loc. > >> It must use the same section as the earlier called > >> dwarf2out_switch_text_section. > >> > >> But also ft32-elf was affected, because the assembler choked on > >> something simple as ".2byte .LM2-.LM1", but fortunately it is > >> able to use native location views, the configure test was just > >> not executed because the ft32 "nop" instruction was missing. > > > > OK for the configure part, I don't understand how using > > current_function_section is correct or how it even makes a > > differnce to function_section. > > > > It seems both would rely on the fact that fde->decl should be > > the same as cfun->decl and both eventually resort to how > > first_function_block_is_cold is set. > > > > Is this from final_scan_insn_1 where we seem to switch > > in_cold_section_p? > > > > The [current_]function_section API might be just confusing to me > > of course. I note that dwarf2out mixes both uses and > > current_function_section seems newer than function_section. Huh. > > > Well, this is how I debugged it: > I use the successfully bootstrapped x86_64-pc-linux-gnu-gcc as host compiler > and build this: > ../gcc-trunk/configure --target=i386-linux-gnu CC="gcc -m32 > -gno-as-loc-support" CXX="g++ -m32 -gno-as-loc-support" > > make stops here: > > g++ -m32 -gno-as-loc-support -fno-PIE -c -g -O2 -DIN_GCC > -DCROSS_DIRECTORY_STRUCTURE -fno-exceptions -fno-rtti > -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings > -Wcast-qual -Wmissing-format-attribute -Wconditionally-supported > -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros > -Wno-overlength-strings -DHAVE_CONFIG_H -fno-PIE -I. -I. > -I../../gcc-trunk/gcc -I../../gcc-trunk/gcc/. > -I../../gcc-trunk/gcc/../include -I../../gcc-trunk/gcc/../libcpp/include > -I../../gcc-trunk/gcc/../libcody -I/home/ed/gnu/gcc-build-x/./gmp > -I/home/ed/gnu/gcc-trunk/gmp -I/home/ed/gnu/gcc-build-x/./mpfr/src > -I/home/ed/gnu/gcc-trunk/mpfr/src -I/home/ed/gnu/gcc-trunk/mpc/src > -I../../gcc-trunk/gcc/../libdecnumber > -I../../gcc-trunk/gcc/../libdecnumber/bid -I../libdecnumber > -I../../gcc-trunk/gcc/../libbacktrace > -I/home/ed/gnu/gcc-build-x/./isl/include -I/home/ed/gnu/gcc-trunk/isl/include > -o gtype-desc.o -MT gtype-desc.o -MMD -MP -MF ./.deps/gtype-desc.TPo > gtype-desc.c c > /tmp/ccB94xhL.s: Assembler messages: > /tmp/ccB94xhL.s:563836: Error: can't resolve .text.unlikely - .LM4229 > /tmp/ccB94xhL.s:563841: Error: can't resolve .text - .LM4230 > /tmp/ccB94xhL.s:564103: Error: can't resolve .text.unlikely - .LM4282 > /tmp/ccB94xhL.s:564108: Error: can't resolve .text - .LM4283 > /tmp/ccB94xhL.s:564115: Error: can't resolve .text.unlikely - .LM4284 > make[2]: *** [Makefile:1194: gtype-desc.o] Error 1 > > I took the original g++ command, and replace "-c" with "-S" and > "-o gtype-desc.o" with "-o /proc/self/fd/1" and add "-wrapper gdb,--args": > > $ g++ -m32 -gno-as-loc-support -fno-PIE -g -O2 -DIN_GCC > -DCROSS_DIRECTORY_STRUCTURE -fno-exceptions -fno-rtti > -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings > -Wcast-qual -Wmissing-format-attribute -Wconditionally-supported > -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros > -Wno-overlength-strings -DHAVE_CONFIG_H -fno-PIE -I. -I. > -I../../gcc-trunk/gcc -I../../gcc-trunk/gcc/. > -I../../gcc-trunk/gcc/../include -I../../gcc-trunk/gcc/../libcpp/include > -I../../gcc-trunk/gcc/../libcody -I/home/ed/gnu/gcc-build-x/./gmp > -I/home/ed/gnu/gcc-trunk/gmp -I/home/ed/gnu/gcc-build-x/./mpfr/src > -I/home/ed/gnu/gcc-trunk/mpfr/src -I/home/ed/gnu/gcc-trunk/mpc/src > -I../../gcc-trunk/gcc/../libdecnumber > -I../../gcc-trunk/gcc/../libdecnumber/bid -I../libdecnumber > -I../../gcc-trunk/gcc/../libbacktrace > -I/home/ed/gnu/gcc-build-x/./isl/include -I/home/ed/gnu/gcc-trunk/isl/include > -MT gtype-desc.o -MMD -MP -MF ./.deps/gtype-desc.TPo gtype-desc.cc -S -o > /proc/self/fd/1 -w rapper gdb,--args > (gdb) b dwarf2out_set_ignored_loc > (gdb) display in_cold_section_p > (gdb) display first_function_block_is_cold > (gdb) r > The first breakpoint is uninteresting: > [...] > .size _Z22gt_pch_p_11eh_region_dPvS_PFvS_S_S_ES_, > .-_Z22gt_pch_p_11eh_region_dPvS_PFvS_S_S_ES_ > .p2align 4 > .globl _Z21gt_pch_p_10eh_catch_dPvS_PFvS_S_S_ES_ > .type _Z21gt_pch_p_10eh_catch_dPvS_PFvS_S_S_ES_, @function > _Z21gt_pch_p_10eh_catch_dPvS_PFvS_S_S_ES_: > .LFB8506: > .cfi_startproc > > Breakpoint 1, dwarf2out_set_ignored_loc (line=12009, column=1, > filename=0x391bd90 "gtype-desc.cc") > at ../../gcc-trunk/gcc/dwarf2out.cc:28976 > 28976 dw_fde_ref fde = cfun->fde; > 1: in_cold_section_p = false > 2: first_function_block_is_cold = false > (gdb) > The next breakpoint is where the problem starts: > (gdb) c > [...] > .size > _Z27hashtab_entry_note_pointersIN8hash_mapIP6gimplei21simple_hashmap_traitsI19default_hash_traitsIS2_EiEE10hash_entryEEvPvS9_PFvS9_S9_S9_ES9_, > > .-_Z27hashtab_entry_note_pointersIN8hash_mapIP6gimplei21simple_hashmap_traitsI19default_hash_traitsIS2_EiEE10hash_entryEEvPvS9_PFvS9_S9_S9_ES9_ > .section .text.unlikely > .LCOLDB30: > .text > .LHOTB30: > .p2align 4 > .globl > _Z49gt_pch_p_38function_summary_ipcp_transformation__PvS_PFvS_S_S_ES_ > .type > _Z49gt_pch_p_38function_summary_ipcp_transformation__PvS_PFvS_S_S_ES_, > @function > _Z49gt_pch_p_38function_summary_ipcp_transformation__PvS_PFvS_S_S_ES_: > .LFB8556: > .cfi_startproc > > Breakpoint 1, dwarf2out_set_ignored_loc (line=12341, column=1, > filename=0x391bd90 "gtype-desc.cc") > at ../../gcc-trunk/gcc/dwarf2out.cc:28976 > 28976 dw_fde_ref fde = cfun->fde; > 1: in_cold_section_p = false > 2: first_function_block_is_cold = false > (gdb) c > Continuing. > .LM4229: > subl $12, %esp > .cfi_def_cfa_offset 16 > movl 20(%esp), %eax > cmpl %eax, 16(%esp) > je .L1179 > addl $12, %esp > .cfi_def_cfa_offset 4 > ret > .cfi_endproc > .section .text.unlikely > .cfi_startproc > > Breakpoint 1, dwarf2out_set_ignored_loc (line=12341, column=1, > filename=0x391bd90 "gtype-desc.cc") > at ../../gcc-trunk/gcc/dwarf2out.cc:28976 > 28976 dw_fde_ref fde = cfun->fde; > 1: in_cold_section_p = true > 2: first_function_block_is_cold = false > (gdb) > Remember, the .LM4229 was the first one complained about, > > > The nice thing, is I can repeat that to the point immediately before the > error: > (gdb) r > [...] > (gdb) c > [...] > .size > _Z27hashtab_entry_note_pointersIN8hash_mapIP6gimplei21simple_hashmap_traitsI19default_hash_traitsIS2_EiEE10hash_entryEEvPvS9_PFvS9_S9_S9_ES9_, > > .-_Z27hashtab_entry_note_pointersIN8hash_mapIP6gimplei21simple_hashmap_traitsI19default_hash_traitsIS2_EiEE10hash_entryEEvPvS9_PFvS9_S9_S9_ES9_ > .section .text.unlikely > .LCOLDB30: > .text > .LHOTB30: > .p2align 4 > .globl > _Z49gt_pch_p_38function_summary_ipcp_transformation__PvS_PFvS_S_S_ES_ > .type > _Z49gt_pch_p_38function_summary_ipcp_transformation__PvS_PFvS_S_S_ES_, > @function > _Z49gt_pch_p_38function_summary_ipcp_transformation__PvS_PFvS_S_S_ES_: > .LFB8556: > .cfi_startproc > > Breakpoint 1, dwarf2out_set_ignored_loc (line=12341, column=1, > filename=0x391bd90 "gtype-desc.cc") > at ../../gcc-trunk/gcc/dwarf2out.cc:28976 > 28976 dw_fde_ref fde = cfun->fde; > 28976 dw_fde_ref fde = cfun->fde; > 1: in_cold_section_p = false > 2: first_function_block_is_cold = false > (gdb) n > 28978 fde->ignored_debug = false; > 1: in_cold_section_p = false > 2: first_function_block_is_cold = false > (gdb) n > 28979 set_cur_line_info_table (function_section (fde->decl)); > 1: in_cold_section_p = false > 2: first_function_block_is_cold = false > (gdb) n > 28981 dwarf2out_source_line (line, column, filename, 0, true); > 1: in_cold_section_p = false > 2: first_function_block_is_cold = false > (gdb) b set_cur_line_info_table > Breakpoint 2 at 0xf25700: file ../../gcc-trunk/gcc/dwarf2out.cc, line 28594. > (gdb) c > Continuing. > .LM4229: > subl $12, %esp > .cfi_def_cfa_offset 16 > movl 20(%esp), %eax > cmpl %eax, 16(%esp) > je .L1179 > addl $12, %esp > .cfi_def_cfa_offset 4 > ret > .cfi_endproc > .section .text.unlikely > .cfi_startproc > > Breakpoint 2, set_cur_line_info_table (sec=sec@entry=0x7ffff3e643a0) at > ../../gcc-trunk/gcc/dwarf2out.cc:28594 > 28594 if (sec == text_section) > 1: in_cold_section_p = true > 2: first_function_block_is_cold = false > Here, you see in_cold_section_p is truth. > (gdb) bt > #0 set_cur_line_info_table (sec=sec@entry=0x7ffff3e643a0) at > ../../gcc-trunk/gcc/dwarf2out.cc:28594 > #1 0x0000000000f3fa3d in dwarf2out_switch_text_section () at > ../../gcc-trunk/gcc/dwarf2out.cc:1339 > #2 0x0000000000fd9297 in final_scan_insn_1 (insn=0x7fffed8a1e70, > file=0x38ee590, seen=0x7fffffffd06c, nopeepholes=0, > optimize_p=2) at ../../gcc-trunk/gcc/final.cc:2182 > #3 0x0000000000fda26c in final_scan_insn (insn=insn@entry=0x7fffed8a1e70, > file=file@entry=0x38ee590, > optimize_p=optimize_p@entry=2, nopeepholes=nopeepholes@entry=0, > seen=<optimized out>, seen@entry=0x7fffffffd06c) > at ../../gcc-trunk/gcc/final.cc:2886 > #4 0x0000000000fda493 in final_1 (first=0x7fffed8a18c0, file=0x38ee590, > seen=<optimized out>, optimize_p=2) > at ../../gcc-trunk/gcc/final.cc:1977 > #5 0x0000000000fdaf80 in rest_of_handle_final () at > ../../gcc-trunk/gcc/final.cc:4239 > #6 (anonymous namespace)::pass_final::execute (this=<optimized out>) at > ../../gcc-trunk/gcc/final.cc:4317 > #7 0x00000000012cef3f in execute_one_pass (pass=pass@entry=0x38e95c0) at > ../../gcc-trunk/gcc/passes.cc:2647 > #8 0x00000000012cf870 in execute_pass_list_1 (pass=0x38e95c0) at > ../../gcc-trunk/gcc/passes.cc:2756 > #9 0x00000000012cf882 in execute_pass_list_1 (pass=0x38e9010) at > ../../gcc-trunk/gcc/passes.cc:2757 > #10 0x00000000012cf882 in execute_pass_list_1 (pass=0x38e7130) at > ../../gcc-trunk/gcc/passes.cc:2757 > #11 0x00000000012cf8a9 in execute_pass_list (fn=0x7fffed8b4b40, > pass=<optimized out>) > at ../../gcc-trunk/gcc/passes.cc:2767 > #12 0x0000000000ecb9d7 in cgraph_node::expand (this=0x7fffee381ee0) at > ../../gcc-trunk/gcc/cgraphunit.cc:1845 > #13 cgraph_node::expand (this=0x7fffee381ee0) at > ../../gcc-trunk/gcc/cgraphunit.cc:1798 > #14 0x0000000000ecd7fb in expand_all_functions () at > ../../gcc-trunk/gcc/cgraphunit.cc:2028 > #15 symbol_table::compile (this=0x7ffff77e5000) at > ../../gcc-trunk/gcc/cgraphunit.cc:2404 > #16 0x0000000000ecfeb8 in symbol_table::compile (this=0x7ffff77e5000) at > ../../gcc-trunk/gcc/cgraphunit.cc:2315 > #17 symbol_table::finalize_compilation_unit (this=0x7ffff77e5000) at > ../../gcc-trunk/gcc/cgraphunit.cc:2589 > #18 0x00000000013fe602 in compile_file () at ../../gcc-trunk/gcc/toplev.cc:478 > #19 0x0000000000a9bf90 in do_compile () at ../../gcc-trunk/gcc/toplev.cc:2209 > #20 toplev::main (this=this@entry=0x7fffffffd34e, argc=<optimized out>, > argc@entry=88, argv=<optimized out>, > argv@entry=0x7fffffffd478) at ../../gcc-trunk/gcc/toplev.cc:2369 > #21 0x0000000000a9d7ee in main (argc=88, argv=0x7fffffffd478) at > ../../gcc-trunk/gcc/main.cc:39 > (gdb) c > Continuing. > > Breakpoint 1, dwarf2out_set_ignored_loc (line=12341, column=1, > filename=0x391bd90 "gtype-desc.cc") > at ../../gcc-trunk/gcc/dwarf2out.cc:28976 > 28976 dw_fde_ref fde = cfun->fde; > 1: in_cold_section_p = true > 2: first_function_block_is_cold = false > (gdb) bt > #0 dwarf2out_set_ignored_loc (line=12341, column=1, filename=0x391bd90 > "gtype-desc.cc") > at ../../gcc-trunk/gcc/dwarf2out.cc:28976 > #1 0x0000000000fd9f30 in final_scan_insn_1 (insn=0x7fffed8a1e70, > file=0x38ee590, seen=0x7fffffffd06c, nopeepholes=0, > optimize_p=2) at ../../gcc-trunk/gcc/final.cc:2191 > #2 0x0000000000fda26c in final_scan_insn (insn=insn@entry=0x7fffed8a1e70, > file=file@entry=0x38ee590, > optimize_p=optimize_p@entry=2, nopeepholes=nopeepholes@entry=0, > seen=<optimized out>, seen@entry=0x7fffffffd06c) > at ../../gcc-trunk/gcc/final.cc:2886 > #3 0x0000000000fda493 in final_1 (first=0x7fffed8a18c0, file=0x38ee590, > seen=<optimized out>, optimize_p=2) > at ../../gcc-trunk/gcc/final.cc:1977 > #4 0x0000000000fdaf80 in rest_of_handle_final () at > ../../gcc-trunk/gcc/final.cc:4239 > #5 (anonymous namespace)::pass_final::execute (this=<optimized out>) at > ../../gcc-trunk/gcc/final.cc:4317 > #6 0x00000000012cef3f in execute_one_pass (pass=pass@entry=0x38e95c0) at > ../../gcc-trunk/gcc/passes.cc:2647 > #7 0x00000000012cf870 in execute_pass_list_1 (pass=0x38e95c0) at > ../../gcc-trunk/gcc/passes.cc:2756 > #8 0x00000000012cf882 in execute_pass_list_1 (pass=0x38e9010) at > ../../gcc-trunk/gcc/passes.cc:2757 > #9 0x00000000012cf882 in execute_pass_list_1 (pass=0x38e7130) at > ../../gcc-trunk/gcc/passes.cc:2757 > #10 0x00000000012cf8a9 in execute_pass_list (fn=0x7fffed8b4b40, > pass=<optimized out>) > at ../../gcc-trunk/gcc/passes.cc:2767 > #11 0x0000000000ecb9d7 in cgraph_node::expand (this=0x7fffee381ee0) at > ../../gcc-trunk/gcc/cgraphunit.cc:1845 > #12 cgraph_node::expand (this=0x7fffee381ee0) at > ../../gcc-trunk/gcc/cgraphunit.cc:1798 > #13 0x0000000000ecd7fb in expand_all_functions () at > ../../gcc-trunk/gcc/cgraphunit.cc:2028 > #14 symbol_table::compile (this=0x7ffff77e5000) at > ../../gcc-trunk/gcc/cgraphunit.cc:2404 > #15 0x0000000000ecfeb8 in symbol_table::compile (this=0x7ffff77e5000) at > ../../gcc-trunk/gcc/cgraphunit.cc:2315 > #16 symbol_table::finalize_compilation_unit (this=0x7ffff77e5000) at > ../../gcc-trunk/gcc/cgraphunit.cc:2589 > #17 0x00000000013fe602 in compile_file () at ../../gcc-trunk/gcc/toplev.cc:478 > #18 0x0000000000a9bf90 in do_compile () at ../../gcc-trunk/gcc/toplev.cc:2209 > #19 toplev::main (this=this@entry=0x7fffffffd34e, argc=<optimized out>, > argc@entry=88, argv=<optimized out>, > argv@entry=0x7fffffffd478) at ../../gcc-trunk/gcc/toplev.cc:2369 > #20 0x0000000000a9d7ee in main (argc=88, argv=0x7fffffffd478) at > ../../gcc-trunk/gcc/main.cc:39 > > now since dwarf2out_set_ignored_loc() uses function_section() > and function section() uses first_function_block_is_cold which is false > this is now the wrong table, but there is no output of any assembler > code in between those two calls of set_cur_line_info_table() > however the function dwarf2out_switch_text_section() uses > current_function_section () which uses in_cold_section_p, and only here > they disagree, but I think current_function_section() is more appropriate for > determining the section where the code is currently being output to, > while function_section() is telling you in which section the function entry > point will be output to. Since lables are usually outout together with code, > the change I've propsed seems right. > > > WDYT?
That was my conclusion as well, the strange difference between the APIs remain. Thus, OK. Thanks, Richard. > Thanks > Bernd. > -- Richard Biener <rguent...@suse.de> SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg, Germany; GF: Ivo Totev, Andrew McDonald, Werner Knoblich; (HRB 36809, AG Nuernberg)