From patchwork Thu Oct 15 05:44:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kugan Vivekanandarajah X-Patchwork-Id: 54981 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by patches.linaro.org (Postfix) with ESMTPS id C49F623012 for ; Thu, 15 Oct 2015 05:45:35 +0000 (UTC) Received: by wibzt1 with SMTP id zt1sf4551630wib.0 for ; Wed, 14 Oct 2015 22:45:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:mailing-list:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:sender :delivered-to:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-type:x-original-sender :x-original-authentication-results; bh=qCevwoJJD2SpsrtBd7guIT+LTrNqTGwQeJMtr70W/cA=; b=T/U+4qlqUTA/eiwVc4NAxLIdlWcqaIGPFV1V9s+EXssXoxHMehIg1fg89gDLir/q2N Mk3gmQDF4XYhU+QKA7ycyoZm37IMBQjbFfx23agvTKJTmOJqkD8qL0LERc74FjezEN9B dyUPZ2VV6mQwGBe1A4+sZ3DRPNvgv+m8yOwguuVBLE4vi5+qvyqKdaoA2gP1JLq/yQjE iiSiNP9Rw2RNeTyEzopWtaUlLF7PBcEOBQ4AHUJy0zvGElEq9RQcnM7rVlkh1W4x+9ww 7C1fF77MKQnJJvJP1osg5ouPYDv3iWijX5x0Ty5Z8a9+dw4JBQ2gvrlGhaaoLKvM9kcZ Z9xA== X-Gm-Message-State: ALoCoQll4DNHiDnzDreGENTJ74rXBk/dFZ0iayEywLUiwVGvTj8tsiDSLR7mChkkZFpZsBckvi5I X-Received: by 10.194.109.233 with SMTP id hv9mr1641119wjb.1.1444887935094; Wed, 14 Oct 2015 22:45:35 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.80.140 with SMTP id e134ls128721lfb.42.gmail; Wed, 14 Oct 2015 22:45:34 -0700 (PDT) X-Received: by 10.25.87.9 with SMTP id l9mr1755692lfb.99.1444887934938; Wed, 14 Oct 2015 22:45:34 -0700 (PDT) Received: from mail-lf0-x22a.google.com (mail-lf0-x22a.google.com. [2a00:1450:4010:c07::22a]) by mx.google.com with ESMTPS id r195si8002534lfg.159.2015.10.14.22.45.34 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Oct 2015 22:45:34 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c07::22a as permitted sender) client-ip=2a00:1450:4010:c07::22a; Received: by lffy185 with SMTP id y185so22436412lff.2 for ; Wed, 14 Oct 2015 22:45:34 -0700 (PDT) X-Received: by 10.25.150.199 with SMTP id y190mr2305487lfd.35.1444887934764; Wed, 14 Oct 2015 22:45:34 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp407063lbq; Wed, 14 Oct 2015 22:45:33 -0700 (PDT) X-Received: by 10.50.118.42 with SMTP id kj10mr28404750igb.71.1444887933183; Wed, 14 Oct 2015 22:45:33 -0700 (PDT) Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id z197si10232997iod.26.2015.10.14.22.45.32 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Oct 2015 22:45:33 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-410212-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Received: (qmail 100948 invoked by alias); 15 Oct 2015 05:45:17 -0000 Mailing-List: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org Precedence: list 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 100521 invoked by uid 89); 15 Oct 2015 05:45:09 -0000 X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pa0-f50.google.com Received: from mail-pa0-f50.google.com (HELO mail-pa0-f50.google.com) (209.85.220.50) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Thu, 15 Oct 2015 05:45:07 +0000 Received: by pacao1 with SMTP id ao1so12017460pac.2 for ; Wed, 14 Oct 2015 22:45:05 -0700 (PDT) X-Received: by 10.66.146.4 with SMTP id sy4mr7947723pab.79.1444887905584; Wed, 14 Oct 2015 22:45:05 -0700 (PDT) Received: from [10.1.1.5] (58-6-183-210.dyn.iinet.net.au. [58.6.183.210]) by smtp.googlemail.com with ESMTPSA id ci2sm12858506pbc.66.2015.10.14.22.45.02 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Oct 2015 22:45:04 -0700 (PDT) Subject: Re: [5/7] Allow gimple debug stmt in widen mode To: Richard Biener References: <55ECFC2A.7050908@linaro.org> <55ECFE08.8060405@linaro.org> <55EE2523.6000209@linaro.org> Cc: Michael Matz , "gcc-patches@gcc.gnu.org" From: Kugan Message-ID: <561F3D5B.4060709@linaro.org> Date: Thu, 15 Oct 2015 16:44:59 +1100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: X-IsSubscribed: yes X-Original-Sender: kugan.vivekanandarajah@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c07::22a as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=pass header.i=@gcc.gnu.org X-Google-Group-Id: 836684582541 On 15/09/15 22:57, Richard Biener wrote: > On Tue, Sep 8, 2015 at 2:00 AM, Kugan wrote: >> >> Thanks for the review. >> >> On 07/09/15 23:20, Michael Matz wrote: >>> Hi, >>> >>> On Mon, 7 Sep 2015, Kugan wrote: >>> >>>> Allow GIMPLE_DEBUG with values in promoted register. >>> >>> Patch does much more. >>> >> >> Oops sorry. Copy and paste mistake. >> >> gcc/ChangeLog: >> >> 2015-09-07 Kugan Vivekanandarajah >> >> * cfgexpand.c (expand_debug_locations): Remove assert as now we are >> also allowing values in promoted register. >> * gimple-ssa-type-promote.c (fixup_uses): Allow GIMPLE_DEBUG to bind >> values in promoted register. >> * rtl.h (wi::int_traits ::decompose): Accept zero extended value >> also. >> >> >>>> gcc/ChangeLog: >>>> >>>> 2015-09-07 Kugan Vivekanandarajah >>>> >>>> * expr.c (expand_expr_real_1): Set proper SUNREG_PROMOTED_MODE for >>>> SSA_NAME that was set by GIMPLE_CALL and assigned to another >>>> SSA_NAME of same type. >>> >>> ChangeLog doesn't match patch, and patch contains dubious changes: >>> >>>> --- a/gcc/cfgexpand.c >>>> +++ b/gcc/cfgexpand.c >>>> @@ -5240,7 +5240,6 @@ expand_debug_locations (void) >>>> tree value = (tree)INSN_VAR_LOCATION_LOC (insn); >>>> rtx val; >>>> rtx_insn *prev_insn, *insn2; >>>> - machine_mode mode; >>>> >>>> if (value == NULL_TREE) >>>> val = NULL_RTX; >>>> @@ -5275,16 +5274,6 @@ expand_debug_locations (void) >>>> >>>> if (!val) >>>> val = gen_rtx_UNKNOWN_VAR_LOC (); >>>> - else >>>> - { >>>> - mode = GET_MODE (INSN_VAR_LOCATION (insn)); >>>> - >>>> - gcc_assert (mode == GET_MODE (val) >>>> - || (GET_MODE (val) == VOIDmode >>>> - && (CONST_SCALAR_INT_P (val) >>>> - || GET_CODE (val) == CONST_FIXED >>>> - || GET_CODE (val) == LABEL_REF))); >>>> - } >>>> >>>> INSN_VAR_LOCATION_LOC (insn) = val; >>>> prev_insn = PREV_INSN (insn); >>> >>> So it seems that the modes of the values location and the value itself >>> don't have to match anymore, which seems dubious when considering how a >>> debugger should load the value in question from the given location. So, >>> how is it supposed to work? >> >> For example (simplified test-case from creduce): >> >> fn1() { >> char a = fn1; >> return a; >> } >> >> --- test.c.142t.veclower21 2015-09-07 23:47:26.362201640 +0000 >> +++ test.c.143t.promotion 2015-09-07 23:47:26.362201640 +0000 >> @@ -5,13 +5,18 @@ >> { >> char a; >> long int fn1.0_1; >> + unsigned int _2; >> int _3; >> + unsigned int _5; >> + char _6; >> >> : >> fn1.0_1 = (long int) fn1; >> - a_2 = (char) fn1.0_1; >> - # DEBUG a => a_2 >> - _3 = (int) a_2; >> + _5 = (unsigned int) fn1.0_1; >> + _2 = _5 & 255; >> + # DEBUG a => _2 >> + _6 = (char) _2; >> + _3 = (int) _6; >> return _3; >> >> } >> >> Please see that DEBUG now points to _2 which is a promoted mode. I am >> assuming that the debugger would load required precision from promoted >> register. May be I am missing the details but how else we can handle >> this? Any suggestions? > > I would have expected the DEBUG insn to be adjusted as > > # DEBUG a => (char)_2 Thanks for the review. Please find the attached patch that attempts to do this. I have also tested a version of this patch with gdb testsuite. As Michael wanted, I have also removed the changes in rtl.h and promoting constants in GIMPLE_DEBUG. > Btw, why do we have > >> + _6 = (char) _2; >> + _3 = (int) _6; > > ? I'd have expected > > unsigned int _6 = SEXT <_2, 8> > _3 = (int) _6; > return _3; I am looking into it. > > see my other mail about promotion of PARM_DECLs and RESULT_DECLs -- we should > promote those as well. > Just to be sure, are you referring to https://gcc.gnu.org/ml/gcc-patches/2015-08/msg00244.html where you wanted an IPA pass to perform this. This is one of my dodo after this. Please let me know if you wanted here is a different issue. Thanks, Kuganb >From 7cbcca8ebd03f60e16a55da4af3fc573f98d4086 Mon Sep 17 00:00:00 2001 From: Kugan Vivekanandarajah Date: Tue, 1 Sep 2015 08:40:40 +1000 Subject: [PATCH 5/7] debug stmt in widen mode --- gcc/cfgexpand.c | 11 ------- gcc/gimple-ssa-type-promote.c | 77 +++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 74 insertions(+), 14 deletions(-) diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c index 357710b..be43f46 100644 --- a/gcc/cfgexpand.c +++ b/gcc/cfgexpand.c @@ -5234,7 +5234,6 @@ expand_debug_locations (void) tree value = (tree)INSN_VAR_LOCATION_LOC (insn); rtx val; rtx_insn *prev_insn, *insn2; - machine_mode mode; if (value == NULL_TREE) val = NULL_RTX; @@ -5269,16 +5268,6 @@ expand_debug_locations (void) if (!val) val = gen_rtx_UNKNOWN_VAR_LOC (); - else - { - mode = GET_MODE (INSN_VAR_LOCATION (insn)); - - gcc_assert (mode == GET_MODE (val) - || (GET_MODE (val) == VOIDmode - && (CONST_SCALAR_INT_P (val) - || GET_CODE (val) == CONST_FIXED - || GET_CODE (val) == LABEL_REF))); - } INSN_VAR_LOCATION_LOC (insn) = val; prev_insn = PREV_INSN (insn); diff --git a/gcc/gimple-ssa-type-promote.c b/gcc/gimple-ssa-type-promote.c index 513d20d..4034203 100644 --- a/gcc/gimple-ssa-type-promote.c +++ b/gcc/gimple-ssa-type-promote.c @@ -585,10 +585,81 @@ fixup_uses (tree use, tree promoted_type, tree old_type) { case GIMPLE_DEBUG: { - gsi = gsi_for_stmt (stmt); - gsi_remove (&gsi, true); - break; + tree op, new_op = NULL_TREE; + gdebug *copy = NULL, *gs = as_a (stmt); + enum tree_code code; + + switch (gs->subcode) + { + case GIMPLE_DEBUG_BIND: + op = gimple_debug_bind_get_value (gs); + break; + case GIMPLE_DEBUG_SOURCE_BIND: + op = gimple_debug_source_bind_get_value (gs); + break; + default: + gcc_unreachable (); + } + + switch (TREE_CODE_CLASS (TREE_CODE (op))) + { + case tcc_exceptional: + case tcc_unary: + { + /* Convert DEBUG stmt of the form: + # DEBUG a => _2 + to + # DEBUG a => (char)_2 */ + new_op = build1 (CONVERT_EXPR, old_type, use); + break; + } + case tcc_binary: + code = TREE_CODE (op); + /* Convert the INTEGER_CST in tcc_binary to promoted_type, + if the expression is of kind that will be promoted. */ + if (code == LROTATE_EXPR + || code == RROTATE_EXPR + || code == COMPLEX_EXPR) + break; + else + { + tree op0 = TREE_OPERAND (op, 0); + tree op1 = TREE_OPERAND (op, 1); + if (TREE_CODE (op0) == INTEGER_CST) + op0 = convert_int_cst (promoted_type, op0, SIGNED); + if (TREE_CODE (op1) == INTEGER_CST) + op1 = convert_int_cst (promoted_type, op1, SIGNED); + new_op = build2 (TREE_CODE (op), promoted_type, op0, op1); + break; + } + default: + break; + } + + if (new_op) + { + if (gimple_debug_bind_p (stmt)) + { + copy = gimple_build_debug_bind + (gimple_debug_bind_get_var (stmt), + new_op, + stmt); + } + if (gimple_debug_source_bind_p (stmt)) + { + copy = gimple_build_debug_source_bind + (gimple_debug_source_bind_get_var (stmt), new_op, + stmt); + } + + if (copy) + { + gsi = gsi_for_stmt (stmt); + gsi_replace (&gsi, copy, false); + } + } } + break; case GIMPLE_ASM: case GIMPLE_CALL: -- 1.9.1