User Tools

Site Tools


LLVM Update

This page summarizes the effort of updating LegUp from LLVM 2.9 to LLVM 3.4.

LegUp Source Changes Required

LLVM Header Files Moved/Deprecated

The following header files have been renamed or removed. The functionality seems identical in most cases.

LLVM Objects and Functions Renamed/Deprecated

Red highlighting indicates changes that may cause problems, or may not be functionally correct.

Yellow highlighting indicates changes that are probably fine, but may need to be double checked.

Unhighlighted rows indicate trivial changes that should have little or no effect.

Functionality Added to LegUp


LLVM 3.4 now uses ConstantDataArray in several places where a ConstantArray was used previously. ConstantDataArray support was added to some LegUp files including:

  • Ram.cpp
  • Ram.h
  • GenerateRTL.cpp
  • IterativeModuloScheduling.cpp

LegUp Makefile Changes Required

llvm-ld Deprecated


llvm-link ...
llvm-opt -std-link-opts ...


Unfortunately llvm-link cannot link archive files, only .bc files. As a result, instead of linking with liblegup.a, libm.a, etc, we need to link with liblegup.bc, libm.bc, etc, which are basically the same thing, just in a different format.

llvm-gcc Deprecated

llvm-gcc was used for OpenMP support. The LLVM project “dragonegg” can be used instead. dragonegg is a gcc plugin. It will be compiled along with the rest of LegUp. It requires gcc 4.5, 4.6, 4.7, or 4.8, and the corresponding gcc-4.X-plugin-dev package (available using apt-get). The main LegUp Makefile assumes the packages gcc-4.6 and gcc-4.6-plugin-dev are installed. If you wish to use a different version of gcc, you must change the DRAGONEGG variable in legup/examples/Makefile.config and DRAGONEGG_GCC_VERSION in legup/Makefile and recompile LegUp.

LLVM Profiling Deprecated

The -insert-edge-profiling pass no longer exists. LLVM no longer exists.

These things have simply been commented out for now.


LLVM 3.4 now produces vectorized code that is not currently supported by LegUp. Adding clang flags -fno-vectorize and -fno-spl-vectorize seems to solve this problem for now. In the future it may be desirable to add this functionality to LegUp in order to obtain more parallel hardware. See LLVM 3.4 Auto-Vectorization for more info.

MIPS1 Target Deprecated

llc no longer has a backend for mips1. Compiling for mips32 with flags -mno-ldc1-sdc1 -soft-float produces somewhat similar code, but it is still not perfect. An awk command can be used to lower conditional move instructions, and add a nop after each lw. Also, the LLVM mips backend was modified to not produce DSP instructions. This seems to work well enough that the mips binutils can assemble working binaries for Tiger.

Changes Required to LegUp Examples

Disable LegUp Features

It was necessary to disable LOCAL_RAMS for the following benchmarks:

  • chstone/blowfish
  • chstone/gsm

It was necessary to disable GROUP_RAMS_SIMPLE_OFFSET for the following benchmarks:

  • chstone/jpeg


  • chstone_hybrid/dfsin: the linker complains about multiple definitions of 'sin' when linking with libm.bc. sin() was renamed to dfsin() to fix this problem.
  • use_begin iterator is now user_begin. Don't use the use_ iterators directly any more. Use is now a bookkeeping helper class for the User class. See:

  • If you must use the use_ iterators (not recommended), you have to use the getUser() method to cast to an instruction like:
for (... i = I->use_begin() ...
Instruction *user = cast<Instruction>(i->getUser());

Optimization Passes Disabled

The following optimization passes were disabled:

  • InstructionCombiningPass
  • SROAPass
  • GVNPass
  • ScalarReplAggregatesPass

These passes were run with opt -std-link-opts; however, they caused several of our benchmarks to fail. There is probably a better solution than simply disabling these passes.

Comparison vs. LLVM 2.9

Cycle Counts

Other Notes

LLVM 3.4 produces calls to more intrinsic functions. Additional source files were copied from newlib/libm into legup/examples/lib/llvm/libm, and compiled into libm.bc.

LegUp with LLVM 3.4 requires that the appropriate version of Clang is in your $PATH. The LLVM 3.4 Clang binary can be obtained from the LLVM download website: LLVM 3.4 Downloads

llvm_update.txt · Last modified: 2014/12/10 16:52 by acanis