[llvm] 795aebf - [Inliner][NFC] Remove redundant nullptr check

Mircea Trofin via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 7 17:22:48 PST 2023


Author: Alex MacLean
Date: 2023-03-07T17:22:38-08:00
New Revision: 795aebf3883112764658cdeb1cf94cc5ea91bb28

URL: https://github.com/llvm/llvm-project/commit/795aebf3883112764658cdeb1cf94cc5ea91bb28
DIFF: https://github.com/llvm/llvm-project/commit/795aebf3883112764658cdeb1cf94cc5ea91bb28.diff

LOG: [Inliner][NFC] Remove redundant nullptr check

Remove the null pointer check on Callee since it is guaranteed to pass by the check
at the top of the loop which continues if Callee is null. While this change is somewhat
trivial, for what it's worth this check triggers Coverity warnings because it implies that
Callee might be null at this point even though it is dereferenced in the preceding code.

Reviewed By: mtrofin

Differential Revision: https://reviews.llvm.org/D145463

Added: 
    

Modified: 
    llvm/lib/Transforms/IPO/Inliner.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/IPO/Inliner.cpp b/llvm/lib/Transforms/IPO/Inliner.cpp
index 748a27e3fa5a5..43afac145d943 100644
--- a/llvm/lib/Transforms/IPO/Inliner.cpp
+++ b/llvm/lib/Transforms/IPO/Inliner.cpp
@@ -555,7 +555,8 @@ inlineCallsImpl(CallGraphSCC &SCC, CallGraph &CG,
 
       // If we inlined or deleted the last possible call site to the function,
       // delete the function body now.
-      if (Callee && Callee->use_empty() && Callee->hasLocalLinkage() &&
+      assert(Callee && "Expected to be non-null due to check at start of loop");
+      if (Callee->use_empty() && Callee->hasLocalLinkage() &&
           // TODO: Can remove if in SCC now.
           !SCCFunctions.count(Callee) &&
           // The function may be apparently dead, but if there are indirect


        


More information about the llvm-commits mailing list