Skip to content

Commit 19f0e1d

Browse files
authored
Merge pull request #4091 from swiftwasm/main
[pull] swiftwasm from main
2 parents 433ad32 + 648d256 commit 19f0e1d

File tree

84 files changed

+427
-245
lines changed

Some content is hidden

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

84 files changed

+427
-245
lines changed

SwiftCompilerSources/Sources/SIL/Instruction.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,10 @@ final public class DeallocStackInst : Instruction, UnaryInstruction {
208208
}
209209
}
210210

211+
final public class DeallocStackRefInst : Instruction, UnaryInstruction {
212+
public var allocRef: AllocRefInst { operand as! AllocRefInst }
213+
}
214+
211215
final public class CondFailInst : Instruction, UnaryInstruction {
212216
public override var mayTrap: Bool { true }
213217

SwiftCompilerSources/Sources/SIL/Registration.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public func registerSILClasses() {
4242
register(EndAccessInst.self)
4343
register(EndBorrowInst.self)
4444
register(DeallocStackInst.self)
45+
register(DeallocStackRefInst.self)
4546
register(CondFailInst.self)
4647
register(FixLifetimeInst.self)
4748
register(DebugValueInst.self)

docs/ABI/Mangling.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -737,15 +737,17 @@ implementation details of a function type.
737737
::
738738

739739
#if SWIFT_VERSION >= 5.1
740-
type ::= 'Qr' // opaque result type (of current decl)
740+
type ::= 'Qr' // opaque result type (of current decl, used for the first opaque type parameter only)
741+
type ::= 'QR' INDEX // same as above, for subsequent opaque type parameters, INDEX is the ordinal -1
741742
type ::= opaque-type-decl-name bound-generic-args 'Qo' INDEX // opaque type
742743

743744
opaque-type-decl-name ::= entity 'QO' // opaque result type of specified decl
744745
#endif
745746

746747
#if SWIFT_VERSION >= 5.4
747-
type ::= 'Qu' // opaque result type (of current decl)
748+
type ::= 'Qu' // opaque result type (of current decl, first param)
748749
// used for ObjC class runtime name purposes.
750+
type ::= 'QU' INDEX
749751
#endif
750752

751753
Opaque return types have a special short representation in the mangling of

docs/SIL.rst

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3143,8 +3143,8 @@ optional ``objc`` attribute indicates that the object should be
31433143
allocated using Objective-C's allocation methods (``+allocWithZone:``).
31443144

31453145
The optional ``stack`` attribute indicates that the object can be allocated
3146-
on the stack instead on the heap. In this case the instruction must have
3147-
balanced with a ``dealloc_ref [stack]`` instruction to mark the end of the
3146+
on the stack instead on the heap. In this case the instruction must be
3147+
balanced with a ``dealloc_stack_ref`` instruction to mark the end of the
31483148
object's lifetime.
31493149
Note that the ``stack`` attribute only specifies that stack allocation is
31503150
possible. The final decision on stack allocation is done during llvm IR
@@ -3381,13 +3381,25 @@ project_box
33813381

33823382
Given a ``@box T`` reference, produces the address of the value inside the box.
33833383

3384+
dealloc_stack_ref
3385+
`````````````````
3386+
::
3387+
3388+
sil-instruction ::= 'dealloc_stack_ref' sil-operand
3389+
3390+
dealloc_stack_ref %0 : $T
3391+
// $T must be a class type
3392+
// %0 must be an 'alloc_ref [stack]' instruction
3393+
3394+
Marks the deallocation of the stack space for an ``alloc_ref [stack]``.
3395+
33843396
dealloc_ref
33853397
```````````
33863398
::
33873399

3388-
sil-instruction ::= 'dealloc_ref' ('[' 'stack' ']')? sil-operand
3400+
sil-instruction ::= 'dealloc_ref' sil-operand
33893401

3390-
dealloc_ref [stack] %0 : $T
3402+
dealloc_ref %0 : $T
33913403
// $T must be a class type
33923404

33933405
Deallocates an uninitialized class type instance, bypassing the reference

include/swift/AST/DiagnosticsSema.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1514,6 +1514,9 @@ ERROR(access_control_extension_open,none,
15141514
ERROR(access_control_open_bad_decl,none,
15151515
"only classes and overridable class members can be declared 'open';"
15161516
" use 'public'", ())
1517+
WARNING(access_control_non_objc_open_member,none,
1518+
"non-'@objc' %0 in extensions cannot be overridden; use 'public' instead",
1519+
(DescriptiveDeclKind))
15171520

15181521
ERROR(invalid_decl_attribute,none,
15191522
"'%0' attribute cannot be applied to this declaration", (DeclAttribute))

include/swift/Demangling/DemangleNodes.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,5 +329,8 @@ NODE(AsyncSuspendResumePartialFunction)
329329
// Added in Swift 5.6
330330
NODE(AccessibleFunctionRecord)
331331

332+
// Added in Swift 5.7
333+
NODE(OpaqueReturnTypeIndexed)
334+
332335
#undef CONTEXT_NODE
333336
#undef NODE

include/swift/SIL/SILBuilder.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2005,10 +2005,14 @@ class SILBuilder {
20052005
return insert(new (getModule())
20062006
DeallocStackInst(getSILDebugLocation(Loc), operand));
20072007
}
2008-
DeallocRefInst *createDeallocRef(SILLocation Loc, SILValue operand,
2009-
bool canBeOnStack) {
2008+
DeallocStackRefInst *createDeallocStackRef(SILLocation Loc,
2009+
SILValue operand) {
2010+
return insert(new (getModule())
2011+
DeallocStackRefInst(getSILDebugLocation(Loc), operand));
2012+
}
2013+
DeallocRefInst *createDeallocRef(SILLocation Loc, SILValue operand) {
20102014
return insert(new (getModule()) DeallocRefInst(
2011-
getSILDebugLocation(Loc), operand, canBeOnStack));
2015+
getSILDebugLocation(Loc), operand));
20122016
}
20132017
DeallocPartialRefInst *createDeallocPartialRef(SILLocation Loc,
20142018
SILValue operand,

include/swift/SIL/SILCloner.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2488,8 +2488,16 @@ SILCloner<ImplClass>::visitDeallocRefInst(DeallocRefInst *Inst) {
24882488
getBuilder().setCurrentDebugScope(getOpScope(Inst->getDebugScope()));
24892489
recordClonedInstruction(
24902490
Inst, getBuilder().createDeallocRef(getOpLocation(Inst->getLoc()),
2491-
getOpValue(Inst->getOperand()),
2492-
Inst->canAllocOnStack()));
2491+
getOpValue(Inst->getOperand())));
2492+
}
2493+
2494+
template<typename ImplClass>
2495+
void
2496+
SILCloner<ImplClass>::visitDeallocStackRefInst(DeallocStackRefInst *Inst) {
2497+
getBuilder().setCurrentDebugScope(getOpScope(Inst->getDebugScope()));
2498+
recordClonedInstruction(
2499+
Inst, getBuilder().createDeallocStackRef(getOpLocation(Inst->getLoc()),
2500+
getOpValue(Inst->getOperand())));
24932501
}
24942502

24952503
template<typename ImplClass>

include/swift/SIL/SILInstruction.h

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7619,6 +7619,18 @@ class DeallocStackInst :
76197619
: UnaryInstructionBase(DebugLoc, operand) {}
76207620
};
76217621

