-OnCopyDown: Do Generate Copy Down Information for Zero Values

Group

OPTIMIZATIONS

Scope

Compilation unit

Syntax
  -OnCopyDown
  
  
Arguments

None

Default

None

Defines

None

Pragmas

None

Description

Startup code usually clears all global variables to zero (zero out) and copies any non-zero initialization values to the variables (copy down). Because of this, it is not necessary to copy zero values unless the usual startup code is modified. If a modified startup code contains a copy down but not a zero out, use this option to prevent the compiler from removing the initialization.

Note: The case of a copy down without a zero out is unusual. Because the copy down needs much more space than the zero out, code usually contains copy down and zero out, zero out alone, or neither.

In the HIWARE format, the object-file format permits the Compiler to remove single assignments in a structure or array initialization. In the ELF format, the Compiler optimizes only when the whole array or structure is initialized with zero.

Note: This option controls the optimizations done in the compiler. However, the linker might further optimize the copy down or the zero out.
Example
  int i=0;

  
  int arr[10]={1,0,0,0,0,0,0,0,0,0};

  

Using this option, the compiler does not generate a copy down for i.

The initialization with zero optimization shown for the arr array only works in the HIWARE format. The ELF format requires initializing the whole array to zero.