LLVM backend for 6502
Go to file
Keno Fischer cc80af1b4f [FastIsel][X86] Fix invalid register replacement for bool args
Summary:
Consider the following IR:

  %3 = load i8* undef
  %4 = trunc i8 %3 to i1
  %5 = call %jl_value_t.0* @foo(..., i1 %4, ...)
  ret %jl_value_t.0* %5

Bools (that are the result of direct truncs) are lowered as whatever
the argument to the trunc was and a "and 1", causing the part of the
MBB responsible for this argument to look something like this:

  %vreg8<def,tied1> = AND8ri %vreg7<kill,tied0>, 1, %EFLAGS<imp-def>; GR8:%vreg8,%vreg7

Later, when the load is lowered, it will insert

  %vreg15<def> = MOV8rm %vreg14, 1, %noreg, 0, %noreg; mem:LD1[undef] GR8:%vreg15 GR64:%vreg14

but remember to (at the end of isel) replace vreg7 by vreg15. Now for
the bug. In fast isel lowering, we mistakenly mark vreg8 as the result
of the load instead of the trunc. This adds a fixup to have
vreg8 replaced by whatever the result of the load is as well, so
we end up with

  %vreg15<def,tied1> = AND8ri %vreg15<kill,tied0>, 1, %EFLAGS<imp-def>; GR8:%vreg15

which is an SSA violation and causes problems later down the road.

This fixes PR21557.

Test Plan: Test test case from PR21557 is added to the test suite.

Reviewers: ributzka

Reviewed By: ributzka

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D6245

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224884 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-27 13:10:15 +00:00
autoconf Require python 2.7. 2014-12-12 15:29:31 +00:00
bindings [OCaml] Expose Llvm_executionengine.get_{global_value,function}_address. 2014-12-24 01:52:51 +00:00
cmake [cmake] Unbreak LLVM-Config.cmake / llvm_expand_dependencies. 2014-12-18 23:56:52 +00:00
docs Documentation for Masked Load and Store intrinsics. 2014-12-25 09:29:13 +00:00
examples
include Masked Load/Store - Changed the order of parameters in intrinsics. 2014-12-25 07:49:20 +00:00
lib [FastIsel][X86] Fix invalid register replacement for bool args 2014-12-27 13:10:15 +00:00
projects
test [FastIsel][X86] Fix invalid register replacement for bool args 2014-12-27 13:10:15 +00:00
tools Another attempt to fix the LLVM Windows build bot lld-x86_64-win7, one last place to fix I think. 2014-12-24 00:16:51 +00:00
unittests Fix a leak found by asan. 2014-12-23 17:20:23 +00:00
utils Masked Load/Store - Changed the order of parameters in intrinsics. 2014-12-25 07:49:20 +00:00
.arcconfig
.clang-format
.clang-tidy
.gitignore
CMakeLists.txt Adding a new option to CMake to disable C++ atexit on llvm-shlib. 2014-12-09 18:49:55 +00:00
CODE_OWNERS.TXT Add myself as SystemZ code owner 2014-12-18 19:27:50 +00:00
configure Require python 2.7. 2014-12-12 15:29:31 +00:00
CREDITS.TXT
LICENSE.TXT
llvm.spec.in
LLVMBuild.txt
Makefile
Makefile.common
Makefile.config.in
Makefile.rules
README.txt

Low Level Virtual Machine (LLVM)
================================

This directory and its subdirectories contain source code for the Low Level
Virtual Machine, 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're writing a package for LLVM, see docs/Packaging.rst for our
suggestions.