llvm-project/llvm
Heejin Ahn ac4006b0d6 [InstCombine] Don't slice up PHIs when pred BB has catchswitch
If an integer PHI has an illegal type (according to the data layout) and
it is only used by `trunc` or `trunc(lshr)` operations, we split the PHI
into various instructions in its predecessors:
6d1543a167/llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp (L1536-L1543)

So this can produce code like the following:
Before:
```
pred:
  ...

bb:
  %p = phi i8 [ %somevalue, %pred ], ...
  ...
  %tobool = trunc i8 %p to i1
  use %tobool
  ...
```
In this code, `%p` has an illegal integer type, `i8`, and its only used
in a `trunc` instruction later. In this case this pass puts extraction
code in its predecessors:

After:
```
pred:
  ...
  %t = and i8 %somevalue, 1
  %extract = icmp ne i8 %t, 0

bb:
  %p.new = phi i1 [ %extract, %pred ], ...
  use %p.new instead of %tobool
```

But this doesn't work if `pred` is a `catchswitch` BB because it cannot
have any non-PHI instructions. This CL ensures we bail out in that case.

Fixes https://github.com/llvm/llvm-project/issues/55803.

Reviewed By: dschuff

Differential Revision: https://reviews.llvm.org/D127699
2022-06-13 18:32:09 -07:00
..
benchmarks
bindings [llvm-ocaml] Add and use opaque pointer compatible bindings 2022-06-02 11:42:24 +02:00
cmake Revert "[cmake] Don't export `LLVM_TOOLS_INSTALL_DIR` anymore" 2022-06-10 19:26:12 +00:00
docs Revert "[X86][RFC] Enable `_Float16` type support on X86 following the psABI" 2022-06-12 15:14:37 +00:00
examples Remove unneeded cl::ZeroOrMore for cl::opt/cl::list options 2022-06-05 01:07:51 -07:00
include [BasicTTI] Remove unused support for multiple opcodes in getTypeBasedIntrinsicInstrCost [nfc] 2022-06-13 18:23:39 -07:00
lib [InstCombine] Don't slice up PHIs when pred BB has catchswitch 2022-06-13 18:32:09 -07:00
projects
resources
runtimes Revert "[runtimes] Detect changes to Tests.cmake" 2022-05-26 09:34:18 -07:00
test [InstCombine] Don't slice up PHIs when pred BB has catchswitch 2022-06-13 18:32:09 -07:00
tools [ORC][ORC_RT] Integrate ORC platforms with LLJIT and lli 2022-06-09 22:47:58 -07:00
unittests [C-API][ORC] Add C API to suspend lookups during definition generation. 2022-06-13 17:20:07 -07:00
utils Revert "gn build: Add support for building the standalone ubsan runtime." 2022-06-13 14:06:14 -07:00
.clang-format
.clang-tidy
.gitattributes
.gitignore
CMakeLists.txt [CMake] Enable LLVM_ENABLE_PER_TARGET_RUNTIME_DIR by default on Linux 2022-06-07 21:22:38 -07:00
CODE_OWNERS.TXT
CREDITS.TXT
LICENSE.TXT
README.txt
RELEASE_TESTERS.TXT
configure
llvm.spec.in

README.txt

The LLVM Compiler Infrastructure
================================

This directory and its subdirectories contain source code for LLVM,
a toolkit for the construction of highly optimized compilers,
optimizers, and runtime environments.

LLVM is open source software. You may freely distribute it under the terms of
the license agreement found in LICENSE.txt.

Please see the documentation provided in docs/ for further
assistance with LLVM, and in particular docs/GettingStarted.rst for getting
started with LLVM and docs/README.txt for an overview of LLVM's
documentation setup.

If you are writing a package for LLVM, see docs/Packaging.rst for our
suggestions.