Skip to content

Multiple fixes to fix the release builds #5193

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions include/swift/SIL/SILOpenedArchetypesTracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ namespace swift {
class SILOpenedArchetypesTracker : public DeleteNotificationHandler {
public:
typedef llvm::DenseMap<Type, SILValue> OpenedArchetypeDefsMap;

SILOpenedArchetypesTracker(SILOpenedArchetypesTracker &Tracker)
: SILOpenedArchetypesTracker(Tracker.F, Tracker) {}

SILOpenedArchetypesTracker(const SILOpenedArchetypesTracker &Tracker)
: SILOpenedArchetypesTracker(Tracker.F) {
assert(Tracker.getOpenedArchetypeDefs().empty() &&
"Only empty const SILOpenedArchetypesTracker can be copied");
}

// Re-use pre-populated map if available.
SILOpenedArchetypesTracker(const SILFunction &F,
SILOpenedArchetypesTracker &Tracker)
Expand Down Expand Up @@ -105,6 +115,9 @@ class SILOpenedArchetypesTracker : public DeleteNotificationHandler {
}

private:
// Never copy
SILOpenedArchetypesTracker &operator = (const SILOpenedArchetypesTracker &) = delete;

/// The function whose opened archetypes are being tracked.
/// Used only for verification purposes.
const SILFunction &F;
Expand Down
2 changes: 1 addition & 1 deletion include/swift/Serialization/ModuleFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class ModuleFile : public LazyMemberLoader {
StringRef IdentifierData;

/// A callback to be invoked every time a type was deserialized.
llvm::function_ref<void(Type)> DeserializedTypeCallback;
std::function<void(Type)> DeserializedTypeCallback;

public:
/// Represents another module that has been imported as a dependency.
Expand Down
3 changes: 2 additions & 1 deletion lib/SILOptimizer/Transforms/SimplifyCFG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1601,7 +1601,8 @@ bool SimplifyCFG::simplifySwitchEnumUnreachableBlocks(SwitchEnumInst *SEI) {
.createUncheckedEnumData(SEI->getLoc(), SEI->getOperand(), Element, Ty);

assert(Dest->bbarg_size() == 1 && "Expected only one argument!");
ArrayRef<SILValue> Args = { UED };
SmallVector<SILValue, 1> Args;
Args.push_back(UED);
SILBuilderWithScope(SEI).createBranch(SEI->getLoc(), Dest, Args);

addToWorklist(SEI->getParent());
Expand Down
59 changes: 30 additions & 29 deletions lib/SILOptimizer/Utils/Generics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -628,37 +628,37 @@ static bool linkSpecialization(SILModule &M, SILFunction *F) {
return false;
}

// The whitelist of classes and functions from the stdlib,
// whose specializations we want to preserve.
static const char *const WhitelistedSpecializations[] = {
"Array",
"_ArrayBuffer",
"_ContiguousArrayBuffer",
"Range",
"RangeIterator",
"CountableRange",
"CountableRangeIterator",
"ClosedRange",
"ClosedRangeIterator",
"CountableClosedRange",
"CountableClosedRangeIterator",
"IndexingIterator",
"Collection",
"MutableCollection",
"BidirectionalCollection",
"RandomAccessCollection",
"RangeReplaceableCollection",
"_allocateUninitializedArray",
"UTF8",
"UTF16",
"String",
"_StringBuffer",
"_toStringReadOnlyPrintable",
};

/// Check of a given name could be a name of a white-listed
/// specialization.
bool swift::isWhitelistedSpecialization(StringRef SpecName) {
// The whitelist of classes and functions from the stdlib,
// whose specializations we want to preserve.
ArrayRef<StringRef> Whitelist = {
"Array",
"_ArrayBuffer",
"_ContiguousArrayBuffer",
"Range",
"RangeIterator",
"CountableRange",
"CountableRangeIterator",
"ClosedRange",
"ClosedRangeIterator",
"CountableClosedRange",
"CountableClosedRangeIterator",
"IndexingIterator",
"Collection",
"MutableCollection",
"BidirectionalCollection",
"RandomAccessCollection",
"RangeReplaceableCollection",
"_allocateUninitializedArray",
"UTF8",
"UTF16",
"String",
"_StringBuffer",
"_toStringReadOnlyPrintable",
};

// TODO: Once there is an efficient API to check if
// a given symbol is a specialization of a specific type,
// use it instead. Doing demangling just for this check
Expand Down Expand Up @@ -701,7 +701,8 @@ bool swift::isWhitelistedSpecialization(StringRef SpecName) {

pos += OfStr.size();

for (auto Name: Whitelist) {
for (auto NameStr: WhitelistedSpecializations) {
StringRef Name = NameStr;
auto pos1 = DemangledName.find(Name, pos);
if (pos1 == pos && !isalpha(DemangledName[pos1+Name.size()])) {
return true;
Expand Down