Skip to content

Commit 15c7e3a

Browse files
authored
Merge pull request swiftlang#30200 from gottesmm/pr-f782df1b8f778cdddc48f8343fb0876f598f9012
[ownership] Remove BranchPropagatedUser.
2 parents b8a87f6 + be16822 commit 15c7e3a

14 files changed

+136
-332
lines changed

include/swift/SIL/ApplySite.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ class ApplySite {
134134
/// Return the callee operand as a value.
135135
SILValue getCallee() const { return getCalleeOperand()->get(); }
136136

137+
/// Return the callee operand.
138+
Operand *getCalleeOperand() { FOREACH_IMPL_RETURN(getCalleeOperand()); }
139+
137140
/// Return the callee operand.
138141
const Operand *getCalleeOperand() const {
139142
FOREACH_IMPL_RETURN(getCalleeOperand());

include/swift/SIL/BasicBlockUtils.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,13 @@ class DeadEndBlocks {
7171
DeadEndBlocks(const SILFunction *F) : F(F) {}
7272

7373
/// Returns true if \p BB is a dead-end block.
74-
bool isDeadEnd(SILBasicBlock *BB) {
74+
bool isDeadEnd(const SILBasicBlock *block) {
7575
if (!isComputed) {
7676
// Lazily compute the dataflow.
7777
compute();
7878
isComputed = true;
7979
}
80-
return ReachableBlocks.count(BB) == 0;
80+
return ReachableBlocks.count(block) == 0;
8181
}
8282
};
8383

include/swift/SIL/BranchPropagatedUser.h

Lines changed: 0 additions & 158 deletions
This file was deleted.

include/swift/SIL/LinearLifetimeChecker.h

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
#include "swift/Basic/Debug.h"
1717
#include "swift/Basic/LLVM.h"
18-
#include "swift/SIL/BranchPropagatedUser.h"
1918
#include "swift/SIL/SILArgument.h"
2019
#include "swift/SIL/SILInstruction.h"
2120
#include "swift/SIL/SILValue.h"
@@ -29,7 +28,6 @@ class SILInstruction;
2928
class SILModule;
3029
class SILValue;
3130
class DeadEndBlocks;
32-
class BranchPropagatedUser;
3331

3432
namespace ownership {
3533

@@ -167,30 +165,21 @@ class LinearLifetimeChecker {
167165
/// \p leakingBlocks If non-null a list of blocks where the value was detected
168166
/// to leak. Can be used to insert missing destroys.
169167
LinearLifetimeError
170-
checkValue(SILValue value, ArrayRef<BranchPropagatedUser> consumingUses,
171-
ArrayRef<BranchPropagatedUser> nonConsumingUses,
168+
checkValue(SILValue value, ArrayRef<Operand *> consumingUses,
169+
ArrayRef<Operand *> nonConsumingUses,
172170
ownership::ErrorBehaviorKind errorBehavior,
173171
SmallVectorImpl<SILBasicBlock *> *leakingBlocks = nullptr);
174172

175173
/// Returns true that \p value forms a linear lifetime with consuming uses \p
176174
/// consumingUses, non consuming uses \p nonConsumingUses. Returns false
177175
/// otherwise.
178-
bool validateLifetime(SILValue value,
179-
ArrayRef<BranchPropagatedUser> consumingUses,
180-
ArrayRef<BranchPropagatedUser> nonConsumingUses) {
176+
bool validateLifetime(SILValue value, ArrayRef<Operand *> consumingUses,
177+
ArrayRef<Operand *> nonConsumingUses) {
181178
return !checkValue(value, consumingUses, nonConsumingUses,
182179
ownership::ErrorBehaviorKind::ReturnFalse,
183180
nullptr /*leakingBlocks*/)
184181
.getFoundError();
185182
}
186-
187-
bool validateLifetime(SILValue value,
188-
ArrayRef<SILInstruction *> consumingUses,
189-
ArrayRef<SILInstruction *> nonConsumingUses) {
190-
return validateLifetime(
191-
value, BranchPropagatedUser::convertFromInstArray(consumingUses),
192-
BranchPropagatedUser::convertFromInstArray(nonConsumingUses));
193-
}
194183
};
195184

196185
} // namespace swift

include/swift/SIL/MemAccessUtils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ bool memInstMustInitialize(Operand *memOper);
540540
/// alloc_stack. If the alloc_stack is destroyed in pieces, we do not guarantee
541541
/// that the list of destroying users is a minimal jointly post-dominating set.
542542
bool isSingleInitAllocStack(AllocStackInst *asi,
543-
SmallVectorImpl<SILInstruction *> &destroyingUsers);
543+
SmallVectorImpl<Operand *> &destroyingUses);
544544

545545
/// Return true if the given address producer may be the source of a formal
546546
/// access (a read or write of a potentially aliased, user visible variable).

include/swift/SIL/OwnershipUtils.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -319,16 +319,15 @@ struct BorrowScopeIntroducingValue {
319319

320320
bool isLocalScope() const { return kind.isLocalScope(); }
321321

322-
/// Returns true if the passed in set of instructions is completely within the
323-
/// lifetime of this borrow introducer.
322+
/// Returns true if the passed in set of uses is completely within
323+
/// the lifetime of this borrow introducer.
324324
///
325325
/// NOTE: Scratch space is used internally to this method to store the end
326326
/// borrow scopes if needed.
327-
bool
328-
areInstructionsWithinScope(ArrayRef<SILInstruction *> instructions,
329-
SmallVectorImpl<SILInstruction *> &scratchSpace,
330-
SmallPtrSetImpl<SILBasicBlock *> &visitedBlocks,
331-
DeadEndBlocks &deadEndBlocks) const;
327+
bool areUsesWithinScope(ArrayRef<Operand *> instructions,
328+
SmallVectorImpl<Operand *> &scratchSpace,
329+
SmallPtrSetImpl<SILBasicBlock *> &visitedBlocks,
330+
DeadEndBlocks &deadEndBlocks) const;
332331

333332
/// Given a local borrow scope introducer, visit all non-forwarding consuming
334333
/// users. This means that this looks through guaranteed block arguments.

include/swift/SIL/SILInstruction.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1875,6 +1875,7 @@ class ApplyInstBase<Impl, Base, false> : public Base {
18751875
/// The operand number of the first argument.
18761876
static unsigned getArgumentOperandNumber() { return NumStaticOperands; }
18771877

1878+
Operand *getCalleeOperand() { return &getAllOperands()[Callee]; }
18781879
const Operand *getCalleeOperand() const { return &getAllOperands()[Callee]; }
18791880
SILValue getCallee() const { return getCalleeOperand()->get(); }
18801881

0 commit comments

Comments
 (0)