Skip to content

Commit d2eec15

Browse files
authored
Merge pull request #5415 from gottesmm/fix_basic_sil_parsing
2 parents b9d3ca6 + 705f2d2 commit d2eec15

File tree

4 files changed

+25
-2
lines changed

4 files changed

+25
-2
lines changed

docs/SIL.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2246,6 +2246,27 @@ which are not represented as box allocations.
22462246
It is produced by SILGen, and is only valid in Raw SIL. It is rewritten as
22472247
appropriate by the definitive initialization pass.
22482248

2249+
mark_uninitialized_behavior
2250+
```````````````````````````
2251+
::
2252+
2253+
init-case ::= sil-value sil-apply-substitution-list? '(' sil-value ')' ':' sil-type
2254+
set-case ::= sil-value sil-apply-substitution-list? '(' sil-value ')' ':' sil-type
2255+
sil-instruction ::= 'mark_uninitialized_behavior' init-case set-case
2256+
2257+
mark_uninitialized_behavior %init<Subs>(%storage) : $T -> U,
2258+
%set<Subs>(%self) : $V -> W
2259+
2260+
Indicates that a logical property is uninitialized at this point and needs to be
2261+
initialized by the end of the function and before any escape point for this
2262+
instruction. Assignments to the property trigger the behavior's ``init`` or
2263+
``set`` logic based on the logical initialization state of the property.
2264+
2265+
It is expected that the ``init-case`` is passed some sort of storage and the
2266+
``set`` case is passed ``self``.
2267+
2268+
This is only valid in Raw SIL.
2269+
22492270
copy_addr
22502271
`````````
22512272
::

lib/Parse/ParseSIL.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2336,7 +2336,8 @@ bool SILParser::parseSILInstruction(SILBasicBlock *BB, SILBuilder &B) {
23362336
|| parseValueName(SelfName)
23372337
|| P.parseToken(tok::r_paren, diag::expected_tok_in_sil_instr, ")")
23382338
|| P.parseToken(tok::colon, diag::expected_tok_in_sil_instr, ":")
2339-
|| parseSILType(SetterTy, SetterSig, SetterEnv))
2339+
|| parseSILType(SetterTy, SetterSig, SetterEnv)
2340+
|| parseSILDebugLocation(InstLoc, B))
23402341
return true;
23412342

23422343
// Resolve the types of the operands.

test/SIL/Parser/basic.sil

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-frontend %s -emit-silgen | %FileCheck %s
1+
// RUN: %target-sil-opt %s | %target-sil-opt | %FileCheck %s
22

33
sil_stage raw // CHECK: sil_stage raw
44

utils/sil-mode.el

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767

6868
;; SIL Instructions - Accessing Memory.
6969
`(,(regexp-opt '("load" "store" "assign" "mark_uninitialized"
70+
"mark_uninitialized_behavior"
7071
"mark_function_escape" "copy_addr" "destroy_addr"
7172
"index_addr" "index_raw_pointer" "bind_memory" "to")
7273
'words) . font-lock-keyword-face)

0 commit comments

Comments
 (0)