Skip to content

Commit f72b5ac

Browse files
Merge pull request #5409 from swiftwasm/main
[pull] swiftwasm from main
2 parents ed3dd14 + ed3555a commit f72b5ac

File tree

114 files changed

+1070
-392
lines changed

Some content is hidden

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

114 files changed

+1070
-392
lines changed

SwiftCompilerSources/Sources/Optimizer/Analysis/CalleeAnalysis.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,9 @@ public struct CalleeAnalysis {
2323
return inst.instruction.isDeinitBarrier(bca.analysis)
2424
},
2525
// getMemBehaviorFn
26-
{ (bridgedCtxt: BridgedPassContext, bridgedApply: BridgedInstruction, observeRetains: Bool) -> swift.MemoryBehavior in
27-
let context = FunctionPassContext(_bridged: bridgedCtxt)
26+
{ (bridgedApply: BridgedInstruction, observeRetains: Bool, bca: BridgedCalleeAnalysis) -> swift.MemoryBehavior in
2827
let apply = bridgedApply.instruction as! ApplySite
29-
let e = context.calleeAnalysis.getSideEffects(of: apply)
28+
let e = bca.analysis.getSideEffects(of: apply)
3029
return e.getMemBehavior(observeRetains: observeRetains)
3130
}
3231
)

