Skip to content

Commit f854f03

Browse files
authored
---
yaml --- r: 278519 b: refs/heads/swift-5.1-old-llvm-branch c: 45fa39c h: refs/heads/master i: 278517: 671ac0b 278515: 8e75c02 278511: be1dd0d
1 parent 18a535e commit f854f03

File tree

74 files changed

+2780
-1219
lines changed

Some content is hidden

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

74 files changed

+2780
-1219
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1241,7 +1241,7 @@ refs/tags/swift-DEVELOPMENT-SNAPSHOT-2019-01-24-a: b6f62823aa5010b2ae53f15f72a57
12411241
refs/heads/marcrasi-astverifier-disable: 3fac766a23a77ebd0640296bfd7fc116ea60a4e0
12421242
refs/heads/revert-22227-a-tall-white-fountain-played: adfce60b2eaa54903ea189bed8a783bca609fa53
12431243
refs/heads/revert-22300-revert-22227-a-tall-white-fountain-played: 5f92040224df7dd4e618fdfb367349df64d8acad
1244-
refs/heads/swift-5.1-old-llvm-branch: d26ca1cd3c62505caf79781770a120ab9e8c27e0
1244+
refs/heads/swift-5.1-old-llvm-branch: 45fa39c8553f786cfffccbf60224372dad152eee
12451245
refs/heads/swift-5.1-branch: 8060872acb4105d9655e020fe047e1ebcd77d0fb
12461246
refs/tags/swift-4.2.2-RELEASE: e429d1f1aaf59e69d38207a96e56265c7f6fccec
12471247
refs/tags/swift-5.0-DEVELOPMENT-SNAPSHOT-2019-02-02-a: 3e5a03d32ff3b1e9af90d6c1198c14f938379a6e

branches/swift-5.1-old-llvm-branch/include/swift/AST/NameLookup.h

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,20 +118,25 @@ class UnqualifiedLookup {
118118
/// That is, \c makeArrayRef(Results).take_front(IndexOfFirstOuterResults)
119119
/// will be Results from the innermost scope that had results, and the
120120
/// remaining elements of Results will be from parent scopes of this one.
121+
///
122+
/// Allows unqualified name lookup to return results from outer scopes.
123+
/// This is necessary for disambiguating calls to functions like `min` and
124+
/// `max`.
121125
size_t IndexOfFirstOuterResult;
122126

123127
/// Return true if anything was found by the name lookup.
124128
bool isSuccess() const { return !Results.empty(); }
125129

126130
/// Get the result as a single type, or a null type if that fails.
127-
TypeDecl *getSingleTypeResult();
131+
TypeDecl *getSingleTypeResult() const;
128132
};
129133

130134
inline UnqualifiedLookup::Options operator|(UnqualifiedLookup::Flags flag1,
131135
UnqualifiedLookup::Flags flag2) {
132136
return UnqualifiedLookup::Options(flag1) | flag2;
133137
}
134138

139+
135140
/// Describes the reason why a certain declaration is visible.
136141
enum class DeclVisibilityKind {
137142
/// Declaration is a local variable or type.
@@ -352,6 +357,29 @@ void lookupInModule(ModuleDecl *module, ModuleDecl::AccessPathTy accessPath,
352357
const DeclContext *moduleScopeContext,
353358
ArrayRef<ModuleDecl::ImportedModule> extraImports = {});
354359

360+
template <typename Fn>
361+
void forAllVisibleModules(const DeclContext *DC, const Fn &fn) {
362+
DeclContext *moduleScope = DC->getModuleScopeContext();
363+
if (auto file = dyn_cast<FileUnit>(moduleScope))
364+
file->forAllVisibleModules(fn);
365+
else
366+
cast<ModuleDecl>(moduleScope)
367+
->forAllVisibleModules(ModuleDecl::AccessPathTy(), fn);
368+
}
369+
370+
/// Only name lookup has gathered a set of results, perform any necessary
371+
/// steps to prune the result set before returning it to the caller.
372+
bool finishLookup(const DeclContext *dc, NLOptions options,
373+
SmallVectorImpl<ValueDecl *> &decls);
374+
375+
/// Do nothing if debugClient is null.
376+
template <typename Result>
377+
void filterForDiscriminator(SmallVectorImpl<Result> &results,
378+
DebuggerClient *debugClient);
379+
380+
void recordLookupOfTopLevelName(DeclContext *topLevelContext, DeclName name,
381+
bool isCascading);
382+
355383
} // end namespace namelookup
356384

