Skip to content

Commit 56dcd68

Browse files
committed
---
yaml --- r: 268155 b: refs/heads/marcrasi-const-evaluator-part-2 c: 2848946 h: refs/heads/master i: 268153: 4f9f13c 268151: 99ba01d
1 parent 0da10b1 commit 56dcd68

Some content is hidden

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

41 files changed

+253
-1291
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1081,7 +1081,7 @@ refs/tags/swift-DEVELOPMENT-SNAPSHOT-2018-09-28-a: c30bf9b3ca148b1b90ebcd80141d9
10811081
refs/heads/bananaphone: 2af9a1dc7f40dcb4b2949876f7e237763d1a7972
10821082
refs/heads/marcrasi-const-evaluator-part-3: 867d96d6aa4cfb5079b7478be617387a1f621c88
10831083
refs/heads/marcrasi-const-evaluator-part-1: 390daeaeea2181a1fc24910e09b5861053cd3558
1084-
refs/heads/marcrasi-const-evaluator-part-2: d8f1917ec142687ebfd9998b4102ac1ddafc7b03
1084+
refs/heads/marcrasi-const-evaluator-part-2: 2848946dc683423b79d70fea4dedeba80a75d55a
10851085
refs/heads/revert-19689-keep-sourcekitd-response-alive-while-variant-lives: b5b1d9ab2340a64a3c7332529cdca1cb2318d93c
10861086
refs/tags/swift-4.2-DEVELOPMENT-SNAPSHOT-2018-10-01-a: 63059bdab8bbcdd68591738fa28c68c8c19bde75
10871087
refs/tags/swift-4.2-DEVELOPMENT-SNAPSHOT-2018-10-02-a: 12514879eff2c34a64ac6e65b323447f6525cfd0

branches/marcrasi-const-evaluator-part-2/docs/ABI/Mangling.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ The following symbolic reference kinds are currently implemented:
9090
dependent-associated-conformance ::= '\x05' .{4} // Reference points directly to associated conformance descriptor (NOT IMPLEMENTED)
9191
dependent-associated-conformance ::= '\x06' .{4} // Reference points indirectly to associated conformance descriptor (NOT IMPLEMENTED)
9292

93-
associated-conformance-access-function ::= '\x07' .{4} // Reference points directly to associated conformance access function relative to the protocol
94-
associated-conformance-access-function ::= '\x08' .{4} // Reference points directly to associated conformance access function relative to the conforming type
95-
keypath-metadata-access-function ::= '\x09' {.4} // Reference points directly to keypath conformance access function
93+
associated-conformance-acceess-function ::= '\x07' .{4} // Reference points directly to associated conformance access function relative to the protocol
94+
associated-conformance-acceess-function ::= '\x08' .{4} // Reference points directly to associated conformance access function relative to the conforming type
95+
keypath-metadata-access-function ::= '\x09' {.4} // Reference points directly to keypath type metadata access function
9696

9797
Globals
9898
~~~~~~~