SwiftCompilerSources/Sources/Optimizer/Utilities/EscapeUtils.swift

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -361,10 +361,6 @@ fileprivate struct EscapeWalker<V: EscapeVisitor> : ValueDefUseWalker,
361361
case is ApplyInst, is TryApplyInst, is BeginApplyInst:
362362
return walkDownCallee(argOp: operand, apply: instruction as! FullApplySite, path: path)
363363
case let pai as PartialApplyInst:
364-
// This is a non-stack closure.
365-
// For `stack` closures, `hasRelevantType` in `walkDown` will return false
366-
// stopping the walk since they don't escape.
367-
368364
// Check whether the partially applied argument can escape in the body.
369365
if walkDownCallee(argOp: operand, apply: pai, path: path.with(knownType: nil)) == .abortWalk {
370366
return .abortWalk
@@ -376,8 +372,9 @@ fileprivate struct EscapeWalker<V: EscapeVisitor> : ValueDefUseWalker,
376372
// 2. something can escape in a destructor when the context is destroyed
377373
return walkDownUses(ofValue: pai, path: path.with(knownType: nil))
378374
case let pta as PointerToAddressInst:
379-
assert(operand.index == 0)
380375
return walkDownUses(ofAddress: pta, path: path.with(knownType: nil))
376+
case let cv as ConvertFunctionInst:
377+
return walkDownUses(ofValue: cv, path: path.with(knownType: nil))
381378
case let bi as BuiltinInst:
382379
switch bi.id {
383380
case .DestroyArray:
@@ -561,6 +558,12 @@ fileprivate struct EscapeWalker<V: EscapeVisitor> : ValueDefUseWalker,
561558
return .continueWalk
562559
}
563560

561+
if argOp.value.type.isNoEscapeFunction {
562+
// Per definition a `partial_apply [on_stack]` cannot escape the callee.
563+
// Potential escapes of its captured values are already handled when visiting the `partial_apply`.
564+
return .continueWalk
565+
}
566+
564567
// Argument effects do not consider any potential stores to the argument (or it's content).
565568
// Therefore, if we need to track stores, the argument effects do not correctly describe what we need.
566569
// For example, argument 0 in the following function is marked as not-escaping, although there

SwiftCompilerSources/Sources/SIL/Type.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public struct Type : CustomStringConvertible, NoReflectionChildren {
4141
public var isEnum: Bool { bridged.getEnumOrBoundGenericEnum() != nil }
4242
public var isFunction: Bool { bridged.isFunction() }
4343
public var isMetatype: Bool { bridged.isMetatype() }
44+
public var isNoEscapeFunction: Bool { bridged.isNoEscapeFunction() }
4445

4546
/// Can only be used if the type is in fact a nominal type (`isNominal` is true).
4647
public var nominal: NominalTypeDecl {

cmake/modules/SwiftSetIfArchBitness.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ function(set_if_arch_bitness var_name)
1414
"${SIA_ARCH}" STREQUAL "armv7" OR
1515
"${SIA_ARCH}" STREQUAL "armv7k" OR
1616
"${SIA_ARCH}" STREQUAL "arm64_32" OR
17+
"${SIA_ARCH}" STREQUAL "armv7m" OR
18+
"${SIA_ARCH}" STREQUAL "armv7em" OR
1719
"${SIA_ARCH}" STREQUAL "armv7s" OR
1820
"${SIA_ARCH}" STREQUAL "wasm32" OR
1921
"${SIA_ARCH}" STREQUAL "powerpc")

include/swift/AST/ASTWalker.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ struct ReferenceMetaData {
4848
SemaReferenceKind Kind;
4949
llvm::Optional<AccessKind> AccKind;
5050
bool isImplicit = false;
51+
bool isImplicitCtorType = false;
5152

5253
/// When non-none, this is a custom attribute reference.
5354
Optional<std::pair<const CustomAttr *, Decl *>> CustomAttrRef;

include/swift/AST/Decl.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8876,6 +8876,10 @@ const ParamDecl *getParameterAt(ConcreteDeclRef declRef, unsigned index);
88768876
/// nullptr if the source does not have a parameter list.
88778877
const ParamDecl *getParameterAt(const ValueDecl *source, unsigned index);
88788878

8879+
/// Retrieve parameter declaration from the given source at given index, or
8880+
/// nullptr if the source does not have a parameter list.
8881+
const ParamDecl *getParameterAt(const DeclContext *source, unsigned index);
8882+
88798883
void simple_display(llvm::raw_ostream &out,
88808884
OptionSet<NominalTypeDecl::LookupDirectFlags> options);
88818885

include/swift/AST/DiagnosticsClangImporter.def

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ NOTE(macro_not_imported, none, "macro '%0' unavailable (cannot import)", (String
156156

157157
NOTE(return_type_not_imported, none, "return type unavailable (cannot import)", ())
158158
NOTE(parameter_type_not_imported, none, "parameter %0 unavailable (cannot import)", (const clang::NamedDecl*))
159+
NOTE(rvalue_ref_params_not_imported, none, "C++ functions with rvalue reference parameters are unavailable in Swift", ())
159160
NOTE(incomplete_interface, none, "interface %0 is incomplete", (const clang::NamedDecl*))
160161
NOTE(incomplete_protocol, none, "protocol %0 is incomplete", (const clang::NamedDecl*))
161162
NOTE(incomplete_record, none, "record '%0' is not defined (incomplete)", (StringRef))
@@ -195,7 +196,7 @@ NOTE(mark_safe_to_import, none, "annotate method '%0' with 'SWIFT_RETURNS_INDEPE
195196
NOTE(at_to_subscript, none, "do you want to replace it with a call "
196197
"to the subscript operator?",
197198
())
198-
NOTE(get_swift_iterator, none, "do you want to make a Swift iterator instead?",
199+
NOTE(use_collection_apis, none, "do you want to use a for-in loop instead?",
199200
())
200201
NOTE(replace_with_nil, none, "do you want to compare against 'nil' instead?",
201202
())

include/swift/AST/DiagnosticsSema.def

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7123,6 +7123,11 @@ ERROR(moveonly_parameter_missing_ownership, none,
71237123
"noncopyable parameter must specify its ownership", ())
71247124
NOTE(moveonly_parameter_ownership_suggestion, none,
71257125
"add '%0' %1", (StringRef, StringRef))
7126+
ERROR(ownership_specifier_copyable,none,
7127+
"Copyable types cannot be 'consuming' or 'borrowing' yet", ())
7128+
ERROR(self_ownership_specifier_copyable,none,
7129+
"%0 is not yet valid on %1s in a Copyable type",
7130+
(SelfAccessKind, DescriptiveDeclKind))
71267131

71277132
//------------------------------------------------------------------------------
71287133
// MARK: Runtime discoverable attributes (@runtimeMetadata)

include/swift/AST/TypeCheckRequests.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3258,17 +3258,17 @@ void simple_display(llvm::raw_ostream &out,
32583258
class ResolveMacroRequest
32593259
: public SimpleRequest<ResolveMacroRequest,
32603260
ConcreteDeclRef(UnresolvedMacroReference,
3261-
const Decl *),
3261+
DeclContext *),
32623262
RequestFlags::Cached> {
32633263
public:
32643264
using SimpleRequest::SimpleRequest;
32653265

32663266
private:
32673267
friend SimpleRequest;
32683268

3269-
ConcreteDeclRef
3270-
evaluate(Evaluator &evaluator, UnresolvedMacroReference macroRef,
3271-
const Decl *decl) const;
3269+
ConcreteDeclRef evaluate(Evaluator &evaluator,
3270+
UnresolvedMacroReference macroRef,
3271+
DeclContext *decl) const;
32723272

32733273
public:
32743274
bool isCached() const { return true; }

include/swift/ClangImporter/ClangImporter.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,14 @@ namespace importer {
588588
/// Returns true if the given module has a 'cplusplus' requirement.
589589
bool requiresCPlusPlus(const clang::Module *module);
590590

591+
/// Returns the pointee type if the given type is a C++ `const`
592+
/// reference type, `None` otherwise.
593+
llvm::Optional<clang::QualType>
594+
getCxxReferencePointeeTypeOrNone(const clang::Type *type);
595+
596+
/// Returns true if the given type is a C++ `const` reference type.
597+
bool isCxxConstReferenceType(const clang::Type *type);
598+
591599
} // namespace importer
592600

593601
struct ClangInvocationFileMapping {

0 commit comments

Comments
 (0)