From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B6550388C00C; Wed, 3 Jun 2020 16:37:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B6550388C00C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1591202269; bh=TxJzuB8yeo1J+qE0UsU9bYcssD5kMrEAtlCbWO0Nx/4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=JkJOWnI0w6TEd1LKQ/Ce9osAtg+b46TXEXxM6wHK4j1eHFUAH7sUl4O9ygamql517 sw1NFQpTk2hWnbkQE/q6xq6je8+O9AdQRfRoLx5y6QSPmt+hYOeIVPCpH6ViDY7hHQ CRBT6GlFwxezwwSRppAuxkERHTv2pznYmWjK6wkA= From: "wilco at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/94986] missing diagnostic on ARM thumb2 compilation with -pg when using r7 in inline asm Date: Wed, 03 Jun 2020 16:37:49 +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: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: wilco 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: cc 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: Wed, 03 Jun 2020 16:37:49 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94986 Wilco changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |wilco at gcc dot gnu.org --- Comment #1 from Wilco --- (In reply to Arnd Bergmann from comment #0) > I reported a bug against clang for a Linux kernel failure, but=20 > it was suggested that the clang behavior is probably correct in this cor= ner > case while gcc gets it wrong, see https://bugs.llvm.org/show_bug.cgi?id= =3D45826 >=20 > echo 'void f(void) { asm("mov r7, #0" ::: "r7"); }' | arm-linux-gnueabi-g= cc > -march=3Darmv7-a -O2 -mthumb -pg -S -xc - >=20 > silently accepts an inline asm statement that clobbers the frame pointer, > but gcc rejects the same code if any of '-O0', '-fomit-frame-pointer' or > 'fno-omit-frame-pointer' are used: >=20 > : In function 'f': > :1:44: error: r7 cannot be used in 'asm' here >=20 > If using r7 in this case is indeed invalid, we need to ensure the kernel > does not do this, and having gcc reject it would be helpful. GCC will reject it if you explicitly enable the frame pointer. The logic se= ems wrong in that it doesn't report an error if the frame pointer is implicitly enabled via -pg. As a workaround for the kernel, just use -pg and -fno-omit-frame-pointer together. Corrupting a frame pointer loses the ability to follow the frame chain, sim= ilar to a function built with -fomit-frame-pointer which will use r7 as a general purpose register. However this always reports an error since this corruption of the frame poi= nter will cause a crash: int *f(int x) { asm("mov r7, #0" ::: "r7"); return __builtin_alloca (x); }=