Skip to content

Commit e33d3c1

Browse files
committed
---
yaml --- r: 293743 b: refs/heads/tensorflow c: ba6582d h: refs/heads/master i: 293741: 299e6d5 293739: 5c06c3d 293735: 9fd3e18 293727: a484558
1 parent 04551c9 commit e33d3c1

File tree

69 files changed

+318
-934
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+318
-934
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: 9587a3a1f643065c4ca853bdcb72b95615f551f9
819+
refs/heads/tensorflow: ba6582d03f2599993ee44c49511cc75cda6dce26
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/benchmark/single-source/ObjectiveCBridging.swift

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,6 @@ public let ObjectiveCBridging = [
7373
BenchmarkInfo(name: "ObjectiveCBridgeFromNSDateComponents",
7474
runFunction: run_ObjectiveCBridgeFromNSDateComponents, tags: t,
7575
setUpFunction: setup_dateComponents),
76-
BenchmarkInfo(name: "ObjectiveCBridgeASCIIStringFromFile",
77-
runFunction: run_ASCIIStringFromFile, tags: ts,
78-
setUpFunction: setup_ASCIIStringFromFile),
7976
]
8077

8178
#if _runtime(_ObjC)
@@ -712,35 +709,3 @@ public func run_ObjectiveCBridgeFromNSDateComponents(_ N: Int) {
712709
}
713710
#endif
714711
}
715-
716-
var ASCIIStringFromFile:String? = nil
717-
public func setup_ASCIIStringFromFile() {
718-
#if _runtime(_ObjC)
719-
let url:URL
720-
if #available(OSX 10.12, iOS 10.0, *) {
721-
url = FileManager.default.temporaryDirectory.appendingPathComponent(
722-
"sphinx.txt"
723-
)
724-
} else {
725-
url = URL(fileURLWithPath: "/tmp/sphinx.txt")
726-
}
727-
var str = "Sphinx of black quartz judge my vow"
728-
str = Array(repeating: str, count: 100).joined()
729-
try? str.write(
730-
to: url,
731-
atomically: true,
732-
encoding: .ascii
733-
)
734-
ASCIIStringFromFile = try! String(contentsOf: url, encoding: .ascii)
735-
#endif
736-
}
737-
738-
@inline(never)
739-
public func run_ASCIIStringFromFile(_ N: Int) {
740-
#if _runtime(_ObjC)
741-
for _ in 0 ..< N {
742-
blackHole((ASCIIStringFromFile! + "").utf8.count)
743-
}
744-
#endif
745-
}
746-

