Skip to content

Commit 7b41f26

Browse files
Merge pull request #4709 from swiftwasm/release/5.7
[pull] swiftwasm-release/5.7 from release/5.7
2 parents 474ec38 + bb547c2 commit 7b41f26

File tree

55 files changed

+613
-145
lines changed

Some content is hidden

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

55 files changed

+613
-145
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4244,6 +4244,9 @@ NOTE(opaque_type_underlying_type_candidate_here,none,
42444244
ERROR(opaque_type_self_referential_underlying_type,none,
42454245
"function opaque return type was inferred as %0, which defines the "
42464246
"opaque type in terms of itself", (Type))
4247+
ERROR(opaque_type_cannot_contain_dynamic_self,none,
4248+
"function with opaque return type cannot return "
4249+
"the covariant 'Self' type of a class", ())
42474250
ERROR(opaque_type_var_no_init,none,
42484251
"property declares an opaque return type, but has no initializer "
42494252
"expression from which to infer an underlying type", ())

lib/AST/ASTMangler.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -822,6 +822,11 @@ std::string ASTMangler::mangleLocalTypeDecl(const TypeDecl *type) {
822822
AllowNamelessEntities = true;
823823
OptimizeProtocolNames = false;
824824

825+
// Local types are not ABI anyway. To avoid problems with the ASTDemangler,
826+
// don't respect @_originallyDefinedIn here, since we don't respect it
827+
// when mangling DWARF types for debug info.
828+
RespectOriginallyDefinedIn = false;
829+
825830
if (auto GTD = dyn_cast<GenericTypeDecl>(type)) {
826831
appendAnyGenericType(GTD);
827832
} else {

lib/AST/NameLookup.cpp

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include "swift/Basic/Statistic.h"
3737
#include "swift/ClangImporter/ClangImporterRequests.h"
3838
#include "swift/Parse/Lexer.h"
39+
#include "swift/Strings.h"
3940
#include "clang/AST/DeclObjC.h"
4041
#include "clang/Basic/Specifiers.h"
4142
#include "llvm/ADT/DenseMap.h"
@@ -1716,14 +1717,34 @@ NominalTypeDecl::lookupDirect(ObjCSelector selector, bool isInstance) {
17161717
return stored.Methods;
17171718
}
17181719

1719-
/// Is the new method an async alternative of any existing method, or vice
1720-
/// versa?
1721-
static bool isAnAsyncAlternative(AbstractFunctionDecl *newDecl,
1722-
llvm::TinyPtrVector<AbstractFunctionDecl *> &vec) {
1723-
return llvm::any_of(vec, [&](AbstractFunctionDecl *oldDecl) {
1720+
/// If there is an apparent conflict between \p newDecl and one of the methods
1721+
/// in \p vec, should we diagnose it?
1722+
static bool
1723+
shouldDiagnoseConflict(NominalTypeDecl *ty, AbstractFunctionDecl *newDecl,
1724+
llvm::TinyPtrVector<AbstractFunctionDecl *> &vec) {
1725+
// Are all conflicting methods imported from ObjC and in our ObjC half or a
1726+
// bridging header? Some code bases implement ObjC methods in Swift even
1727+
// though it's not exactly supported.
1728+
auto newDeclModuleName = newDecl->getModuleContext()->getName();
1729+
if (llvm::all_of(vec, [&](AbstractFunctionDecl *oldDecl) {
1730+
if (!oldDecl->hasClangNode())
1731+
return false;
1732+
auto oldDeclModuleName = oldDecl->getModuleContext()->getName();
1733+
return oldDeclModuleName == newDeclModuleName
1734+
|| oldDeclModuleName.str() == CLANG_HEADER_MODULE_NAME;
1735+
}))
1736+
return false;
1737+
1738+
// If we're looking at protocol requirements, is the new method an async
1739+
// alternative of any existing method, or vice versa?
1740+
if (isa<ProtocolDecl>(ty) &&
1741+
llvm::any_of(vec, [&](AbstractFunctionDecl *oldDecl) {
17241742
return newDecl->getAsyncAlternative(/*isKnownObjC=*/true) == oldDecl
17251743
|| oldDecl->getAsyncAlternative(/*isKnownObjC=*/true) == newDecl;
1726-
});
1744+
}))
1745+
return false;
1746+
1747+
return true;
17271748
}
17281749

17291750
void NominalTypeDecl::recordObjCMethod(AbstractFunctionDecl *method,
@@ -1743,7 +1764,7 @@ void NominalTypeDecl::recordObjCMethod(AbstractFunctionDecl *method,
17431764
if (auto *sf = method->getParentSourceFile()) {
17441765
if (vec.empty()) {
17451766
sf->ObjCMethodList.push_back(method);
1746-
} else if (!isa<ProtocolDecl>(this) || !isAnAsyncAlternative(method, vec)) {
1767+
} else if (shouldDiagnoseConflict(this, method, vec)) {
17471768
// We have a conflict.
17481769
sf->ObjCMethodConflicts.insert({ this, selector, isInstanceMethod });
17491770
}

lib/AST/RequirementMachine/RequirementLowering.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -987,7 +987,12 @@ TypeAliasRequirementsRequest::evaluate(Evaluator &evaluator,
987987
// to the associated type would have to be conditional, which we cannot
988988
// model.
989989
if (auto ext = dyn_cast<ExtensionDecl>(type->getDeclContext())) {
990-
if (ext->isConstrainedExtension()) continue;
990+
// FIXME: isConstrainedExtension() can cause request cycles because it
991+
// computes a generic signature. getTrailingWhereClause() should be good
992+
// enough for protocol extensions, which cannot specify constraints in
993+
// any other way right now (eg, via requirement inference or by
994+
// extending a bound generic type).
995+
if (ext->getTrailingWhereClause()) continue;
991996
}
992997

993998
// We found something.

lib/AST/TypeCheckRequests.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,10 +1230,7 @@ Optional<Type> DefaultArgumentTypeRequest::getCachedResult() const {
12301230
if (!defaultInfo)
12311231
return None;
12321232

1233-
if (!defaultInfo->InitContextAndIsTypeChecked.getInt())
1234-
return None;
1235-
1236-
return defaultInfo->ExprType;
1233+
return defaultInfo->ExprType ? defaultInfo->ExprType : Optional<Type>();
12371234
}
12381235

12391236
void DefaultArgumentTypeRequest::cacheResult(Type type) const {

lib/ClangImporter/ImportType.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2850,7 +2850,7 @@ ImportedType ClangImporter::Implementation::importMethodParamsAndReturnType(
28502850
importType(paramTy, importKind, paramAddDiag,
28512851
allowNSUIntegerAsIntInParam, Bridgeability::Full,
28522852
getImportTypeAttrs(param, /*isParam=*/true,
2853-
/*sendableByDefault=*/paramIsCompletionHandler),
2853+
/*sendableByDefault=*/false),
28542854
optionalityOfParam,
28552855
/*resugarNSErrorPointer=*/!paramIsError,
28562856
completionHandlerErrorParamIndex);

lib/SILOptimizer/PassManager/PassPipeline.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -767,6 +767,7 @@ static void addLateLoopOptPassPipeline(SILPassPipelinePlan &P) {
767767
// - don't require IRGen information.
768768
static void addLastChanceOptPassPipeline(SILPassPipelinePlan &P) {
769769
// Optimize access markers for improved IRGen after all other optimizations.
770+
P.addOptimizeHopToExecutor();
770771
P.addAccessEnforcementReleaseSinking();
771772
P.addAccessEnforcementOpts();
772773
P.addAccessEnforcementWMO();

lib/SILOptimizer/SemanticARC/OwnershipLiveRange.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,14 @@ OwnershipLiveRange::OwnershipLiveRange(SILValue value)
123123
continue;
124124

125125
for (auto *succArg : succBlock->getSILPhiArguments()) {
126-
// If we have an any value, just continue.
127-
if (succArg->getOwnershipKind() == OwnershipKind::None)
126+
// Owned values can get transformed to None values, currently we bail
127+
// out computing OwnershipLiveRange in this case, because it can lead to
128+
// incorrect results in the presence of dead edges on the non-trivial
129+
// paths of switch_enum.
130+
if (succArg->getOwnershipKind() == OwnershipKind::None) {
131+
tmpUnknownConsumingUses.push_back(op);
128132
continue;
133+
}
129134

130135
// Otherwise add all users of this BBArg to the worklist to visit
131136
// recursively.

lib/SILOptimizer/Transforms/AllocBoxToStack.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ static llvm::cl::opt<bool> AllocBoxToStackAnalyzeApply(
5353
// SIL Utilities for alloc_box Promotion
5454
//===----------------------------------------------------------------------===//
5555

56-
static SILValue stripOffCopyValue(SILValue V) {
57-
while (auto *CVI = dyn_cast<CopyValueInst>(V)) {
58-
V = CVI->getOperand();
56+
static SILValue stripOffCopyAndBorrow(SILValue V) {
57+
while (isa<CopyValueInst>(V) || isa<BeginBorrowInst>(V)) {
58+
V = cast<SingleValueInstruction>(V)->getOperand(0);
5959
}
6060
return V;
6161
}
@@ -127,7 +127,7 @@ static bool addLastRelease(SILValue V, SILBasicBlock *BB,
127127
for (auto I = BB->rbegin(); I != BB->rend(); ++I) {
128128
if (isa<StrongReleaseInst>(*I) || isa<DeallocBoxInst>(*I) ||
129129
isa<DestroyValueInst>(*I)) {
130-
if (stripOffCopyValue(I->getOperand(0)) != V)
130+
if (stripOffCopyAndBorrow(I->getOperand(0)) != V)
131131
continue;
132132

133133
Releases.push_back(&*I);

lib/Sema/CSApply.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5929,7 +5929,7 @@ ArgumentList *ExprRewriter::coerceCallArguments(
59295929

59305930
// If the argument is an existential type that has been opened, perform
59315931
// the open operation.
5932-
if (argType->getInOutObjectType()->isAnyExistentialType() &&
5932+
if (argType->getWithoutSpecifierType()->isAnyExistentialType() &&
59335933
paramType->hasOpenedExistential()) {
59345934
// FIXME: Look for an opened existential and use it. We need to
59355935
// know how far out we need to go to close the existentials. Huh.

0 commit comments

Comments
 (0)