Skip to content

Commit 09602ef

Browse files
committed
---
yaml --- r: 327159 b: refs/heads/tensorflow c: f567b8f h: refs/heads/master i: 327157: 5e050e2 327155: cf53429 327151: 88e9eda
1 parent 87da117 commit 09602ef

24 files changed

+45
-423
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: 771a390c573f1274749897c648fe5d49d160f41b
819+
refs/heads/tensorflow: f567b8ff422c9dd3cd10343839b4bdadf0f0b428
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/include/swift/AST/Builtins.def

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -418,14 +418,6 @@ BUILTIN_MISC_OPERATION(Strideof, "strideof", "n", Special)
418418
/// IsPOD has type T.Type -> Bool
419419
BUILTIN_MISC_OPERATION(IsPOD, "ispod", "n", Special)
420420

421-
/// IsConcrete has type (T.Type) -> Bool
422-
///
423-
/// If the meta type T is concrete, we can always transform this to `true` at
424-
/// any time in SIL. If it's generic, then we lower it to `false` right before
425-
/// IRGen in IRGenPrepare. This allows for the optimizer to specialize this at
426-
/// -O and eliminate conditional code.
427-
BUILTIN_MISC_OPERATION(IsConcrete, "isConcrete", "n", Special)
428-
429421
/// IsBitwiseTakable has type T.Type -> Bool
430422
BUILTIN_MISC_OPERATION(IsBitwiseTakable, "isbitwisetakable", "n", Special)
431423

branches/tensorflow/lib/AST/Builtins.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -737,13 +737,6 @@ static ValueDecl *getIsPODOperation(ASTContext &Context, Identifier Id) {
737737
return builder.build(Id);
738738
}
739739

