Skip to content

Commit 7323ea9

Browse files
committed
[semantic-arc-opts] Eliminate unneeded use of bisection that caused ASAN to fire.
I was being too clever here and in the process of "foot-gunned" myself. Specifically, I was hoping to use bisection to do some is contained in list tests. But the list that I actually bisected upon was not the original list and was just based on the original sorted list! So the pointer comparison for the bisect no longer worked. Since the bisection was on pointer addresses, if we were lucky and the new addresses in the new array were sorted the same as the original array, we wouldn't hit anything. rdar://60262326
1 parent 6b88599 commit 7323ea9

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

lib/SILOptimizer/Transforms/SemanticARCOpts.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -884,10 +884,6 @@ bool SemanticARCOptVisitor::performPostPeepholeOwnedArgElimination() {
884884
continue;
885885
}
886886

887-
// Then sort the incoming value operand list so that we can bisect search
888-
// it.
889-
sort(incomingValueOperandList);
890-
891887
// Grab our list of introducer values paired with this SILArgument. See if
892888
// all of these introducer values were ones that /could/ have been
893889
// eliminated if it was not for the given phi. If all of them are, we can
@@ -936,8 +932,8 @@ bool SemanticARCOptVisitor::performPostPeepholeOwnedArgElimination() {
936932
// cvi is one of our originalIncomingValues. If so, we need to set
937933
// originalIncomingValues to be cvi->getOperand(). Otherwise, weirdness
938934
// results since we are deleting one of our stashed values.
939-
auto iter = lower_bound(originalIncomingValues, cvi);
940-
if (iter != originalIncomingValues.end() && *iter == cvi) {
935+
auto iter = find(originalIncomingValues, cvi);
936+
if (iter != originalIncomingValues.end()) {
941937
// We use an auxillary array here so we can continue to bisect on
942938
// original incoming values. Once we are done processing here, we will
943939
// not need that property anymore.

0 commit comments

Comments
 (0)