Skip to content

Commit b10dda6

Browse files
committed
Frontend: Don't record request references in WMO builds
Part of <rdar://problem/72906325>.
1 parent 539eaca commit b10dda6

File tree

5 files changed

+26
-4
lines changed

5 files changed

+26
-4
lines changed

include/swift/AST/DependencyCollector.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class NominalTypeDecl;
2727

2828
namespace evaluator {
2929

30-
struct DependencyRecorder;
30+
class DependencyRecorder;
3131

3232
/// A \c DependencyCollector defines an abstract write-only buffer of
3333
/// \c Reference objects. References are added to a collector during the write

include/swift/AST/EvaluatorDependencies.h

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,13 @@ using DependencySource = swift::NullablePtr<SourceFile>;
4747

4848
/// A \c DependencyRecorder is an aggregator of named references discovered in a
4949
/// particular \c DependencyScope during the course of request evaluation.
50-
struct DependencyRecorder {
50+
class DependencyRecorder {
5151
friend DependencyCollector;
5252

53-
private:
53+
/// Whether we are performing an incremental build and should therefore
54+
/// record request references.
55+
bool shouldRecord;
56+
5457
/// References recorded while evaluating a dependency source request for each
5558
/// source file. This map is updated upon completion of a dependency source
5659
/// request, and includes all references from each downstream request as well.
@@ -82,6 +85,8 @@ struct DependencyRecorder {
8285
#endif
8386

8487
public:
88+
DependencyRecorder(bool shouldRecord) : shouldRecord(shouldRecord) {}
89+
8590
/// Push a new empty set onto the activeRequestReferences stack.
8691
template<typename Request>
8792
void beginRequest();
@@ -131,6 +136,9 @@ struct DependencyRecorder {
131136

132137
template<typename Request>
133138
void evaluator::DependencyRecorder::beginRequest() {
139+
if (!shouldRecord)
140+
return;
141+
134142
if (!Request::isEverCached && !Request::isDependencySource)
135143
return;
136144

@@ -139,6 +147,9 @@ void evaluator::DependencyRecorder::beginRequest() {
139147

140148
template<typename Request>
141149
void evaluator::DependencyRecorder::endRequest(const Request &req) {
150+
if (!shouldRecord)
151+
return;
152+
142153
if (!Request::isEverCached && !Request::isDependencySource)
143154
return;
144155

@@ -170,6 +181,9 @@ template<typename Request>
170181
void evaluator::DependencyRecorder::replayCachedRequest(const Request &req) {
171182
assert(req.isCached());
172183

184+
if (!shouldRecord)
185+
return;
186+
173187
if (activeRequestReferences.empty())
174188
return;
175189

include/swift/Basic/LangOptions.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,9 @@ namespace swift {
218218
/// Enable named lazy member loading.
219219
bool NamedLazyMemberLoading = true;
220220

221+
/// Whether to record request references for incremental builds.
222+
bool RecordRequestReferences = true;
223+
221224
/// The path to which we should emit GraphViz output for the complete
222225
/// request-evaluator graph.
223226
std::string RequestEvaluatorGraphVizPath;

lib/AST/Evaluator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ Evaluator::Evaluator(DiagnosticEngine &diags, const LangOptions &opts)
6767
: diags(diags),
6868
debugDumpCycles(opts.DebugDumpCycles),
6969
buildDependencyGraph(opts.BuildRequestDependencyGraph),
70-
recorder{} {}
70+
recorder(opts.RecordRequestReferences) {}
7171

7272
void Evaluator::emitRequestEvaluatorGraphViz(llvm::StringRef graphVizPath) {
7373
std::error_code error;

lib/Frontend/Frontend.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,11 @@ bool CompilerInstance::setUpASTContextIfNeeded() {
205205
return false;
206206
}
207207

208+
// For the time being, we only need to record dependencies in batch mode
209+
// and single file builds.
210+
Invocation.getLangOptions().RecordRequestReferences
211+
= !isWholeModuleCompilation();
212+
208213
Context.reset(ASTContext::get(
209214
Invocation.getLangOptions(), Invocation.getTypeCheckerOptions(),
210215
Invocation.getSearchPathOptions(),

0 commit comments

Comments
 (0)