Skip to content

Commit 137b664

Browse files
authored
Merge pull request #3574 from swiftwasm/main
2 parents e4dc996 + e1a9be5 commit 137b664

File tree

117 files changed

+792
-215
lines changed

Some content is hidden

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

117 files changed

+792
-215
lines changed

benchmark/single-source/MapReduce.swift

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public func run_MapReduce(_ n: Int) {
7777
var c = 0
7878
for _ in 1...n*100 {
7979
numbers = numbers.map { $0 &+ 5 }
80-
c += numbers.reduce(0, &+)
80+
c = c &+ numbers.reduce(0, &+)
8181
}
8282
check(c != 0)
8383
}
@@ -89,7 +89,7 @@ public func run_MapReduceAnyCollection(_ n: Int) {
8989
var c = 0
9090
for _ in 1...n*100 {
9191
let mapped = numbers.map { $0 &+ 5 }
92-
c += mapped.reduce(0, &+)
92+
c = c &+ mapped.reduce(0, &+)
9393
}
9494
check(c != 0)
9595
}
@@ -101,7 +101,7 @@ public func run_MapReduceAnyCollectionShort(_ n: Int) {
101101
var c = 0
102102
for _ in 1...n*1_000 {
103103
let mapped = numbers.map { $0 &+ 5 }
104-
c += mapped.reduce(0, &+)
104+
c = c &+ mapped.reduce(0, &+)
105105
}
106106
check(c != 0)
107107
}
@@ -113,7 +113,7 @@ public func run_MapReduceShort(_ n: Int) {
113113
var c = 0
114114
for _ in 1...n*1_000 {
115115
numbers = numbers.map { $0 &+ 5 }
116-
c += numbers.reduce(0, &+)
116+
c = c &+ numbers.reduce(0, &+)
117117
}
118118
check(c != 0)
119119
}
@@ -125,7 +125,7 @@ public func run_MapReduceSequence(_ n: Int) {
125125
var c = 0
126126
for _ in 1...n*100 {
127127
let mapped = numbers.map { $0 &+ 5 }
128-
c += mapped.reduce(0, &+)
128+
c = c &+ mapped.reduce(0, &+)
129129
}
130130
check(c != 0)
131131
}
@@ -137,7 +137,7 @@ public func run_MapReduceLazySequence(_ n: Int) {
137137
var c = 0
138138
for _ in 1...n*100 {
139139
let mapped = numbers.lazy.map { $0 &+ 5 }
140-
c += mapped.reduce(0, &+)
140+
c = c &+ mapped.reduce(0, &+)
141141
}
142142
check(c != 0)
143143
}
@@ -149,7 +149,7 @@ public func run_MapReduceLazyCollection(_ n: Int) {
149149
var c = 0
150150
for _ in 1...n*100 {
151151
let mapped = numbers.lazy.map { $0 &+ 5 }
152-
c += mapped.reduce(0, &+)
152+
c = c &+ mapped.reduce(0, &+)
153153
}
154154
check(c != 0)
155155
}
@@ -161,7 +161,7 @@ public func run_MapReduceLazyCollectionShort(_ n: Int) {
161161
var c = 0
162162
for _ in 1...n*10000 {
163163
let mapped = numbers.lazy.map { $0 &+ 5 }
164-
c += mapped.reduce(0, &+)
164+
c = c &+ mapped.reduce(0, &+)
165165
}
166166
check(c != 0)
167167
}
@@ -172,7 +172,7 @@ public func run_MapReduceString(_ n: Int) {
172172

173173
var c: UInt64 = 0
174174
for _ in 1...n*100 {
175-
c += s.utf8.map { UInt64($0 &+ 5) }.reduce(0, &+)
175+
c = c &+ s.utf8.map { UInt64($0 &+ 5) }.reduce(0, &+)
176176
}
177177
check(c != 0)
178178
}
@@ -183,7 +183,7 @@ public func run_MapReduceShortString(_ n: Int) {
183183

184184
var c: UInt64 = 0
185185
for _ in 1...n*100 {
186-
c += s.utf8.map { UInt64($0 &+ 5) }.reduce(0, &+)
186+
c = c &+ s.utf8.map { UInt64($0 &+ 5) }.reduce(0, &+)
187187
}
188188
check(c != 0)
189189
}
@@ -196,7 +196,7 @@ public func run_MapReduceNSDecimalNumber(_ n: Int) {
196196
var c = 0
197197
for _ in 1...n*10 {
198198
let mapped = numbers.map { $0.intValue &+ 5 }
199-
c += mapped.reduce(0, &+)
199+
c = c &+ mapped.reduce(0, &+)
200200
}
201201
check(c != 0)
202202
#endif
@@ -210,7 +210,7 @@ public func run_MapReduceNSDecimalNumberShort(_ n: Int) {
210210
var c = 0
211211
for _ in 1...n*1_000 {
212212
let mapped = numbers.map { $0.intValue &+ 5 }
213-
c += mapped.reduce(0, &+)
213+
c = c &+ mapped.reduce(0, &+)
214214
}
215215
check(c != 0)
216216
#endif
@@ -224,7 +224,7 @@ public func run_MapReduceClass(_ n: Int) {
224224
var c = 0
225225
for _ in 1...n*10 {
226226
let mapped = numbers.map { $0.v &+ 5 }
227-
c += mapped.reduce(0, &+)
227+
c = c &+ mapped.reduce(0, &+)
228228
}
229229
check(c != 0)
230230
}
@@ -236,7 +236,7 @@ public func run_MapReduceClassShort(_ n: Int) {
236236
var c = 0
237237
for _ in 1...n*1_000 {
238238
let mapped = numbers.map { $0.v &+ 5 }
239-
c += mapped.reduce(0, &+)
239+
c = c &+ mapped.reduce(0, &+)
240240
}
241241
check(c != 0)
242242
}

cmake/modules/AddSwift.cmake

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -724,10 +724,15 @@ endfunction()
724724
# This is a temporary workaround until it's possible to compile libswift with
725725
# cmake's builtin swift support.
726726
function(add_libswift name)
727+
set(libswift_compile_options
728+
"-target" "x86_64-apple-macosx10.15" # TODO: remove this once #38675 lands.
729+
"-Xfrontend" "-validate-tbd-against-ir=none"
730+
"-Xfrontend" "-enable-cxx-interop")
731+
727732
if(CMAKE_BUILD_TYPE STREQUAL Debug)
728-
set(libswift_compile_options "-g")
733+
list(APPEND libswift_compile_options "-g")
729734
else()
730-
set(libswift_compile_options "-O" "-cross-module-optimization")
735+
list(APPEND libswift_compile_options "-O" "-cross-module-optimization")
731736
endif()
732737
733738
set(build_dir ${CMAKE_CURRENT_BINARY_DIR})

include/swift-c/DependencyScan/DependencyScan.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,9 @@ swiftscan_clang_detail_get_context_hash(swiftscan_module_details_t details);
203203
SWIFTSCAN_PUBLIC swiftscan_string_set_t *
204204
swiftscan_clang_detail_get_command_line(swiftscan_module_details_t details);
205205

206+
SWIFTSCAN_PUBLIC swiftscan_string_set_t *
207+
swiftscan_clang_detail_get_captured_pcm_args(swiftscan_module_details_t details);
208+
206209
//=== Batch Scan Input Functions ------------------------------------------===//
207210

208211
/// Create an \c swiftscan_batch_scan_input_t instance.

include/swift/AST/DiagnosticsModuleDiffer.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ ERROR(not_inheriting_convenience_inits,APIDigesterBreakage,"%0 no longer inherit
8888

8989
ERROR(enum_case_added,APIDigesterBreakage,"%0 has been added as a new enum case", (StringRef))
9090

91-
ERROR(demangled_name_changed,APIDigesterBreakage,"%0 has mangled name changing from '%1' to '%2'", (StringRef, StringRef, StringRef))
91+
WARNING(demangled_name_changed,APIDigesterBreakage,"%0 has mangled name changing from '%1' to '%2'", (StringRef, StringRef, StringRef))
9292

9393
WARNING(cannot_read_allowlist,none,"cannot read breakage allowlist at '%0'", (StringRef))
9494

include/swift/AST/DiagnosticsSIL.def

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -676,9 +676,9 @@ WARNING(semantic_function_improper_nesting, none, "'@_semantics' function calls
676676

677677
// Capture promotion diagnostics
678678
WARNING(capturepromotion_concurrentcapture_mutation, none,
679-
"'%0' mutated after capture by concurrent closure", (StringRef))
679+
"'%0' mutated after capture by sendable closure", (StringRef))
680680
NOTE(capturepromotion_concurrentcapture_closure_here, none,
681-
"variable captured by concurrent closure", ())
681+
"variable captured by sendable closure", ())
682682
NOTE(capturepromotion_concurrentcapture_capturinguse_here, none,
683683
"capturing use", ())
684684
NOTE(capturepromotion_variable_defined_here,none,

include/swift/AST/DiagnosticsSema.def

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3883,28 +3883,28 @@ NOTE(silence_debug_description_in_interpolation_segment_call,none,
38833883
"use 'String(describing:)' to silence this warning", ())
38843884

38853885
NOTE(noescape_parameter,none,
3886-
"parameter %1 is implicitly %select{non-escaping|non-concurrent}0",
3886+
"parameter %1 is implicitly %select{non-escaping|non-sendable}0",
38873887
(unsigned, Identifier))
38883888
NOTE(generic_parameters_always_escaping,none,
38893889
"generic parameters are always considered '@escaping'", ())
38903890

38913891
ERROR(passing_noattrfunc_to_attrfunc,none,
3892-
"passing %select{non-escaping|non-concurrent}0 parameter %1 to function "
3892+
"passing %select{non-escaping|non-sendable}0 parameter %1 to function "
38933893
"expecting %select{an @escaping|a @Sendable}0 closure",
38943894
(unsigned, Identifier))
38953895
ERROR(converting_noespace_param_to_generic_type,none,
38963896
"converting non-escaping parameter %0 to generic parameter %1 may allow it to escape",
38973897
(Identifier, Type))
38983898
ERROR(assigning_noattrfunc_to_attrfunc,none,
3899-
"assigning %select{non-escaping|non-concurrent}0 parameter %1 to "
3899+
"assigning %select{non-escaping|non-sendable}0 parameter %1 to "
39003900
"%select{an @escaping|a @Sendable}0 closure",
39013901
(unsigned, Identifier))
39023902
ERROR(general_noattrfunc_to_attr,none,
3903-
"using %select{non-escaping|non-concurrent}0 parameter %1 in a context "
3903+
"using %select{non-escaping|non-sendable}0 parameter %1 in a context "
39043904
"expecting %select{an @escaping|a @Sendable}0 closure",
39053905
(unsigned, Identifier))
39063906
ERROR(converting_noattrfunc_to_type,none,
3907-
"converting %select{non-escaping|non-concurrent function}0 value to %1 "
3907+
"converting %select{non-escaping|non-sendable function}0 value to %1 "
39083908
"may %select{allow it to escape|introduce data races}0",
39093909
(unsigned, Type))
39103910
NOTE(escape_expected_at_parameter_position,none,

include/swift/AST/ModuleDependencies.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,16 +247,22 @@ class ClangModuleDependenciesStorage : public ModuleDependenciesStorageBase {
247247
/// The file dependencies
248248
const std::vector<std::string> fileDependencies;
249249

250+
/// The swift-specific PCM arguments captured by this dependencies object
251+
/// as found by the scanning action that discovered it
252+
const std::vector<std::string> capturedPCMArgs;
253+
250254
ClangModuleDependenciesStorage(
251255
const std::string &moduleMapFile,
252256
const std::string &contextHash,
253257
const std::vector<std::string> &nonPathCommandLine,
254-
const std::vector<std::string> &fileDependencies
258+
const std::vector<std::string> &fileDependencies,
259+
const std::vector<std::string> &capturedPCMArgs
255260
) : ModuleDependenciesStorageBase(ModuleDependenciesKind::Clang),
256261
moduleMapFile(moduleMapFile),
257262
contextHash(contextHash),
258263
nonPathCommandLine(nonPathCommandLine),
259-
fileDependencies(fileDependencies) { }
264+
fileDependencies(fileDependencies),
265+
capturedPCMArgs(capturedPCMArgs) {}
260266

261267
ModuleDependenciesStorageBase *clone() const override {
262268
return new ClangModuleDependenciesStorage(*this);
@@ -361,10 +367,12 @@ class ModuleDependencies {
361367
const std::string &moduleMapFile,
362368
const std::string &contextHash,
363369
const std::vector<std::string> &nonPathCommandLine,
364-
const std::vector<std::string> &fileDependencies) {
370+
const std::vector<std::string> &fileDependencies,
371+
const std::vector<std::string> &capturedPCMArgs) {
365372
return ModuleDependencies(
366373
std::make_unique<ClangModuleDependenciesStorage>(
367-
moduleMapFile, contextHash, nonPathCommandLine, fileDependencies));
374+
moduleMapFile, contextHash, nonPathCommandLine,
375+
fileDependencies, capturedPCMArgs));
368376
}
369377

370378
/// Describe a placeholder dependency swift module.

include/swift/DependencyScan/DependencyScanImpl.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ typedef struct {
129129

130130
/// Options to the compile command required to build this clang modulemap
131131
swiftscan_string_set_t *command_line;
132+
133+
/// The swift-specific PCM arguments captured by this dependencies object
134+
swiftscan_string_set_t *captured_pcm_args;
132135
} swiftscan_clang_details_t;
133136

134137
struct swiftscan_module_details_s {

include/swift/DependencyScan/SerializedModuleDependencyCacheFormat.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ const unsigned MODULE_DEPENDENCY_CACHE_FORMAT_VERSION_MINOR = 0;
4646
using IdentifierIDField = BCVBR<13>;
4747
using FileIDField = IdentifierIDField;
4848
using ModuleIDField = IdentifierIDField;
49-
using CompilerFlagField = IdentifierIDField;
5049
using ContextHashField = IdentifierIDField;
5150

5251
/// A bit that indicates whether or not a module is a framework
@@ -166,7 +165,8 @@ using ClangModuleDetailsLayout =
166165
FileIDField, // moduleMapPath
167166
ContextHashField, // contextHash
168167
FlagIDArrayIDField, // commandLine
169-
FileIDArrayIDField // fileDependencies
168+
FileIDArrayIDField, // fileDependencies
169+
FlagIDArrayIDField // capturedPCMArgs
170170
>;
171171
} // namespace graph_block
172172

include/swift/Runtime/Concurrent.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ template <class ElemTy> struct ConcurrentList {
6363

6464
/// Remove all of the links in the chain. This method leaves
6565
/// the list at a usable state and new links can be added.
66-
/// Notice that this operation is non-concurrent because
66+
/// Notice that this operation is non-sendable because
6767
/// we have no way of ensuring that no one is currently
6868
/// traversing the list.
6969
void clear() {

include/swift/SIL/SILBridging.h

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,7 @@
1515

1616
#include "BridgedSwiftObject.h"
1717
#include <stddef.h>
18-
19-
#ifdef __cplusplus
20-
extern "C" {
21-
#endif
18+
#include <string>
2219

2320
typedef struct {
2421
const unsigned char * _Nullable data;
@@ -155,17 +152,17 @@ BridgedSlab PassContext_freeSlab(BridgedPassContext passContext,
155152
BridgedSlab slab);
156153

157154
BridgedStringRef SILFunction_getName(BridgedFunction function);
158-
BridgedStringRef SILFunction_debugDescription(BridgedFunction function);
155+
std::string SILFunction_debugDescription(BridgedFunction function);
159156
OptionalBridgedBasicBlock SILFunction_firstBlock(BridgedFunction function);
160157
OptionalBridgedBasicBlock SILFunction_lastBlock(BridgedFunction function);
161158

162159
BridgedStringRef SILGlobalVariable_getName(BridgedGlobalVar global);
163-
BridgedStringRef SILGlobalVariable_debugDescription(BridgedGlobalVar global);
160+
std::string SILGlobalVariable_debugDescription(BridgedGlobalVar global);
164161

165162
OptionalBridgedBasicBlock SILBasicBlock_next(BridgedBasicBlock block);
166163
OptionalBridgedBasicBlock SILBasicBlock_previous(BridgedBasicBlock block);
167164
BridgedFunction SILBasicBlock_getFunction(BridgedBasicBlock block);
168-
BridgedStringRef SILBasicBlock_debugDescription(BridgedBasicBlock block);
165+
std::string SILBasicBlock_debugDescription(BridgedBasicBlock block);
169166
OptionalBridgedInstruction SILBasicBlock_firstInst(BridgedBasicBlock block);
170167
OptionalBridgedInstruction SILBasicBlock_lastInst(BridgedBasicBlock block);
171168
SwiftInt SILBasicBlock_getNumArguments(BridgedBasicBlock block);
@@ -179,7 +176,7 @@ BridgedValue Operand_getValue(BridgedOperand);
179176
OptionalBridgedOperand Operand_nextUse(BridgedOperand);
180177
BridgedInstruction Operand_getUser(BridgedOperand);
181178

182-
BridgedStringRef SILNode_debugDescription(BridgedNode node);
179+
std::string SILNode_debugDescription(BridgedNode node);
183180
OptionalBridgedOperand SILValue_firstUse(BridgedValue value);
184181
BridgedType SILValue_getType(BridgedValue value);
185182

@@ -227,8 +224,4 @@ BridgedInstruction SILBuilder_createBuiltinBinaryFunction(
227224
BridgedInstruction SILBuilder_createCondFail(BridgedInstruction insertionPoint,
228225
BridgedLocation loc, BridgedValue condition, BridgedStringRef messge);
229226

230-
#ifdef __cplusplus
231-
} // extern "C"
232-
#endif
233-
234227
#endif

include/swift/Sema/ConstraintSystem.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -768,8 +768,18 @@ enum ScoreKind {
768768
SK_ValueToPointerConversion,
769769
/// A closure/function conversion to an autoclosure parameter.
770770
SK_FunctionToAutoClosureConversion,
771-
772-
SK_LastScoreKind = SK_FunctionToAutoClosureConversion,
771+
/// An unapplied reference to a function. The purpose of this
772+
/// score bit is to prune overload choices that are functions
773+
/// when a solution has already been found using property.
774+
///
775+
/// \Note The solver only prefers variables over functions
776+
/// to resolve ambiguities, so please be sure that any score
777+
/// kind added after this is truly less impactful. Only other
778+
/// ambiguity tie-breakers should go after this; anything else
779+
/// should be added above.
780+
SK_UnappliedFunction,
781+
782+
SK_LastScoreKind = SK_UnappliedFunction,
773783
};
774784

775785
/// The number of score kinds.

lib/AST/ClangTypeConverter.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,6 @@ ClangTypeConverter::getClangTemplateArguments(
865865
ArrayRef<Type> genericArgs,
866866
SmallVectorImpl<clang::TemplateArgument> &templateArgs) {
867867
assert(templateArgs.size() == 0);
868-
assert(genericArgs.size() == templateParams->size());
869868

870869
// Keep track of the types we failed to convert so we can return a useful
871870
// error.
@@ -874,6 +873,13 @@ ClangTypeConverter::getClangTemplateArguments(
874873
// Note: all template parameters must be template type parameters. This is
875874
// verified when we import the Clang decl.
876875
auto templateParam = cast<clang::TemplateTypeParmDecl>(param);
876+
// We must have found a defaulted parameter at the end of the list.
877+
if (templateParam->getIndex() >= genericArgs.size()) {
878+
templateArgs.push_back(
879+
clang::TemplateArgument(templateParam->getDefaultArgument()));
880+
continue;
881+
}
882+
877883
auto replacement = genericArgs[templateParam->getIndex()];
878884
auto qualType = convert(replacement);
879885
if (qualType.isNull()) {

0 commit comments

Comments
 (0)