branches/tensorflow/include/swift/SIL/SILBuilder.h

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -198,13 +198,9 @@ class SILBuilder {
198198
SILModule &getModule() const { return C.Module; }
199199
ASTContext &getASTContext() const { return getModule().getASTContext(); }
200200
const Lowering::TypeLowering &getTypeLowering(SILType T) const {
201-
auto expansion = ResilienceExpansion::Maximal;
202-
// If there's no current SILFunction, we're inserting into a global
203-
// variable initializer.
204-
if (F)
205-
expansion = F->getResilienceExpansion();
206-
207-
return getModule().Types.getTypeLowering(T, expansion);
201+
// FIXME: Expansion
202+
return getModule().Types.getTypeLowering(T,
203+
ResilienceExpansion::Minimal);
208204
}
209205

210206
void setOpenedArchetypesTracker(SILOpenedArchetypesTracker *Tracker) {
@@ -2162,7 +2158,15 @@ class SILBuilder {
21622158
if (!SILModuleConventions(M).useLoweredAddresses())
21632159
return true;
21642160

2165-
return getTypeLowering(Ty).isLoadable();
2161+
// FIXME: Just call getTypeLowering() here, and move this code there
2162+
2163+
auto expansion = ResilienceExpansion::Maximal;
2164+
// If there's no current SILFunction, we're inserting into a global
2165+
// variable initializer.
2166+
if (F)
2167+
expansion = F->getResilienceExpansion();
2168+
2169+
return M.Types.getTypeLowering(Ty, expansion).isLoadable();
21662170
}
21672171

21682172
void appendOperandTypeName(SILType OpdTy, llvm::SmallString<16> &Name) {

branches/tensorflow/include/swift/SIL/SILType.h

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,25 +252,46 @@ class SILType {
252252

253253
/// True if the type, or the referenced type of an address type, is loadable.
254254
/// This is the opposite of isAddressOnly.
255+
bool isLoadable(SILModule &M) const {
256+
return !isAddressOnly(M);
257+
}
258+
259+
/// Like isLoadable(SILModule), but specific to a function.
260+
///
261+
/// This takes the resilience expansion of the function into account. If the
262+
/// type is not loadable in general (because it's resilient), it still might
263+
/// be loadable inside a resilient function in the module.
264+
/// In other words: isLoadable(SILModule) is the conservative default, whereas
265+
/// isLoadable(SILFunction) might give a more optimistic result.
255266
bool isLoadable(const SILFunction &F) const {
256267
return !isAddressOnly(F);
257268
}
258269

259270
/// True if either:
260271
/// 1) The type, or the referenced type of an address type, is loadable.
261272
/// 2) The SIL Module conventions uses lowered addresses
273+
bool isLoadableOrOpaque(SILModule &M) const;
274+
275+
/// Like isLoadableOrOpaque(SILModule), but takes the resilience expansion of
276+
/// \p F into account (see isLoadable(SILFunction)).
262277
bool isLoadableOrOpaque(const SILFunction &F) const;
263278

264279
/// True if the type, or the referenced type of an address type, is
265280
/// address-only. This is the opposite of isLoadable.
281+
bool isAddressOnly(SILModule &M) const;
282+
283+
/// Like isAddressOnly(SILModule), but takes the resilience expansion of
284+
/// \p F into account (see isLoadable(SILFunction)).
266285
bool isAddressOnly(const SILFunction &F) const;
267286

268287
/// True if the type, or the referenced type of an address type, is trivial,
269288
/// meaning it is loadable and can be trivially copied, moved or detroyed.
270289
bool isTrivial(const SILFunction &F) const;
271290

272291
/// True if the type, or the referenced type of an address type, is known to
273-
/// be a scalar reference-counted type.
292+
/// be a scalar reference-counted type. If this is false, then some part of
293+
/// the type may be opaque. It may become reference counted later after
294+
/// specialization.
274295
bool isReferenceCounted(SILModule &M) const;
275296

276297
/// Returns true if the referenced type is a function type that never

branches/tensorflow/include/swift/SILOptimizer/Analysis/AliasAnalysis.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ class AliasAnalysis : public SILAnalysis {
137137
SILType TBAAType2 = SILType());
138138

139139
/// Returns True if memory of type \p T1 and \p T2 may alias.
140-
bool typesMayAlias(SILType T1, SILType T2, const SILFunction &F);
140+
bool typesMayAlias(SILType T1, SILType T2);
141141

142142
virtual void handleDeleteNotification(SILNode *node) override {
143143
assert(node->isRepresentativeSILNodeInObject());

branches/tensorflow/include/swift/SILOptimizer/Analysis/ArraySemantic.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ class ArraySemanticsCall {
151151

152152
/// Replace a call to append(contentsOf: ) with a series of
153153
/// append(element: ) calls.
154-
bool replaceByAppendingValues(SILFunction *AppendFn,
154+
bool replaceByAppendingValues(SILModule &M, SILFunction *AppendFn,
155155
SILFunction *ReserveFn,
156156
const llvm::SmallVectorImpl<SILValue> &Vals,
157157
SubstitutionMap Subs);

branches/tensorflow/include/swift/SILOptimizer/Utils/Generics.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,8 @@ class ReabstractionInfo {
156156
}
157157

158158
ResilienceExpansion getResilienceExpansion() const {
159-
return (Serialized
160-
? ResilienceExpansion::Minimal
161-
: ResilienceExpansion::Maximal);
159+
// FIXME: Expansion
160+
return ResilienceExpansion::Minimal;
162161
}
163162

164163
/// Returns true if the \p ParamIdx'th (non-result) formal parameter is

branches/tensorflow/lib/SIL/SILFunction.cpp

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -228,34 +228,45 @@ bool SILFunction::isNoReturnFunction() const {
228228

229229
const TypeLowering &
230230
SILFunction::getTypeLowering(AbstractionPattern orig, Type subst) {
231+
// FIXME: Expansion
231232
return getModule().Types.getTypeLowering(orig, subst,
232-
getResilienceExpansion());
233+
ResilienceExpansion::Minimal);
233234
}
234235

235236
const TypeLowering &SILFunction::getTypeLowering(Type t) const {
236-
return getModule().Types.getTypeLowering(t, getResilienceExpansion());
237+
// FIXME: Expansion
238+
return getModule().Types.getTypeLowering(t, ResilienceExpansion::Minimal);
237239
}
238240

239241
SILType
240242
SILFunction::getLoweredType(AbstractionPattern orig, Type subst) const {
243+
// FIXME: Expansion
241244
return getModule().Types.getLoweredType(orig, subst,
242-
getResilienceExpansion());
245+
ResilienceExpansion::Minimal);
243246
}
244247

245248
SILType SILFunction::getLoweredType(Type t) const {
246-
return getModule().Types.getLoweredType(t, getResilienceExpansion());
249+
// FIXME: Expansion
250+
return getModule().Types.getLoweredType(t,
251+
ResilienceExpansion::Minimal);
247252
}
248253

249254
SILType SILFunction::getLoweredLoadableType(Type t) const {
250-
return getModule().Types.getLoweredLoadableType(t, getResilienceExpansion());
255+
// FIXME: Expansion
256+
return getModule().Types.getLoweredLoadableType(t,
257+
ResilienceExpansion::Minimal);
251258
}
252259

253260
const TypeLowering &SILFunction::getTypeLowering(SILType type) const {
254-
return getModule().Types.getTypeLowering(type, getResilienceExpansion());
261+
// FIXME: Expansion
262+
return getModule().Types.getTypeLowering(type,
263+
ResilienceExpansion::Minimal);
255264
}
256265

257266
bool SILFunction::isTypeABIAccessible(SILType type) const {
258-
return getModule().isTypeABIAccessible(type, getResilienceExpansion());
267+
// FIXME: Expansion
268+
return getModule().isTypeABIAccessible(type,
269+
ResilienceExpansion::Minimal);
259270
}
260271

261272
SILBasicBlock *SILFunction::createBasicBlock() {

branches/tensorflow/lib/SIL/SILFunctionType.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,9 +1005,8 @@ static CanSILFunctionType getSILFunctionType(
10051005
// from the function to which the argument is attached.
10061006
if (constant && !constant->isDefaultArgGenerator()) {
10071007
if (auto function = constant->getAnyFunctionRef()) {
1008-
auto expansion = ResilienceExpansion::Maximal;
1009-
if (constant->isSerialized())
1010-
expansion = ResilienceExpansion::Minimal;
1008+
// FIXME: Expansion
1009+
auto expansion = ResilienceExpansion::Minimal;
10111010
lowerCaptureContextParameters(M, *function, genericSig, expansion,
10121011
inputs);
10131012
}

branches/tensorflow/lib/SIL/SILType.cpp

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ SILType SILType::getSILTokenType(const ASTContext &C) {
8181
}
8282

8383
bool SILType::isTrivial(const SILFunction &F) const {
84-
return F.getTypeLowering(*this).isTrivial();
84+
// FIXME: Should just call F.getTypeLowering()
85+
return F.getModule().Types.getTypeLowering(*this,
86+
ResilienceExpansion::Minimal).isTrivial();
8587
}
8688

8789
bool SILType::isReferenceCounted(SILModule &M) const {
@@ -175,13 +177,28 @@ SILType SILType::getEnumElementType(EnumElementDecl *elt, SILModule &M) const {
175177
return SILType(loweredTy, getCategory());
176178
}
177179

180+
bool SILType::isLoadableOrOpaque(SILModule &M) const {
181+
return isLoadable(M) || !SILModuleConventions(M).useLoweredAddresses();
182+
}
183+
178184
bool SILType::isLoadableOrOpaque(const SILFunction &F) const {
179185
SILModule &M = F.getModule();
180-
return isLoadable(F) || !SILModuleConventions(M).useLoweredAddresses();
186+
return isLoadable(F) ||
187+
!SILModuleConventions(M).useLoweredAddresses();
188+
}
189+
190+
/// True if the type, or the referenced type of an address type, is
191+
/// address-only. For example, it could be a resilient struct or something of
192+
/// unknown size.
193+
bool SILType::isAddressOnly(SILModule &M) const {
194+
return M.Types.getTypeLowering(*this, ResilienceExpansion::Minimal)
195+
.isAddressOnly();
181196
}
182197

183198
bool SILType::isAddressOnly(const SILFunction &F) const {
184-
return F.getTypeLowering(*this).isAddressOnly();
199+
// FIXME: Should just call F.getTypeLowering()
200+
return F.getModule().Types.getTypeLowering(*this,
201+
F.getResilienceExpansion()).isAddressOnly();
185202
}
186203

187204
SILType SILType::substGenericArgs(SILModule &M,

branches/tensorflow/lib/SILGen/RValue.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class ExplodeTupleValue
8585

8686
void visitType(CanType formalType, ManagedValue v) {
8787
// If we have a loadable type that has not been loaded, actually load it.
88-
if (!v.getType().isObject() && v.getType().isLoadable(SGF.F)) {
88+
if (!v.getType().isObject() && v.getType().isLoadable(SGF.getModule())) {
8989
if (v.isPlusOne(SGF)) {
9090
v = SGF.B.createLoadTake(loc, v);
9191
} else {
@@ -390,7 +390,7 @@ static void verifyHelper(ArrayRef<ManagedValue> values,
390390
auto result = Optional<ValueOwnershipKind>(ValueOwnershipKind::Any);
391391
Optional<bool> sameHaveCleanups;
392392
for (ManagedValue v : values) {
393-
assert((!SGF || !v.getType().isLoadable(SGF.get()->F) ||
393+
assert((!SGF || !v.getType().isLoadable(SGF.get()->getModule()) ||
394394
v.getType().isObject()) &&
395395
"All loadable values in an RValue must be an object");
396396

@@ -803,7 +803,7 @@ SILType RValue::getLoweredType(SILGenFunction &SGF) const & {
803803

804804
SILType RValue::getLoweredImplodedTupleType(SILGenFunction &SGF) const & {
805805
SILType loweredType = getLoweredType(SGF);
806-
if (loweredType.isAddressOnly(SGF.F) &&
806+
if (loweredType.isAddressOnly(SGF.getModule()) &&
807807
SGF.silConv.useLoweredAddresses())
808808
return loweredType.getAddressType();
809809
return loweredType.getObjectType();

0 commit comments

Comments
 (0)