mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Add a new frontend option for debugging called '-disable-incremental-llvm-codegen'.
Currently IRGen stores hashes of the bitcode generated by swift in object files. This is then used to reduce compile time by not re-codegening if a subsequent compilation yields a bit code with the same hash. This is good for users and general compilation, but can result in confusion when attempting to measure the "real" compile time of the compiler. By default it is off.
This commit is contained in:
@@ -145,6 +145,13 @@ public:
|
|||||||
/// List of backend command-line options for -embed-bitcode.
|
/// List of backend command-line options for -embed-bitcode.
|
||||||
std::vector<uint8_t> CmdArgs;
|
std::vector<uint8_t> CmdArgs;
|
||||||
|
|
||||||
|
/// Should we try to build incrementally by not emitting an object file if it
|
||||||
|
/// has the same IR hash as the module that we are preparing to emit?
|
||||||
|
///
|
||||||
|
/// This is a debugging option meant to make it easier to perform compile time
|
||||||
|
/// measurements on a non-clean build directory.
|
||||||
|
unsigned UseIncrementalLLVMCodeGen : 1;
|
||||||
|
|
||||||
IRGenOptions() : OutputKind(IRGenOutputKind::LLVMAssembly), Verify(true),
|
IRGenOptions() : OutputKind(IRGenOutputKind::LLVMAssembly), Verify(true),
|
||||||
Optimize(false), DebugInfoKind(IRGenDebugInfoKind::None),
|
Optimize(false), DebugInfoKind(IRGenDebugInfoKind::None),
|
||||||
UseJIT(false), DisableLLVMOptzns(false),
|
UseJIT(false), DisableLLVMOptzns(false),
|
||||||
@@ -153,7 +160,8 @@ public:
|
|||||||
EmitStackPromotionChecks(false), GenerateProfile(false),
|
EmitStackPromotionChecks(false), GenerateProfile(false),
|
||||||
PrintInlineTree(false), EmbedMode(IRGenEmbedMode::None),
|
PrintInlineTree(false), EmbedMode(IRGenEmbedMode::None),
|
||||||
HasValueNamesSetting(false), ValueNames(false),
|
HasValueNamesSetting(false), ValueNames(false),
|
||||||
StripReflectionNames(true), StripReflectionMetadata(true)
|
StripReflectionNames(true), StripReflectionMetadata(true),
|
||||||
|
CmdArgs(), UseIncrementalLLVMCodeGen(true)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/// Gets the name of the specified output filename.
|
/// Gets the name of the specified output filename.
|
||||||
|
|||||||
@@ -296,6 +296,10 @@ def print_inst_counts : Flag<["-"], "print-inst-counts">,
|
|||||||
def print_llvm_inline_tree : Flag<["-"], "print-llvm-inline-tree">,
|
def print_llvm_inline_tree : Flag<["-"], "print-llvm-inline-tree">,
|
||||||
HelpText<"Print the LLVM inline tree.">;
|
HelpText<"Print the LLVM inline tree.">;
|
||||||
|
|
||||||
|
def disable_incremental_llvm_codegeneration :
|
||||||
|
Flag<["-"], "disable-incremental-llvm-codegen">,
|
||||||
|
HelpText<"Disable incremental llvm code generation.">;
|
||||||
|
|
||||||
def emit_sorted_sil : Flag<["-"], "emit-sorted-sil">,
|
def emit_sorted_sil : Flag<["-"], "emit-sorted-sil">,
|
||||||
HelpText<"When printing SIL, print out all sil entities sorted by name to "
|
HelpText<"When printing SIL, print out all sil entities sorted by name to "
|
||||||
"ease diffing">;
|
"ease diffing">;
|
||||||
|
|||||||
@@ -1202,6 +1202,10 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
|
|||||||
Opts.GenerateProfile |= Args.hasArg(OPT_profile_generate);
|
Opts.GenerateProfile |= Args.hasArg(OPT_profile_generate);
|
||||||
Opts.PrintInlineTree |= Args.hasArg(OPT_print_llvm_inline_tree);
|
Opts.PrintInlineTree |= Args.hasArg(OPT_print_llvm_inline_tree);
|
||||||
|
|
||||||
|
// This is set to true by default.
|
||||||
|
Opts.UseIncrementalLLVMCodeGen &=
|
||||||
|
!Args.hasArg(OPT_disable_incremental_llvm_codegeneration);
|
||||||
|
|
||||||
if (Args.hasArg(OPT_embed_bitcode))
|
if (Args.hasArg(OPT_embed_bitcode))
|
||||||
Opts.EmbedMode = IRGenEmbedMode::EmbedBitcode;
|
Opts.EmbedMode = IRGenEmbedMode::EmbedBitcode;
|
||||||
else if (Args.hasArg(OPT_embed_bitcode_marker))
|
else if (Args.hasArg(OPT_embed_bitcode_marker))
|
||||||
|
|||||||
@@ -304,7 +304,7 @@ static bool performLLVM(IRGenOptions &Opts, DiagnosticEngine &Diags,
|
|||||||
llvm::Module *Module,
|
llvm::Module *Module,
|
||||||
llvm::TargetMachine *TargetMachine,
|
llvm::TargetMachine *TargetMachine,
|
||||||
StringRef OutputFilename) {
|
StringRef OutputFilename) {
|
||||||
if (HashGlobal) {
|
if (Opts.UseIncrementalLLVMCodeGen && HashGlobal) {
|
||||||
// Check if we can skip the llvm part of the compilation if we have an
|
// Check if we can skip the llvm part of the compilation if we have an
|
||||||
// existing object file which was generated from the same llvm IR.
|
// existing object file which was generated from the same llvm IR.
|
||||||
MD5::MD5Result Result;
|
MD5::MD5Result Result;
|
||||||
|
|||||||
Reference in New Issue
Block a user