Skip to content

Commit 68ec810

Browse files
committed
Rename stripOwnershipInsts to lookThroughCopyValueInsts
1 parent 372efd5 commit 68ec810

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

include/swift/SIL/InstructionUtils.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,13 @@ SILValue stripCasts(SILValue V);
3737
/// mark_dependence) from the current SILValue.
3838
SILValue stripCastsWithoutMarkDependence(SILValue V);
3939

40-
/// Return the underlying SILValue after stripping off all copy_value and
40+
/// Return the underlying SILValue after looking through all copy_value and
4141
/// begin_borrow instructions.
42-
SILValue stripOwnershipInsts(SILValue v);
42+
SILValue lookThroughOwnershipInsts(SILValue v);
43+
44+
/// Return the underlying SILValue after looking through all copy_value
45+
/// instructions.
46+
SILValue lookThroughCopyValueInsts(SILValue v);
4347

4448
/// Return the underlying SILValue after stripping off all upcasts from the
4549
/// current SILValue.

lib/SIL/Utils/InstructionUtils.cpp

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
using namespace swift;
2727

28-
SILValue swift::stripOwnershipInsts(SILValue v) {
28+
SILValue swift::lookThroughOwnershipInsts(SILValue v) {
2929
while (true) {
3030
switch (v->getKind()) {
3131
default:
@@ -37,6 +37,14 @@ SILValue swift::stripOwnershipInsts(SILValue v) {
3737
}
3838
}
3939

40+
SILValue swift::lookThroughCopyValueInsts(SILValue val) {
41+
while (auto *cvi =
42+
dyn_cast_or_null<CopyValueInst>(val->getDefiningInstruction())) {
43+
val = cvi->getOperand();
44+
}
45+
return val;
46+
}
47+
4048
/// Strip off casts/indexing insts/address projections from V until there is
4149
/// nothing left to strip.
4250
///
@@ -46,7 +54,7 @@ SILValue swift::getUnderlyingObject(SILValue v) {
4654
SILValue v2 = stripCasts(v);
4755
v2 = stripAddressProjections(v2);
4856
v2 = stripIndexingInsts(v2);
49-
v2 = stripOwnershipInsts(v2);
57+
v2 = lookThroughOwnershipInsts(v2);
5058
if (v2 == v)
5159
return v2;
5260
v = v2;
@@ -58,7 +66,7 @@ SILValue swift::getUnderlyingObjectStopAtMarkDependence(SILValue v) {
5866
SILValue v2 = stripCastsWithoutMarkDependence(v);
5967
v2 = stripAddressProjections(v2);
6068
v2 = stripIndexingInsts(v2);
61-
v2 = stripOwnershipInsts(v2);
69+
v2 = lookThroughOwnershipInsts(v2);
6270
if (v2 == v)
6371
return v2;
6472
v = v2;
@@ -137,7 +145,7 @@ SILValue swift::stripCasts(SILValue v) {
137145
continue;
138146
}
139147
}
140-
SILValue v2 = stripOwnershipInsts(v);
148+
SILValue v2 = lookThroughOwnershipInsts(v);
141149
if (v2 != v) {
142150
v = v2;
143151
continue;
@@ -159,7 +167,7 @@ SILValue swift::stripUpCasts(SILValue v) {
159167
}
160168

161169
SILValue v2 = stripSinglePredecessorArgs(v);
162-
v2 = stripOwnershipInsts(v2);
170+
v2 = lookThroughOwnershipInsts(v2);
163171
if (v2 == v) {
164172
return v2;
165173
}
@@ -179,7 +187,7 @@ SILValue swift::stripClassCasts(SILValue v) {
179187
continue;
180188
}
181189

182-
SILValue v2 = stripOwnershipInsts(v);
190+
SILValue v2 = lookThroughOwnershipInsts(v);
183191
if (v2 != v) {
184192
v = v2;
185193
continue;

lib/SILOptimizer/Utils/ConstantFolding.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1522,7 +1522,7 @@ constantFoldGlobalStringTablePointerBuiltin(BuiltinInst *bi,
15221522
//
15231523
// We can look through ownership instructions to get to the string value that
15241524
// is passed to this builtin.
1525-
SILValue builtinOperand = stripOwnershipInsts(bi->getOperand(0));
1525+
SILValue builtinOperand = lookThroughOwnershipInsts(bi->getOperand(0));
15261526
SILFunction *caller = bi->getFunction();
15271527

15281528
FullApplySite stringInitSite = FullApplySite::isa(builtinOperand);

0 commit comments

Comments
 (0)