[all-commits] [llvm/llvm-project] 994eb5: [CodeGen] Fix unconditional branch duplication iss...

Daniel Hoekwater via All-commits all-commits at lists.llvm.org
Thu Aug 24 09:28:44 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 994eb5adc40cd001d82d0f95d18d1827b57e496c
      https://github.com/llvm/llvm-project/commit/994eb5adc40cd001d82d0f95d18d1827b57e496c
  Author: Daniel Hoekwater <hoekwater at google.com>
  Date:   2023-08-24 (Thu, 24 Aug 2023)

  Changed paths:
    M llvm/lib/CodeGen/BasicBlockSections.cpp
    M llvm/test/CodeGen/Generic/machine-function-splitter.ll

  Log Message:
  -----------
  [CodeGen] Fix unconditional branch duplication issue in bbsections

If an end section basic block ends in an unconditional branch to its
fallthrough, BasicBlockSections will duplicate the unconditional branch.
This doesn't break x86, but it is a (slight) size optimization and more
importantly prevents AArch64 builds from breaking.

Ex:
```
bb1 (bbsections Hot):
  jmp bb2

bb2 (bbsections Cold):
  /* do work... */
```

After running sortBasicBlocksAndUpdateBranches():
```
bb1 (bbsections Hot):
  jmp bb2
  jmp bb2

bb2 (bbsections Cold):
  /* do work... */
```

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




More information about the All-commits mailing list