public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: visitor x <visitor20212@outlook.com>
To: "gcc-help@gcc.gnu.org" <gcc-help@gcc.gnu.org>
Subject: When will gcc assign local variables to registers?
Date: Tue, 10 Nov 2020 11:27:51 +0000	[thread overview]
Message-ID: <SL2PR02MB35968C6DE34B614513F5E57C83E90@SL2PR02MB3596.apcprd02.prod.outlook.com> (raw)

Hello,

I'm trying to distinguish local variable assigned to register from a binary.

I got that compilers will assign some local variable to registers rather than stack for performance reason, while which variable depends on the compiler. I also found there is a calling convention on x64 that the first six arguments are passed to register (when the class is INTEGER).

However, I got almost nothing about the rest of the case. I am aware that compilers are free to arrange variables in both stack and registers, but what pricinple or specification will they follow?

Is there any materials about gcc's behavior on deciding which variables should be kept in registers? Or any other hint to find variables stored in register from a bianry?

visitor20

             reply	other threads:[~2020-11-10 11:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-10 11:27 visitor x [this message]
2020-11-10 15:24 ` Andrew Haley
     [not found] <SL2PR02MB3596DBDC06124B066570F3D383E80@SL2PR02MB3596.apcprd02.prod.outlook.com>
2020-11-12  5:04 ` visitor x
2020-11-12  6:54   ` Henri Cloetens
2020-11-12 11:43     ` x visitor

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=SL2PR02MB35968C6DE34B614513F5E57C83E90@SL2PR02MB3596.apcprd02.prod.outlook.com \
    --to=visitor20212@outlook.com \
    --cc=gcc-help@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).