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

Stack usage increased after version 18.1.x.LTS when building with --opt_level=0

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: Low Low

      The attached file contains these lines ...

      switch (switchInput)
          {
              case 1:
              {
                  dummyStruct dummyInstance;
                  dummyFunction(x+11, &dummyInstance);
                  break;
              }
      
              case 2:
              {
                  dummyStruct dummyInstance;
                  dummyFunction(x+12, &dummyInstance);
                  break;
              }
      
              /* 4 more switch cases that are similar */
      

      dummyStruct is 400 bytes. Build it with version 18.1.8.LTS ...

      % armcl --opt_level=0 --src_interlist file.c
      

      Inspect file.asm. Here are some key lines ...

      ; The following local variables in dummyFunctionWithSwitchInside() will be grouped together
      ; to share stack space among distinct scoping blocks.  References
      ; in the source interlisting will look like "O$1.s3_1.u4_2.s4_3.l4_4" or "&$O$O1+0".
      ;
      ;    --offset--    --reference--		 --variable--
      ;
      ;         0	  O$1.s3_1.u4_2.s4_3.l4_4        struct $$fake0 dummyInstance  [file.c:54]
      ;         0	  O$1.s3_1.u4_2.s4_5.l4_6        struct $$fake0 dummyInstance  [file.c:47]
      ;         0	  O$1.s3_1.u4_2.s4_7.l4_8        struct $$fake0 dummyInstance  [file.c:40]
      ;         0	  O$1.s3_1.u4_2.s4_9.l4_10       struct $$fake0 dummyInstance  [file.c:33]
      ;         0	  O$1.s3_1.u4_2.s4_11.l4_12      struct $$fake0 dummyInstance  [file.c:26]
      ;         0	  O$1.s3_1.u4_2.s4_13.l4_14      struct $$fake0 dummyInstance  [file.c:19]
      
      <skip many lines>
      
      ;*****************************************************************************
      ;* FUNCTION NAME: dummyFunctionWithSwitchInside                              *
      ;*                                                                           *
      ;*   Regs Modified     : A1,V9,SP,LR,SR                                      *
      ;*   Regs Used         : A1,V9,SP,LR,SR                                      *
      ;*   Local Frame Size  : 0 Args + 400 Auto + 4 Save = 404 byte               *
      ;*****************************************************************************
      dummyFunctionWithSwitchInside:
      

      Do the same thing with version 20.2.7.LTS. The comment about local variables grouped together is not present. The local frame size for the function is 2404 bytes, 6X more. Change to --opt_level=1, then stack usage is the same as 18.1.8.LTS with --opt_level=0.

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

              Created:
              Updated: