Hi!
On 2022-02-23T12:14:57+0100, Tom de Vries via Gcc-patches
<[email protected]> wrote:
> [ Re: [committed][nvptx] Add -mptx-comment ]
>
> On 2/22/22 14:53, Tom de Vries wrote:
>> Add functionality that indicates which insns are added by -minit-regs, such
>> that for instance we have for pr53465.s:
>> ...
>> // #APP
>> // 9 "gcc/testsuite/gcc.c-torture/execute/pr53465.c" 1
>> // Start: Added by -minit-regs=3:
>> // #NO_APP
>> mov.u32 %r26, 0;
>> // #APP
>> // 9 "gcc/testsuite/gcc.c-torture/execute/pr53465.c" 1
>> // End: Added by -minit-regs=3:
>> // #NO_APP
>> ...
>>
>> Can be switched off using -mno-ptx-comment.
>>
>> Tested on nvptx.
>
> But tested in combination with another patch, which is still waiting for
> review.
>
> This patch by itself caused some regressions
I'd just begun analyzing and determined that it was
commit c2b23aaaf4457278403c01cd145cd3936683384e
"[nvptx] Add -mptx-comment" that causes a load of FAILs in nvptx
offloading testing:
Program received signal SIGSEGV, Segmentation fault.
0x000000000084abad in final_scan_insn_1 (insn=insn@entry=0x7ffff7380940,
file=file@entry=0x1f50c40, optimize_p=optimize_p@entry=0,
nopeepholes=nopeepholes@entry=0, seen=seen@entry=0x7fffffffd07c) at
[...]/source-gcc/gcc/final.cc:2650
2650 if (*loc.file && loc.line)
(gdb) print loc
$1 = {file = 0x0, line = 0, column = 0, data = 0x0, sysp = false}
(gdb) bt
#0 0x000000000084abad in final_scan_insn_1
(insn=insn@entry=0x7ffff7380940, file=file@entry=0x1f50c40,
optimize_p=optimize_p@entry=0, nopeepholes=nopeepholes@entry=0,
seen=seen@entry=0x7fffffffd07c) at [...]/source-gcc/gcc/final.cc:2650
#1 0x000000000084b86a in final_scan_insn (insn=insn@entry=0x7ffff7380940,
file=file@entry=0x1f50c40, optimize_p=optimize_p@entry=0,
nopeepholes=nopeepholes@entry=0, seen=seen@entry=0x7fffffffd07c) at
[...]/source-gcc/gcc/final.cc:2942
#2 0x000000000084823a in final_1 (first=0x7ffff74631c0, file=0x1f50c40,
seen=1, optimize_p=0) at [...]/source-gcc/gcc/final.cc:1999
#3 0x000000000085091a in rest_of_handle_final () at
[...]/source-gcc/gcc/final.cc:4287
#4 0x0000000000850de4 in (anonymous namespace)::pass_final::execute
(this=0x1f4bd00) at [...]/source-gcc/gcc/final.cc:4365
#5 0x0000000000b781b1 in execute_one_pass (pass=pass@entry=0x1f4bd00) at
[...]/source-gcc/gcc/passes.cc:2639
#6 0x0000000000b7855a in execute_pass_list_1 (pass=0x1f4bd00) at
[...]/source-gcc/gcc/passes.cc:2739
#7 0x0000000000b7858d in execute_pass_list_1 (pass=0x1f4b820) at
[...]/source-gcc/gcc/passes.cc:2740
#8 0x0000000000b7858d in execute_pass_list_1 (pass=0x1f49d20,
pass@entry=0x1f45780) at [...]/source-gcc/gcc/passes.cc:2740
#9 0x0000000000b785e9 in execute_pass_list (fn=0x7ffff72e1e40,
pass=0x1f45780) at [...]/source-gcc/gcc/passes.cc:2750
#10 0x0000000000732a66 in cgraph_node::expand (this=0x7ffff72efbb0) at
[...]/source-gcc/gcc/cgraphunit.cc:1836
#11 0x000000000073336a in cgraph_order_sort::process (this=0x20730f8) at
[...]/source-gcc/gcc/cgraphunit.cc:2075
#12 0x00000000007336f4 in output_in_order () at
[...]/source-gcc/gcc/cgraphunit.cc:2143
#13 0x0000000000733dbe in symbol_table::compile (this=0x7ffff7542000) at
[...]/source-gcc/gcc/cgraphunit.cc:2347
#14 0x000000000065d79b in lto_main () at [...]/source-gcc/gcc/lto/lto.cc:655
#15 0x0000000000c709e6 in compile_file () at
[...]/source-gcc/gcc/toplev.cc:454
#16 0x0000000000c73abb in do_compile (no_backend=no_backend@entry=false) at
[...]/source-gcc/gcc/toplev.cc:2160
#17 0x0000000000c73ea6 in toplev::main (this=this@entry=0x7fffffffd4b0,
argc=argc@entry=16, argv=0x1f1db40, argv@entry=0x7fffffffd5b8) at
[...]/source-gcc/gcc/toplev.cc:2312
#18 0x000000000174fe5f in main (argc=16, argv=0x7fffffffd5b8) at
[...]/source-gcc/gcc/main.cc:41
> currently testing attached
> fix.
Per the test results that I've got so far (but is still running), your
proposed fix does resolve the SIGSEGVs, thanks.
Grüße
Thomas
> [nvptx] Fix dummy location in gen_comment
>
> I committed "[nvptx] Add -mptx-comment", but tested it in combination with the
> proposed "[final] Handle compiler-generated asm insn" (
> https://gcc.gnu.org/pipermail/gcc-patches/2022-February/590721.html ), so
> by itself the commit introduced some regressions:
> ...
> FAIL: gcc.dg/20020426-2.c (internal compiler error: Segmentation fault)
> FAIL: gcc.dg/analyzer/zlib-3.c (internal compiler error: Segmentation fault)
> FAIL: gcc.dg/pr101223.c (internal compiler error: Segmentation fault)
> FAIL: gcc.dg/torture/pr80764.c -O2 (internal compiler error: Segmentation
> fault)
> ...
>
> There are due to cfun->function_start_locus == 0.
>
> Fix these by using DECL_SOURCE_LOCATION (cfun->decl) instead.
>
> Tested on nvptx.
>
> gcc/ChangeLog:
>
> 2022-02-23 Tom de Vries <[email protected]>
>
> * config/nvptx/nvptx.cc (gen_comment): Use
> DECL_SOURCE_LOCATION (cfun->decl) instead of cfun->function_start_locus.
>
> ---
> gcc/config/nvptx/nvptx.cc | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/gcc/config/nvptx/nvptx.cc b/gcc/config/nvptx/nvptx.cc
> index 858789e6df76..6f6d592e4621 100644
> --- a/gcc/config/nvptx/nvptx.cc
> +++ b/gcc/config/nvptx/nvptx.cc
> @@ -5382,7 +5382,7 @@ gen_comment (const char *s)
> char *comment = (char *) alloca (len);
> snprintf (comment, len, "%s%s%s", ASM_COMMENT_START, sep, s);
> return gen_rtx_ASM_INPUT_loc (VOIDmode, ggc_strdup (comment),
> - cfun->function_start_locus);
> + DECL_SOURCE_LOCATION (cfun->decl));
> }
>
> /* Initialize all declared regs at function entry.
-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634
München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas
Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht
München, HRB 106955