PowerAda Suppressing Run-Time Checks
Suppressing run-time checks is can often save much more space and execution time than any optimization. Of course, this also sacrifices one of the greatest advantages of the Ada language, so is recommended only for performance tuning in well-tested, time-critical code.
When writing code, one should avoid counting on the results of compiler-generated checks during normal execution. By explicitly performing checks where they are required by an algorithm, the code is free to be compiled with checks suppressed if deemed necessary.
There are several different ways to suppress run-time checks. In order of thoroughness, they are:
- the -S option to the compiler
- the implementation-defined pragma SUPPRESS_ALL, and
- the language-defined pragma SUPPRESS.
The -S compiler option suppresses all checks in the code generated for the compilation unit. If the unit is a package specification, the data and code for tracking elaboration of the package is also not generated.
Pragma SUPPRESS_ALL is an implementation-specific pragma which suppresses all checks except for STORAGE_CHECK and ELABORATION_CHECK. Its syntax is:
As with the predefined pragma SUPPRESS, pragma SUPPRESS_ALL is valid in any declarative part or package specification and affects all nested regions.
Pragma SUPPRESS is a language-defined pragma which can be used to suppress specific exception checks which would be generated for code in the scope in which it appears. Its use and arguments are described in <RM95 11.5>.
Pragma NO_SUPPRESS is an implementation-specific pragma that prevents the suppression of checks in a specific scope. Its arguments and placement are the same as for pragma SUPPRESS. Even in the absence of pragma SUPPRESS, pragma NO_SUPPRESS is useful as a documentation tool to indicate that a particular check is being relied upon by an algorithm.
the command line switch
-S overrides this pragma, so use of NO_SUPPRESS is not sufficient to guarantee that checks will remain in a particular unit.