Skip to content

Commit 75dda75

Browse files
committed
[sil] Fix parsing of mark_must_check.
As a bonus I put in an extra serialization test as well.
1 parent 4590be1 commit 75dda75

File tree

3 files changed

+77
-5
lines changed

3 files changed

+77
-5
lines changed

lib/SIL/Parser/ParseSIL.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3431,11 +3431,6 @@ bool SILParser::parseSpecificSILInstruction(SILBuilder &B,
34313431
}
34323432

34333433
case SILInstructionKind::MarkMustCheckInst: {
3434-
if (parseTypedValueRef(Val, B))
3435-
return true;
3436-
if (parseSILDebugLocation(InstLoc, B))
3437-
return true;
3438-
34393434
StringRef AttrName;
34403435
if (!parseSILOptional(AttrName, *this)) {
34413436
auto diag = diag::sil_markmustcheck_requires_attribute;
@@ -3454,6 +3449,12 @@ bool SILParser::parseSpecificSILInstruction(SILBuilder &B,
34543449
P.diagnose(InstLoc.getSourceLoc(), diag, AttrName);
34553450
return true;
34563451
}
3452+
3453+
if (parseTypedValueRef(Val, B))
3454+
return true;
3455+
if (parseSILDebugLocation(InstLoc, B))
3456+
return true;
3457+
34573458
auto *MVI = B.createMarkMustCheckInst(InstLoc, Val, CKind);
34583459
ResultVal = MVI;
34593460
break;

test/SIL/Parser/basic2_moveonly.sil

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// RUN: %target-sil-opt -enable-experimental-move-only %s | %target-sil-opt -enable-experimental-move-only | %FileCheck %s
2+
3+
// Once move only is no longer behind a feature flag, merge this into basic2.
4+
5+
sil_stage raw
6+
7+
class Klass {}
8+
@_moveOnly struct MoveOnlyPair {
9+
var lhs: Klass
10+
var rhs: Klass
11+
}
12+
13+
// CHECK-LABEL: sil [ossa] @testMarkMustCheckInst : $@convention(thin) (@guaranteed Klass) -> () {
14+
// CHECK: mark_must_check [no_implicit_copy] %{{[0-9]+}} : $*MoveOnlyPair
15+
// CHECK: } // end sil function 'testMarkMustCheckInst'
16+
sil [ossa] @testMarkMustCheckInst : $@convention(thin) (@guaranteed Klass) -> () {
17+
bb0(%0 : @guaranteed $Klass):
18+
%1 = alloc_box ${ var MoveOnlyPair }
19+
%2 = project_box %1 : ${ var MoveOnlyPair }, 0
20+
%3 = mark_must_check [no_implicit_copy] %2 : $*MoveOnlyPair
21+
%3c = begin_access [modify] [static] %3 : $*MoveOnlyPair
22+
%3a = struct_element_addr %3c : $*MoveOnlyPair, #MoveOnlyPair.lhs
23+
%3b = struct_element_addr %3c : $*MoveOnlyPair, #MoveOnlyPair.rhs
24+
%0a = copy_value %0 : $Klass
25+
%0b = copy_value %0 : $Klass
26+
store %0a to [init] %3a : $*Klass
27+
store %0b to [init] %3b : $*Klass
28+
end_access %3c : $*MoveOnlyPair
29+
30+
destroy_value %1 : ${ var MoveOnlyPair }
31+
32+
%9999 = tuple()
33+
return %9999 : $()
34+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-sil-opt -enable-experimental-move-only %s -emit-sib -o %t/tmp.sib -module-name basic2
3+
// RUN: %target-sil-opt -enable-experimental-move-only %t/tmp.sib -o %t/tmp.2.sib -module-name basic2
4+
// RUN: %target-sil-opt -enable-experimental-move-only %t/tmp.2.sib -module-name basic2 -emit-sorted-sil | %FileCheck %s
5+
6+
// Once move only is no longer behind a feature flag, merge this into basic2.
7+
8+
sil_stage raw
9+
10+
class Klass {}
11+
@_moveOnly struct MoveOnlyPair {
12+
var lhs: Klass
13+
var rhs: Klass
14+
}
15+
16+
// CHECK-LABEL: sil [ossa] @testMarkMustCheckInst : $@convention(thin) (@guaranteed Klass) -> () {
17+
// CHECK: mark_must_check [no_implicit_copy] %{{[0-9]+}} : $*MoveOnlyPair
18+
// CHECK: } // end sil function 'testMarkMustCheckInst'
19+
sil [ossa] @testMarkMustCheckInst : $@convention(thin) (@guaranteed Klass) -> () {
20+
bb0(%0 : @guaranteed $Klass):
21+
%1 = alloc_box ${ var MoveOnlyPair }
22+
%2 = project_box %1 : ${ var MoveOnlyPair }, 0
23+
%3 = mark_must_check [no_implicit_copy] %2 : $*MoveOnlyPair
24+
%3c = begin_access [modify] [static] %3 : $*MoveOnlyPair
25+
%3a = struct_element_addr %3c : $*MoveOnlyPair, #MoveOnlyPair.lhs
26+
%3b = struct_element_addr %3c : $*MoveOnlyPair, #MoveOnlyPair.rhs
27+
%0a = copy_value %0 : $Klass
28+
%0b = copy_value %0 : $Klass
29+
store %0a to [init] %3a : $*Klass
30+
store %0b to [init] %3b : $*Klass
31+
end_access %3c : $*MoveOnlyPair
32+
33+
destroy_value %1 : ${ var MoveOnlyPair }
34+
35+
%9999 = tuple()
36+
return %9999 : $()
37+
}

0 commit comments

Comments
 (0)