On 27/06/2023 11:42, Richard Biener wrote:
On Tue, Jun 27, 2023 at 11:36 AM Pierrick Philippe
<pierrick.phili...@irisa.fr> wrote:
Hi everyone,
I'm trying to get the gimple * associated to the definition of a given
var_decl.
Basically, I am iterating over the locals of a function (through the
local_decls member) and I need to be able to get the gimple * of its
definition within the function's gimple_seq.
Does any of you have an idea on how this could be achieved ?
You need to walk the body of the function looking for defining
stmts. Note the VAR_DECL might be in SSA form in which
case you can also walk all SSA names and check those
whose SSA_NAME_VAR is the specific VAR_DECL. But then
SSA names can "lose" their associated decks so when a
variable is in SSA form the set of original assignments cannot
always be recovered easily.
Thank you for your answer Richard.
I'll have a look into that.
My main problem is regarding uninitialized definition, but still not
being considered undefined behavior.
For example, the following code:
int x;
int *y = &x;
*y = 6;
What I'm doing is basically looking at each gimple statement if the lhs
has a given attribute for the purpose of the analysis I'm trying to perform.
To precise, I'm plugged into the analyzer, so an out-of-tree plugin.
But in the example above, the definition of x is not really within the
gimple_seq of the function as it is never directly assigned.
Pierrick
Richard.
Thanks,
Pierrick