* Handling of local variables in the backend
@ 2017-09-12 21:54 Dibyendu Majumdar
2017-09-12 22:44 ` Christopher Li
0 siblings, 1 reply; 5+ messages in thread
From: Dibyendu Majumdar @ 2017-09-12 21:54 UTC (permalink / raw)
To: Linux-Sparse
Hi,
One issue I am facing at the moment is that there is no explicit
alloca for each symbol that is used in a function - so that the
backend has to detect when a symbol is accessed and then do alloca to
associate stack space. In the LLVM backend this is not so much an
issue as LLVM allows instructions to be inserted at a particular point
- so my code just ensures that all the allocas go at the start of the
function as required by LLVM. But I am having trouble with the other
backend that doesn't have this capability.
I think that there is no easy way to identify all the symbols used for
which stack space is needed and do the allocas at the start - is
there? I mean the only way is to go through all the instructions to
find these references as far as I know.
Is there a better way?
Regards
Dibyendu
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Handling of local variables in the backend
2017-09-12 21:54 Handling of local variables in the backend Dibyendu Majumdar
@ 2017-09-12 22:44 ` Christopher Li
2017-09-13 9:56 ` Dibyendu Majumdar
0 siblings, 1 reply; 5+ messages in thread
From: Christopher Li @ 2017-09-12 22:44 UTC (permalink / raw)
To: Dibyendu Majumdar; +Cc: Linux-Sparse
On Tue, Sep 12, 2017 at 5:54 PM, Dibyendu Majumdar
<mobile@majumdar.org.uk> wrote:
>
> I think that there is no easy way to identify all the symbols used for
> which stack space is needed and do the allocas at the start - is
> there? I mean the only way is to go through all the instructions to
> find these references as far as I know.
Have you try the sym->symbol_list for the function node?
It should contain all the symbol used in that function.
I can even see that symbol_list under test-inspect.
under
[SYM_NODE:
[ ctype.base_type: SYM_FN]
[ symbol_list: symbol_list,
... <============== here.
]
]
It has other label symbol as well. You should be able to filter
out those pretty easily.
Chris
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Handling of local variables in the backend
2017-09-12 22:44 ` Christopher Li
@ 2017-09-13 9:56 ` Dibyendu Majumdar
2017-09-13 10:18 ` Luc Van Oostenryck
0 siblings, 1 reply; 5+ messages in thread
From: Dibyendu Majumdar @ 2017-09-13 9:56 UTC (permalink / raw)
To: Christopher Li; +Cc: Linux-Sparse
Hi Chris,
On 12 September 2017 at 23:44, Christopher Li <sparse@chrisli.org> wrote:
> On Tue, Sep 12, 2017 at 5:54 PM, Dibyendu Majumdar
> <mobile@majumdar.org.uk> wrote:
>>
>> I think that there is no easy way to identify all the symbols used for
>> which stack space is needed and do the allocas at the start - is
>> there? I mean the only way is to go through all the instructions to
>> find these references as far as I know.
>
>
> Have you try the sym->symbol_list for the function node?
> It should contain all the symbol used in that function.
>
Did you mean struct entrypoint -> syms instead?
I see that this contains a list of symbols ... I don't know if this is
guaranteed to have all symbols defined in the function.
Regards
Dibyendu
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Handling of local variables in the backend
2017-09-13 9:56 ` Dibyendu Majumdar
@ 2017-09-13 10:18 ` Luc Van Oostenryck
2017-09-13 10:22 ` Dibyendu Majumdar
0 siblings, 1 reply; 5+ messages in thread
From: Luc Van Oostenryck @ 2017-09-13 10:18 UTC (permalink / raw)
To: Dibyendu Majumdar; +Cc: Christopher Li, Linux-Sparse
On Wed, Sep 13, 2017 at 10:56:16AM +0100, Dibyendu Majumdar wrote:
> Hi Chris,
>
> On 12 September 2017 at 23:44, Christopher Li <sparse@chrisli.org> wrote:
> > On Tue, Sep 12, 2017 at 5:54 PM, Dibyendu Majumdar
> > <mobile@majumdar.org.uk> wrote:
> >>
> >> I think that there is no easy way to identify all the symbols used for
> >> which stack space is needed and do the allocas at the start - is
> >> there? I mean the only way is to go through all the instructions to
> >> find these references as far as I know.
> >
> >
> > Have you try the sym->symbol_list for the function node?
> > It should contain all the symbol used in that function.
> >
>
> Did you mean struct entrypoint -> syms instead?
> I see that this contains a list of symbols ... I don't know if this is
> guaranteed to have all symbols defined in the function.
ep->accesses contains all the pseudos corresponding to the symbols
used for doing load & store accesses.
So, you probably should doing something like:
pseudo_t pseudo;
FOR_EACH_PTR(ep->accesses, pseudo) {
struct symbol *sym = pseudo->sym;
unsigned log mods = sym->ctype.modifiers;
if (mods & MOD_VOLATILE)
...
if (mods & (MOD_NONLOCAL | MOD_STATIC | MOD_ADDRESSABLE))
...
-- Luc
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Handling of local variables in the backend
2017-09-13 10:18 ` Luc Van Oostenryck
@ 2017-09-13 10:22 ` Dibyendu Majumdar
0 siblings, 0 replies; 5+ messages in thread
From: Dibyendu Majumdar @ 2017-09-13 10:22 UTC (permalink / raw)
To: Luc Van Oostenryck; +Cc: Christopher Li, Linux-Sparse
Hi Luc,
On 13 September 2017 at 11:18, Luc Van Oostenryck
<luc.vanoostenryck@gmail.com> wrote:
> On Wed, Sep 13, 2017 at 10:56:16AM +0100, Dibyendu Majumdar wrote:
>> Hi Chris,
>>
>> On 12 September 2017 at 23:44, Christopher Li <sparse@chrisli.org> wrote:
>> > On Tue, Sep 12, 2017 at 5:54 PM, Dibyendu Majumdar
>> > <mobile@majumdar.org.uk> wrote:
>> >>
>> >> I think that there is no easy way to identify all the symbols used for
>> >> which stack space is needed and do the allocas at the start - is
>> >> there? I mean the only way is to go through all the instructions to
>> >> find these references as far as I know.
>> >
>> >
>> > Have you try the sym->symbol_list for the function node?
>> > It should contain all the symbol used in that function.
>> >
>>
>> Did you mean struct entrypoint -> syms instead?
>> I see that this contains a list of symbols ... I don't know if this is
>> guaranteed to have all symbols defined in the function.
>
> ep->accesses contains all the pseudos corresponding to the symbols
> used for doing load & store accesses.
>
> So, you probably should doing something like:
>
> pseudo_t pseudo;
>
> FOR_EACH_PTR(ep->accesses, pseudo) {
> struct symbol *sym = pseudo->sym;
> unsigned log mods = sym->ctype.modifiers;
>
> if (mods & MOD_VOLATILE)
> ...
> if (mods & (MOD_NONLOCAL | MOD_STATIC | MOD_ADDRESSABLE))
> ...
>
>
Thanks. I will look at this.
Regards
Dibyendu
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-09-13 10:22 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-12 21:54 Handling of local variables in the backend Dibyendu Majumdar
2017-09-12 22:44 ` Christopher Li
2017-09-13 9:56 ` Dibyendu Majumdar
2017-09-13 10:18 ` Luc Van Oostenryck
2017-09-13 10:22 ` Dibyendu Majumdar
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 NNTP newsgroup(s).