357385
/// Retrieve the set of nominal type declarations that are directly

branches/swift-5.1-old-llvm-branch/include/swift/Demangling/Demangle.h

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift.org open source project
44
//
5-
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2014 - 2019 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See https://swift.org/LICENSE.txt for license information
@@ -35,6 +35,11 @@ namespace Demangle {
3535

3636
enum class SymbolicReferenceKind : uint8_t;
3737

38+
/// A simple default implementation that assigns letters to archetypes in
39+
/// alphabetic order.
40+
std::string archetypeName(uint64_t index, uint64_t depth);
41+
42+
/// Display style options for the demangler.
3843
struct DemangleOptions {
3944
bool SynthesizeSugarOnTypes = false;
4045
bool DisplayDebuggerGeneratedModule = true;
@@ -52,6 +57,7 @@ struct DemangleOptions {
5257
bool ShortenArchetype = false;
5358
bool ShowPrivateDiscriminators = true;
5459
bool ShowFunctionArgumentTypes = true;
60+
std::function<std::string(uint64_t, uint64_t)> ArchetypeName = archetypeName;
5561

5662
DemangleOptions() {}
5763

@@ -346,17 +352,19 @@ class Context {
346352
/// prefix: _T, _T0, $S, _$S.
347353
///
348354
/// \returns The demangled string.
349-
std::string demangleSymbolAsString(llvm::StringRef MangledName,
350-
const DemangleOptions &Options = DemangleOptions());
355+
std::string demangleSymbolAsString(
356+
llvm::StringRef MangledName,
357+
const DemangleOptions &Options = DemangleOptions());
351358

352359
/// Demangle the given type and return the readable name.
353360
///
354361
/// \param MangledName The mangled type string, which does _not_ start with
355362
/// a mangling prefix.
356363
///
357364
/// \returns The demangled string.
358-
std::string demangleTypeAsString(llvm::StringRef MangledName,
359-
const DemangleOptions &Options = DemangleOptions());
365+
std::string
366+
demangleTypeAsString(llvm::StringRef MangledName,
367+
const DemangleOptions &Options = DemangleOptions());
360368

361369
/// Returns true if the mangledName refers to a thunk function.
362370
///
@@ -584,7 +592,6 @@ bool nodeConsumesGenericArgs(Node *node);
584592
bool isSpecialized(Node *node);
585593

586594
NodePointer getUnspecialized(Node *node, NodeFactory &Factory);
587-
std::string archetypeName(Node::IndexType index, Node::IndexType depth);
588595

589596
/// Returns true if the node \p kind refers to a context node, e.g. a nominal
590597
/// type or a function.

branches/swift-5.1-old-llvm-branch/include/swift/Remote/MetadataReader.h

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2451,6 +2451,12 @@ class MetadataReader {
24512451
tryFindSymbol(_address, symbolName); \
24522452
tryReadSymbol(_address, dest); \
24532453
} while (0)
2454+
# define tryFindAndReadSymbolWithDefault(dest, symbolName, default) do { \
2455+
dest = default; \
2456+
auto _address = Reader->getSymbolAddress(symbolName); \
2457+
if (_address) \
2458+
tryReadSymbol(_address, dest); \
2459+
} while (0)
24542460

24552461
tryFindAndReadSymbol(TaggedPointerMask,
24562462
"objc_debug_taggedpointer_mask");
@@ -2463,30 +2469,34 @@ class MetadataReader {
24632469
if (!TaggedPointerClassesAddr)
24642470
finish(TaggedPointerEncodingKind::Error);
24652471
TaggedPointerClasses = TaggedPointerClassesAddr.getAddressData();
2466-
tryFindAndReadSymbol(TaggedPointerExtendedMask,
2467-
"objc_debug_taggedpointer_ext_mask");
2468-
tryFindAndReadSymbol(TaggedPointerExtendedSlotShift,
2469-
"objc_debug_taggedpointer_ext_slot_shift");
2470-
tryFindAndReadSymbol(TaggedPointerExtendedSlotMask,
2471-
"objc_debug_taggedpointer_ext_slot_mask");
2472-
tryFindSymbol(TaggedPointerExtendedClassesAddr,
2473-
"objc_debug_taggedpointer_ext_classes");
2474-
if (!TaggedPointerExtendedClassesAddr)
2475-
finish(TaggedPointerEncodingKind::Error);
2476-
TaggedPointerExtendedClasses =
2477-
TaggedPointerExtendedClassesAddr.getAddressData();
2472+
2473+
// Extended tagged pointers don't exist on older OSes. Handle those
2474+
// by setting the variables to zero.
2475+
tryFindAndReadSymbolWithDefault(TaggedPointerExtendedMask,
2476+
"objc_debug_taggedpointer_ext_mask",
2477+
0);
2478+
tryFindAndReadSymbolWithDefault(TaggedPointerExtendedSlotShift,
2479+
"objc_debug_taggedpointer_ext_slot_shift",
2480+
0);
2481+
tryFindAndReadSymbolWithDefault(TaggedPointerExtendedSlotMask,
2482+
"objc_debug_taggedpointer_ext_slot_mask",
2483+
0);
2484+
auto TaggedPointerExtendedClassesAddr =
2485+
Reader->getSymbolAddress("objc_debug_taggedpointer_ext_classes");
2486+
if (TaggedPointerExtendedClassesAddr)
2487+
TaggedPointerExtendedClasses =
2488+
TaggedPointerExtendedClassesAddr.getAddressData();
24782489

24792490
// The tagged pointer obfuscator is not present on older OSes, in
24802491
// which case we can treat it as zero.
2481-
TaggedPointerObfuscator = 0;
2482-
auto TaggedPointerObfuscatorAddr = Reader->getSymbolAddress(
2483-
"objc_debug_taggedpointer_obfuscator");
2484-
if (TaggedPointerObfuscatorAddr)
2485-
tryReadSymbol(TaggedPointerObfuscatorAddr, TaggedPointerObfuscator);
2486-
2492+
tryFindAndReadSymbolWithDefault(TaggedPointerObfuscator,
2493+
"objc_debug_taggedpointer_obfuscator",
2494+
0);
2495+
24872496
# undef tryFindSymbol
24882497
# undef tryReadSymbol
24892498
# undef tryFindAndReadSymbol
2499+
# undef tryFindAndReadSymbolWithDefault
24902500

24912501
return finish(TaggedPointerEncodingKind::Extended);
24922502
}

branches/swift-5.1-old-llvm-branch/include/swift/SIL/OptimizationRemark.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ struct Argument {
5050
Argument(StringRef Key, unsigned long long N);
5151

5252
Argument(StringRef Key, SILFunction *F);
53-
Argument(StringRef Key, SILType *Ty);
53+
Argument(StringRef Key, SILType Ty);
54+
Argument(StringRef Key, CanType Ty);
5455
};
5556

5657
/// Shorthand to insert named-value pairs.

branches/swift-5.1-old-llvm-branch/include/swift/SIL/SILBuilder.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -918,8 +918,10 @@ class SILBuilder {
918918
} \
919919
Copy##Name##ValueInst *createCopy##Name##Value(SILLocation Loc, \
920920
SILValue operand) { \
921+
auto type = getFunction().getLoweredType( \
922+
operand->getType().getASTType().getReferenceStorageReferent()); \
921923
return insert(new (getModule()) \
922-
Copy##Name##ValueInst(getSILDebugLocation(Loc), operand, getModule())); \
924+
Copy##Name##ValueInst(getSILDebugLocation(Loc), operand, type)); \
923925
}
924926
#define SOMETIMES_LOADABLE_CHECKED_REF_STORAGE(Name, ...) \
925927
NEVER_LOADABLE_CHECKED_REF_STORAGE(Name, "...") \

branches/swift-5.1-old-llvm-branch/include/swift/SIL/SILFunction.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ class SILModule;
3838
class SILFunctionBuilder;
3939
class SILProfiler;
4040

41+
namespace Lowering {
42+
class TypeLowering;
43+
class AbstractionPattern;
44+
}
45+
4146
enum IsBare_t { IsNotBare, IsBare };
4247
enum IsTransparent_t { IsNotTransparent, IsTransparent };
4348
enum Inline_t { InlineDefault, NoInline, AlwaysInline };
@@ -464,6 +469,19 @@ class SILFunction
464469
: ResilienceExpansion::Maximal);
465470
}
466471

472+
const Lowering::TypeLowering &
473+
getTypeLowering(Lowering::AbstractionPattern orig, Type subst);
474+
475+
const Lowering::TypeLowering &getTypeLowering(Type t) const;
476+
477+
SILType getLoweredType(Lowering::AbstractionPattern orig, Type subst) const;
478+
479+
SILType getLoweredType(Type t) const;
480+
481+
SILType getLoweredLoadableType(Type t) const;
482+
483+
const Lowering::TypeLowering &getTypeLowering(SILType type) const;
484+
467485
/// Returns true if this function has a calling convention that has a self
468486
/// argument.
469487
bool hasSelfParam() const {

branches/swift-5.1-old-llvm-branch/include/swift/SIL/SILInstruction.h

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3929,30 +3929,26 @@ class StoreReferenceInstBase : public InstructionBase<K, NonValueInstruction> {
39293929
/// \param loc The location of the expression that caused the load.
39303930
/// \param lvalue The SILValue representing the address to
39313931
/// use for the load.
3932-
#define NEVER_LOADABLE_CHECKED_REF_STORAGE(Name, ...) \
3932+
#define NEVER_OR_SOMETIMES_LOADABLE_CHECKED_REF_STORAGE(Name, ...) \
39333933
class Load##Name##Inst \
39343934
: public LoadReferenceInstBase<SILInstructionKind::Load##Name##Inst> { \
39353935
friend SILBuilder; \
39363936
Load##Name##Inst(SILDebugLocation loc, SILValue lvalue, IsTake_t isTake) \
39373937
: LoadReferenceInstBase(loc, lvalue, isTake) {} \
39383938
};
3939-
#define SOMETIMES_LOADABLE_CHECKED_REF_STORAGE(Name, ...) \
3940-
NEVER_LOADABLE_CHECKED_REF_STORAGE(Name, "...")
39413939
#include "swift/AST/ReferenceStorage.def"
39423940

39433941
/// Represents a store to a dynamic reference storage memory location.
39443942
/// This is only required for address-only scenarios; for loadable
39453943
/// references, it's better to use a ref_to_##name and a store.
3946-
#define NEVER_LOADABLE_CHECKED_REF_STORAGE(Name, ...) \
3944+
#define NEVER_OR_SOMETIMES_LOADABLE_CHECKED_REF_STORAGE(Name, ...) \
39473945
class Store##Name##Inst \
39483946
: public StoreReferenceInstBase<SILInstructionKind::Store##Name##Inst> { \
39493947
friend SILBuilder; \
39503948
Store##Name##Inst(SILDebugLocation loc, SILValue src, SILValue dest, \
39513949
IsInitialization_t isInit) \
39523950
: StoreReferenceInstBase(loc, src, dest, isInit) {} \
39533951
};
3954-
#define SOMETIMES_LOADABLE_CHECKED_REF_STORAGE(Name, ...) \
3955-
NEVER_LOADABLE_CHECKED_REF_STORAGE(Name, "...")
39563952
#include "swift/AST/ReferenceStorage.def"
39573953

