[PATCH] gcc/config/tilegx/tilegx.c (tilegx_function_profiler): Save r10 to stack before call mcount
From: Chen Gang r10 may also be as parameter for the nested function, so need save it before call mcount. 2016-05-29 Chen Gang * config/tilegx/tilegx.c (tilegx_function_profiler): Save r10 to stack before call mcount. --- gcc/config/tilegx/tilegx.c | 14 -- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/gcc/config/tilegx/tilegx.c b/gcc/config/tilegx/tilegx.c index 06c832c..bc41105 100644 --- a/gcc/config/tilegx/tilegx.c +++ b/gcc/config/tilegx/tilegx.c @@ -5510,18 +5510,28 @@ tilegx_function_profiler (FILE *file, int labelno ATTRIBUTE_UNUSED) if (flag_pic) { fprintf (file, + "\tst\tsp, r10\n" + "\taddi\tsp, sp, -8\n" "\t{\n" "\tmove\tr10, lr\n" "\tjal\tplt(%s)\n" - "\t}\n", MCOUNT_NAME); + "\t}\n" + "\taddi\tsp, sp, 8\n" + "\tld\tr10, sp\n", + MCOUNT_NAME); } else { fprintf (file, + "\tst\tsp, r10\n" + "\taddi\tsp, sp, -8\n" "\t{\n" "\tmove\tr10, lr\n" "\tjal\t%s\n" - "\t}\n", MCOUNT_NAME); + "\t}\n" + "\taddi\tsp, sp, 8\n" + "\tld\tr10, sp\n", + MCOUNT_NAME); } tilegx_in_bundle = false; -- 1.9.3
[PATCH v2] gcc/config/tilegx/tilegx.c (tilegx_function_profiler): Save r10 to stack before call mcount
From: Chen Gang r10 may also be as parameter stack pointer for the nested function, so need save it before call mcount. 2016-06-03 Chen Gang gcc/ PR target/71331 * config/tilegx/tilegx.c (tilegx_function_profiler): Save r10 to stack before call mcount. --- gcc/config/tilegx/tilegx.c | 14 -- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/gcc/config/tilegx/tilegx.c b/gcc/config/tilegx/tilegx.c index 06c832c..bc41105 100644 --- a/gcc/config/tilegx/tilegx.c +++ b/gcc/config/tilegx/tilegx.c @@ -5510,18 +5510,32 @@ tilegx_function_profiler (FILE *file, int labelno ATTRIBUTE_UNUSED) if (flag_pic) { fprintf (file, + "\t{\n" + "\taddi\tsp, sp, -8\n" + "\tst\tsp, r10\n" + "\t}\n" "\t{\n" "\tmove\tr10, lr\n" "\tjal\tplt(%s)\n" - "\t}\n", MCOUNT_NAME); + "\t}\n" + "\taddi\tsp, sp, 8\n" + "\tld\tr10, sp\n", + MCOUNT_NAME); } else { fprintf (file, + "\t{\n" + "\taddi\tsp, sp, -8\n" + "\tst\tsp, r10\n" + "\t}\n" "\t{\n" "\tmove\tr10, lr\n" "\tjal\t%s\n" - "\t}\n", MCOUNT_NAME); + "\t}\n" + "\taddi\tsp, sp, 8\n" + "\tld\tr10, sp\n", + MCOUNT_NAME); } tilegx_in_bundle = false; -- 1.9.3
[PATCH v3] gcc/config/tilegx/tilegx.c (tilegx_function_profiler): Save r10 to stack before call mcount
From: Chen Gang r10 may also be as parameter stack pointer for the nested function, so need save it before call mcount. Also clean up code: use '!' instead of "== 0" for checking static_chain_decl and compute_total_frame_size. 2016-06-04 Chen Gang gcc/ PR target/71331 * config/tilegx/tilegx.c (tilegx_function_profiler): Save r10 to stack before call mcount. (tilegx_can_use_return_insn_p): Clean up code. --- gcc/config/tilegx/tilegx.c | 20 ++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/gcc/config/tilegx/tilegx.c b/gcc/config/tilegx/tilegx.c index 06c832c..55161bb 100644 --- a/gcc/config/tilegx/tilegx.c +++ b/gcc/config/tilegx/tilegx.c @@ -3880,8 +3880,8 @@ bool tilegx_can_use_return_insn_p (void) { return (reload_completed - && cfun->static_chain_decl == 0 - && compute_total_frame_size () == 0 + && !cfun->static_chain_decl + && !compute_total_frame_size () && tilegx_current_function_is_leaf () && !crtl->profile && !df_regs_ever_live_p (TILEGX_LINK_REGNUM)); } @@ -5507,6 +5507,15 @@ tilegx_function_profiler (FILE *file, int labelno ATTRIBUTE_UNUSED) fprintf (file, "\t}\n"); } + if (cfun->static_chain_decl) +{ + fprintf (file, + "\t{\n" + "\taddi\tsp, sp, -8\n" + "\tst\tsp, r10\n" + "\t}\n"); +} + if (flag_pic) { fprintf (file, @@ -5524,6 +5533,13 @@ tilegx_function_profiler (FILE *file, int labelno ATTRIBUTE_UNUSED) "\t}\n", MCOUNT_NAME); } + if (cfun->static_chain_decl) +{ + fprintf (file, + "\taddi\tsp, sp, 8\n" + "\tld\tr10, sp\n"); +} + tilegx_in_bundle = false; } -- 1.9.3
[PATCH] gcc: config: tilegx: Reserve prev insn when delete useless insn
From: Chen Gang When check bundle, gcc may still need modify the prev insn. Original implementation will lose the prev insn. Also correct the coding styles of relate code. 2016-12-10 Chen Gang gcc/ PR target/78222 * tilegx.c (tilegx_gen_bundle): Reserve prev insn when delete useless insn. --- gcc/config/tilegx/tilegx.c | 22 -- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/gcc/config/tilegx/tilegx.c b/gcc/config/tilegx/tilegx.c index 76a7455..f846ca7 100644 --- a/gcc/config/tilegx/tilegx.c +++ b/gcc/config/tilegx/tilegx.c @@ -4469,8 +4469,7 @@ tilegx_gen_bundles (void) rtx_insn *end = NEXT_INSN (BB_END (bb)); prev = NULL; - for (insn = next_insn_to_bundle (BB_HEAD (bb), end); insn; - prev = insn, insn = next) + for (insn = next_insn_to_bundle (BB_HEAD (bb), end); insn; insn = next) { next = next_insn_to_bundle (NEXT_INSN (insn), end); @@ -4499,14 +4498,17 @@ tilegx_gen_bundles (void) /* Delete barrier insns, because they can mess up the emitting of bundle braces. If it is end-of-bundle, then the previous insn must be marked end-of-bundle. */ - if (get_attr_type (insn) == TYPE_NOTHING) { - if (GET_MODE (insn) == QImode && prev != NULL - && GET_MODE (prev) == SImode) - { - PUT_MODE (prev, QImode); - } - delete_insn (insn); - } + if (get_attr_type (insn) == TYPE_NOTHING) + { + if (GET_MODE (insn) == QImode && prev != NULL + && GET_MODE (prev) == SImode) + { + PUT_MODE (prev, QImode); + } + delete_insn (insn); + } + else + prev = insn; } } } -- 2.5.0
Re: [PATCH] gcc: config: tilegx: Reserve prev insn when delete useless insn
From: Chen Gang On Sat, Dec 10, 2016 at 03:38:10PM +, Bernd Edlinger wrote: > On 12/10/16 12:23, cheng...@emindsoft.com.cn wrote: > > From: Chen Gang > > > > When check bundle, gcc may still need modify the prev insn. Original > > implementation will lose the prev insn. > > > > Also correct the coding styles of relate code. > > > > 2016-12-10 Chen Gang > > > > gcc/ > > PR target/78222 > > * tilegx.c (tilegx_gen_bundle): Reserve prev insn when delete > > useless insn. > > I think this was already fixed by Walt: > > > r242617 | walt | 2016-11-19 03:34:17 +0100 (Sat, 19 Nov 2016) | 5 lines > Changed paths: > M /trunk/gcc/ChangeLog > M /trunk/gcc/config/tilegx/tilegx.c > > TILE-Gx: Fix bundling when encountering consecutive barriers. > > * config/tilegx/tilegx.c (tilegx_gen_bundles): Preserve >end-of-bundle marker for consecutive barriers. > Oh, yes, Good news to me. > > But the formatting here is still odd, and should be fixed: > TAB usage, single statements in braces, { not in a line of its own. > Yes. > I am however not sure about this statement: > >/* Never wrap {} around inline asm. */ >if (GET_CODE (PATTERN (insn)) != ASM_INPUT) > > ... because this does only exclude asm(""); that is basic asm with > empty assembler string. To exclude all other forms of asm statements > that are hidden in PARALLEL constructs we would need: > >/* Never wrap {} around inline asm. */ >if (GET_CODE (PATTERN (insn)) != ASM_INPUT >&& asm_noperands (PATTERN (insn)) < 0) > > > I think this if-condition is probably unnecessary, because it does > apparently not create any problems although it is completely broken. > For me, we need not touch it, since we are not quite sure about it. And welcome any other related members' idea for it. All together, I guess, I can leave this patch and continue to find and send another patches about tilegx. If I should still do somthing about this patch, please let me know. Thanks. >From cheng...@emindsoft.com.cn Mon Dec 12 19:23:58 2016 Date: Mon, 12 Dec 2016 19:23:58 +0800 From: Chen Gang To: Bernd Edlinger Cc: "cheng...@emindsoft.com.cn" , "l...@redhat.com" , "r...@redhat.com" , "mikest...@comcast.net" , "w...@tilera.com" , "gcc-patches@gcc.gnu.org" , "peter.mayd...@linaro.com" , "cmetc...@mellanox.com" Subject: Re: [PATCH] gcc: config: tilegx: Reserve prev insn when delete useless insn Message-ID: <20161212112320.GA22787@localhost.localdomain> References: <1481369032-26571-1-git-send-email-cheng...@emindsoft.com.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.7.1 (2016-10-04) Status: RO Content-Length: 2159 Lines: 66 On Sat, Dec 10, 2016 at 03:38:10PM +, Bernd Edlinger wrote: > On 12/10/16 12:23, cheng...@emindsoft.com.cn wrote: > > From: Chen Gang > > > > When check bundle, gcc may still need modify the prev insn. Original > > implementation will lose the prev insn. > > > > Also correct the coding styles of relate code. > > > > 2016-12-10 Chen Gang > > > > gcc/ > > PR target/78222 > > * tilegx.c (tilegx_gen_bundle): Reserve prev insn when delete > > useless insn. > > I think this was already fixed by Walt: > > > r242617 | walt | 2016-11-19 03:34:17 +0100 (Sat, 19 Nov 2016) | 5 lines > Changed paths: > M /trunk/gcc/ChangeLog > M /trunk/gcc/config/tilegx/tilegx.c > > TILE-Gx: Fix bundling when encountering consecutive barriers. > > * config/tilegx/tilegx.c (tilegx_gen_bundles): Preserve >end-of-bundle marker for consecutive barriers. > Oh, yes, Good news to me. > > But the formatting here is still odd, and should be fixed: > TAB usage, single statements in braces, { not in a line of its own. > Yes. > I am however not sure about this statement: > >/* Never wrap {} around inline asm. */ >if (GET_CODE (PATTERN (insn)) != ASM_INPUT) > > ... because this does only exclude asm(""); that is basic asm with > empty assembler string. To exclude all other forms of asm statements > that are hidden in PARALLEL constructs we would need: > >/* Never wrap {} around inline asm. */ >if (GET_CODE (PATTERN (insn)) != ASM_INPUT >&& asm_noperands (PATTERN (insn)) < 0) > > > I think this if-condition is probably unnecessary, because it does > apparently not create any problems although it is completely broken. > For me, we need not touch it, since we are not quite sure about it. And welcome any other related members' idea for it. All together, I guess, I can leave this patch and continue to find and send another patches about tilegx. If I should still do somth
[PATCH v4] gcc/config/tilegx/tilegx.c (tilegx_function_profiler): Save r10 to stack before call mcount
From: Chen Gang r10 may also be as parameter stack pointer for the nested function, so need save it before call mcount. Also clean up code: use '!' instead of "== 0" for checking static_chain_decl and compute_total_frame_size. 2016-11-06 Chen Gang gcc/ PR target/71331 * config/tilegx/tilegx.c (tilegx_function_profiler): Save r10 to stack before call mcount. (tilegx_can_use_return_insn_p): Clean up code. --- gcc/config/tilegx/tilegx.c | 20 ++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/gcc/config/tilegx/tilegx.c b/gcc/config/tilegx/tilegx.c index e403c32..fd9181b 100644 --- a/gcc/config/tilegx/tilegx.c +++ b/gcc/config/tilegx/tilegx.c @@ -3919,8 +3919,8 @@ bool tilegx_can_use_return_insn_p (void) { return (reload_completed - && cfun->static_chain_decl == 0 - && compute_total_frame_size () == 0 + && !cfun->static_chain_decl + && !compute_total_frame_size () && tilegx_current_function_is_leaf () && !crtl->profile && !df_regs_ever_live_p (TILEGX_LINK_REGNUM)); } @@ -5551,6 +5551,15 @@ tilegx_function_profiler (FILE *file, int labelno ATTRIBUTE_UNUSED) fprintf (file, "\t}\n"); } + if (cfun->static_chain_decl) +{ + fprintf (file, + "\t{\n" + "\taddi\tsp, sp, -16\n" + "\tst\tsp, r10\n" + "\t}\n"); +} + if (flag_pic) { fprintf (file, @@ -5568,6 +5577,13 @@ tilegx_function_profiler (FILE *file, int labelno ATTRIBUTE_UNUSED) "\t}\n", MCOUNT_NAME); } + if (cfun->static_chain_decl) +{ + fprintf (file, + "\taddi\tsp, sp, 16\n" + "\tld\tr10, sp\n"); +} + tilegx_in_bundle = false; } -- 1.9.3