[Attributor] Use AssumptionCache in AANonNullFloating::initialize

This commit is contained in:
Hideto Ueno 2020-02-25 12:32:50 +09:00
parent 1612d38241
commit 2c0edbf19c
2 changed files with 7 additions and 4 deletions

View File

@ -2032,15 +2032,18 @@ struct AANonNullFloating
const DataLayout &DL = A.getDataLayout();
DominatorTree *DT = nullptr;
AssumptionCache *AC = nullptr;
InformationCache &InfoCache = A.getInfoCache();
if (const Function *Fn = getAnchorScope())
if (const Function *Fn = getAnchorScope()) {
DT = InfoCache.getAnalysisResultForFunction<DominatorTreeAnalysis>(*Fn);
AC = InfoCache.getAnalysisResultForFunction<AssumptionAnalysis>(*Fn);
}
auto VisitValueCB = [&](Value &V, AANonNull::StateType &T,
bool Stripped) -> bool {
const auto &AA = A.getAAFor<AANonNull>(*this, IRPosition::value(V));
if (!Stripped && this == &AA) {
if (!isKnownNonZero(&V, DL, 0, /* TODO: AC */ nullptr, getCtxI(), DT))
if (!isKnownNonZero(&V, DL, 0, AC, getCtxI(), DT))
T.indicatePessimisticFixpoint();
} else {
// Use abstract attribute information.

View File

@ -119,8 +119,8 @@ define i8* @test9(i8* %a, i64 %n) {
}
declare void @llvm.assume(i1)
; FIXME: missing nonnull
; ATTRIBUTOR: define i8* @test10
; ATTRIBUTOR_OPM: define i8* @test10
; ATTRIBUTOR_NPM: define nonnull i8* @test10
define i8* @test10(i8* %a, i64 %n) {
%cmp = icmp ne i64 %n, 0
call void @llvm.assume(i1 %cmp)