public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/97831] New: Lack of disable_tail_calls attribute
@ 2020-11-14 20:31 irogers at google dot com
  2020-11-14 20:47 ` [Bug c/97831] " pinskia at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: irogers at google dot com @ 2020-11-14 20:31 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97831

            Bug ID: 97831
           Summary: Lack of disable_tail_calls attribute
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: irogers at google dot com
  Target Milestone: ---

Tail call optimization may remove stack frames, certain tests assert stack
frames are present. Previously these tests would use
__attribute__((optimize("no-optimize-sibling-calls"))), however, the use of the
optimize attribute shouldn't occur in production code as per the FAQ:
https://gcc.gnu.org/wiki/FAQ#optimize_attribute_broken
The attribute disable_tail_calls is used in other compilers for this situation:
https://clang.llvm.org/docs/AttributeReference.html#disable-tail-calls

A situation where this has come up is in Linux:
https://lore.kernel.org/lkml/20201028081123.GT2628@hirez.programming.kicks-ass.net/
https://lore.kernel.org/lkml/20201114000803.909530-1-irogers@google.com/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c/97831] Lack of disable_tail_calls attribute
  2020-11-14 20:31 [Bug c/97831] New: Lack of disable_tail_calls attribute irogers at google dot com
@ 2020-11-14 20:47 ` pinskia at gcc dot gnu.org
  2020-11-14 20:56 ` pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2020-11-14 20:47 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97831

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I can think of a simple way disabling tail calls:

static void disabletailcallfunc(void*) __attribute__((noipa));
static void disabletailcallfunc(void *x){}
#define disabletailcall() do {int a; disabletailcallfunc(&a);}while(0);

int functionwhichIwantToDisableTailCallFrom(...)
{
disabletailcall();

}

The overhead for this extra variable and call is small in terms of things.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c/97831] Lack of disable_tail_calls attribute
  2020-11-14 20:31 [Bug c/97831] New: Lack of disable_tail_calls attribute irogers at google dot com
  2020-11-14 20:47 ` [Bug c/97831] " pinskia at gcc dot gnu.org
@ 2020-11-14 20:56 ` pinskia at gcc dot gnu.org
  2020-11-14 20:57 ` pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2020-11-14 20:56 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97831

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I think this was rejected 3 years ago:
https://gcc.gnu.org/legacy-ml/gcc-patches/2017-05/msg02221.html

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c/97831] Lack of disable_tail_calls attribute
  2020-11-14 20:31 [Bug c/97831] New: Lack of disable_tail_calls attribute irogers at google dot com
  2020-11-14 20:47 ` [Bug c/97831] " pinskia at gcc dot gnu.org
  2020-11-14 20:56 ` pinskia at gcc dot gnu.org
@ 2020-11-14 20:57 ` pinskia at gcc dot gnu.org
  2020-11-16  7:19 ` rguenth at gcc dot gnu.org
  2021-09-02  5:38 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2020-11-14 20:57 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97831

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #2)
And see https://gcc.gnu.org/legacy-ml/gcc-patches/2017-07/msg00130.html

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c/97831] Lack of disable_tail_calls attribute
  2020-11-14 20:31 [Bug c/97831] New: Lack of disable_tail_calls attribute irogers at google dot com
                   ` (2 preceding siblings ...)
  2020-11-14 20:57 ` pinskia at gcc dot gnu.org
@ 2020-11-16  7:19 ` rguenth at gcc dot gnu.org
  2021-09-02  5:38 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-11-16  7:19 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97831

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement
            Version|unknown                     |10.2.1

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c/97831] Lack of disable_tail_calls attribute
  2020-11-14 20:31 [Bug c/97831] New: Lack of disable_tail_calls attribute irogers at google dot com
                   ` (3 preceding siblings ...)
  2020-11-16  7:19 ` rguenth at gcc dot gnu.org
@ 2021-09-02  5:38 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-09-02  5:38 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97831

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
In the case of glibc, the callee needs to be marked as not a tail callable and
not the caller.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-09-02  5:38 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-14 20:31 [Bug c/97831] New: Lack of disable_tail_calls attribute irogers at google dot com
2020-11-14 20:47 ` [Bug c/97831] " pinskia at gcc dot gnu.org
2020-11-14 20:56 ` pinskia at gcc dot gnu.org
2020-11-14 20:57 ` pinskia at gcc dot gnu.org
2020-11-16  7:19 ` rguenth at gcc dot gnu.org
2021-09-02  5:38 ` pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).