From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by sourceware.org (Postfix) with ESMTPS id 56609386F837 for ; Tue, 12 May 2020 14:02:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 56609386F837 Received: by mail-ed1-x529.google.com with SMTP id b91so6984494edf.3 for ; Tue, 12 May 2020 07:02:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=wk+tBQU+eCpgeP3cd4/zh2D3b5I+PCCTtIhV8YOoSyk=; b=ThH8GsYn+DWV157xRDaeWnZlVSjzC92mD2cY6KSGulhGuTH/818fZmkp8i8ScxjwoU vmg1hFuiZj369XnPD3ttJUzepZ95jTrnd+eUOJZ7KsFne4w0oveIrxmU6ESwKPzrufVG TDdvTEQrAHPHNOuNKZlQ/gYx2Zot0XRxKK58kkEeQxNkmDDycWsMCdUkXMXaGlRG0VU9 1cngxxQOt+EyK0SJIzbDa9xnve0B7+UMkrA94cAOAdYdFTpl9KZ4CkeHWg1vzsZCQh46 jNfkAr8UJzwbmZjO8pjZ5uPL6F3nl8pJYxSQL9KIqpDXoqQUny0NywaUekyu8ZhOjwSH VJtw== X-Gm-Message-State: AOAM530NU3ZFB2Vn1aIfmj6MOP0RDoEp9LVALeqq131BHSolPwcjYyJ5 QXMMyCVStyx/wqqzz/zt+grzrB1CuIWP2CrW7b8= X-Google-Smtp-Source: ABdhPJykmf6mc7rGHQGu7bVgP20wkk/O66RJ/fD5emlNGISHDlj7IaNEipy4IGWojVV1r57gBoX1vMfG5laCboL5fsk= X-Received: by 2002:a50:e791:: with SMTP id b17mr7155157edn.248.1589292165027; Tue, 12 May 2020 07:02:45 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Richard Biener Date: Tue, 12 May 2020 16:02:33 +0200 Message-ID: Subject: Re: how to find variable related to a virtual ssa name To: =?UTF-8?B?5piT5Lya5oiY?= Cc: gcc Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00, BODY_8BITS, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham 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: Tue, 12 May 2020 14:02:51 -0000 On Tue, May 12, 2020 at 2:44 PM =E6=98=93=E4=BC=9A=E6=88=98 via Gcc wrote: > > hi, I am working on gcc ssa name. For each function, we can traverse all = defined ssa name by macro FOR_EACH_SSA_NAME. If a ssa name is default defin= ition for a symbol (check SSA_NAME_IS_DEFAULT_DEF) , I can get the symbol b= y SSA_NAME_VAR. But for a virtual DEFAULT DEF, I cannot get it, SSA_NAME_VA= R return a identifier named .MEM. I cannot find which variable related to t= he default definition. Why and how I should find the related variable? > > > By the way , I give my current work,  I wish find a MEM_REF refer to= global/heap memory or local stack. I try my best to get a correct memory t= ype. Since MEM_REF have a base address, which is often a ssa name. Athough = it is not virtual ssa name. But I find just check ssa name data flow is not= enough to get the info. > For example, a malloc function allocate some heap memory and record the a= ddress in a global ptr. On gimple ssa IR, the malloc function return a addr= ess assigned to a ssa name , then ssa name assign the value to the global p= tr. When i check ssa name defined by the global ptr, I donot know if the pt= r point to global memory or local memory. > Please see the gimple code: > _2 =3D malloc() > ptr =3D _2 > _3 =3D ptr > MEM_REF[BASE _3] > I wish get _3  is a address pointing to global memory. But just from= _3=3Dptr, cannot judge it.  > I wish memory SSA can help solve the problem. memory SSA will not solve this problem. You can instead query points-to information on _3 for example by calling ptr_deref_may_alias_global_p (_3) which intern= ally looks at SSA_NAME_PTR_INFO which contains the solution of the points-to computation. Richard. > > Or gcc gives the info at other pass? wish get some advice. Thanks a lot.