Files
carbon-lang/toolchain/lower/options.h
T
Geoff Romer fd9200ebc3 Disable InstNamer in lowering unless we're emitting textual llvm IR (#7878)
`InstNamer` takes O(N^2) time to resolve N colliding inst names, so it
should be limited to textual dumps (where we can presumably prioritize
readability over performance). Without this change, compiling 200,000
destructor calls took hours. With this change, compiling 1,000,000
destructor calls takes about 30 seconds.
2026-10-01 00:10:11 +00:00

51 lines
1.6 KiB
C++

// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#ifndef CARBON_TOOLCHAIN_LOWER_OPTIONS_H_
#define CARBON_TOOLCHAIN_LOWER_OPTIONS_H_
#include "llvm/Support/raw_ostream.h"
namespace Carbon::Lower {
enum class OptimizationLevel {
// No optimizations beyond necessary ones like inlining always-inline
// functions. Corresponds to Clang -O0.
None,
// Perform optimizations that make the build faster and don't degrade
// debugging. Corresponds to Clang -O1 or -Og.
Debug,
// Optimize for binary size. Corresponds to Clang -Oz.
Size,
// Optimize for program execution speed. Corresponds to Clang -O3.
Speed,
};
struct LowerToLLVMOptions {
// Options must be set individually, not through initialization.
explicit LowerToLLVMOptions() = default;
// If set, enables LLVM IR verification.
llvm::raw_ostream* llvm_verifier_stream = nullptr;
// Whether to include debug info in lowered output.
bool want_debug_info = false;
// If set, enables verbose output.
llvm::raw_ostream* vlog_stream = nullptr;
// The optimization level to set on lowered functions by default.
OptimizationLevel opt_level = OptimizationLevel::Debug;
// Whether to use the string form of the fingerprint for mangling.
bool mangle_string_fingerprint = false;
// Whether to generate names for LLVM instructions.
bool generate_inst_names = false;
};
} // namespace Carbon::Lower
#endif // CARBON_TOOLCHAIN_LOWER_OPTIONS_H_