MPS issue job003446

TitleOptimization possibility for NOTREACHED in RASH variety
Statussuspended
Prioritynice
Assigned userGareth Rees
OrganizationRavenbrook
DescriptionIn the RASH variety we define NOTREACHED as expanding to NOOP.

    #define NOTREACHED NOOP

Compilers would have more opportunities for optimization if we indicated that we believe this statement is not reachable.

This might also improve the accuracy of the test coverage report; see job003443.
AnalysisBoth Clang/LLVM [1] and GCC [2] have a builtin for declaring to the compiler that a statement is unreachable, so for these compilers we could use:

    #define NOTREACHED __builtin_unreachable()

RB says that there are other builtins for providing hints like "this is the more/less likely branch to take". For example, the various assertion macros could say "less likely" and that might prompt the compiler to move them out of the main line of execution.

We would want to do some measurement before deciding that any of this was worthwhile, of course.

GDR 2013-05-16: I tried this out, and it neither improves the runtime of the test suite, nor does it improve the accuracy of the coverage reporting. So I marked this job as suspended.
How foundinspection
Evidence[1] <http://clang.llvm.org/docs/LanguageExtensions.html#builtin-unreachable>
[2] <http://gcc.gnu.org/onlinedocs/gcc-4.5....t_005f_005fbuiltin_005funreachable-3030>
Observed in1.110.0
Created byGareth Rees
Created on2013-03-14 14:26:59
Last modified byGareth Rees
Last modified on2013-05-16 11:47:49
History2013-03-14 GDR Created.
2013-05-16 GDR Suspended.