Skip to content

Commit e0fdf0c

Browse files
committed
[SIL] Bridge findPointerEscape() and fix OnoneSimplifyable
Do not bridge the hasPointerEscape flag until it is implemented.
1 parent 017ed74 commit e0fdf0c

File tree

7 files changed

+10
-5
lines changed

7 files changed

+10
-5
lines changed

SwiftCompilerSources/Sources/Optimizer/InstructionSimplification/SimplifyBeginBorrow.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ extension BeginBorrowInst : OnoneSimplifyable {
1818
// We need to keep lexical lifetimes in place.
1919
!isLexical,
2020
// The same for borrow-scopes which encapsulated pointer escapes.
21-
!hasPointerEscape
21+
!findPointerEscape()
2222
{
2323
tryReplaceBorrowWithOwnedOperand(beginBorrow: self, context)
2424
}

SwiftCompilerSources/Sources/Optimizer/Utilities/OptUtils.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ extension Value {
4141
}
4242
}
4343

44+
func findPointerEscape() -> Bool { bridged.findPointerEscape() }
45+
4446
/// Walks over all fields of an aggregate and checks if a reference count
4547
/// operation for this value is required. This differs from a simple `Type.isTrivial`
4648
/// check, because it treats a value_to_bridge_object instruction as "trivial".

SwiftCompilerSources/Sources/SIL/Instruction.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,6 @@ final public class BeginBorrowInst : SingleValueInstruction, UnaryInstruction, B
881881
public var borrowedValue: Value { operand.value }
882882

883883
public var isLexical: Bool { bridged.BeginBorrow_isLexical() }
884-
public var hasPointerEscape: Bool { bridged.BeginBorrow_hasPointerEscape() }
885884
}
886885

887886
final public class ProjectBoxInst : SingleValueInstruction, UnaryInstruction {

include/swift/SIL/SILBridging.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,8 @@ struct BridgedValue {
192192
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE OptionalBridgedOperand getFirstUse() const;
193193
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedType getType() const;
194194
BRIDGED_INLINE Ownership getOwnership() const;
195+
196+
bool findPointerEscape() const;
195197
};
196198

197199
struct OptionalBridgedValue {
@@ -623,7 +625,6 @@ struct BridgedInstruction {
623625
BRIDGED_INLINE OptionalBridgedValue StructInst_getUniqueNonTrivialFieldValue() const;
624626
BRIDGED_INLINE SwiftInt StructElementAddrInst_fieldIndex() const;
625627
BRIDGED_INLINE bool BeginBorrow_isLexical() const;
626-
BRIDGED_INLINE bool BeginBorrow_hasPointerEscape() const;
627628
BRIDGED_INLINE SwiftInt ProjectBoxInst_fieldIndex() const;
628629
BRIDGED_INLINE bool EndCOWMutationInst_doKeepUnique() const;
629630
BRIDGED_INLINE SwiftInt EnumInst_caseIndex() const;

include/swift/SIL/SILBridgingImpl.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -814,8 +814,6 @@ bool BridgedInstruction::BeginBorrow_isLexical() const {
814814
return getAs<swift::BeginBorrowInst>()->isLexical();
815815
}
816816

817-
bool BridgedInstruction::BeginBorrow_hasPointerEscape() const {
818-
return getAs<swift::BeginBorrowInst>()->hasPointerEscape();
819817
}
820818

821819
SwiftInt BridgedInstruction::ProjectBoxInst_fieldIndex() const {

include/swift/SIL/SILInstruction.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4467,6 +4467,7 @@ class BeginBorrowInst
44674467
/// doesn't have a lexical bit, do not do anything.
44684468
void removeIsLexical() { sharedUInt8().BeginBorrowInst.lexical = false; }
44694469

4470+
/// WARNING: this flag is not yet implemented!
44704471
bool hasPointerEscape() const {
44714472
return sharedUInt8().BeginBorrowInst.pointerEscape;
44724473
}

lib/SIL/Utils/SILBridging.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "swift/AST/Attr.h"
2121
#include "swift/AST/SemanticAttrs.h"
2222
#include "swift/SIL/MemAccessUtils.h"
23+
#include "swift/SIL/OwnershipUtils.h"
2324
#include "swift/SIL/ParseTestSpecification.h"
2425
#include "swift/SIL/SILBuilder.h"
2526
#include "swift/SIL/SILGlobalVariable.h"
@@ -273,6 +274,9 @@ ArrayRef<SILValue> BridgedValueArray::getValues(SmallVectorImpl<SILValue> &stora
273274
return storage;
274275
}
275276

277+
bool BridgedValue::findPointerEscape() const {
278+
return swift::findPointerEscape(getSILValue());
279+
}
276280

277281
//===----------------------------------------------------------------------===//
278282
// SILArgument

0 commit comments

Comments
 (0)