[AssumptionCache] Avoid dangling llvm.assume calls in the cache
authorJohannes Doerfert <johannes@jdoerfert.de>
Fri, 5 Feb 2021 16:53:33 +0000 (10:53 -0600)
committerJohannes Doerfert <johannes@jdoerfert.de>
Sat, 6 Feb 2021 18:18:39 +0000 (12:18 -0600)
commitb7d870eae7fdadcf10d0f177faa7409c2e37d776
tree208eb97f65ea5d11d7390f386a87332b94c946dd
parent378f4e5ec26c3e0d2119c1112ec645b369eed2de
[AssumptionCache] Avoid dangling llvm.assume calls in the cache

PR49043 exposed a problem when it comes to RAUW llvm.assumes. While
D96106 would fix it for GVNSink, it seems a more general concern. To
avoid future problems this patch moves away from the vector of weak
reference model used in the assumption cache. Instead, we track the
llvm.assume calls with a callback handle which will remove itself from
the cache if the call is deleted.

Fixes PR49043.

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D96168
llvm/include/llvm/Analysis/AssumptionCache.h
llvm/lib/Analysis/AssumptionCache.cpp
llvm/lib/Analysis/CodeMetrics.cpp
llvm/lib/Analysis/ScalarEvolution.cpp
llvm/lib/Transforms/Scalar/AlignmentFromAssumptions.cpp
llvm/lib/Transforms/Utils/CodeExtractor.cpp
llvm/lib/Transforms/Utils/PredicateInfo.cpp
llvm/test/Analysis/AssumptionCache/basic.ll