From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 5C7A1385840F; Fri, 24 Feb 2023 08:52:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5C7A1385840F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1677228729; bh=PaAeLsEennrVDFNhM/ANTqLco29/u7+a5Gye96OkNuk=; h=From:To:Subject:Date:From; b=TOT3RwR/ZGu7g3poJd0oNiQyTbrMCys7ftVNtptPB8l9bMD4G2j9+oQkhVVM1V0hy ntAS0xFnSRd00peq0WWvut4e6oGxR5y3+wE8AoE8BK5CWYu0QyhQZGsifCB99En3gk ZNoB/SNTFRx6wEy8smdQAoYGEOBhocV8VgZdRZrU= From: "jcmvbkbc at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/108919] New: pure nested function may clobber its static chain pointer in windowed ABI on xtensa Date: Fri, 24 Feb 2023 08:52:09 +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: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: jcmvbkbc 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 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D108919 Bug ID: 108919 Summary: pure nested function may clobber its static chain pointer in windowed ABI on xtensa Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: jcmvbkbc at gcc dot gnu.org Target Milestone: --- Created attachment 54525 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D54525&action=3Dedit test.c The following gfortran tests fail on windowed ABI xtensa target, but pass on call0 ABI: gfortran.dg/character_workout_1.f90 -O[123s] execution test gfortran.dg/character_workout_4.f90 -O[123s] execution test E.g. gfortran.dg/character_workout_1.f90 -O1 ends with the message 'STOP 20= 9'. This happens because in these tests pure nested functions are generated for subroutines achar_cm and achar_am and the fwprop1 pass removes static chain pointer initialization between the calls to these functions: .L143:=20=20 addi a3, sp, 108 movi a4, 0xd4 add.n a4, sp, a4 addi a8, sp, -20 s32i.n a4, a8, 0 movi.n a11, 7 mov.n a10, a3 call8 achar_cm.21 movi.n a11, 7 mov.n a10, a3 call8 achar_am.15 Windowed ABI for xtensa specifies that the static chain is passed on the st= ack, at offset -20 from the called function's CFA, i.e. outside the caller's sta= ck frame. This location may be overwritten if the called function makes functi= on calls that exceed certain depth. The issue may be reproduced with the attached small test case.=