From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qt1-x829.google.com (mail-qt1-x829.google.com [IPv6:2607:f8b0:4864:20::829]) by sourceware.org (Postfix) with ESMTPS id F0B92385E005 for ; Sun, 6 Sep 2020 23:32:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org F0B92385E005 Received: by mail-qt1-x829.google.com with SMTP id t20so8784675qtr.8 for ; Sun, 06 Sep 2020 16:32:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=uVAY3sAT1O7m/YrD75I8isozvvlFy7V4OQQR0UWGz4g=; b=HrufddgEl6KEK3AYseirq2cX7y3M6QIL5oFPOK0guc3Oo9Cn+N24vafRTZHx9FknKa uAY/O1vypT7XcF+hIxOTLbqB5ebuScwT3KOh29fAunvV2nRvRqLe3lt6/CKWkSpAf4y3 ylh56XpIBAVAiPPbAOrLKLlWVrQmp2maCLdA4qFOorNUCjRArtOmBpb8sthQ2HpApVZ0 +xv82c6R3gKlNGkfoHe3YgphPe7h/3IJe3qSrejQgVL8UKOkRCS3OCnRXHllmR0n6oiF wp+vdh4BPhG7uJzPwXeaz13Y6rOy8ic+lq55Y7kTACrBsc70PobsnuXw4XYRM4c8Dzc6 MLuQ== X-Gm-Message-State: AOAM533tatxaRzRobIGYZncJE/fV+oVbHbyd20htHXWlbwFlmruAVEe9 cSvvwdOlIkGNyeO8x5RHZNbYK/iUmzI= X-Google-Smtp-Source: ABdhPJxWLsF+fFgRzrORxh4fP+/s0BQY6aJpna+iOTLd4D9S4RPJmW8rCcGCm8N7/6dsHKOx3Fw/qA== X-Received: by 2002:ac8:5d4d:: with SMTP id g13mr18692384qtx.348.1599435120397; Sun, 06 Sep 2020 16:32:00 -0700 (PDT) Received: from [192.168.0.41] (174-16-103-228.hlrn.qwest.net. [174.16.103.228]) by smtp.gmail.com with ESMTPSA id w44sm10511196qth.9.2020.09.06.16.31.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 06 Sep 2020 16:31:59 -0700 (PDT) Subject: Re: about souce code location To: =?UTF-8?B?5piT5Lya5oiY?= , Richard Biener Cc: gcc References: From: Martin Sebor Message-ID: <6b415f3d-903e-a841-372a-3e39fd8483b6@gmail.com> Date: Sun, 6 Sep 2020 17:31:58 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00, BODY_8BITS, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, FREEMAIL_REPLY, NICE_REPLY_A, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Sep 2020 23:32:19 -0000 On 9/4/20 6:26 AM, 易会战 via Gcc wrote: > how to check the location corresponding to a gimple statement? My instrument stmt include some memory access, I wish get right source code line. By context it is possible get wrong line. The gimple_location() function returns the location of the GIMPLE statement passed to it as an argument. When the location isn't available (e.g., because the statement corresponds to two or more source lines) there isn't much you can do to retrieve it. Sometimes it's possible to come close by using the location of the next (or previous) GIMPLE statement. Other times the best you can do is point at the function body (either the opening or closing curly). Martin > > > > ---Original--- > From: "Richard Biener" Date: Fri, Sep 4, 2020 15:08 PM > To: "易会战" Cc: "gcc" Subject: Re: about souce code location > > > On Fri, Sep 4, 2020 at 2:23 AM 易会战 via Gcc > > > I am working a instrumention tool, and need get the location info for a gimple statement. I use the location structure to get the info, and it can work when i use -O1. When I use -O2, sometimes the info seems to be lost and I get line num is zero.&nbsp; anyone can tell me how to get the info? > > Not all statements have a location, if you encounter such you need to > look at the "surrounding context" > to find one. >