Le 2015-02-05 14:59, Benjamin Ylvisaker a écrit :
>> On Feb 5, 2015, at 3:52 AM, Gabriel Kerneis <gabr...@kerneis.info> 
>> wrote:
>>
>> On Wed, Feb 04, 2015 at 11:04:38AM -0700, Benjamin Ylvisaker wrote:
>>> I was recently looking at copyFunction because I need something 
>>> similar.
>>> I was surprised to not find any changes to slocals. Is that a bug 
>>> or am
>>> I misunderstanding the role of slocals.
>>
>> I'm not sure I understand what you mean (but we have had bugs with
>> copyFunction in the past, so it may well be another CIL issue). 
>> Could
>> you give an example of the observed behaviour (on a small piece of C
>> code), and what you would expect instead?
>
> Sorry for being too concise.  I don’t have a misbehaving test.  Here
> is what’s causing my confusion in a little more detail:
>
> - The slocals field of fundec is a list of varinfos.  I assume this
> represents the set of local variables used in the function.
> - varinfos include the unique id field.
> - The copyFunctionVisitor class makes new varinfos with new ids (for
> the old function? See bug 143).
> - I don’t see where slocals is changed anywhere.
>
> So won’t both copies’ slocals refer to the same set of varinfos?  Is
> that not actually a problem for some reason?

The CIL visitor semantics is a bit tricky to follow at times, but I 
don't think there is a bug here.

ChangeDoChildrenPost in vfunc:
   
https://github.com/cil-project/cil/blob/d9d6a08b8017dea996f3f6a4eef07dc017682d6d/src/cil.ml#L6451
will eventually trigger the invoke of visitCilFunction, which in turns 
iterates over the formals:
   
https://github.com/cil-project/cil/blob/d9d6a08b8017dea996f3f6a4eef07dc017682d6d/src/cil.ml#L5590
which calls the vvdec method:
   
https://github.com/cil-project/cil/blob/d9d6a08b8017dea996f3f6a4eef07dc017682d6d/src/cil.ml#L5497

And vvdec for copyFunction does the right thing of allocating new 
locals:
   
https://github.com/cil-project/cil/blob/d9d6a08b8017dea996f3f6a4eef07dc017682d6d/src/cil.ml#L6463

Don't hesitate if you have further questions.

Best,
-- 
Gabriel

------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
CIL-users mailing list
CIL-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cil-users

Reply via email to