diff options
author | Timothy Werquin <timothy@werquin.com> | 2025-05-27 15:51:48 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-05-27 15:51:48 +0200 |
commit | a8e486bfc4960a532d81f41c56d25e46e559157a (patch) | |
tree | 173ae93f161acdc00ac2d5f9fc8a077dbb4f4ddc /llvm/lib/Bitcode/Reader/BitcodeReader.cpp | |
parent | 904d0c293e4de2c63ef473bbd2b1d3f56f113402 (diff) | |
download | llvm-a8e486bfc4960a532d81f41c56d25e46e559157a.zip llvm-a8e486bfc4960a532d81f41c56d25e46e559157a.tar.gz llvm-a8e486bfc4960a532d81f41c56d25e46e559157a.tar.bz2 |
[Bitcode] Fix constexpr expansion creating invalid PHIs (#141560)
Fixes errors about duplicate PHI edges when the input had duplicates
with constexprs in them. The constexpr translation makes new basic
blocks, causing the verifier to complain about duplicate entries in PHI
nodes.
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
-rw-r--r-- | llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index 58625ee..ce7b1ef 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -6095,14 +6095,18 @@ Error BitcodeReader::parseFunctionBody(Function *F) { // seen value here, to avoid expanding a constant expression multiple // times. auto It = Args.find(BB); + BasicBlock *EdgeBB = ConstExprEdgeBBs.lookup({BB, CurBB}); if (It != Args.end()) { - PN->addIncoming(It->second, BB); + // If this predecessor was also replaced with a constexpr basic + // block, it must be de-duplicated. + if (!EdgeBB) { + PN->addIncoming(It->second, BB); + } continue; } // If there already is a block for this edge (from a different phi), // use it. - BasicBlock *EdgeBB = ConstExprEdgeBBs.lookup({BB, CurBB}); if (!EdgeBB) { // Otherwise, use a temporary block (that we will discard if it // turns out to be unnecessary). |