diff --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp index 429123a47a93f..f08d7f8ba00f4 100644 --- a/llvm/lib/Transforms/IPO/Attributor.cpp +++ b/llvm/lib/Transforms/IPO/Attributor.cpp @@ -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(*Fn); + AC = InfoCache.getAnalysisResultForFunction(*Fn); + } auto VisitValueCB = [&](Value &V, AANonNull::StateType &T, bool Stripped) -> bool { const auto &AA = A.getAAFor(*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. diff --git a/llvm/test/Transforms/Attributor/nonnull.ll b/llvm/test/Transforms/Attributor/nonnull.ll index d668332278bad..d3ccccf35c094 100644 --- a/llvm/test/Transforms/Attributor/nonnull.ll +++ b/llvm/test/Transforms/Attributor/nonnull.ll @@ -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)