[PATCH 2/2] Add tests for the vartrace pass

2019-11-10 Thread Andi Kleen
From: Andi Kleen So far they are mostly i386 target specific. Later they could be moved up to architecture specific if some other architecture adds vartracing. This would need abstracing the scanning for the trace function. gcc/testsuite/: 2019-11-10 Andi Kleen * g++.dg/vartrace-3

[PATCH 1/2] Add a pass to automatically add ptwrite instrumentation

2019-11-10 Thread Andi Kleen
From: Andi Kleen [v4: Rebased on current tree. Avoid some redundant log statements for locals and a few other fixes. Fix some comments. Improve documentation. Did some studies on the debug information quality, see below] Add a new pass to automatically instrument changes to variables with the

[PATCH] Document configuring your name and email address for git.

2020-01-12 Thread Andi Kleen

[PATCH] Document how to use --reference

2020-01-12 Thread Andi Kleen
From: Andi Kleen By popular demand, I did some updates to the git documentation how to use --reference to save disk space. Also recommend https instead of http (even though both are currently broken) --- htdocs/git.html | 15 --- 1 file changed, 12 insertions(+), 3 deletions

Re: [PATCH] Document how to use --reference

2020-01-12 Thread Andi Kleen
On Sun, Jan 12, 2020 at 08:51:28PM +0100, Andreas Schwab wrote: > On Jan 12 2020, Andi Kleen wrote: > > > By popular demand, I did some updates to the git documentation how > > to use --reference to save disk space. > > I would advice against using --reference. Now

Re: [PATCH] Document how to use --reference

