[mlir][LLVM] Implement mapping of phi source values of llvm.invoke

This patch allows the usage of the normalDestOperands and unwindDestOperands operands of llvm.invoke and have them be correctly mapped to phis in the successor when exported to LLVM IR.

Differential Revision: https://reviews.llvm.org/D116706
This commit is contained in:
Markus Böck
2022-01-06 00:41:35 +01:00
parent bbce75e352
commit 560972052a
3 changed files with 40 additions and 4 deletions

View File

@@ -386,8 +386,15 @@ static Value getPHISourceValue(Block *current, Block *pred,
return switchOp.getCaseOperands(i.index())[index];
}
llvm_unreachable("only branch or switch operations can be terminators of a "
"block that has successors");
if (auto invokeOp = dyn_cast<LLVM::InvokeOp>(terminator)) {
return invokeOp.getNormalDest() == current
? invokeOp.getNormalDestOperands()[index]
: invokeOp.getUnwindDestOperands()[index];
}
llvm_unreachable(
"only branch, switch or invoke operations can be terminators "
"of a block that has successors");
}
/// Connect the PHI nodes to the results of preceding blocks.