Menu

#3015 Extremely long compile times for big arrays

open
nobody
None
other
5
2020-07-30
2020-06-03
No

char s[2048] = "a";

This takes 28 seconds to compile on my system, on version SDCC : mcs51/z80/z180/r2k/r3ka/gbz80/tlcs90/ez80_z80/z80n/ds390/pic16/pic14/TININative/ds400/hc08/s08/stm8/pdk13/pdk14/pdk15 4.0.2 #0 (Linux) (built from commit 11643).

Discussion

  • Philipp Klaus Krause

    Weirdly, this apparently depends on the backend. I tried a few on my system:

    • stm8: 0s
    • pdk14: 22s
    • z80: 0s
    • mcs51: 23s
    • hc08: 0s
     

    Last edit: Philipp Klaus Krause 2020-06-04
  • Erik Petrich

    Erik Petrich - 2020-06-24

    The backends that initialize data by doing a bulk copy from code memory compile quickly. The others generate the code equivalent of

    s[0]=97;
    s[1]=0;
    s[2]=0;
    s[3]=0;
    ...
    s[2047]=0;
    

    This in turn seems to be choking GCSE and dataflow analysis with several thousand iTemps.

    Since data memory should already be zeroed, couldn't it just initialize the non-zero elements (assuming global or static)?

     
    • Philipp Klaus Krause

      RFE [feature-requests:#342] looks related.
      Currently SDCC only makes a difference between explicitly initalized vs. implicitly initialized, not checking for zeores that could be omitted in DATA.

      A more complicated case would be INITALIZED. There, AFAIK currently is no zero-initalization and everything will be initialized via a copy (0 or not).
      Then there is also RFE [feature-requests:#455] and RFE [feature-requests:#380].

       

      Related

      Feature Requests: #342
      Feature Requests: #380
      Feature Requests: #455


      Last edit: Maarten Brock 2020-07-30

Log in to post a comment.

MongoDB Logo MongoDB