SPRUI04F july 2015 – april 2023
You can control program-level optimization, which you invoke with --program_level_compile --opt_level=3, by using the --call_assumptions option. Specifically, the --call_assumptions option indicates if functions in other modules can call a module's external functions or modify a module's external variables. The number following --call_assumptions indicates the level you set for the module that you are allowing to be called or modified. The --opt_level=3 option combines this information with its own file-level analysis to decide whether to treat this module's external function and variable declarations as if they had been declared static. Use Table 4-3 to select the appropriate level to append to the --call_assumptions option.
If Your Module … | Use this Option |
---|---|
Has functions that are called from other modules and global variables that are modified in other modules | --call_assumptions=0 |
Does not have functions that are called by other modules but has global variables that are modified in other modules | --call_assumptions=1 |
Does not have functions that are called by other modules or global variables that are modified in other modules | --call_assumptions=2 |
Has functions that are called from other modules but does not have global variables that are modified in other modules | --call_assumptions=3 |
In certain circumstances, the compiler reverts to a different --call_assumptions level from the one you specified, or it might disable program-level optimization altogether. Table 4-4 lists the combinations of --call_assumptions levels and conditions that cause the compiler to revert to other --call_assumptions levels.
If --call_assumptions is... | Under these Conditions... | Then the --call_assumptions Level... |
---|---|---|
Not specified | The --opt_level=3 optimization level was specified | Defaults to --call_assumptions=2 |
Not specified | The compiler sees calls to outside functions under the --opt_level=3 optimization level | Reverts to --call_assumptions=0 |
Not specified | Main is not defined | Reverts to --call_assumptions=0 |
--call_assumptions=1 or --call_assumptions=2 | No function has main defined as an entry point, and no interrupt functions are defined, and no functions are identified by the FUNC_EXT_CALLED pragma | Reverts to --call_assumptions=0 |
--call_assumptions=1 or --call_assumptions=2 | A main function is defined, or, an interrupt function is defined, or a function is identified by the FUNC_EXT_CALLED pragma | Remains --call_assumptions=1 or --call_assumptions=2 |
--call_assumptions=3 | Any condition | Remains --call_assumptions=3 |
In some situations when you use --program_level_compile and --opt_level=3, you must use a --call_assumptions option or the FUNC_EXT_CALLED pragma. See Section 4.4.2 for information about these situations.