git: c009c03b3731 - stable/13 - Fix assertion when building devel/glog with new pass manager

From: Dimitry Andric <dim_at_FreeBSD.org>
Date: Mon, 06 Dec 2021 16:33:25 UTC
The branch stable/13 has been updated by dim:

URL: https://cgit.FreeBSD.org/src/commit/?id=c009c03b3731dbbc0461172eb729da461eed5181

commit c009c03b3731dbbc0461172eb729da461eed5181
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2021-11-02 10:17:37 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2021-12-06 16:30:09 +0000

    Fix assertion when building devel/glog with new pass manager
    
    Merge commit 029f1a534489 from llvm git (by Arthur Eubanks):
    
      [LazyCallGraph] Skip blockaddresses
    
      blockaddresses do not participate in the call graph since the only
      instructions that use them must all return to someplace within the
      current function. And passes cannot retrieve a function address from a
      blockaddress.
    
      This was suggested by efriedma in D58260.
    
      Fixes PR50881.
    
      Reviewed By: nickdesaulniers
    
      Differential Revision: https://reviews.llvm.org/D112178
    
    (cherry picked from commit a18c6161efc903f636c41b8e521e917a5b315ce8)
---
 .../llvm/include/llvm/Analysis/LazyCallGraph.h     | 24 +++-------------------
 1 file changed, 3 insertions(+), 21 deletions(-)

diff --git a/contrib/llvm-project/llvm/include/llvm/Analysis/LazyCallGraph.h b/contrib/llvm-project/llvm/include/llvm/Analysis/LazyCallGraph.h
index 81500905c0f5..148be34aa73b 100644
--- a/contrib/llvm-project/llvm/include/llvm/Analysis/LazyCallGraph.h
+++ b/contrib/llvm-project/llvm/include/llvm/Analysis/LazyCallGraph.h
@@ -1098,28 +1098,10 @@ public:
         continue;
       }
 
-      // The blockaddress constant expression is a weird special case, we can't
-      // generically walk its operands the way we do for all other constants.
-      if (BlockAddress *BA = dyn_cast<BlockAddress>(C)) {
-        // If we've already visited the function referred to by the block
-        // address, we don't need to revisit it.
-        if (Visited.count(BA->getFunction()))
-          continue;
-
-        // If all of the blockaddress' users are instructions within the
-        // referred to function, we don't need to insert a cycle.
-        if (llvm::all_of(BA->users(), [&](User *U) {
-              if (Instruction *I = dyn_cast<Instruction>(U))
-                return I->getFunction() == BA->getFunction();
-              return false;
-            }))
-          continue;
-
-        // Otherwise we should go visit the referred to function.
-        Visited.insert(BA->getFunction());
-        Worklist.push_back(BA->getFunction());
+      // blockaddresses are weird and don't participate in the call graph anyway,
+      // skip them.
+      if (isa<BlockAddress>(C))
         continue;
-      }
 
       for (Value *Op : C->operand_values())
         if (Visited.insert(cast<Constant>(Op)).second)