[llvm] 2c0edbf - [Attributor] Use AssumptionCache in AANonNullFloating::initialize

Hideto Ueno via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 24 20:08:10 PST 2020


Author: Hideto Ueno
Date: 2020-02-25T13:00:03+09:00
New Revision: 2c0edbf19c1b0115b944cd017201eaf1f6a832ee

URL: https://github.com/llvm/llvm-project/commit/2c0edbf19c1b0115b944cd017201eaf1f6a832ee
DIFF: https://github.com/llvm/llvm-project/commit/2c0edbf19c1b0115b944cd017201eaf1f6a832ee.diff

LOG: [Attributor] Use AssumptionCache in AANonNullFloating::initialize

Added: 
    

Modified: 
    llvm/lib/Transforms/IPO/Attributor.cpp
    llvm/test/Transforms/Attributor/nonnull.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp
index 429123a47a93..f08d7f8ba00f 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<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.

diff  --git a/llvm/test/Transforms/Attributor/nonnull.ll b/llvm/test/Transforms/Attributor/nonnull.ll
index d668332278ba..d3ccccf35c09 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)


        


More information about the llvm-commits mailing list