public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "linkw at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug target/108315] -mcpu=power10 changes ABI Date: Tue, 28 Feb 2023 05:07:59 +0000 [thread overview] Message-ID: <bug-108315-4-stFRCgtdE0@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-108315-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108315 Kewen Lin <linkw at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |linkw at gcc dot gnu.org --- Comment #2 from Kewen Lin <linkw at gcc dot gnu.org> --- (In reply to Alexander Monakov from comment #0) > Created attachment 54202 [details] > testcase > > At least the documentation should mention that if intentional. > > In the attached example, the function bar is compiled to > > bar: > .localentry bar,1 > mtctr 3 > mr 12,3 > bctr > .long 0 > .byte 0,0,0,0,0,0,0,0 > > i.e. it does not preserve r2 (it's compiled with -mcpu=power10). If the > caller is not compiled with -mcpu=power10, it needs r2 preserved (bar has a > localentry, so the nop in the caller stays a nop after linking). My local 64bit-elfv2-abi spec v1.5 has the following description: 3.4.1. Symbol Values "The values of these three most significant bits of the st_other field have the following meanings: ... 1 The local and global entry points are the same, and r2 should be treated as caller-saved for local and global callers. " ... "The value of st_other is determined from the .localentry directive as follows: If the .localentry value is 0, the value of st_other is 0. If the .localentry value is 1, the value of st_other is 1. Otherwise, the value of st_other is the logarithm (base 2) of the .localentry value." The function bar is with st_other value 1, r2 should be treated as caller-saved, so it doesn't take action to preserve r2. > > I verified the testcase misbehaves on Compile Farm's gcc135: as it does not > use any power10-specific instructions, it's runnable there. I tried the attachment on one local machine (also ppc64le p9) and noticed the linker already did some fix-ups with long_branch.bar stub, Dump of assembler code for function main: 0x0000000010000540 <+0>: lis r2,4098 0x0000000010000544 <+4>: addi r2,r2,32512 0x0000000010000548 <+8>: mflr r0 0x000000001000054c <+12>: nop 0x0000000010000550 <+16>: ld r3,-32728(r2) 0x0000000010000554 <+20>: std r0,16(r1) 0x0000000010000558 <+24>: stdu r1,-32(r1) 0x000000001000055c <+28>: bl 0x10000510 <00000038.long_branch.bar> => 0x0000000010000560 <+32>: ld r2,24(r1) 0x0000000010000564 <+36>: addis r3,r2,-2 0x0000000010000568 <+40>: addi r3,r3,-30328 Dump of assembler code for function 00000038.long_branch.bar: => 0x0000000010000510 <+0>: std r2,24(r1) 0x0000000010000514 <+4>: b 0x10000710 <bar> which would save r2 onto the corresponding stack slot ahead, it runs well as expected. Not sure why it doesn't work on your side, maybe this inter-operation requires some support in newer binutils? My local one is GNU ld 2.34 which is for final linking (and 2.35 for power10 support, ie. bar.o generation).
next prev parent reply other threads:[~2023-02-28 5:08 UTC|newest] Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-01-06 11:23 [Bug target/108315] New: " amonakov at gcc dot gnu.org 2023-02-28 2:57 ` [Bug target/108315] " bergner at gcc dot gnu.org 2023-02-28 5:07 ` linkw at gcc dot gnu.org [this message] 2023-02-28 6:15 ` amonakov at gcc dot gnu.org 2023-02-28 6:31 ` amonakov at gcc dot gnu.org 2023-02-28 8:05 ` amodra at gmail dot com 2023-02-28 15:33 ` marxin at gcc dot gnu.org 2023-02-28 16:01 ` segher at gcc dot gnu.org 2023-02-28 16:26 ` segher at gcc dot gnu.org 2023-03-01 1:24 ` rui314 at gmail dot com 2023-03-02 16:53 ` amonakov at gcc dot gnu.org 2023-03-03 1:06 ` rui314 at gmail dot com 2023-03-03 1:54 ` dje at gcc dot gnu.org 2023-03-03 17:30 ` segher at gcc dot gnu.org 2023-03-03 18:16 ` amonakov at gcc dot gnu.org 2023-03-03 19:31 ` segher at gcc dot gnu.org 2023-03-03 20:09 ` amonakov at gcc dot gnu.org 2023-03-03 21:45 ` segher at gcc dot gnu.org 2023-03-06 20:20 ` amonakov at gcc dot gnu.org 2023-10-12 4:09 ` bergner at gcc dot gnu.org 2023-10-12 4:34 ` rui314 at gmail dot com 2023-10-13 1:23 ` rui314 at gmail dot com
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-108315-4-stFRCgtdE0@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: linkBe 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).