-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

With usual startup code, all global variables are first set to 0 (zero out). If the definition contained an initialization value, this initialization value is copied to the variable (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 normally not used. Because the copy down needs much more space than the zero out, it usually contains copy down and zero out, zero out alone, or none of them.

In the ELF format, the object-file format permits optimization only if the whole array or structure is initialized with 0.

Note: This option controls the optimizations done in the compiler. However, the linker itself 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};
  
  

If this option is present, no copy down is generated for i.

For the arr array, it is not possible to separate initialization with 0 from initialization with 1.