Skip to content

Commit cc614c4

Browse files
committed
---
yaml --- r: 294333 b: refs/heads/tensorflow c: c957c50 h: refs/heads/master i: 294331: e4bea9a
1 parent 6fa5044 commit cc614c4

39 files changed

+219
-840
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,7 @@ refs/tags/swift-DEVELOPMENT-SNAPSHOT-2018-04-25-a: 22f738a831d43aff2b9c9773bcb65
816816
refs/tags/swift-DEVELOPMENT-SNAPSHOT-2018-05-08-a: 7d98cc16689baba5c8a3b90a9329bdcc1a12b4e9
817817
refs/heads/cherr42: a566ad54b073c2c56ac0a705d0a5bed9743135a5
818818
"refs/heads/codable_test_comment_fix": fc8f6824f7f347e1e8db55bff62db385c5728b5a
819-
refs/heads/tensorflow: 6cca050fd9a51b6fa41e1efffe044de11d6a18dd
819+
refs/heads/tensorflow: c957c50e28974ed264b14fe832a95421099cbd65
820820
refs/tags/swift-4.1-DEVELOPMENT-SNAPSHOT-2018-05-11-a: 8126fd7a652e2f70ad6d76505239e34fb2ef3e1a
821821
refs/tags/swift-4.1-DEVELOPMENT-SNAPSHOT-2018-05-12-a: b3fd3dd84df6717f2e2e9df58c6d7e99fed57086
822822
refs/tags/swift-4.1-DEVELOPMENT-SNAPSHOT-2018-05-13-a: 71135119579039dc321c5f65d870050fe36efda2