740-
static ValueDecl *getIsConcrete(ASTContext &Context, Identifier Id) {
741-
BuiltinGenericSignatureBuilder builder(Context);
742-
builder.addParameter(makeMetatype(makeGenericParam()));
743-
builder.setResult(makeConcrete(BuiltinIntegerType::get(1,Context)));
744-
return builder.build(Id);
745-
}
746-
747740
static ValueDecl *getIsBitwiseTakable(ASTContext &Context, Identifier Id) {
748741
BuiltinGenericSignatureBuilder builder(Context);
749742
builder.addParameter(makeMetatype(makeGenericParam()));
@@ -1864,9 +1857,6 @@ ValueDecl *swift::getBuiltinValueDecl(ASTContext &Context, Identifier Id) {
18641857
case BuiltinValueKind::IsPOD:
18651858
return getIsPODOperation(Context, Id);
18661859

1867-
case BuiltinValueKind::IsConcrete:
1868-
return getIsConcrete(Context, Id);
1869-
18701860
case BuiltinValueKind::IsBitwiseTakable:
18711861
return getIsBitwiseTakable(Context, Id);
18721862

branches/tensorflow/lib/AST/NameLookup.cpp

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -261,22 +261,19 @@ static void recordShadowedDeclsAfterSignatureMatch(
261261
isa<ProtocolDecl>(secondDecl->getDeclContext()))
262262
continue;
263263

264-
// Prefer declarations in the current module over those in another
265-
// module.
266-
// FIXME: This is a hack. We should query a (lazily-built, cached)
267-
// module graph to determine shadowing.
268-
if ((firstModule == curModule) != (secondModule == curModule)) {
269-
// If the first module is the current module, the second declaration
270-
// is shadowed by the first.
271-
if (firstModule == curModule) {
264+
// [Backward compatibility] For members of types, the general module
265+
// shadowing check is performed after unavailable candidates have
266+
// already been dropped.
267+
if (firstModule != secondModule &&
268+
!firstDecl->getDeclContext()->isModuleScopeContext() &&
269+
!secondDecl->getDeclContext()->isModuleScopeContext()) {
270+
if (imports.isShadowedBy(firstModule, secondModule, dc)) {
271+
shadowed.insert(firstDecl);
272+
break;
273+
} else if (imports.isShadowedBy(secondModule, firstModule, dc)) {
272274
shadowed.insert(secondDecl);
273275
continue;
274276
}
275-
276-
// Otherwise, the first declaration is shadowed by the second. There is
277-
// no point in continuing to compare the first declaration to others.
278-
shadowed.insert(firstDecl);
279-
break;
280277
}
281278

282279
// Prefer declarations in the any module over those in the standard

branches/tensorflow/lib/IRGen/GenBuiltin.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -179,13 +179,6 @@ void irgen::emitBuiltinCall(IRGenFunction &IGF, const BuiltinInfo &Builtin,
179179
return;
180180
}
181181

182-
if (Builtin.ID == BuiltinValueKind::IsConcrete) {
183-
(void)args.claimAll();
184-
auto isConcrete = !substitutions.getReplacementTypes()[0]->hasArchetype();
185-
out.add(llvm::ConstantInt::get(IGF.IGM.Int1Ty, isConcrete));
186-
return;
187-
}
188-
189182
if (Builtin.ID == BuiltinValueKind::IsBitwiseTakable) {
190183
(void)args.claimAll();
191184
auto valueTy = getLoweredTypeAndTypeInfo(IGF.IGM,

branches/tensorflow/lib/Parse/ParseType.cpp

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -669,19 +669,19 @@ Parser::TypeResult Parser::parseTypeIdentifier() {
669669
if (startsWithLess(Tok)) {
670670
SmallVector<TypeRepr *, 4> GenericArgsAST;
671671
SourceLoc LAngleLoc, RAngleLoc;
672-
auto GenericArgsResult = parseGenericArgumentClauseSyntax();
672+
auto GenericArgsResult =
673+
parseGenericArgumentsAST(GenericArgsAST, LAngleLoc, RAngleLoc);
673674
if (!GenericArgsResult.isSuccess()) {
674675
if (Base)
675676
Junk.push_back(*Base);
676677
if (Period)
677678
Junk.push_back(*Period);
678679
Junk.push_back(*Identifier);
679-
auto genericJunks = GenericArgsResult.getUnknownNodes();
680-
Junk.append(genericJunks.begin(), genericJunks.end());
681-
return makeParsedResult<ParsedTypeSyntax>(
682-
Junk, GenericArgsResult.getStatus());
680+
if (auto GenericJunk = SyntaxContext->popIf<ParsedSyntax>())
681+
Junk.push_back(*GenericJunk);
682+
return makeParsedResult<ParsedTypeSyntax>(Junk, GenericArgsResult);
683683
}
684-
GenericArgs = GenericArgsResult.getResult();
684+
GenericArgs = SyntaxContext->popIf<ParsedGenericArgumentClauseSyntax>();
685685
}
686686

687687
if (!Base)
@@ -1074,18 +1074,15 @@ Parser::TypeResult Parser::parseTypeTupleBody() {
10741074
// Consume a name.
10751075
NameLoc = Tok.getLoc();
10761076
Name = consumeArgumentLabelSyntax();
1077-
LocalJunk.push_back(*Name);
10781077

10791078
// If there is a second name, consume it as well.
10801079
if (Tok.canBeArgumentLabel()) {
10811080
SecondNameLoc = Tok.getLoc();
10821081
SecondName = consumeArgumentLabelSyntax();
1083-
LocalJunk.push_back(*SecondName);
10841082
}
10851083

10861084
// Consume the ':'.
10871085
if ((Colon = consumeTokenSyntaxIf(tok::colon))) {
1088-
LocalJunk.push_back(*Colon);
10891086
// If we succeed, then we successfully parsed a label.
10901087
if (Backtracking)
10911088
Backtracking->cancelBacktrack();
@@ -1094,6 +1091,8 @@ Parser::TypeResult Parser::parseTypeTupleBody() {
10941091
} else {
10951092
if (!Backtracking)
10961093
diagnose(Tok, diag::expected_parameter_colon);
1094+
Name = None;
1095+
SecondName = None;
10971096
NameLoc = SourceLoc();
10981097
SecondNameLoc = SourceLoc();
10991098
}
@@ -1104,14 +1103,20 @@ Parser::TypeResult Parser::parseTypeTupleBody() {
11041103

11051104
Backtracking.reset();
11061105

1106+
if (Name)
1107+
LocalJunk.push_back(*Name);
1108+
if (SecondName)
1109+
LocalJunk.push_back(*SecondName);
1110+
if (Colon)
1111+
LocalJunk.push_back(*Colon);
1112+
11071113
// Parse the type annotation.
11081114
auto TypeLoc = Tok.getLoc();
11091115
auto TypeASTResult = parseType(diag::expected_type);
11101116
if (TypeASTResult.hasCodeCompletion() || TypeASTResult.isNull()) {
1111-
Junk.append(LocalJunk.begin(), LocalJunk.end());
1112-
if (auto parsedT = SyntaxContext->popIf<ParsedTypeSyntax>())
1113-
Junk.push_back(*parsedT);
11141117
skipListUntilDeclRBraceSyntax(Junk, LParenLoc, tok::r_paren, tok::comma);
1118+
for (auto &&Item : LocalJunk)
1119+
Junk.push_back(Item);
11151120
return TypeASTResult.hasCodeCompletion()
11161121
? makeParserCodeCompletionStatus()
11171122
: makeParserError();

branches/tensorflow/lib/SIL/OperandOwnership.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -983,7 +983,6 @@ ANY_OWNERSHIP_BUILTIN(IntToFPWithOverflow)
983983
ANY_OWNERSHIP_BUILTIN(IntToPtr)
984984
ANY_OWNERSHIP_BUILTIN(IsOptionalType)
985985
ANY_OWNERSHIP_BUILTIN(IsPOD)
986-
ANY_OWNERSHIP_BUILTIN(IsConcrete)
987986
ANY_OWNERSHIP_BUILTIN(IsBitwiseTakable)
988987
ANY_OWNERSHIP_BUILTIN(IsSameMetatype)
989988
ANY_OWNERSHIP_BUILTIN(LShr)

branches/tensorflow/lib/SIL/ValueOwnership.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,6 @@ CONSTANT_OWNERSHIP_BUILTIN(Any, Sizeof)
448448
CONSTANT_OWNERSHIP_BUILTIN(Any, Strideof)
449449
CONSTANT_OWNERSHIP_BUILTIN(Any, StringObjectOr)
450450
CONSTANT_OWNERSHIP_BUILTIN(Any, IsPOD)
451-
CONSTANT_OWNERSHIP_BUILTIN(Any, IsConcrete)
452451
CONSTANT_OWNERSHIP_BUILTIN(Any, IsBitwiseTakable)
453452
CONSTANT_OWNERSHIP_BUILTIN(Any, IsSameMetatype)
454453
CONSTANT_OWNERSHIP_BUILTIN(Any, Alignof)

branches/tensorflow/lib/SILOptimizer/Mandatory/SemanticARCOpts.cpp

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -340,62 +340,6 @@ bool SemanticARCOptVisitor::performGuaranteedCopyValueOptimization(CopyValueInst
340340
if (isConsumed(cvi, destroys, &guaranteedForwardingInsts))
341341
return false;
342342

343-
// Next check if we have any destroys at all of our copy_value and an operand
344-
// that is not a function argument. Otherwise, due to the way we ignore dead
345-
// end blocks, we may eliminate the copy_value, creating a use of the borrowed
346-
// value after the end_borrow.
347-
//
348-
// DISCUSSION: Consider the following SIL:
349-
//
350-
// ```
351-
// %1 = begin_borrow %0 : $KlassPair (1)
352-
// %2 = struct_extract %1 : $KlassPair, #KlassPair.firstKlass
353-
// %3 = copy_value %2 : $Klass
354-
// ...
355-
// end_borrow %1 : $LintCommand (2)
356-
// cond_br ..., bb1, bb2
357-
//
358-
// ...
359-
//
360-
// bbN:
361-
// // Never return type implies dead end block.
362-
// apply %f(%3) : $@convention(thin) (@guaranteed Klass) -> Never (3)
363-
// unreachable
364-
// ```
365-
//
366-
// For simplicity, note that if bbN post-dominates %3, given that when we
367-
// compute linear lifetime errors we ignore dead end blocks, we would not
368-
// register that the copy_values only use is outside of the begin_borrow
369-
// region defined by (1), (2) and thus would eliminate the copy. This would
370-
// result in %2 being used by %f, causing the linear lifetime checker to
371-
// error.
372-
//
373-
// Naively one may assume that the solution to this is to just check if %3 has
374-
// /any/ destroy_values at all and if it doesn't have any reachable
375-
// destroy_values, then we are in this case. But is this correct in
376-
// general. We prove this below:
377-
//
378-
// The only paths along which the copy_value can not be destroyed or consumed
379-
// is along paths to dead end blocks. Trivially, we know that such a dead end
380-
// block, can not be reachable from the end_borrow since by their nature dead
381-
// end blocks end in unreachables.
382-
//
383-
// So we know that we can only run into this bug if we have a dead end block
384-
// reachable from the end_borrow, meaning that the bug can not occur if we
385-
// branch before the end_borrow since in that case, the borrow scope would
386-
// last over the dead end block's no return meaning that we will not use the
387-
// borrowed value after its lifetime is ended by the end_borrow.
388-
//
389-
// With that in hand, we note again that if we have exactly one consumed,
390-
// destroy_value /after/ the end_borrow we will not optimize here. This means
391-
// that this bug can only occur if the copy_value is only post-dominated by
392-
// dead end blocks that use the value in a non-consuming way.
393-
if (destroys.empty() && llvm::any_of(borrowIntroducers, [](SILValue v) {
394-
return !isa<SILFunctionArgument>(v);
395-
})) {
396-
return false;
397-
}
398-
399343
// If we reached this point, then we know that all of our users can
400344
// accept a guaranteed value and our owned value is destroyed only
401345
// by destroy_value. Check if all of our destroys are joint

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,9 +285,6 @@ class SILCombiner :
285285
/// Instruction visitor helpers.
286286
SILInstruction *optimizeBuiltinCanBeObjCClass(BuiltinInst *AI);
287287

288-
// Optimize the "isConcrete" builtin.
289-
SILInstruction *optimizeBuiltinIsConcrete(BuiltinInst *I);
290-
291288
// Optimize the "trunc_N1_M2" builtin. if N1 is a result of "zext_M1_*" and
292289
// the following holds true: N1 > M1 and M2>= M1
293290
SILInstruction *optimizeBuiltinTruncOrBitCast(BuiltinInst *I);

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,6 @@ SILInstruction *SILCombiner::optimizeBuiltinCanBeObjCClass(BuiltinInst *BI) {
102102
llvm_unreachable("Unhandled TypeTraitResult in switch.");
103103
}
104104

105-
SILInstruction *SILCombiner::optimizeBuiltinIsConcrete(BuiltinInst *BI) {
106-
if (BI->getOperand(0)->getType().hasArchetype())
107-
return nullptr;
108-
109-
return Builder.createIntegerLiteral(BI->getLoc(), BI->getType(), 1);
110-
}
111-
112105
static unsigned getTypeWidth(SILType Ty) {
113106
if (auto BuiltinIntTy = Ty.getAs<BuiltinIntegerType>()) {
114107
if (BuiltinIntTy->isFixedWidth()) {
@@ -532,8 +525,6 @@ SILInstruction *SILCombiner::optimizeStringObject(BuiltinInst *BI) {
532525
SILInstruction *SILCombiner::visitBuiltinInst(BuiltinInst *I) {
533526
if (I->getBuiltinInfo().ID == BuiltinValueKind::CanBeObjCClass)
534527
return optimizeBuiltinCanBeObjCClass(I);
535-
if (I->getBuiltinInfo().ID == BuiltinValueKind::IsConcrete)
536-
return optimizeBuiltinIsConcrete(I);
537528
if (I->getBuiltinInfo().ID == BuiltinValueKind::TakeArrayFrontToBack ||
538529
I->getBuiltinInfo().ID == BuiltinValueKind::TakeArrayBackToFront ||
539530
I->getBuiltinInfo().ID == BuiltinValueKind::TakeArrayNoAlias ||

branches/tensorflow/lib/SILOptimizer/Transforms/AccessEnforcementReleaseSinking.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ static bool isBarrier(SILInstruction *inst) {
109109
case BuiltinValueKind::Sizeof:
110110
case BuiltinValueKind::Strideof:
111111
case BuiltinValueKind::IsPOD:
112-
case BuiltinValueKind::IsConcrete:
113112
case BuiltinValueKind::IsBitwiseTakable:
114113
case BuiltinValueKind::IsSameMetatype:
115114
case BuiltinValueKind::Alignof:

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

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,18 +1166,6 @@ static SILValue foldFPTrunc(BuiltinInst *BI, const BuiltinInfo &Builtin,
11661166
return B.createFloatLiteral(Loc, BI->getType(), truncVal);
11671167
}
11681168

1169-
static SILValue constantFoldIsConcrete(BuiltinInst *BI) {
1170-
if (BI->getOperand(0)->getType().hasArchetype()) {
1171-
return SILValue();
1172-
}
1173-
SILBuilderWithScope builder(BI);
1174-
auto *inst = builder.createIntegerLiteral(
1175-
BI->getLoc(), SILType::getBuiltinIntegerType(1, builder.getASTContext()),
1176-
true);
1177-
BI->replaceAllUsesWith(inst);
1178-
return inst;
1179-
}
1180-
11811169
static SILValue constantFoldBuiltin(BuiltinInst *BI,
11821170
Optional<bool> &ResultsInError) {
11831171
const IntrinsicInfo &Intrinsic = BI->getIntrinsicInfo();
@@ -1575,8 +1563,7 @@ void ConstantFolder::initializeWorklist(SILFunction &f) {
15751563
continue;
15761564
}
15771565

1578-
if (isApplyOfBuiltin(*inst, BuiltinValueKind::GlobalStringTablePointer) ||
1579-
isApplyOfBuiltin(*inst, BuiltinValueKind::IsConcrete)) {
1566+
if (isApplyOfBuiltin(*inst, BuiltinValueKind::GlobalStringTablePointer)) {
15801567
WorkList.insert(inst);
15811568
continue;
15821569
}
@@ -1794,17 +1781,6 @@ ConstantFolder::processWorkList() {
17941781
continue;
17951782
}
17961783

1797-
if (isApplyOfBuiltin(*I, BuiltinValueKind::IsConcrete)) {
1798-
if (constantFoldIsConcrete(cast<BuiltinInst>(I))) {
1799-
// Here, the bulitin instruction got folded, so clean it up.
1800-
recursivelyDeleteTriviallyDeadInstructions(
1801-
I, /*force*/ true,
1802-
[&](SILInstruction *DeadI) { WorkList.remove(DeadI); });
1803-
InvalidateInstructions = true;
1804-
}
1805-
continue;
1806-
}
1807-
18081784
// Go through all users of the constant and try to fold them.
18091785
FoldedUsers.clear();
18101786
for (auto Result : I->getResults()) {

branches/tensorflow/lib/Sema/TypeCheckStorage.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,14 @@ static void addMemberToContextIfNeeded(Decl *D, DeclContext *DC,
412412
}
413413
}
414414

415+
static ParamDecl *getParamDeclAtIndex(FuncDecl *fn, unsigned index) {
416+
return fn->getParameters()->get(index);
417+
}
418+
419+
static VarDecl *getFirstParamDecl(FuncDecl *fn) {
420+
return getParamDeclAtIndex(fn, 0);
421+
};
422+
415423
/// Build a parameter list which can forward the formal index parameters of a
416424
/// declaration.
417425
///
@@ -1299,7 +1307,7 @@ synthesizeTrivialSetterBodyWithStorage(AccessorDecl *setter,
12991307
ASTContext &ctx) {
13001308
SourceLoc loc = setter->getStorage()->getLoc();
13011309

1302-
VarDecl *valueParamDecl = setter->getParameters()->get(0);
1310+
VarDecl *valueParamDecl = getFirstParamDecl(setter);
13031311

13041312
auto *valueDRE =
13051313
new (ctx) DeclRefExpr(valueParamDecl, DeclNameLoc(), /*IsImplicit=*/true);

branches/tensorflow/stdlib/public/core/Builtin.swift

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -691,19 +691,6 @@ func _isPOD<T>(_ type: T.Type) -> Bool {
691691
return Bool(Builtin.ispod(type))
692692
}
693693

694-
/// Returns `true` if `type` is known to refer to a concrete type once all
695-
/// optimizations and constant folding has occurred at the call site. Otherwise,
696-
/// this returns `false` if the check has failed.
697-
///
698-
/// Note that there may be cases in which, despite `T` being concrete at some
699-
/// point in the caller chain, this function will return `false`.
700-
@_alwaysEmitIntoClient
701-
@_transparent
702-
public // @testable
703-
func _isConcrete<T>(_ type: T.Type) -> Bool {
704-
return Bool(Builtin.isConcrete(type))
705-
}
706-
707694
/// Returns `true` if type is a bitwise takable. A bitwise takable type can
708695
/// just be moved to a different address in memory.
709696
@_transparent

0 commit comments

Comments
 (0)