7622+
/// Like DeallocStackInst, but for `alloc_ref [stack]`.
7623+
class DeallocStackRefInst
7624+
: public UnaryInstructionBase<SILInstructionKind::DeallocStackRefInst,
7625+
DeallocationInst> {
7626+
friend SILBuilder;
7627+
7628+
DeallocStackRefInst(SILDebugLocation DebugLoc, SILValue Operand)
7629+
: UnaryInstructionBase(DebugLoc, Operand) {}
7630+
public:
7631+
AllocRefInst *getAllocRef() { return cast<AllocRefInst>(getOperand()); }
7632+
};
7633+
76227634
/// Deallocate memory for a reference type instance from a destructor or
76237635
/// failure path of a constructor.
76247636
///
@@ -7632,21 +7644,8 @@ class DeallocRefInst :
76327644
DeallocationInst> {
76337645
friend SILBuilder;
76347646

7635-
private:
7636-
DeallocRefInst(SILDebugLocation DebugLoc, SILValue Operand,
7637-
bool canBeOnStack = false)
7638-
: UnaryInstructionBase(DebugLoc, Operand) {
7639-
SILNode::Bits.DeallocRefInst.OnStack = canBeOnStack;
7640-
}
7641-
7642-
public:
7643-
bool canAllocOnStack() const {
7644-
return SILNode::Bits.DeallocRefInst.OnStack;
7645-
}
7646-
7647-
void setStackAllocatable(bool OnStack) {
7648-
SILNode::Bits.DeallocRefInst.OnStack = OnStack;
7649-
}
7647+
DeallocRefInst(SILDebugLocation DebugLoc, SILValue Operand)
7648+
: UnaryInstructionBase(DebugLoc, Operand) { }
76507649
};
76517650

76527651
/// Deallocate memory for a reference type instance from a failure path of a

include/swift/SIL/SILNode.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,10 +218,6 @@ class alignas(8) SILNode :
218218
Length : 32
219219
);
220220

221-
SWIFT_INLINE_BITFIELD(DeallocRefInst, DeallocationInst, 1,
222-
OnStack : 1
223-
);
224-
225221
// Ensure that AllocBoxInst bitfield does not overflow.
226222
IBWTO_BITFIELD_EMPTY(AllocBoxInst, AllocationInst);
227223
// Ensure that AllocExistentialBoxInst bitfield does not overflow.

0 commit comments

Comments
 (0)