Uploaded image for project: 'Embedded Software & Tools'
  1. Embedded Software & Tools
  2. EXT_EP-11470

During initialization with a designated initializer, constant values are copied to a temp location on the stack, then to the final destination

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: Medium Medium

      The attached file has these lines ...

      void fxn()
      {
          Global.var = (tsArray) { .array = {100, 101, 102, 103, 104} };
      }
      

      Build it ...

      cl2000 -s -o --unified_memory file.c
      

      Inspect file.asm to see that an array of values is created in .const. That array is copied into a temporary array on the stack, then the temporary array on the stack is copied to Global.var. This is inefficient. Eliminate the use of the temporary array on the stack.

      In this cutdown test case, the inefficiency does not look that bad. In the customer use case, the array of values is very large. It overflowed the stack.

            syncuser TI User
            syncuser TI User
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: