Skip to content

Commit 8e50d4d

Browse files
authored
Merge pull request #2402 from swiftwasm/main
[pull] swiftwasm from main
2 parents 8f0c66f + 949b0c0 commit 8e50d4d

22 files changed

+2981
-143
lines changed

include/swift/AST/DiagnosticsParse.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,6 +1224,9 @@ NOTE(super_in_closure_with_capture_here,none,
12241224
"'self' explicitly captured here", ())
12251225

12261226
ERROR(try_before_await,none, "'await' must precede 'try'", ())
1227+
WARNING(warn_await_keyword,none,
1228+
"future versions of Swift reserve the word 'await'; "
1229+
"if this name is unavoidable, use backticks to escape it", ())
12271230

12281231
// Tuples and parenthesized expressions
12291232
ERROR(expected_expr_in_expr_list,none,

include/swift/IDE/IDERequests.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ class CollectOverriddenDeclsRequest:
234234
//----------------------------------------------------------------------------//
235235
struct ProtocolNameOwner {
236236
DeclContext *DC;
237-
StringRef Name;
237+
std::string Name;
238238
ProtocolNameOwner(DeclContext *DC, StringRef Name): DC(DC), Name(Name) {}
239239

240240
friend llvm::hash_code hash_value(const ProtocolNameOwner &CI) {

include/swift/SIL/InstructionUtils.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,13 @@ SILValue stripCasts(SILValue V);
3737
/// mark_dependence) from the current SILValue.
3838
SILValue stripCastsWithoutMarkDependence(SILValue V);
3939

40-
/// Return the underlying SILValue after stripping off all copy_value and
40+
/// Return the underlying SILValue after looking through all copy_value and
4141
/// begin_borrow instructions.
42-
SILValue stripOwnershipInsts(SILValue v);
42+
SILValue lookThroughOwnershipInsts(SILValue v);
43+
44+
/// Return the underlying SILValue after looking through all copy_value
45+
/// instructions.
46+
SILValue lookThroughCopyValueInsts(SILValue v);
4347

4448
/// Return the underlying SILValue after stripping off all upcasts from the
4549
/// current SILValue.

include/swift/SIL/SILInstruction.h

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,12 +523,20 @@ class SILInstruction
523523
private:
524524
/// Predicate used to filter OperandValueRange.
525525
struct OperandToValue;
526+
/// Predicate used to filter TransformedOperandValueRange.
527+
struct OperandToTransformedValue;
526528

527529
public:
528530
using OperandValueRange =
529531
OptionalTransformRange<ArrayRef<Operand>, OperandToValue>;
532+
using TransformedOperandValueRange =
533+
OptionalTransformRange<ArrayRef<Operand>, OperandToTransformedValue>;
534+
530535
OperandValueRange
531536
getOperandValues(bool skipTypeDependentOperands = false) const;
537+
TransformedOperandValueRange
538+
getOperandValues(std::function<SILValue(SILValue)> transformFn,
539+
bool skipTypeDependentOperands) const;
532540

533541
SILValue getOperand(unsigned Num) const {
534542
return getAllOperands()[Num].get();
@@ -727,13 +735,40 @@ struct SILInstruction::OperandToValue {
727735
}
728736
};
729737

738+
struct SILInstruction::OperandToTransformedValue {
739+
const SILInstruction &i;
740+
std::function<SILValue(SILValue)> transformFn;
741+
bool skipTypeDependentOps;
742+
743+
OperandToTransformedValue(const SILInstruction &i,
744+
std::function<SILValue(SILValue)> transformFn,
745+
bool skipTypeDependentOps)
746+
: i(i), transformFn(transformFn),
747+
skipTypeDependentOps(skipTypeDependentOps) {}
748+
749+
Optional<SILValue> operator()(const Operand &use) const {
750+
if (skipTypeDependentOps && i.isTypeDependentOperand(use))
751+
return None;
752+
return transformFn(use.get());
753+
}
754+
};
755+
730756
inline auto
731757
SILInstruction::getOperandValues(bool skipTypeDependentOperands) const
732758
-> OperandValueRange {
733759
return OperandValueRange(getAllOperands(),
734760
OperandToValue(*this, skipTypeDependentOperands));
735761
}
736762

763+
inline auto
764+
SILInstruction::getOperandValues(std::function<SILValue(SILValue)> transformFn,
765+
bool skipTypeDependentOperands) const
766+
-> TransformedOperandValueRange {
767+
return TransformedOperandValueRange(
768+
getAllOperands(),
769+
OperandToTransformedValue(*this, transformFn, skipTypeDependentOperands));
770+
}
771+
737772
struct SILInstruction::OperandToType {
738773
const SILInstruction &i;
739774

include/swift/SILOptimizer/Utils/OwnershipOptUtils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ struct OwnershipFixupContext {
4242
/// Namely, we do not support RAUWing values with ValueOwnershipKind::None
4343
/// that have uses that do not require ValueOwnershipKind::None or
4444
/// ValueOwnershipKind::Any.
45-
static bool canFixUpOwnershipForRAUW(SingleValueInstruction *oldValue,
45+
static bool canFixUpOwnershipForRAUW(const SingleValueInstruction *oldValue,
4646
SILValue newValue);
4747
};
4848

lib/Parse/ParseExpr.cpp

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -399,16 +399,22 @@ ParserResult<Expr> Parser::parseExprSequenceElement(Diag<> message,
399399
SyntaxParsingContext ElementContext(SyntaxContext,
400400
SyntaxContextKind::Expr);
401401

402-
if (shouldParseExperimentalConcurrency() && Tok.isContextualKeyword("await")) {
403-
SourceLoc awaitLoc = consumeToken();
404-
ParserResult<Expr> sub =
405-
parseExprSequenceElement(diag::expected_expr_after_await, isExprBasic);
406-
if (!sub.hasCodeCompletion() && !sub.isNull()) {
407-
ElementContext.setCreateSyntax(SyntaxKind::AwaitExpr);
408-
sub = makeParserResult(new (Context) AwaitExpr(awaitLoc, sub.get()));
409-
}
402+
if (Tok.isContextualKeyword("await")) {
403+
if (shouldParseExperimentalConcurrency()) {
404+
SourceLoc awaitLoc = consumeToken();
405+
ParserResult<Expr> sub =
406+
parseExprSequenceElement(diag::expected_expr_after_await, isExprBasic);
407+
if (!sub.hasCodeCompletion() && !sub.isNull()) {
408+
ElementContext.setCreateSyntax(SyntaxKind::AwaitExpr);
409+
sub = makeParserResult(new (Context) AwaitExpr(awaitLoc, sub.get()));
410+
}
410411

411-
return sub;
412+
return sub;
413+
} else {
414+
// warn that future versions of Swift will parse this token differently.
415+
diagnose(Tok.getLoc(), diag::warn_await_keyword)
416+
.fixItReplace(Tok.getLoc(), "`await`");
417+
}
412418
}
413419

414420
SourceLoc tryLoc;

lib/SIL/IR/SILInstruction.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,14 @@ namespace {
372372
return true;
373373
}
374374

375+
bool visitDestructureStructInst(const DestructureStructInst *RHS) {
376+
return true;
377+
}
378+
379+
bool visitDestructureTupleInst(const DestructureTupleInst *RHS) {
380+
return true;
381+
}
382+
375383
bool visitAllocRefInst(const AllocRefInst *RHS) {
376384
auto *LHSInst = cast<AllocRefInst>(LHS);
377385
auto LHSTypes = LHSInst->getTailAllocatedTypes();

lib/SIL/Utils/InstructionUtils.cpp

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
using namespace swift;
2727

28-
SILValue swift::stripOwnershipInsts(SILValue v) {
28+
SILValue swift::lookThroughOwnershipInsts(SILValue v) {
2929
while (true) {
3030
switch (v->getKind()) {
3131
default:
@@ -37,6 +37,14 @@ SILValue swift::stripOwnershipInsts(SILValue v) {
3737
}
3838
}
3939

40+
SILValue swift::lookThroughCopyValueInsts(SILValue val) {
41+
while (auto *cvi =
42+
dyn_cast_or_null<CopyValueInst>(val->getDefiningInstruction())) {
43+
val = cvi->getOperand();
44+
}
45+
return val;
46+
}
47+
4048
/// Strip off casts/indexing insts/address projections from V until there is
4149
/// nothing left to strip.
4250
///
@@ -46,7 +54,7 @@ SILValue swift::getUnderlyingObject(SILValue v) {
4654
SILValue v2 = stripCasts(v);
4755
v2 = stripAddressProjections(v2);
4856
v2 = stripIndexingInsts(v2);
49-
v2 = stripOwnershipInsts(v2);
57+
v2 = lookThroughOwnershipInsts(v2);
5058
if (v2 == v)
5159
return v2;
5260
v = v2;
@@ -58,7 +66,7 @@ SILValue swift::getUnderlyingObjectStopAtMarkDependence(SILValue v) {
5866
SILValue v2 = stripCastsWithoutMarkDependence(v);
5967
v2 = stripAddressProjections(v2);
6068
v2 = stripIndexingInsts(v2);
61-
v2 = stripOwnershipInsts(v2);
69+
v2 = lookThroughOwnershipInsts(v2);
6270
if (v2 == v)
6371
return v2;
6472
v = v2;
@@ -137,7 +145,7 @@ SILValue swift::stripCasts(SILValue v) {
137145
continue;
138146
}
139147
}
140-
SILValue v2 = stripOwnershipInsts(v);
148+
SILValue v2 = lookThroughOwnershipInsts(v);
141149
if (v2 != v) {
142150
v = v2;
143151
continue;
@@ -159,7 +167,7 @@ SILValue swift::stripUpCasts(SILValue v) {
159167
}
160168

161169
SILValue v2 = stripSinglePredecessorArgs(v);
162-
v2 = stripOwnershipInsts(v2);
170+
v2 = lookThroughOwnershipInsts(v2);
163171
if (v2 == v) {
164172
return v2;
165173
}
@@ -179,7 +187,7 @@ SILValue swift::stripClassCasts(SILValue v) {
179187
continue;
180188
}
181189

182-
SILValue v2 = stripOwnershipInsts(v);
190+
SILValue v2 = lookThroughOwnershipInsts(v);
183191
if (v2 != v) {
184192
v = v2;
185193
continue;

0 commit comments

Comments
 (0)