Skip to content

Commit 7f8b000

Browse files
authored
Merge pull request #2360 from swiftwasm/main
[pull] swiftwasm from main
2 parents 34d0c43 + fd1fd25 commit 7f8b000

File tree

82 files changed

+1503
-982
lines changed

Some content is hidden

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

82 files changed

+1503
-982
lines changed

docs/ABI/Mangling.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ types where the metadata itself has unknown layout.)
207207
global ::= global 'TD' // dynamic dispatch thunk
208208
global ::= global 'Td' // direct method reference thunk
209209
global ::= global 'TI' // implementation of a dynamic_replaceable function
210+
global :== global 'Tu' // async function pointer of a function
210211
global ::= global 'TX' // function pointer of a dynamic_replaceable function
211212
global ::= entity entity 'TV' // vtable override thunk, derived followed by base
212213
global ::= type label-list? 'D' // type mangling for the debugger with label list for function types.
@@ -493,6 +494,7 @@ Types
493494
type ::= 'Bb' // Builtin.BridgeObject
494495
type ::= 'BB' // Builtin.UnsafeValueBuffer
495496
type ::= 'Bc' // Builtin.RawUnsafeContinuation
497+
type ::= 'BD' // Builtin.DefaultActorStorage
496498
type ::= 'Bf' NATURAL '_' // Builtin.Float<n>
497499
type ::= 'Bi' NATURAL '_' // Builtin.Int<n>
498500
type ::= 'BI' // Builtin.IntLiteral

include/swift/AST/TypeNodes.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ ABSTRACT_TYPE(Builtin, Type)
110110
BUILTIN_TYPE(BuiltinNativeObject, BuiltinType)
111111
BUILTIN_TYPE(BuiltinBridgeObject, BuiltinType)
112112
BUILTIN_TYPE(BuiltinUnsafeValueBuffer, BuiltinType)
113+
BUILTIN_TYPE(BuiltinDefaultActorStorage, BuiltinType)
113114
BUILTIN_TYPE(BuiltinVector, BuiltinType)
114115
TYPE_RANGE(Builtin, BuiltinInteger, BuiltinVector)
115116
TYPE(Tuple, Type)
@@ -185,6 +186,7 @@ SINGLETON_TYPE(RawUnsafeContinuation, BuiltinRawUnsafeContinuation)
185186
SINGLETON_TYPE(NativeObject, BuiltinNativeObject)
186187
SINGLETON_TYPE(BridgeObject, BuiltinBridgeObject)
187188
SINGLETON_TYPE(UnsafeValueBuffer, BuiltinUnsafeValueBuffer)
189+
SINGLETON_TYPE(DefaultActorStorage, BuiltinDefaultActorStorage)
188190
SINGLETON_TYPE(SILToken, SILToken)
189191
#undef SINGLETON_TYPE
190192
#endif

include/swift/AST/Types.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1420,6 +1420,22 @@ class BuiltinJobType : public BuiltinType {
14201420
};
14211421
DEFINE_EMPTY_CAN_TYPE_WRAPPER(BuiltinJobType, BuiltinType);
14221422

1423+
/// BuiltinDefaultActorStorageType - The type of the stored property
1424+
/// that's added implicitly to default actors. No C equivalent because
1425+
/// the C types all include a heap-object header. Similarly, this type
1426+
/// generally does not appear in the AST/SIL around default actors;
1427+
/// it's purely a convenience in IRGen.
1428+
class BuiltinDefaultActorStorageType : public BuiltinType {
1429+
friend class ASTContext;
1430+
BuiltinDefaultActorStorageType(const ASTContext &C)
1431+
: BuiltinType(TypeKind::BuiltinDefaultActorStorage, C) {}
1432+
public:
1433+
static bool classof(const TypeBase *T) {
1434+
return T->getKind() == TypeKind::BuiltinDefaultActorStorage;
1435+
}
1436+
};
1437+
DEFINE_EMPTY_CAN_TYPE_WRAPPER(BuiltinDefaultActorStorageType, BuiltinType);
1438+
14231439
/// BuiltinNativeObjectType - The builtin opaque object-pointer type.
14241440
/// Useful for keeping an object alive when it is otherwise being
14251441
/// manipulated via an unsafe pointer type.

include/swift/Demangling/DemangleNodes.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,5 +306,8 @@ NODE(GlobalVariableOnceToken)
306306
NODE(GlobalVariableOnceDeclList)
307307
NODE(CanonicalPrespecializedGenericTypeCachingOnceToken)
308308

309+
// Added in Swift 5.5
310+
NODE(AsyncFunctionPointer)
311+
309312
#undef CONTEXT_NODE
310313
#undef NODE

include/swift/Reflection/Records.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ class FieldRecordFlags {
3737

3838
// Is this a mutable `var` property?
3939
IsVar = 0x2,
40+
41+
// Is this an artificial field?
42+
IsArtificial = 0x4,
4043
};
4144
int_type Data = 0;
4245

@@ -49,6 +52,10 @@ class FieldRecordFlags {
4952
return (Data & IsVar) == IsVar;
5053
}
5154

