public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c/115589] New: (aarch64) clobbered register variables @ 2024-06-22 12:50 pietro.braione at gmail dot com 2024-06-22 14:11 ` [Bug target/115589] " pinskia at gcc dot gnu.org ` (3 more replies) 0 siblings, 4 replies; 5+ messages in thread From: pietro.braione at gmail dot com @ 2024-06-22 12:50 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115589 Bug ID: 115589 Summary: (aarch64) clobbered register variables Product: gcc Version: 11.4.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: pietro.braione at gmail dot com Target Milestone: --- /* * compiled with gcc -O0, on my platform (Ubuntu 22.04 aarch64) prints: * * 4 * 2 * * This is a very simplified example. In my production code I have * variables that are assigned register x21-x23, and gcc generates * code that uses these registers as temporaries without saving * elsewhere the content of the variables, that are lost. */ #include <stdio.h> int a = 1, b = 1, c = 1, d = 1; void main() { register int x asm("x0"); x = 0; printf("%d\n", a + b + c + d); printf("%d\n", x); } ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug target/115589] (aarch64) clobbered register variables 2024-06-22 12:50 [Bug c/115589] New: (aarch64) clobbered register variables pietro.braione at gmail dot com @ 2024-06-22 14:11 ` pinskia at gcc dot gnu.org 2024-06-22 14:14 ` pinskia at gcc dot gnu.org ` (2 subsequent siblings) 3 siblings, 0 replies; 5+ messages in thread From: pinskia at gcc dot gnu.org @ 2024-06-22 14:11 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115589 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |inline-asm --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- variables that are assigned register x21-x23, and gcc generates * code that uses these registers as temporaries without saving Iirc this is not the use of local register variables. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug target/115589] (aarch64) clobbered register variables 2024-06-22 12:50 [Bug c/115589] New: (aarch64) clobbered register variables pietro.braione at gmail dot com 2024-06-22 14:11 ` [Bug target/115589] " pinskia at gcc dot gnu.org @ 2024-06-22 14:14 ` pinskia at gcc dot gnu.org 2024-06-22 14:15 ` pinskia at gcc dot gnu.org 2024-06-22 15:26 ` pietro.braione at gmail dot com 3 siblings, 0 replies; 5+ messages in thread From: pinskia at gcc dot gnu.org @ 2024-06-22 14:14 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115589 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |INVALID Status|UNCONFIRMED |RESOLVED --- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> --- https://gcc.gnu.org/onlinedocs/gcc-14.1.0/gcc/Local-Register-Variables.html The only supported use for this feature is to specify registers for input and output operands when calling Extended asm ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug target/115589] (aarch64) clobbered register variables 2024-06-22 12:50 [Bug c/115589] New: (aarch64) clobbered register variables pietro.braione at gmail dot com 2024-06-22 14:11 ` [Bug target/115589] " pinskia at gcc dot gnu.org 2024-06-22 14:14 ` pinskia at gcc dot gnu.org @ 2024-06-22 14:15 ` pinskia at gcc dot gnu.org 2024-06-22 15:26 ` pietro.braione at gmail dot com 3 siblings, 0 replies; 5+ messages in thread From: pinskia at gcc dot gnu.org @ 2024-06-22 14:15 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115589 --- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Some developers use Local Register Variables in an attempt to improve gcc’s allocation of registers, especially in large functions. In this case the register name is essentially a hint to the register allocator. While in some instances this can generate better code, improvements are subject to the whims of the allocator/optimizers. Since there are no guarantees that your improvements won’t be lost, this usage of Local Register Variables is discouraged. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug target/115589] (aarch64) clobbered register variables 2024-06-22 12:50 [Bug c/115589] New: (aarch64) clobbered register variables pietro.braione at gmail dot com ` (2 preceding siblings ...) 2024-06-22 14:15 ` pinskia at gcc dot gnu.org @ 2024-06-22 15:26 ` pietro.braione at gmail dot com 3 siblings, 0 replies; 5+ messages in thread From: pietro.braione at gmail dot com @ 2024-06-22 15:26 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115589 --- Comment #4 from Pietro Braione <pietro.braione at gmail dot com> --- I see. Sorry for the noise. ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-06-22 15:26 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2024-06-22 12:50 [Bug c/115589] New: (aarch64) clobbered register variables pietro.braione at gmail dot com 2024-06-22 14:11 ` [Bug target/115589] " pinskia at gcc dot gnu.org 2024-06-22 14:14 ` pinskia at gcc dot gnu.org 2024-06-22 14:15 ` pinskia at gcc dot gnu.org 2024-06-22 15:26 ` pietro.braione at gmail dot com
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).