how to find variable related to a virtual ssa name
易会战
huizhanyi@foxmail.com
Tue May 12 14:16:22 GMT 2020
thanks a lot. I will check your advice.
Can you give some explaination about memory ssa, and how to use it. I check internal, cannot get it. Maybe you know some examples or some more materials.
---Original---
From: "Richard Biener"<richard.guenther@gmail.com>
Date: Tue, May 12, 2020 22:02 PM
To: "易会战"<huizhanyi@foxmail.com>;
Cc: "gcc"<gcc@gcc.gnu.org>;
Subject: Re: how to find variable related to a virtual ssa name
On Tue, May 12, 2020 at 2:44 PM 易会战 via Gcc <gcc@gcc.gnu.org> 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 definition for a symbol (check SSA_NAME_IS_DEFAULT_DEF) , I can get the symbol by SSA_NAME_VAR. But for a virtual DEFAULT DEF, I cannot get it, SSA_NAME_VAR return a identifier named .MEM. I cannot find which variable related to the 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 type. 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 address in a global ptr. On gimple ssa IR, the malloc function return a address assigned to a ssa name , then ssa name assign the value to the global ptr. When i check ssa name defined by the global ptr, I donot know if the ptr point to global memory or local memory.
> Please see the gimple code:
> _2 = malloc()
> ptr = _2
> _3 = ptr
> MEM_REF[BASE _3]
> I wish get _3 is a address pointing to global memory. But just from _3=ptr, 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 internally
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.
More information about the Gcc
mailing list