public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "lukas.graetz@tu-darmstadt.de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug ipa/111643] __attribute__((flatten)) with -O1 runs out of memory (killed cc1)
Date: Fri, 06 Oct 2023 16:34:15 +0000	[thread overview]
Message-ID: <bug-111643-4-iPuLdKkzNU@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-111643-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #9 from Lukas Grätz <lukas.graetz@tu-darmstadt.de> ---
Thanks for everything, it seemed to be a misunderstanding from my side anyway
and the documentation fix should help others.

I am sorry for being silent, I was sick for a few days. As for my original
problem, I am thinking of opening a new report, because I realized there could
be another solution without flatten. To explain a bit more, we have
bar_original() and bar_new(), the latter should behave identical to the former
except one additional statement, the "instrumentation". Since the
instrumentation can be done in two assembler instructions only, the overhead of
bar_new() calling bar_original() is not negligible.

int bar_original (int x) { /* CODE */ }

unsigned int trace_buffer[512];
uint8_t trace_pos;

#define FUNCTION_NUMBER_bar     0x686
int bar_new (int x) {
    trace_buffer[trace_pos++] = 0x686; // instrumentation
    return bar_original(x);
}

My idea: Do not touch the stack inside bar_new() and replace the call in
bar_new() with a jump or better a fall-through to bar_original(). This is
possible, because both functions have the same signature. It could save around
4 instructions and some stack memory. I have a lot of such functions after my
instrumentation step.

I also wondered whether

int bar_alias (void) { return bar_original(); }

could be a portable alternative to attribute alias. Except that current GCC
does not translate it that way.

  parent reply	other threads:[~2023-10-06 16:34 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-29 19:49 [Bug c/111643] New: " lukas.graetz@tu-darmstadt.de
2023-09-29 19:52 ` [Bug ipa/111643] " pinskia at gcc dot gnu.org
2023-09-29 20:39 ` glisse at gcc dot gnu.org
2023-09-30  6:19 ` lukas.graetz@tu-darmstadt.de
2023-10-01  0:53 ` lukas.graetz@tu-darmstadt.de
2023-10-01  1:13 ` pinskia at gcc dot gnu.org
2023-10-04  9:21 ` rguenth at gcc dot gnu.org
2023-10-05  8:26 ` cvs-commit at gcc dot gnu.org
2023-10-05  9:02 ` rguenth at gcc dot gnu.org
2023-10-06 16:34 ` lukas.graetz@tu-darmstadt.de [this message]
2023-10-06 16:45 ` amonakov at gcc dot gnu.org
2023-10-06 21:31 ` lukas.graetz@tu-darmstadt.de
2023-10-06 21:37 ` pinskia at gcc dot gnu.org
2023-10-06 21:40 ` pinskia at gcc dot gnu.org
2023-10-06 22:03 ` lukas.graetz@tu-darmstadt.de

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-111643-4-iPuLdKkzNU@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).