From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 784603858D20; Mon, 22 Jan 2024 23:12:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 784603858D20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1705965132; bh=0EVBkm2boVLrj0VABJY9fjl8brwnyZZu9GhJF7L9aII=; h=From:To:Subject:Date:From; b=aV5jyujH/hoazRKnv+xka9nBp4llFzLPSSbFHouHucR9ResED7OdIo093ACbMZ4Nw n9wA0euq36da7F5709ZDFi6wV4+APMH3d1HOHpNhaJepKnemcK0kMsB+5BYJh8PIsI VT72vlPQDTJ7rN8Y+tBY2tEETN5tXXG3c8Z79uds= From: "ianthompson at microsoft dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/113550] New: data512_t initializers dereference a clobbered register Date: Mon, 22 Jan 2024 23:12:11 +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.2.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: ianthompson at microsoft dot com 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 cf_gcctarget 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D113550 Bug ID: 113550 Summary: data512_t initializers dereference a clobbered register Product: gcc Version: 12.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: ianthompson at microsoft dot com Target Milestone: --- Target: aarch64 Created attachment 57189 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D57189&action=3Dedit Additional non-minimal failing cases When initializing or copying a data512_t, the compiler is generating code w= hich clobbers the register containing the source pointer of the copy. Initially observed on Arm GNU Toolchain 12.2.Rel1, but this also reproduces on trunk. Minimal reproduction, hits a segfault when compiled with "aarch64-none-elf-= gcc -march=3Darmv9-a+ls64": #include void test_data512_init() { data512_t my_value =3D {}; } This code generates this assembly snippet for initializing my_value: adrp x0, .LC0 add x0, x0, :lo12:.LC0 ldp x0, x1, [x0] ldp x2, x3, [x0, 16] ldp x4, x5, [x0, 32] ldp x6, x7, [x0, 48] Notice that the first ldp clobbers x0, redirecting the remaining 3 loads to whatever address happens to be in val[0] of the initializer. Similar incorrect code is generated in many other situations that involve copying a data512_t (passing a global variable to a function, dereferencing= a data512_t*, etc). See the attached source file for the other failing cases = I'm seeing.=