From a18c6161efc903f636c41b8e521e917a5b315ce8 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Tue, 2 Nov 2021 11:17:37 +0100 Subject: [PATCH] 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 --- .../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 @@ class LazyCallGraph { 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(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(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(C)) continue; - } for (Value *Op : C->operand_values()) if (Visited.insert(cast(Op)).second)