[PATCH] D97848: [CodeGenPrepare] Eliminate llvm.expect before removing empty blocks

Jann Horn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 3 03:11:27 PST 2021


thejh created this revision.
thejh added reviewers: bkramer, Carrot.
Herald added a subscriber: hiraditya.
thejh requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

CodeGenPrepare currently first removes empty blocks, then in a loop
performs other optimizations. One of those optimizations is the removal
of call instructions that invoke @llvm.assume, which can create new
empty blocks.

This means that when a branch only contains a call to __builtin_assume(),
the empty branch will survive into MIR, and will then only be
half-removed by MIR-level optimizations (e.g. removing the branch but
leaving the condition intact).

Fix it by eliminating @llvm.expect builtin calls before removing empty
blocks.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D97848

Files:
  llvm/lib/CodeGen/CodeGenPrepare.cpp
  llvm/test/Transforms/CodeGenPrepare/X86/delete-assume-dead-code.ll
  llvm/test/Transforms/CodeGenPrepare/remove-assume-block.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97848.327736.patch
Type: text/x-patch
Size: 4153 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210303/41b2e36f/attachment.bin>


More information about the llvm-commits mailing list