LLVM backend for 6502
Go to file
Chandler Carruth 41b55f5556 PR14972: SROA vs. GVN exposed a really bad bug in SROA.
The fundamental problem is that SROA didn't allow for overly wide loads
where the bits past the end of the alloca were masked away and the load
was sufficiently aligned to ensure there is no risk of page fault, or
other trapping behavior. With such widened loads, SROA would delete the
load entirely rather than clamping it to the size of the alloca in order
to allow mem2reg to fire. This was exposed by a test case that neatly
arranged for GVN to run first, widening certain loads, followed by an
inline step, and then SROA which miscompiles the code. However, I see no
reason why this hasn't been plaguing us in other contexts. It seems
deeply broken.

Diagnosing all of the above took all of 10 minutes of debugging. The
really annoying aspect is that fixing this completely breaks the pass.
;] There was an implicit reliance on the fact that no loads or stores
extended past the alloca once we decided to rewrite them in the final
stage of SROA. This was used to encode information about whether the
loads and stores had been split across multiple partitions of the
original alloca. That required threading explicit tracking of whether
a *use* of a partition is split across multiple partitions.

Once that was done, another problem arose: we allowed splitting of
integer loads and stores iff they were loads and stores to the entire
alloca. This is a really arbitrary limitation, and splitting at least
some integer loads and stores is crucial to maximize promotion
opportunities. My first attempt was to start removing the restriction
entirely, but currently that does Very Bad Things by causing *many*
common alloca patterns to be fully decomposed into i8 operations and
lots of or-ing together to produce larger integers on demand. The code
bloat is terrifying. That is still the right end-goal, but substantial
work must be done to either merge partitions or ensure that small i8
values are eagerly merged in some other pass. Sadly, figuring all this
out took essentially all the time and effort here.

So the end result is that we allow splitting only when the load or store
at least covers the alloca. That ensures widened loads and stores don't
hurt SROA, and that we don't rampantly decompose operations more than we
have previously.

All of this was already fairly well tested, and so I've just updated the
tests to cover the wide load behavior. I can add a test that crafts the
pass ordering magic which caused the original PR, but that seems really
brittle and to provide little benefit. The fundamental problem is that
widened loads should Just Work.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@177055 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-14 11:32:24 +00:00
autoconf configure: remove workaround for gcc's -Wno-maybe-uninitialized 2013-02-13 21:19:39 +00:00
bindings
cmake Simplify CMake rules in HandleLLVMOptions module. 2013-03-13 20:50:23 +00:00
docs ReleaseNotes: Add Hexagon Target section 2013-03-12 12:20:51 +00:00
examples
include Add two of the float related ARM-specific entries for e_flags needed for 2013-03-14 08:01:36 +00:00
lib PR14972: SROA vs. GVN exposed a really bad bug in SROA. 2013-03-14 11:32:24 +00:00
projects Print a warning message if compiler-rt can't be built because of old CMake version to make this requirement more visible to users 2013-03-05 14:43:07 +00:00
runtime Remove GCDAProfiling.c. This copy is old, the copy in compiler-rt is newer and 2013-03-07 02:03:08 +00:00
test PR14972: SROA vs. GVN exposed a really bad bug in SROA. 2013-03-14 11:32:24 +00:00
tools Make LTO codegen use a PassManager, rather than a FunctionPassManager, for the 2013-03-13 21:18:46 +00:00
unittests [Support][Test] Missed this in the API change. 2013-03-14 00:33:37 +00:00
utils lit.TestFormats.GoogleTest: Honor LitConfig.noExecute, or --no-execute were ignored. 2013-03-13 06:16:33 +00:00
.arcconfig
.gitignore
CMakeLists.txt Revert CMake version bump since we don't actually need 2.8.6 any more. 2013-02-18 11:53:37 +00:00
CODE_OWNERS.TXT Reflect reality. 2013-03-12 10:38:39 +00:00
configure configure: remove workaround for gcc's -Wno-maybe-uninitialized 2013-02-13 21:19:39 +00:00
CREDITS.TXT Reflect reality. 2013-03-12 10:38:39 +00:00
LICENSE.TXT
llvm.spec.in
LLVMBuild.txt
Makefile
Makefile.common
Makefile.config.in
Makefile.rules remove an ancient and quaint bit of commented out makefile goo from when 2013-03-08 01:26:10 +00:00
README.txt Revert "Test commit" 2013-02-22 19:19:41 +00:00

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.