git: e06dc0bf2b96 - stable/12 - Fix assertion when building devel/glog with new pass manager

From: Dimitry Andric <dim_at_FreeBSD.org>
Date: Sat, 25 Dec 2021 11:56:26 UTC
The branch stable/12 has been updated by dim:

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

commit e06dc0bf2b96663cf165c38eec960151881b7952
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2021-11-02 10:17:37 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2021-12-25 11:51:40 +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)