LLVM 24.0.0git
OptimizationLevel.h
Go to the documentation of this file.
1//===-------- LLVM-provided High-Level Optimization levels -*- C++ -*------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8/// \file
9///
10/// This header enumerates the LLVM-provided high-level optimization levels.
11/// Each level has a specific goal and rationale.
12///
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_PASSES_OPTIMIZATIONLEVEL_H
16#define LLVM_PASSES_OPTIMIZATIONLEVEL_H
17
19#include <assert.h>
20
21namespace llvm {
22
24 /// Disable as many optimizations as possible. This doesn't completely
25 /// disable the optimizer in all cases, for example always_inline functions
26 /// can be required to be inlined for correctness.
27 O0 = 0,
28
29 /// Optimize quickly without destroying debuggability.
30 ///
31 /// This level is tuned to produce a result from the optimizer as quickly
32 /// as possible and to avoid destroying debuggability. This tends to result
33 /// in a very good development mode where the compiled code will be
34 /// immediately executed as part of testing. As a consequence, where
35 /// possible, we would like to produce efficient-to-execute code, but not
36 /// if it significantly slows down compilation or would prevent even basic
37 /// debugging of the resulting binary.
38 ///
39 /// As an example, complex loop transformations such as versioning,
40 /// vectorization, or fusion don't make sense here due to the degree to
41 /// which the executed code differs from the source code, and the compile
42 /// time cost.
43 O1 = 1,
44
45 /// Optimize for fast execution as much as possible without triggering
46 /// significant incremental compile time or code size growth.
47 ///
48 /// The key idea is that optimizations at this level should "pay for
49 /// themselves". So if an optimization increases compile time by 5% or
50 /// increases code size by 5% for a particular benchmark, that benchmark
51 /// should also be one which sees a 5% runtime improvement. If the compile
52 /// time or code size penalties happen on average across a diverse range of
53 /// LLVM users' benchmarks, then the improvements should as well.
54 ///
55 /// And no matter what, the compile time needs to not grow superlinearly
56 /// with the size of input to LLVM so that users can control the runtime of
57 /// the optimizer in this mode.
58 ///
59 /// This is expected to be a good default optimization level for the vast
60 /// majority of users.
61 O2 = 2,
62 /// Optimize for fast execution as much as possible.
63 ///
64 /// This mode is significantly more aggressive in trading off compile time
65 /// and code size to get execution time improvements. The core idea is that
66 /// this mode should include any optimization that helps execution time on
67 /// balance across a diverse collection of benchmarks, even if it increases
68 /// code size or compile time for some benchmarks without corresponding
69 /// improvements to execution time.
70 ///
71 /// Despite being willing to trade more compile time off to get improved
72 /// execution time, this mode still tries to avoid superlinear growth in
73 /// order to make even significantly slower compile times at least scale
74 /// reasonably. This does not preclude very substantial constant factor
75 /// costs though.
76 O3 = 3,
77};
78} // namespace llvm
79
80#endif
This is an optimization pass for GlobalISel generic memory operations.
@ O1
Optimize quickly without destroying debuggability.
@ O0
Disable as many optimizations as possible.
@ O3
Optimize for fast execution as much as possible.
@ O2
Optimize for fast execution as much as possible without triggering significant incremental compile ti...