[Incremental] Plumb -verify-incremental-dependencies Through The Frontend and Driver

When enabled at the driver level, the frontends will inherit the flag. For each frontend that recieves this option, all primaries will have their reference dependencies validated.
This commit is contained in:
Robert Widmann
2020-02-28 15:28:42 -08:00
parent 101dd2d9f7
commit d3edb5b15a
8 changed files with 45 additions and 1 deletions

View File

@@ -159,6 +159,9 @@ WARNING(warn_ignore_embed_bitcode_marker, none,
WARNING(verify_debug_info_requires_debug_option,none, WARNING(verify_debug_info_requires_debug_option,none,
"ignoring '-verify-debug-info'; no debug info is being generated", ()) "ignoring '-verify-debug-info'; no debug info is being generated", ())
ERROR(verify_incremental_dependencies_needs_incremental,none,
"'-verify-incremental-dependencies' requires '-incremental'", ())
ERROR(error_profile_missing,none, ERROR(error_profile_missing,none,
"no profdata file exists at '%0'", (StringRef)) "no profdata file exists at '%0'", (StringRef))

View File

@@ -21,7 +21,9 @@
#include "swift/Basic/LLVM.h" #include "swift/Basic/LLVM.h"
namespace swift { namespace swift {
class FileUnit;
class SourceManager; class SourceManager;
class SourceFile;
/// Set up the specified source manager so that diagnostics are captured /// Set up the specified source manager so that diagnostics are captured
/// instead of being printed. /// instead of being printed.
@@ -34,6 +36,9 @@ namespace swift {
/// This returns true if there are any mismatches found. /// This returns true if there are any mismatches found.
bool verifyDiagnostics(SourceManager &SM, ArrayRef<unsigned> BufferIDs, bool verifyDiagnostics(SourceManager &SM, ArrayRef<unsigned> BufferIDs,
bool autoApplyFixes, bool ignoreUnknown); bool autoApplyFixes, bool ignoreUnknown);
bool verifyDependencies(SourceManager &SM, ArrayRef<FileUnit *> SFs);
bool verifyDependencies(SourceManager &SM, ArrayRef<SourceFile *> SFs);
} }
#endif #endif

View File

@@ -263,6 +263,9 @@ public:
/// Should we lock .swiftinterface while generating .swiftmodule from it? /// Should we lock .swiftinterface while generating .swiftmodule from it?
bool DisableInterfaceFileLock = false; bool DisableInterfaceFileLock = false;
/// Should we enable the dependency verifier for all primary files known to this frontend?
bool VerifyDependencies = false;
/// The different modes for validating TBD against the LLVM IR. /// The different modes for validating TBD against the LLVM IR.
enum class TBDValidationMode { enum class TBDValidationMode {
Default, ///< Do the default validation for the current platform. Default, ///< Do the default validation for the current platform.

View File

@@ -184,6 +184,11 @@ Flag<["-"], "driver-verify-fine-grained-dependency-graph-after-every-import">,
InternalDebugOpt, InternalDebugOpt,
HelpText<"Debug DriverGraph by verifying it after every import">; HelpText<"Debug DriverGraph by verifying it after every import">;
def verify_incremental_dependencies :
Flag<["-"], "verify-incremental-dependencies">,
Flags<[FrontendOption, HelpHidden]>,
HelpText<"Enable the dependency verifier for each frontend job">;
def driver_emit_fine_grained_dependency_dot_file_after_every_import : def driver_emit_fine_grained_dependency_dot_file_after_every_import :
Flag<["-"], "driver-emit-fine-grained-dependency-dot-file-after-every-import">, Flag<["-"], "driver-emit-fine-grained-dependency-dot-file-after-every-import">,
InternalDebugOpt, InternalDebugOpt,

View File

@@ -179,6 +179,24 @@ static void validateDebugInfoArgs(DiagnosticEngine &diags,
diags.diagnose(SourceLoc(), diag::error_invalid_debug_prefix_map, A); diags.diagnose(SourceLoc(), diag::error_invalid_debug_prefix_map, A);
} }
static void validateVerifyIncrementalArgs(DiagnosticEngine &diags,
const ArgList &args) {
// No option? No problem!
if (!args.hasArg(options::OPT_verify_incremental_dependencies)) {
return;
}
// Make sure we see -incremental but not -wmo, no matter in what order they're
// in - the build systems can pass them both and just hope the last one wins.
if (args.hasArg(options::OPT_incremental) &&
!args.hasArg(options::OPT_whole_module_optimization)) {
return;
}
diags.diagnose(SourceLoc(),
diag::verify_incremental_dependencies_needs_incremental);
}
static void validateCompilationConditionArgs(DiagnosticEngine &diags, static void validateCompilationConditionArgs(DiagnosticEngine &diags,
const ArgList &args) { const ArgList &args) {
for (const Arg *A : args.filtered(options::OPT_D)) { for (const Arg *A : args.filtered(options::OPT_D)) {
@@ -239,6 +257,7 @@ static void validateArgs(DiagnosticEngine &diags, const ArgList &args,
validateCompilationConditionArgs(diags, args); validateCompilationConditionArgs(diags, args);
validateSearchPathArgs(diags, args); validateSearchPathArgs(diags, args);
validateAutolinkingArgs(diags, args, T); validateAutolinkingArgs(diags, args, T);
validateVerifyIncrementalArgs(diags, args);
} }
std::unique_ptr<ToolChain> std::unique_ptr<ToolChain>

View File

@@ -254,7 +254,9 @@ static void addCommonFrontendArgs(const ToolChain &TC, const OutputInfo &OI,
inputArgs.AddLastArg(arguments, options::OPT_disable_parser_lookup); inputArgs.AddLastArg(arguments, options::OPT_disable_parser_lookup);
inputArgs.AddLastArg(arguments, inputArgs.AddLastArg(arguments,
options::OPT_enable_experimental_concise_pound_file); options::OPT_enable_experimental_concise_pound_file);
inputArgs.AddLastArg(arguments,
options::OPT_verify_incremental_dependencies);
// Pass on any build config options // Pass on any build config options
inputArgs.AddAllArgs(arguments, options::OPT_D); inputArgs.AddAllArgs(arguments, options::OPT_D);

View File

@@ -176,6 +176,7 @@ bool ArgsToFrontendOptionsConverter::convert(
Opts.EnableSourceImport |= Args.hasArg(OPT_enable_source_import); Opts.EnableSourceImport |= Args.hasArg(OPT_enable_source_import);
Opts.ImportUnderlyingModule |= Args.hasArg(OPT_import_underlying_module); Opts.ImportUnderlyingModule |= Args.hasArg(OPT_import_underlying_module);
Opts.VerifyDependencies |= Args.hasArg(OPT_verify_incremental_dependencies);
computeImportObjCHeaderOptions(); computeImportObjCHeaderOptions();
computeImplicitImportModuleNames(); computeImplicitImportModuleNames();

View File

@@ -1480,6 +1480,12 @@ computeDeallocatableResources(const CompilerInvocation &Invocation,
return DeallocatableResources::SILModule; return DeallocatableResources::SILModule;
} }
// Verifying incremental dependencies relies on access to the Swift Module's
// source files. We can still free the SIL module, though.
if (Invocation.getFrontendOptions().VerifyDependencies) {
return DeallocatableResources::SILModule;
}
// If there are multiple primary inputs it is too soon to free // If there are multiple primary inputs it is too soon to free
// the ASTContext, etc.. OTOH, if this compilation generates code for > 1 // the ASTContext, etc.. OTOH, if this compilation generates code for > 1
// primary input, then freeing it after processing the last primary is // primary input, then freeing it after processing the last primary is