39583954
/// CopyAddrInst - Represents a copy from one memory location to another. This
@@ -6332,9 +6328,8 @@ class Copy##Name##ValueInst \
63326328
SingleValueInstruction> { \
63336329
friend class SILBuilder; \
63346330
Copy##Name##ValueInst(SILDebugLocation DebugLoc, SILValue operand, \
6335-
SILModule &M) \
6336-
: UnaryInstructionBase(DebugLoc, operand, \
6337-
operand->getType().getReferentType(M)) {} \
6331+
SILType type) \
6332+
: UnaryInstructionBase(DebugLoc, operand, type) {} \
63386333
};
63396334
#include "swift/AST/ReferenceStorage.def"
63406335

branches/swift-5.1-old-llvm-branch/include/swift/SIL/SILModule.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,10 @@ class SILModule {
598598

599599
/// Can value operations (copies and destroys) on the given lowered type
600600
/// be performed in this module?
601-
bool isTypeABIAccessible(SILType type);
601+
// FIXME: Expansion
602+
bool isTypeABIAccessible(SILType type,
603+
ResilienceExpansion forExpansion
604+
= ResilienceExpansion::Minimal);
602605

603606
/// Can type metadata for the given formal type be fetched in
604607
/// the given module?

branches/swift-5.1-old-llvm-branch/include/swift/SIL/SILType.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -477,12 +477,6 @@ class SILType {
477477
/// representation. Class existentials do not always qualify.
478478
bool isHeapObjectReferenceType() const;
479479

480-
/// Return the SILType corresponding to the underlying type of the given
481-
/// metatype type.
482-
///
483-
/// *NOTE* Only call on SILTypes for metatype types.
484-
SILType getMetatypeInstanceType(SILModule& M) const;
485-
486480
/// Returns true if this SILType is an aggregate that contains \p Ty
487481
bool aggregateContainsRecord(SILType Ty, SILModule &SILMod) const;
488482

@@ -501,10 +495,6 @@ class SILType {
501495

502496
/// Returns true if this is the AnyObject SILType;
503497
bool isAnyObject() const { return getASTType()->isAnyObject(); }
504-
505-
/// Returns the underlying referent SILType of an @sil_unowned or @sil_weak
506-
/// Type.
507-
SILType getReferentType(SILModule &M) const;
508498

509499
/// Returns a SILType with any archetypes mapped out of context.
510500
SILType mapTypeOutOfContext() const;

branches/swift-5.1-old-llvm-branch/include/swift/SIL/TypeLowering.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -769,13 +769,16 @@ class TypeConverter {
769769
ResilienceExpansion::Minimal);
770770

771771
// Returns the lowered SIL type for a Swift type.
772-
SILType getLoweredType(Type t) {
773-
return getTypeLowering(t, ResilienceExpansion::Minimal).getLoweredType();
772+
SILType getLoweredType(Type t, ResilienceExpansion forExpansion
773+
= ResilienceExpansion::Minimal) {
774+
return getTypeLowering(t, forExpansion).getLoweredType();
774775
}
775776

776777
// Returns the lowered SIL type for a Swift type.
777-
SILType getLoweredType(AbstractionPattern origType, Type substType) {
778-
return getTypeLowering(origType, substType, ResilienceExpansion::Minimal)
778+
SILType getLoweredType(AbstractionPattern origType, Type substType,
779+
ResilienceExpansion forExpansion =
780+
ResilienceExpansion::Minimal) {
781+
return getTypeLowering(origType, substType, forExpansion)
779782
.getLoweredType();
780783
}
781784

branches/swift-5.1-old-llvm-branch/include/swift/SILOptimizer/Utils/Devirtualize.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class Emitter;
4444
/// \p Subs a container to be used for storing the set of subclasses
4545
void getAllSubclasses(ClassHierarchyAnalysis *CHA,
4646
ClassDecl *CD,
47-
SILType ClassType,
47+
CanType ClassType,
4848
SILModule &M,
4949
ClassHierarchyAnalysis::ClassList &Subs);
5050

@@ -69,18 +69,19 @@ ApplySite tryDevirtualizeApply(ApplySite AI,
6969
ClassHierarchyAnalysis *CHA,
7070
OptRemark::Emitter *ORE = nullptr);
7171
bool canDevirtualizeApply(FullApplySite AI, ClassHierarchyAnalysis *CHA);
72-
bool isNominalTypeWithUnboundGenericParameters(SILType Ty, SILModule &M);
73-
bool canDevirtualizeClassMethod(FullApplySite AI, SILType ClassInstanceType,
72+
bool canDevirtualizeClassMethod(FullApplySite AI, ClassDecl *CD,
7473
OptRemark::Emitter *ORE = nullptr,
7574
bool isEffectivelyFinalMethod = false);
76-
SILFunction *getTargetClassMethod(SILModule &M, SILType ClassOrMetatypeType,
75+
SILFunction *getTargetClassMethod(SILModule &M, ClassDecl *CD,
7776
MethodInst *MI);
77+
CanType getSelfInstanceType(CanType ClassOrMetatypeType);
7878

7979
/// Devirtualize the given apply site, which is known to be devirtualizable.
8080
///
8181
/// The caller must call deleteDevirtualizedApply on the original apply site.
8282
FullApplySite devirtualizeClassMethod(FullApplySite AI,
8383
SILValue ClassInstance,
84+
ClassDecl *CD,
8485
OptRemark::Emitter *ORE);
8586

8687
/// Attempt to devirtualize the given apply site, which is known to be
@@ -89,7 +90,9 @@ FullApplySite devirtualizeClassMethod(FullApplySite AI,
8990
/// If this succeeds, the caller must call deleteDevirtualizedApply on
9091
/// the original apply site.
9192
FullApplySite
92-
tryDevirtualizeClassMethod(FullApplySite AI, SILValue ClassInstance,
93+
tryDevirtualizeClassMethod(FullApplySite AI,
94+
SILValue ClassInstance,
95+
ClassDecl *CD,
9396
OptRemark::Emitter *ORE,
9497
bool isEffectivelyFinalMethod = false);
9598

0 commit comments

Comments
 (0)