<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/114796>114796</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [Verifier] Duplicated Predecessors of BasicBlock can pass verifier
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          x14ngch3n
      </td>
    </tr>
</table>

<pre>
    IR below is generated with LLVM-3.6, this BB (block_1645788) has three duplicated predecessors (block_1645730) and its PHINode has three duplicated incoming values ( [ %tmp41218, %block_1645730 ] ). This BB is actually a switch case, and the duplicated predecessors are where the SwitchInst is located, the duplicated predecessors is because different cases fall through the same block. 

```llvm
block_1645788:                                    ; preds = %bb31747, %block_164577c, %block_1645730, %block_1645730, %block_1645730
  %tmp41324 = phi i64 [ %tmp31748, %bb31747 ], [ %tmp41323, %block_164577c ], [ %tmp41218, %block_1645730 ], [ %tmp41218, %block_1645730 ], [ %tmp41218, %block_1645730 ], !asm !165
  %tmp41325 = phi i64 [ %tmp41318, %bb31747 ], [ %tmp41318, %block_164577c ], [ %tmp31712, %block_1645730 ], [ %tmp31712, %block_1645730 ], [ %tmp31712, %block_1645730 ], !asm !165
  %tmp41326 = phi i64 [ %tmp41319, %bb31747 ], [ %tmp41319, %block_164577c ], [ %tmp41105, %block_1645730 ], [ %tmp41105, %block_1645730 ], [ %tmp41105, %block_1645730 ], !asm !165
  br label %block_164578c, !asm !166
```

To compare, in the latest LLVM/Clang, the compiler will not generate BB with duplicated predecessors: https://godbolt.org/z/Pxond9x47

*I don't understand why this IR can pass the verifier? Why not just keep one predecessors? * In other words, when can we assume that PHI Node can only have incoming values from distinct incoming blocks (predecessors)?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0Vt2O4jgTfRpzU2oU2_m9yEUzKPqQ5lu1ZkezlysnKbBnH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