[InstCombine] Fix a code-sinking bug after D73832/f1a9efabcb9b

- UserParent = PN->getIncomingBlock(*I->use_begin());
+ UserParent = PN->getIncomingBlock(*SingleUse);

The first use of I may be droppable (llvm.assume).

When compiling llvm/lib/IR/AutoUpgrade.cpp with a bootstrapped clang
with ThinLTO with minimized bitcode files, I see such a case in
the function _ZN4llvm20UpgradeIntrinsicCallEPNS_8CallInstEPNS_8FunctionE

  clang -c -fthinlto-index=AutoUpgrade.o.thinlto.bc AutoUpgrade.bc -O3

Unfortunately it is really difficult to get a minimized reproduce.
This commit is contained in:
Fangrui Song 2020-03-25 22:41:02 -07:00
parent d264f02c6f
commit 4c52d51e78
1 changed files with 1 additions and 1 deletions

View File

@ -3505,7 +3505,7 @@ bool InstCombiner::run() {
// Get the block the use occurs in.
if (PHINode *PN = dyn_cast<PHINode>(UserInst))
UserParent = PN->getIncomingBlock(*I->use_begin());
UserParent = PN->getIncomingBlock(*SingleUse);
else
UserParent = UserInst->getParent();