From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E37703846410; Thu, 25 Apr 2024 07:45:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E37703846410 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1714031118; bh=NZmSGY8oOC3O3e8fqPZFhfO6BbUSS/fkeFJeqcEJb60=; h=From:To:Subject:Date:From; b=P7LDK83mqMbhqKHI7FihrPVbvEQ31nyVXsl7X07aN4g5EaubywdTgClUunAHVkXMu Ap7rPKYsTB9cOZ49/MuTSwbVbGsf61cUeq70iNBavSaVhOOrvnMIaay1XjhzsbhK3A tk3QjAHDZIGeW/9V9QSurhLediF9WJDoyo/oV+ao= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/114848] New: longarch: epilogue in _Unwind_RaiseException corrupts return value due to __builtin_eh_return Date: Thu, 25 Apr 2024 07:45:18 +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: 14.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia at gcc dot gnu.org 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 keywords bug_severity priority component assigned_to reporter target_milestone cf_gcctarget 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=3D114848 Bug ID: 114848 Summary: longarch: epilogue in _Unwind_RaiseException corrupts return value due to __builtin_eh_return Product: gcc Version: 14.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: pinskia at gcc dot gnu.org Target Milestone: --- Target: longarch64-linux-gnu I reduced an miscompile for aarch64 inside _Unwind_RaiseException and I not= iced the same issue can be reproduced on powerpc64-linux-gnu and powerpc-linux-g= nu. Reduced testcase: ``` __attribute__((noipa,noinline)) int f(int *a, long offset, void *handler) { if (*a =3D=3D 5) return 5; __builtin_eh_return (offset, handler); } int main() { int t =3D 5; if (f(&t, 0, 0) !=3D 5) __builtin_abort(); } ``` This produces a load (of r4) in the epilogue part for the `return 5` path (which is reduced from the end of stack path inside _Unwind_RaiseException). ``` bne $r13,$r12,.L2 addi.w $r4,$r0,5 # 0x5 or $r8,$r0,$r0 .L4: ld.d $r1,$r3,40 .cfi_remember_state .cfi_restore 1 ld.d $r5,$r3,24 .cfi_restore 5 ld.d $r4,$r3,32 .cfi_restore 4 ld.d $r6,$r3,16 .cfi_restore 6 ld.d $r7,$r3,8 .cfi_restore 7 addi.d $r3,$r3,48 .cfi_def_cfa_offset 0 add.d $r3,$r3,$r8 jr $r1 ```=