From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 56056385781D; Mon, 5 Jul 2021 15:32:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 56056385781D From: "tuliom at ascii dot art.br" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/101324] New: powerpc64le: hashst appears before mflr at -O1 or higher Date: Mon, 05 Jul 2021 15:32:31 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: tuliom at ascii dot art.br X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Jul 2021 15:32:33 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D101324 Bug ID: 101324 Summary: powerpc64le: hashst appears before mflr at -O1 or higher Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: tuliom at ascii dot art.br Target Milestone: --- Created attachment 51105 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D51105&action=3Dedit __memmove_ppc extracted from glibc When using ROP (-mrop-protect), it's expected that generated code reads the value from LR (mflr) and hash it later (hashst). This works well at -O0. However, at -O1 and higher, we're seeing cases where hashst appears before mflr. I'm attaching an example extracted from glibc. You can reproduce the issue with command: gcc -S -O1 -mrop-protect -mcpu=3Dpower10 memmove-ppc64.i -o - The generated asm contains the following: __memmove_ppc: .LFB6: .cfi_startproc .localentry __memmove_ppc,1 hashst 0,-40(1) std 28,-32(1) stdu 1,-80(1) .cfi_def_cfa_offset 80 .cfi_offset 28, -32 mr 28,3 subf 9,4,3 cmpld 0,9,5 bge 0,.L17 std 31,72(1) .cfi_offset 31, -8 add 4,4,5 add 31,3,5 cmpldi 0,5,15 ble 0,.L4 mflr 0 ...=