branches/tensorflow/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ set_property(CACHE SWIFT_ANALYZE_CODE_COVERAGE PROPERTY
123123
# SWIFT_VERSION is deliberately /not/ cached so that an existing build directory
124124
# can be reused when a new version of Swift comes out (assuming the user hasn't
125125
# manually set it as part of their own CMake configuration).
126-
set(SWIFT_VERSION "5.1")
126+
set(SWIFT_VERSION "5.0")
127127

128128
set(SWIFT_VENDOR "" CACHE STRING
129129
"The vendor name of the Swift compiler")

branches/tensorflow/benchmark/single-source/SetTests.swift

Lines changed: 2 additions & 559 deletions
Large diffs are not rendered by default.

branches/tensorflow/include/swift/AST/DiagnosticsSema.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ ERROR(serialization_missing_dependencies,Fatal,
625625
ERROR(serialization_circular_dependency,Fatal,
626626
"circular dependency between modules '%0' and %1",
627627
(StringRef, Identifier))
628-
ERROR(serialization_missing_underlying_module,Fatal,
628+
ERROR(serialization_missing_shadowed_module,Fatal,
629629
"cannot load underlying module for %0", (Identifier))
630630
ERROR(serialization_name_mismatch,Fatal,
631631
"cannot load module '%0' as '%1'", (StringRef, StringRef))

branches/tensorflow/include/swift/Serialization/ModuleFile.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ class ModuleFile
5757
/// A reference back to the AST representation of the file.
5858
FileUnit *FileContext = nullptr;
5959

60-
/// The module that this module is an overlay of, if any.
61-
ModuleDecl *UnderlyingModule = nullptr;
60+
/// The module shadowed by this module, if any.
61+
ModuleDecl *ShadowedModule = nullptr;
6262

6363
/// The module file data.
6464
std::unique_ptr<llvm::MemoryBuffer> ModuleInputBuffer;
@@ -702,8 +702,8 @@ class ModuleFile
702702
return Dependencies;
703703
}
704704

705-
/// The module that this module is an overlay for, if any.
706-
ModuleDecl *getUnderlyingModule() const { return UnderlyingModule; }
705+
/// The module shadowed by this module, if any.
706+
ModuleDecl *getShadowedModule() const { return ShadowedModule; }
707707

708708
/// Searches the module's top-level decls for the given identifier.
709709
void lookupValue(DeclName name, SmallVectorImpl<ValueDecl*> &results);

branches/tensorflow/include/swift/Serialization/ModuleFormat.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const uint16_t SWIFTMODULE_VERSION_MAJOR = 0;
5252
/// describe what change you made. The content of this comment isn't important;
5353
/// it just ensures a conflict if two people change the module format.
5454
/// Don't worry about adhering to the 80-column limit for this line.
55-
const uint16_t SWIFTMODULE_VERSION_MINOR = 490; // dependency directories
55+
const uint16_t SWIFTMODULE_VERSION_MINOR = 491; // mangled class names as vtable keys
5656

5757
using DeclIDField = BCFixed<31>;
5858

branches/tensorflow/include/swift/Serialization/SerializedSILLoader.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,7 @@ class SerializedSILLoader {
6161
lookupSILFunction(StringRef Name, bool declarationOnly = false,
6262
Optional<SILLinkage> linkage = None);
6363
bool hasSILFunction(StringRef Name, Optional<SILLinkage> linkage = None);
64-
SILVTable *lookupVTable(Identifier Name);
65-
SILVTable *lookupVTable(const ClassDecl *C) {
66-
return lookupVTable(C->getName());
67-
}
64+
SILVTable *lookupVTable(const ClassDecl *C);
6865
SILWitnessTable *lookupWitnessTable(SILWitnessTable *C);
6966
SILDefaultWitnessTable *lookupDefaultWitnessTable(SILDefaultWitnessTable *C);
7067

branches/tensorflow/include/swift/Serialization/Validation.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ enum class Status {
4343
MissingDependency,
4444

4545
/// The module file is an overlay for a Clang module, which can't be found.
46-
MissingUnderlyingModule,
46+
MissingShadowedModule,
4747

4848
/// The module file depends on a module that is still being loaded, i.e.
4949
/// there is a circular dependency.

branches/tensorflow/lib/IDE/CodeCompletion.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2559,7 +2559,7 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
25592559
}
25602560

25612561
// If we won't be able to provide a result, bail out.
2562-
if (!ConstructorType && addName.empty() && !needInit)
2562+
if (MemberType->hasError() && addName.empty() && !needInit)
25632563
return;
25642564

25652565
// Add the constructor, possibly including any default arguments.
@@ -2577,6 +2577,8 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
25772577
Builder.addTextChunk("init");
25782578
} else if (!addName.empty()) {
25792579
Builder.addTextChunk(addName.str());
2580+
} else {
2581+
assert(!MemberType->hasError() && "will insert empty result");
25802582
}
25812583

25822584
if (!ConstructorType) {

branches/tensorflow/lib/SIL/SILVerifier.cpp

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -494,10 +494,8 @@ struct ImmutableAddressUseVerifier {
494494
while (!worklist.empty()) {
495495
auto *use = worklist.pop_back_val();
496496
auto *inst = use->getUser();
497-
498497
if (inst->isTypeDependentOperand(*use))
499498
continue;
500-
501499
switch (inst->getKind()) {
502500
case SILInstructionKind::MarkDependenceInst:
503501
case SILInstructionKind::LoadBorrowInst:
@@ -514,14 +512,6 @@ struct ImmutableAddressUseVerifier {
514512
//
515513
// TODO: Can we do better?
516514
break;
517-
case SILInstructionKind::BranchInst:
518-
case SILInstructionKind::CondBranchInst:
519-
// We do not analyze through branches and cond_br instructions and just
520-
// assume correctness. This is so that we can avoid having to analyze
521-
// through phi loops and since we want to remove address phis (meaning
522-
// that this eventually would never be able to happen). Once that
523-
// changes happens, we should remove this code and just error below.
524-
break;
525515
case SILInstructionKind::ApplyInst:
526516
case SILInstructionKind::TryApplyInst:
527517
case SILInstructionKind::PartialApplyInst:
@@ -587,8 +577,7 @@ struct ImmutableAddressUseVerifier {
587577
}
588578
break;
589579
default:
590-
llvm::errs() << "Unhandled, unexpected instruction: " << *inst;
591-
llvm_unreachable("invoking standard assertion failure");
580+
llvm_unreachable("Unhandled unexpected instruction");
592581
break;
593582
}
594583
}

branches/tensorflow/lib/SILOptimizer/SILCombiner/SILCombiner.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ class SILCombiner :
235235
SILInstruction *visitUpcastInst(UpcastInst *UCI);
236236
SILInstruction *optimizeLoadFromStringLiteral(LoadInst *LI);
237237
SILInstruction *visitLoadInst(LoadInst *LI);
238+
SILInstruction *visitStoreInst(StoreInst *si);
238239
SILInstruction *visitIndexAddrInst(IndexAddrInst *IA);
239240
SILInstruction *visitAllocStackInst(AllocStackInst *AS);
240241
SILInstruction *visitAllocRefInst(AllocRefInst *AR);

branches/tensorflow/lib/SILOptimizer/SILCombiner/SILCombinerMiscVisitors.cpp

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,79 @@ SILInstruction *SILCombiner::optimizeLoadFromStringLiteral(LoadInst *LI) {
586586
return Builder.createIntegerLiteral(LI->getLoc(), LI->getType(), str[index]);
587587
}
588588

589+
SILInstruction *SILCombiner::visitStoreInst(StoreInst *si) {
590+
auto *f = si->getFunction();
591+
assert(f->getConventions().useLoweredAddresses() &&
592+
"These optimizations assume that opaque values are not enabled");
593+
594+
// (store (struct_element_addr addr) object)
595+
// ->
596+
// (store addr (struct object))
597+
598+
// If our store's destination is not a struct_element_addr, bail early.
599+
auto *sea = dyn_cast<StructElementAddrInst>(si->getDest());
600+
if (!sea)
601+
return nullptr;
602+
603+
// Ok, we have at least one struct_element_addr. Canonicalize the underlying
604+
// store.
605+
Builder.setInsertionPoint(si);
606+
SILLocation loc = si->getLoc();
607+
608+
auto &mod = si->getModule();
609+
SILValue result = si->getSrc();
610+
SILValue iterAddr = sea->getOperand();
611+
SILValue storeAddr;
612+
while (true) {
613+
SILType iterAddrType = iterAddr->getType();
614+
615+
// If our aggregate has unreferenced storage then we can never prove if it
616+
// actually has a single field.
617+
if (iterAddrType.aggregateHasUnreferenceableStorage())
618+
break;
619+
620+
auto *decl = iterAddrType.getStructOrBoundGenericStruct();
621+
assert(
622+
!decl->isResilient(mod.getSwiftModule(), f->getResilienceExpansion()) &&
623+
"This code assumes resilient structs can not have fragile fields. If "
624+
"this assert is hit, this has been changed. Please update this code.");
625+
626+
// NOTE: If this is ever changed to support enums, we must check for address
627+
// only types here. For structs we do not have to check since a single
628+
// element struct with a loadable element can never be address only. We
629+
// additionally do not have to worry about our input value being address
630+
// only since we are storing into it.
631+
auto props = decl->getStoredProperties();
632+
if (std::next(props.begin()) != props.end())
633+
break;
634+
635+
// Update the store location now that we know it is safe.
636+
storeAddr = iterAddr;
637+
638+
// Otherwise, create the struct.
639+
result = Builder.createStruct(loc, iterAddrType.getObjectType(), result);
640+
641+
// See if we have another struct_element_addr we can strip off. If we don't
642+
// then this as much as we can promote.
643+
sea = dyn_cast<StructElementAddrInst>(sea->getOperand());
644+
if (!sea)
645+
break;
646+
iterAddr = sea->getOperand();
647+
}
648+
649+
// If we failed to create any structs, bail.
650+
if (result == si->getSrc())
651+
return nullptr;
652+
653+
// Then create a new store, storing the value into the relevant computed
654+
// address.
655+
Builder.createStore(loc, result, storeAddr,
656+
StoreOwnershipQualifier::Unqualified);
657+
658+
// Then eliminate the original store.
659+
return eraseInstFromFunction(*si);
660+
}
661+
589662
SILInstruction *SILCombiner::visitLoadInst(LoadInst *LI) {
590663
// (load (upcast-ptr %x)) -> (upcast-ref (load %x))
591664
Builder.setCurrentDebugScope(LI->getDebugScope());

branches/tensorflow/lib/SILOptimizer/Utils/CanonicalizeInstruction.cpp

Lines changed: 0 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -309,84 +309,6 @@ splitAggregateLoad(LoadInst *loadInst, CanonicalizeInstruction &pass) {
309309
return killInstAndIncidentalUses(loadInst, nextII, pass);
310310
}
311311

312-
// Given a store within a single property struct, recursively form the parent
313-
// struct values and promote the store to the outer struct type.
314-
//
315-
// (store (struct_element_addr %base) object)
316-
// ->
317-
// (store %base (struct object))
318-
static SILBasicBlock::iterator
319-
broadenSingleElementStores(StoreInst *storeInst,
320-
CanonicalizeInstruction &pass) {
321-
// Keep track of the next iterator after any newly added or to-be-deleted
322-
// instructions. This must be valid regardless of whether the pass immediately
323-
// deletes the instructions or simply records them for later deletion.
324-
auto nextII = std::next(storeInst->getIterator());
325-
326-
// Bail if the store's destination is not a struct_element_addr.
327-
auto *sea = dyn_cast<StructElementAddrInst>(storeInst->getDest());
328-
if (!sea)
329-
return nextII;
330-
331-
auto *f = storeInst->getFunction();
332-
333-
// Continue up the struct_element_addr chain, as long as each struct only has
334-
// a single property, creating StoreInsts along the way.
335-
SILBuilderWithScope builder(storeInst);
336-
337-
SILValue result = storeInst->getSrc();
338-
SILValue baseAddr = sea->getOperand();
339-
SILValue storeAddr;
340-
while (true) {
341-
SILType baseAddrType = baseAddr->getType();
342-
343-
// If our aggregate has unreferenced storage then we can never prove if it
344-
// actually has a single field.
345-
if (baseAddrType.aggregateHasUnreferenceableStorage())
346-
break;
347-
348-
auto *decl = baseAddrType.getStructOrBoundGenericStruct();
349-
assert(
350-
!decl->isResilient(f->getModule().getSwiftModule(),
351-
f->getResilienceExpansion()) &&
352-
"This code assumes resilient structs can not have fragile fields. If "
353-
"this assert is hit, this has been changed. Please update this code.");
354-
355-
// NOTE: If this is ever changed to support enums, we must check for address
356-
// only types here. For structs we do not have to check since a single
357-
// element struct with a loadable element can never be address only. We
358-
// additionally do not have to worry about our input value being address
359-
// only since we are storing into it.
360-
auto props = decl->getStoredProperties();
361-
if (std::next(props.begin()) != props.end())
362-
break;
363-
364-
// Update the store location now that we know it is safe.
365-
storeAddr = baseAddr;
366-
367-
// Otherwise, create the struct.
368-
result = builder.createStruct(storeInst->getLoc(),
369-
baseAddrType.getObjectType(), result);
370-
371-
// See if we have another struct_element_addr we can strip off. If we don't
372-
// then this as much as we can promote.
373-
sea = dyn_cast<StructElementAddrInst>(sea->getOperand());
374-
if (!sea)
375-
break;
376-
baseAddr = sea->getOperand();
377-
}
378-
// If we failed to create any structs, bail.
379-
if (result == storeInst->getSrc())
380-
return nextII;
381-
382-
// Store the new struct-wrapped value into the final base address.
383-
builder.createStore(storeInst->getLoc(), result, storeAddr,
384-
storeInst->getOwnershipQualifier());
385-
386-
// Erase the original store.
387-
return killInstruction(storeInst, nextII, pass);
388-
}
389-
390312
//===----------------------------------------------------------------------===//
391313
// Top-Level Entry Point
392314
//===----------------------------------------------------------------------===//
@@ -399,9 +321,6 @@ CanonicalizeInstruction::canonicalize(SILInstruction *inst) {
399321
if (auto *loadInst = dyn_cast<LoadInst>(inst))
400322
return splitAggregateLoad(loadInst, *this);
401323

402-
if (auto *storeInst = dyn_cast<StoreInst>(inst))
403-
return broadenSingleElementStores(storeInst, *this);
404-
405324
// Skip ahead.
406325
return std::next(inst->getIterator());
407326
}

branches/tensorflow/lib/Serialization/Deserialization.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2010,14 +2010,14 @@ ModuleDecl *ModuleFile::getModule(ArrayRef<Identifier> name,
20102010
// FIXME: duplicated from NameBinder::getModule
20112011
if (name.size() == 1 &&
20122012
name.front() == FileContext->getParentModule()->getName()) {
2013-
if (!UnderlyingModule && allowLoading) {
2013+
if (!ShadowedModule && allowLoading) {
20142014
auto importer = getContext().getClangModuleLoader();
20152015
assert(importer && "no way to import shadowed module");
2016-
UnderlyingModule = importer->loadModule(SourceLoc(),
2017-
{{name.front(), SourceLoc()}});
2016+
ShadowedModule = importer->loadModule(SourceLoc(),
2017+
{ { name.front(), SourceLoc() } });
20182018
}
20192019

2020-
return UnderlyingModule;
2020+
return ShadowedModule;
20212021
}
20222022

20232023
SmallVector<ImportDecl::AccessPathElement, 4> importPath;

branches/tensorflow/lib/Serialization/DeserializeSIL.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2779,10 +2779,10 @@ SILVTable *SILDeserializer::readVTable(DeclID VId) {
27792779
return vT;
27802780
}
27812781

2782-
SILVTable *SILDeserializer::lookupVTable(Identifier Name) {
2782+
SILVTable *SILDeserializer::lookupVTable(StringRef MangledClassName) {
27832783
if (!VTableList)
27842784
return nullptr;
2785-
auto iter = VTableList->find(Name.str());
2785+
auto iter = VTableList->find(MangledClassName);
27862786
if (iter == VTableList->end())
27872787
return nullptr;
27882788

branches/tensorflow/lib/Serialization/DeserializeSIL.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ namespace swift {
141141
SILFunction *lookupSILFunction(StringRef Name,
142142
bool declarationOnly = false);
143143
bool hasSILFunction(StringRef Name, Optional<SILLinkage> Linkage = None);
144-
SILVTable *lookupVTable(Identifier Name);
144+
SILVTable *lookupVTable(StringRef MangledClassName);
145145
SILWitnessTable *lookupWitnessTable(SILWitnessTable *wt);
146146
SILDefaultWitnessTable *
147147
lookupDefaultWitnessTable(SILDefaultWitnessTable *wt);

branches/tensorflow/lib/Serialization/ModuleFile.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1570,10 +1570,10 @@ Status ModuleFile::associateWithFileContext(FileUnit *file,
15701570
}
15711571
auto module = getModule(modulePath, /*allowLoading*/true);
15721572
if (!module || module->failedToLoad()) {
1573-
// If we're missing the module we're an overlay for, treat that specially.
1573+
// If we're missing the module we're shadowing, treat that specially.
15741574
if (modulePath.size() == 1 &&
15751575
modulePath.front() == file->getParentModule()->getName()) {
1576-
return error(Status::MissingUnderlyingModule);
1576+
return error(Status::MissingShadowedModule);
15771577
}
15781578

15791579
// Otherwise, continue trying to load dependencies, so that we can list
@@ -1720,10 +1720,10 @@ TypeDecl *ModuleFile::lookupNestedType(Identifier name,
17201720
}
17211721
}
17221722

1723-
if (!UnderlyingModule)
1723+
if (!ShadowedModule)
17241724
return nullptr;
17251725

1726-
for (FileUnit *file : UnderlyingModule->getFiles())
1726+
for (FileUnit *file : ShadowedModule->getFiles())
17271727
if (auto *nestedType = file->lookupNestedType(name, parent))
17281728
return nestedType;
17291729

@@ -2195,8 +2195,8 @@ ModuleFile::getOpaqueReturnTypeDecls(SmallVectorImpl<OpaqueTypeDecl *> &results)
21952195
}
21962196

21972197
void ModuleFile::getDisplayDecls(SmallVectorImpl<Decl *> &results) {
2198-
if (UnderlyingModule)
2199-
UnderlyingModule->getDisplayDecls(results);
2198+
if (ShadowedModule)
2199+
ShadowedModule->getDisplayDecls(results);
22002200

22012201
PrettyStackTraceModuleFile stackEntry(*this);
22022202
getImportDecls(results);

0 commit comments

Comments
 (0)