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
This commit is contained in:
Dimitry Andric 2021-11-02 11:17:37 +01:00
parent 4e117af10c
commit a18c6161ef

View File

@ -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<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)