Skip to content

Commit 286b2e0

Browse files
committed
PredictableMemOpt: Fix source location for injected destroys
It's not correct to copy the location from an instruction and turn it into a RegularLocation if the Location was, e.g., a CleanupLocation. It's always safe to use a compilergenerated location instead. Caught by the dihole verification int the source compatibility suite. rdar://107984038
1 parent 8ea5ab8 commit 286b2e0

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lib/SILOptimizer/Mandatory/PredictableMemOpt.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,7 +1219,8 @@ void AvailableValueAggregator::addHandOffCopyDestroysForPhis(
12191219
// Otherwise, we need to insert one last destroy after the load for our phi.
12201220
auto next = std::next(load->getIterator());
12211221
SILBuilderWithScope builder(next);
1222-
builder.emitDestroyValueOperation(RegularLocation(next->getLoc()), phi);
1222+
builder.emitDestroyValueOperation(
1223+
RegularLocation::getAutoGeneratedLocation(), phi);
12231224
}
12241225

12251226
// Alright! In summary, we just lifetime extended all of our phis,
@@ -1251,7 +1252,8 @@ void AvailableValueAggregator::addMissingDestroysForCopiedValues(
12511252
assert(li->getParent() == load->getParent());
12521253
auto next = std::next(load->getIterator());
12531254
SILBuilderWithScope builder(next);
1254-
builder.emitDestroyValueOperation(RegularLocation(next->getLoc()), li);
1255+
builder.emitDestroyValueOperation(
1256+
RegularLocation::getAutoGeneratedLocation(), li);
12551257
continue;
12561258
}
12571259
}
@@ -1301,7 +1303,8 @@ void AvailableValueAggregator::addMissingDestroysForCopiedValues(
13011303
// Otherwise, we need to insert one last destroy after the load for our phi.
13021304
auto next = std::next(load->getIterator());
13031305
SILBuilderWithScope builder(next);
1304-
builder.emitDestroyValueOperation(RegularLocation(next->getLoc()), cvi);
1306+
builder.emitDestroyValueOperation(
1307+
RegularLocation::getAutoGeneratedLocation(), cvi);
13051308
}
13061309
}
13071310

0 commit comments

Comments
 (0)