Tool News
 
 
 

Tool News

Products Info
Downloads
Tools FAQs
MAEC TOOL NEWS: MAECT-M3T-CC32R-011201D

M3T-CC32R
Precaution

Please take note of the following problem in using cross-tool kit M3T-CC32R for the M32R family MCUs.
  • On optimization at a function taking 4 arguments or more which calls another function taking 3 arguments or less.


  1. Versions Concerned
    M3T-CC32R V.1.00 Release 1 -- V.3.10 Release 1

  2. Description
    When an optimizing option covering the -04 option is used for a program in which a function taking 4 arguments or more calls another function taking 3 arguments or less, the fourth argument of the former may be treated incorrectly.
    2.1 Conditions
    This problem may occur if the following six conditions are satisfied:
    (1) An optimizing option covering the -O4 option is used (any of the following options is selected: -O4, -O5, -O6, -O7, -Otime only, or -Ospace only).
    (2) A function have 4 or more arguments and the first four arguments are of respective types that can be passed to registers, (that is, either integer, pointer, or float-type variables). *1)
    (3) Any of the following variables are dynamically initialized or assigned a value in the function described in (2) above:
    (a) a whole structure
    (b) a variable of type double
    (c) an array
    (4) After the processing of (3), a function taking 3 arguments or less is called from the function described in (2).
    (5) After the function call in (4), the fourth argument of the function described in (2) is referenced.
    (6) The dynamic initialization or assignment in (3) is replaced with a _100_builtin_memcopy function at compilation. *2)

    Notes:
    *1) This condition cannot be met in CC32R V.2.10 and earlier because no variables of type float are passed to registers in these versions.
    *2) To check whether Condition (6) is met or not, search for a character string "_100_builtin_memcopy" in the assembly source file generated with the -S option used. For details of how to check this, see the latter half of the following section.

    2.2 Examples
    Example 1: Source file "sample1.c"
    --------------------------------------------------------------------
    extern int foo1(int, int, int);
    struct {int a; int b[30]; int c;} A, B;
    
    int
    func1(int a, int b, int c, int d)   /* Condition (2) */
    {
         A = B;                         /* Condition (3)-(a):
                                           Assigns a structure B to A */
         foo1(a, b, c);                 /* Condition (4) */
         return d;                      /* Condition (5) */
    }
    --------------------------------------------------------------------
    
    Example 2: Source file "sample2.c"
    --------------------------------------------------------------------
    extern int foo2(int, int, int)
    
    int
    func2(int a,int b,int c,int d)     /* Condition (2) */
    {
         int x[3] = {193,156,119};     /* Condition (3)-(c) */
         foo2(x[a], b, c);             /* Condition (4) */
         return d;                     /* Condition (5) */
    }
    --------------------------------------------------------------------
    
    Example of typing commands in M3T-CC32R (a % sign denotes a prompt)
    --------------------------------------------------------------------
    In "sample1.c"
      % cc32R -S -O4 sample1.c                    ; Condition (1) met.
      % find "_100_builtin_memcopy" sample1.ms    ; Condition (6) checked.
    
      If Condition (6) met:
      ---------------------------------------
      ---------- sample1.ms
              .IMPORT $_100_builtin_memcopy
              BL      $_100_builtin_memcopy
    
      If Condition (6) not met:
      ---------------------------------------
      ---------- sample1.ms                       ; Nothing displayed.
    
    In "sample2.c"
      % cc32R -S -Ospace sample2.c                ; Condition (1) met.
      % find "_100_builtin_memcopy" sample2.ms    ; Condition (6) checked.
    
      If Condition (6) met:
      ---------------------------------------
      ---------- sample2.ms               .IMPORT $_100_builtin_memcopy
              BL      $_100_builtin_memcopy
    
      If Condition (6) not met:
      ---------------------------------------
      ---------- sample2.ms                       ; Nothing displayed.
    --------------------------------------------------------------------
    Note: On UNIX-based EWS, use a grep command instead of a find command.

  3. Workaround
    This problem will be circumvented in any of the following ways:
    (1) Suppress optimization in the -O4 level.
    Optimization covering the -O4 option will be performed when optimizing option -04, -O5, -O6, -O7, -Otime only or -Ospace only has been selected. If you want to use -Otime or -Ospace, select any of these options, -O0, -O1, -O2, and -O3, at the same time.
    (2) Change the dynamic initialization of a variable or the assignment of a value to a variable into the call of a memcpy function that produces the equivalent result.
    [Example 1: Modification of Source file "sample1.c"]
    --------------------------------------------------------------------
    #include <string.h>             /* Added to call a memcpy function */
    extern int foo1(int, int, int);
    struct {int a; int b[30]; int c;} A, B;
    
    int
    func1(int a, int b, int c, int d)
    {
         memcpy(&A, &B, sizeof(A));  /* Assigning a structure changed 
                                        to calling a memcpy function */
         foo1(a, b, c);
         return d;
    }
    --------------------------------------------------------------------
    
    [Example 2: Modification of Source file "sample2.c"]
    --------------------------------------------------------------------
    #include <string.h>            /* Added to call a memcpy function */
    extern int foo2(int, int, int)
    
    int
    func2(int a,int b,int c,int d)
    {          int x[3];                       /* Initialization of 
                                                  array x canceled */
         static int x_init[3] = {193,156,119}; /* Added to declare and 
                                               initialize array x_init */
         memcpy(x, x_init, sizeof(x));        /* A memcpy function called 
                                                 to initialize array x */
         foo2(x[a], b, c);
         return d;     }
    --------------------------------------------------------------------
    (3) Change dynamic initialization to static initialization.
    Note that this circumvention cannot be applied to any programs that assume dynamic initialization.
    [Example 3: Modification of Source file "sample2.c"]
    --------------------------------------------------------------------
    extern int foo2(int, int, int)
    
    int
    func2(int a,int b,int c,int d)
    {
         static int x[3] = {193,156,119};     /* Dynamic initialization 
                                                 changed to static one */
         foo2(x[a], b, c);
         return d;
    }
    --------------------------------------------------------------------
  4. Schedule of Fixing the Problem
    We plan to fix this problem in our next release.




© 2008. Renesas Technology Corp., All rights reserved. Privacy | Legal