#143 CopyFunction changes SIDs.

Bug
pending
None
5
2014-06-26
2014-01-14
az bro
No

As a side effect of making a copy of a function using
CopyFunction, the statement IDs of the original function
are changed. This should either be fixed, or a note should
be added to the documentation.

method vstmt (s: stmt) : stmt visitAction =
s.sid <- !sid; incr sid;
let s' = {s with sid = s.sid} in

Related

Bugs: #143

Discussion

  • This seems a feature rather than a bug to me. I've updated the documentation to mention the allocation of fresh sids.

     
    • status: open --> closed
     
    • az bro
      az bro
      2014-05-27

      OK, makes sense.

      On Tue, May 27, 2014 at 6:11 PM, Gabriel Kerneis kerneis@users.sf.netwrote:

      • status: open --> closed

      Status: closed
      Group: Bug

      Created: Tue Jan 14, 2014 08:46 PM UTC by az bro
      Last Updated: Tue May 27, 2014 03:11 PM UTC
      Owner: nobody

      As a side effect of making a copy of a function using
      CopyFunction, the statement IDs of the original function
      are changed. This should either be fixed, or a note should
      be added to the documentation.

      method vstmt (s: stmt) : stmt visitAction =
      s.sid <- !sid; incr sid;
      let s' = {s with sid = s.sid} in


      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/cil/bugs/143/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

      --
      sɐpıɯ ƃuıʞ ǝsɹǝʌuı

       

      Related

      Bugs: #143

    • status: closed --> closed-fixed
     
  • No, in fact it makes no sense… Sids must be fresh within a single function. There is no reason in principle to break them. However, notice that stmt.preds and stmt.succs are going to be broken anyway - pointing to the old statements. So I guess the right thing to do is to reset everything (sid = -1, preds = succs = []), and force recomputation of the CFG?

    I'll commit this if it makes sense.

     
  • Ha, the code abuses the sid to index the hashtable! This is horrible. Oh my... It should use the statements themselves, with physical equality. I did not realize that it resets the original sids... Oh...

    I'll fix that. The new behaviour will be:
    - original statement unchanged,
    - new statement with sid = -1.

     
    • status: closed-fixed --> open-accepted
     
  • There is a patch proposal in branch fix-copyfunction. Could you tell me if it solves your issue (as well as #142)? Thanks a lot.

     
    • status: open-accepted --> pending
    • assigned_to: Gabriel Kerneis