Skip to content

Commit 83be432

Browse files
authored
---
yaml --- r: 349130 b: refs/heads/master c: bd94891 h: refs/heads/master
1 parent 5c36c58 commit 83be432

File tree

8 files changed

+47
-9
lines changed

8 files changed

+47
-9
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 0381ae866683b4cb9c613859ec2b91925856e838
2+
refs/heads/master: bd94891745fbc4c1bcf53213e207f4bf77c073df
33
refs/heads/master-next: 203b3026584ecad859eb328b2e12490099409cd5
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea

trunk/include/swift/SIL/SILDeclRef.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,11 @@ struct SILDeclRef {
249249
bool isStoredPropertyInitializer() const {
250250
return kind == Kind::StoredPropertyInitializer;
251251
}
252+
/// True if the SILDeclRef references the initializer for the backing storage
253+
/// of a property wrapper.
254+
bool isPropertyWrapperBackingInitializer() const {
255+
return kind == Kind::PropertyWrapperBackingInitializer;
256+
}
252257

253258
/// True if the SILDeclRef references the ivar initializer or deinitializer of
254259
/// a class.

trunk/lib/Frontend/Frontend.cpp

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,23 @@ void CompilerInstance::setUpDiagnosticOptions() {
318318
}
319319
}
320320

321+
// The ordering of ModuleLoaders is important!
322+
//
323+
// 1. SourceLoader: This is a hack and only the compiler's tests are using it,
324+
// to avoid writing repetitive code involving generating modules/interfaces.
325+
// Ideally, we'd get rid of it.
326+
// 2. MemoryBufferSerializedModuleLoader: This is used by LLDB, because it might
327+
// already have the module available in memory.
328+
// 3. ModuleInterfaceLoader: Tries to find an up-to-date swiftmodule. If it
329+
// succeeds, it issues a particular "error" (see
330+
// [Note: ModuleInterfaceLoader-defer-to-SerializedModuleLoader]), which
331+
// is interpreted by the overarching loader as a command to use the
332+
// SerializedModuleLoader. If we failed to find a .swiftmodule, this falls
333+
// back to using an interface. Actual errors lead to diagnostics.
334+
// 4. SerializedModuleLoader: Loads a serialized module if it can.
335+
// 5. ClangImporter: This must come after all the Swift module loaders because
336+
// in the presence of overlays and mixed-source frameworks, we want to prefer
337+
// the overlay or framework module over the underlying Clang module.
321338
bool CompilerInstance::setUpModuleLoaders() {
322339
if (hasSourceImport()) {
323340
bool enableLibraryEvolution =
@@ -354,10 +371,6 @@ bool CompilerInstance::setUpModuleLoaders() {
354371
Context->addModuleLoader(std::move(MemoryBufferLoader));
355372
}
356373

357-
std::unique_ptr<SerializedModuleLoader> SML =
358-
SerializedModuleLoader::create(*Context, getDependencyTracker(), MLM);
359-
this->SML = SML.get();
360-
361374
// Wire up the Clang importer. If the user has specified an SDK, use it.
362375
// Otherwise, we just keep it around as our interface to Clang's ABI
363376
// knowledge.
@@ -380,7 +393,12 @@ bool CompilerInstance::setUpModuleLoaders() {
380393
FEOpts.RemarkOnRebuildFromModuleInterface);
381394
Context->addModuleLoader(std::move(PIML));
382395
}
396+
397+
std::unique_ptr<SerializedModuleLoader> SML =
398+
SerializedModuleLoader::create(*Context, getDependencyTracker(), MLM);
399+
this->SML = SML.get();
383400
Context->addModuleLoader(std::move(SML));
401+
384402
Context->addModuleLoader(std::move(clangImporter), /*isClang*/ true);
385403

386404
return false;

trunk/lib/Frontend/ModuleInterfaceLoader.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,7 @@ class ModuleInterfaceLoaderImpl {
764764
}
765765
}
766766

767+
// [Note: ModuleInterfaceLoader-defer-to-SerializedModuleLoader]
767768
// Finally, if there's a module adjacent to the .swiftinterface that we can
768769
// _likely_ load (it validates OK and is up to date), bail early with
769770
// errc::not_supported, so the next (serialized) loader in the chain will