branches/marcrasi-const-evaluator-part-2/include/swift/ABI/Metadata.h

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -2611,57 +2611,6 @@ class TargetGenericRequirementDescriptor {
26112611
using GenericRequirementDescriptor =
26122612
TargetGenericRequirementDescriptor<InProcess>;
26132613

2614-
template<typename Runtime>
2615-
class TargetGenericEnvironment
2616-
: public swift::ABI::TrailingObjects<TargetGenericEnvironment<Runtime>,
2617-
uint16_t, GenericParamDescriptor,
2618-
TargetGenericRequirementDescriptor<Runtime>> {
2619-
using GenericRequirementDescriptor =
2620-
TargetGenericRequirementDescriptor<Runtime>;
2621-
using TrailingObjects =
2622-
swift::ABI::TrailingObjects<TargetGenericEnvironment<Runtime>,
2623-
uint16_t, GenericParamDescriptor, GenericRequirementDescriptor>;
2624-
friend TrailingObjects;
2625-
2626-
template<typename T>
2627-
using OverloadToken = typename TrailingObjects::template OverloadToken<T>;
2628-
2629-
size_t numTrailingObjects(OverloadToken<uint16_t>) const {
2630-
return Flags.getNumGenericParameterLevels();
2631-
}
2632-
2633-
size_t numTrailingObjects(OverloadToken<GenericParamDescriptor>) const {
2634-
return getGenericParameterCounts().back();
2635-
}
2636-
2637-
size_t numTrailingObjects(OverloadToken<GenericRequirementDescriptor>) const {
2638-
return Flags.getNumGenericRequirements();
2639-
}
2640-
2641-
GenericEnvironmentFlags Flags;
2642-
2643-
public:
2644-
/// Retrieve the cumulative generic parameter counts at each level of genericity.
2645-
ArrayRef<uint16_t> getGenericParameterCounts() const {
2646-
return ArrayRef<uint16_t>(this->template getTrailingObjects<uint16_t>(),
2647-
Flags.getNumGenericParameterLevels());
2648-
}
2649-
2650-
/// Retrieve the generic parameters descriptors.
2651-
ArrayRef<GenericParamDescriptor> getGenericParameters() const {
2652-
return ArrayRef<GenericParamDescriptor>(
2653-
this->template getTrailingObjects<GenericParamDescriptor>(),
2654-
getGenericParameterCounts().back());
2655-
}
2656-
2657-
/// Retrieve the generic requirements.
2658-
ArrayRef<GenericRequirementDescriptor> getGenericRequirements() const {
2659-
return ArrayRef<GenericRequirementDescriptor>(
2660-
this->template getTrailingObjects<GenericRequirementDescriptor>(),
2661-
Flags.getNumGenericRequirements());
2662-
}
2663-
};
2664-
26652614
/// CRTP class for a context descriptor that includes trailing generic
26662615
/// context description.
26672616
template<class Self,

branches/marcrasi-const-evaluator-part-2/include/swift/ABI/MetadataValues.h

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1508,45 +1508,6 @@ enum class GenericRequirementLayoutKind : uint32_t {
15081508
Class = 0,
15091509
};
15101510

1511-
class GenericEnvironmentFlags {
1512-
uint32_t Value;
1513-
1514-
enum : uint32_t {
1515-
NumGenericParameterLevelsMask = 0xFFF,
1516-
NumGenericRequirementsShift = 12,
1517-
NumGenericRequirementsMask = 0xFFFF << NumGenericRequirementsShift,
1518-
};
1519-
1520-
constexpr explicit GenericEnvironmentFlags(uint32_t value) : Value(value) { }
1521-
1522-
public:
1523-
constexpr GenericEnvironmentFlags() : Value(0) { }
1524-
1525-
constexpr GenericEnvironmentFlags
1526-
withNumGenericParameterLevels(uint16_t numGenericParameterLevels) const {
1527-
return GenericEnvironmentFlags((Value &~ NumGenericParameterLevelsMask)
1528-
| numGenericParameterLevels);
1529-
}
1530-
1531-
constexpr GenericEnvironmentFlags
1532-
withNumGenericRequirements(uint16_t numGenericRequirements) const {
1533-
return GenericEnvironmentFlags((Value &~ NumGenericRequirementsMask)
1534-
| (numGenericRequirements << NumGenericRequirementsShift));
1535-
}
1536-
1537-
constexpr unsigned getNumGenericParameterLevels() const {
1538-
return Value & NumGenericParameterLevelsMask;
1539-
}
1540-
1541-
constexpr unsigned getNumGenericRequirements() const {
1542-
return (Value & NumGenericRequirementsMask) >> NumGenericRequirementsShift;
1543-
}
1544-
1545-
constexpr uint32_t getIntValue() const {
1546-
return Value;
1547-
}
1548-
};
1549-
15501511
/// Flags used by generic metadata patterns.
15511512
class GenericMetadataPatternFlags : public FlagSet<uint32_t> {
15521513
enum {

branches/marcrasi-const-evaluator-part-2/include/swift/Migrator/ASTMigratorPass.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,6 @@ void runAPIDiffMigratorPass(EditorAdapter &Editor,
5050
SourceFile *SF,
5151
const MigratorOptions &Opts);
5252

53-
/// Run a pass to fix up the new type of 'try?' in Swift 4
54-
void runOptionalTryMigratorPass(EditorAdapter &Editor,
55-
SourceFile *SF,
56-
const MigratorOptions &Opts);
57-
58-
5953
} // end namespace migrator
6054
} // end namespace swift
6155

branches/marcrasi-const-evaluator-part-2/lib/AST/ASTVerifier.cpp

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1958,21 +1958,15 @@ class Verifier : public ASTWalker {
19581958
void verifyChecked(OptionalTryExpr *E) {
19591959
PrettyStackTraceExpr debugStack(Ctx, "verifying OptionalTryExpr", E);
19601960

1961-
if (Ctx.LangOpts.isSwiftVersionAtLeast(5)) {
1962-
checkSameType(E->getType(), E->getSubExpr()->getType(),
1963-
"OptionalTryExpr and sub-expression");
1964-
}
1965-
else {
1966-
Type unwrappedType = E->getType()->getOptionalObjectType();
1967-
if (!unwrappedType) {
1968-
Out << "OptionalTryExpr result type is not optional\n";
1969-
abort();
1970-
}
1971-
1972-
checkSameType(unwrappedType, E->getSubExpr()->getType(),
1973-
"OptionalTryExpr and sub-expression");
1961+
Type unwrappedType = E->getType()->getOptionalObjectType();
1962+
if (!unwrappedType) {
1963+
Out << "OptionalTryExpr result type is not optional\n";
1964+
abort();
19741965
}
1975-
1966+
1967+
checkSameType(unwrappedType, E->getSubExpr()->getType(),
1968+
"OptionalTryExpr and sub-expression");
1969+
19761970
verifyCheckedBase(E);
19771971
}
19781972

branches/marcrasi-const-evaluator-part-2/lib/AST/Expr.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1821,13 +1821,6 @@ RebindSelfInConstructorExpr::getCalledConstructor(bool &isChainToSuper) const {
18211821
candidate = covariantExpr->getSubExpr();
18221822
continue;
18231823
}
1824-
1825-
// Look through inject into optional expressions
1826-
if (auto injectIntoOptionalExpr
1827-
= dyn_cast<InjectIntoOptionalExpr>(candidate)) {
1828-
candidate = injectIntoOptionalExpr->getSubExpr();
1829-
continue;
1830-
}
18311824
break;
18321825
}
18331826

branches/marcrasi-const-evaluator-part-2/lib/Demangling/Demangler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ swift::Demangle::makeSymbolicMangledNameStringRef(const char *base) {
136136
// Skip over symbolic references.
137137
if (*end >= '\x01' && *end <= '\x17')
138138
end += sizeof(uint32_t);
139-
else if (*end >= '\x18' && *end <= '\x1F')
139+
if (*end >= '\x18' && *end <= '\x1F')
140140
end += sizeof(void*);
141141
++end;
142142
}

branches/marcrasi-const-evaluator-part-2/lib/IRGen/GenKeyPath.cpp

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ emitGeneratorForKeyPath(IRGenModule &IGM,
657657
ArrayRef<GenericRequirement> requirements,
658658
llvm::function_ref<void(IRGenFunction&,CanType)> emit) {
659659

660-
return IGM.getAddrOfStringForMetadataRef(name, /*alignment=*/2,
660+
return IGM.getAddrOfStringForMetadataRef(name,
661661
/*shouldSetLowBit=*/true,
662662
[&](ConstantInitBuilder &B) {
663663
// Build a stub that loads the necessary bindings from the key path's
@@ -707,11 +707,34 @@ emitMetadataGeneratorForKeyPath(IRGenModule &IGM,
707707
CanType type,
708708
GenericEnvironment *genericEnv,
709709
ArrayRef<GenericRequirement> requirements) {
710-
// Produce a mangled name for the type.
711-
auto constant = IGM.getTypeRef(type, MangledTypeRefRole::Metadata);
712-
auto bitConstant = llvm::ConstantInt::get(IGM.IntPtrTy, 1);
713-
return llvm::ConstantExpr::getGetElementPtr(nullptr, constant, bitConstant);
714-
}
710+
// If we have a non-dependent type, use a normal mangled type name.
711+
if (!type->hasTypeParameter()) {
712+
auto constant = IGM.getTypeRef(type, MangledTypeRefRole::Metadata);
713+
auto bitConstant = llvm::ConstantInt::get(IGM.IntPtrTy, 1);
714+
return llvm::ConstantExpr::getGetElementPtr(nullptr, constant, bitConstant);
715+
}
716+
717+
// Otherwise, create an accessor.
718+
CanGenericSignature genericSig;
719+
if (genericEnv)
720+
genericSig = genericEnv->getGenericSignature()->getCanonicalSignature();
721+
722+
IRGenMangler mangler;
723+
std::string symbolName =
724+
mangler.mangleSymbolNameForKeyPathMetadata(
725+
"keypath_get_type", genericSig, type,
726+
ProtocolConformanceRef::forInvalid());
727+
728+
// TODO: Use the standard metadata accessor when there are no arguments
729+
// and the metadata accessor is defined.
730+
return emitGeneratorForKeyPath(IGM, symbolName, type,
731+
IGM.TypeMetadataPtrTy,
732+
genericEnv, requirements,
733+
[&](IRGenFunction &IGF, CanType substType) {
734+
auto ret = IGF.emitTypeMetadataRef(substType);
735+
IGF.Builder.CreateRet(ret);
736+
});
737+
};
715738

716739
static llvm::Constant *
717740
emitWitnessTableGeneratorForKeyPath(IRGenModule &IGM,
@@ -1148,9 +1171,6 @@ IRGenModule::getAddrOfKeyPathPattern(KeyPathPattern *pattern,
11481171
fields.addInt32(0);
11491172
}
11501173

1151-
// Add the generic environment.
1152-
fields.addRelativeAddressOrNull(
1153-
getAddrOfGenericEnvironment(pattern->getGenericSignature()));
11541174
// Store type references for the root and leaf.
11551175
fields.addRelativeAddress(
11561176
emitMetadataGeneratorForKeyPath(*this, rootTy, genericEnv, requirements));

branches/marcrasi-const-evaluator-part-2/lib/IRGen/GenProto.cpp

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@
6767
#include "GenericRequirement.h"
6868
#include "IRGenDebugInfo.h"
6969
#include "IRGenFunction.h"
70-
#include "IRGenMangler.h"
7170
#include "IRGenModule.h"
7271
#include "MetadataPath.h"
7372
#include "MetadataRequest.h"
@@ -3420,58 +3419,3 @@ llvm::Value *irgen::emitProtocolDescriptorRef(IRGenFunction &IGF,
34203419

34213420
return val;
34223421
}
3423-
3424-
llvm::Constant *IRGenModule::getAddrOfGenericEnvironment(
3425-
CanGenericSignature signature) {
3426-
if (!signature)
3427-
return nullptr;
3428-
3429-
IRGenMangler mangler;
3430-
auto symbolName = mangler.mangleSymbolNameForGenericEnvironment(signature);
3431-
return getAddrOfStringForMetadataRef(symbolName, /*alignment=*/0, false,
3432-
[&] (ConstantInitBuilder &builder) -> ConstantInitFuture {
3433-
/// Collect the cumulative count of parameters at each level.
3434-
llvm::SmallVector<uint16_t, 4> genericParamCounts;
3435-
unsigned curDepth = 0;
3436-
unsigned genericParamCount = 0;
3437-
for (const auto gp : signature->getGenericParams()) {
3438-
if (curDepth != gp->getDepth()) {
3439-
genericParamCounts.push_back(genericParamCount);
3440-
curDepth = gp->getDepth();
3441-
}
3442-
3443-
++genericParamCount;
3444-
}
3445-
genericParamCounts.push_back(genericParamCount);
3446-
3447-
auto flags = GenericEnvironmentFlags()
3448-
.withNumGenericParameterLevels(genericParamCounts.size())
3449-
.withNumGenericRequirements(signature->getRequirements().size());
3450-
3451-
ConstantStructBuilder fields = builder.beginStruct();
3452-
fields.setPacked(true);
3453-
3454-
// Flags
3455-
fields.addInt32(flags.getIntValue());
3456-
3457-
// Parameter counts.
3458-
for (auto count : genericParamCounts) {
3459-
fields.addInt16(count);
3460-
}
3461-
3462-
// Generic parameters.
3463-
signature->forEachParam([&](GenericTypeParamType *param,
3464-
bool canonical) {
3465-
fields.addInt(Int8Ty,
3466-
GenericParamDescriptor(GenericParamKind::Type,
3467-
canonical,
3468-
false)
3469-
.getIntValue());
3470-
});
3471-
3472-
// Generic requirements
3473-
irgen::addGenericRequirements(*this, fields, signature,
3474-
signature->getRequirements());
3475-
return fields.finishAndCreateFuture();
3476-
});
3477-
}

branches/marcrasi-const-evaluator-part-2/lib/IRGen/IRGenMangler.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -294,11 +294,3 @@ std::string IRGenMangler::mangleSymbolNameForKeyPathMetadata(
294294
assert(conformance.isInvalid() && "Unknown protocol conformance");
295295
return finalize();
296296
}
297-
298-
std::string IRGenMangler::mangleSymbolNameForGenericEnvironment(
299-
CanGenericSignature genericSig) {
300-
beginManglingWithoutPrefix();
301-
Buffer << "generic environment ";
302-
appendGenericSignature(genericSig);
303-
return finalize();
304-
}

branches/marcrasi-const-evaluator-part-2/lib/IRGen/IRGenMangler.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,8 +416,6 @@ class IRGenMangler : public Mangle::ASTMangler {
416416
CanType type,
417417
ProtocolConformanceRef conformance);
418418

419-
std::string mangleSymbolNameForGenericEnvironment(
420-
CanGenericSignature genericSig);
421419
protected:
422420
SymbolicMangling
423421
withSymbolicReferences(IRGenModule &IGM,

branches/marcrasi-const-evaluator-part-2/lib/IRGen/IRGenModule.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,7 +1032,6 @@ class IRGenModule {
10321032
///
10331033
/// \param symbolName The name of the symbol that describes the metadata
10341034
/// being referenced.
1035-
/// \param alignment If non-zero, the alignment of the requested variable.
10361035
/// \param shouldSetLowBit Whether to set the low bit of the result
10371036
/// constant, which is used by some clients to indicate that the result is
10381037
/// a mangled name.
@@ -1042,7 +1041,6 @@ class IRGenModule {
10421041
/// \returns the address of the global variable describing this metadata.
10431042
llvm::Constant *getAddrOfStringForMetadataRef(
10441043
StringRef symbolName,
1045-
unsigned alignment,
10461044
bool shouldSetLowBit,
10471045
llvm::function_ref<ConstantInitFuture(ConstantInitBuilder &)> body);
10481046

@@ -1278,7 +1276,6 @@ private: \
12781276
llvm::Constant *getAddrOfObjCModuleContextDescriptor();
12791277
llvm::Constant *getAddrOfClangImporterModuleContextDescriptor();
12801278
ConstantReference getAddrOfParentContextDescriptor(DeclContext *from);
1281-
llvm::Constant *getAddrOfGenericEnvironment(CanGenericSignature signature);
12821279
llvm::Constant *getAddrOfProtocolRequirementsBaseDescriptor(
12831280
ProtocolDecl *proto);
12841281
llvm::GlobalValue *defineProtocolRequirementsBaseDescriptor(

branches/marcrasi-const-evaluator-part-2/lib/IRGen/MetadataRequest.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,6 @@ MetadataDependency MetadataDependencyCollector::finish(IRGenFunction &IGF) {
220220

221221
llvm::Constant *IRGenModule::getAddrOfStringForMetadataRef(
222222
StringRef symbolName,
223-
unsigned alignment,
224223
bool shouldSetLowBit,
225224
llvm::function_ref<ConstantInitFuture (ConstantInitBuilder &)> body) {
226225
// Call this to form the return value.
@@ -252,8 +251,7 @@ llvm::Constant *IRGenModule::getAddrOfStringForMetadataRef(
252251
llvm::GlobalValue::HiddenVisibility,
253252
llvm::GlobalValue::DefaultStorageClass})
254253
.to(var);
255-
if (alignment)
256-
var->setAlignment(alignment);
254+
var->setAlignment(2);
257255
setTrueConstGlobal(var);
258256
var->setSection(getReflectionTypeRefSectionName());
259257

branches/marcrasi-const-evaluator-part-2/lib/Migrator/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ add_swift_host_library(swiftMigrator STATIC
4848
FixitApplyDiagnosticConsumer.cpp
4949
Migrator.cpp
5050
MigrationState.cpp
51-
OptionalTryMigratorPass.cpp
5251
RewriteBufferEditsReceiver.cpp
5352
LINK_LIBRARIES swiftSyntax swiftIDE)
5453

branches/marcrasi-const-evaluator-part-2/lib/Migrator/Migrator.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,6 @@ bool Migrator::performSyntacticPasses() {
197197

198198
runAPIDiffMigratorPass(Editor, StartInstance->getPrimarySourceFile(),
199199
getMigratorOptions());
200-
runOptionalTryMigratorPass(Editor, StartInstance->getPrimarySourceFile(),
201-
getMigratorOptions());
202200

203201
Edits.commit(Editor.getEdits());
204202

0 commit comments

Comments
 (0)