[all-commits] [llvm/llvm-project] c5d84d: GlobalISel/AArch64: don't optimize away redundant ...

adrian-prantl via All-commits all-commits at lists.llvm.org
Thu Jul 29 16:04:39 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: c5d84d2eb35c1f0d3b08e1d1e95c1a22a28904d1
      https://github.com/llvm/llvm-project/commit/c5d84d2eb35c1f0d3b08e1d1e95c1a22a28904d1
  Author: Adrian Prantl <aprantl at apple.com>
  Date:   2021-07-29 (Thu, 29 Jul 2021)

  Changed paths:
    M llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
    M llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
    M llvm/test/CodeGen/AArch64/GlobalISel/arm64-atomic-128.ll
    M llvm/test/CodeGen/AArch64/GlobalISel/arm64-atomic.ll
    M llvm/test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll
    M llvm/test/CodeGen/AArch64/unwind-preserved.ll
    M llvm/test/CodeGen/Mips/GlobalISel/llvm-ir/jump_table_and_brjt.ll
    M llvm/test/CodeGen/Mips/GlobalISel/llvm-ir/long_ambiguous_chain_s32.ll
    M llvm/test/CodeGen/Mips/GlobalISel/llvm-ir/long_ambiguous_chain_s64.ll
    M llvm/test/CodeGen/Mips/GlobalISel/llvm-ir/phi.ll
    A llvm/test/DebugInfo/AArch64/fallthrough-branch.ll

  Log Message:
  -----------
  GlobalISel/AArch64: don't optimize away redundant branches at -O0

This patch prevents GlobalISel from optimizing out redundant branch
instructions when compiling without optimizations.

The motivating example is code like the following common pattern in
Swift, where users expect to be able to set a breakpoint on the early
exit:

public func f(b: Bool) {
  guard b else {
    return // I would like to set a breakpoint here.
  }
  ...
}

The patch modifies two places in GlobalISEL: The first one is in
IRTranslator.cpp where the removal of redundant branches is made
conditional on the optimization level. The second one is in
AArch64InstructionSelector.cpp where an -O0 *only* optimization is
being removed.

Disabling these optimizations increases code size at -O0 by
~8%. However, doing so improves debuggability, and debug builds are
the primary reason why developers compile without optimizations. We
thus concluded that this is the right trade-off.

rdar://79515454

This tenatively reapplies the patch without modifications, the LLDB
test that has blocked this from landing previously has since been
modified to hopefully no longer be sensitive to this change.

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




More information about the All-commits mailing list