trunk/lib/SIL/SILProfiler.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ static bool canCreateProfilerForAST(ASTNode N, SILDeclRef forDecl) {
135135
return true;
136136
} else if (auto *E = N.get<Expr *>()) {
137137
if (forDecl.isStoredPropertyInitializer() ||
138+
forDecl.isPropertyWrapperBackingInitializer() ||
138139
forDecl.getAbstractClosureExpr())
139140
return true;
140141
}
@@ -151,8 +152,10 @@ SILProfiler *SILProfiler::create(SILModule &M, ForDefinition_t forDefinition,
151152
if (!doesASTRequireProfiling(M, N) && Opts.UseProfile.empty())
152153
return nullptr;
153154

154-
if (!canCreateProfilerForAST(N, forDecl))
155+
if (!canCreateProfilerForAST(N, forDecl)) {
156+
N.dump(llvm::errs());
155157
llvm_unreachable("Invalid AST node for profiling");
158+
}
156159

157160
auto *Buf = M.allocate<SILProfiler>(1);
158161
auto *SP =

trunk/lib/SILGen/SILGen.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,10 +1145,11 @@ emitPropertyWrapperBackingInitializer(VarDecl *var) {
11451145
preEmitFunction(constant, var, f, var);
11461146
PrettyStackTraceSILFunction X(
11471147
"silgen emitPropertyWrapperBackingInitializer", f);
1148-
f->createProfiler(var, constant, ForDefinition);
1149-
auto varDC = var->getInnermostDeclContext();
11501148
auto wrapperInfo = var->getPropertyWrapperBackingPropertyInfo();
11511149
assert(wrapperInfo.initializeFromOriginal);
1150+
f->createProfiler(wrapperInfo.initializeFromOriginal, constant,
1151+
ForDefinition);
1152+
auto varDC = var->getInnermostDeclContext();
11521153
SILGenFunction SGF(*this, *f, varDC);
11531154
SGF.emitGeneratorFunction(constant, wrapperInfo.initializeFromOriginal);
11541155
postEmitFunction(constant, f);

trunk/test/Profiler/coverage_var_init.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -profile-generate -profile-coverage-mapping -emit-sorted-sil -emit-sil -module-name coverage_var_init %s | %FileCheck %s
22

33
final class VarInit {
4+
// CHECK: sil_coverage_map {{.*}} "$s17coverage_var_init7VarInitC018initializedWrapperE0SivpfP"
5+
// CHECK-NEXT: [[@LINE+1]]:4 -> [[@LINE+1]]:38 : 0
6+
@Wrapper var initializedWrapperInit = 2
7+
48
// CHECK: sil_coverage_map {{.*}} "$s17coverage_var_init7VarInitC04lazydE033_49373CB2DFB47C8DC62FA963604688DFLLSSvgSSyXEfU_"
59
// CHECK-NEXT: [[@LINE+1]]:42 -> [[@LINE+3]]:4 : 0
610
private lazy var lazyVarInit: String = {
@@ -23,7 +27,13 @@ final class VarInit {
2327
print(lazyVarInit)
2428
print(basicVarInit)
2529
print(simpleVar)
30+
print(initializedWrapperInit)
2631
}
2732
}
2833

34+
@propertyWrapper struct Wrapper {
35+
init(wrappedValue: Int) {}
36+
var wrappedValue: Int { 1 }
37+
}
38+
2939
VarInit().coverageFunction()

trunk/utils/build-script-impl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3054,7 +3054,7 @@ for host in "${ALL_HOSTS[@]}"; do
30543054
results_dir="${lldb_build_dir}/test-results"
30553055

30563056
call mkdir -p "${results_dir}"
3057-
LLVM_LIT_ARG="${LLVM_LIT_ARGS} --xunit-xml-output=${results_dir}/results.xml"
3057+
LLVM_LIT_ARGS="${LLVM_LIT_ARGS} --xunit-xml-output=${results_dir}/results.xml"
30583058

30593059
if [[ "${ENABLE_ASAN}" ]] ; then
30603060
# Limit the number of parallel tests

0 commit comments

Comments
 (0)