* [gimple-ssa] result_decl and ssa_name @ 2024-04-05 11:58 Pierrick Philippe 2024-04-05 12:46 ` Richard Biener 0 siblings, 1 reply; 6+ messages in thread From: Pierrick Philippe @ 2024-04-05 11:58 UTC (permalink / raw) To: gcc Hi all, I do have a question regarding ssa_name and result_decl. For example on the following gimple function: int f () { int x; int D.2747; int _2; <bb 2> : x_1 = 42; _2 = x_1; <bb 3> : <L0>: return _2; } On the above example, using the macro SSA_NAME_VAR() on _2 does not yield anything usable. Neither to call ssa_default_def() on the result of the result_decl obtain through macro DECL_RESULT(). Is there a way to get the ssa_name corresponding to the result_decl of a function obtained through the use of macro DECL_RESULT() on a fn_decl? And/or the other way around? I.e., from the returned ssa_name of a function to the result_decl of that function? I totally might be missing something here, but I cannot figure out what. Thanks for your time, Pierrick ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [gimple-ssa] result_decl and ssa_name 2024-04-05 11:58 [gimple-ssa] result_decl and ssa_name Pierrick Philippe @ 2024-04-05 12:46 ` Richard Biener 2024-04-05 13:44 ` Pierrick Philippe 0 siblings, 1 reply; 6+ messages in thread From: Richard Biener @ 2024-04-05 12:46 UTC (permalink / raw) To: Pierrick Philippe; +Cc: gcc On Fri, Apr 5, 2024 at 1:59 PM Pierrick Philippe <pierrick.philippe@irisa.fr> wrote: > > Hi all, > > I do have a question regarding ssa_name and result_decl. > > For example on the following gimple function: > > int f () > { > int x; > int D.2747; > int _2; > > <bb 2> : > x_1 = 42; > _2 = x_1; > > <bb 3> : > <L0>: > return _2; > > } > > On the above example, using the macro SSA_NAME_VAR() on _2 does not > yield anything usable. > Neither to call ssa_default_def() on the result of the result_decl > obtain through macro DECL_RESULT(). > > Is there a way to get the ssa_name corresponding to the result_decl of a > function obtained through the use of macro DECL_RESULT() on a fn_decl? > And/or the other way around? I.e., from the returned ssa_name of a > function to the result_decl of that function? > > I totally might be missing something here, but I cannot figure out what. DECL_RESULT isn't always used (as in your example). Not all SSA names have corresponding declarations, we have "anonymous" SSA names which have a NULL_TREE SSA_NAME_VAR (such as the _2 in your example). What do you try to find in the end? If you want to find all returns you can walk predecessors of EXIT_BLOCK and look at their last stmt whether they are greturn statements. Richard. > Thanks for your time, > > Pierrick > ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [gimple-ssa] result_decl and ssa_name 2024-04-05 12:46 ` Richard Biener @ 2024-04-05 13:44 ` Pierrick Philippe 2024-04-06 12:53 ` Richard Biener 0 siblings, 1 reply; 6+ messages in thread From: Pierrick Philippe @ 2024-04-05 13:44 UTC (permalink / raw) To: Richard Biener; +Cc: gcc [-- Attachment #1: Type: text/plain, Size: 2164 bytes --] On 05/04/2024 14:46, Richard Biener wrote: > On Fri, Apr 5, 2024 at 1:59 PM Pierrick Philippe > <pierrick.philippe@irisa.fr> wrote: >> Hi all, >> >> I do have a question regarding ssa_name and result_decl. >> >> For example on the following gimple function: >> >> int f () >> { >> int x; >> int D.2747; >> int _2; >> >> <bb 2> : >> x_1 = 42; >> _2 = x_1; >> >> <bb 3> : >> <L0>: >> return _2; >> >> } >> >> On the above example, using the macro SSA_NAME_VAR() on _2 does not >> yield anything usable. >> Neither to call ssa_default_def() on the result of the result_decl >> obtain through macro DECL_RESULT(). >> >> Is there a way to get the ssa_name corresponding to the result_decl of a >> function obtained through the use of macro DECL_RESULT() on a fn_decl? >> And/or the other way around? I.e., from the returned ssa_name of a >> function to the result_decl of that function? >> >> I totally might be missing something here, but I cannot figure out what. > DECL_RESULT isn't always used (as in your example). Not all SSA names > have corresponding declarations, we have "anonymous" SSA names which > have a NULL_TREE SSA_NAME_VAR (such as the _2 in your example). I see, that makes so much more sense to me now. > What do you try to find in the end? If you want to find all returns you can > walk predecessors of EXIT_BLOCK and look at their last stmt whether they > are greturn statements. I am implementing a state_machine within the analyzer, and I am trying to understand where would be the best place to propagate the state of the return value. I intuitively thought it would be best to do so in the state_machine::on_pop_frame() method, which is called by the analyzer between the two frames of the caller and the callee. What I do have access to is the struct function of the callee/caller, the gcall instruction in the caller and the callee have been processed by my analysis. And to illustrate, here I do have the _2 ssa_name and its state which I know in that case should be propagate to the lhs of the caller gcall instruction. Again I might be taking this in a wrong way. > Richard. >> Thanks for your time, >> >> Pierrick ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [gimple-ssa] result_decl and ssa_name 2024-04-05 13:44 ` Pierrick Philippe @ 2024-04-06 12:53 ` Richard Biener 2024-04-08 8:47 ` Pierrick Philippe 0 siblings, 1 reply; 6+ messages in thread From: Richard Biener @ 2024-04-06 12:53 UTC (permalink / raw) To: Pierrick Philippe; +Cc: gcc On Fri, Apr 5, 2024 at 3:44 PM Pierrick Philippe <pierrick.philippe@irisa.fr> wrote: > > On 05/04/2024 14:46, Richard Biener wrote: > > On Fri, Apr 5, 2024 at 1:59 PM Pierrick Philippe > <pierrick.philippe@irisa.fr> wrote: > > Hi all, > > I do have a question regarding ssa_name and result_decl. > > For example on the following gimple function: > > int f () > { > int x; > int D.2747; > int _2; > > <bb 2> : > x_1 = 42; > _2 = x_1; > > <bb 3> : > <L0>: > return _2; > > } > > On the above example, using the macro SSA_NAME_VAR() on _2 does not > yield anything usable. > Neither to call ssa_default_def() on the result of the result_decl > obtain through macro DECL_RESULT(). > > Is there a way to get the ssa_name corresponding to the result_decl of a > function obtained through the use of macro DECL_RESULT() on a fn_decl? > And/or the other way around? I.e., from the returned ssa_name of a > function to the result_decl of that function? > > I totally might be missing something here, but I cannot figure out what. > > DECL_RESULT isn't always used (as in your example). Not all SSA names > have corresponding declarations, we have "anonymous" SSA names which > have a NULL_TREE SSA_NAME_VAR (such as the _2 in your example). > > I see, that makes so much more sense to me now. > > What do you try to find in the end? If you want to find all returns you can > walk predecessors of EXIT_BLOCK and look at their last stmt whether they > are greturn statements. > > I am implementing a state_machine within the analyzer, and I am trying to understand where would be the best place to propagate the state of the return value. > I intuitively thought it would be best to do so in the state_machine::on_pop_frame() method, which is called by the analyzer between the two frames of the caller and the callee. What I do have access to is the struct function of the callee/caller, the gcall instruction in the caller and the callee have been processed by my analysis. It might make sense to record the analysis of the return value in meta-data that the analyzer keeps and access it that way. Other than that you'd have to do it the way I said with finding the greturn stmts again and look at what is returned there. > And to illustrate, here I do have the _2 ssa_name and its state which I know in that case should be propagate to the lhs of the caller gcall instruction. > > Again I might be taking this in a wrong way. > > Richard. > > Thanks for your time, > > Pierrick ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [gimple-ssa] result_decl and ssa_name 2024-04-06 12:53 ` Richard Biener @ 2024-04-08 8:47 ` Pierrick Philippe 2024-04-08 9:02 ` Richard Biener 0 siblings, 1 reply; 6+ messages in thread From: Pierrick Philippe @ 2024-04-08 8:47 UTC (permalink / raw) To: Richard Biener; +Cc: gcc [-- Attachment #1: Type: text/plain, Size: 2982 bytes --] On 06/04/2024 14:53, Richard Biener wrote: > On Fri, Apr 5, 2024 at 3:44 PM Pierrick Philippe > <pierrick.philippe@irisa.fr> wrote: >> On 05/04/2024 14:46, Richard Biener wrote: >> >> On Fri, Apr 5, 2024 at 1:59 PM Pierrick Philippe >> <pierrick.philippe@irisa.fr> wrote: >> >> Hi all, >> >> I do have a question regarding ssa_name and result_decl. >> >> For example on the following gimple function: >> >> int f () >> { >> int x; >> int D.2747; >> int _2; >> >> <bb 2> : >> x_1 = 42; >> _2 = x_1; >> >> <bb 3> : >> <L0>: >> return _2; >> >> } >> >> On the above example, using the macro SSA_NAME_VAR() on _2 does not >> yield anything usable. >> Neither to call ssa_default_def() on the result of the result_decl >> obtain through macro DECL_RESULT(). >> >> Is there a way to get the ssa_name corresponding to the result_decl of a >> function obtained through the use of macro DECL_RESULT() on a fn_decl? >> And/or the other way around? I.e., from the returned ssa_name of a >> function to the result_decl of that function? >> >> I totally might be missing something here, but I cannot figure out what. >> >> DECL_RESULT isn't always used (as in your example). Not all SSA names >> have corresponding declarations, we have "anonymous" SSA names which >> have a NULL_TREE SSA_NAME_VAR (such as the _2 in your example). >> >> I see, that makes so much more sense to me now. >> >> What do you try to find in the end? If you want to find all returns you can >> walk predecessors of EXIT_BLOCK and look at their last stmt whether they >> are greturn statements. >> >> I am implementing a state_machine within the analyzer, and I am trying to understand where would be the best place to propagate the state of the return value. >> I intuitively thought it would be best to do so in the state_machine::on_pop_frame() method, which is called by the analyzer between the two frames of the caller and the callee. What I do have access to is the struct function of the callee/caller, the gcall instruction in the caller and the callee have been processed by my analysis. > It might make sense to record the analysis of the return value in > meta-data that the analyzer keeps and access it that way. > Other than that you'd have to do it the way I said with finding the > greturn stmts again and look at what is returned there. That is what I had in mind, thanks for answering me. I do have another question though, how do you obtain the decl_context of such an ssa_name? The DECL_CONTEXT macro is failing during the tree check and I ha ve no idea how to know where a given ssa_name is declared without accessing its inner var (through SSA_NAME_VAR). And this operation is failing on _i ssa_name trees. >> And to illustrate, here I do have the _2 ssa_name and its state which I know in that case should be propagate to the lhs of the caller gcall instruction. >> >> Again I might be taking this in a wrong way. >> >> Richard. >> >> Thanks for your time, >> >> Pierrick ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [gimple-ssa] result_decl and ssa_name 2024-04-08 8:47 ` Pierrick Philippe @ 2024-04-08 9:02 ` Richard Biener 0 siblings, 0 replies; 6+ messages in thread From: Richard Biener @ 2024-04-08 9:02 UTC (permalink / raw) To: Pierrick Philippe; +Cc: gcc On Mon, Apr 8, 2024 at 10:47 AM Pierrick Philippe <pierrick.philippe@irisa.fr> wrote: > > On 06/04/2024 14:53, Richard Biener wrote: > > On Fri, Apr 5, 2024 at 3:44 PM Pierrick Philippe > <pierrick.philippe@irisa.fr> wrote: > > On 05/04/2024 14:46, Richard Biener wrote: > > On Fri, Apr 5, 2024 at 1:59 PM Pierrick Philippe > <pierrick.philippe@irisa.fr> wrote: > > Hi all, > > I do have a question regarding ssa_name and result_decl. > > For example on the following gimple function: > > int f () > { > int x; > int D.2747; > int _2; > > <bb 2> : > x_1 = 42; > _2 = x_1; > > <bb 3> : > <L0>: > return _2; > > } > > On the above example, using the macro SSA_NAME_VAR() on _2 does not > yield anything usable. > Neither to call ssa_default_def() on the result of the result_decl > obtain through macro DECL_RESULT(). > > Is there a way to get the ssa_name corresponding to the result_decl of a > function obtained through the use of macro DECL_RESULT() on a fn_decl? > And/or the other way around? I.e., from the returned ssa_name of a > function to the result_decl of that function? > > I totally might be missing something here, but I cannot figure out what. > > DECL_RESULT isn't always used (as in your example). Not all SSA names > have corresponding declarations, we have "anonymous" SSA names which > have a NULL_TREE SSA_NAME_VAR (such as the _2 in your example). > > I see, that makes so much more sense to me now. > > What do you try to find in the end? If you want to find all returns you can > walk predecessors of EXIT_BLOCK and look at their last stmt whether they > are greturn statements. > > I am implementing a state_machine within the analyzer, and I am trying to understand where would be the best place to propagate the state of the return value. > I intuitively thought it would be best to do so in the state_machine::on_pop_frame() method, which is called by the analyzer between the two frames of the caller and the callee. What I do have access to is the struct function of the callee/caller, the gcall instruction in the caller and the callee have been processed by my analysis. > > It might make sense to record the analysis of the return value in > meta-data that the analyzer keeps and access it that way. > Other than that you'd have to do it the way I said with finding the > greturn stmts again and look at what is returned there. > > That is what I had in mind, thanks for answering me. > > I do have another question though, how do you obtain the decl_context of such an ssa_name? The DECL_CONTEXT macro is failing during the tree check and I ha ve no idea how to know where a given ssa_name is declared without accessing its inner var (through SSA_NAME_VAR). And this operation is failing on _i ssa_name trees. There is no DECL_CONTEXT for SSA names, if the name is anonymous (no SSA_NAME_VAR) then the context is implicityly the whole function, thus the FUNCTION_DECL. > > And to illustrate, here I do have the _2 ssa_name and its state which I know in that case should be propagate to the lhs of the caller gcall instruction. > > Again I might be taking this in a wrong way. > > Richard. > > Thanks for your time, > > Pierrick ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-04-08 9:02 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2024-04-05 11:58 [gimple-ssa] result_decl and ssa_name Pierrick Philippe 2024-04-05 12:46 ` Richard Biener 2024-04-05 13:44 ` Pierrick Philippe 2024-04-06 12:53 ` Richard Biener 2024-04-08 8:47 ` Pierrick Philippe 2024-04-08 9:02 ` Richard Biener
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).