Skip to content

Commit 786c4ac

Browse files
authored
[GVN] Fixed a crash.
1 parent 8933f5a commit 786c4ac

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

llvm/lib/Transforms/Scalar/GVN.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2257,13 +2257,15 @@ bool GVNPass::ValueTable::areCallValsEqual(uint32_t Num, uint32_t NewNum,
22572257
uint32_t GVNPass::ValueTable::phiTranslateImpl(const BasicBlock *Pred,
22582258
const BasicBlock *PhiBlock,
22592259
uint32_t Num, GVNPass &Gvn) {
2260-
if (PHINode *PN = NumberingPhi[Num]) {
2261-
for (unsigned i = 0; i != PN->getNumIncomingValues(); ++i) {
2262-
if (PN->getParent() == PhiBlock && PN->getIncomingBlock(i) == Pred)
2263-
if (uint32_t TransVal = lookup(PN->getIncomingValue(i), false))
2264-
return TransVal;
2260+
if (NumberingPhi.find(Num) != NumberingPhi.end()) {
2261+
if (PHINode *PN = NumberingPhi[Num]) {
2262+
for (unsigned i = 0; i != PN->getNumIncomingValues(); ++i) {
2263+
if (PN->getParent() == PhiBlock && PN->getIncomingBlock(i) == Pred)
2264+
if (uint32_t TransVal = lookup(PN->getIncomingValue(i), false))
2265+
return TransVal;
2266+
}
2267+
return Num;
22652268
}
2266-
return Num;
22672269
}
22682270

22692271
// If there is any value related with Num is defined in a BB other than

0 commit comments

Comments
 (0)