From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id ABD5E3858D32; Mon, 17 Oct 2022 09:42:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ABD5E3858D32 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1665999733; bh=tQekDz4BdItceeXlhgWPO/B61702q4GMuwefVd4T9Tg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=m6wVjcnuNsRePaE/BwgH9fxQgIFegHdsKGPUUTamt3tkISkUU8XFJktaU2Zw7ufH9 nWIOeZzCYng9pRzwtLk27bKNYFjpfBZyZm7FE4/gZwVxTRPZD44Ocs1QHS54SnC0/m PnFKiO52gjmqAHGhsEUaPdHLKCwGx/dMEHRY9ZZY= From: "jskumari at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/100799] Stackoverflow in optimized code on PPC Date: Mon, 17 Oct 2022 09:42:10 +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.3.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: jskumari at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: jskumari at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D100799 --- Comment #18 from Surya Kumari Jangala --- I git cloned and built flexiblas to see what is the frame size and what is = the assembly code generated for the flexiblas C wrapper routine for dgebal. The important assembly code snippets for dgebal.c : // r23-r31 are saved in the callee frame std r23,-72(r1) std r24,-64(r1) ... ... std r31,-8(r1) // allocate the stack frame stdu r1,-112(r1) // save the parameter registers r3-r10 into r23-r30 mr r30,r3 ... mr r23,r10 // some of the param regs are used as temps ld r3,0(r31) lwz r11,16(r3) // populate the param registers appropriately mr r3,r30 ... mr r10,r23 // make the call to the fortran dgebal routine bctrl // restore r1 addi r1,r1,112 // restore r23-r31 ld r23,-72(r1) ... ld r31,-8(r1) // return blr As we can see, the frame size allocated is only 112 out of which 32 is for things like LR, TOC etc. and 72 is needed to save r23-r31. So clearly, the wrapper routine is not allocating any parameter save area in it's frame. Now, the dgebal fortran routine writes into the caller's frame thereby corrupting a callee save register (one of r23-r31). So when control returns back from the wrapper routine to the fortran routine dgeev, we see a corrup= ted value.=