Skip to content

Commit 06c5bda

Browse files
authored
Merge pull request #78182 from nkcsgexi/fine-trace-opt-out-6.1
🍒[6.1] Frontend: set-up mechanisms to opt-out of collecting fine grained module tracing
2 parents 1b742c0 + 8253cdb commit 06c5bda

File tree

6 files changed

+28
-1
lines changed

6 files changed

+28
-1
lines changed

include/swift/Basic/BlockListAction.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@ BLOCKLIST_ACTION(ShouldUseBinaryModule)
2323
BLOCKLIST_ACTION(ShouldUseTextualModule)
2424
BLOCKLIST_ACTION(DowngradeInterfaceVerificationFailure)
2525
BLOCKLIST_ACTION(ShouldUseLayoutStringValueWitnesses)
26+
BLOCKLIST_ACTION(SkipEmittingFineModuleTrace)
2627

2728
#undef BLOCKLIST_ACTION

include/swift/Frontend/FrontendOptions.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,10 @@ class FrontendOptions {
565565

566566
/// All block list configuration files to be honored in this compilation.
567567
std::vector<std::string> BlocklistConfigFilePaths;
568+
569+
/// Whether explicitly disble fine-grained module tracing in this compiler
570+
/// invocation.
571+
bool DisableFineModuleTracing = false;
568572
private:
569573
static bool canActionEmitDependencies(ActionType);
570574
static bool canActionEmitReferenceDependencies(ActionType);

include/swift/Option/FrontendOptions.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,6 +1241,10 @@ def skip_import_in_public_interface:
12411241
HelpText<"Skip the import statement corresponding to a module name "
12421242
"when printing the public interface.">;
12431243

1244+
def disable_fine_module_tracing:
1245+
Flag<["-"], "disable-fine-module-tracing">,
1246+
HelpText<"Skip the emission of fine grained module tracing file.">;
1247+
12441248
def clang_header_expose_decls:
12451249
Joined<["-"], "clang-header-expose-decls=">,
12461250
HelpText<"Which declarations should be exposed in the generated clang header.">,

lib/Frontend/ArgsToFrontendOptionsConverter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ bool ArgsToFrontendOptionsConverter::convert(
386386
}
387387

388388
Opts.DisableSandbox = Args.hasArg(OPT_disable_sandbox);
389-
389+
Opts.DisableFineModuleTracing = Args.hasArg(OPT_disable_fine_module_tracing);
390390
return false;
391391
}
392392

lib/FrontendTool/LoadedModuleTrace.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -946,11 +946,17 @@ static bool shouldActionTypeEmitFineModuleTrace(FrontendOptions::ActionType acti
946946

947947
bool swift::emitFineModuleTraceIfNeeded(CompilerInstance &Instance,
948948
const FrontendOptions &opts) {
949+
if (opts.DisableFineModuleTracing) {
950+
return false;
951+
}
949952
if (!shouldActionTypeEmitFineModuleTrace(opts.RequestedAction)) {
950953
return false;
951954
}
952955
ModuleDecl *mainModule = Instance.getMainModule();
953956
ASTContext &ctxt = mainModule->getASTContext();
957+
if (ctxt.blockListConfig.hasBlockListAction(mainModule->getNameStr(),
958+
BlockListKeyKind::ModuleName, BlockListAction::SkipEmittingFineModuleTrace))
959+
return false;
954960
assert(!ctxt.hadError() &&
955961
"We should've already exited earlier if there was an error.");
956962

test/IDE/objc_send_collector_1.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,18 @@
1010
// RUN: SWIFT_COMPILER_FINE_GRAINED_TRACE_PATH=%t/given_trace_2.json %target-swift-frontend -I %t/lib/swift -emit-module %s %S/Inputs/objc_send_collector_2.swift -module-name main -swift-version 5 -F %S/Inputs/mock-sdk -emit-loaded-module-trace-path %t/.MODULE_TRACE -enable-library-evolution
1111
// RUN: not ls %t/given_trace_2.json
1212

13+
14+
// RUN: echo "---" > %t/blocklist.yml
15+
// RUN: echo "SkipEmittingFineModuleTrace:" >> %t/blocklist.yml
16+
// RUN: echo " ModuleName:" >> %t/blocklist.yml
17+
// RUN: echo " - FooBar" >> %t/blocklist.yml
18+
19+
// RUN: SWIFT_COMPILER_FINE_GRAINED_TRACE_PATH=%t/given_trace_3.json %target-swift-frontend -I %t/lib/swift -typecheck %s %S/Inputs/objc_send_collector_2.swift -module-name FooBar -swift-version 5 -F %S/Inputs/mock-sdk -emit-loaded-module-trace-path %t/.MODULE_TRACE -blocklist-file %t/blocklist.yml
20+
// RUN: not ls %t/given_trace_3.json
21+
22+
// RUN: SWIFT_COMPILER_FINE_GRAINED_TRACE_PATH=%t/given_trace_4.json %target-swift-frontend -I %t/lib/swift -typecheck %s %S/Inputs/objc_send_collector_2.swift -module-name FooBar -swift-version 5 -F %S/Inputs/mock-sdk -emit-loaded-module-trace-path %t/.MODULE_TRACE -disable-fine-module-tracing
23+
// RUN: not ls %t/given_trace_4.json
24+
1325
// REQUIRES: objc_interop
1426

1527
import Foo

0 commit comments

Comments
 (0)