Optimizations in CCS
--------------------

Project-Wide Optimizations
^^^^^^^^^^^^^^^^^^^^^^^^^^

Open the project optimization settings by going to ``Project Properties``
|rarr| ``CCS Build`` |rarr| ``ARM Compiler`` |rarr| ``Optimization``

.. figure:: /debugging/resources/ccs_optim_level_project.png
    :align: center

    Project-level optimization setting in CCS

.. figure:: /debugging/resources/ccs_theia_optim_level_project.png
    :align: center

    Project-level optimization setting in CCS Theia


Single-File Optimizations
^^^^^^^^^^^^^^^^^^^^^^^^^

.. note::
   Do single-file optimizations with care because this also overrides the
   project-wide preprocessor symbols.

1. Right-click on the file in the Workspace pane.

2. Choose Properties.

3. Change the optimization level of the file using the same menu in the CCS
   project-wide optimization menu.

Single-Function Optimizations
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. warning::
    Care must be taken when using pragmas, since they are very specific to the toolchain and may render non-reusable code. 

.. important::
    The TI ARM Clang compiler does not support single-function optimizations. Use Single File optimizations instead.
	For additional details, check section 3 of the `TI ARM Clang User's Guide <https://software-dl.ti.com/codegen/docs/tiarmclang/rel1_0_0_sts/tiarmclang_ug/tiarmclang-portfolio/index.html>`_.

.. code-block:: c
   :caption: Function-level optimization setting in gcc
   :emphasize-lines: 1,2,8

   #pragma GCC push_options
   #pragma GCC optimize ("O0")
   static void myFunction(int number)
   {
       // ...
       return yourFunction(other_number);
   }
   #pragma GCC pop_options
