Skip to content

Commit 139b80d

Browse files
committed
SIL: fix AllocStackInst.isLexical
If wrongly returned false.
1 parent c06fe5b commit 139b80d

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

SwiftCompilerSources/Sources/SIL/Instruction.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,6 +1346,7 @@ final public class AllocStackInst : SingleValueInstruction, Allocation, DebugVar
13461346
public var hasDynamicLifetime: Bool { bridged.AllocStackInst_hasDynamicLifetime() }
13471347
public var isFromVarDecl: Bool { bridged.AllocStackInst_isFromVarDecl() }
13481348
public var usesMoveableValueDebugInfo: Bool { bridged.AllocStackInst_usesMoveableValueDebugInfo() }
1349+
public override var isLexical: Bool { bridged.AllocStackInst_isLexical() }
13491350

13501351
public var varDecl: VarDecl? {
13511352
bridged.AllocStack_getDecl().getAs(VarDecl.self)

include/swift/SIL/SILBridging.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,7 @@ struct BridgedInstruction {
772772
BRIDGED_INLINE bool AllocStackInst_hasDynamicLifetime() const;
773773
BRIDGED_INLINE bool AllocStackInst_isFromVarDecl() const;
774774
BRIDGED_INLINE bool AllocStackInst_usesMoveableValueDebugInfo() const;
775+
BRIDGED_INLINE bool AllocStackInst_isLexical() const;
775776
BRIDGED_INLINE bool AllocRefInstBase_isObjc() const;
776777
BRIDGED_INLINE bool AllocRefInstBase_canAllocOnStack() const;
777778
BRIDGED_INLINE SwiftInt AllocRefInstBase_getNumTailTypes() const;

include/swift/SIL/SILBridgingImpl.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,6 +1305,10 @@ bool BridgedInstruction::AllocStackInst_usesMoveableValueDebugInfo() const {
13051305
return getAs<swift::AllocStackInst>()->usesMoveableValueDebugInfo();
13061306
}
13071307

1308+
bool BridgedInstruction::AllocStackInst_isLexical() const {
1309+
return getAs<swift::AllocStackInst>()->isLexical();
1310+
}
1311+
13081312
bool BridgedInstruction::AllocRefInstBase_isObjc() const {
13091313
return getAs<swift::AllocRefInstBase>()->isObjC();
13101314
}

test/SILOptimizer/simplify_alloc_stack.sil

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ sil [ossa] @use_mp : $@convention(thin) (@in_guaranteed MP) -> ()
4141
sil [ossa] @use_c2 : $@convention(thin) (@in_guaranteed C2) -> ()
4242

4343
// CHECK-LABEL: sil [ossa] @expand_alloc_stack_of_enum1 :
44-
// CHECK: [[A:%[0-9]+]] = alloc_stack $S
44+
// CHECK: [[A:%[0-9]+]] = alloc_stack [lexical] $S
4545
// CHECK: bb1:
4646
// CHECK-NEXT: store %0 to [trivial] [[A]]
4747
// CHECK: bb2:
@@ -51,7 +51,7 @@ sil [ossa] @use_c2 : $@convention(thin) (@in_guaranteed C2) -> ()
5151
// CHECK: } // end sil function 'expand_alloc_stack_of_enum1'
5252
sil [ossa] @expand_alloc_stack_of_enum1 : $@convention(method) (S) -> () {
5353
bb0(%0 : $S):
54-
%1 = alloc_stack $MP
54+
%1 = alloc_stack [lexical] $MP
5555
cond_br undef, bb1, bb2
5656

5757
bb1:
@@ -215,7 +215,7 @@ bb0(%0 : $S):
215215
}
216216

217217
// CHECK-LABEL: sil [ossa] @replace_archetype :
218-
// CHECK: [[S:%.*]] = alloc_stack $T
218+
// CHECK: [[S:%.*]] = alloc_stack [lexical] $T
219219
// CHECK: debug_value [[S]]
220220
// CHECK: unchecked_addr_cast [[S]]
221221
// CHECK: destroy_addr [[S]]
@@ -225,7 +225,7 @@ bb0(%0 : @owned $T):
225225
%1 = metatype $@thick T.Type
226226
%2 = init_existential_metatype %1, $@thick P.Type
227227
%3 = open_existential_metatype %2 to $@thick (@opened("82105EE0-DCB0-11E5-865D-C8E0EB309913", P) Self).Type
228-
%4 = alloc_stack $@opened("82105EE0-DCB0-11E5-865D-C8E0EB309913", P) Self
228+
%4 = alloc_stack [lexical] $@opened("82105EE0-DCB0-11E5-865D-C8E0EB309913", P) Self
229229
debug_value %4, var, name "x"
230230
%5 = unchecked_addr_cast %4 to $*T
231231
store %0 to [init] %5

0 commit comments

Comments
 (0)