LLVM backend for 6502
Go to file
Diego Novillo 0de8cecb84 Propagation of profile samples through the CFG.
This adds a propagation heuristic to convert instruction samples
into branch weights. It implements a similar heuristic to the one
implemented by Dehao Chen on GCC.

The propagation proceeds in 3 phases:

1- Assignment of block weights. All the basic blocks in the function
   are initial assigned the same weight as their most frequently
   executed instruction.

2- Creation of equivalence classes. Since samples may be missing from
   blocks, we can fill in the gaps by setting the weights of all the
   blocks in the same equivalence class to the same weight. To compute
   the concept of equivalence, we use dominance and loop information.
   Two blocks B1 and B2 are in the same equivalence class if B1
   dominates B2, B2 post-dominates B1 and both are in the same loop.

3- Propagation of block weights into edges. This uses a simple
   propagation heuristic. The following rules are applied to every
   block B in the CFG:

   - If B has a single predecessor/successor, then the weight
     of that edge is the weight of the block.

   - If all the edges are known except one, and the weight of the
     block is already known, the weight of the unknown edge will
     be the weight of the block minus the sum of all the known
     edges. If the sum of all the known edges is larger than B's weight,
     we set the unknown edge weight to zero.

   - If there is a self-referential edge, and the weight of the block is
     known, the weight for that edge is set to the weight of the block
     minus the weight of the other incoming edges to that block (if
     known).

Since this propagation is not guaranteed to finalize for every CFG, we
only allow it to proceed for a limited number of iterations (controlled
by -sample-profile-max-propagate-iterations). It currently uses the same
GCC default of 100.

Before propagation starts, the pass builds (for each block) a list of
unique predecessors and successors. This is necessary to handle
identical edges in multiway branches. Since we visit all blocks and all
edges of the CFG, it is cleaner to build these lists once at the start
of the pass.

Finally, the patch fixes the computation of relative line locations.
The profiler emits lines relative to the function header. To discover
it, we traverse the compilation unit looking for the subprogram
corresponding to the function. The line number of that subprogram is the
line where the function begins. That becomes line zero for all the
relative locations.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198972 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-10 23:23:46 +00:00
autoconf Remove the test for endianness in configure.ac and regenerate. 2014-01-09 01:09:57 +00:00
bindings Makefile.ocaml: Tweak to use --system-libs. 2013-12-20 00:36:59 +00:00
cmake CMake: Provide LLVM_PLUGIN_EXT definition 2014-01-08 11:10:24 +00:00
docs Add a note about the old asm printer being removed. 2014-01-10 22:06:26 +00:00
examples [CMake] Update LLVM_LINK_COMPONENTS for each CMakeLists.txt. 2013-12-10 11:13:32 +00:00
include All backends use MC now. 2014-01-10 21:49:27 +00:00
lib Propagation of profile samples through the CFG. 2014-01-10 23:23:46 +00:00
projects Revert "Revert "Windows: Add support for unicode command lines"" 2013-10-07 01:00:07 +00:00
test Propagation of profile samples through the CFG. 2014-01-10 23:23:46 +00:00
tools Space formatting fix for r198966. 2014-01-10 23:17:39 +00:00
unittests Remove remove_all. A compiler has no need for recursively deleting a directory. 2014-01-10 20:36:42 +00:00
utils Constant propagate MachineInstrClassName. 2014-01-10 22:59:49 +00:00
.arcconfig Add .arcconfig to the repository. Useful if someone wants to use phabricator's command line tool. 2012-12-01 12:07:58 +00:00
.clang-format Add a clang-format file so that the tool can automatically detect the 2013-09-02 07:19:04 +00:00
.gitignore Add extra vim swap file pattern 2012-10-09 23:48:34 +00:00
CMakeLists.txt Introduce a cmake LLVM_ENABLE_LIBCXX build parameter to compile using libc++ instead of the system default 2014-01-06 18:27:27 +00:00
CODE_OWNERS.TXT Update email address. 2013-12-04 09:42:49 +00:00
configure Remove the test for endianness in configure.ac and regenerate. 2014-01-09 01:09:57 +00:00
CREDITS.TXT Fix documentation typos 2013-12-20 00:33:39 +00:00
LICENSE.TXT Update the copyright credits -- Happy new year 2014! 2014-01-01 08:27:31 +00:00
llvm.spec.in
LLVMBuild.txt Remove the very substantial, largely unmaintained legacy PGO 2013-10-02 15:42:23 +00:00
Makefile llvm-config: Fixup r197380, tweak for cross compilation. SYSTEM_LIBS should be --host's in BuildTools/llvm-config. 2013-12-16 13:09:06 +00:00
Makefile.common Makefile.common: Update a description, s/Source/SOURCES/ , according to MakefileGuide.html#control-variables . 2012-12-07 01:43:23 +00:00
Makefile.config.in Add an autoconf option for turning on -gsplit-dwarf by default 2013-06-25 01:12:25 +00:00
Makefile.rules [Mips]Work around MIPS linker issues exposed by commit r198087 until bug 18360 is resolved 2014-01-03 22:18:43 +00:00
README.txt Revert "Test commit to check e-mail address. Please discard this." 2013-10-04 10:59:13 +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.