[all-commits] [llvm/llvm-project] f66309: [GlobalISel] Don't add duplicate successors to MBB...

Jessica Paquette via All-commits all-commits at lists.llvm.org
Fri May 8 13:40:28 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: f66309deab1d99a17d6740244dfd1b9f959e9095
      https://github.com/llvm/llvm-project/commit/f66309deab1d99a17d6740244dfd1b9f959e9095
  Author: Jessica Paquette <jpaquette at apple.com>
  Date:   2020-05-08 (Fri, 08 May 2020)

  Changed paths:
    M llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
    A llvm/test/CodeGen/AArch64/GlobalISel/irtranslator-indirect-br-repeated-block.ll

  Log Message:
  -----------
  [GlobalISel] Don't add duplicate successors to MBBs when translating indirectbr

This fixes a verifier failure on a bot:

http://green.lab.llvm.org/green/job/test-suite-verify-machineinstrs-aarch64-O0-g/

```
*** Bad machine code: MBB has duplicate entries in its successor list. ***
- function:    foo
- basic block: %bb.5 indirectgoto (0x7fe3d687ca08)
```

One of the GCC torture suite tests (pr70460.c) has an indirectbr instruction
which has duplicate blocks in its destination list.

According to the langref this is allowed:

> Blocks are allowed to occur multiple times in the destination list, though
> this isn’t particularly useful.
(https://www.llvm.org/docs/LangRef.html#indirectbr-instruction)

We don't allow this in MIR. So, when we translate such an instruction, the
verifier screams.

This patch makes `translateIndirectBr` check if a successor has already been
added to a block. If the successor is present, it is skipped rather than added
twice.

Differential Revision: https://reviews.llvm.org/D79609




More information about the All-commits mailing list