From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 3B36C385DC26; Thu, 9 Apr 2020 15:29:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3B36C385DC26 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1586446158; bh=RnAUsH8S0SfoQAtuUMAdiwNx1P97TZl4uHoN01mA8/A=; h=From:To:Subject:Date:In-Reply-To:References:From; b=yG5r9t1DUDiSrYgqFFFl8lvvh6d8IhbRqkzCdvvhpsrdhgcN7gtiv/IrcMwCqycbT xU3Jl1jUoZKyYkA179zA+Ijw46e5Aw/CxuQDCZTUm/3UKaSZZCxckG+UPNdZzXGht6 J/JuwdksxG0/xi3+hdVObiW8jE0m9hcSrXOcLN7o= From: "hjl.tools at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/94541] [8/9/10 Regression] -mx32 gcc produces wrong code passing structs by value Date: Thu, 09 Apr 2020 15:29:18 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 10.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: hjl.tools at gmail dot com X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: hjl.tools at gmail dot com X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: assigned_to cf_reconfirmed_on bug_status cf_known_to_work short_desc everconfirmed Message-ID: In-Reply-To: References: 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: Thu, 09 Apr 2020 15:29:18 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94541 H.J. Lu changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|unassigned at gcc dot gnu.org |hjl.tools at gmail = dot com Last reconfirmed| |2020-04-09 Status|UNCONFIRMED |ASSIGNED Known to work| |4.9.3 Summary|-mx32 gcc produces wrong |[8/9/10 Regression] -mx32 |code passing structs by |gcc produces wrong code |value |passing structs by value Ever confirmed|0 |1 --- Comment #3 from H.J. Lu --- [hjl@gnu-cfl-2 tmp]$ cat bar.c typedef unsigned int size_t; struct Array { size_t length; void *ptr; }; extern int munmap (void *__addr, size_t __len); int deallocate(struct Array b) { int result =3D 0; if (b.length) result =3D munmap(b.ptr, b.length); return result; } [hjl@gnu-cfl-2 tmp]$ gcc -S -O bar.c -mx32=20 [hjl@gnu-cfl-2 tmp]$ cat bar.s .file "bar.c" .text .globl deallocate .type deallocate, @function deallocate: .LFB0: .cfi_startproc movl $0, %eax testl %edi, %edi jne .L8 ret .L8: subl $8, %esp .cfi_def_cfa_offset 16 movq %rdi, %rsi <<<<<< It should be movl %edi, %esi shrq $32, %rdi call munmap addl $8, %esp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE0: .size deallocate, .-deallocate .ident "GCC: (GNU) 9.3.1 20200408 (Red Hat 9.3.1-2)" .section .note.GNU-stack,"",@progbits [hjl@gnu-cfl-2 tmp]$=20 GCC 4.9.3 works.=