From patchwork Fri May 13 15:13:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Senthil Kumar Selvaraj X-Patchwork-Id: 622058 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3r5tg52WjRz9t6s for ; Sat, 14 May 2016 01:14:08 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=nCuedIu6; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:mime-version:content-type; q=dns; s=default; b=FvvW2uhXuXHc1NEEDo8DShuwifC/pjDkIGe2oyPWqDr9+go6pV 8EnUg4qju5layoShfDpBb262emowLQOBv17i62WJjkx1YCjc7NKztYA0yBRntGzq xoIn+CozfNi9hJgn7U037+kjPIO7s2+7y8IzNltrMjdpvOPYPhWR32VxU= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:mime-version:content-type; s= default; bh=ToV1SkqsYktVXrFw4CFx1A+OViA=; b=nCuedIu6rr07RwdzZBpB 0bOb+0goTHgzey2LpVlu9NElLPKX1Abqc9hwaTMyqYjwj93/SBU25tF/XQeAODS1 e+4mqOeU3VCWF+iOvUt5XJ/waKXHy5sl1czNBVLD1U50627iqvOKYu0TOn6zSbBl vOsj4xEapStjeZPE4+1iIkM= Received: (qmail 104659 invoked by alias); 13 May 2016 15:14:01 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 104648 invoked by uid 89); 13 May 2016 15:14:00 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.3 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: eusmtp01.atmel.com Received: from eusmtp01.atmel.com (HELO eusmtp01.atmel.com) (212.144.249.242) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Fri, 13 May 2016 15:13:50 +0000 Received: from HNOCHT02.corp.atmel.com (10.161.30.162) by eusmtp01.atmel.com (10.161.101.30) with Microsoft SMTP Server (TLS) id 14.3.235.1; Fri, 13 May 2016 17:13:38 +0200 Received: from jaguar.atmel.com (10.161.30.18) by HNOCHT02.corp.atmel.com (10.161.30.162) with Microsoft SMTP Server (TLS) id 14.3.235.1; Fri, 13 May 2016 17:13:43 +0200 User-agent: mu4e 0.9.17; emacs 24.5.1 From: Senthil Kumar Selvaraj To: , Denis Chertykov , "Eric Botcazou" CC: Sebastian Huber Subject: [Patch, avr] Include INCOMING_FRAME_SP_OFFSET when printing stack usage Date: Fri, 13 May 2016 20:43:46 +0530 Message-ID: <87posq2dp1.fsf@atmel.com> MIME-Version: 1.0 X-IsSubscribed: yes Hi, This trivial patch adds INCOMING_FRAME_SP_OFFSET to current_function_static_stack_size, thus fixing the 2 (or 3, for 3 byte PC devices) byte difference between reported and actual values when using -fstack-usage. The patch came about because of this discussion (https://gcc.gnu.org/ml/gcc/2016-05/msg00107.html). For AVRs, the return address gets pushed into the stack as part of the call instruction, and the number of bytes pushed varies by PC width. This is already taken care of when defining INCOMING_FRAME_SP_OFFSET, so I just add it to the previously computed value when setting current_function_static_stack_size. If this is ok, could someone commit please? I don't have commit access. Regards Senthil gcc/ChangeLog 2016-05-13 Senthil Kumar Selvaraj * config/avr/avr.c (avr_expand_prologue): Add INCOMING_FRAME_SP_OFFSET to computed stack_usage. diff --git gcc/config/avr/avr.c gcc/config/avr/avr.c index 8de39e0..ba5cd91 100644 --- gcc/config/avr/avr.c +++ gcc/config/avr/avr.c @@ -1484,7 +1484,7 @@ avr_expand_prologue (void) avr_prologue_setup_frame (size, set); if (flag_stack_usage_info) - current_function_static_stack_size = cfun->machine->stack_usage; + current_function_static_stack_size = cfun->machine->stack_usage + INCOMING_FRAME_SP_OFFSET; }