2020-01-12 Thread Andi Kleen
On Sun, Jan 12, 2020 at 09:51:22PM +0100, Gerald Pfeifer wrote: > On Sun, 12 Jan 2020, Andi Kleen wrote: > > By popular demand, I did some updates to the git documentation how > > to use --reference to save disk space. > > > > Also recommend https instead of http (eve

Re: [PING^3] Re: [PATCH 1/2] Add a pass to automatically add ptwrite instrumentation

2019-12-09 Thread Andi Kleen
Andi Kleen writes: Ping! > Andi Kleen writes: > > Ping! > >> Andi Kleen writes: >> >> Ping! >> >>> From: Andi Kleen >>> >>> [v4: Rebased on current tree. Avoid some redundant log statements >>> for locals and a few othe

Re: [PATCH][RFC] Add new ipa-reorder pass

2019-12-11 Thread Andi Kleen
Martin Liška writes: > > Notes and limitations: > - The call-chain-clustering algorithm requires to fit as many as possible > functions into page size (4K). > Based on my measurements that should correspond to ~1000 GIMPLE statements > (IPA inliner size). I can > make it a param in the futur

Re: [PING^4] Re: [PATCH 1/2] Add a pass to automatically add ptwrite instrumentation

2019-12-16 Thread Andi Kleen
Andi Kleen writes: Ping! > Andi Kleen writes: > > Ping! > >> Andi Kleen writes: >> >> Ping! >> >>> Andi Kleen writes: >>> >>> Ping! >>> >>>> From: Andi Kleen >>>> >>>> [v4: Rebased on

Re: [PING^5] Re: [PATCH 1/2] Add a pass to automatically add ptwrite instrumentation

2020-01-07 Thread Andi Kleen
Andi Kleen writes: Ping! > Andi Kleen writes: > > Ping! > >> Andi Kleen writes: >> >> Ping! >> >>> Andi Kleen writes: >>> >>> Ping! >>> >>>> Andi Kleen writes: >>>> >>>> Ping

C/C++ frontend patches ping

2024-03-14 Thread Andi Kleen
musttail support for C/C++ https://gcc.gnu.org/pipermail/gcc-patches/2024-January/643867.html Support constexpr for asm statements in C++ https://gcc.gnu.org/pipermail/gcc-patches/2024-January/643933.html

Re: C/C++ frontend patches ping

2024-03-14 Thread Andi Kleen
Andrew Pinski writes: > On Thu, Mar 14, 2024 at 9:36 PM Andi Kleen wrote: >> >> >> musttail support for C/C++ >> >> https://gcc.gnu.org/pipermail/gcc-patches/2024-January/643867.html >> >> >> Support constexpr for asm statements in C++ &

Re: [PATCH v1] C++: Support constexpr strings for asm statements

2024-03-15 Thread Andi Kleen
Thanks Jakub. > > +/* Parse a string literal or constant expression yielding a string. > > + The constant expression uses extra parens to avoid ambiguity with "x" > > (expr). > > + > > + asm-string-expr: > > + string-literal > > + ( constant-expr ) */ > > + > > +static tree > > +cp_pa

Re: [PATCH v1] C++: Support constexpr strings for asm statements

2024-03-15 Thread Andi Kleen
> > I think keeping it untranslated is fine for now. Any translation > > if really needed would be a separate feature. > > I mean, unless you make extra effort, it is translated. > Even in your current version, try constexpr *foo () { return "nop"; } > and you'll see that it actually results in "\

Re: [PATCH v3 1/5] Improve must tail in RTL backend

2024-01-31 Thread Andi Kleen
> This results in "error: cannot tail-call: cannot tail-call: other reasons". > So the second argument should be "other reasons" only. Yes will fix those. Thanks. > > I notice that if I don't use -O2 I also get "other reasons". But it should be > easy-ish to say "cannot tail-call: optimizations

Re: [PATCH v3 2/5] C++: Support clang compatible [[musttail]] (PR83324)

2024-01-31 Thread Andi Kleen
> > For compatibility it also detects clang::musttail > > FWIW, it's not clear to me we should do this. I don't see a precedent. It would make existing code just work (as long as they don't use ifdef) > > > One problem is that tree-tailcall usually fails when optimization > > is disabled, whic

Re: [PATCH v3 4/5] Add tests for C/C++ musttail attributes

2024-01-31 Thread Andi Kleen
> This will run the test only once with -std=c++11. We'll get better coverage > with dropping the line above and using > > /* { dg-do compile { target { tail_call && { c || c++11 } } } } */ > > but here it may not matter. The problem is that older C/C++ standards don't support [[]] attributes.

[PATCH v4 1/5] Improve must tail in RTL backend

2024-02-02 Thread Andi Kleen
- Give error messages for all causes of non sibling call generation - Don't override choices of other non sibling call checks with must tail. This causes ICEs. The must tail attribute now only overrides flag_optimize_sibling_calls locally. - Error out when tree-tailcall failed to mark a must-tail c

[PATCH v4 4/5] Add tests for C/C++ musttail attributes

2024-02-02 Thread Andi Kleen
Mostly adopted from the existing C musttail plugin tests. gcc/testsuite/ChangeLog: * c-c++-common/musttail1.c: New test. * c-c++-common/musttail2.c: New test. * c-c++-common/musttail3.c: New test. * c-c++-common/musttail4.c: New test. * c-c++-common/musttai

Updated musttail patches

2024-02-02 Thread Andi Kleen
This patchkit implements a [[musttail]] attribute for C/C++. v4: Addressed all feedback except clang::musttail is still supported (I don't want to force an #ifdef to most users) and I'm also still using the lookup/remove_attributes (not clear if anything else is worth it and it would certainly be

[PATCH v4 5/5] Add documentation for musttail attribute

2024-02-02 Thread Andi Kleen
gcc/ChangeLog: * doc/extend.texi: Document [[musttail]] --- gcc/doc/extend.texi | 16 1 file changed, 16 insertions(+) diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index 142e41ab8fbf..866f6c4a9fed 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -9

[PATCH v4 3/5] C: Implement musttail attribute for returns

2024-02-02 Thread Andi Kleen
Implement a C23 clang compatible musttail attribute similar to the earlier C++ implementation in the C parser. PR83324 gcc/c/ChangeLog: * c-parser.cc (struct attr_state): Define with musttail_p. (c_parser_statement_after_labels): Handle [[musttail]] (c_parser_std_

[PATCH v4 2/5] C++: Support clang compatible [[musttail]] (PR83324)

2024-02-02 Thread Andi Kleen
This patch implements a clang compatible [[musttail]] attribute for returns. musttail is useful as an alternative to computed goto for interpreters. With computed goto the interpreter function usually ends up very big which causes problems with register allocation and other per function optimizati

Re: Updated musttail patches

2024-02-02 Thread Andi Kleen
On Fri, Feb 02, 2024 at 01:18:06PM +, Joseph Myers wrote: > On Fri, 2 Feb 2024, Andi Kleen wrote: > > > This patchkit implements a [[musttail]] attribute for C/C++. > > > > v4: > > Addressed all feedback except clang::musttail is still supported > > (I d

Re: [PATCH v4 4/5] Add tests for C/C++ musttail attributes

2024-02-02 Thread Andi Kleen
> Sorry, I wasn't clear about this in previous patch -- noipa will > subsume other ipa attributes, > so there's no need to have noinline, noclone along with noipa. > int __attribute__((noipa)) callee(int i) should be sufficient for > disabling IPA optimizations involving callee. I thought you were

Re: [PATCH v4 5/5] Add documentation for musttail attribute

2024-02-05 Thread Andi Kleen
On Sat, Feb 03, 2024 at 09:35:43PM -0700, Sandra Loosemore wrote: > On 2/2/24 02:09, Andi Kleen wrote: > > gcc/ChangeLog: > > > > * doc/extend.texi: Document [[musttail]] > > --- > > gcc/doc/extend.texi | 16 > > 1 file changed, 16

Re: [PATCH] i386: [APX] Document inline asm behavior and new switch for APX

2024-01-10 Thread Andi Kleen
Hongtao Liu writes: >> >> +@opindex mapx-inline-asm-use-gpr32 >> +@item -mapx-inline-asm-use-gpr32 >> +When APX_F enabled, EGPR usage was by default disabled to prevent >> +unexpected EGPR generation in instructions that does not support it. >> +To invoke EGPR usage in inline asm, use this switch

[PATCH v1 1/4] Improve must tail in RTL backend

2024-01-24 Thread Andi Kleen
- Give error messages for all causes of non sibling call generation - Don't override choices of other non sibling call checks with must tail. This causes ICEs. The must tail attribute now only overrides flag_optimize_sibling_calls locally. - Error out when tree-tailcall failed to mark a must-tail c

[PATCH v1 3/4] Add tests for C++ musttail attribute

2024-01-24 Thread Andi Kleen
Mostly adopted from the existing C musttail plugin tests. --- gcc/testsuite/g++.dg/musttail1.C | 15 gcc/testsuite/g++.dg/musttail2.C | 35 ++ gcc/testsuite/g++.dg/musttail3.C | 42 gcc/testsuite/g++.dg/musttail4.C | 19

[PATCH v1 4/4] Add documentation for musttail attribute

2024-01-24 Thread Andi Kleen
--- gcc/doc/extend.texi | 19 ++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index 0bc586d120e7..444b68f5d071 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -27890,7 +27890,8 @@ Predefined Macros,cpp,The GN

[PATCH v1 2/4] C++: Support clang compatible [[musttail]]

2024-01-24 Thread Andi Kleen
This patch implements a clang compatible [[musttail]] attribute for returns. musttail is useful as an alternative to computed goto for interpreters. With computed goto the interpreter function usually ends up very big which causes problems with register allocation and other per function optimizati

Re: [PATCH v1 2/4] C++: Support clang compatible [[musttail]]

2024-01-24 Thread Andi Kleen
> ...are the three hunks above needed? The reason for asking is that, > if they were needed, I'd have expected that we'd also need a table > entry for clang::musttail (which is possible to add). But trying it > locally, the patch seemed to work without this. Interesting thanks. I think I copied

Re: [PATCH v1 2/4] C++: Support clang compatible [[musttail]]

2024-01-24 Thread Andi Kleen
On Wed, Jan 24, 2024 at 11:13:44AM +, Sam James wrote: > > Andi Kleen writes: > > > This patch implements a clang compatible [[musttail]] attribute for > > returns. > > This is PR83324. See also PR52067 and PR110899. Thanks for the references. I'll add i

[no subject]

2024-01-24 Thread Andi Kleen
This version addresses all the feedback so far (Thanks!). The largest change is support for using [[musttail]] in C23, not just C++. -Andi

[PATCH v2 1/5] Improve must tail in RTL backend

2024-01-24 Thread Andi Kleen
- Give error messages for all causes of non sibling call generation - Don't override choices of other non sibling call checks with must tail. This causes ICEs. The must tail attribute now only overrides flag_optimize_sibling_calls locally. - Error out when tree-tailcall failed to mark a must-tail c

[PATCH v2 3/5] C: Implement musttail attribute for returns

2024-01-24 Thread Andi Kleen
Implement a C23 clang compatible musttail attribute similar to the earlier C++ implementation in the C parser. --- gcc/c/c-parser.cc | 59 +-- gcc/c/c-tree.h| 2 +- gcc/c/c-typeck.cc | 15 ++-- 3 files changed, 61 insertions(+), 15 deletions

[PATCH v2 2/5] C++: Support clang compatible [[musttail]] (PR83324)

2024-01-24 Thread Andi Kleen
This patch implements a clang compatible [[musttail]] attribute for returns. musttail is useful as an alternative to computed goto for interpreters. With computed goto the interpreter function usually ends up very big which causes problems with register allocation and other per function optimizati

[PATCH v2 5/5] Add documentation for musttail attribute

2024-01-24 Thread Andi Kleen
--- gcc/doc/extend.texi | 16 1 file changed, 16 insertions(+) diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index 0bc586d120e7..c68d32bed8de 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -9867,6 +9867,22 @@ foo (int x, int y) @code{y} is not actually in

[PATCH v2 4/5] Add tests for C/C++ musttail attributes

2024-01-24 Thread Andi Kleen
Mostly adopted from the existing C musttail plugin tests. --- gcc/testsuite/c-c++-common/musttail1.c | 17 gcc/testsuite/c-c++-common/musttail2.c | 36 ++ gcc/testsuite/c-c++-common/musttail3.c | 31 ++ gcc/testsuite/c-c++-common/musttail4.c

Re: [PATCH v2 5/5] Add documentation for musttail attribute

2024-01-25 Thread Andi Kleen
On Thu, Jan 25, 2024 at 07:51:21AM +0100, rep.dot@gmail.com wrote: > On 24 January 2024 20:30:45 CET, Andi Kleen wrote: > >--- > > gcc/doc/extend.texi | 16 > > 1 file changed, 16 insertions(+) > > > >diff --git a/gcc/doc/extend.texi b/gcc/doc/

[PATCH v1] C++: Support constexpr strings for asm statements

2024-01-25 Thread Andi Kleen
Some programing styles use a lot of inline assembler, and it is common to use very complex preprocessor macros to generate the assembler strings for the asm statements. In C++ there would be a typesafe alternative using templates and constexpr to generate the assembler strings, but unfortunately th

Re: [PATCH v2 3/5] C: Implement musttail attribute for returns

2024-01-25 Thread Andi Kleen
On Thu, Jan 25, 2024 at 08:08:23PM +, Joseph Myers wrote: > On Wed, 24 Jan 2024, Andi Kleen wrote: > > > Implement a C23 clang compatible musttail attribute similar to the earlier > > C++ implementation in the C parser. > > I'd expect diagnostics, and associat

Re: [PATCH v2 3/5] C: Implement musttail attribute for returns

2024-01-26 Thread Andi Kleen
> > I don't have tests for that but since it's not new behavior I suppose > > that's sufficient. > > Each attribute should have tests that invalid uses are appropriately > diagnosed. See gcc.dg/c23-attr-fallthrough-2.c for examples of such tests > in the case of the [[fallthrough]] attribute.

Updated [[musttail]] patchkit

2024-01-30 Thread Andi Kleen
Fixed all earlier review comments.

[PATCH v3 2/5] C++: Support clang compatible [[musttail]] (PR83324)

2024-01-30 Thread Andi Kleen
This patch implements a clang compatible [[musttail]] attribute for returns. musttail is useful as an alternative to computed goto for interpreters. With computed goto the interpreter function usually ends up very big which causes problems with register allocation and other per function optimizati

[PATCH v3 1/5] Improve must tail in RTL backend

2024-01-30 Thread Andi Kleen
- Give error messages for all causes of non sibling call generation - Don't override choices of other non sibling call checks with must tail. This causes ICEs. The must tail attribute now only overrides flag_optimize_sibling_calls locally. - Error out when tree-tailcall failed to mark a must-tail c

[PATCH v3 4/5] Add tests for C/C++ musttail attributes

2024-01-30 Thread Andi Kleen
Mostly adopted from the existing C musttail plugin tests. --- gcc/testsuite/c-c++-common/musttail1.c | 17 gcc/testsuite/c-c++-common/musttail2.c | 36 + gcc/testsuite/c-c++-common/musttail3.c | 31 + gcc/testsuite/c-c++-common/musttail4.

[PATCH v3 3/5] C: Implement musttail attribute for returns

2024-01-30 Thread Andi Kleen
Implement a C23 clang compatible musttail attribute similar to the earlier C++ implementation in the C parser. --- gcc/c/c-parser.cc | 61 +-- gcc/c/c-tree.h| 2 +- gcc/c/c-typeck.cc | 15 ++-- 3 files changed, 63 insertions(+), 15 deletions

[PATCH v3 5/5] Add documentation for musttail attribute

2024-01-30 Thread Andi Kleen
--- gcc/doc/extend.texi | 16 1 file changed, 16 insertions(+) diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index 0bc586d120e7..1d413b0ef6d1 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -9867,6 +9867,22 @@ foo (int x, int y) @code{y} is not actually in

[PING] Re: Updated musttail patchkit

2024-07-01 Thread Andi Kleen
Andi Kleen writes: I wanted to ping this patch kit to add musttail support for C/C++, to enable future python versions and other users and keep up with clang. https://gcc.gnu.org/pipermail/gcc-patches/2024-June/thread.html#655447 It unfortunately touches various different parts of the

Re: [PATCH] x86: Update branch hint for Redwood Cove.

2024-07-02 Thread Andi Kleen
liuhongt writes: > From: "H.J. Lu" > > According to Intel® 64 and IA-32 Architectures Optimization Reference > Manual[1], Branch Hint is updated for Redwood Cove. > > cut from [1]- > Starting with the Redwood Cove microarchitecture, if the predictor has > no store

Re: [PATCH v8 07/12] Enable musttail tail conversion even when not optimizing

2024-07-06 Thread Andi Kleen
> > +class pass_musttail : public gimple_opt_pass > > +{ > > +public: > > + pass_musttail (gcc::context *ctxt) > > +: gimple_opt_pass (pass_data_musttail, ctxt) > > + {} > > + > > + /* opt_pass methods: */ > > + /* This pass is only used when not optimizing to make [[musttail]] still > > +

Re: [PATCH v8 03/12] Add a musttail generic attribute to the c-attribs table

2024-07-06 Thread Andi Kleen
On Fri, Jul 05, 2024 at 12:44:47PM +0200, Richard Biener wrote: > On Sat, Jun 22, 2024 at 8:57 PM Andi Kleen wrote: > > > > It does nothing currently since statement attributes are handled > > directly in the parser. > > Is this needed at all? a "'musttail

Re: [PATCH v8 09/12] Delay caller error reporting for musttail

2024-07-06 Thread Andi Kleen
On Fri, Jul 05, 2024 at 01:45:17PM +0200, Richard Biener wrote: > On Sat, Jun 22, 2024 at 9:00 PM Andi Kleen wrote: > > > > Move the error reporting for caller attributes to be > > after the tail call discovery, so that we can give proper > > error messages tagged to

Re: [PATCH v8 08/12] Give better error messages for musttail

2024-07-06 Thread Andi Kleen
> >if (!single_succ_p (bb)) > > -return; > > +{ > > + int num_eh, num_other; > > + bb_get_succ_edge_count (bb, num_eh, num_other); > > + /* Allow EH edges so that we can give a better > > +error message later. */ > > Please instead use has_abnormal_or_eh_outgoin

Re: [PATCH v8 07/12] Enable musttail tail conversion even when not optimizing

2024-07-08 Thread Andi Kleen
On Mon, Jul 08, 2024 at 08:53:27AM +0200, Richard Biener wrote: > Ah, I see. So this pass is responsible for both -O0 and > -fno-optimized-sibling-calls. > But I'm quite sure the other pass doesn't run with -O0 > -foptimize-sibling-calls, does it? It does run: ./cc1 -O0 -fdump-passes -foptimize-

Re: [PATCH v8 09/12] Delay caller error reporting for musttail

2024-07-08 Thread Andi Kleen
> > Overall the logic in this pass is rather convoluted and > > could deserve some cleanups and separation of concerns. > > e.g. it would be better to separate tail calls and tail > > recursion. But I'm not trying to rewrite the pass here. > > Understood. For a v9, can you squash the tree-tailcal

Re: [PATCH v8 08/12] Give better error messages for musttail

2024-07-08 Thread Andi Kleen
On Mon, Jul 08, 2024 at 09:06:21AM +0200, Richard Biener wrote: > On Sat, Jul 6, 2024 at 8:45 PM Andi Kleen wrote: > > > > > >if (!single_succ_p (bb)) > > > > -return; > > > > +{ > > > > + int num_eh, num_other; >

Re: [PATCH v3] Target-independent store forwarding avoidance.

2024-07-08 Thread Andi Kleen
> I have added a target hook for this in v4 of this patch. The hook > receives all the information about the stores, the load, the estimated > sequence cost and whether we expect to eliminate the load. With this > information the target should be able to make an informed decision. > > What you men

Re: [PATCH v8 07/12] Enable musttail tail conversion even when not optimizing

2024-07-08 Thread Andi Kleen
On Mon, Jul 08, 2024 at 05:27:53PM +0200, Richard Biener wrote: > > > > Am 08.07.2024 um 17:22 schrieb Andi Kleen : > > > > On Mon, Jul 08, 2024 at 08:53:27AM +0200, Richard Biener wrote: > >> Ah, I see. So this pass is responsible for both -O0 and > >&

[PATCH v9 02/10] Fix pro_and_epilogue for sibcalls at -O0 (PR115255)

2024-07-08 Thread Andi Kleen
Some of the cfg fixups in pro_and_epilogue for sibcalls were dependent on "optimize". Make them check cfun->tail_call_marked instead to handle the -O0 musttail case. This fixes the musttail test cases on arm targets. gcc/ChangeLog: PR target/115255 * function.cc (thread_prologue_

[PATCH v9 03/10] Add a musttail generic attribute to the c-attribs table

2024-07-08 Thread Andi Kleen
The actual handling is directly in the parser since the generic mechanism doesn't support statement attributes, but this gives basic error checking/detection on the attribute. gcc/c-family/ChangeLog: PR83324 * c-attribs.cc (handle_musttail_attribute): Add. * c-common.h (ha

New musttail patchkit

2024-07-08 Thread Andi Kleen
This version addresses all the review feedback (Thanks everyone!) It is getting close to the finish line. The only missing reviews now are for the C frontend part (patch 5). Joseph and Marek, I would appreciate if you could take a look. - Addressed Richie's feedback with various improvements and

[PATCH v9 04/10] C++: Support clang compatible [[musttail]] (PR83324)

2024-07-08 Thread Andi Kleen
This patch implements a clang compatible [[musttail]] attribute for returns. musttail is useful as an alternative to computed goto for interpreters. With computed goto the interpreter function usually ends up very big which causes problems with register allocation and other per function optimizati

[PATCH v9 06/10] Enable musttail tail conversion even when not optimizing

2024-07-08 Thread Andi Kleen
Enable the tailcall optimization for non optimizing builds, but in this case only checks calls that have the musttail attribute set. This makes musttail work without optimization. This is done with a new late musttail pass that is only active when not optimizing. The new pass relies on tree-cfg to

[PATCH v9 01/10] Improve must tail in RTL backend

2024-07-08 Thread Andi Kleen
- Give error messages for all causes of non sibling call generation - When giving error messages clear the musttail flag to avoid ICEs - Error out when tree-tailcall failed to mark a must-tail call sibcall. In this case it doesn't know the true reason and only gives a vague message. PR8332

[PATCH v9 07/10] Give better error messages for musttail

2024-07-08 Thread Andi Kleen
When musttail is set, make tree-tailcall give error messages when it cannot handle a call. This avoids vague "other reasons" error messages later at expand time when it sees a musttail function not marked tail call. In various cases this requires delaying the error until the call is discovered. A

[PATCH v9 09/10] Add documentation for musttail attribute

2024-07-08 Thread Andi Kleen
gcc/ChangeLog: PR83324 * doc/extend.texi: Document [[musttail]] --- gcc/doc/extend.texi | 25 +++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index b2e41a581dd1..f83e643da19c 100644 --- a/gcc/doc/ex

[PATCH v9 08/10] Add tests for C/C++ musttail attributes

2024-07-08 Thread Andi Kleen
Some adopted from the existing C musttail plugin tests. gcc/testsuite/ChangeLog: * c-c++-common/musttail1.c: New test. * c-c++-common/musttail2.c: New test. * c-c++-common/musttail3.c: New test. * c-c++-common/musttail4.c: New test. * c-c++-common/musttail7

[PATCH v9 05/10] C: Implement musttail attribute for returns

2024-07-08 Thread Andi Kleen
Implement a C23 clang compatible musttail attribute similar to the earlier C++ implementation in the C parser. PR83324 gcc/c/ChangeLog: * c-parser.cc (struct attr_state): Define with musttail_p. (c_parser_statement_after_labels): Handle [[musttail]] (c_parser_std_

[PATCH v9 10/10] Mark expand musttail error messages for translation

2024-07-08 Thread Andi Kleen
The musttail error messages are reported to the user, so must be translated. gcc/ChangeLog: PR83324 * calls.cc (initialize_argument_information): Mark messages for translation. (can_implement_as_sibling_call_p): Dito. (expand_call): Dito. --- gcc/calls.cc

Re: [PATCH v9 05/10] C: Implement musttail attribute for returns

2024-07-13 Thread Andi Kleen
Here's an updated patch with your feedback addressed. Is this version ok? The common code is in the C++ patch. --- Implement a C23 clang compatible musttail attribute similar to the earlier C++ implementation in the C parser. gcc/c/ChangeLog: PR c/83324 * c-parser.cc (struct

Re: [PATCH v9 04/10] C++: Support clang compatible [[musttail]] (PR83324)

2024-07-13 Thread Andi Kleen
Updated version with common code for C/C++ extracted in c-family. Other than that no changes. Is this version ok to commit? --- This patch implements a clang compatible [[musttail]] attribute for returns. musttail is useful as an alternative to computed goto for interpreters. With computed go

Re: [PATCH v9 08/10] Add tests for C/C++ musttail attributes

2024-07-15 Thread Andi Kleen
On Mon, Jul 15, 2024 at 06:57:57PM -0400, Jason Merrill wrote: > On 7/8/24 12:56 PM, Andi Kleen wrote: > > diff --git a/gcc/testsuite/g++.dg/musttail10.C > > b/gcc/testsuite/g++.dg/musttail10.C > > new file mode 100644 > > index ..9b7043b8a306 > > ---

Re: [PATCH v9 08/10] Add tests for C/C++ musttail attributes

2024-07-16 Thread Andi Kleen
> In the adjusted test it looks like the types of f and g match, so I wouldn't > expect an error. Good point! Missing the forest for the trees. Anyways are the C++ patches ok with this change? Thanks, -Andi

Re: [PATCH v9 08/10] Add tests for C/C++ musttail attributes

2024-07-16 Thread Andi Kleen
On Tue, Jul 16, 2024 at 11:17:14AM -0400, Jason Merrill wrote: > On 7/16/24 11:15 AM, Andi Kleen wrote: > > > In the adjusted test it looks like the types of f and g match, so I > > > wouldn't > > > expect an error. > > > > Good point! Missing the f

Re: [PATCH v9 08/10] Add tests for C/C++ musttail attributes

2024-07-16 Thread Andi Kleen
On Tue, Jul 16, 2024 at 02:51:13PM -0400, Jason Merrill wrote: > On 7/16/24 12:18 PM, Andi Kleen wrote: > > On Tue, Jul 16, 2024 at 11:17:14AM -0400, Jason Merrill wrote: > > > On 7/16/24 11:15 AM, Andi Kleen wrote: > > > > > In the adjusted test it looks like

Re: [PATCH v9 08/10] Add tests for C/C++ musttail attributes

2024-07-16 Thread Andi Kleen
On Tue, Jul 16, 2024 at 12:52:31PM -0700, Andi Kleen wrote: > On Tue, Jul 16, 2024 at 02:51:13PM -0400, Jason Merrill wrote: > > On 7/16/24 12:18 PM, Andi Kleen wrote: > > > On Tue, Jul 16, 2024 at 11:17:14AM -0400, Jason Merrill wrote: > > > > On 7/16/24 11:15 AM, An

Re: [PATCH v9 08/10] Add tests for C/C++ musttail attributes

2024-07-16 Thread Andi Kleen
On Tue, Jul 16, 2024 at 06:06:42PM -0400, Jason Merrill wrote: > On 7/16/24 5:55 PM, Andi Kleen wrote: > > On Tue, Jul 16, 2024 at 12:52:31PM -0700, Andi Kleen wrote: > > > On Tue, Jul 16, 2024 at 02:51:13PM -0400, Jason Merrill wrote: > > > > On 7/16/24 12:18 PM,

Re: [PATCH v9 08/10] Add tests for C/C++ musttail attributes

2024-07-17 Thread Andi Kleen
> Great. Does it also work in a non-template function? Sadly it did not because there needs to be more AGGR_VIEW_EXPR handling, as you predicted at some point. I fixed it now. Will send updated patches. -Andi

Remaining frontend patches for musttail

2024-07-17 Thread Andi Kleen
This patchkit contains the remaining C/C++ frontend patches for the [[musttail]] extension that still need approval for trunk. I already committed the tree-ssa and RTL pieces. C: I addressed Marek's feedback, but need final ack. Marek can you please take a look? C++: Fixed support for AGGR_VIEW

[PATCH v10 1/3] C++: Support clang compatible [[musttail]] (PR83324)

2024-07-17 Thread Andi Kleen
This patch implements a clang compatible [[musttail]] attribute for returns. musttail is useful as an alternative to computed goto for interpreters. With computed goto the interpreter function usually ends up very big which causes problems with register allocation and other per function optimizati

[PATCH v10 2/3] C: Implement musttail attribute for returns

2024-07-17 Thread Andi Kleen
Implement a C23 clang compatible musttail attribute similar to the earlier C++ implementation in the C parser. gcc/c/ChangeLog: PR c/83324 * c-parser.cc (struct attr_state): Define with musttail_p. (c_parser_statement_after_labels): Handle [[musttail]]. (c_parser_s

[PATCH v10 3/3] Add tests for C/C++ musttail attributes

2024-07-17 Thread Andi Kleen
Some adopted from the existing C musttail plugin tests. Also extends the ability to query the sibcall capabilities of the target. gcc/testsuite/ChangeLog: * testsuite/lib/target-supports.exp (check_effective_target_struct_tail_call): New function. * c-c++-common/musttail1.

Re: [PATCH v10 2/3] C: Implement musttail attribute for returns

2024-07-18 Thread Andi Kleen
On Thu, Jul 18, 2024 at 02:19:21PM -0400, Marek Polacek wrote: > On Wed, Jul 17, 2024 at 09:30:00PM -0700, Andi Kleen wrote: > > Implement a C23 clang compatible musttail attribute similar to the earlier > > C++ implementation in the C parser. > > > > gcc/c/ChangeL

Re: [PATCH v10 2/3] C: Implement musttail attribute for returns

2024-07-18 Thread Andi Kleen
> > > > + set_musttail_on_return (retval, xloc, musttail_p); > > > > + > > > >if (retval) > > > > { > > > >tree semantic_type = NULL_TREE; > > > > > > Is it deliberate that set_musttail_on_return is called outside the > > > if (retval) block? If it can be moved into it, set_must

Re: [PATCH v10 1/3] C++: Support clang compatible [[musttail]] (PR83324)

2024-07-18 Thread Andi Kleen
Updated patch with the !retval bug fix identified by Marek. This patch implements a clang compatible [[musttail]] attribute for returns. musttail is useful as an alternative to computed goto for interpreters. With computed goto the interpreter function usually ends up very big which causes pr

Re: [PATCH v5 5/5] Add documentation for musttail attribute

2024-05-14 Thread Andi Kleen
> Looks generally OK though does this mean people can debug > programs using [[gnu::musttail]] only with optimized builds? It > seems to me we should try harder to make [[gnu::musttail]] work > at -O0 and generally behave the same at all optimization levels? Yes that's a fair point. The problem i

Re: [PATCH v5 1/5] Improve must tail in RTL backend

2024-05-14 Thread Andi Kleen
> > diff --git a/gcc/testsuite/gcc.dg/plugin/must-tail-call-1.c > > b/gcc/testsuite/gcc.dg/plugin/must-tail-call-1.c > > index 3a6d4cceaba7..44af361e2925 100644 > > --- a/gcc/testsuite/gcc.dg/plugin/must-tail-call-1.c > > +++ b/gcc/testsuite/gcc.dg/plugin/must-tail-call-1.c > > @@ -1,4 +1,5 @@ > >

Re: [PATCH v5 2/5] C++: Support clang compatible [[musttail]] (PR83324)

2024-05-14 Thread Andi Kleen
Hi Jason, On Mon, May 06, 2024 at 11:02:20PM -0400, Jason Merrill wrote: > > @@ -30189,7 +30207,7 @@ cp_parser_std_attribute (cp_parser *parser, tree > > attr_ns) > > /* Maybe we don't expect to see any arguments for this attribute. */ > > const attribute_spec *as > > = looku

Re: [PATCH v5 2/5] C++: Support clang compatible [[musttail]] (PR83324)

2024-05-14 Thread Andi Kleen
> > > You need a template testcase; I expect it doesn't work in templates with > > > the > > > current patch. It's probably enough to copy it in tsubst_expr where we > > > currently propagate CALL_EXPR_OPERATOR_SYNTAX. > > > > I tried it with the appended test case, everything seems to work with

Re: [PATCH v5 1/5] Improve must tail in RTL backend

2024-05-19 Thread Andi Kleen
On Tue, May 14, 2024 at 04:15:08PM +0200, Richard Biener wrote: > On Sun, May 5, 2024 at 8:16 PM Andi Kleen wrote: > > > > - Give error messages for all causes of non sibling call generation > > - Don't override choices of other non sibling call checks with > >

Re: [PATCH v5 1/5] Improve must tail in RTL backend

2024-05-21 Thread Andi Kleen
> I can't see how this triggers on the IL above, the loop should have > ignored both the return and the clobber and when recursing to > the predecessor stop before the above check when runnig into the > call? Yes, I tracked that down later. The problem was that there were multiple successors to th

Musttail patchkit v6

2024-05-21 Thread Andi Kleen
I reworked the musttail patchkit to make it work without optimization and also give better error messages and fixed some bugs and increased the test coverage. The no optimization support is not perfect: it cannot handle returning small structures which would need to be allocated to registers first

[PATCH v6 3/8] C++: Support clang compatible [[musttail]] (PR83324)

2024-05-21 Thread Andi Kleen
This patch implements a clang compatible [[musttail]] attribute for returns. musttail is useful as an alternative to computed goto for interpreters. With computed goto the interpreter function usually ends up very big which causes problems with register allocation and other per function optimizati

[PATCH v6 4/8] C: Implement musttail attribute for returns

2024-05-21 Thread Andi Kleen
Implement a C23 clang compatible musttail attribute similar to the earlier C++ implementation in the C parser. PR83324 gcc/c/ChangeLog: * c-parser.cc (struct attr_state): Define with musttail_p. (c_parser_statement_after_labels): Handle [[musttail]] (c_parser_std_

[PATCH v6 1/8] Improve must tail in RTL backend

2024-05-21 Thread Andi Kleen
- Give error messages for all causes of non sibling call generation - When giving error messages clear the musttail flag to avoid ICEs - Error out when tree-tailcall failed to mark a must-tail call sibcall. In this case it doesn't know the true reason and only gives a vague message. PR8332

[PATCH v6 2/8] Add a musttail generic attribute to the c-attribs table

2024-05-21 Thread Andi Kleen
It does nothing currently since statement attributes are handled directly in the parser. gcc/c-family/ChangeLog: * c-attribs.cc (handle_musttail_attribute): Add. * c-common.h (handle_musttail_attribute): Add. --- gcc/c-family/c-attribs.cc | 15 +++ gcc/c-family/c-comm

[PATCH v6 5/8] Add tests for C/C++ musttail attributes

2024-05-21 Thread Andi Kleen
Mostly adopted from the existing C musttail plugin tests. gcc/testsuite/ChangeLog: * c-c++-common/musttail1.c: New test. * c-c++-common/musttail2.c: New test. * c-c++-common/musttail3.c: New test. * c-c++-common/musttail4.c: New test. * c-c++-common/musttai

[PATCH v6 7/8] Give better error messages for musttail

2024-05-21 Thread Andi Kleen
When musttail is set, make tree-tailcall to give error messages when it cannot handle a call. This avoids vague "other reasons" error messages later at expand time. This doesn't always work, for example when find_tail_call walking gives up because the control flow is too complicated then it won't

  1   2   3   4   5   6   7   8   9   >