Skip to content

Commit 95bf090

Browse files
committed
Fix bug in getting PHI sources
1 parent ab3ec43 commit 95bf090

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

mlir/lib/Target/LLVMIR/ModuleTranslation.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -807,8 +807,10 @@ static Value getPHISourceValue(Block *current, Block *pred,
807807

808808
if (auto indBrOp = dyn_cast<LLVM::IndirectBrOp>(terminator)) {
809809
// For indirect branches we take operands for each successor.
810-
for (const auto &i : llvm::enumerate(indBrOp->getSuccessors()))
811-
return indBrOp.getSuccessorOperands(i.index())[index];
810+
for (const auto &i : llvm::enumerate(indBrOp->getSuccessors())) {
811+
if (indBrOp->getSuccessor(i.index()) == current)
812+
return indBrOp.getSuccessorOperands(i.index())[index];
813+
}
812814
}
813815

814816
if (auto invokeOp = dyn_cast<LLVM::InvokeOp>(terminator)) {

0 commit comments

Comments
 (0)