Menu

#3505 different code is generated each time

closed-fixed
None
other
5
2023-01-23
2022-10-13
No

In function btree_add_symbol, when symbols are added, they're sorted by the symbol* pointer, so each time we run sdcc, we may get the symbols in different order in btree_alloc, thus different machine code may be generated (especially on macOS)

Related

Discussion: Is it possible to get all the same once use stack auto
Wiki: NGI0-Entrust-SDCC
Wiki: SDCC 4.3.0 Release

Discussion

  • Benedikt Freisen

    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1 +1 @@
    -In function [btree_add_symbol]  (SDCCbtree.cc), when symbols are added, they're sorted by the symbol* pointer, so each time we run sdcc, we may get the symbols in different order in [btree_alloc], thus different machine code may be generated (espacially on macOS)
    +In function [`btree_add_symbol`](https://sourceforge.net/p/sdcc/code/HEAD/tree/trunk/sdcc/src/SDCCbtree.cc#l102), when symbols are added, they're sorted by the `symbol*` pointer, so each time we run sdcc, we may get the symbols in different order in [`btree_alloc`](https://sourceforge.net/p/sdcc/code/HEAD/tree/trunk/sdcc/src/SDCCbtree.cc#l152), thus different machine code may be generated (especially on macOS)
    
     
  • Benedikt Freisen

    Output reproducibility is a known issue, but there is currently no consensus on how to handle it.
    The central question is whether or not fully reproducible compiler output justifies the potential performance penalties.

     
    • Philipp Klaus Krause

      I think for this case (btree_alloc), we should aim for reproducibility. The performance cost is relatively low (e.g. sort the symbols by name instead of pointer value). AFAIK we do not spend that much time in here (SDCC tends to spend most of its time in register allocation and peephole optimization).
      And the nondeterminism here is a rather bad one, as it can change from one run to the next (while the one in the register allocator will only give different results depending on the libraries present at configure and compile time).

       

      Last edit: Philipp Klaus Krause 2023-01-21
  • Philipp Klaus Krause

    • assigned_to: Philipp Klaus Krause
     
  • Philipp Klaus Krause

    • Category: Front-end --> other
     
  • Philipp Klaus Krause

    • status: open --> closed-fixed
     
  • Philipp Klaus Krause

    Fixed in [r13809].

     

    Related

    Commit: [r13809]


Log in to post a comment.

MongoDB Logo MongoDB