55+
bool isArtificial() const {
56+
return (Data & IsArtificial) == IsArtificial;
57+
}
58+
5259
void setIsIndirectCase(bool IndirectCase=true) {
5360
if (IndirectCase)
5461
Data |= IsIndirectCase;
@@ -63,6 +70,13 @@ class FieldRecordFlags {
6370
Data &= ~IsVar;
6471
}
6572

73+
void setIsArtificial(bool artificial=true) {
74+
if (artificial)
75+
Data |= IsArtificial;
76+
else
77+
Data &= ~IsArtificial;
78+
}
79+
6680
int_type getRawValue() const {
6781
return Data;
6882
}

include/swift/SIL/ApplySite.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ class ApplySite {
337337
}
338338

339339
/// Return the SILArgumentConvention for the given applied argument operand.
340-
SILArgumentConvention getArgumentConvention(Operand &oper) const {
340+
SILArgumentConvention getArgumentConvention(const Operand &oper) const {
341341
unsigned calleeArgIdx =
342342
getCalleeArgIndexOfFirstAppliedArg() + getAppliedArgIndex(oper);
343343
return getSubstCalleeConv().getSILArgumentConvention(calleeArgIdx);
@@ -615,7 +615,8 @@ class FullApplySite : public ApplySite {
615615
/// Returns true if \p op is an operand that passes an indirect
616616
/// result argument to the apply site.
617617
bool isIndirectResultOperand(const Operand &op) const {
618-
return getCalleeArgIndex(op) < getNumIndirectSILResults();
618+
return isArgumentOperand(op)
619+
&& (getCalleeArgIndex(op) < getNumIndirectSILResults());
619620
}
620621

621622
static FullApplySite getFromOpaqueValue(void *p) { return FullApplySite(p); }

include/swift/SIL/OwnershipUtils.h

Lines changed: 38 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -32,29 +32,47 @@ class DeadEndBlocks;
3232
/// Returns true if v is an address or trivial.
3333
bool isValueAddressOrTrivial(SILValue v);
3434

35-
/// Is this an operand that can forward both owned and guaranteed ownership into
36-
/// one of the operand's owner instruction's result.
37-
bool isOwnershipForwardingUse(Operand *op);
38-
39-
/// Is this an operand that can forward guaranteed ownership into one of the
40-
/// operand's owner instruction's result.
41-
bool isGuaranteedForwardingUse(Operand *op);
42-
43-
/// Is this an operand that can forward owned ownership into one of the
44-
/// operand's owner instruction's result.
45-
bool isOwnedForwardingUse(Operand *use);
35+
/// Is the opcode that produces \p value capable of forwarding guaranteed
36+
/// values?
37+
///
38+
/// This may be true even if the current instance of the instruction is not a
39+
/// ForwardingBorrow. If true, then the operation may be trivially rewritten
40+
/// with Guaranteed ownership.
41+
bool canOpcodeForwardGuaranteedValues(SILValue value);
4642

47-
/// Is this a value that is the result of an instruction that forwards
48-
/// guaranteed ownership from one of its operands.
49-
bool isGuaranteedForwardingValue(SILValue value);
43+
/// Is the opcode that consumes \p use capable of forwarding guaranteed values?
44+
///
45+
/// This may be true even if \p use is not a ForwardingBorrow. If true, then the
46+
/// operation may be trivially rewritten with Guaranteed ownership.
47+
bool canOpcodeForwardGuaranteedValues(Operand *use);
48+
49+
// This is the use-def equivalent of use->getOperandOwnership() ==
50+
// OperandOwnership::ForwardingBorrow.
51+
inline bool isForwardingBorrow(SILValue value) {
52+
assert(value.getOwnershipKind() == OwnershipKind::Guaranteed);
53+
return canOpcodeForwardGuaranteedValues(value);
54+
}
55+
56+
/// Is the opcode that produces \p value capable of forwarding owned values?
57+
///
58+
/// This may be true even if the current instance of the instruction is not a
59+
/// ForwardingConsume. If true, then the operation may be trivially rewritten
60+
/// with Owned ownership.
61+
bool canOpcodeForwardOwnedValues(SILValue value);
5062

51-
/// Is this value the result of an instruction that 'forward's owned ownership,
52-
/// but may not be able to forward guaranteed ownership.
63+
/// Is this opcode that consumes \p use capable of forwarding owned values?
5364
///
54-
/// This will be either a multiple value instruction resuilt, a single value
55-
/// instruction that forwards or an argument that forwards the ownership from a
56-
/// previous terminator.
57-
bool isOwnedForwardingValue(SILValue value);
65+
/// This may be true even if the current instance of the instruction is not a
66+
/// ForwardingConsume. If true, then the operation may be trivially rewritten
67+
/// with Owned ownership.
68+
bool canOpcodeForwardOwnedValues(Operand *use);
69+
70+
// This is the use-def equivalent of use->getOperandOwnership() ==
71+
// OperandOwnership::ForwardingConsume.
72+
inline bool isForwardingConsume(SILValue value) {
73+
assert(value.getOwnershipKind() == OwnershipKind::Owned);
74+
return canOpcodeForwardOwnedValues(value);
75+
}
5876

5977
class ForwardingOperand {
6078
Operand *use;
@@ -225,25 +243,6 @@ struct BorrowingOperand {
225243
llvm_unreachable("Covered switch isn't covered?!");
226244
}
227245

228-
/// Is this a borrow scope operand that can open new borrow scopes
229-
/// for owned values.
230-
bool canAcceptOwnedValues() const {
231-
switch (kind) {
232-
// begin_borrow can take any parameter
233-
case BorrowingOperandKind::BeginBorrow:
234-
// Yield can implicit borrow owned values.
235-
case BorrowingOperandKind::Yield:
236-
// FullApplySites can implicit borrow owned values.
237-
case BorrowingOperandKind::BeginApply:
238-
case BorrowingOperandKind::Apply:
239-
case BorrowingOperandKind::TryApply:
240-
return true;
241-
case BorrowingOperandKind::Branch:
242-
return false;
243-
}
244-
llvm_unreachable("Covered switch isn't covered?!");
245-
}
246-
247246
/// Is the result of this instruction also a borrow introducer?
248247
///
249248
/// TODO: This needs a better name.

0 commit comments

Comments
 (0)