Vendor import of llvm RELEASE_350/final tag r216957 (effectively, 3.5.0 release):

https://llvm.org/svn/llvm-project/llvm/tags/RELEASE_350/final@216957
This commit is contained in:
dim 2014-11-24 09:08:18 +00:00
parent 87ba4fbed5
commit e27feadae0
6862 changed files with 524351 additions and 418502 deletions

View File

@ -1,4 +1,4 @@
{
"project_id" : "llvm",
"conduit_uri" : "http://llvm-reviews.chandlerc.com/"
"conduit_uri" : "http://reviews.llvm.org/"
}

View File

@ -1 +1,2 @@
BasedOnStyle: LLVM

5
.gitignore vendored
View File

@ -18,6 +18,8 @@
# vim swap files
.*.swp
.sw?
#OS X specific files.
.DS_store
#==============================================================================#
# Explicit files to ignore (only matches one).
@ -35,7 +37,6 @@ compile_commands.json
#==============================================================================#
# External projects that are tracked independently.
projects/*
!projects/sample
!projects/CMakeLists.txt
!projects/Makefile
# Clang, which is tracked independently.
@ -44,5 +45,7 @@ tools/clang
tools/lldb
# lld, which is tracked independently.
tools/lld
# Polly, which is tracked independently.
tools/polly
# Sphinx build tree, if building in-source dir.
docs/_build

View File

@ -1,7 +1,22 @@
# See docs/CMake.html for instructions about how to build LLVM with CMake.
cmake_minimum_required(VERSION 2.8.8)
# FIXME: It may be removed when we use 2.8.12.
if(CMAKE_VERSION VERSION_LESS 2.8.12)
# Invalidate a couple of keywords.
set(cmake_2_8_12_INTERFACE)
set(cmake_2_8_12_PRIVATE)
else()
# Use ${cmake_2_8_12_KEYWORD} intead of KEYWORD in target_link_libraries().
set(cmake_2_8_12_INTERFACE INTERFACE)
set(cmake_2_8_12_PRIVATE PRIVATE)
if(POLICY CMP0022)
cmake_policy(SET CMP0022 NEW) # automatic when 2.8.12 is required
endif()
endif()
project(LLVM)
cmake_minimum_required(VERSION 2.8)
# Add path for custom modules
set(CMAKE_MODULE_PATH
@ -11,11 +26,11 @@ set(CMAKE_MODULE_PATH
)
set(LLVM_VERSION_MAJOR 3)
set(LLVM_VERSION_MINOR 4)
set(LLVM_VERSION_PATCH 1)
set(LLVM_VERSION_MINOR 5)
set(LLVM_VERSION_PATCH 0)
if (NOT PACKAGE_VERSION)
set(PACKAGE_VERSION "${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}")
set(PACKAGE_VERSION "${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}svn")
endif()
option(LLVM_INSTALL_TOOLCHAIN_ONLY "Only include toolchain files in the 'install' target." OFF)
@ -38,6 +53,9 @@ set(PACKAGE_NAME LLVM)
set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
set(PACKAGE_BUGREPORT "http://llvm.org/bugs/")
set(BUG_REPORT_URL "${PACKAGE_BUGREPORT}" CACHE STRING
"Default URL where bug reports are to be submitted.")
# Configure CPack.
set(CPACK_PACKAGE_INSTALL_DIRECTORY "LLVM")
set(CPACK_PACKAGE_VENDOR "LLVM")
@ -49,6 +67,8 @@ set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.TXT")
if(WIN32 AND NOT UNIX)
set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "LLVM")
set(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}\\\\cmake\\\\nsis_logo.bmp")
set(CPACK_NSIS_MUI_ICON "${CMAKE_CURRENT_SOURCE_DIR}\\\\cmake\\\\nsis_icon.ico")
set(CPACK_NSIS_MUI_UNIICON "${CMAKE_CURRENT_SOURCE_DIR}\\\\cmake\\\\nsis_icon.ico")
set(CPACK_NSIS_MODIFY_PATH "ON")
set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL "ON")
set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS
@ -91,11 +111,25 @@ endif()
string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE)
set(LLVM_MAIN_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(LLVM_MAIN_INCLUDE_DIR ${LLVM_MAIN_SRC_DIR}/include)
set(LLVM_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
set(LLVM_TOOLS_BINARY_DIR ${LLVM_BINARY_DIR}/bin)
# They are used as destination of target generators.
set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin)
set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib)
if(WIN32 OR CYGWIN)
# DLL platform -- put DLLs into bin.
set(LLVM_SHLIB_OUTPUT_INTDIR ${LLVM_RUNTIME_OUTPUT_INTDIR})
else()
set(LLVM_SHLIB_OUTPUT_INTDIR ${LLVM_LIBRARY_OUTPUT_INTDIR})
endif()
# Each of them corresponds to llvm-config's.
set(LLVM_TOOLS_BINARY_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR}) # --bindir
set(LLVM_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}) # --libdir
set(LLVM_MAIN_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR} ) # --src-root
set(LLVM_MAIN_INCLUDE_DIR ${LLVM_MAIN_SRC_DIR}/include ) # --includedir
set(LLVM_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR} ) # --prefix
set(LLVM_EXAMPLES_BINARY_DIR ${LLVM_BINARY_DIR}/examples)
set(LLVM_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/include)
set(LLVM_LIBDIR_SUFFIX "" CACHE STRING "Define suffix of library directory name (32/64)" )
set(LLVM_ALL_TARGETS
@ -126,11 +160,6 @@ set(LLVM_EXPERIMENTAL_TARGETS_TO_BUILD ""
option(BUILD_SHARED_LIBS
"Build all libraries as shared libraries instead of static" OFF)
option(LLVM_ENABLE_CBE_PRINTF_A "Set to ON if CBE is enabled for printf %a output" ON)
if(LLVM_ENABLE_CBE_PRINTF_A)
set(ENABLE_CBE_PRINTF_A 1)
endif()
option(LLVM_ENABLE_TIMESTAMPS "Enable embedding timestamp information in build" ON)
if(LLVM_ENABLE_TIMESTAMPS)
set(ENABLE_TIMESTAMPS 1)
@ -168,8 +197,6 @@ set(LLVM_TARGETS_TO_BUILD
${LLVM_EXPERIMENTAL_TARGETS_TO_BUILD})
list(REMOVE_DUPLICATES LLVM_TARGETS_TO_BUILD)
set(llvm_builded_incs_dir ${LLVM_BINARY_DIR}/include/llvm)
include(AddLLVMDefinitions)
option(LLVM_ENABLE_PIC "Build Position-Independent Code" ON)
@ -177,10 +204,12 @@ option(LLVM_ENABLE_PIC "Build Position-Independent Code" ON)
# MSVC has a gazillion warnings with this.
if( MSVC )
option(LLVM_ENABLE_WARNINGS "Enable compiler warnings." OFF)
else( MSVC )
else()
option(LLVM_ENABLE_WARNINGS "Enable compiler warnings." ON)
endif()
option(LLVM_ENABLE_CXX1Y "Compile with C++1y enabled." OFF)
option(LLVM_ENABLE_LIBCXX "Use libc++ if available." OFF)
option(LLVM_ENABLE_PEDANTIC "Compile with pedantic enabled." ON)
option(LLVM_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF)
@ -190,6 +219,9 @@ else()
option(LLVM_ENABLE_ASSERTIONS "Enable assertions" ON)
endif()
option(LLVM_FORCE_USE_OLD_HOST_TOOLCHAIN
"Set to ON to force using an old, unsupported host toolchain." OFF)
option(LLVM_USE_INTEL_JITEVENTS
"Use Intel JIT API to inform Intel(R) VTune(TM) Amplifier XE 2011 about JIT code"
OFF)
@ -208,7 +240,7 @@ option(LLVM_USE_OPROFILE
# If enabled, verify we are on a platform that supports oprofile.
if( LLVM_USE_OPROFILE )
if( NOT CMAKE_SYSTEM_NAME MATCHES "Linux" )
message(FATAL_ERROR "OProfile support is available on Linux only.")
message(FATAL_ERROR "OProfile support is available on Linux only.")
endif( NOT CMAKE_SYSTEM_NAME MATCHES "Linux" )
endif( LLVM_USE_OPROFILE )
@ -218,6 +250,9 @@ set(LLVM_USE_SANITIZER "" CACHE STRING
option(LLVM_USE_SPLIT_DWARF
"Use -gsplit-dwarf when compiling llvm." OFF)
option(WITH_POLLY "Build LLVM with Polly" ON)
option(LINK_POLLY_INTO_TOOLS "Static link Polly into tools" OFF)
# Define an option controlling whether we should build for 32-bit on 64-bit
# platforms, where supported.
if( CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32 )
@ -246,6 +281,8 @@ option(LLVM_INCLUDE_TOOLS "Generate build targets for the LLVM tools." ON)
option(LLVM_BUILD_TOOLS
"Build the LLVM tools. If OFF, just generate build targets." ON)
option(LLVM_INCLUDE_UTILS "Generate build targets for the LLVM utils." ON)
option(LLVM_BUILD_RUNTIME
"Build the LLVM runtime libraries." ON)
option(LLVM_BUILD_EXAMPLES
@ -258,7 +295,11 @@ option(LLVM_INCLUDE_TESTS "Generate build targets for the LLVM unit tests." ON)
option (LLVM_BUILD_DOCS "Build the llvm documentation." OFF)
option (LLVM_INCLUDE_DOCS "Generate build targets for llvm documentation." ON)
option (LLVM_ENABLE_DOXYGEN "Use doxygen to generate llvm documentation." OFF)
option (LLVM_ENABLE_DOXYGEN "Use doxygen to generate llvm API documentation." OFF)
option (LLVM_ENABLE_SPHINX "Use Sphinx to generate llvm documentation." OFF)
option (LLVM_BUILD_EXTERNAL_COMPILER_RT
"Build compiler-rt as an external project." OFF)
# All options referred to from HandleLLVMOptions have to be specified
# BEFORE this include, otherwise options will not be correctly set on
@ -380,39 +421,53 @@ endforeach(t)
# include various classes of targets.
configure_file(
${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/AsmPrinters.def.in
${LLVM_BINARY_DIR}/include/llvm/Config/AsmPrinters.def
${LLVM_INCLUDE_DIR}/llvm/Config/AsmPrinters.def
)
configure_file(
${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/AsmParsers.def.in
${LLVM_BINARY_DIR}/include/llvm/Config/AsmParsers.def
${LLVM_INCLUDE_DIR}/llvm/Config/AsmParsers.def
)
configure_file(
${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/Disassemblers.def.in
${LLVM_BINARY_DIR}/include/llvm/Config/Disassemblers.def
${LLVM_INCLUDE_DIR}/llvm/Config/Disassemblers.def
)
configure_file(
${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/Targets.def.in
${LLVM_BINARY_DIR}/include/llvm/Config/Targets.def
${LLVM_INCLUDE_DIR}/llvm/Config/Targets.def
)
# Configure the three LLVM configuration header files.
configure_file(
${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/config.h.cmake
${LLVM_BINARY_DIR}/include/llvm/Config/config.h)
${LLVM_INCLUDE_DIR}/llvm/Config/config.h)
configure_file(
${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/llvm-config.h.cmake
${LLVM_BINARY_DIR}/include/llvm/Config/llvm-config.h)
${LLVM_INCLUDE_DIR}/llvm/Config/llvm-config.h)
configure_file(
${LLVM_MAIN_INCLUDE_DIR}/llvm/Support/DataTypes.h.cmake
${LLVM_BINARY_DIR}/include/llvm/Support/DataTypes.h)
${LLVM_INCLUDE_DIR}/llvm/Support/DataTypes.h)
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LLVM_TOOLS_BINARY_DIR} )
# They are not referenced. See set_output_directory().
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LLVM_BINARY_DIR}/bin )
set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LLVM_BINARY_DIR}/lib )
set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LLVM_BINARY_DIR}/lib )
set(CMAKE_BUILD_WITH_INSTALL_RPATH ON)
if (APPLE)
set(CMAKE_INSTALL_NAME_DIR "@rpath")
set(CMAKE_INSTALL_RPATH "@executable_path/../lib")
else(UNIX)
if(NOT DEFINED CMAKE_INSTALL_RPATH)
set(CMAKE_INSTALL_RPATH "\$ORIGIN/../lib")
if (${CMAKE_SYSTEM_NAME} MATCHES FreeBSD)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-z,origin")
endif()
endif(NOT DEFINED CMAKE_INSTALL_RPATH)
endif()
set(CMAKE_INCLUDE_CURRENT_DIR ON)
include_directories( ${LLVM_BINARY_DIR}/include ${LLVM_MAIN_INCLUDE_DIR})
include_directories( ${LLVM_INCLUDE_DIR} ${LLVM_MAIN_INCLUDE_DIR})
if( ${CMAKE_SYSTEM_NAME} MATCHES FreeBSD )
# On FreeBSD, /usr/local/* is not used by default. In order to build LLVM
@ -448,15 +503,32 @@ add_subdirectory(include/llvm)
add_subdirectory(lib)
add_subdirectory(utils/FileCheck)
add_subdirectory(utils/FileUpdate)
add_subdirectory(utils/count)
add_subdirectory(utils/not)
add_subdirectory(utils/llvm-lit)
add_subdirectory(utils/yaml-bench)
if( LLVM_INCLUDE_UTILS )
add_subdirectory(utils/FileCheck)
add_subdirectory(utils/PerfectShuffle)
add_subdirectory(utils/count)
add_subdirectory(utils/not)
add_subdirectory(utils/llvm-lit)
add_subdirectory(utils/yaml-bench)
else()
if ( LLVM_INCLUDE_TESTS )
message(FATAL_ERROR "Including tests when not building utils will not work.
Either set LLVM_INCLUDE_UTILS to On, or set LLVM_INCLDE_TESTS to Off.")
endif()
endif()
if(LLVM_INCLUDE_TESTS)
add_subdirectory(utils/unittest)
endif()
add_subdirectory(projects)
if(WITH_POLLY)
if(NOT EXISTS ${LLVM_MAIN_SRC_DIR}/tools/polly/CMakeLists.txt)
set(WITH_POLLY OFF)
endif()
endif(WITH_POLLY)
if( LLVM_INCLUDE_TOOLS )
add_subdirectory(tools)
endif()
@ -467,7 +539,6 @@ endif()
if( LLVM_INCLUDE_TESTS )
add_subdirectory(test)
add_subdirectory(utils/unittest)
add_subdirectory(unittests)
if (MSVC)
# This utility is used to prevent crashing tests from calling Dr. Watson on
@ -497,7 +568,7 @@ endif()
add_subdirectory(cmake/modules)
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
install(DIRECTORY include/
install(DIRECTORY include/llvm include/llvm-c
DESTINATION include
FILES_MATCHING
PATTERN "*.def"
@ -508,7 +579,7 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
PATTERN ".svn" EXCLUDE
)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/
install(DIRECTORY ${LLVM_INCLUDE_DIR}/llvm
DESTINATION include
FILES_MATCHING
PATTERN "*.def"
@ -517,16 +588,7 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
PATTERN "*.inc"
# Exclude include/llvm/CMakeFiles/intrinsics_gen.dir, matched by "*.def"
PATTERN "CMakeFiles" EXCLUDE
PATTERN "config.h" EXCLUDE
PATTERN ".svn" EXCLUDE
)
endif()
# Workaround for MSVS10 to avoid the Dialog Hell
# FIXME: This could be removed with future version of CMake.
if(MSVC_VERSION EQUAL 1600)
set(LLVM_SLN_FILENAME "${CMAKE_CURRENT_BINARY_DIR}/LLVM.sln")
if( EXISTS "${LLVM_SLN_FILENAME}" )
file(APPEND "${LLVM_SLN_FILENAME}" "\n# This should be regenerated!\n")
endif()
endif()

View File

@ -29,6 +29,10 @@ N: Evan Cheng
E: evan.cheng@apple.com
D: ARM target, parts of code generator not covered by someone else
N: Renato Golin
E: renato.golin@linaro.org
D: ARM Linux support
N: Eric Christopher
E: echristo@gmail.com
D: Debug Information, autotools/configure/make build, inline assembly
@ -45,7 +49,7 @@ D: Hexagon Backend
N: Hal Finkel
E: hfinkel@anl.gov
D: BBVectorize and the PowerPC target
D: BBVectorize, the loop reroller and the PowerPC target
N: Venkatraman Govindaraju
E: venkatra@cs.wisc.edu
@ -58,15 +62,16 @@ N: James Grosbach
E: grosbach@apple.com
D: MC layer
N: Howard Hinnant
N: Marshall Clow
E: mclow.lists@gmail.com
D: libc++
N: Justin Holewinski
E: jholewinski@nvidia.com
D: NVPTX Target (lib/Target/NVPTX/*)
N: Andy Kaylor
E: andrew.kaylor@intel.com
N: Lang Hames
E: lhames@gmail.com
D: MCJIT, RuntimeDyld and JIT event listeners
N: Galina Kistanova
@ -91,7 +96,7 @@ W: http://nondot.org/~sabre/
D: Everything not covered by someone else
N: Tim Northover
E: Tim.Northover@arm.com
E: t.p.northover@gmail.com
D: AArch64 backend
N: Jakob Olesen

View File

@ -107,6 +107,10 @@ N: Rafael Avila de Espindola
E: rafael.espindola@gmail.com
D: The ARM backend
N: Dave Estes
E: cestes@codeaurora.org
D: AArch64 machine description for Cortex-A53
N: Alkis Evlogimenos
E: alkis@evlogimenos.com
D: Linear scan register allocator, many codegen improvements, Java frontend
@ -132,6 +136,7 @@ W: http://www-src.lip6.fr/homepages/Nicolas.Geoffray/
D: PPC backend fixes for Linux
N: Louis Gerbarg
E: lgg@apple.com
D: Portions of the PowerPC backend
N: Saem Ghani
@ -161,10 +166,12 @@ D: Improvements for space efficiency
N: James Grosbach
E: grosbach@apple.com
I: grosbach
D: SjLj exception handling support
D: General fixes and improvements for the ARM back-end
D: MCJIT
D: ARM integrated assembler and assembly parser
D: Led effort for the backend formerly known as ARM64
N: Lang Hames
E: lhames@gmail.com
@ -256,7 +263,7 @@ E: sylvestre@debian.org
W: http://sylvestre.ledru.info/
W: http://llvm.org/apt/
D: Debian and Ubuntu packaging
D: Continous integration with jenkins
D: Continuous integration with jenkins
N: Andrew Lenharth
E: alenhar2@cs.uiuc.edu
@ -338,6 +345,10 @@ D: LTO tool, PassManager rewrite, Loop Pass Manager, Loop Rotate
D: GCC PCH Integration (llvm-gcc), llvm-gcc improvements
D: Optimizer improvements, Loop Index Split
N: Ana Pazos
E: apazos@codeaurora.org
D: Fixes and improvements to the AArch64 backend
N: Wesley Peck
E: peckw@wesleypeck.com
W: http://wesleypeck.com/
@ -367,8 +378,10 @@ D: ARM calling conventions rewrite, hard float support
N: Chad Rosier
E: mcrosier@codeaurora.org
D: ARM fast-isel improvements
D: Performance monitoring
I: mcrosier
D: AArch64 fast instruction selection pass
D: Fixes and improvements to the ARM fast-isel pass
D: Fixes and improvements to the AArch64 backend
N: Nadav Rotem
E: nrotem@apple.com

View File

@ -4,7 +4,7 @@ LLVM Release License
University of Illinois/NCSA
Open Source License
Copyright (c) 2003-2013 University of Illinois at Urbana-Champaign.
Copyright (c) 2003-2014 University of Illinois at Urbana-Champaign.
All rights reserved.
Developed by:
@ -63,7 +63,6 @@ Program Directory
------- ---------
Autoconf llvm/autoconf
llvm/projects/ModuleMaker/autoconf
llvm/projects/sample/autoconf
Google Test llvm/utils/unittest/googletest
OpenBSD regex llvm/lib/Support/{reg*, COPYRIGHT.regex}
pyyaml tests llvm/test/YAMLParser/{*.data, LICENSE.TXT}

View File

@ -15,7 +15,7 @@ LEVEL := .
# 3. Build IR, which builds the Intrinsics.inc file used by libs.
# 4. Build libs, which are needed by llvm-config.
# 5. Build llvm-config, which determines inter-lib dependencies for tools.
# 6. Build tools and docs.
# 6. Build tools, docs, and cmake modules.
#
# When cross-compiling, there are some things (tablegen) that need to
# be build for the build system first.
@ -31,7 +31,7 @@ ifeq ($(BUILD_DIRS_ONLY),1)
OPTIONAL_DIRS := tools/clang/utils/TableGen
else
DIRS := lib/Support lib/TableGen utils lib/IR lib tools/llvm-shlib \
tools/llvm-config tools docs unittests
tools/llvm-config tools docs cmake unittests
OPTIONAL_DIRS := projects bindings
endif
@ -112,11 +112,20 @@ cross-compile-build-tools:
cd BuildTools ; \
unset CFLAGS ; \
unset CXXFLAGS ; \
AR=$(BUILD_AR) ; \
AS=$(BUILD_AS) ; \
LD=$(BUILD_LD) ; \
CC=$(BUILD_CC) ; \
CXX=$(BUILD_CXX) ; \
unset SDKROOT ; \
unset UNIVERSAL_SDK_PATH ; \
configure_opts= ; \
if test "$(ENABLE_LIBCPP)" -ne 0 ; then \
configure_opts="$$configure_opts --enable-libcpp"; \
fi; \
$(PROJ_SRC_DIR)/configure --build=$(BUILD_TRIPLE) \
--host=$(BUILD_TRIPLE) --target=$(BUILD_TRIPLE) \
--disable-polly ; \
--disable-polly $$configure_opts; \
cd .. ; \
fi; \
($(MAKE) -C BuildTools \
@ -126,6 +135,7 @@ cross-compile-build-tools:
SDKROOT= \
TARGET_NATIVE_ARCH="$(TARGET_NATIVE_ARCH)" \
TARGETS_TO_BUILD="$(TARGETS_TO_BUILD)" \
TARGET_LIBS="$(LIBS)" \
ENABLE_OPTIMIZED=$(ENABLE_OPTIMIZED) \
ENABLE_PROFILING=$(ENABLE_PROFILING) \
ENABLE_COVERAGE=$(ENABLE_COVERAGE) \

View File

@ -122,6 +122,7 @@ HOST_ARCH=@HOST_ARCH@
# Target hardware architecture
ARCH=@ARCH@
TARGET_NATIVE_ARCH := $(ARCH)
LLVM_NATIVE_ARCH := @LLVM_NATIVE_ARCH@
# Indicates, whether we're cross-compiling LLVM or not
LLVM_CROSS_COMPILING=@LLVM_CROSS_COMPILING@
@ -211,13 +212,22 @@ POD2MAN := @POD2MAN@
PDFROFF := @PDFROFF@
ZIP := @ZIP@
HAVE_LIBZ := @HAVE_LIBZ@
HAVE_DLOPEN := @HAVE_DLOPEN@
HAVE_PTHREAD := @HAVE_PTHREAD@
HAVE_TERMINFO := @HAVE_TERMINFO@
LIBS := @LIBS@
# Targets that are possible to build
ALL_TARGETS := @ALL_TARGETS@
# Targets that we should build
TARGETS_TO_BUILD=@TARGETS_TO_BUILD@
# Targets supporting JIT
TARGETS_WITH_JIT := @TARGETS_WITH_JIT@
# Path to directory where object files should be stored during a build.
# Set OBJ_ROOT to "." if you do not want to use a separate place for
# object files.
@ -236,24 +246,28 @@ RDYNAMIC := @RDYNAMIC@
#ENABLE_LIBCPP = 0
ENABLE_LIBCPP = @ENABLE_LIBCPP@
# When ENABLE_CXX11 is enabled, LLVM uses c++11 mode by default to build.
ENABLE_CXX11 = @ENABLE_CXX11@
# When ENABLE_CXX1Y is enabled, LLVM uses c++1y mode by default to build.
# Otherwise it uses the baseline c++11.
ENABLE_CXX1Y = @ENABLE_CXX1Y@
# When ENABLE_SPLIT_DWARF is enabled, LLVM uses -gfission to build in debug mode.
ENABLE_SPLIT_DWARF = @ENABLE_SPLIT_DWARF@
# When enabled, clang will have plugin support.
CLANG_PLUGIN_SUPPORT = @CLANG_PLUGIN_SUPPORT@
# When ENABLE_CLANG_ARCMT is enabled, clang will have ARCMigrationTool.
ENABLE_CLANG_ARCMT = @ENABLE_CLANG_ARCMT@
# When ENABLE_CLANG_REWRITER is enabled, clang will have Rewriter.
ENABLE_CLANG_REWRITER = @ENABLE_CLANG_REWRITER@
# When ENABLE_CLANG_STATIC_ANALYZER is enabled, clang will have StaticAnalyzer.
ENABLE_CLANG_STATIC_ANALYZER = @ENABLE_CLANG_STATIC_ANALYZER@
# When ENABLE_WERROR is enabled, we'll pass -Werror on the command line
ENABLE_WERROR = @ENABLE_WERROR@
# When ENABLE_TERMINFO is enabled, we use terminfo.
ENABLE_TERMINFO = @ENABLE_TERMINFO@
# When ENABLE_OPTIMIZED is enabled, LLVM code is optimized and output is put
# into the "Release" directories. Otherwise, LLVM code is not optimized and
# output is put in the "Debug" directories.
@ -334,9 +348,6 @@ ENABLE_TIMESTAMPS := @ENABLE_TIMESTAMPS@
# Enable JIT for this platform
TARGET_HAS_JIT = @TARGET_HAS_JIT@
# Environment variable to set to change the runtime shared library search path.
SHLIBPATH_VAR = @SHLIBPATH_VAR@
# Shared library extension for host platform.
SHLIBEXT = @SHLIBEXT@

View File

@ -78,6 +78,12 @@ LLVMBuildTool := $(PROJ_SRC_ROOT)/utils/llvm-build/llvm-build
# The files we are going to generate using llvm-build.
LLVMBuildMakeFrag := $(PROJ_OBJ_ROOT)/Makefile.llvmbuild
LLVMBuildCMakeFrag := $(PROJ_OBJ_ROOT)/LLVMBuild.cmake
LLVMBuildCMakeExportsFrag := $(PROJ_OBJ_ROOT)/cmake/modules/LLVMBuildExports.cmake
LLVMBuildMakeFrags := \
$(LLVMBuildMakeFrag) \
$(LLVMBuildCMakeFrag) \
$(LLVMBuildCMakeExportsFrag)
LLVMConfigLibraryDependenciesInc := \
$(PROJ_OBJ_ROOT)/tools/llvm-config/LibraryDependencies.inc
@ -94,18 +100,20 @@ endif
#
# We include a dependency on this Makefile to ensure that changes to the
# generation command get picked up.
$(LLVMBuildMakeFrag): $(PROJ_SRC_ROOT)/Makefile.rules \
$(PROJ_OBJ_ROOT)/Makefile.config
$(LLVMBuildMakeFrags): $(PROJ_SRC_ROOT)/Makefile.rules \
$(PROJ_OBJ_ROOT)/Makefile.config
$(Echo) Constructing LLVMBuild project information.
$(Verb)$(PYTHON) $(LLVMBuildTool) \
--native-target "$(TARGET_NATIVE_ARCH)" \
--enable-targets "$(TARGETS_TO_BUILD)" \
--enable-optional-components "$(OPTIONAL_COMPONENTS)" \
--write-library-table $(LLVMConfigLibraryDependenciesInc) \
--write-make-fragment $(LLVMBuildMakeFrag)
--write-make-fragment $(LLVMBuildMakeFrag) \
--write-cmake-fragment $(LLVMBuildCMakeFrag) \
--write-cmake-exports-fragment $(LLVMBuildCMakeExportsFrag)
# For completeness, let Make know how the extra files are generated.
$(LLVMConfigLibraryDependenciesInc): $(LLVMBuildMakeFrag)
$(LLVMConfigLibraryDependenciesInc): $(LLVMBuildMakeFrags)
# Include the generated Makefile fragment.
#
@ -120,7 +128,7 @@ LLVMBUILD_INCLUDE_DEPENDENCIES := 1
# Clean the generated makefile fragment at the top-level.
clean-local::
-$(Verb) $(RM) -f $(LLVMBuildMakeFrag)
-$(Verb) $(RM) -f $(LLVMBuildMakeFrags)
endif
-include $(LLVMBuildMakeFrag)
@ -311,8 +319,16 @@ ifeq ($(ENABLE_LIBCPP),1)
LD.Flags += -stdlib=libc++
endif
ifeq ($(ENABLE_CXX11),1)
CXX.Flags += -std=c++11
ifeq ($(ENABLE_CXX1Y),1)
CXX.Flags += -std=c++1y
else
ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
# MinGW and Cygwin are a bit stricter and lack things like
# 'strdup', 'stricmp', etc in c++11 mode.
CXX.Flags += -std=gnu++11
else
CXX.Flags += -std=c++11
endif
endif
ifeq ($(ENABLE_WERROR),1)
@ -361,6 +377,7 @@ ifeq ($(ENABLE_COVERAGE),1)
BuildMode := $(BuildMode)+Coverage
CXX.Flags += -ftest-coverage -fprofile-arcs
C.Flags += -ftest-coverage -fprofile-arcs
LD.Flags += -ftest-coverage -fprofile-arcs
endif
# If DISABLE_ASSERTIONS=1 is specified (make command line or configured),
@ -581,6 +598,8 @@ ifdef SHARED_LIBRARY
ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
ifneq ($(HOST_OS),Darwin)
LD.Flags += $(RPATH) -Wl,'$$ORIGIN'
else
LD.Flags += -Wl,-install_name -Wl,"@rpath/lib$(LIBRARYNAME)$(SHLIBEXT)"
endif
endif
endif
@ -608,6 +627,24 @@ ifndef KEEP_SYMBOLS
Install.StripFlag += -s
endif
# By default, strip dead symbols at link time
ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
ifneq ($(HOST_OS),Darwin)
ifneq ($(HOST_ARCH),Mips)
CXX.Flags += -ffunction-sections -fdata-sections
endif
endif
endif
ifndef NO_DEAD_STRIP
ifeq ($(HOST_OS),Darwin)
LD.Flags += -Wl,-dead_strip
else
ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
LD.Flags += -Wl,--gc-sections
endif
endif
endif
# Adjust linker flags for building an executable
ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
ifndef TOOL_NO_EXPORTS
@ -651,13 +688,13 @@ ifeq ($(HOST_OS),HP-UX)
CompileCommonOpts := -D_REENTRANT -D_HPUX_SOURCE
endif
# If we are building a universal binary on Mac OS/X, pass extra options. This
# If we are building a universal binary on Mac OS X, pass extra options. This
# is useful to people that want to link the LLVM libraries into their universal
# apps.
#
# The following can be optionally specified:
# UNIVERSAL_SDK_PATH variable can be specified as a path to the SDK to use.
# For Mac OS/X 10.4 Intel machines, the traditional one is:
# For Mac OS X 10.4 Intel machines, the traditional one is:
# UNIVERSAL_SDK_PATH=/Developer/SDKs/MacOSX10.4u.sdk/
# UNIVERSAL_ARCH can be optionally specified to be a list of architectures
# to build for, e.g. UNIVERSAL_ARCH="i386 ppc ppc64". This defaults to
@ -1027,8 +1064,9 @@ ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
LLVMLibsOptions += -Wl,--enable-auto-import,--enable-runtime-pseudo-reloc \
-L $(SharedLibDir)
endif
LLVMLibsOptions += -lLLVM-$(LLVMVersion)
LLVMLibsPaths += $(SharedLibDir)/$(SharedPrefix)LLVM-$(LLVMVersion)$(SHLIBEXT)
LLVM_SO_NAME = LLVM-$(LLVM_VERSION_MAJOR).$(LLVM_VERSION_MINOR)$(LLVM_VERSION_SUFFIX)
LLVMLibsOptions += -l$(LLVM_SO_NAME)
LLVMLibsPaths += $(SharedLibDir)/$(SharedPrefix)$(LLVM_SO_NAME)$(SHLIBEXT)
else
ifndef NO_LLVM_CONFIG
@ -1144,7 +1182,12 @@ LibName.O := $(LibDir)/$(LIBRARYNAME).o
#---------------------------------------------------------
ifdef SHARED_LIBRARY
all-local:: $(LibName.SO)
all-local:: $(AliasName.SO)
$(AliasName.SO): $(LibName.SO)
ifdef SHARED_ALIAS
$(Verb) $(AliasTool) $(BaseLibName.SO) $(AliasName.SO)
endif
ifdef EXPORTED_SYMBOL_FILE
$(LibName.SO): $(NativeExportsFile)
@ -1196,12 +1239,15 @@ $(DestSharedLib): $(LibName.SO) $(DestSharedLibDir)
$(Verb) $(INSTALL) $(LibName.SO) $(DestSharedLib)
ifdef SHARED_ALIAS
$(Echo) Creating alias from $(DestSharedLib) to $(DestSharedAlias)
$(Verb) $(AliasTool) $(DestSharedLib) $(DestSharedAlias)
$(Verb) $(AliasTool) $(BaseLibName.SO) $(DestSharedAlias)
endif
uninstall-local::
$(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib)
-$(Verb) $(RM) -f $(DestSharedLib)
ifdef SHARED_ALIAS
-$(Verb) $(RM) -f $(DestSharedAlias)
endif
endif
endif
@ -1677,8 +1723,14 @@ $(ObjDir)/%GenDFAPacketizer.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN)
$(Echo) "Building $(<F) DFA packetizer tables with tblgen"
$(Verb) $(LLVMTableGen) -gen-dfa-packetizer -o $(call SYSPATH, $@) $<
# Dump all the records to <target>.td.expanded. This is useful for debugging.
$(TARGET:%=%.td.expanded): \
%.td.expanded : %.td $(LLVM_TBLGEN) $(TDFiles)
$(Echo) "Building a fully expanded version of $(<F)"
$(Verb) $(LLVMTableGen) -o $(call SYSPATH, $@) $<
clean-local::
-$(Verb) $(RM) -f $(INCFiles)
-$(Verb) $(RM) -f $(INCFiles) $(TARGET).td.expanded
endif # TARGET

View File

@ -15,4 +15,3 @@ documentation setup.
If you're writing a package for LLVM, see docs/Packaging.rst for our
suggestions.

View File

@ -17,7 +17,6 @@ clean() {
want_autoconf_version='2\.60'
want_autoheader_version=$want_autoconf_version
want_aclocal_version='1\.9\.6'
want_libtool_version='1\.5\.22'
### END NOTE #########################################################
outfile=configure
@ -26,7 +25,6 @@ configfile=configure.ac
want_autoconf_version_clean=$(clean $want_autoconf_version)
want_autoheader_version_clean=$(clean $want_autoheader_version)
want_aclocal_version_clean=$(clean $want_aclocal_version)
want_libtool_version_clean=$(clean $want_libtool_version)
test -d autoconf && test -f autoconf/$configfile && cd autoconf
test -f $configfile || die "Can't find 'autoconf' dir; please cd into it first"
@ -36,8 +34,6 @@ aclocal --version | grep '^aclocal.*'$want_aclocal_version > /dev/null
test $? -eq 0 || die "Your aclocal was not detected as being $want_aclocal_version_clean"
autoheader --version | grep '^autoheader.*'$want_autoheader_version > /dev/null
test $? -eq 0 || die "Your autoheader was not detected as being $want_autoheader_version_clean"
libtool --version | grep $want_libtool_version > /dev/null
test $? -eq 0 || die "Your libtool was not detected as being $want_libtool_version_clean"
echo ""
echo "### NOTE: ############################################################"
echo "### If you get *any* warnings from autoconf below you MUST fix the"

View File

@ -1,38 +1,3 @@
Upgrading Libtool
===============================================================================
If you are in the mood to upgrade libtool, you must do the following:
1. Get the new version of libtool and put it in <SRC>
2. configure/build/install libtool with --prefix=<PFX>
3. Copy <SRC>/ltdl.m4 to llvm/autoconf/m4
4. Copy <PFX>/share/aclocal/libtool.m4 to llvm/autoconf/m4/libtool.m4
5. Copy <PFX>/share/libtool/ltmain.sh to llvm/autoconf/ltmain.sh
6. Copy <PFX>/share/libtool/libltdl/ltdl.c to llvm/lib/System
7. Copy <PFX>/share/libtool/libltdl/ltdl.h to llvm/lib/System
8. Edit the ltdl.h file to #include "llvm/Config/config.h" at the very top. You
might also need to resolve some compiler warnings (typically about
comparison of signed vs. unsigned values). But, you won't find out about
those until you build LLVM (step 13).
9. Edit the llvm/autoconf/m4/libtool.m4 file so that:
a) in AC_PROB_LIBTOOL macro, the value of LIBTOOL is set to
$(top_builddir)/mklib, not $(top_builddir)/libtool
b) in AC_LIBTOOL_SETUP macro, the variable default_ofile is set to
"mklib" instead of "libtool"
c) s/AC_ENABLE_SHARED_DEFAULT/enable_shared_default/g
d) s/AC_ENABLE_STATIC_DEFAULT/enable_static_default/g
e) s/AC_ENABLE_FAST_INSTALL_DEFAULT/enable_fast_install_default/g
10. Run "autoupdate libtool.m4 ltdl.m4" in the llvm/autoconf/m4 directory.
This should correctly update the macro definitions in the libtool m4
files to match the version of autoconf that LLVM uses. This converts
AC_HELP_STRING to AS_HELP_STRING and AC_TRY_LINK to AC_LINK_IFELSE, amongst
other things. You may need to manually adjust the files.
11. Run AutoRegen.sh to get the new macros into configure script
12. If there are any warnings from AutoRegen.sh, go to step 9.
13. Rebuild LLVM, making sure it reconfigures
14. Test the JIT which uses libltdl
15. If it all works, only THEN commit the changes.
Upgrading autoconf
===============================================================================

View File

@ -864,6 +864,9 @@ EOF
i*86:Minix:*:*)
echo ${UNAME_MACHINE}-pc-minix
exit ;;
aarch64*:Linux:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
alpha:Linux:*:*)
case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
EV5) UNAME_MACHINE=alphaev5 ;;

View File

@ -32,11 +32,11 @@ dnl===-----------------------------------------------------------------------===
dnl Initialize autoconf and define the package name, version number and
dnl address for reporting bugs.
AC_INIT([LLVM],[3.4.1],[http://llvm.org/bugs/])
AC_INIT([LLVM],[3.5.0],[http://llvm.org/bugs/])
LLVM_VERSION_MAJOR=3
LLVM_VERSION_MINOR=4
LLVM_VERSION_PATCH=1
LLVM_VERSION_MINOR=5
LLVM_VERSION_PATCH=0
LLVM_VERSION_SUFFIX=
AC_DEFINE_UNQUOTED([LLVM_VERSION_MAJOR], $LLVM_VERSION_MAJOR, [Major version of the LLVM API])
@ -50,8 +50,8 @@ AC_SUBST([LLVM_VERSION_SUFFIX])
dnl Provide a copyright substitution and ensure the copyright notice is included
dnl in the output of --version option of the generated configure script.
AC_SUBST(LLVM_COPYRIGHT,["Copyright (c) 2003-2013 University of Illinois at Urbana-Champaign."])
AC_COPYRIGHT([Copyright (c) 2003-2013 University of Illinois at Urbana-Champaign.])
AC_SUBST(LLVM_COPYRIGHT,["Copyright (c) 2003-2014 University of Illinois at Urbana-Champaign."])
AC_COPYRIGHT([Copyright (c) 2003-2014 University of Illinois at Urbana-Champaign.])
dnl Indicate that we require autoconf 2.60 or later.
AC_PREREQ(2.60)
@ -79,8 +79,8 @@ dnl instead of the autoconf default (for example, '-g -O2' for CC=gcc).
dnl We need to check for the compiler up here to avoid anything else
dnl starting with a different one.
AC_PROG_CC(clang llvm-gcc gcc)
AC_PROG_CXX(clang++ llvm-g++ g++)
AC_PROG_CC(clang gcc)
AC_PROG_CXX(clang++ g++)
AC_PROG_CPP
dnl If CXX is Clang, check that it can find and parse C++ standard library
@ -109,6 +109,25 @@ if test "$CXX" = "clang++" ; then
AC_LANG_POP([C++])
fi
dnl Set up variables that track whether the host compiler is GCC or Clang where
dnl we can effectively sanity check them. We don't try to sanity check all the
dnl other possible compilers.
AC_MSG_CHECKING([whether GCC or Clang is our host compiler])
AC_LANG_PUSH([C++])
llvm_cv_cxx_compiler=unknown
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#if ! __clang__
#error
#endif
]])],
llvm_cv_cxx_compiler=clang,
[AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#if ! __GNUC__
#error
#endif
]])],
llvm_cv_cxx_compiler=gcc, [])])
AC_LANG_POP([C++])
AC_MSG_RESULT([${llvm_cv_cxx_compiler}])
dnl Configure all of the projects present in our source tree. While we could
dnl just AC_CONFIG_SUBDIRS on the set of directories in projects that have a
dnl configure script, that usage of the AC_CONFIG_SUBDIRS macro is deprecated.
@ -122,11 +141,6 @@ dnl created before running the configure scripts of projects that depend upon
dnl them.
dnl
dnl Several projects use llvm-gcc, so configure that first
if test -d ${srcdir}/projects/llvm-gcc ; then
AC_CONFIG_SUBDIRS([projects/llvm-gcc])
fi
dnl Several projects use the LLVM test suite, so configure it next.
if test -d ${srcdir}/projects/test-suite ; then
AC_CONFIG_SUBDIRS([projects/test-suite])
@ -152,16 +166,8 @@ for i in `ls ${srcdir}/projects`
do
if test -d ${srcdir}/projects/${i} ; then
case ${i} in
sample) AC_CONFIG_SUBDIRS([projects/sample]) ;;
privbracket) AC_CONFIG_SUBDIRS([projects/privbracket]) ;;
llvm-stacker) AC_CONFIG_SUBDIRS([projects/llvm-stacker]) ;;
llvm-reopt) AC_CONFIG_SUBDIRS([projects/llvm-reopt]);;
llvm-java) AC_CONFIG_SUBDIRS([projects/llvm-java]) ;;
llvm-tv) AC_CONFIG_SUBDIRS([projects/llvm-tv]) ;;
safecode) AC_CONFIG_SUBDIRS([projects/safecode]) ;;
llvm-kernel) AC_CONFIG_SUBDIRS([projects/llvm-kernel]) ;;
compiler-rt) ;;
llvm-gcc) ;;
test-suite) ;;
llvm-test) ;;
poolalloc) ;;
@ -413,6 +419,7 @@ AC_CACHE_CHECK([target architecture],[llvm_cv_target_arch],
amd64-* | x86_64-*) llvm_cv_target_arch="x86_64" ;;
sparc*-*) llvm_cv_target_arch="Sparc" ;;
powerpc*-*) llvm_cv_target_arch="PowerPC" ;;
arm64*-*) llvm_cv_target_arch="AArch64" ;;
arm*-*) llvm_cv_target_arch="ARM" ;;
aarch64*-*) llvm_cv_target_arch="AArch64" ;;
mips-* | mips64-*) llvm_cv_target_arch="Mips" ;;
@ -438,6 +445,7 @@ esac
dnl Define a substitution, ARCH, for the target architecture
AC_SUBST(ARCH,$llvm_cv_target_arch)
AC_SUBST(LLVM_NATIVE_ARCH,$LLVM_NATIVE_ARCH)
dnl Determine what our host architecture.
dnl This will allow MCJIT regress tests runs only for supported
@ -447,6 +455,7 @@ case $host in
amd64-* | x86_64-*) host_arch="x86_64" ;;
sparc*-*) host_arch="Sparc" ;;
powerpc*-*) host_arch="PowerPC" ;;
arm64*-*) host_arch="AArch64" ;;
arm*-*) host_arch="ARM" ;;
aarch64*-*) host_arch="AArch64" ;;
mips-* | mips64-*) host_arch="Mips" ;;
@ -464,9 +473,6 @@ fi
AC_SUBST(HOST_ARCH,$host_arch)
dnl Check for the endianness of the target
AC_C_BIGENDIAN(AC_SUBST([ENDIAN],[big]),AC_SUBST([ENDIAN],[little]))
dnl Check for build platform executable suffix if we're cross-compiling
if test "$cross_compiling" = yes; then
AC_SUBST(LLVM_CROSS_COMPILING, [1])
@ -516,19 +522,100 @@ case "$enableval" in
*) AC_MSG_ERROR([Invalid setting for --enable-libcpp. Use "yes" or "no"]) ;;
esac
dnl --enable-cxx11 : check whether or not to use -std=c++11 on the command line
AC_ARG_ENABLE(cxx11,
AS_HELP_STRING([--enable-cxx11],
[Use c++11 if available (default is NO)]),,
dnl Check both GCC and Clang for sufficiently modern versions. These checks can
dnl be bypassed by passing a flag if necessary on a platform. We have to do
dnl these checks here so that we have the configuration of the standard C++
dnl library finished.
AC_ARG_ENABLE(compiler-version-checks,
AS_HELP_STRING([--enable-compiler-version-checks],
[Check the version of the host compiler (default is YES)]),,
enableval=default)
case "$enableval" in
yes) AC_SUBST(ENABLE_CXX11,[1]) ;;
no) AC_SUBST(ENABLE_CXX11,[0]) ;;
default) AC_SUBST(ENABLE_CXX11,[0]);;
*) AC_MSG_ERROR([Invalid setting for --enable-cxx11. Use "yes" or "no"]) ;;
no)
;;
yes|default)
AC_LANG_PUSH([C++])
case "$llvm_cv_cxx_compiler" in
clang)
AC_MSG_CHECKING([whether Clang is new enough])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
#if __clang_major__ < 3 || (__clang_major__ == 3 && __clang_minor__ < 1)
#error This version of Clang is too old to build LLVM
#endif
]])],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])
AC_MSG_ERROR([
The selected Clang compiler is not new enough to build LLVM. Please upgrade to
Clang 3.1. You may pass --disable-compiler-version-checks to configure to
bypass these sanity checks.])])
dnl Note that libstdc++4.6 is known broken for C++11 builds. The errors
dnl are sometimes deeply confusing though. Here we test for an obvious
dnl incomplete feature in 4.6's standard library that was completed in
dnl 4.7's. We also have to disable this test if 'ENABLE_LIBCPP' is set
dnl because the enable flags don't actually fix CXXFLAGS, they rely on
dnl that happening in the Makefile.
if test "$ENABLE_LIBCPP" -eq 0 ; then
AC_MSG_CHECKING([whether Clang will select a modern C++ standard library])
llvm_cv_old_cxxflags="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS -std=c++0x"
AC_LINK_IFELSE([AC_LANG_SOURCE([[
#include <atomic>
std::atomic<float> x(0.0f);
int main() { return (float)x; }
]])],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])
AC_MSG_ERROR([
We detected a missing feature in the standard C++ library that was known to be
missing in libstdc++4.6 and implemented in libstdc++4.7. There are numerous
C++11 problems with 4.6's library, and we don't support GCCs or libstdc++ older
than 4.7. You will need to update your system and ensure Clang uses the newer
standard library.
If this error is incorrect or you need to force things to work, you may pass
'--disable-compiler-version-checks' to configure to bypass this test.])])
CXXFLAGS="$llvm_cv_old_cxxflags"
fi
;;
gcc)
AC_MSG_CHECKING([whether GCC is new enough])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 7)
#error This version of GCC is too old to build LLVM
#endif
]])],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])
AC_MSG_ERROR([
The selected GCC C++ compiler is not new enough to build LLVM. Please upgrade
to GCC 4.7. You may pass --disable-compiler-version-checks to configure to
bypass these sanity checks.])])
;;
unknown)
;;
esac
AC_LANG_POP([C++])
;;
*)
AC_MSG_ERROR([Invalid setting for --enable-compiler-version-checks. Use "yes" or "no"])
;;
esac
dnl --enable-fission : check whether or not to use -gsplit-dwarf on the command
dnl --enable-cxx1y : check whether or not to use -std=c++1y on the command line
AC_ARG_ENABLE(cxx1y,
AS_HELP_STRING([--enable-cxx1y],
[Use c++1y if available (default is NO)]),,
enableval=default)
case "$enableval" in
yes) AC_SUBST(ENABLE_CXX1Y,[1]) ;;
no) AC_SUBST(ENABLE_CXX1Y,[0]) ;;
default) AC_SUBST(ENABLE_CXX1Y,[0]);;
*) AC_MSG_ERROR([Invalid setting for --enable-cxx1y. Use "yes" or "no"]) ;;
esac
dnl --enable-split-dwarf : check whether or not to use -gsplit-dwarf on the command
dnl line
AC_ARG_ENABLE(split-dwarf,
AS_HELP_STRING([--enable-split-dwarf],
@ -555,6 +642,20 @@ case "$enableval" in
*) AC_MSG_ERROR([Invalid setting for --enable-clang-arcmt. Use "yes" or "no"]) ;;
esac
dnl --enable-clang-plugin-support: check whether to enable plugins in clang
clang_plugin_support="yes"
AC_ARG_ENABLE(clang-plugin-support,
AS_HELP_STRING([--enable-clang-plugin-support],
[Enable plugin support in clang (default is YES)]),
clang_plugin_support="$enableval",
enableval="yes")
case "$enableval" in
yes) AC_SUBST(CLANG_PLUGIN_SUPPORT,[1]) ;;
no) AC_SUBST(CLANG_PLUGIN_SUPPORT,[0]) ;;
default) AC_SUBST(CLANG_PLUGIN_SUPPORT,[1]);;
*) AC_MSG_ERROR([Invalid setting for --enable-clang-plugin-support. Use "yes" or "no"]) ;;
esac
dnl --enable-clang-static-analyzer: check whether to enable static-analyzer
clang_static_analyzer="yes"
AC_ARG_ENABLE(clang-static-analyzer,
@ -574,26 +675,6 @@ case "$enableval" in
*) AC_MSG_ERROR([Invalid setting for --enable-clang-static-analyzer. Use "yes" or "no"]) ;;
esac
dnl --enable-clang-rewriter: check whether to enable clang rewriter
AC_ARG_ENABLE(clang-rewriter,
AS_HELP_STRING([--enable-clang-rewriter],
[Enable building of clang rewriter (default is YES)]),,
enableval="yes")
case "$enableval" in
yes) AC_SUBST(ENABLE_CLANG_REWRITER,[1]) ;;
no)
if test ${clang_arcmt} != "no" ; then
AC_MSG_ERROR([Cannot enable clang ARC Migration Tool while disabling rewriter.])
fi
if test ${clang_static_analyzer} != "no" ; then
AC_MSG_ERROR([Cannot enable clang static analyzer while disabling rewriter.])
fi
AC_SUBST(ENABLE_CLANG_REWRITER,[0])
;;
default) AC_SUBST(ENABLE_CLANG_REWRITER,[1]);;
*) AC_MSG_ERROR([Invalid setting for --enable-clang-rewriter. Use "yes" or "no"]) ;;
esac
dnl --enable-optimized : check whether they want to do an optimized build:
AC_ARG_ENABLE(optimized, AS_HELP_STRING(
--enable-optimized,[Compile with optimizations enabled (default is NO)]),,enableval=$optimize)
@ -685,7 +766,6 @@ else
PowerPC) AC_SUBST(TARGET_HAS_JIT,1) ;;
x86_64) AC_SUBST(TARGET_HAS_JIT,1) ;;
ARM) AC_SUBST(TARGET_HAS_JIT,1) ;;
AArch64) AC_SUBST(TARGET_HAS_JIT,0) ;;
Mips) AC_SUBST(TARGET_HAS_JIT,1) ;;
XCore) AC_SUBST(TARGET_HAS_JIT,0) ;;
MSP430) AC_SUBST(TARGET_HAS_JIT,0) ;;
@ -696,6 +776,9 @@ else
esac
fi
TARGETS_WITH_JIT="ARM AArch64 Mips PowerPC SystemZ X86"
AC_SUBST(TARGETS_WITH_JIT,$TARGETS_WITH_JIT)
dnl Allow enablement of building and installing docs
AC_ARG_ENABLE(docs,
AS_HELP_STRING([--enable-docs],
@ -845,18 +928,22 @@ if test "$llvm_cv_enable_crash_overrides" = "yes" ; then
[Define to enable crash handling overrides])
fi
dnl List all possible targets
ALL_TARGETS="X86 Sparc PowerPC ARM AArch64 Mips XCore MSP430 CppBackend NVPTX Hexagon SystemZ R600"
AC_SUBST(ALL_TARGETS,$ALL_TARGETS)
dnl Allow specific targets to be specified for building (or not)
TARGETS_TO_BUILD=""
AC_ARG_ENABLE([targets],AS_HELP_STRING([--enable-targets],
[Build specific host targets: all or target1,target2,... Valid targets are:
host, x86, x86_64, sparc, powerpc, arm, aarch64, mips, hexagon,
host, x86, x86_64, sparc, powerpc, arm64, arm, aarch64, mips, hexagon,
xcore, msp430, nvptx, systemz, r600, and cpp (default=all)]),,
enableval=all)
if test "$enableval" = host-only ; then
enableval=host
fi
case "$enableval" in
all) TARGETS_TO_BUILD="X86 Sparc PowerPC AArch64 ARM Mips XCore MSP430 CppBackend NVPTX Hexagon SystemZ R600" ;;
all) TARGETS_TO_BUILD="$ALL_TARGETS" ;;
*)for a_target in `echo $enableval|sed -e 's/,/ /g' ` ; do
case "$a_target" in
x86) TARGETS_TO_BUILD="X86 $TARGETS_TO_BUILD" ;;
@ -864,6 +951,7 @@ case "$enableval" in
sparc) TARGETS_TO_BUILD="Sparc $TARGETS_TO_BUILD" ;;
powerpc) TARGETS_TO_BUILD="PowerPC $TARGETS_TO_BUILD" ;;
aarch64) TARGETS_TO_BUILD="AArch64 $TARGETS_TO_BUILD" ;;
arm64) TARGETS_TO_BUILD="AArch64 $TARGETS_TO_BUILD" ;;
arm) TARGETS_TO_BUILD="ARM $TARGETS_TO_BUILD" ;;
mips) TARGETS_TO_BUILD="Mips $TARGETS_TO_BUILD" ;;
mipsel) TARGETS_TO_BUILD="Mips $TARGETS_TO_BUILD" ;;
@ -1117,6 +1205,21 @@ AC_ARG_ENABLE(terminfo,AS_HELP_STRING(
*) AC_MSG_ERROR([Invalid setting for --enable-terminfo. Use "yes" or "no"]) ;;
esac],
llvm_cv_enable_terminfo="yes")
case "$llvm_cv_enable_terminfo" in
yes) AC_SUBST(ENABLE_TERMINFO,[1]) ;;
no) AC_SUBST(ENABLE_TERMINFO,[0]) ;;
esac
dnl --enable-libedit: check whether the user wants to turn off libedit.
AC_ARG_ENABLE(libedit,AS_HELP_STRING(
[--enable-libedit],
[Use libedit if available (default is YES)]),
[case "$enableval" in
yes) llvm_cv_enable_libedit="yes" ;;
no) llvm_cv_enable_libedit="no" ;;
*) AC_MSG_ERROR([Invalid setting for --enable-libedit. Use "yes" or "no"]) ;;
esac],
llvm_cv_enable_libedit="yes")
dnl --enable-libffi : check whether the user wants to turn off libffi:
AC_ARG_ENABLE(libffi,AS_HELP_STRING(
@ -1140,12 +1243,10 @@ dnl=== SECTION 4: Check for programs we need and that they are the right version
dnl===
dnl===-----------------------------------------------------------------------===
AC_PROG_NM
AC_SUBST(NM)
dnl Check for the tools that the makefiles require
AC_CHECK_GNU_MAKE
AC_PROG_LN_S
AC_PATH_PROG(NM, [nm], [nm])
AC_PATH_PROG(CMP, [cmp], [cmp])
AC_PATH_PROG(CP, [cp], [cp])
AC_PATH_PROG(DATE, [date], [date])
@ -1161,16 +1262,6 @@ AC_PATH_PROG(TAR, [tar], [gtar])
AC_PATH_PROG(BINPWD,[pwd], [pwd])
dnl Looking for misc. graph plotting software
AC_PATH_PROG(GRAPHVIZ, [Graphviz], [echo Graphviz])
if test "$GRAPHVIZ" != "echo Graphviz" ; then
AC_DEFINE([HAVE_GRAPHVIZ],[1],[Define if the Graphviz program is available])
dnl If we're targeting for mingw we should emit windows paths, not msys
if test "$llvm_cv_os_type" = "MingW" ; then
GRAPHVIZ=`echo $GRAPHVIZ | sed 's/^\/\([[A-Za-z]]\)\//\1:\//' `
fi
AC_DEFINE_UNQUOTED([LLVM_PATH_GRAPHVIZ],"$GRAPHVIZ${EXEEXT}",
[Define to path to Graphviz program if found or 'echo Graphviz' otherwise])
fi
AC_PATH_PROG(DOT, [dot], [echo dot])
if test "$DOT" != "echo dot" ; then
AC_DEFINE([HAVE_DOT],[1],[Define if the dot program is available])
@ -1181,76 +1272,6 @@ if test "$DOT" != "echo dot" ; then
AC_DEFINE_UNQUOTED([LLVM_PATH_DOT],"$DOT${EXEEXT}",
[Define to path to dot program if found or 'echo dot' otherwise])
fi
AC_PATH_PROG(FDP, [fdp], [echo fdp])
if test "$FDP" != "echo fdp" ; then
AC_DEFINE([HAVE_FDP],[1],[Define if the neat program is available])
dnl If we're targeting for mingw we should emit windows paths, not msys
if test "$llvm_cv_os_type" = "MingW" ; then
FDP=`echo $FDP | sed 's/^\/\([[A-Za-z]]\)\//\1:\//' `
fi
AC_DEFINE_UNQUOTED([LLVM_PATH_FDP],"$FDP${EXEEXT}",
[Define to path to fdp program if found or 'echo fdp' otherwise])
fi
AC_PATH_PROG(NEATO, [neato], [echo neato])
if test "$NEATO" != "echo neato" ; then
AC_DEFINE([HAVE_NEATO],[1],[Define if the neat program is available])
dnl If we're targeting for mingw we should emit windows paths, not msys
if test "$llvm_cv_os_type" = "MingW" ; then
NEATO=`echo $NEATO | sed 's/^\/\([[A-Za-z]]\)\//\1:\//' `
fi
AC_DEFINE_UNQUOTED([LLVM_PATH_NEATO],"$NEATO${EXEEXT}",
[Define to path to neato program if found or 'echo neato' otherwise])
fi
AC_PATH_PROG(TWOPI, [twopi], [echo twopi])
if test "$TWOPI" != "echo twopi" ; then
AC_DEFINE([HAVE_TWOPI],[1],[Define if the neat program is available])
dnl If we're targeting for mingw we should emit windows paths, not msys
if test "$llvm_cv_os_type" = "MingW" ; then
TWOPI=`echo $TWOPI | sed 's/^\/\([[A-Za-z]]\)\//\1:\//' `
fi
AC_DEFINE_UNQUOTED([LLVM_PATH_TWOPI],"$TWOPI${EXEEXT}",
[Define to path to twopi program if found or 'echo twopi' otherwise])
fi
AC_PATH_PROG(CIRCO, [circo], [echo circo])
if test "$CIRCO" != "echo circo" ; then
AC_DEFINE([HAVE_CIRCO],[1],[Define if the neat program is available])
dnl If we're targeting for mingw we should emit windows paths, not msys
if test "$llvm_cv_os_type" = "MingW" ; then
CIRCO=`echo $CIRCO | sed 's/^\/\([[A-Za-z]]\)\//\1:\//' `
fi
AC_DEFINE_UNQUOTED([LLVM_PATH_CIRCO],"$CIRCO${EXEEXT}",
[Define to path to circo program if found or 'echo circo' otherwise])
fi
AC_PATH_PROGS(GV, [gv gsview32], [echo gv])
if test "$GV" != "echo gv" ; then
AC_DEFINE([HAVE_GV],[1],[Define if the gv program is available])
dnl If we're targeting for mingw we should emit windows paths, not msys
if test "$llvm_cv_os_type" = "MingW" ; then
GV=`echo $GV | sed 's/^\/\([[A-Za-z]]\)\//\1:\//' `
fi
AC_DEFINE_UNQUOTED([LLVM_PATH_GV],"$GV${EXEEXT}",
[Define to path to gv program if found or 'echo gv' otherwise])
fi
AC_PATH_PROG(DOTTY, [dotty], [echo dotty])
if test "$DOTTY" != "echo dotty" ; then
AC_DEFINE([HAVE_DOTTY],[1],[Define if the dotty program is available])
dnl If we're targeting for mingw we should emit windows paths, not msys
if test "$llvm_cv_os_type" = "MingW" ; then
DOTTY=`echo $DOTTY | sed 's/^\/\([[A-Za-z]]\)\//\1:\//' `
fi
AC_DEFINE_UNQUOTED([LLVM_PATH_DOTTY],"$DOTTY${EXEEXT}",
[Define to path to dotty program if found or 'echo dotty' otherwise])
fi
AC_PATH_PROGS(XDOT, [xdot xdot.py], [echo xdot])
if test "$XDOT" != "echo xdot" ; then
AC_DEFINE([HAVE_XDOT],[1],[Define if the xdot program is available])
dnl If we're targeting for mingw we should emit windows paths, not msys
if test "$llvm_cv_os_type" = "MingW" ; then
XDOT=`echo $XDOT | sed 's/^\/\([[A-Za-z]]\)\//\1:\//' `
fi
AC_DEFINE_UNQUOTED([LLVM_PATH_XDOT],"$XDOT${EXEEXT}",
[Define to path to xdot program if found or 'echo xdot' otherwise])
fi
dnl Find the install program
AC_PROG_INSTALL
@ -1291,11 +1312,15 @@ AC_LINK_EXPORT_DYNAMIC
dnl Determine whether the linker supports the --version-script option.
AC_LINK_VERSION_SCRIPT
dnl Check for libtool and the library that has dlopen function (which must come
dnl before the AC_PROG_LIBTOOL check in order to enable dlopening libraries with
dnl libtool).
AC_LIBTOOL_DLOPEN
AC_LIB_LTDL
AC_CHECK_HEADERS([errno.h])
case "$llvm_cv_os_type" in
Cygwin|MingW|Win32) llvm_shlib_ext=.dll ;;
Darwin) llvm_shlib_ext=.dylib ;;
*) llvm_shlib_ext=.so ;;
esac
AC_DEFINE_UNQUOTED([LTDL_SHLIB_EXT], ["$llvm_shlib_ext"], [The shared library extension])
AC_MSG_CHECKING([tool compatibility])
@ -1417,7 +1442,7 @@ if test "$llvm_cv_os_type" = "MingW" ; then
fi
dnl dlopen() is required for plugin support.
AC_SEARCH_LIBS(dlopen,dl,AC_DEFINE([HAVE_DLOPEN],[1],
AC_SEARCH_LIBS(dlopen,dl,LLVM_DEFINE_SUBST([HAVE_DLOPEN],[1],
[Define if dlopen() is available on this platform.]),
AC_MSG_WARN([dlopen() not found - disabling plugin support]))
@ -1430,8 +1455,15 @@ dnl The curses library is optional; used for querying terminal info
if test "$llvm_cv_enable_terminfo" = "yes" ; then
dnl We need the has_color functionality in curses for it to be useful.
AC_SEARCH_LIBS(setupterm,tinfo terminfo curses ncurses ncursesw,
AC_DEFINE([HAVE_TERMINFO],[1],
[Define if the setupterm() function is supported this platform.]))
LLVM_DEFINE_SUBST([HAVE_TERMINFO],[1],
[Define if the setupterm() function is supported this platform.]))
fi
dnl The libedit library is optional; used by lib/LineEditor
if test "$llvm_cv_enable_libedit" = "yes" ; then
AC_SEARCH_LIBS(el_init,edit,
AC_DEFINE([HAVE_LIBEDIT],[1],
[Define if libedit is available on this platform.]))
fi
dnl libffi is optional; used to call external functions from the interpreter
@ -1465,25 +1497,6 @@ if test "$LLVM_ENABLE_ZLIB" -eq 1 ; then
AC_CHECK_LIB(z, compress2)
fi
dnl Allow extra x86-disassembler library
AC_ARG_WITH(udis86,
AS_HELP_STRING([--with-udis86=<path>],
[Use udis86 external x86 disassembler library]),
[
AC_SUBST(USE_UDIS86, [1])
case "$withval" in
/usr/lib|yes) ;;
*) LDFLAGS="$LDFLAGS -L${withval}" ;;
esac
AC_CHECK_LIB(udis86, ud_init, [], [
echo "Error! You need to have libudis86 around."
exit -1
])
],
AC_SUBST(USE_UDIS86, [0]))
AC_DEFINE_UNQUOTED([USE_UDIS86],$USE_UDIS86,
[Define if use udis86 library])
dnl Allow OProfile support for JIT output.
AC_ARG_WITH(oprofile,
AS_HELP_STRING([--with-oprofile=<prefix>],
@ -1667,13 +1680,16 @@ AC_CHECK_FUNCS([log log2 log10 exp exp2])
AC_CHECK_FUNCS([getpagesize getrusage getrlimit setrlimit gettimeofday ])
AC_CHECK_FUNCS([isatty mkdtemp mkstemp ])
AC_CHECK_FUNCS([mktemp posix_spawn pread realpath sbrk setrlimit ])
AC_CHECK_FUNCS([strerror strerror_r setenv arc4random ])
AC_CHECK_FUNCS([strerror strerror_r setenv ])
AC_CHECK_FUNCS([strtoll strtoq sysconf malloc_zone_statistics ])
AC_CHECK_FUNCS([setjmp longjmp sigsetjmp siglongjmp writev])
AC_CHECK_FUNCS([futimes futimens])
AC_C_PRINTF_A
AC_FUNC_RAND48
dnl Check for arc4random accessible via AC_INCLUDES_DEFAULT.
AC_CHECK_DECLS([arc4random])
dnl Check the declaration "Secure API" on Windows environments.
AC_CHECK_DECLS([strerror_s])
@ -1795,11 +1811,7 @@ AC_CHECK_FUNCS([__dso_handle])
dnl Propagate the shared library extension that the libltdl checks did to
dnl the Makefiles so we can use it there too
AC_SUBST(SHLIBEXT,$libltdl_cv_shlibext)
dnl Propagate the run-time library path variable that the libltdl
dnl checks found to the Makefiles so we can use it there too
AC_SUBST(SHLIBPATH_VAR,$libltdl_cv_shlibpath_var)
AC_SUBST(SHLIBEXT,$llvm_shlib_ext)
dnl Translate the various configuration directories and other basic
dnl information into substitutions that will end up in Makefile.config.in

View File

@ -1,522 +0,0 @@
#! /bin/sh
# depcomp - compile a program generating dependencies as side-effects
scriptversion=2004-05-31.23
# Copyright (C) 1999, 2000, 2003, 2004 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
case $1 in
'')
echo "$0: No command. Try \`$0 --help' for more information." 1>&2
exit 1;
;;
-h | --h*)
cat <<\EOF
Usage: depcomp [--help] [--version] PROGRAM [ARGS]
Run PROGRAMS ARGS to compile a file, generating dependencies
as side-effects.
Environment variables:
depmode Dependency tracking mode.
source Source file read by `PROGRAMS ARGS'.
object Object file output by `PROGRAMS ARGS'.
DEPDIR directory where to store dependencies.
depfile Dependency file to output.
tmpdepfile Temporary file to use when outputing dependencies.
libtool Whether libtool is used (yes/no).
Report bugs to <bug-automake@gnu.org>.
EOF
exit 0
;;
-v | --v*)
echo "depcomp $scriptversion"
exit 0
;;
esac
if test -z "$depmode" || test -z "$source" || test -z "$object"; then
echo "depcomp: Variables source, object and depmode must be set" 1>&2
exit 1
fi
# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
depfile=${depfile-`echo "$object" |
sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
rm -f "$tmpdepfile"
# Some modes work just like other modes, but use different flags. We
# parameterize here, but still list the modes in the big case below,
# to make depend.m4 easier to write. Note that we *cannot* use a case
# here, because this file can only contain one case statement.
if test "$depmode" = hp; then
# HP compiler uses -M and no extra arg.
gccflag=-M
depmode=gcc
fi
if test "$depmode" = dashXmstdout; then
# This is just like dashmstdout with a different argument.
dashmflag=-xM
depmode=dashmstdout
fi
case "$depmode" in
gcc3)
## gcc 3 implements dependency tracking that does exactly what
## we want. Yay! Note: for some reason libtool 1.4 doesn't like
## it if -MD -MP comes after the -MF stuff. Hmm.
"$@" -MT "$object" -MD -MP -MF "$tmpdepfile"
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
mv "$tmpdepfile" "$depfile"
;;
gcc)
## There are various ways to get dependency output from gcc. Here's
## why we pick this rather obscure method:
## - Don't want to use -MD because we'd like the dependencies to end
## up in a subdir. Having to rename by hand is ugly.
## (We might end up doing this anyway to support other compilers.)
## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
## -MM, not -M (despite what the docs say).
## - Using -M directly means running the compiler twice (even worse
## than renaming).
if test -z "$gccflag"; then
gccflag=-MD,
fi
"$@" -Wp,"$gccflag$tmpdepfile"
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
echo "$object : \\" > "$depfile"
alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
## The second -e expression handles DOS-style file names with drive letters.
sed -e 's/^[^:]*: / /' \
-e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
## This next piece of magic avoids the `deleted header file' problem.
## The problem is that when a header file which appears in a .P file
## is deleted, the dependency causes make to die (because there is
## typically no way to rebuild the header). We avoid this by adding
## dummy dependencies for each header file. Too bad gcc doesn't do
## this for us directly.
tr ' ' '
' < "$tmpdepfile" |
## Some versions of gcc put a space before the `:'. On the theory
## that the space means something, we add a space to the output as
## well.
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
hp)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
sgi)
if test "$libtool" = yes; then
"$@" "-Wp,-MDupdate,$tmpdepfile"
else
"$@" -MDupdate "$tmpdepfile"
fi
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
echo "$object : \\" > "$depfile"
# Clip off the initial element (the dependent). Don't try to be
# clever and replace this with sed code, as IRIX sed won't handle
# lines with more than a fixed number of characters (4096 in
# IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
# the IRIX cc adds comments like `#:fec' to the end of the
# dependency line.
tr ' ' '
' < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
tr '
' ' ' >> $depfile
echo >> $depfile
# The second pass generates a dummy entry for each header file.
tr ' ' '
' < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
>> $depfile
else
# The sourcefile does not contain any dependencies, so just
# store a dummy comment line, to avoid errors with the Makefile
# "include basename.Plo" scheme.
echo "#dummy" > "$depfile"
fi
rm -f "$tmpdepfile"
;;
aix)
# The C for AIX Compiler uses -M and outputs the dependencies
# in a .u file. In older versions, this file always lives in the
# current directory. Also, the AIX compiler puts `$object:' at the
# start of each line; $object doesn't have directory information.
# Version 6 uses the directory in both cases.
stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'`
tmpdepfile="$stripped.u"
if test "$libtool" = yes; then
"$@" -Wc,-M
else
"$@" -M
fi
stat=$?
if test -f "$tmpdepfile"; then :
else
stripped=`echo "$stripped" | sed 's,^.*/,,'`
tmpdepfile="$stripped.u"
fi
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
if test -f "$tmpdepfile"; then
outname="$stripped.o"
# Each line is of the form `foo.o: dependent.h'.
# Do two passes, one to just change these to
# `$object: dependent.h' and one to simply `dependent.h:'.
sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile"
sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
else
# The sourcefile does not contain any dependencies, so just
# store a dummy comment line, to avoid errors with the Makefile
# "include basename.Plo" scheme.
echo "#dummy" > "$depfile"
fi
rm -f "$tmpdepfile"
;;
icc)
# Intel's C compiler understands `-MD -MF file'. However on
# icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
# ICC 7.0 will fill foo.d with something like
# foo.o: sub/foo.c
# foo.o: sub/foo.h
# which is wrong. We want:
# sub/foo.o: sub/foo.c
# sub/foo.o: sub/foo.h
# sub/foo.c:
# sub/foo.h:
# ICC 7.1 will output
# foo.o: sub/foo.c sub/foo.h
# and will wrap long lines using \ :
# foo.o: sub/foo.c ... \
# sub/foo.h ... \
# ...
"$@" -MD -MF "$tmpdepfile"
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
# Each line is of the form `foo.o: dependent.h',
# or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
# Do two passes, one to just change these to
# `$object: dependent.h' and one to simply `dependent.h:'.
sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
# Some versions of the HPUX 10.20 sed can't process this invocation
# correctly. Breaking it into two sed invocations is a workaround.
sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
tru64)
# The Tru64 compiler uses -MD to generate dependencies as a side
# effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
# At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
# dependencies in `foo.d' instead, so we check for that too.
# Subdirectories are respected.
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
test "x$dir" = "x$object" && dir=
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
if test "$libtool" = yes; then
# Dependencies are output in .lo.d with libtool 1.4.
# With libtool 1.5 they are output both in $dir.libs/$base.o.d
# and in $dir.libs/$base.o.d and $dir$base.o.d. We process the
# latter, because the former will be cleaned when $dir.libs is
# erased.
tmpdepfile1="$dir.libs/$base.lo.d"
tmpdepfile2="$dir$base.o.d"
tmpdepfile3="$dir.libs/$base.d"
"$@" -Wc,-MD
else
tmpdepfile1="$dir$base.o.d"
tmpdepfile2="$dir$base.d"
tmpdepfile3="$dir$base.d"
"$@" -MD
fi
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
exit $stat
fi
if test -f "$tmpdepfile1"; then
tmpdepfile="$tmpdepfile1"
elif test -f "$tmpdepfile2"; then
tmpdepfile="$tmpdepfile2"
else
tmpdepfile="$tmpdepfile3"
fi
if test -f "$tmpdepfile"; then
sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
# That's a tab and a space in the [].
sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
else
echo "#dummy" > "$depfile"
fi
rm -f "$tmpdepfile"
;;
#nosideeffect)
# This comment above is used by automake to tell side-effect
# dependency tracking mechanisms from slower ones.
dashmstdout)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout, regardless of -o.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test $1 != '--mode=compile'; do
shift
done
shift
fi
# Remove `-o $object'.
IFS=" "
for arg
do
case $arg in
-o)
shift
;;
$object)
shift
;;
*)
set fnord "$@" "$arg"
shift # fnord
shift # $arg
;;
esac
done
test -z "$dashmflag" && dashmflag=-M
# Require at least two characters before searching for `:'
# in the target name. This is to cope with DOS-style filenames:
# a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
"$@" $dashmflag |
sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile"
rm -f "$depfile"
cat < "$tmpdepfile" > "$depfile"
tr ' ' '
' < "$tmpdepfile" | \
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
dashXmstdout)
# This case only exists to satisfy depend.m4. It is never actually
# run, as this mode is specially recognized in the preamble.
exit 1
;;
makedepend)
"$@" || exit $?
# Remove any Libtool call
if test "$libtool" = yes; then
while test $1 != '--mode=compile'; do
shift
done
shift
fi
# X makedepend
shift
cleared=no
for arg in "$@"; do
case $cleared in
no)
set ""; shift
cleared=yes ;;
esac
case "$arg" in
-D*|-I*)
set fnord "$@" "$arg"; shift ;;
# Strip any option that makedepend may not understand. Remove
# the object too, otherwise makedepend will parse it as a source file.
-*|$object)
;;
*)
set fnord "$@" "$arg"; shift ;;
esac
done
obj_suffix="`echo $object | sed 's/^.*\././'`"
touch "$tmpdepfile"
${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
rm -f "$depfile"
cat < "$tmpdepfile" > "$depfile"
sed '1,2d' "$tmpdepfile" | tr ' ' '
' | \
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile" "$tmpdepfile".bak
;;
cpp)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test $1 != '--mode=compile'; do
shift
done
shift
fi
# Remove `-o $object'.
IFS=" "
for arg
do
case $arg in
-o)
shift
;;
$object)
shift
;;
*)
set fnord "$@" "$arg"
shift # fnord
shift # $arg
;;
esac
done
"$@" -E |
sed -n '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
sed '$ s: \\$::' > "$tmpdepfile"
rm -f "$depfile"
echo "$object : \\" > "$depfile"
cat < "$tmpdepfile" >> "$depfile"
sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
msvisualcpp)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout, regardless of -o,
# because we must use -o when running libtool.
"$@" || exit $?
IFS=" "
for arg
do
case "$arg" in
"-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
set fnord "$@"
shift
shift
;;
*)
set fnord "$@" "$arg"
shift
shift
;;
esac
done
"$@" -E |
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
rm -f "$depfile"
echo "$object : \\" > "$depfile"
. "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile"
echo " " >> "$depfile"
. "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
rm -f "$tmpdepfile"
;;
none)
exec "$@"
;;
*)
echo "Unknown depmode $depmode" 1>&2
exit 1
;;
esac
exit 0
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-end: "$"
# End:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,5 @@
# Combine AC_DEFINE and AC_SUBST
AC_DEFUN([LLVM_DEFINE_SUBST], [
AC_DEFINE([$1], [$2], [$3])
AC_SUBST([$1], ['$2'])
])

6389
autoconf/m4/libtool.m4 vendored

File diff suppressed because it is too large Load Diff

View File

@ -6,7 +6,7 @@
AC_DEFUN([AC_LINK_GET_VERSION],
[AC_CACHE_CHECK([for linker version],[llvm_cv_link_version],
[
version_string="$(ld -v 2>&1 | head -1)"
version_string="$(${LD:-ld} -v 2>&1 | head -1)"
# Check for ld64.
if (echo "$version_string" | grep -q "ld64"); then

View File

@ -1,397 +0,0 @@
## ltdl.m4 - Configure ltdl for the target system. -*-Autoconf-*-
## Copyright (C) 1999-2000 Free Software Foundation, Inc.
##
## This file is free software; the Free Software Foundation gives
## unlimited permission to copy and/or distribute it, with or without
## modifications, as long as this notice is preserved.
# serial 7 AC_LIB_LTDL
# AC_WITH_LTDL
# ------------
# Clients of libltdl can use this macro to allow the installer to
# choose between a shipped copy of the ltdl sources or a preinstalled
# version of the library.
AC_DEFUN([AC_WITH_LTDL],
[AC_REQUIRE([AC_LIB_LTDL])
AC_SUBST([LIBLTDL])
AC_SUBST([INCLTDL])
# Unless the user asks us to check, assume no installed ltdl exists.
use_installed_libltdl=no
AC_ARG_WITH([included_ltdl],
[ --with-included-ltdl use the GNU ltdl sources included here])
if test "x$with_included_ltdl" != xyes; then
# We are not being forced to use the included libltdl sources, so
# decide whether there is a useful installed version we can use.
AC_CHECK_HEADER([ltdl.h],
[AC_CHECK_LIB([ltdl], [lt_dlcaller_register],
[with_included_ltdl=no],
[with_included_ltdl=yes])
])
fi
if test "x$enable_ltdl_install" != xyes; then
# If the user did not specify an installable libltdl, then default
# to a convenience lib.
AC_LIBLTDL_CONVENIENCE
fi
if test "x$with_included_ltdl" = xno; then
# If the included ltdl is not to be used. then Use the
# preinstalled libltdl we found.
AC_DEFINE([HAVE_LTDL], [1],
[Define this if a modern libltdl is already installed])
LIBLTDL=-lltdl
fi
# Report our decision...
AC_MSG_CHECKING([whether to use included libltdl])
AC_MSG_RESULT([$with_included_ltdl])
AC_CONFIG_SUBDIRS([libltdl])
])# AC_WITH_LTDL
# AC_LIB_LTDL
# -----------
# Perform all the checks necessary for compilation of the ltdl objects
# -- including compiler checks and header checks.
AC_DEFUN([AC_LIB_LTDL],
[AC_PREREQ(2.60)
AC_REQUIRE([AC_PROG_CC])
AC_REQUIRE([AC_C_CONST])
AC_REQUIRE([AC_HEADER_STDC])
AC_REQUIRE([AC_HEADER_DIRENT])
AC_REQUIRE([_LT_AC_CHECK_DLFCN])
AC_REQUIRE([AC_LTDL_ENABLE_INSTALL])
AC_REQUIRE([AC_LTDL_SHLIBEXT])
AC_REQUIRE([AC_LTDL_SYSSEARCHPATH])
AC_REQUIRE([AC_LTDL_OBJDIR])
AC_REQUIRE([AC_LTDL_DLPREOPEN])
AC_REQUIRE([AC_LTDL_DLLIB])
AC_REQUIRE([AC_LTDL_SYMBOL_USCORE])
AC_REQUIRE([AC_LTDL_DLSYM_USCORE])
AC_REQUIRE([AC_LTDL_SYS_DLOPEN_DEPLIBS])
AC_REQUIRE([AC_LTDL_FUNC_ARGZ])
AC_CHECK_HEADERS([errno.h malloc.h memory.h unistd.h])
AC_CHECK_HEADERS([mach-o/dyld.h])
AC_CHECK_FUNCS([closedir opendir readdir])
])# AC_LIB_LTDL
# AC_LTDL_ENABLE_INSTALL
# ----------------------
AC_DEFUN([AC_LTDL_ENABLE_INSTALL],
[AC_ARG_ENABLE([ltdl-install],
[AS_HELP_STRING([--enable-ltdl-install],[install libltdl])])
AM_CONDITIONAL(INSTALL_LTDL, test x"${enable_ltdl_install-no}" != xno)
AM_CONDITIONAL(CONVENIENCE_LTDL, test x"${enable_ltdl_convenience-no}" != xno)
])# AC_LTDL_ENABLE_INSTALL
# AC_LTDL_SYS_DLOPEN_DEPLIBS
# --------------------------
AC_DEFUN([AC_LTDL_SYS_DLOPEN_DEPLIBS],
[AC_REQUIRE([AC_CANONICAL_HOST])
AC_CACHE_CHECK([whether deplibs are loaded by dlopen],
[libltdl_cv_sys_dlopen_deplibs],
[# PORTME does your system automatically load deplibs for dlopen?
# or its logical equivalent (e.g. shl_load for HP-UX < 11)
# For now, we just catch OSes we know something about -- in the
# future, we'll try test this programmatically.
libltdl_cv_sys_dlopen_deplibs=unknown
case "$host_os" in
aix3*|aix4.1.*|aix4.2.*)
# Unknown whether this is true for these versions of AIX, but
# we want this `case' here to explicitly catch those versions.
libltdl_cv_sys_dlopen_deplibs=unknown
;;
aix[[45]]*)
libltdl_cv_sys_dlopen_deplibs=yes
;;
darwin*)
# Assuming the user has installed a libdl from somewhere, this is true
# If you are looking for one http://www.opendarwin.org/projects/dlcompat
libltdl_cv_sys_dlopen_deplibs=yes
;;
gnu* | linux* | kfreebsd*-gnu | knetbsd*-gnu)
# GNU and its variants, using gnu ld.so (Glibc)
libltdl_cv_sys_dlopen_deplibs=yes
;;
hpux10*|hpux11*)
libltdl_cv_sys_dlopen_deplibs=yes
;;
interix*)
libltdl_cv_sys_dlopen_deplibs=yes
;;
irix[[12345]]*|irix6.[[01]]*)
# Catch all versions of IRIX before 6.2, and indicate that we don't
# know how it worked for any of those versions.
libltdl_cv_sys_dlopen_deplibs=unknown
;;
irix*)
# The case above catches anything before 6.2, and it's known that
# at 6.2 and later dlopen does load deplibs.
libltdl_cv_sys_dlopen_deplibs=yes
;;
netbsd*)
libltdl_cv_sys_dlopen_deplibs=yes
;;
openbsd*)
libltdl_cv_sys_dlopen_deplibs=yes
;;
osf[[1234]]*)
# dlopen did load deplibs (at least at 4.x), but until the 5.x series,
# it did *not* use an RPATH in a shared library to find objects the
# library depends on, so we explicitly say `no'.
libltdl_cv_sys_dlopen_deplibs=no
;;
osf5.0|osf5.0a|osf5.1)
# dlopen *does* load deplibs and with the right loader patch applied
# it even uses RPATH in a shared library to search for shared objects
# that the library depends on, but there's no easy way to know if that
# patch is installed. Since this is the case, all we can really
# say is unknown -- it depends on the patch being installed. If
# it is, this changes to `yes'. Without it, it would be `no'.
libltdl_cv_sys_dlopen_deplibs=unknown
;;
osf*)
# the two cases above should catch all versions of osf <= 5.1. Read
# the comments above for what we know about them.
# At > 5.1, deplibs are loaded *and* any RPATH in a shared library
# is used to find them so we can finally say `yes'.
libltdl_cv_sys_dlopen_deplibs=yes
;;
solaris*)
libltdl_cv_sys_dlopen_deplibs=yes
;;
sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
libltdl_cv_sys_dlopen_deplibs=yes
;;
esac
])
if test "$libltdl_cv_sys_dlopen_deplibs" != yes; then
AC_DEFINE([LTDL_DLOPEN_DEPLIBS], [1],
[Define if the OS needs help to load dependent libraries for dlopen().])
fi
])# AC_LTDL_SYS_DLOPEN_DEPLIBS
# AC_LTDL_SHLIBEXT
# ----------------
AC_DEFUN([AC_LTDL_SHLIBEXT],
[AC_REQUIRE([AC_LIBTOOL_SYS_DYNAMIC_LINKER])
AC_CACHE_CHECK([which extension is used for loadable modules],
[libltdl_cv_shlibext],
[
module=yes
eval libltdl_cv_shlibext=$shrext_cmds
])
if test -n "$libltdl_cv_shlibext"; then
AC_DEFINE_UNQUOTED([LTDL_SHLIB_EXT], ["$libltdl_cv_shlibext"],
[Define to the extension used for shared libraries, say, ".so".])
fi
])# AC_LTDL_SHLIBEXT
# AC_LTDL_SYSSEARCHPATH
# ---------------------
AC_DEFUN([AC_LTDL_SYSSEARCHPATH],
[AC_REQUIRE([AC_LIBTOOL_SYS_DYNAMIC_LINKER])
AC_CACHE_CHECK([for the default library search path],
[libltdl_cv_sys_search_path],
[libltdl_cv_sys_search_path="$sys_lib_dlsearch_path_spec"])
if test -n "$libltdl_cv_sys_search_path"; then
sys_search_path=
for dir in $libltdl_cv_sys_search_path; do
if test -z "$sys_search_path"; then
sys_search_path="$dir"
else
sys_search_path="$sys_search_path$PATH_SEPARATOR$dir"
fi
done
AC_DEFINE_UNQUOTED([LTDL_SYSSEARCHPATH], ["$sys_search_path"],
[Define to the system default library search path.])
fi
])# AC_LTDL_SYSSEARCHPATH
# AC_LTDL_OBJDIR
# --------------
AC_DEFUN([AC_LTDL_OBJDIR],
[AC_CACHE_CHECK([for objdir],
[libltdl_cv_objdir],
[libltdl_cv_objdir="$objdir"
if test -n "$objdir"; then
:
else
rm -f .libs 2>/dev/null
mkdir .libs 2>/dev/null
if test -d .libs; then
libltdl_cv_objdir=.libs
else
# MS-DOS does not allow filenames that begin with a dot.
libltdl_cv_objdir=_libs
fi
rmdir .libs 2>/dev/null
fi
])
AC_DEFINE_UNQUOTED([LTDL_OBJDIR], ["$libltdl_cv_objdir/"],
[Define to the sub-directory in which libtool stores uninstalled libraries.])
])# AC_LTDL_OBJDIR
# AC_LTDL_DLPREOPEN
# -----------------
AC_DEFUN([AC_LTDL_DLPREOPEN],
[AC_REQUIRE([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])
AC_CACHE_CHECK([whether libtool supports -dlopen/-dlpreopen],
[libltdl_cv_preloaded_symbols],
[if test -n "$lt_cv_sys_global_symbol_pipe"; then
libltdl_cv_preloaded_symbols=yes
else
libltdl_cv_preloaded_symbols=no
fi
])
if test x"$libltdl_cv_preloaded_symbols" = xyes; then
AC_DEFINE([HAVE_PRELOADED_SYMBOLS], [1],
[Define if libtool can extract symbol lists from object files.])
fi
])# AC_LTDL_DLPREOPEN
# AC_LTDL_DLLIB
# -------------
AC_DEFUN([AC_LTDL_DLLIB],
[LIBADD_DL=
AC_SUBST(LIBADD_DL)
AC_LANG_PUSH([C])
AC_CHECK_FUNC([shl_load],
[AC_DEFINE([HAVE_SHL_LOAD], [1],
[Define if you have the shl_load function.])],
[AC_CHECK_LIB([dld], [shl_load],
[AC_DEFINE([HAVE_SHL_LOAD], [1],
[Define if you have the shl_load function.])
LIBADD_DL="$LIBADD_DL -ldld"],
[AC_CHECK_LIB([dl], [dlopen],
[AC_DEFINE([HAVE_LIBDL], [1],
[Define if you have the libdl library or equivalent.])
LIBADD_DL="-ldl" libltdl_cv_lib_dl_dlopen="yes"],
[AC_LINK_IFELSE([AC_LANG_PROGRAM([[#if HAVE_DLFCN_H
# include <dlfcn.h>
#endif
]], [[dlopen(0, 0);]])],[AC_DEFINE([HAVE_LIBDL], [1],
[Define if you have the libdl library or equivalent.]) libltdl_cv_func_dlopen="yes"],[AC_CHECK_LIB([svld], [dlopen],
[AC_DEFINE([HAVE_LIBDL], [1],
[Define if you have the libdl library or equivalent.])
LIBADD_DL="-lsvld" libltdl_cv_func_dlopen="yes"],
[AC_CHECK_LIB([dld], [dld_link],
[AC_DEFINE([HAVE_DLD], [1],
[Define if you have the GNU dld library.])
LIBADD_DL="$LIBADD_DL -ldld"],
[AC_CHECK_FUNC([_dyld_func_lookup],
[AC_DEFINE([HAVE_DYLD], [1],
[Define if you have the _dyld_func_lookup function.])])
])
])
])
])
])
])
if test x"$libltdl_cv_func_dlopen" = xyes || test x"$libltdl_cv_lib_dl_dlopen" = xyes
then
lt_save_LIBS="$LIBS"
LIBS="$LIBS $LIBADD_DL"
AC_CHECK_FUNCS([dlerror])
LIBS="$lt_save_LIBS"
fi
AC_LANG_POP
])# AC_LTDL_DLLIB
# AC_LTDL_SYMBOL_USCORE
# ---------------------
# does the compiler prefix global symbols with an underscore?
AC_DEFUN([AC_LTDL_SYMBOL_USCORE],
[AC_REQUIRE([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])
AC_CACHE_CHECK([for _ prefix in compiled symbols],
[ac_cv_sys_symbol_underscore],
[ac_cv_sys_symbol_underscore=no
cat > conftest.$ac_ext <<EOF
void nm_test_func(){}
int main(){nm_test_func;return 0;}
EOF
if AC_TRY_EVAL(ac_compile); then
# Now try to grab the symbols.
ac_nlist=conftest.nm
if AC_TRY_EVAL(NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $ac_nlist) && test -s "$ac_nlist"; then
# See whether the symbols have a leading underscore.
if grep '^. _nm_test_func' "$ac_nlist" >/dev/null; then
ac_cv_sys_symbol_underscore=yes
else
if grep '^. nm_test_func ' "$ac_nlist" >/dev/null; then
:
else
echo "configure: cannot find nm_test_func in $ac_nlist" >&AS_MESSAGE_LOG_FD
fi
fi
else
echo "configure: cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD
fi
else
echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD
cat conftest.c >&AS_MESSAGE_LOG_FD
fi
rm -rf conftest*
])
])# AC_LTDL_SYMBOL_USCORE
# AC_LTDL_DLSYM_USCORE
# --------------------
AC_DEFUN([AC_LTDL_DLSYM_USCORE],
[AC_REQUIRE([AC_LTDL_SYMBOL_USCORE])
if test x"$ac_cv_sys_symbol_underscore" = xyes; then
if test x"$libltdl_cv_func_dlopen" = xyes ||
test x"$libltdl_cv_lib_dl_dlopen" = xyes ; then
AC_CACHE_CHECK([whether we have to add an underscore for dlsym],
[libltdl_cv_need_uscore],
[libltdl_cv_need_uscore=unknown
save_LIBS="$LIBS"
LIBS="$LIBS $LIBADD_DL"
_LT_AC_TRY_DLOPEN_SELF(
[libltdl_cv_need_uscore=no], [libltdl_cv_need_uscore=yes],
[], [libltdl_cv_need_uscore=cross])
LIBS="$save_LIBS"
])
fi
fi
if test x"$libltdl_cv_need_uscore" = xyes; then
AC_DEFINE([NEED_USCORE], [1],
[Define if dlsym() requires a leading underscore in symbol names.])
fi
])# AC_LTDL_DLSYM_USCORE
# AC_LTDL_FUNC_ARGZ
# -----------------
AC_DEFUN([AC_LTDL_FUNC_ARGZ],
[AC_CHECK_HEADERS([argz.h])
AC_CHECK_TYPES([error_t],
[],
[AC_DEFINE([error_t], [int],
[Define to a type to use for `error_t' if it is not otherwise available.])],
[#if HAVE_ARGZ_H
# include <argz.h>
#endif])
AC_CHECK_FUNCS([argz_append argz_create_sep argz_insert argz_next argz_stringify])
])# AC_LTDL_FUNC_ARGZ

View File

@ -1,39 +0,0 @@
dnl This macro checks for tclsh which is required to run dejagnu. On some
dnl platforms (notably FreeBSD), tclsh is named tclshX.Y - this handles
dnl that for us so we can get the latest installed tclsh version.
dnl
AC_DEFUN([DJ_AC_PATH_TCLSH], [
no_itcl=true
AC_MSG_CHECKING(for the tclsh program in tclinclude directory)
AC_ARG_WITH(tclinclude,
AS_HELP_STRING([--with-tclinclude],
[directory where tcl headers are]),
[with_tclinclude=${withval}],[with_tclinclude=''])
AC_CACHE_VAL(ac_cv_path_tclsh,[
dnl first check to see if --with-itclinclude was specified
if test x"${with_tclinclude}" != x ; then
if test -f ${with_tclinclude}/tclsh ; then
ac_cv_path_tclsh=`(cd ${with_tclinclude}; pwd)`
elif test -f ${with_tclinclude}/src/tclsh ; then
ac_cv_path_tclsh=`(cd ${with_tclinclude}/src; pwd)`
else
AC_MSG_ERROR([${with_tclinclude} directory doesn't contain tclsh])
fi
fi])
dnl see if one is installed
if test x"${ac_cv_path_tclsh}" = x ; then
AC_MSG_RESULT(none)
AC_PATH_PROGS([TCLSH],[tclsh8.4 tclsh8.4.8 tclsh8.4.7 tclsh8.4.6 tclsh8.4.5 tclsh8.4.4 tclsh8.4.3 tclsh8.4.2 tclsh8.4.1 tclsh8.4.0 tclsh8.3 tclsh8.3.5 tclsh8.3.4 tclsh8.3.3 tclsh8.3.2 tclsh8.3.1 tclsh8.3.0 tclsh])
if test x"${TCLSH}" = x ; then
ac_cv_path_tclsh='';
else
ac_cv_path_tclsh="${TCLSH}";
fi
else
AC_MSG_RESULT(${ac_cv_path_tclsh})
TCLSH="${ac_cv_path_tclsh}"
AC_SUBST(TCLSH)
fi
])

View File

@ -9,7 +9,7 @@
LEVEL := ../..
DIRS = llvm bitreader bitwriter irreader analysis target executionengine \
transforms linker backends
transforms linker backends all_backends
ExtraMakefiles = $(PROJ_OBJ_DIR)/Makefile.ocaml
ocamldoc:

View File

@ -37,7 +37,7 @@ OcamlDir := $(LibDir)/ocaml
# Info from llvm-config and similar
ifndef IS_CLEANING_TARGET
ifdef UsedComponents
UsedLibs = $(shell $(LLVM_CONFIG) --libs $(UsedComponents))
UsedLibs = $(shell $(LLVM_CONFIG) --libs --system-libs $(UsedComponents))
UsedLibNames = $(shell $(LLVM_CONFIG) --libnames $(UsedComponents))
endif
endif

View File

@ -0,0 +1,21 @@
##===- bindings/ocaml/all_backends/Makefile ----------------------*- Makefile -*-===##
#
# The LLVM Compiler Infrastructure
#
# This file is distributed under the University of Illinois Open Source
# License. See LICENSE.TXT for details.
#
##===----------------------------------------------------------------------===##
#
# This is the makefile for the Objective Caml Llvm_backends interface.
#
##===----------------------------------------------------------------------===##
LEVEL := ../../..
include $(LEVEL)/Makefile.config
LIBRARYNAME := llvm_all_backends
UsedComponents := $(TARGETS_TO_BUILD)
UsedOcamlInterfaces :=
include ../Makefile.ocaml

View File

@ -0,0 +1,32 @@
/*===-- all_backends_ocaml.c - LLVM OCaml Glue ------------------*- C++ -*-===*\
|* *|
|* The LLVM Compiler Infrastructure *|
|* *|
|* This file is distributed under the University of Illinois Open Source *|
|* License. See LICENSE.TXT for details. *|
|* *|
|*===----------------------------------------------------------------------===*|
|* *|
|* This file glues LLVM's OCaml interface to its C interface. These functions *|
|* are by and large transparent wrappers to the corresponding C functions. *|
|* *|
|* Note that these functions intentionally take liberties with the CAMLparamX *|
|* macros, since most of the parameters are not GC heap objects. *|
|* *|
\*===----------------------------------------------------------------------===*/
#include "llvm-c/Target.h"
#include "caml/alloc.h"
#include "caml/fail.h"
#include "caml/memory.h"
#include "caml/custom.h"
/* unit -> unit */
CAMLprim value llvm_initialize_all(value Unit) {
LLVMInitializeAllTargetInfos();
LLVMInitializeAllTargets();
LLVMInitializeAllTargetMCs();
LLVMInitializeAllAsmPrinters();
LLVMInitializeAllAsmParsers();
return Val_unit;
}

View File

@ -0,0 +1,10 @@
(*===-- llvm_all_backends.ml - LLVM OCaml Interface -----------*- OCaml -*-===*
*
* The LLVM Compiler Infrastructure
*
* This file is distributed under the University of Illinois Open Source
* License. See LICENSE.TXT for details.
*
*===----------------------------------------------------------------------===*)
external initialize : unit -> unit = "llvm_initialize_all"

View File

@ -0,0 +1,11 @@
(*===-- llvm_all_backends.mli - LLVM OCaml Interface ----------*- OCaml -*-===*
*
* The LLVM Compiler Infrastructure
*
* This file is distributed under the University of Illinois Open Source
* License. See LICENSE.TXT for details.
*
*===----------------------------------------------------------------------===*)
(** Initialize all the backends targets *)
val initialize : unit -> unit

View File

@ -151,4 +151,6 @@ module ExecutionEngine: sig
val data_layout : t -> Llvm_target.DataLayout.t
end
(** [initialize_native_target ()] initializes the native target corresponding
to the host. Returns [true] if initialization is {b not} done. *)
val initialize_native_target : unit -> bool

View File

@ -93,3 +93,11 @@ package "linker" (
archive(byte) = "llvm_linker.cma"
archive(native) = "llvm_linker.cmxa"
)
package "all_backends" (
requires = "llvm"
version = "@PACKAGE_VERSION@"
description = "All backends for LLVM"
archive(byte) = "llvm_all_backends.cma"
archive(native) = "llvm_all_backends.cmxa"
)

View File

@ -16,6 +16,7 @@ type lluse
type llbasicblock
type llbuilder
type llmemorybuffer
type llmdkind
module TypeKind = struct
type t =
@ -299,7 +300,7 @@ type ('a, 'b) llrev_pos =
external create_context : unit -> llcontext = "llvm_create_context"
external dispose_context : llcontext -> unit = "llvm_dispose_context"
external global_context : unit -> llcontext = "llvm_global_context"
external mdkind_id : llcontext -> string -> int = "llvm_mdkind_id"
external mdkind_id : llcontext -> string -> llmdkind = "llvm_mdkind_id"
(*===-- Modules -----------------------------------------------------------===*)
external create_module : llcontext -> string -> llmodule = "llvm_create_module"
@ -442,9 +443,9 @@ external constexpr_opcode : llvalue -> Opcode.t = "llvm_constexpr_get_opcode"
(*--... Operations on instructions .........................................--*)
external has_metadata : llvalue -> bool = "llvm_has_metadata"
external metadata : llvalue -> int -> llvalue option = "llvm_metadata"
external set_metadata : llvalue -> int -> llvalue -> unit = "llvm_set_metadata"
external clear_metadata : llvalue -> int -> unit = "llvm_clear_metadata"
external metadata : llvalue -> llmdkind -> llvalue option = "llvm_metadata"
external set_metadata : llvalue -> llmdkind -> llvalue -> unit = "llvm_set_metadata"
external clear_metadata : llvalue -> llmdkind -> unit = "llvm_clear_metadata"
(*--... Operations on metadata .......,.....................................--*)
external mdstring : llcontext -> string -> llvalue = "llvm_mdstring"

View File

@ -48,6 +48,9 @@ type llbuilder
See the [llvm::MemoryBuffer] class. *)
type llmemorybuffer
(** The kind id of metadata attached to an instruction. *)
type llmdkind
(** The kind of an [lltype], the result of [classify_type ty]. See the
[llvm::Type::TypeID] enumeration. *)
module TypeKind : sig
@ -154,38 +157,40 @@ end
See the [llvm::ICmpInst::Predicate] enumeration. *)
module Icmp : sig
type t =
| Eq
| Ne
| Ugt
| Uge
| Ult
| Ule
| Sgt
| Sge
| Slt
| Sle
| Eq (* Equal *)
| Ne (* Not equal *)
| Ugt (* Unsigned greater than *)
| Uge (* Unsigned greater or equal *)
| Ult (* Unsigned less than *)
| Ule (* Unsigned less or equal *)
| Sgt (* Signed greater than *)
| Sge (* Signed greater or equal *)
| Slt (* Signed less than *)
| Sle (* Signed less or equal *)
end
(** The predicate for a floating-point comparison ([fcmp]) instruction.
Ordered means that neither operand is a QNAN while unordered means
that either operand may be a QNAN.
See the [llvm::FCmpInst::Predicate] enumeration. *)
module Fcmp : sig
type t =
| False
| Oeq
| Ogt
| Oge
| Olt
| Ole
| One
| Ord
| Uno
| Ueq
| Ugt
| Uge
| Ult
| Ule
| Une
| True
| False (* Always false *)
| Oeq (* Ordered and equal *)
| Ogt (* Ordered and greater than *)
| Oge (* Ordered and greater or equal *)
| Olt (* Ordered and less than *)
| Ole (* Ordered and less or equal *)
| One (* Ordered and not equal *)
| Ord (* Ordered (no operand is NaN) *)
| Uno (* Unordered (one operand at least is NaN) *)
| Ueq (* Unordered and equal *)
| Ugt (* Unordered and greater than *)
| Uge (* Unordered and greater or equal *)
| Ult (* Unordered and less than *)
| Ule (* Unordered and less or equal *)
| Une (* Unordered and not equal *)
| True (* Always true *)
end
(** The opcodes for LLVM instructions and constant expressions. *)
@ -392,7 +397,7 @@ val global_context : unit -> llcontext
(** [mdkind_id context name] returns the MDKind ID that corresponds to the
name [name] in the context [context]. See the function
[llvm::LLVMContext::getMDKindID]. *)
val mdkind_id : llcontext -> string -> int
val mdkind_id : llcontext -> string -> llmdkind
(** {6 Modules} *)
@ -770,15 +775,15 @@ val has_metadata : llvalue -> bool
(** [metadata i kind] optionally returns the metadata associated with the
kind [kind] in the instruction [i] See the function
[llvm::Instruction::getMetadata]. *)
val metadata : llvalue -> int -> llvalue option
val metadata : llvalue -> llmdkind -> llvalue option
(** [set_metadata i kind md] sets the metadata [md] of kind [kind] in the
instruction [i]. See the function [llvm::Instruction::setMetadata]. *)
val set_metadata : llvalue -> int -> llvalue -> unit
val set_metadata : llvalue -> llmdkind -> llvalue -> unit
(** [clear_metadata i kind] clears the metadata of kind [kind] in the
instruction [i]. See the function [llvm::Instruction::setMetadata]. *)
val clear_metadata : llvalue -> int -> unit
val clear_metadata : llvalue -> llmdkind -> unit
(** {7 Operations on metadata} *)
@ -1048,12 +1053,12 @@ val const_lshr : llvalue -> llvalue -> llvalue
See the method [llvm::ConstantExpr::getAShr]. *)
val const_ashr : llvalue -> llvalue -> llvalue
(** [const_gep pc indices] returns the constant [getElementPtr] of [p1] with the
(** [const_gep pc indices] returns the constant [getElementPtr] of [pc] with the
constant integers indices from the array [indices].
See the method [llvm::ConstantExpr::getGetElementPtr]. *)
val const_gep : llvalue -> llvalue array -> llvalue
(** [const_in_bounds_gep pc indices] returns the constant [getElementPtr] of [p1]
(** [const_in_bounds_gep pc indices] returns the constant [getElementPtr] of [pc]
with the constant integers indices from the array [indices].
See the method [llvm::ConstantExpr::getInBoundsGetElementPtr]. *)
val const_in_bounds_gep : llvalue -> llvalue array -> llvalue
@ -2357,7 +2362,7 @@ val build_insertelement : llvalue -> llvalue -> llvalue -> string ->
val build_shufflevector : llvalue -> llvalue -> llvalue -> string ->
llbuilder -> llvalue
(** [build_insertvalue agg idx name b] creates a
(** [build_extractvalue agg idx name b] creates a
[%name = extractvalue %agg, %idx]
instruction at the position specified by the instruction builder [b].
See the method [llvm::LLVMBuilder::CreateExtractValue]. *)

View File

@ -352,8 +352,8 @@ CAMLprim value llvm_targetmachine_data_layout(value Machine) {
CAMLreturn(DataLayout);
}
/* TargetMachine.t -> bool -> unit */
CAMLprim value llvm_targetmachine_set_verbose_asm(value Machine, value Verb) {
/* bool -> TargetMachine.t -> unit */
CAMLprim value llvm_targetmachine_set_verbose_asm(value Verb, value Machine) {
LLVMSetTargetMachineAsmVerbosity(TargetMachine_val(Machine), Bool_val(Verb));
return Val_unit;
}

View File

@ -12,7 +12,7 @@
This interface provides an OCaml API for LLVM scalar transforms, the
classes in the [LLVMScalarOpts] library. *)
(** See the [llvm::createConstantPropogationPass] function. *)
(** See the [llvm::createConstantPropagationPass] function. *)
external add_constant_propagation : [<Llvm.PassManager.any] Llvm.PassManager.t
-> unit
= "llvm_add_constant_propagation"

View File

@ -134,6 +134,12 @@ CAMLprim value llvm_add_tail_call_elimination(LLVMPassManagerRef PM) {
return Val_unit;
}
/* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */
CAMLprim value llvm_add_merged_load_store_motion(LLVMPassManagerRef PM) {
LLVMAddMergedLoadStoreMotionPass(PM);
return Val_unit;
}
/* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */
CAMLprim value llvm_add_gvn(LLVMPassManagerRef PM) {
LLVMAddGVNPass(PM);

View File

@ -20,6 +20,7 @@
__all__ = [
"lib",
"Enums",
"OpCode",
"MemoryBuffer",
"Module",
@ -32,42 +33,115 @@
]
lib = get_library()
Enums = []
class OpCode(object):
"""Represents an individual OpCode enumeration."""
_value_map = {}
class LLVMEnumeration(object):
"""Represents an individual LLVM enumeration."""
def __init__(self, name, value):
self.name = name
self.value = value
def __repr__(self):
return 'OpCode.%s' % self.name
return '%s.%s' % (self.__class__.__name__,
self.name)
@staticmethod
def from_value(value):
"""Obtain an OpCode instance from a numeric value."""
result = OpCode._value_map.get(value, None)
@classmethod
def from_value(cls, value):
"""Obtain an enumeration instance from a numeric value."""
result = cls._value_map.get(value, None)
if result is None:
raise ValueError('Unknown OpCode: %d' % value)
raise ValueError('Unknown %s: %d' % (cls.__name__,
value))
return result
@staticmethod
def register(name, value):
"""Registers a new OpCode enumeration.
@classmethod
def register(cls, name, value):
"""Registers a new enumeration.
This is called by this module for each enumeration defined in
enumerations. You should not need to call this outside this module.
"""
if value in OpCode._value_map:
raise ValueError('OpCode value already registered: %d' % value)
if value in cls._value_map:
raise ValueError('%s value already registered: %d' % (cls.__name__,
value))
enum = cls(name, value)
cls._value_map[value] = enum
setattr(cls, name, enum)
opcode = OpCode(name, value)
OpCode._value_map[value] = opcode
setattr(OpCode, name, opcode)
class Attribute(LLVMEnumeration):
"""Represents an individual Attribute enumeration."""
_value_map = {}
def __init__(self, name, value):
super(Attribute, self).__init__(name, value)
class OpCode(LLVMEnumeration):
"""Represents an individual OpCode enumeration."""
_value_map = {}
def __init__(self, name, value):
super(OpCode, self).__init__(name, value)
class TypeKind(LLVMEnumeration):
"""Represents an individual TypeKind enumeration."""
_value_map = {}
def __init__(self, name, value):
super(TypeKind, self).__init__(name, value)
class Linkage(LLVMEnumeration):
"""Represents an individual Linkage enumeration."""
_value_map = {}
def __init__(self, name, value):
super(Linkage, self).__init__(name, value)
class Visibility(LLVMEnumeration):
"""Represents an individual visibility enumeration."""
_value_map = {}
def __init__(self, name, value):
super(Visibility, self).__init__(name, value)
class CallConv(LLVMEnumeration):
"""Represents an individual calling convention enumeration."""
_value_map = {}
def __init__(self, name, value):
super(CallConv, self).__init__(name, value)
class IntPredicate(LLVMEnumeration):
"""Represents an individual IntPredicate enumeration."""
_value_map = {}
def __init__(self, name, value):
super(IntPredicate, self).__init__(name, value)
class RealPredicate(LLVMEnumeration):
"""Represents an individual RealPredicate enumeration."""
_value_map = {}
def __init__(self, name, value):
super(RealPredicate, self).__init__(name, value)
class LandingPadClauseTy(LLVMEnumeration):
"""Represents an individual LandingPadClauseTy enumeration."""
_value_map = {}
def __init__(self, name, value):
super(LandingPadClauseTy, self).__init__(name, value)
class MemoryBuffer(LLVMObject):
"""Represents an opaque memory buffer."""
@ -125,7 +199,7 @@ def __init__(self, module, name=None, context=None):
@classmethod
def CreateWithName(cls, module_id):
m = Module(lib.LLVMModuleCreateWithName(module_id))
c = Context.GetGlobalContext().take_ownership(m)
Context.GetGlobalContext().take_ownership(m)
return m
@property
@ -516,11 +590,27 @@ def register_library(library):
library.LLVMGetInstructionOpcode.restype = c_uint
def register_enumerations():
for name, value in enumerations.OpCodes:
OpCode.register(name, value)
if Enums:
return None
enums = [
(Attribute, enumerations.Attributes),
(OpCode, enumerations.OpCodes),
(TypeKind, enumerations.TypeKinds),
(Linkage, enumerations.Linkages),
(Visibility, enumerations.Visibility),
(CallConv, enumerations.CallConv),
(IntPredicate, enumerations.IntPredicate),
(RealPredicate, enumerations.RealPredicate),
(LandingPadClauseTy, enumerations.LandingPadClauseTy),
]
for enum_class, enum_spec in enums:
for name, value in enum_spec:
print name, value
enum_class.register(name, value)
return enums
def initialize_llvm():
c = Context.GetGlobalContext()
Context.GetGlobalContext()
p = PassRegistry()
lib.LLVMInitializeCore(p)
lib.LLVMInitializeTransformUtils(p)
@ -536,5 +626,5 @@ def initialize_llvm():
lib.LLVMInitializeTarget(p)
register_library(lib)
register_enumerations()
Enums = register_enumerations()
initialize_llvm()

View File

@ -78,7 +78,10 @@
"""
from ctypes import c_char_p
from ctypes import c_char
from ctypes import POINTER
from ctypes import c_uint64
from ctypes import string_at
from .common import CachedProperty
from .common import LLVMObject
@ -211,7 +214,12 @@ def contents(self):
if self.expired:
raise Exception('Section instance has expired.')
return lib.LLVMGetSectionContents(self)
siz = self.size
r = lib.LLVMGetSectionContents(self)
if r:
return string_at(r, siz)
return None
@CachedProperty
def address(self):
@ -310,14 +318,6 @@ def address(self):
return lib.LLVMGetSymbolAddress(self)
@CachedProperty
def file_offset(self):
"""The offset of this symbol in the file, in long bytes."""
if self.expired:
raise Exception('Symbol instance has expired.')
return lib.LLVMGetSymbolFileOffset(self)
@CachedProperty
def size(self):
"""The size of the symbol, in long bytes."""
@ -345,7 +345,6 @@ def cache(self):
"""Cache all cacheable properties."""
getattr(self, 'name')
getattr(self, 'address')
getattr(self, 'file_offset')
getattr(self, 'size')
def expire(self):
@ -471,7 +470,8 @@ def register_library(library):
library.LLVMGetSectionSize.restype = c_uint64
library.LLVMGetSectionContents.argtypes = [c_object_p]
library.LLVMGetSectionContents.restype = c_char_p
# Can't use c_char_p here as it isn't a NUL-terminated string.
library.LLVMGetSectionContents.restype = POINTER(c_char)
library.LLVMGetSectionAddress.argtypes = [c_object_p]
library.LLVMGetSectionAddress.restype = c_uint64
@ -495,9 +495,6 @@ def register_library(library):
library.LLVMGetSymbolAddress.argtypes = [Symbol]
library.LLVMGetSymbolAddress.restype = c_uint64
library.LLVMGetSymbolFileOffset.argtypes = [Symbol]
library.LLVMGetSymbolFileOffset.restype = c_uint64
library.LLVMGetSymbolSize.argtypes = [Symbol]
library.LLVMGetSymbolSize.restype = c_uint64

View File

@ -1,20 +1,30 @@
from .base import TestBase
from ..core import OpCode
from ..core import MemoryBuffer
from ..core import PassRegistry
from ..core import Context
from ..core import Module
from ..core import Enums
from ..core import OpCode
from ..bit_reader import parse_bitcode
class TestCore(TestBase):
def test_opcode(self):
self.assertTrue(hasattr(OpCode, 'Ret'))
self.assertTrue(isinstance(OpCode.Ret, OpCode))
self.assertEqual(OpCode.Ret.value, 1)
def test_enumerations(self):
for enum_cls, enum_spec in Enums:
for enum_name, enum_value in enum_spec:
# First make sure that enum_cls has the name of the enum as an
# attribute. People will access these values as
# EnumCls.EnumName.
self.assertTrue(hasattr(enum_cls, enum_name))
v_attr = getattr(enum_cls, enum_name)
self.assertTrue(isinstance(v_attr, enum_cls))
op = OpCode.from_value(1)
self.assertTrue(isinstance(op, OpCode))
self.assertEqual(op, OpCode.Ret)
# Then make sure that the value returned for this attribute is
# correct in both ways.
self.assertEqual(v_attr.value, enum_value)
e = enum_cls.from_value(enum_value)
self.assertTrue(isinstance(e, enum_cls))
self.assertEqual(e, v_attr)
def test_memory_buffer_create_from_file(self):
source = self.get_test_file()
@ -61,7 +71,7 @@ def test_module_print_module_to_file(self):
target = "thumbv7-apple-ios5.0.0"
m.target = target
m.print_module_to_file("test2.ll")
def test_module_function_iteration(self):
m = parse_bitcode(MemoryBuffer(filename=self.get_test_bc()))
i = 0
@ -81,19 +91,19 @@ def test_module_function_iteration(self):
def test_function_basicblock_iteration(self):
m = parse_bitcode(MemoryBuffer(filename=self.get_test_bc()))
i = 0
bb_list = ['b1', 'b2', 'end']
f = m.first
while f.name != "f6":
f = f.next
# Forward
for bb in f:
self.assertEqual(bb.name, bb_list[i])
bb.dump()
i += 1
# Backwards
for bb in reversed(f):
i -= 1
@ -103,12 +113,12 @@ def test_function_basicblock_iteration(self):
def test_basicblock_instruction_iteration(self):
m = parse_bitcode(MemoryBuffer(filename=self.get_test_bc()))
i = 0
inst_list = [('arg1', OpCode.ExtractValue),
('arg2', OpCode.ExtractValue),
('', OpCode.Call),
('', OpCode.Ret)]
bb = m.first.first
# Forward

View File

@ -16,9 +16,9 @@ def test_basic(self):
self.assertEqual(count, 3)
self.assertEqual(s, '\tjcxz\t-127')
def test_nonexistant_triple(self):
def test_nonexistent_triple(self):
with self.assertRaisesRegexp(Exception, "Could not obtain disassembler for triple"):
Disassembler("nonexistant-triple-raises")
Disassembler("nonexistent-triple-raises")
def test_get_instructions(self):
sequence = '\x67\xe3\x81\x01\xc7' # jcxz -127; addl %eax, %edi

View File

@ -23,6 +23,7 @@ def test_get_sections(self):
assert isinstance(section.size, long)
assert isinstance(section.contents, str)
assert isinstance(section.address, long)
assert len(section.contents) == section.size
self.assertGreater(count, 0)
@ -39,7 +40,6 @@ def test_get_symbols(self):
assert isinstance(symbol.name, str)
assert isinstance(symbol.address, long)
assert isinstance(symbol.size, long)
assert isinstance(symbol.file_offset, long)
self.assertGreater(count, 0)

12
cmake/Makefile Normal file
View File

@ -0,0 +1,12 @@
##===- cmake/Makefile --------------------------------------*- Makefile -*-===##
#
# The LLVM Compiler Infrastructure
#
# This file is distributed under the University of Illinois Open Source
# License. See LICENSE.TXT for details.
#
##===----------------------------------------------------------------------===##
LEVEL = ..
DIRS := modules
include $(LEVEL)/Makefile.common

View File

@ -11,10 +11,17 @@ include(CheckFunctionExists)
include(CheckCXXSourceCompiles)
include(TestBigEndian)
include(HandleLLVMStdlib)
if( UNIX AND NOT BEOS )
# Used by check_symbol_exists:
set(CMAKE_REQUIRED_LIBRARIES m)
endif()
# x86_64 FreeBSD 9.2 requires libcxxrt to be specified explicitly.
if( CMAKE_SYSTEM MATCHES "FreeBSD-9.2-RELEASE" AND
CMAKE_SIZEOF_VOID_P EQUAL 8 )
list(APPEND CMAKE_REQUIRED_LIBRARIES "cxxrt")
endif()
# Helper macros and functions
macro(add_cxx_include result files)
@ -49,7 +56,6 @@ check_include_file(ndir.h HAVE_NDIR_H)
if( NOT PURE_WINDOWS )
check_include_file(pthread.h HAVE_PTHREAD_H)
endif()
check_include_file(sanitizer/msan_interface.h HAVE_SANITIZER_MSAN_INTERFACE_H)
check_include_file(signal.h HAVE_SIGNAL_H)
check_include_file(stdint.h HAVE_STDINT_H)
check_include_file(sys/dir.h HAVE_SYS_DIR_H)
@ -97,6 +103,7 @@ if( NOT PURE_WINDOWS )
else()
set(HAVE_LIBZ 0)
endif()
check_library_exists(edit el_init "" HAVE_LIBEDIT)
if(LLVM_ENABLE_TERMINFO)
set(HAVE_TERMINFO 0)
foreach(library tinfo terminfo curses ncurses ncursesw)
@ -114,7 +121,7 @@ if( NOT PURE_WINDOWS )
endif()
# function checks
check_symbol_exists(arc4random "stdlib.h" HAVE_ARC4RANDOM)
check_symbol_exists(arc4random "stdlib.h" HAVE_DECL_ARC4RANDOM)
check_symbol_exists(backtrace "execinfo.h" HAVE_BACKTRACE)
check_symbol_exists(getpagesize unistd.h HAVE_GETPAGESIZE)
check_symbol_exists(getrusage sys/resource.h HAVE_GETRUSAGE)
@ -245,15 +252,9 @@ function(llvm_find_program name)
endif(LLVM_PATH_${NAME})
endfunction()
llvm_find_program(gv)
llvm_find_program(circo)
llvm_find_program(twopi)
llvm_find_program(neato)
llvm_find_program(fdp)
llvm_find_program(dot)
llvm_find_program(dotty)
llvm_find_program(xdot xdot.py)
llvm_find_program(Graphviz)
if (LLVM_ENABLE_DOXYGEN)
llvm_find_program(dot)
endif ()
if( LLVM_ENABLE_FFI )
find_path(FFI_INCLUDE_PATH ffi.h PATHS ${FFI_INCLUDE_DIR})
@ -297,27 +298,6 @@ else()
set(ENABLE_PIC 0)
endif()
find_package(LibXml2)
if (LIBXML2_FOUND)
set(CLANG_HAVE_LIBXML 1)
# When cross-compiling, liblzma is not detected as a dependency for libxml2,
# which makes linking c-index-test fail. But for native builds, all libraries
# are installed and checked by CMake before Makefiles are generated and everything
# works according to the plan. However, if a -llzma is added to native builds,
# an additional requirement on the static liblzma.a is required, but will not
# be checked by CMake, breaking native compilation.
# Since this is only pertinent to cross-compilations, and there's no way CMake
# can check for every foreign library on every OS, we add the dep and warn the dev.
if ( CMAKE_CROSSCOMPILING )
if (NOT PC_LIBXML_VERSION VERSION_LESS "2.8.0")
message(STATUS "Adding LZMA as a dep to XML2 for cross-compilation, make sure liblzma.a is available.")
set(LIBXML2_LIBRARIES ${LIBXML2_LIBRARIES} "-llzma")
endif ()
endif ()
endif ()
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-Wno-variadic-macros" SUPPORTS_NO_VARIADIC_MACROS_FLAG)
set(USE_NO_MAYBE_UNINITIALIZED 0)
@ -366,6 +346,8 @@ elseif (LLVM_NATIVE_ARCH MATCHES "powerpc")
set(LLVM_NATIVE_ARCH PowerPC)
elseif (LLVM_NATIVE_ARCH MATCHES "aarch64")
set(LLVM_NATIVE_ARCH AArch64)
elseif (LLVM_NATIVE_ARCH MATCHES "arm64")
set(LLVM_NATIVE_ARCH AArch64)
elseif (LLVM_NATIVE_ARCH MATCHES "arm")
set(LLVM_NATIVE_ARCH ARM)
elseif (LLVM_NATIVE_ARCH MATCHES "mips")
@ -479,7 +461,7 @@ set(LLVM_PREFIX ${CMAKE_INSTALL_PREFIX})
if (LLVM_ENABLE_DOXYGEN)
message(STATUS "Doxygen enabled.")
find_package(Doxygen)
find_package(Doxygen REQUIRED)
if (DOXYGEN_FOUND)
# If we find doxygen and we want to enable doxygen by default create a
@ -498,3 +480,13 @@ if (LLVM_ENABLE_DOXYGEN)
else()
message(STATUS "Doxygen disabled.")
endif()
if (LLVM_ENABLE_SPHINX)
message(STATUS "Sphinx enabled.")
find_package(Sphinx REQUIRED)
if (LLVM_BUILD_DOCS)
add_custom_target(sphinx ALL)
endif()
else()
message(STATUS "Sphinx disabled.")
endif()

View File

@ -2,16 +2,306 @@ include(LLVMParseArguments)
include(LLVMProcessSources)
include(LLVM-Config)
macro(add_llvm_library name)
llvm_process_sources( ALL_FILES ${ARGN} )
add_library( ${name} ${ALL_FILES} )
set_property( GLOBAL APPEND PROPERTY LLVM_LIBS ${name} )
if( LLVM_COMMON_DEPENDS )
add_dependencies( ${name} ${LLVM_COMMON_DEPENDS} )
endif( LLVM_COMMON_DEPENDS )
function(llvm_update_compile_flags name)
get_property(sources TARGET ${name} PROPERTY SOURCES)
if("${sources}" MATCHES "\\.c(;|$)")
set(update_src_props ON)
endif()
if( BUILD_SHARED_LIBS )
llvm_config( ${name} ${LLVM_LINK_COMPONENTS} )
# LLVM_REQUIRES_EH is an internal flag that individual
# targets can use to force EH
if(LLVM_REQUIRES_EH OR LLVM_ENABLE_EH)
if(NOT (LLVM_REQUIRES_RTTI OR LLVM_ENABLE_RTTI))
message(AUTHOR_WARNING "Exception handling requires RTTI. Enabling RTTI for ${name}")
set(LLVM_REQUIRES_RTTI ON)
endif()
else()
if(LLVM_COMPILER_IS_GCC_COMPATIBLE)
list(APPEND LLVM_COMPILE_FLAGS "-fno-exceptions")
elseif(MSVC)
list(APPEND LLVM_COMPILE_DEFINITIONS _HAS_EXCEPTIONS=0)
list(APPEND LLVM_COMPILE_FLAGS "/EHs-c-")
endif()
endif()
# LLVM_REQUIRES_RTTI is an internal flag that individual
# targets can use to force RTTI
if(NOT (LLVM_REQUIRES_RTTI OR LLVM_ENABLE_RTTI))
list(APPEND LLVM_COMPILE_DEFINITIONS GTEST_HAS_RTTI=0)
if (LLVM_COMPILER_IS_GCC_COMPATIBLE)
list(APPEND LLVM_COMPILE_FLAGS "-fno-rtti")
elseif (MSVC)
list(APPEND LLVM_COMPILE_FLAGS "/GR-")
endif ()
endif()
# Assume that;
# - LLVM_COMPILE_FLAGS is list.
# - PROPERTY COMPILE_FLAGS is string.
string(REPLACE ";" " " target_compile_flags "${LLVM_COMPILE_FLAGS}")
if(update_src_props)
foreach(fn ${sources})
get_filename_component(suf ${fn} EXT)
if("${suf}" STREQUAL ".cpp")
set_property(SOURCE ${fn} APPEND_STRING PROPERTY
COMPILE_FLAGS "${target_compile_flags}")
endif()
endforeach()
else()
# Update target props, since all sources are C++.
set_property(TARGET ${name} APPEND_STRING PROPERTY
COMPILE_FLAGS "${target_compile_flags}")
endif()
set_property(TARGET ${name} APPEND PROPERTY COMPILE_DEFINITIONS ${LLVM_COMPILE_DEFINITIONS})
endfunction()
function(add_llvm_symbol_exports target_name export_file)
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(native_export_file "${target_name}.exports")
add_custom_command(OUTPUT ${native_export_file}
COMMAND sed -e "s/^/_/" < ${export_file} > ${native_export_file}
DEPENDS ${export_file}
VERBATIM
COMMENT "Creating export file for ${target_name}")
set_property(TARGET ${target_name} APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,-exported_symbols_list,${CMAKE_CURRENT_BINARY_DIR}/${native_export_file}")
elseif(LLVM_HAVE_LINK_VERSION_SCRIPT)
# Gold and BFD ld require a version script rather than a plain list.
set(native_export_file "${target_name}.exports")
# FIXME: Don't write the "local:" line on OpenBSD.
add_custom_command(OUTPUT ${native_export_file}
COMMAND echo "{" > ${native_export_file}
COMMAND grep -q "[[:alnum:]]" ${export_file} && echo " global:" >> ${native_export_file} || :
COMMAND sed -e "s/$/;/" -e "s/^/ /" < ${export_file} >> ${native_export_file}
COMMAND echo " local: *;" >> ${native_export_file}
COMMAND echo "};" >> ${native_export_file}
DEPENDS ${export_file}
VERBATIM
COMMENT "Creating export file for ${target_name}")
set_property(TARGET ${target_name} APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,--version-script,${CMAKE_CURRENT_BINARY_DIR}/${native_export_file}")
else()
set(native_export_file "${target_name}.def")
set(CAT "type")
if(CYGWIN)
set(CAT "cat")
endif()
# Using ${export_file} in add_custom_command directly confuses cmd.exe.
file(TO_NATIVE_PATH ${export_file} export_file_backslashes)
add_custom_command(OUTPUT ${native_export_file}
COMMAND ${CMAKE_COMMAND} -E echo "EXPORTS" > ${native_export_file}
COMMAND ${CAT} ${export_file_backslashes} >> ${native_export_file}
DEPENDS ${export_file}
VERBATIM
COMMENT "Creating export file for ${target_name}")
if(CYGWIN OR MINGW)
set_property(TARGET ${target_name} APPEND_STRING PROPERTY
LINK_FLAGS " ${CMAKE_CURRENT_BINARY_DIR}/${native_export_file}")
else()
set_property(TARGET ${target_name} APPEND_STRING PROPERTY
LINK_FLAGS " /DEF:${CMAKE_CURRENT_BINARY_DIR}/${native_export_file}")
endif()
endif()
add_custom_target(${target_name}_exports DEPENDS ${native_export_file})
set_target_properties(${target_name}_exports PROPERTIES FOLDER "Misc")
get_property(srcs TARGET ${target_name} PROPERTY SOURCES)
foreach(src ${srcs})
get_filename_component(extension ${src} EXT)
if(extension STREQUAL ".cpp")
set(first_source_file ${src})
break()
endif()
endforeach()
# Force re-linking when the exports file changes. Actually, it
# forces recompilation of the source file. The LINK_DEPENDS target
# property only works for makefile-based generators.
# FIXME: This is not safe because this will create the same target
# ${native_export_file} in several different file:
# - One where we emitted ${target_name}_exports
# - One where we emitted the build command for the following object.
# set_property(SOURCE ${first_source_file} APPEND PROPERTY
# OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${native_export_file})
set_property(DIRECTORY APPEND
PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${native_export_file})
add_dependencies(${target_name} ${target_name}_exports)
# Add dependency to *_exports later -- CMake issue 14747
list(APPEND LLVM_COMMON_DEPENDS ${target_name}_exports)
set(LLVM_COMMON_DEPENDS ${LLVM_COMMON_DEPENDS} PARENT_SCOPE)
endfunction(add_llvm_symbol_exports)
function(add_dead_strip target_name)
if(NOT LLVM_NO_DEAD_STRIP)
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set_property(TARGET ${target_name} APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,-dead_strip")
elseif(NOT WIN32)
# Object files are compiled with -ffunction-data-sections.
set_property(TARGET ${target_name} APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,--gc-sections")
endif()
endif()
endfunction(add_dead_strip)
# Set each output directory according to ${CMAKE_CONFIGURATION_TYPES}.
# Note: Don't set variables CMAKE_*_OUTPUT_DIRECTORY any more,
# or a certain builder, for eaxample, msbuild.exe, would be confused.
function(set_output_directory target bindir libdir)
# Do nothing if *_OUTPUT_INTDIR is empty.
if("${bindir}" STREQUAL "")
return()
endif()
# moddir -- corresponding to LIBRARY_OUTPUT_DIRECTORY.
# It affects output of add_library(MODULE).
if(WIN32 OR CYGWIN)
# DLL platform
set(moddir ${bindir})
else()
set(moddir ${libdir})
endif()
if(NOT "${CMAKE_CFG_INTDIR}" STREQUAL ".")
foreach(build_mode ${CMAKE_CONFIGURATION_TYPES})
string(TOUPPER "${build_mode}" CONFIG_SUFFIX)
string(REPLACE ${CMAKE_CFG_INTDIR} ${build_mode} bi ${bindir})
string(REPLACE ${CMAKE_CFG_INTDIR} ${build_mode} li ${libdir})
string(REPLACE ${CMAKE_CFG_INTDIR} ${build_mode} mi ${moddir})
set_target_properties(${target} PROPERTIES "RUNTIME_OUTPUT_DIRECTORY_${CONFIG_SUFFIX}" ${bi})
set_target_properties(${target} PROPERTIES "ARCHIVE_OUTPUT_DIRECTORY_${CONFIG_SUFFIX}" ${li})
set_target_properties(${target} PROPERTIES "LIBRARY_OUTPUT_DIRECTORY_${CONFIG_SUFFIX}" ${mi})
endforeach()
else()
set_target_properties(${target} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${bindir})
set_target_properties(${target} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${libdir})
set_target_properties(${target} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${moddir})
endif()
endfunction()
# llvm_add_library(name sources...
# SHARED;STATIC
# STATIC by default w/o BUILD_SHARED_LIBS.
# SHARED by default w/ BUILD_SHARED_LIBS.
# MODULE
# Target ${name} might not be created on unsupported platforms.
# Check with "if(TARGET ${name})".
# OUTPUT_NAME name
# Corresponds to OUTPUT_NAME in target properties.
# DEPENDS targets...
# Same semantics as add_dependencies().
# LINK_COMPONENTS components...
# Same as the variable LLVM_LINK_COMPONENTS.
# LINK_LIBS lib_targets...
# Same semantics as target_link_libraries().
# ADDITIONAL_HEADERS
# May specify header files for IDE generators.
# )
function(llvm_add_library name)
cmake_parse_arguments(ARG
"MODULE;SHARED;STATIC"
"OUTPUT_NAME"
"ADDITIONAL_HEADERS;DEPENDS;LINK_COMPONENTS;LINK_LIBS;OBJLIBS"
${ARGN})
list(APPEND LLVM_COMMON_DEPENDS ${ARG_DEPENDS})
if(ARG_ADDITIONAL_HEADERS)
# Pass through ADDITIONAL_HEADERS.
set(ARG_ADDITIONAL_HEADERS ADDITIONAL_HEADERS ${ARG_ADDITIONAL_HEADERS})
endif()
if(ARG_OBJLIBS)
set(ALL_FILES ${ARG_OBJLIBS})
else()
llvm_process_sources(ALL_FILES ${ARG_UNPARSED_ARGUMENTS} ${ARG_ADDITIONAL_HEADERS})
endif()
if(ARG_MODULE)
if(ARG_SHARED OR ARG_STATIC)
message(WARNING "MODULE with SHARED|STATIC doesn't make sense.")
endif()
if(NOT LLVM_ENABLE_PLUGINS)
message(STATUS "${name} ignored -- Loadable modules not supported on this platform.")
return()
endif()
else()
if(BUILD_SHARED_LIBS AND NOT ARG_STATIC)
set(ARG_SHARED TRUE)
endif()
if(NOT ARG_SHARED)
set(ARG_STATIC TRUE)
endif()
endif()
# Generate objlib
if(ARG_SHARED AND ARG_STATIC)
# Generate an obj library for both targets.
set(obj_name "obj.${name}")
add_library(${obj_name} OBJECT EXCLUDE_FROM_ALL
${ALL_FILES}
)
llvm_update_compile_flags(${obj_name})
set(ALL_FILES "$<TARGET_OBJECTS:${obj_name}>")
# Do add_dependencies(obj) later due to CMake issue 14747.
list(APPEND objlibs ${obj_name})
set_target_properties(${obj_name} PROPERTIES FOLDER "Object Libraries")
endif()
if(ARG_SHARED AND ARG_STATIC)
# static
set(name_static "${name}_static")
if(ARG_OUTPUT_NAME)
set(output_name OUTPUT_NAME "${ARG_OUTPUT_NAME}")
endif()
# DEPENDS has been appended to LLVM_COMMON_LIBS.
llvm_add_library(${name_static} STATIC
${output_name}
OBJLIBS ${ALL_FILES} # objlib
LINK_LIBS ${ARG_LINK_LIBS}
LINK_COMPONENTS ${ARG_LINK_COMPONENTS}
)
# FIXME: Add name_static to anywhere in TARGET ${name}'s PROPERTY.
set(ARG_STATIC)
endif()
if(ARG_MODULE)
add_library(${name} MODULE ${ALL_FILES})
elseif(ARG_SHARED)
add_library(${name} SHARED ${ALL_FILES})
else()
add_library(${name} STATIC ${ALL_FILES})
endif()
set_output_directory(${name} ${LLVM_RUNTIME_OUTPUT_INTDIR} ${LLVM_LIBRARY_OUTPUT_INTDIR})
llvm_update_compile_flags(${name})
add_dead_strip( ${name} )
if(ARG_OUTPUT_NAME)
set_target_properties(${name}
PROPERTIES
OUTPUT_NAME ${ARG_OUTPUT_NAME}
)
endif()
if(ARG_MODULE)
set_target_properties(${name} PROPERTIES
PREFIX ""
SUFFIX ${LLVM_PLUGIN_EXT}
)
endif()
if(ARG_SHARED)
if(WIN32)
set_target_properties(${name} PROPERTIES
PREFIX ""
)
endif()
if (MSVC)
set_target_properties(${name}
PROPERTIES
@ -19,20 +309,11 @@ macro(add_llvm_library name)
endif ()
endif()
# Ensure that the system libraries always comes last on the
# list. Without this, linking the unit tests on MinGW fails.
link_system_libs( ${name} )
if( EXCLUDE_FROM_ALL )
set_target_properties( ${name} PROPERTIES EXCLUDE_FROM_ALL ON)
else()
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ${name} STREQUAL "LTO")
install(TARGETS ${name}
LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX})
if(ARG_MODULE OR ARG_SHARED)
if (LLVM_EXPORTED_SYMBOL_FILE)
add_llvm_symbol_exports( ${name} ${LLVM_EXPORTED_SYMBOL_FILE} )
endif()
endif()
set_target_properties(${name} PROPERTIES FOLDER "Libraries")
# Add the explicit dependency information for this library.
#
@ -40,43 +321,103 @@ macro(add_llvm_library name)
# name, but using get_property(... SET) doesn't suffice to determine if a
# property has been set to an empty value.
get_property(lib_deps GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_${name})
target_link_libraries(${name} ${lib_deps})
llvm_map_components_to_libnames(llvm_libs
${ARG_LINK_COMPONENTS}
${LLVM_LINK_COMPONENTS}
)
if(CMAKE_VERSION VERSION_LESS 2.8.12)
# Link libs w/o keywords, assuming PUBLIC.
target_link_libraries(${name}
${ARG_LINK_LIBS}
${lib_deps}
${llvm_libs}
)
elseif(ARG_STATIC)
target_link_libraries(${name} INTERFACE
${ARG_LINK_LIBS}
${lib_deps}
${llvm_libs}
)
elseif((CYGWIN OR WIN32) AND ARG_SHARED)
# Win32's import library may be unaware of its dependent libs.
target_link_libraries(${name} PRIVATE
${ARG_LINK_LIBS}
${lib_deps}
${llvm_libs}
)
elseif(ARG_SHARED AND BUILD_SHARED_LIBS)
# FIXME: It may be PRIVATE since SO knows its dependent libs.
target_link_libraries(${name} PUBLIC
${ARG_LINK_LIBS}
${lib_deps}
${llvm_libs}
)
else()
# MODULE|SHARED
target_link_libraries(${name} PRIVATE
${ARG_LINK_LIBS}
${lib_deps}
${llvm_libs}
)
endif()
if(LLVM_COMMON_DEPENDS)
add_dependencies(${name} ${LLVM_COMMON_DEPENDS})
# Add dependencies also to objlibs.
# CMake issue 14747 -- add_dependencies() might be ignored to objlib's user.
foreach(objlib ${objlibs})
add_dependencies(${objlib} ${LLVM_COMMON_DEPENDS})
endforeach()
endif()
endfunction()
macro(add_llvm_library name)
if( BUILD_SHARED_LIBS )
llvm_add_library(${name} SHARED ${ARGN})
else()
llvm_add_library(${name} ${ARGN})
endif()
set_property( GLOBAL APPEND PROPERTY LLVM_LIBS ${name} )
if( EXCLUDE_FROM_ALL )
set_target_properties( ${name} PROPERTIES EXCLUDE_FROM_ALL ON)
else()
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ${name} STREQUAL "LTO")
install(TARGETS ${name}
EXPORT LLVMExports
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX})
endif()
set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS ${name})
endif()
set_target_properties(${name} PROPERTIES FOLDER "Libraries")
endmacro(add_llvm_library name)
macro(add_llvm_loadable_module name)
if( NOT LLVM_ON_UNIX OR CYGWIN )
message(STATUS "Loadable modules not supported on this platform.
${name} ignored.")
llvm_add_library(${name} MODULE ${ARGN})
if(NOT TARGET ${name})
# Add empty "phony" target
add_custom_target(${name})
else()
llvm_process_sources( ALL_FILES ${ARGN} )
if (MODULE)
set(libkind MODULE)
else()
set(libkind SHARED)
endif()
add_library( ${name} ${libkind} ${ALL_FILES} )
set_target_properties( ${name} PROPERTIES PREFIX "" )
llvm_config( ${name} ${LLVM_LINK_COMPONENTS} )
link_system_libs( ${name} )
if (APPLE)
# Darwin-specific linker flags for loadable modules.
set_target_properties(${name} PROPERTIES
LINK_FLAGS "-Wl,-flat_namespace -Wl,-undefined -Wl,suppress")
endif()
if( EXCLUDE_FROM_ALL )
set_target_properties( ${name} PROPERTIES EXCLUDE_FROM_ALL ON)
else()
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
if(WIN32 OR CYGWIN)
# DLL platform
set(dlldir "bin")
else()
set(dlldir "lib${LLVM_LIBDIR_SUFFIX}")
endif()
install(TARGETS ${name}
LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
EXPORT LLVMExports
LIBRARY DESTINATION ${dlldir}
ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX})
endif()
set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS ${name})
endif()
endif()
@ -91,12 +432,19 @@ macro(add_llvm_executable name)
else()
add_executable(${name} ${ALL_FILES})
endif()
llvm_update_compile_flags(${name})
add_dead_strip( ${name} )
if (LLVM_EXPORTED_SYMBOL_FILE)
add_llvm_symbol_exports( ${name} ${LLVM_EXPORTED_SYMBOL_FILE} )
endif(LLVM_EXPORTED_SYMBOL_FILE)
set(EXCLUDE_FROM_ALL OFF)
set_output_directory(${name} ${LLVM_RUNTIME_OUTPUT_INTDIR} ${LLVM_LIBRARY_OUTPUT_INTDIR})
llvm_config( ${name} ${LLVM_LINK_COMPONENTS} )
if( LLVM_COMMON_DEPENDS )
add_dependencies( ${name} ${LLVM_COMMON_DEPENDS} )
endif( LLVM_COMMON_DEPENDS )
link_system_libs( ${name} )
endmacro(add_llvm_executable name)
@ -106,7 +454,6 @@ set (LLVM_TOOLCHAIN_TOOLS
)
macro(add_llvm_tool name)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LLVM_TOOLS_BINARY_DIR})
if( NOT LLVM_BUILD_TOOLS )
set(EXCLUDE_FROM_ALL ON)
endif()
@ -115,15 +462,19 @@ macro(add_llvm_tool name)
list(FIND LLVM_TOOLCHAIN_TOOLS ${name} LLVM_IS_${name}_TOOLCHAIN_TOOL)
if (LLVM_IS_${name}_TOOLCHAIN_TOOL GREATER -1 OR NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
if( LLVM_BUILD_TOOLS )
install(TARGETS ${name} RUNTIME DESTINATION bin)
install(TARGETS ${name}
EXPORT LLVMExports
RUNTIME DESTINATION bin)
endif()
endif()
if( LLVM_BUILD_TOOLS )
set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS ${name})
endif()
set_target_properties(${name} PROPERTIES FOLDER "Tools")
endmacro(add_llvm_tool name)
macro(add_llvm_example name)
# set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LLVM_EXAMPLES_BINARY_DIR})
if( NOT LLVM_BUILD_EXAMPLES )
set(EXCLUDE_FROM_ALL ON)
endif()
@ -145,14 +496,14 @@ macro(add_llvm_target target_name)
include_directories(BEFORE
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR})
add_llvm_library(LLVM${target_name} ${ARGN} ${TABLEGEN_OUTPUT})
add_llvm_library(LLVM${target_name} ${ARGN})
set( CURRENT_LLVM_TARGET LLVM${target_name} )
endmacro(add_llvm_target)
# Add external project that may want to be built as part of llvm such as Clang,
# lld, and Polly. This adds two options. One for the source directory of the
# project, which defaults to ${CMAKE_CURRENT_SOURCE_DIR}/${name}. Another to
# enable or disable building it with everthing else.
# enable or disable building it with everything else.
# Additional parameter can be specified as the name of directory.
macro(add_llvm_external_project name)
set(add_llvm_external_dir "${ARGN}")
@ -204,12 +555,30 @@ endfunction(add_llvm_implicit_external_projects)
# Generic support for adding a unittest.
function(add_unittest test_suite test_name)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
if( NOT LLVM_BUILD_TESTS )
set(EXCLUDE_FROM_ALL ON)
endif()
# Visual Studio 2012 only supports up to 8 template parameters in
# std::tr1::tuple by default, but gtest requires 10
if (MSVC AND MSVC_VERSION EQUAL 1700)
list(APPEND LLVM_COMPILE_DEFINITIONS _VARIADIC_MAX=10)
endif ()
include_directories(${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include)
if (NOT LLVM_ENABLE_THREADS)
list(APPEND LLVM_COMPILE_DEFINITIONS GTEST_HAS_PTHREAD=0)
endif ()
if (SUPPORTS_NO_VARIADIC_MACROS_FLAG)
list(APPEND LLVM_COMPILE_FLAGS "-Wno-variadic-macros")
endif ()
set(LLVM_REQUIRES_RTTI OFF)
add_llvm_executable(${test_name} ${ARGN})
set(outdir ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR})
set_output_directory(${test_name} ${outdir} ${outdir})
target_link_libraries(${test_name}
gtest
gtest_main
@ -221,34 +590,10 @@ function(add_unittest test_suite test_name)
if (NOT ${test_suite_folder} STREQUAL "NOTFOUND")
set_property(TARGET ${test_name} PROPERTY FOLDER "${test_suite_folder}")
endif ()
# Visual Studio 2012 only supports up to 8 template parameters in
# std::tr1::tuple by default, but gtest requires 10
if (MSVC AND MSVC_VERSION EQUAL 1700)
set_property(TARGET ${test_name} APPEND PROPERTY COMPILE_DEFINITIONS _VARIADIC_MAX=10)
endif ()
include_directories(${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include)
set_property(TARGET ${test_name} APPEND PROPERTY COMPILE_DEFINITIONS GTEST_HAS_RTTI=0)
if (NOT LLVM_ENABLE_THREADS)
set_property(TARGET ${test_name} APPEND PROPERTY COMPILE_DEFINITIONS GTEST_HAS_PTHREAD=0)
endif ()
get_property(target_compile_flags TARGET ${test_name} PROPERTY COMPILE_FLAGS)
if (LLVM_COMPILER_IS_GCC_COMPATIBLE)
set(target_compile_flags "${target_compile_flags} -fno-rtti")
elseif (MSVC)
llvm_replace_compiler_option(target_compile_flags "/GR" "/GR-")
endif ()
if (SUPPORTS_NO_VARIADIC_MACROS_FLAG)
set(target_compile_flags "${target_compile_flags} -Wno-variadic-macros")
endif ()
set_property(TARGET ${test_name} PROPERTY COMPILE_FLAGS "${target_compile_flags}")
endfunction()
# This function provides an automatic way to 'configure'-like generate a file
# based on a set of common and custom variables, specifically targetting the
# based on a set of common and custom variables, specifically targeting the
# variables needed for the 'lit.site.cfg' files. This function bundles the
# common variables that any Lit instance is likely to need, and custom
# variables can be passed in.
@ -259,33 +604,31 @@ function(configure_lit_site_cfg input output)
set(TARGETS_TO_BUILD ${TARGETS_BUILT})
set(SHLIBEXT "${LTDL_SHLIB_EXT}")
set(SHLIBDIR "${LLVM_BINARY_DIR}/lib/${CMAKE_CFG_INTDIR}")
if(BUILD_SHARED_LIBS)
set(LLVM_SHARED_LIBS_ENABLED "1")
else()
set(LLVM_SHARED_LIBS_ENABLED "0")
endif(BUILD_SHARED_LIBS)
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(SHLIBPATH_VAR "DYLD_LIBRARY_PATH")
else() # Default for all other unix like systems.
# CMake hardcodes the library locaction using rpath.
# Therefore LD_LIBRARY_PATH is not required to run binaries in the
# build dir. We pass it anyways.
set(SHLIBPATH_VAR "LD_LIBRARY_PATH")
endif()
# Configuration-time: See Unit/lit.site.cfg.in
set(LLVM_BUILD_MODE "%(build_mode)s")
if (CMAKE_CFG_INTDIR STREQUAL ".")
set(LLVM_BUILD_MODE ".")
else ()
set(LLVM_BUILD_MODE "%(build_mode)s")
endif ()
# They below might not be the build tree but provided binary tree.
set(LLVM_SOURCE_DIR ${LLVM_MAIN_SRC_DIR})
set(LLVM_BINARY_DIR ${LLVM_BINARY_DIR})
set(LLVM_TOOLS_DIR "${LLVM_TOOLS_BINARY_DIR}/%(build_mode)s")
set(LLVM_LIBS_DIR "${LLVM_BINARY_DIR}/lib/%(build_mode)s")
string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLVM_TOOLS_DIR ${LLVM_TOOLS_BINARY_DIR})
string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLVM_LIBS_DIR ${LLVM_LIBRARY_DIR})
# SHLIBDIR points the build tree.
string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} SHLIBDIR "${LLVM_SHLIB_OUTPUT_INTDIR}")
set(PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE})
set(ENABLE_SHARED ${LLVM_SHARED_LIBS_ENABLED})
set(SHLIBPATH_VAR ${SHLIBPATH_VAR})
# FIXME: "ENABLE_SHARED" doesn't make sense, since it is used just for
# plugins. We may rename it.
if(LLVM_ENABLE_PLUGINS)
set(ENABLE_SHARED "1")
else()
set(ENABLE_SHARED "0")
endif()
if(LLVM_ENABLE_ASSERTIONS AND NOT MSVC_IDE)
set(ENABLE_ASSERTIONS "1")
@ -296,22 +639,6 @@ function(configure_lit_site_cfg input output)
set(HOST_OS ${CMAKE_SYSTEM_NAME})
set(HOST_ARCH ${CMAKE_SYSTEM_PROCESSOR})
if (CLANG_ENABLE_ARCMT)
set(ENABLE_CLANG_ARCMT "1")
else()
set(ENABLE_CLANG_ARCMT "0")
endif()
if (CLANG_ENABLE_REWRITER)
set(ENABLE_CLANG_REWRITER "1")
else()
set(ENABLE_CLANG_REWRITER "0")
endif()
if (CLANG_ENABLE_STATIC_ANALYZER)
set(ENABLE_CLANG_STATIC_ANALYZER "1")
else()
set(ENABLE_CLANG_STATIC_ANALYZER "0")
endif()
configure_file(${input} ${output} @ONLY)
endfunction()
@ -321,12 +648,15 @@ function(add_lit_target target comment)
parse_arguments(ARG "PARAMS;DEPENDS;ARGS" "" ${ARGN})
set(LIT_ARGS "${ARG_ARGS} ${LLVM_LIT_ARGS}")
separate_arguments(LIT_ARGS)
set(LIT_COMMAND
${PYTHON_EXECUTABLE}
${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py
--param build_mode=${CMAKE_CFG_INTDIR}
${LIT_ARGS}
)
if (NOT CMAKE_CFG_INTDIR STREQUAL ".")
list(APPEND LIT_ARGS --param build_mode=${CMAKE_CFG_INTDIR})
endif ()
if (LLVM_MAIN_SRC_DIR)
set (LIT_COMMAND ${PYTHON_EXECUTABLE} ${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py)
else()
find_program(LIT_COMMAND llvm-lit)
endif ()
list(APPEND LIT_COMMAND ${LIT_ARGS})
foreach(param ${ARG_PARAMS})
list(APPEND LIT_COMMAND --param ${param})
endforeach()
@ -338,9 +668,12 @@ function(add_lit_target target comment)
add_dependencies(${target} ${ARG_DEPENDS})
else()
add_custom_target(${target}
COMMAND cmake -E echo "${target} does nothing, no tools built.")
COMMAND ${CMAKE_COMMAND} -E echo "${target} does nothing, no tools built.")
message(STATUS "${target} does nothing.")
endif()
# Tests should be excluded from "Build Solution".
set_target_properties(${target} PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD ON)
endfunction()
# A function to add a set of lit test suites to be driven through 'check-*' targets.

View File

@ -0,0 +1,56 @@
# Handy function for creating the different Sphinx targets.
#
# ``builder`` should be one of the supported builders used by
# the sphinx-build command.
#
# ``project`` should be the project name
function (add_sphinx_target builder project)
set(SPHINX_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/${builder}")
set(SPHINX_DOC_TREE_DIR "${CMAKE_CURRENT_BINARY_DIR}/_doctrees")
set(SPHINX_TARGET_NAME docs-${project}-${builder})
add_custom_target(${SPHINX_TARGET_NAME}
COMMAND ${SPHINX_EXECUTABLE}
-b ${builder}
-d "${SPHINX_DOC_TREE_DIR}"
-q # Quiet: no output other than errors and warnings.
-W # Warnings are errors.
"${CMAKE_CURRENT_SOURCE_DIR}" # Source
"${SPHINX_BUILD_DIR}" # Output
COMMENT
"Generating ${builder} Sphinx documentation for ${project}")
# When "clean" target is run, remove the Sphinx build directory
set_property(DIRECTORY APPEND PROPERTY
ADDITIONAL_MAKE_CLEAN_FILES
"${SPHINX_BUILD_DIR}")
# We need to remove ${SPHINX_DOC_TREE_DIR} when make clean is run
# but we should only add this path once
get_property(_CURRENT_MAKE_CLEAN_FILES
DIRECTORY PROPERTY ADDITIONAL_MAKE_CLEAN_FILES)
list(FIND _CURRENT_MAKE_CLEAN_FILES "${SPHINX_DOC_TREE_DIR}" _INDEX)
if (_INDEX EQUAL -1)
set_property(DIRECTORY APPEND PROPERTY
ADDITIONAL_MAKE_CLEAN_FILES
"${SPHINX_DOC_TREE_DIR}")
endif()
if (LLVM_BUILD_DOCS)
add_dependencies(sphinx ${SPHINX_TARGET_NAME})
# Handle installation
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
if (builder STREQUAL man)
# FIXME: We might not ship all the tools that these man pages describe
install(DIRECTORY "${SPHINX_BUILD_DIR}/" # Slash indicates contents of
DESTINATION share/man/man1)
elseif (builder STREQUAL html)
install(DIRECTORY "${SPHINX_BUILD_DIR}"
DESTINATION "share/doc/${project}")
else()
message(WARNING Installation of ${builder} not supported)
endif()
endif()
endif()
endfunction()

View File

@ -1,33 +1,89 @@
set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/share/llvm/cmake")
set(LLVM_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
set(LLVM_INSTALL_PACKAGE_DIR share/llvm/cmake)
set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/${LLVM_INSTALL_PACKAGE_DIR}")
get_property(llvm_libs GLOBAL PROPERTY LLVM_LIBS)
get_property(LLVM_EXPORTS GLOBAL PROPERTY LLVM_EXPORTS)
export(TARGETS ${LLVM_EXPORTS}
FILE ${llvm_cmake_builddir}/LLVMExports.cmake)
foreach(lib ${llvm_libs})
get_property(LLVM_AVAILABLE_LIBS GLOBAL PROPERTY LLVM_LIBS)
foreach(lib ${LLVM_AVAILABLE_LIBS})
get_property(llvm_lib_deps GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_${lib})
set(all_llvm_lib_deps
"${all_llvm_lib_deps}\nset_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_${lib} ${llvm_lib_deps})")
endforeach(lib)
# Generate LLVMConfig.cmake for the build tree.
set(LLVM_CONFIG_CODE "
# LLVM_BUILD_* values available only from LLVM build tree.
set(LLVM_BUILD_BINARY_DIR \"${LLVM_BINARY_DIR}\")
set(LLVM_BUILD_LIBRARY_DIR \"${LLVM_LIBRARY_DIR}\")
set(LLVM_BUILD_MAIN_INCLUDE_DIR \"${LLVM_MAIN_INCLUDE_DIR}\")
set(LLVM_BUILD_MAIN_SRC_DIR \"${LLVM_MAIN_SRC_DIR}\")
")
set(LLVM_CONFIG_INCLUDE_DIRS
"${LLVM_MAIN_INCLUDE_DIR}"
"${LLVM_INCLUDE_DIR}"
)
set(LLVM_CONFIG_LIBRARY_DIRS
"${LLVM_LIBRARY_DIR}"
)
set(LLVM_CONFIG_CMAKE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
set(LLVM_CONFIG_TOOLS_BINARY_DIR "${LLVM_TOOLS_BINARY_DIR}")
set(LLVM_CONFIG_EXPORTS_FILE "${llvm_cmake_builddir}/LLVMExports.cmake")
configure_file(
LLVMConfig.cmake.in
${llvm_cmake_builddir}/LLVMConfig.cmake
@ONLY)
# For compatibility with projects that include(LLVMConfig)
# via CMAKE_MODULE_PATH, place API modules next to it.
# This should be removed in the future.
file(COPY .
DESTINATION ${llvm_cmake_builddir}
FILES_MATCHING PATTERN *.cmake
PATTERN .svn EXCLUDE
PATTERN CMakeFiles EXCLUDE
)
# Generate LLVMConfig.cmake for the install tree.
set(LLVM_CONFIG_CODE "
# Compute the installation prefix from this LLVMConfig.cmake file location.
get_filename_component(LLVM_INSTALL_PREFIX \"\${CMAKE_CURRENT_LIST_FILE}\" PATH)")
# Construct the proper number of get_filename_component(... PATH)
# calls to compute the installation prefix.
string(REGEX REPLACE "/" ";" _count "${LLVM_INSTALL_PACKAGE_DIR}")
foreach(p ${_count})
set(LLVM_CONFIG_CODE "${LLVM_CONFIG_CODE}
get_filename_component(LLVM_INSTALL_PREFIX \"\${LLVM_INSTALL_PREFIX}\" PATH)")
endforeach(p)
set(LLVM_CONFIG_INCLUDE_DIRS "\${LLVM_INSTALL_PREFIX}/include")
set(LLVM_CONFIG_LIBRARY_DIRS "\${LLVM_INSTALL_PREFIX}/lib")
set(LLVM_CONFIG_CMAKE_DIR "\${LLVM_INSTALL_PREFIX}/${LLVM_INSTALL_PACKAGE_DIR}")
set(LLVM_CONFIG_TOOLS_BINARY_DIR "\${LLVM_INSTALL_PREFIX}/bin")
set(LLVM_CONFIG_EXPORTS_FILE "\${LLVM_CMAKE_DIR}/LLVMExports.cmake")
configure_file(
LLVMConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/LLVMConfig.cmake
@ONLY)
# Generate LLVMConfigVersion.cmake for build and install tree.
configure_file(
LLVMConfigVersion.cmake.in
${llvm_cmake_builddir}/LLVMConfigVersion.cmake
@ONLY)
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
install(EXPORT LLVMExports DESTINATION ${LLVM_INSTALL_PACKAGE_DIR})
install(FILES
${llvm_cmake_builddir}/LLVMConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/LLVMConfig.cmake
${llvm_cmake_builddir}/LLVMConfigVersion.cmake
LLVM-Config.cmake
DESTINATION share/llvm/cmake)
DESTINATION ${LLVM_INSTALL_PACKAGE_DIR})
install(DIRECTORY .
DESTINATION share/llvm/cmake
DESTINATION ${LLVM_INSTALL_PACKAGE_DIR}
FILES_MATCHING PATTERN *.cmake
PATTERN .svn EXCLUDE
PATTERN LLVMConfig.cmake EXCLUDE

View File

@ -64,14 +64,14 @@ variables (LLVM_USE_CRT_DEBUG, etc) instead.")
string(TOUPPER "${build_type}" build)
if (NOT LLVM_USE_CRT_${build})
get_current_crt(LLVM_USE_CRT_${build}
MSVC_CRT_REGEX
CMAKE_CXX_FLAGS_${build})
MSVC_CRT_REGEX
CMAKE_CXX_FLAGS_${build})
set(LLVM_USE_CRT_${build}
"${LLVM_USE_CRT_${build}}"
CACHE STRING "Specify VC++ CRT to use for ${build_type} configurations."
FORCE)
"${LLVM_USE_CRT_${build}}"
CACHE STRING "Specify VC++ CRT to use for ${build_type} configurations."
FORCE)
set_property(CACHE LLVM_USE_CRT_${build}
PROPERTY STRINGS ;${${MSVC_CRT}})
PROPERTY STRINGS ;${${MSVC_CRT}})
endif(NOT LLVM_USE_CRT_${build})
endforeach(build_type)
@ -84,7 +84,7 @@ variables (LLVM_USE_CRT_DEBUG, etc) instead.")
list(FIND ${MSVC_CRT} ${LLVM_USE_CRT_${build}} idx)
if (idx LESS 0)
message(FATAL_ERROR
"Invalid value for LLVM_USE_CRT_${build}: ${LLVM_USE_CRT_${build}}. Valid options are one of: ${${MSVC_CRT}}")
"Invalid value for LLVM_USE_CRT_${build}: ${LLVM_USE_CRT_${build}}. Valid options are one of: ${${MSVC_CRT}}")
endif (idx LESS 0)
message(STATUS "Using ${build_type} VC++ CRT: ${LLVM_USE_CRT_${build}}")
endif()

View File

@ -0,0 +1,25 @@
# CMake find_package() Module for Sphinx documentation generator
# http://sphinx-doc.org/
#
# Example usage:
#
# find_package(Sphinx)
#
# If successful the following variables will be defined
# SPHINX_FOUND
# SPHINX_EXECUTABLE
find_program(SPHINX_EXECUTABLE
NAMES sphinx-build sphinx-build2
DOC "Path to sphinx-build executable")
# Handle REQUIRED and QUIET arguments
# this will also set SPHINX_FOUND to true if SPHINX_EXECUTABLE exists
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Sphinx
"Failed to locate sphinx-build executable"
SPHINX_EXECUTABLE)
# Provide options for controlling different types of output
option(SPHINX_OUTPUT_HTML "Output standalone HTML files" ON)
option(SPHINX_OUTPUT_MAN "Output man pages" ON)

View File

@ -2,16 +2,48 @@
# options and executing the appropriate CMake commands to realize the users'
# selections.
include(HandleLLVMStdlib)
include(AddLLVMDefinitions)
include(CheckCCompilerFlag)
include(CheckCXXCompilerFlag)
if( CMAKE_COMPILER_IS_GNUCXX )
set(LLVM_COMPILER_IS_GCC_COMPATIBLE ON)
elseif( MSVC )
set(LLVM_COMPILER_IS_GCC_COMPATIBLE OFF)
elseif( "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" )
set(LLVM_COMPILER_IS_GCC_COMPATIBLE ON)
if(NOT LLVM_FORCE_USE_OLD_TOOLCHAIN)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7)
message(FATAL_ERROR "Host GCC version must be at least 4.7!")
endif()
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.1)
message(FATAL_ERROR "Host Clang version must be at least 3.1!")
endif()
# Also test that we aren't using too old of a version of libstdc++ with the
# Clang compiler. This is tricky as there is no real way to check the
# version of libstdc++ directly. Instead we test for a known bug in
# libstdc++4.6 that is fixed in libstdc++4.7.
if(NOT LLVM_ENABLE_LIBCXX)
set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
set(OLD_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
set(CMAKE_REQUIRED_FLAGS "-std=c++0x")
if (ANDROID)
set(CMAKE_REQUIRED_LIBRARIES "atomic")
endif()
check_cxx_source_compiles("
#include <atomic>
std::atomic<float> x(0.0f);
int main() { return (float)x; }"
LLVM_NO_OLD_LIBSTDCXX)
if(NOT LLVM_NO_OLD_LIBSTDCXX)
message(FATAL_ERROR "Host Clang must be able to find libstdc++4.7 or newer!")
endif()
set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
set(CMAKE_REQUIRED_LIBRARIES ${OLD_CMAKE_REQUIRED_LIBRARIES})
endif()
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 17.0)
message(FATAL_ERROR "Host Visual Studio must be at least 2012 (MSVC 17.0)")
endif()
endif()
endif()
if( LLVM_ENABLE_ASSERTIONS )
@ -24,23 +56,21 @@ if( LLVM_ENABLE_ASSERTIONS )
if( NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" )
add_definitions( -UNDEBUG )
# Also remove /D NDEBUG to avoid MSVC warnings about conflicting defines.
set(REGEXP_NDEBUG "(^| )[/-]D *NDEBUG($| )")
string (REGEX REPLACE "${REGEXP_NDEBUG}" " "
CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
string (REGEX REPLACE "${REGEXP_NDEBUG}" " "
CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
string (REGEX REPLACE "${REGEXP_NDEBUG}" " "
CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL}")
endif()
else()
if( NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE" )
if( NOT MSVC_IDE AND NOT XCODE )
add_definitions( -DNDEBUG )
endif()
foreach (flags_var_to_scrub
CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_RELWITHDEBINFO
CMAKE_CXX_FLAGS_MINSIZEREL
CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_RELWITHDEBINFO
CMAKE_C_FLAGS_MINSIZEREL)
string (REGEX REPLACE "(^| )[/-]D *NDEBUG($| )" " "
"${flags_var_to_scrub}" "${${flags_var_to_scrub}}")
endforeach()
endif()
endif()
if(WIN32)
set(LLVM_HAVE_LINK_VERSION_SCRIPT 0)
if(CYGWIN)
set(LLVM_ON_WIN32 0)
set(LLVM_ON_UNIX 1)
@ -48,8 +78,6 @@ if(WIN32)
set(LLVM_ON_WIN32 1)
set(LLVM_ON_UNIX 0)
endif(CYGWIN)
set(LTDL_SHLIB_EXT ".dll")
set(EXEEXT ".exe")
# Maximum path length is 160 for non-unicode paths
set(MAXPATHLEN 160)
else(WIN32)
@ -57,11 +85,10 @@ else(WIN32)
set(LLVM_ON_WIN32 0)
set(LLVM_ON_UNIX 1)
if(APPLE)
set(LTDL_SHLIB_EXT ".dylib")
set(LLVM_HAVE_LINK_VERSION_SCRIPT 0)
else(APPLE)
set(LTDL_SHLIB_EXT ".so")
set(LLVM_HAVE_LINK_VERSION_SCRIPT 1)
endif(APPLE)
set(EXEEXT "")
# FIXME: Maximum path length is currently set to 'safe' fixed value
set(MAXPATHLEN 2024)
else(UNIX)
@ -69,17 +96,16 @@ else(WIN32)
endif(UNIX)
endif(WIN32)
function(add_flag_or_print_warning flag)
check_c_compiler_flag(${flag} C_SUPPORTS_FLAG)
check_cxx_compiler_flag(${flag} CXX_SUPPORTS_FLAG)
if (C_SUPPORTS_FLAG AND CXX_SUPPORTS_FLAG)
message(STATUS "Building with ${flag}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}" PARENT_SCOPE)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}" PARENT_SCOPE)
else()
message(WARNING "${flag} is not supported.")
endif()
endfunction()
set(EXEEXT ${CMAKE_EXECUTABLE_SUFFIX})
set(LTDL_SHLIB_EXT ${CMAKE_SHARED_LIBRARY_SUFFIX})
# We use *.dylib rather than *.so on darwin.
set(LLVM_PLUGIN_EXT ${CMAKE_SHARED_LIBRARY_SUFFIX})
if(APPLE)
# Darwin-specific linker flags for loadable modules.
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,-flat_namespace -Wl,-undefined -Wl,suppress")
endif()
function(append value)
foreach(variable ${ARGN})
@ -95,13 +121,25 @@ function(append_if condition value)
endif()
endfunction()
macro(add_flag_if_supported flag)
check_c_compiler_flag(${flag} C_SUPPORTS_FLAG)
append_if(C_SUPPORTS_FLAG "${flag}" CMAKE_C_FLAGS)
check_cxx_compiler_flag(${flag} CXX_SUPPORTS_FLAG)
append_if(CXX_SUPPORTS_FLAG "${flag}" CMAKE_CXX_FLAGS)
macro(add_flag_if_supported flag name)
check_c_compiler_flag("-Werror ${flag}" "C_SUPPORTS_${name}")
append_if("C_SUPPORTS_${name}" "${flag}" CMAKE_C_FLAGS)
check_cxx_compiler_flag("-Werror ${flag}" "CXX_SUPPORTS_${name}")
append_if("CXX_SUPPORTS_${name}" "${flag}" CMAKE_CXX_FLAGS)
endmacro()
function(add_flag_or_print_warning flag name)
check_c_compiler_flag("-Werror ${flag}" "C_SUPPORTS_${name}")
check_cxx_compiler_flag("-Werror ${flag}" "CXX_SUPPORTS_${name}")
if ("C_SUPPORTS_${name}" AND "CXX_SUPPORTS_${name}")
message(STATUS "Building with ${flag}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}" PARENT_SCOPE)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}" PARENT_SCOPE)
else()
message(WARNING "${flag} is not supported.")
endif()
endfunction()
if( LLVM_ENABLE_PIC )
if( XCODE )
# Xcode has -mdynamic-no-pic on by default, which overrides -fPIC. I don't
@ -110,7 +148,7 @@ if( LLVM_ENABLE_PIC )
elseif( WIN32 OR CYGWIN)
# On Windows all code is PIC. MinGW warns if -fPIC is used.
else()
add_flag_or_print_warning("-fPIC")
add_flag_or_print_warning("-fPIC" FPIC)
if( WIN32 OR CYGWIN)
# MinGW warns if -fvisibility-inlines-hidden is used.
@ -132,6 +170,29 @@ if( CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32 )
endif( LLVM_BUILD_32_BITS )
endif( CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32 )
if( XCODE )
# For Xcode enable several build settings that correspond to
# many warnings that are on by default in Clang but are
# not enabled for historical reasons. For versions of Xcode
# that do not support these options they will simply
# be ignored.
set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_ABOUT_RETURN_TYPE "YES")
set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_ABOUT_MISSING_NEWLINE "YES")
set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_UNUSED_VALUE "YES")
set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_UNUSED_VARIABLE "YES")
set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_SIGN_COMPARE "YES")
set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_UNUSED_FUNCTION "YES")
set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED "YES")
set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS "YES")
set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_UNINITIALIZED_AUTOS "YES")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_BOOL_CONVERSION "YES")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_EMPTY_BODY "YES")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_ENUM_CONVERSION "YES")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_INT_CONVERSION "YES")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_CONSTANT_CONVERSION "YES")
set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_NON_VIRTUAL_DESTRUCTOR "YES")
endif()
# On Win32 using MS tools, provide an option to set the number of parallel jobs
# to use.
if( MSVC_IDE )
@ -141,14 +202,8 @@ if( MSVC_IDE )
if( LLVM_COMPILER_JOBS STREQUAL "0" )
add_llvm_definitions( /MP )
else()
if (MSVC10)
message(FATAL_ERROR
"Due to a bug in CMake only 0 and 1 is supported for "
"LLVM_COMPILER_JOBS when generating for Visual Studio 2010")
else()
message(STATUS "Number of parallel compiler jobs set to " ${LLVM_COMPILER_JOBS})
add_llvm_definitions( /MP${LLVM_COMPILER_JOBS} )
endif()
message(STATUS "Number of parallel compiler jobs set to " ${LLVM_COMPILER_JOBS})
add_llvm_definitions( /MP${LLVM_COMPILER_JOBS} )
endif()
else()
message(STATUS "Parallel compilation disabled")
@ -167,13 +222,7 @@ if( MSVC )
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /STACK:10000000")
endif()
if( MSVC10 )
# MSVC 10 will complain about headers in the STL not being exported, but
# will not complain in MSVC 11.
add_llvm_definitions(
-wd4275 # Suppress 'An exported class was derived from a class that was not exported.'
)
elseif( MSVC11 )
if( MSVC11 )
add_llvm_definitions(-D_VARIADIC_MAX=10)
endif()
@ -192,13 +241,14 @@ if( MSVC )
-wd4180 # Suppress 'qualifier applied to function type has no meaning; ignored'
-wd4244 # Suppress ''argument' : conversion from 'type1' to 'type2', possible loss of data'
-wd4267 # Suppress ''var' : conversion from 'size_t' to 'type', possible loss of data'
-wd4291 # Suppress ''declaration' : no matching operator delete found; memory will not be freed if initialization throws an exception'
-wd4345 # Suppress 'behavior change: an object of POD type constructed with an initializer of the form () will be default-initialized'
-wd4351 # Suppress 'new behavior: elements of array 'array' will be default initialized'
-wd4355 # Suppress ''this' : used in base member initializer list'
-wd4503 # Suppress ''identifier' : decorated name length exceeded, name was truncated'
-wd4624 # Suppress ''derived class' : destructor could not be generated because a base class destructor is inaccessible'
-wd4722 # Suppress 'function' : destructor never returns, potential memory leak
-wd4800 # Suppress ''type' : forcing value to bool 'true' or 'false' (performance warning)'
-wd4291 # Suppress ''declaration' : no matching operator delete found; memory will not be freed if initialization throws an exception'
# Promoted warnings.
-w14062 # Promote 'enumerator in switch of enum is not handled' to level 1 warning.
@ -234,31 +284,57 @@ elseif( LLVM_COMPILER_IS_GCC_COMPATIBLE )
endif()
append_if(LLVM_ENABLE_PEDANTIC "-pedantic -Wno-long-long" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
check_cxx_compiler_flag("-Werror -Wcovered-switch-default" CXX_SUPPORTS_COVERED_SWITCH_DEFAULT_FLAG)
append_if(CXX_SUPPORTS_COVERED_SWITCH_DEFAULT_FLAG "-Wcovered-switch-default" CMAKE_CXX_FLAGS)
check_c_compiler_flag("-Werror -Wcovered-switch-default" C_SUPPORTS_COVERED_SWITCH_DEFAULT_FLAG)
append_if(C_SUPPORTS_COVERED_SWITCH_DEFAULT_FLAG "-Wcovered-switch-default" CMAKE_C_FLAGS)
add_flag_if_supported("-Wcovered-switch-default" COVERED_SWITCH_DEFAULT_FLAG)
append_if(USE_NO_UNINITIALIZED "-Wno-uninitialized" CMAKE_CXX_FLAGS)
append_if(USE_NO_MAYBE_UNINITIALIZED "-Wno-maybe-uninitialized" CMAKE_CXX_FLAGS)
check_cxx_compiler_flag("-Werror -Wnon-virtual-dtor" CXX_SUPPORTS_NON_VIRTUAL_DTOR_FLAG)
append_if(CXX_SUPPORTS_NON_VIRTUAL_DTOR_FLAG "-Wnon-virtual-dtor" CMAKE_CXX_FLAGS)
# Check if -Wcomment is OK with an // comment ending with '\' if the next
# line is also a // comment.
set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} -Werror -Wcomment)
CHECK_C_SOURCE_COMPILES("// \\\\\\n//\\nint main() {return 0;}"
C_WCOMMENT_ALLOWS_LINE_WRAP)
set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
if (NOT C_WCOMMENT_ALLOWS_LINE_WRAP)
append("-Wno-comment" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
endif()
endif (LLVM_ENABLE_WARNINGS)
if (LLVM_ENABLE_WERROR)
add_llvm_definitions( -Werror )
endif (LLVM_ENABLE_WERROR)
append_if(LLVM_ENABLE_WERROR "-Werror" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
if (NOT LLVM_ENABLE_TIMESTAMPS)
add_flag_if_supported("-Werror=date-time" WERROR_DATE_TIME)
endif ()
if (LLVM_ENABLE_CXX1Y)
check_cxx_compiler_flag("-std=c++1y" CXX_SUPPORTS_CXX1Y)
append_if(CXX_SUPPORTS_CXX1Y "-std=c++1y" CMAKE_CXX_FLAGS)
else()
check_cxx_compiler_flag("-std=c++11" CXX_SUPPORTS_CXX11)
if (CXX_SUPPORTS_CXX11)
if (CYGWIN OR MINGW)
# MinGW and Cygwin are a bit stricter and lack things like
# 'strdup', 'stricmp', etc in c++11 mode.
append("-std=gnu++11" CMAKE_CXX_FLAGS)
else()
append("-std=c++11" CMAKE_CXX_FLAGS)
endif()
else()
message(FATAL_ERROR "LLVM requires C++11 support but the '-std=c++11' flag isn't supported.")
endif()
endif()
endif( MSVC )
macro(append_common_sanitizer_flags)
# Append -fno-omit-frame-pointer and turn on debug info to get better
# stack traces.
add_flag_if_supported("-fno-omit-frame-pointer")
add_flag_if_supported("-fno-omit-frame-pointer" FNO_OMIT_FRAME_POINTER)
if (NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" AND
NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "RELWITHDEBINFO")
add_flag_if_supported("-gline-tables-only")
add_flag_if_supported("-gline-tables-only" GLINE_TABLES_ONLY)
endif()
# Use -O1 even in debug mode, otherwise sanitizers slowdown is too large.
if (uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG")
add_flag_if_supported("-O1")
add_flag_if_supported("-O1" O1)
endif()
endmacro()
@ -267,12 +343,12 @@ if(LLVM_USE_SANITIZER)
if (LLVM_ON_UNIX)
if (LLVM_USE_SANITIZER STREQUAL "Address")
append_common_sanitizer_flags()
add_flag_or_print_warning("-fsanitize=address")
append("-fsanitize=address" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
elseif (LLVM_USE_SANITIZER MATCHES "Memory(WithOrigins)?")
append_common_sanitizer_flags()
add_flag_or_print_warning("-fsanitize=memory")
append("-fsanitize=memory" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
if(LLVM_USE_SANITIZER STREQUAL "MemoryWithOrigins")
add_flag_or_print_warning("-fsanitize-memory-track-origins")
append("-fsanitize-memory-track-origins" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
endif()
else()
message(WARNING "Unsupported value of LLVM_USE_SANITIZER: ${LLVM_USE_SANITIZER}")
@ -297,3 +373,56 @@ if (UNIX AND
CMAKE_GENERATOR STREQUAL "Ninja")
append("-fcolor-diagnostics" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
endif()
# Add flags for add_dead_strip().
# FIXME: With MSVS, consider compiling with /Gy and linking with /OPT:REF?
# But MinSizeRel seems to add that automatically, so maybe disable these
# flags instead if LLVM_NO_DEAD_STRIP is set.
if(NOT CYGWIN AND NOT WIN32)
if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
check_c_compiler_flag("-Werror -fno-function-sections" C_SUPPORTS_FNO_FUNCTION_SECTIONS)
if (C_SUPPORTS_FNO_FUNCTION_SECTIONS)
# Don't add -ffunction-section if it can be disabled with -fno-function-sections.
# Doing so will break sanitizers.
add_flag_if_supported("-ffunction-sections" FFUNCTION_SECTIONS)
endif()
add_flag_if_supported("-fdata-sections" FDATA_SECTIONS)
endif()
endif()
if(CYGWIN OR MINGW)
# Prune --out-implib from executables. It doesn't make sense even
# with --export-all-symbols.
string(REGEX REPLACE "-Wl,--out-implib,[^ ]+ " " "
CMAKE_C_LINK_EXECUTABLE "${CMAKE_C_LINK_EXECUTABLE}")
string(REGEX REPLACE "-Wl,--out-implib,[^ ]+ " " "
CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE}")
endif()
if(MSVC)
# Remove flags here, for exceptions and RTTI.
# Each target property or source property should be responsible to control
# them.
# CL.EXE complains to override flags like "/GR /GR-".
string(REGEX REPLACE "(^| ) */EH[-cs]+ *( |$)" "\\1 \\2" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
string(REGEX REPLACE "(^| ) */GR-? *( |$)" "\\1 \\2" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
endif()
# Provide public options to globally control RTTI and EH
option(LLVM_ENABLE_EH "Enable Exception handling" OFF)
option(LLVM_ENABLE_RTTI "Enable run time type information" OFF)
if(LLVM_ENABLE_EH AND NOT LLVM_ENABLE_RTTI)
message(FATAL_ERROR "Exception handling requires RTTI. You must set LLVM_ENABLE_RTTI to ON")
endif()
# Plugin support
# FIXME: Make this configurable.
if(WIN32 OR CYGWIN)
if(BUILD_SHARED_LIBS)
set(LLVM_ENABLE_PLUGINS ON)
else()
set(LLVM_ENABLE_PLUGINS OFF)
endif()
else()
set(LLVM_ENABLE_PLUGINS ON)
endif()

View File

@ -0,0 +1,35 @@
# This CMake module is responsible for setting the standard library to libc++
# if the user has requested it.
if(NOT DEFINED LLVM_STDLIB_HANDLED)
set(LLVM_STDLIB_HANDLED ON)
if(CMAKE_COMPILER_IS_GNUCXX)
set(LLVM_COMPILER_IS_GCC_COMPATIBLE ON)
elseif( MSVC )
set(LLVM_COMPILER_IS_GCC_COMPATIBLE OFF)
elseif( "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" )
set(LLVM_COMPILER_IS_GCC_COMPATIBLE ON)
endif()
function(append_if condition value)
if(${condition})
foreach(variable ${ARGN})
set(${variable} "${${variable}} ${value}" PARENT_SCOPE)
endforeach(variable)
endif()
endfunction()
include(CheckCXXCompilerFlag)
if(LLVM_ENABLE_LIBCXX)
if(LLVM_COMPILER_IS_GCC_COMPATIBLE)
check_cxx_compiler_flag("-stdlib=libc++" CXX_SUPPORTS_STDLIB)
append_if(CXX_SUPPORTS_STDLIB "-stdlib=libc++" CMAKE_CXX_FLAGS)
append_if(CXX_SUPPORTS_STDLIB "-stdlib=libc++" CMAKE_EXE_LINKER_FLAGS)
append_if(CXX_SUPPORTS_STDLIB "-stdlib=libc++" CMAKE_SHARED_LINKER_FLAGS)
append_if(CXX_SUPPORTS_STDLIB "-stdlib=libc++" CMAKE_MODULE_LINKER_FLAGS)
else()
message(WARNING "Not sure how to specify libc++ for this compiler")
endif()
endif()
endif()

View File

@ -1,36 +1,12 @@
function(get_system_libs return_var)
# Returns in `return_var' a list of system libraries used by LLVM.
if( NOT MSVC )
if( MINGW )
set(system_libs ${system_libs} imagehlp psapi shell32)
elseif( CMAKE_HOST_UNIX )
if( HAVE_LIBRT )
set(system_libs ${system_libs} rt)
endif()
if( HAVE_LIBDL )
set(system_libs ${system_libs} ${CMAKE_DL_LIBS})
endif()
if(LLVM_ENABLE_TERMINFO)
if(HAVE_TERMINFO)
set(system_libs ${system_libs} ${TERMINFO_LIBS})
endif()
endif()
if( LLVM_ENABLE_THREADS AND HAVE_LIBPTHREAD )
set(system_libs ${system_libs} pthread)
endif()
if ( LLVM_ENABLE_ZLIB AND HAVE_LIBZ )
set(system_libs ${system_libs} z)
endif()
endif( MINGW )
endif( NOT MSVC )
set(${return_var} ${system_libs} PARENT_SCOPE)
endfunction(get_system_libs)
message(AUTHOR_WARNING "get_system_libs no longer needed")
set(${return_var} "" PARENT_SCOPE)
endfunction()
function(link_system_libs target)
get_system_libs(llvm_system_libs)
target_link_libraries(${target} ${llvm_system_libs})
endfunction(link_system_libs)
message(AUTHOR_WARNING "link_system_libs no longer needed")
endfunction()
function(is_llvm_target_library library return_var)
@ -41,12 +17,12 @@ function(is_llvm_target_library library return_var)
string(TOUPPER "${LLVM_ALL_TARGETS}" targets)
foreach(t ${targets})
if( capitalized_lib STREQUAL t OR
capitalized_lib STREQUAL "LLVM${t}" OR
capitalized_lib STREQUAL "LLVM${t}CODEGEN" OR
capitalized_lib STREQUAL "LLVM${t}ASMPARSER" OR
capitalized_lib STREQUAL "LLVM${t}ASMPRINTER" OR
capitalized_lib STREQUAL "LLVM${t}DISASSEMBLER" OR
capitalized_lib STREQUAL "LLVM${t}INFO" )
capitalized_lib STREQUAL "LLVM${t}" OR
capitalized_lib STREQUAL "LLVM${t}CODEGEN" OR
capitalized_lib STREQUAL "LLVM${t}ASMPARSER" OR
capitalized_lib STREQUAL "LLVM${t}ASMPRINTER" OR
capitalized_lib STREQUAL "LLVM${t}DISASSEMBLER" OR
capitalized_lib STREQUAL "LLVM${t}INFO" )
set(${return_var} ON PARENT_SCOPE)
break()
endif()
@ -62,23 +38,35 @@ endmacro(llvm_config)
function(explicit_llvm_config executable)
set( link_components ${ARGN} )
explicit_map_components_to_libraries(LIBRARIES ${link_components})
target_link_libraries(${executable} ${LIBRARIES})
llvm_map_components_to_libnames(LIBRARIES ${link_components})
get_target_property(t ${executable} TYPE)
if("${t}" STREQUAL "STATIC_LIBRARY")
target_link_libraries(${executable} ${cmake_2_8_12_INTERFACE} ${LIBRARIES})
elseif("${t}" STREQUAL "SHARED_LIBRARY" OR "${t}" STREQUAL "MODULE_LIBRARY")
target_link_libraries(${executable} ${cmake_2_8_12_PRIVATE} ${LIBRARIES})
else()
# Use plain form for legacy user.
target_link_libraries(${executable} ${LIBRARIES})
endif()
endfunction(explicit_llvm_config)
# This is a variant intended for the final user:
# This is Deprecated
function(llvm_map_components_to_libraries OUT_VAR)
message(AUTHOR_WARNING "Using llvm_map_components_to_libraries() is deprecated. Use llvm_map_components_to_libnames() instead")
explicit_map_components_to_libraries(result ${ARGN})
get_system_libs(sys_result)
set( ${OUT_VAR} ${result} ${sys_result} PARENT_SCOPE )
endfunction(llvm_map_components_to_libraries)
function(explicit_map_components_to_libraries out_libs)
# This is a variant intended for the final user:
# Map LINK_COMPONENTS to actual libnames.
function(llvm_map_components_to_libnames out_libs)
set( link_components ${ARGN} )
get_property(llvm_libs GLOBAL PROPERTY LLVM_LIBS)
string(TOUPPER "${llvm_libs}" capitalized_libs)
if(NOT LLVM_AVAILABLE_LIBS)
# Inside LLVM itself available libs are in a global property.
get_property(LLVM_AVAILABLE_LIBS GLOBAL PROPERTY LLVM_LIBS)
endif()
string(TOUPPER "${LLVM_AVAILABLE_LIBS}" capitalized_libs)
# Expand some keywords:
list(FIND LLVM_TARGETS_TO_BUILD "${LLVM_NATIVE_ARCH}" have_native_backend)
@ -104,43 +92,46 @@ function(explicit_map_components_to_libraries out_libs)
# add codegen, asmprinter, asmparser, disassembler
list(FIND LLVM_TARGETS_TO_BUILD ${c} idx)
if( NOT idx LESS 0 )
list(FIND llvm_libs "LLVM${c}CodeGen" idx)
if( NOT idx LESS 0 )
list(APPEND expanded_components "LLVM${c}CodeGen")
if( TARGET LLVM${c}CodeGen )
list(APPEND expanded_components "LLVM${c}CodeGen")
else()
list(FIND llvm_libs "LLVM${c}" idx)
if( NOT idx LESS 0 )
list(APPEND expanded_components "LLVM${c}")
else()
message(FATAL_ERROR "Target ${c} is not in the set of libraries.")
endif()
if( TARGET LLVM${c} )
list(APPEND expanded_components "LLVM${c}")
else()
message(FATAL_ERROR "Target ${c} is not in the set of libraries.")
endif()
endif()
list(FIND llvm_libs "LLVM${c}AsmPrinter" asmidx)
if( NOT asmidx LESS 0 )
if( TARGET LLVM${c}AsmPrinter )
list(APPEND expanded_components "LLVM${c}AsmPrinter")
endif()
list(FIND llvm_libs "LLVM${c}AsmParser" asmidx)
if( NOT asmidx LESS 0 )
if( TARGET LLVM${c}AsmParser )
list(APPEND expanded_components "LLVM${c}AsmParser")
endif()
list(FIND llvm_libs "LLVM${c}Info" asmidx)
if( NOT asmidx LESS 0 )
if( TARGET LLVM${c}Desc )
list(APPEND expanded_components "LLVM${c}Desc")
endif()
if( TARGET LLVM${c}Info )
list(APPEND expanded_components "LLVM${c}Info")
endif()
list(FIND llvm_libs "LLVM${c}Disassembler" asmidx)
if( NOT asmidx LESS 0 )
if( TARGET LLVM${c}Disassembler )
list(APPEND expanded_components "LLVM${c}Disassembler")
endif()
elseif( c STREQUAL "native" )
# already processed
elseif( c STREQUAL "nativecodegen" )
list(APPEND expanded_components "LLVM${LLVM_NATIVE_ARCH}CodeGen")
if( TARGET LLVM${LLVM_NATIVE_ARCH}Desc )
list(APPEND expanded_components "LLVM${LLVM_NATIVE_ARCH}Desc")
endif()
if( TARGET LLVM${LLVM_NATIVE_ARCH}Info )
list(APPEND expanded_components "LLVM${LLVM_NATIVE_ARCH}Info")
endif()
elseif( c STREQUAL "backend" )
# same case as in `native'.
elseif( c STREQUAL "engine" )
# already processed
elseif( c STREQUAL "all" )
list(APPEND expanded_components ${llvm_libs})
list(APPEND expanded_components ${LLVM_AVAILABLE_LIBS})
else( NOT idx LESS 0 )
# Canonize the component name:
string(TOUPPER "${c}" capitalized)
@ -152,12 +143,18 @@ function(explicit_map_components_to_libraries out_libs)
message(FATAL_ERROR "Library `${c}' not found in list of llvm libraries.")
endif()
else( lib_idx LESS 0 )
list(GET llvm_libs ${lib_idx} canonical_lib)
list(GET LLVM_AVAILABLE_LIBS ${lib_idx} canonical_lib)
list(APPEND expanded_components ${canonical_lib})
endif( lib_idx LESS 0 )
endif( NOT idx LESS 0 )
endforeach(c)
# Expand dependencies while topologically sorting the list of libraries:
set(${out_libs} ${expanded_components} PARENT_SCOPE)
endfunction()
# Expand dependencies while topologically sorting the list of libraries:
function(llvm_expand_dependencies out_libs)
set(expanded_components ${ARGN})
list(LENGTH expanded_components lst_size)
set(cursor 0)
set(processed)
@ -177,11 +174,16 @@ function(explicit_map_components_to_libraries out_libs)
list(LENGTH processed cursor)
list(LENGTH expanded_components lst_size)
endwhile( cursor LESS lst_size )
set(${out_libs} ${expanded_components} PARENT_SCOPE)
endfunction()
function(explicit_map_components_to_libraries out_libs)
llvm_map_components_to_libnames(link_libs ${ARGN})
llvm_expand_dependencies(expanded_components ${link_libs})
# Return just the libraries included in this build:
set(result)
foreach(c ${expanded_components})
list(FIND llvm_libs ${c} lib_idx)
if( NOT lib_idx LESS 0 )
if( TARGET ${c} )
set(result ${result} ${c})
endif()
endforeach(c)

View File

@ -1,12 +1,15 @@
# This file provides information and services to the final user.
@LLVM_CONFIG_CODE@
set(LLVM_VERSION_MAJOR @LLVM_VERSION_MAJOR@)
set(LLVM_VERSION_MINOR @LLVM_VERSION_MINOR@)
set(LLVM_VERSION_PATCH @LLVM_VERSION_PATCH@)
set(LLVM_PACKAGE_VERSION @PACKAGE_VERSION@)
set(LLVM_COMMON_DEPENDS @LLVM_COMMON_DEPENDS@)
set_property( GLOBAL PROPERTY LLVM_LIBS "@llvm_libs@")
set(LLVM_AVAILABLE_LIBS @LLVM_AVAILABLE_LIBS@)
set(LLVM_ALL_TARGETS @LLVM_ALL_TARGETS@)
@ -18,7 +21,11 @@ set(LLVM_TARGETS_WITH_JIT @LLVM_TARGETS_WITH_JIT@)
set(TARGET_TRIPLE "@TARGET_TRIPLE@")
set(LLVM_TOOLS_BINARY_DIR @LLVM_TOOLS_BINARY_DIR@)
set(LLVM_ENABLE_ASSERTIONS @LLVM_ENABLE_ASSERTIONS@)
set(LLVM_ENABLE_EH @LLVM_ENABLE_EH@)
set(LLVM_ENABLE_RTTI @LLVM_ENABLE_RTTI@)
set(LLVM_ENABLE_TERMINFO @LLVM_ENABLE_TERMINFO@)
@ -30,29 +37,17 @@ set(LLVM_NATIVE_ARCH @LLVM_NATIVE_ARCH@)
set(LLVM_ENABLE_PIC @LLVM_ENABLE_PIC@)
set(HAVE_TERMINFO @HAVE_TERMINFO@)
set(TERMINFO_LIBS @TERMINFO_LIBS@)
set(HAVE_LIBDL @HAVE_LIBDL@)
set(HAVE_LIBPTHREAD @HAVE_LIBPTHREAD@)
set(HAVE_LIBZ @HAVE_LIBZ@)
set(LLVM_ON_UNIX @LLVM_ON_UNIX@)
set(LLVM_ON_WIN32 @LLVM_ON_WIN32@)
set(LLVM_INSTALL_PREFIX "@LLVM_INSTALL_PREFIX@")
set(LLVM_INCLUDE_DIRS ${LLVM_INSTALL_PREFIX}/include)
set(LLVM_LIBRARY_DIRS ${LLVM_INSTALL_PREFIX}/lib)
set(LLVM_INCLUDE_DIRS "@LLVM_CONFIG_INCLUDE_DIRS@")
set(LLVM_LIBRARY_DIRS "@LLVM_CONFIG_LIBRARY_DIRS@")
set(LLVM_DEFINITIONS "-D__STDC_LIMIT_MACROS" "-D__STDC_CONSTANT_MACROS")
set(LLVM_CMAKE_DIR "@LLVM_CONFIG_CMAKE_DIR@")
set(LLVM_TOOLS_BINARY_DIR "@LLVM_CONFIG_TOOLS_BINARY_DIR@")
# We try to include using the current setting of CMAKE_MODULE_PATH,
# which suppossedly was filled by the user with the directory where
# this file was installed:
include( LLVM-Config OPTIONAL RESULT_VARIABLE LLVMCONFIG_INCLUDED )
# If failed, we assume that this is an un-installed build:
if( NOT LLVMCONFIG_INCLUDED )
set(CMAKE_MODULE_PATH
${CMAKE_MODULE_PATH}
"@LLVM_SOURCE_DIR@/cmake/modules")
include( LLVM-Config )
if(NOT TARGET LLVMSupport)
include("@LLVM_CONFIG_EXPORTS_FILE@")
endif()
include(${LLVM_CMAKE_DIR}/LLVM-Config.cmake)

View File

@ -1 +1,13 @@
set(PACKAGE_VERSION "@PACKAGE_VERSION@")
set(PACKAGE_VERSION "@PACKAGE_VERSION@")
# LLVM is API-compatible only with matching major.minor versions
# and patch versions not less than that requested.
if("@LLVM_VERSION_MAJOR@.@LLVM_VERSION_MINOR@" VERSION_EQUAL
"${PACKAGE_FIND_VERSION_MAJOR}.${PACKAGE_FIND_VERSION_MINOR}"
AND NOT "@LLVM_VERSION_PATCH@" VERSION_LESS "${PACKAGE_FIND_VERSION_PATCH}")
set(PACKAGE_VERSION_COMPATIBLE 1)
if("@LLVM_VERSION_PATCH@" VERSION_EQUAL
"${PACKAGE_FIND_VERSION_PATCH}")
set(PACKAGE_VERSION_EXACT 1)
endif()
endif()

View File

@ -1,4 +1,5 @@
include(AddFileDependencies)
include(CMakeParseArguments)
function(llvm_replace_compiler_option var old new)
# Replaces a compiler option or switch `old' in `var' by `new'.
@ -38,48 +39,24 @@ endmacro(add_header_files)
function(llvm_process_sources OUT_VAR)
set( sources ${ARGN} )
cmake_parse_arguments(ARG "" "" "ADDITIONAL_HEADERS" ${ARGN})
set(sources ${ARG_UNPARSED_ARGUMENTS})
llvm_check_source_file_list( ${sources} )
# Create file dependencies on the tablegenned files, if any. Seems
# that this is not strictly needed, as dependencies of the .cpp
# sources on the tablegenned .inc files are detected and handled,
# but just in case...
foreach( s ${sources} )
set( f ${CMAKE_CURRENT_SOURCE_DIR}/${s} )
add_file_dependencies( ${f} ${TABLEGEN_OUTPUT} )
endforeach(s)
if( MSVC_IDE OR XCODE )
# This adds .td and .h files to the Visual Studio solution:
# FIXME: Shall we handle *.def here?
add_td_sources(sources)
add_header_files(sources)
set_source_files_properties(${ARG_ADDITIONAL_HEADERS} PROPERTIES HEADER_FILE_ONLY ON)
list(APPEND sources ${ARG_ADDITIONAL_HEADERS})
endif()
# Set common compiler options:
if( NOT LLVM_REQUIRES_EH )
if( LLVM_COMPILER_IS_GCC_COMPATIBLE )
add_definitions( -fno-exceptions )
elseif( MSVC )
llvm_replace_compiler_option(CMAKE_CXX_FLAGS "/EHsc" "/EHs-c-")
add_definitions( /D_HAS_EXCEPTIONS=0 )
endif()
endif()
if( NOT LLVM_REQUIRES_RTTI )
if( LLVM_COMPILER_IS_GCC_COMPATIBLE )
llvm_replace_compiler_option(CMAKE_CXX_FLAGS "-frtti" "-fno-rtti")
elseif( MSVC )
llvm_replace_compiler_option(CMAKE_CXX_FLAGS "/GR" "/GR-")
endif()
endif()
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" PARENT_SCOPE )
set( ${OUT_VAR} ${sources} PARENT_SCOPE )
endfunction(llvm_process_sources)
function(llvm_check_source_file_list)
set(listed ${ARGN})
file(GLOB globbed *.cpp)
file(GLOB globbed *.c *.cpp)
foreach(g ${globbed})
get_filename_component(fn ${g} NAME)
list(FIND LLVM_OPTIONAL_SOURCES ${fn} idx)
@ -87,7 +64,7 @@ function(llvm_check_source_file_list)
list(FIND listed ${fn} idx)
if( idx LESS 0 )
message(SEND_ERROR "Found unknown source file ${g}
Please update ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt\n")
Please update ${CMAKE_CURRENT_LIST_FILE}\n")
endif()
endif()
endforeach()

122
cmake/modules/Makefile Normal file
View File

@ -0,0 +1,122 @@
##===- cmake/modules/Makefile ------------------------------*- Makefile -*-===##
#
# The LLVM Compiler Infrastructure
#
# This file is distributed under the University of Illinois Open Source
# License. See LICENSE.TXT for details.
#
##===----------------------------------------------------------------------===##
LEVEL = ../..
LINK_COMPONENTS := all
include $(LEVEL)/Makefile.common
PROJ_cmake := $(DESTDIR)$(PROJ_prefix)/share/llvm/cmake
ifeq ($(DISABLE_ASSERTIONS),1)
LLVM_ENABLE_ASSERTIONS := 0
else
LLVM_ENABLE_ASSERTIONS := 1
endif
ifeq ($(REQUIRES_EH),1)
LLVM_ENABLE_EH := 1
else
LLVM_ENABLE_EH := 0
endif
ifeq ($(REQUIRES_RTTI),1)
LLVM_ENABLE_RTTI := 1
else
LLVM_ENABLE_RTTI := 0
endif
OBJMODS := LLVMConfig.cmake LLVMConfigVersion.cmake LLVMExports.cmake
$(PROJ_OBJ_DIR)/LLVMConfig.cmake: LLVMConfig.cmake.in $(LLVMBuildCMakeFrag)
$(Echo) 'Generating LLVM CMake package config file'
$(Verb) ( \
cat $< | sed \
-e 's/@LLVM_CONFIG_CODE@/set(LLVM_INSTALL_PREFIX "'"$(subst /,\/,$(PROJ_prefix))"'")/' \
-e 's/@LLVM_VERSION_MAJOR@/'"$(LLVM_VERSION_MAJOR)"'/' \
-e 's/@LLVM_VERSION_MINOR@/'"$(LLVM_VERSION_MINOR)"'/' \
-e 's/@LLVM_VERSION_PATCH@/'"$(LLVM_VERSION_PATCH)"'/' \
-e 's/@PACKAGE_VERSION@/'"$(LLVMVersion)"'/' \
-e 's/@LLVM_COMMON_DEPENDS@//' \
-e 's/@LLVM_AVAILABLE_LIBS@/'"$(subst -l,,$(LLVMConfigLibs))"'/' \
-e 's/@LLVM_ALL_TARGETS@/'"$(ALL_TARGETS)"'/' \
-e 's/@LLVM_TARGETS_TO_BUILD@/'"$(TARGETS_TO_BUILD)"'/' \
-e 's/@LLVM_TARGETS_WITH_JIT@/'"$(TARGETS_WITH_JIT)"'/' \
-e 's/@TARGET_TRIPLE@/'"$(TARGET_TRIPLE)"'/' \
-e 's/@LLVM_ENABLE_ASSERTIONS@/'"$(LLVM_ENABLE_ASSERTIONS)"'/' \
-e 's/@LLVM_ENABLE_EH@/'"$(LLVM_ENABLE_EH)"'/' \
-e 's/@LLVM_ENABLE_RTTI@/'"$(LLVM_ENABLE_RTTI)"'/' \
-e 's/@LLVM_ENABLE_TERMINFO@/'"$(ENABLE_TERMINFO)"'/' \
-e 's/@LLVM_ENABLE_THREADS@/'"$(ENABLE_THREADS)"'/' \
-e 's/@LLVM_ENABLE_ZLIB@/'"$(ENABLE_ZLIB)"'/' \
-e 's/@LLVM_NATIVE_ARCH@/'"$(LLVM_NATIVE_ARCH)"'/' \
-e 's/@LLVM_ENABLE_PIC@/'"$(ENABLE_PIC)"'/' \
-e 's/@LLVM_ON_UNIX@/'"$(LLVM_ON_UNIX)"'/' \
-e 's/@LLVM_ON_WIN32@/'"$(LLVM_ON_WIN32)"'/' \
-e 's/@LLVM_CONFIG_INCLUDE_DIRS@/'"$(subst /,\/,$(PROJ_includedir))"'/' \
-e 's/@LLVM_CONFIG_LIBRARY_DIRS@/'"$(subst /,\/,$(PROJ_libdir))"'/' \
-e 's/@LLVM_CONFIG_CMAKE_DIR@/'"$(subst /,\/,$(PROJ_cmake))"'/' \
-e 's/@LLVM_CONFIG_TOOLS_BINARY_DIR@/'"$(subst /,\/,$(PROJ_bindir))"'/' \
-e 's/@LLVM_CONFIG_EXPORTS_FILE@/$${LLVM_CMAKE_DIR}\/LLVMExports.cmake/' \
-e 's/@all_llvm_lib_deps@//' \
&& \
grep '^set_property.*LLVMBUILD_LIB_DEPS_' "$(LLVMBuildCMakeFrag)" \
) > $@
$(PROJ_OBJ_DIR)/LLVMConfigVersion.cmake: LLVMConfigVersion.cmake.in
$(Echo) 'Generating LLVM CMake package version file'
$(Verb) cat $< | sed \
-e 's/@PACKAGE_VERSION@/'"$(LLVMVersion)"'/' \
-e 's/@LLVM_VERSION_MAJOR@/'"$(LLVM_VERSION_MAJOR)"'/' \
-e 's/@LLVM_VERSION_MINOR@/'"$(LLVM_VERSION_MINOR)"'/' \
-e 's/@LLVM_VERSION_PATCH@/'"$(LLVM_VERSION_PATCH)"'/' \
> $@
$(PROJ_OBJ_DIR)/LLVMExports.cmake: $(LLVMBuildCMakeExportsFrag)
$(Echo) 'Generating LLVM CMake target exports file'
$(Verb) ( \
echo '# LLVM CMake target exports. Do not include directly.' && \
for lib in $(subst -l,,$(LLVMConfigLibs)); do \
echo 'add_library('"$$lib"' STATIC IMPORTED)' && \
echo 'set_property(TARGET '"$$lib"' PROPERTY IMPORTED_LOCATION "'"$(PROJ_libdir)/lib$$lib.a"'")' ; \
done && \
cat "$(LLVMBuildCMakeExportsFrag)" && \
echo 'set_property(TARGET LLVMSupport APPEND PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES '"$(subst -l,,$(LIBS))"')' \
) | grep -v gtest > $@
all-local:: $(addprefix $(PROJ_OBJ_DIR)/, $(OBJMODS))
SKIPSRCMODS := \
CheckAtomic.cmake \
GetHostTriple.cmake \
LLVMBuildExports.cmake \
LLVMConfig.cmake \
LLVMConfigVersion.cmake \
LLVMExports.cmake \
VersionFromVCS.cmake
SRCMODS := $(notdir $(wildcard $(PROJ_SRC_DIR)/*.cmake))
SRCMODS := $(filter-out $(SKIPSRCMODS),$(SRCMODS))
INSTSRCMODS := $(addprefix $(PROJ_cmake)/, $(SRCMODS))
INSTOBJMODS := $(addprefix $(PROJ_cmake)/, $(OBJMODS))
$(PROJ_cmake):
$(Echo) Making install directory: $@
$(Verb) $(MKDIR) $@
$(INSTSRCMODS): $(PROJ_cmake)/%.cmake: $(PROJ_SRC_DIR)/%.cmake | $(PROJ_cmake)
$(Echo) Installing cmake modules: $(notdir $<)
$(Verb) $(DataInstall) $< $(PROJ_cmake)
$(INSTOBJMODS): $(PROJ_cmake)/%.cmake: $(PROJ_OBJ_DIR)/%.cmake | $(PROJ_cmake)
$(Echo) Installing cmake modules: $(notdir $<)
$(Verb) $(DataInstall) $< $(PROJ_cmake)
install-local:: $(INSTSRCMODS) $(INSTOBJMODS)

View File

@ -2,21 +2,32 @@
# Extra parameters for `tblgen' may come after `ofn' parameter.
# Adds the name of the generated file to TABLEGEN_OUTPUT.
macro(tablegen project ofn)
function(tablegen project ofn)
# Validate calling context.
foreach(v
${project}_TABLEGEN_EXE
LLVM_MAIN_SRC_DIR
LLVM_MAIN_INCLUDE_DIR
)
if(NOT ${v})
message(FATAL_ERROR "${v} not set")
endif()
endforeach()
file(GLOB local_tds "*.td")
file(GLOB_RECURSE global_tds "${LLVM_MAIN_SRC_DIR}/include/llvm/*.td")
file(GLOB_RECURSE global_tds "${LLVM_MAIN_INCLUDE_DIR}/llvm/*.td")
if (IS_ABSOLUTE ${LLVM_TARGET_DEFINITIONS})
set(LLVM_TARGET_DEFINITIONS_ABSOLUTE ${LLVM_TARGET_DEFINITIONS})
else()
set(LLVM_TARGET_DEFINITIONS_ABSOLUTE
set(LLVM_TARGET_DEFINITIONS_ABSOLUTE
${CMAKE_CURRENT_SOURCE_DIR}/${LLVM_TARGET_DEFINITIONS})
endif()
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${ofn}.tmp
# Generate tablegen output in a temporary file.
COMMAND ${${project}_TABLEGEN_EXE} ${ARGN} -I ${CMAKE_CURRENT_SOURCE_DIR}
-I ${LLVM_MAIN_SRC_DIR}/lib/Target -I ${LLVM_MAIN_INCLUDE_DIR}
${LLVM_TARGET_DEFINITIONS_ABSOLUTE}
${LLVM_TARGET_DEFINITIONS_ABSOLUTE}
-o ${CMAKE_CURRENT_BINARY_DIR}/${ofn}.tmp
# The file in LLVM_TARGET_DEFINITIONS may be not in the current
# directory and local_tds may not contain it, so we must
@ -33,28 +44,30 @@ macro(tablegen project ofn)
${CMAKE_CURRENT_BINARY_DIR}/${ofn}.tmp
${CMAKE_CURRENT_BINARY_DIR}/${ofn}
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${ofn}.tmp
COMMENT ""
COMMENT "Updating ${ofn}..."
)
# `make clean' must remove all those generated files:
set_property(DIRECTORY APPEND
PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${ofn}.tmp ${ofn})
set(TABLEGEN_OUTPUT ${TABLEGEN_OUTPUT} ${CMAKE_CURRENT_BINARY_DIR}/${ofn})
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/${ofn}
PROPERTIES GENERATED 1)
endmacro(tablegen)
set(TABLEGEN_OUTPUT ${TABLEGEN_OUTPUT} ${CMAKE_CURRENT_BINARY_DIR}/${ofn} PARENT_SCOPE)
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/${ofn} PROPERTIES
GENERATED 1)
endfunction()
# Creates a target for publicly exporting tablegen dependencies.
function(add_public_tablegen_target target)
# Creates a target for publicly exporting tablegen dependencies.
if( TABLEGEN_OUTPUT )
add_custom_target(${target}
DEPENDS ${TABLEGEN_OUTPUT})
if (LLVM_COMMON_DEPENDS)
add_dependencies(${target} ${LLVM_COMMON_DEPENDS})
endif ()
set_target_properties(${target} PROPERTIES FOLDER "Tablegenning")
endif( TABLEGEN_OUTPUT )
if(NOT TABLEGEN_OUTPUT)
message(FATAL_ERROR "Requires tablegen() definitions as TABLEGEN_OUTPUT.")
endif()
add_custom_target(${target}
DEPENDS ${TABLEGEN_OUTPUT})
if(LLVM_COMMON_DEPENDS)
add_dependencies(${target} ${LLVM_COMMON_DEPENDS})
endif()
set_target_properties(${target} PROPERTIES FOLDER "Tablegenning")
set(LLVM_COMMON_DEPENDS ${LLVM_COMMON_DEPENDS} ${target} PARENT_SCOPE)
endfunction()
if(CMAKE_CROSSCOMPILING)
@ -64,9 +77,18 @@ if(CMAKE_CROSSCOMPILING)
COMMAND ${CMAKE_COMMAND} -E make_directory ${CX_NATIVE_TG_DIR}
COMMENT "Creating ${CX_NATIVE_TG_DIR}...")
# Forward a subset of configure options to discover additional tablegen modules.
get_cmake_property(_variableNames CACHE_VARIABLES)
foreach (_variableName ${_variableNames})
if (_variableName MATCHES "^(LLVM_EXTERNAL_.*_SOURCE_DIR)$")
list(APPEND CX_CMAKE_ARGUMENTS "-D${_variableName}=\"${${_variableName}}\"")
endif ()
endforeach()
add_custom_command(OUTPUT ${CX_NATIVE_TG_DIR}/CMakeCache.txt
# TODO: Clear the old CMakeCache.txt somehow without breaking restat.
COMMAND ${CMAKE_COMMAND} -UMAKE_TOOLCHAIN_FILE -DCMAKE_BUILD_TYPE=Release
-DLLVM_BUILD_POLLY=OFF
-DLLVM_BUILD_POLLY=OFF ${CX_CMAKE_ARGUMENTS}
-G "${CMAKE_GENERATOR}" ${CMAKE_SOURCE_DIR}
WORKING_DIRECTORY ${CX_NATIVE_TG_DIR}
DEPENDS ${CX_NATIVE_TG_DIR}
@ -78,23 +100,11 @@ if(CMAKE_CROSSCOMPILING)
endif()
macro(add_tablegen target project)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LLVM_TOOLS_BINARY_DIR})
set(${target}_OLD_LLVM_LINK_COMPONENTS ${LLVM_LINK_COMPONENTS})
set(LLVM_LINK_COMPONENTS ${LLVM_LINK_COMPONENTS} TableGen)
add_llvm_utility(${target} ${ARGN})
set(LLVM_LINK_COMPONENTS ${${target}_OLD_LLVM_LINK_COMPONENTS})
# For Xcode builds, symlink bin/<target> to bin/<Config>/<target> so that
# a separately-configured Clang project can still find llvm-tblgen.
if (XCODE)
add_custom_target(${target}-top ALL
${CMAKE_COMMAND} -E create_symlink
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/${target}${CMAKE_EXECUTABLE_SUFFIX}
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${target}${CMAKE_EXECUTABLE_SUFFIX}
DEPENDS ${target})
endif ()
set(${project}_TABLEGEN "${target}" CACHE
STRING "Native TableGen executable. Saves building one when cross-compiling.")
@ -106,7 +116,7 @@ macro(add_tablegen target project)
FORCE)
endif()
endif()
# Effective tblgen executable to be used:
set(${project}_TABLEGEN_EXE ${${project}_TABLEGEN} PARENT_SCOPE)
@ -128,16 +138,14 @@ macro(add_tablegen target project)
endif()
if( MINGW )
target_link_libraries(${target} imagehlp psapi shell32)
if(CMAKE_SIZEOF_VOID_P MATCHES "8")
set_target_properties(${target} PROPERTIES LINK_FLAGS -Wl,--stack,16777216)
endif(CMAKE_SIZEOF_VOID_P MATCHES "8")
endif( MINGW )
if( LLVM_ENABLE_THREADS AND HAVE_LIBPTHREAD AND NOT BEOS )
target_link_libraries(${target} pthread)
endif()
if (${project} STREQUAL LLVM AND NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
install(TARGETS ${target} RUNTIME DESTINATION bin)
install(TARGETS ${target}
EXPORT LLVMExports
RUNTIME DESTINATION bin)
endif()
set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS ${target})
endmacro()

BIN
cmake/nsis_icon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

View File

@ -22,7 +22,8 @@ ENDIF()
SET(ANDROID "1" CACHE STRING "ANDROID" FORCE)
SET(ANDROID_COMMON_FLAGS "-target arm-linux-androideabi --sysroot=${LLVM_ANDROID_TOOLCHAIN_DIR}/sysroot -B${LLVM_ANDROID_TOOLCHAIN_DIR} -mllvm -arm-enable-ehabi")
SET(ANDROID_COMMON_FLAGS "-target arm-linux-androideabi --sysroot=${LLVM_ANDROID_TOOLCHAIN_DIR}/sysroot -B${LLVM_ANDROID_TOOLCHAIN_DIR}")
SET(CMAKE_C_FLAGS "${ANDROID_COMMON_FLAGS}" CACHE STRING "toolchain_cflags" FORCE)
SET(CMAKE_CXX_FLAGS "${ANDROID_COMMON_FLAGS}" CACHE STRING "toolchain_cxxflags" FORCE)
SET(CMAKE_LINK_FLAGS "${ANDROID_COMMON_FLAGS}" CACHE STRING "toolchain_linkflags" FORCE)
SET(CMAKE_EXE_LINKER_FLAGS "-pie" CACHE STRING "toolchain_exelinkflags" FORCE)

5697
configure vendored

File diff suppressed because it is too large Load Diff

BIN
docs/ARM-BE-bitcastfail.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

BIN
docs/ARM-BE-ld1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

BIN
docs/ARM-BE-ldr.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

@ -51,7 +51,7 @@ starting address and size, and function calls are represented as the actual
get mod/ref information for arbitrary instructions.
All ``AliasAnalysis`` interfaces require that in queries involving multiple
values, values which are not `constants <LangRef.html#constants>`_ are all
values, values which are not :ref:`constants <constants>` are all
defined within the same function.
Representation of Pointers
@ -111,7 +111,7 @@ returns MustAlias, PartialAlias, MayAlias, or NoAlias as appropriate.
Like all ``AliasAnalysis`` interfaces, the ``alias`` method requires that either
the two pointer values be defined within the same function, or at least one of
the values is a `constant <LangRef.html#constants>`_.
the values is a :ref:`constant <constants>`.
.. _Must, May, or No:
@ -126,7 +126,7 @@ used for reading memory. Another is when the memory is freed and reallocated
between accesses through one pointer and accesses through the other --- in this
case, there is a dependence, but it's mediated by the free and reallocation.
As an exception to this is with the `noalias <LangRef.html#noalias>`_ keyword;
As an exception to this is with the :ref:`noalias <noalias>` keyword;
the "irrelevant" dependencies are ignored.
The ``MayAlias`` response is used whenever the two pointers might refer to the
@ -246,6 +246,20 @@ analysis run method (``run`` for a ``Pass``, ``runOnFunction`` for a
return false;
}
Required methods to override
----------------------------
You must override the ``getAdjustedAnalysisPointer`` method on all subclasses
of ``AliasAnalysis``. An example implementation of this method would look like:
.. code-block:: c++
void *getAdjustedAnalysisPointer(const void* ID) override {
if (ID == &AliasAnalysis::ID)
return (AliasAnalysis*)this;
return this;
}
Interfaces which may be specified
---------------------------------

View File

@ -110,8 +110,7 @@ where threads and signals are involved.
``cmpxchg`` and ``atomicrmw`` are essentially like an atomic load followed by an
atomic store (where the store is conditional for ``cmpxchg``), but no other
memory operation can happen on any thread between the load and store. Note that
LLVM's cmpxchg does not provide quite as many options as the C++0x version.
memory operation can happen on any thread between the load and store.
A ``fence`` provides Acquire and/or Release ordering which is not part of
another operation; it is normally used along with Monotonic memory operations.
@ -430,10 +429,9 @@ other ``atomicrmw`` operations generate a loop with ``LOCK CMPXCHG``. Depending
on the users of the result, some ``atomicrmw`` operations can be translated into
operations like ``LOCK AND``, but that does not work in general.
On ARM, MIPS, and many other RISC architectures, Acquire, Release, and
SequentiallyConsistent semantics require barrier instructions for every such
On ARM (before v8), MIPS, and many other RISC architectures, Acquire, Release,
and SequentiallyConsistent semantics require barrier instructions for every such
operation. Loads and stores generate normal instructions. ``cmpxchg`` and
``atomicrmw`` can be represented using a loop with LL/SC-style instructions
which take some sort of exclusive lock on a cache line (``LDREX`` and ``STREX``
on ARM, etc.). At the moment, the IR does not provide any way to represent a
weak ``cmpxchg`` which would not require a loop.
on ARM, etc.).

205
docs/BigEndianNEON.rst Normal file
View File

@ -0,0 +1,205 @@
==============================================
Using ARM NEON instructions in big endian mode
==============================================
.. contents::
:local:
Introduction
============
Generating code for big endian ARM processors is for the most part straightforward. NEON loads and stores however have some interesting properties that make code generation decisions less obvious in big endian mode.
The aim of this document is to explain the problem with NEON loads and stores, and the solution that has been implemented in LLVM.
In this document the term "vector" refers to what the ARM ABI calls a "short vector", which is a sequence of items that can fit in a NEON register. This sequence can be 64 or 128 bits in length, and can constitute 8, 16, 32 or 64 bit items. This document refers to A64 instructions throughout, but is almost applicable to the A32/ARMv7 instruction sets also. The ABI format for passing vectors in A32 is sligtly different to A64. Apart from that, the same concepts apply.
Example: C-level intrinsics -> assembly
---------------------------------------
It may be helpful first to illustrate how C-level ARM NEON intrinsics are lowered to instructions.
This trivial C function takes a vector of four ints and sets the zero'th lane to the value "42"::
#include <arm_neon.h>
int32x4_t f(int32x4_t p) {
return vsetq_lane_s32(42, p, 0);
}
arm_neon.h intrinsics generate "generic" IR where possible (that is, normal IR instructions not ``llvm.arm.neon.*`` intrinsic calls). The above generates::
define <4 x i32> @f(<4 x i32> %p) {
%vset_lane = insertelement <4 x i32> %p, i32 42, i32 0
ret <4 x i32> %vset_lane
}
Which then becomes the following trivial assembly::
f: // @f
movz w8, #0x2a
ins v0.s[0], w8
ret
Problem
=======
The main problem is how vectors are represented in memory and in registers.
First, a recap. The "endianness" of an item affects its representation in memory only. In a register, a number is just a sequence of bits - 64 bits in the case of AArch64 general purpose registers. Memory, however, is a sequence of addressable units of 8 bits in size. Any number greater than 8 bits must therefore be split up into 8-bit chunks, and endianness describes the order in which these chunks are laid out in memory.
A "little endian" layout has the least significant byte first (lowest in memory address). A "big endian" layout has the *most* significant byte first. This means that when loading an item from big endian memory, the lowest 8-bits in memory must go in the most significant 8-bits, and so forth.
``LDR`` and ``LD1``
===================
.. figure:: ARM-BE-ldr.png
:align: right
Big endian vector load using ``LDR``.
A vector is a consecutive sequence of items that are operated on simultaneously. To load a 64-bit vector, 64 bits need to be read from memory. In little endian mode, we can do this by just performing a 64-bit load - ``LDR q0, [foo]``. However if we try this in big endian mode, because of the byte swapping the lane indices end up being swapped! The zero'th item as laid out in memory becomes the n'th lane in the vector.
.. figure:: ARM-BE-ld1.png
:align: right
Big endian vector load using ``LD1``. Note that the lanes retain the correct ordering.
Because of this, the instruction ``LD1`` performs a vector load but performs byte swapping not on the entire 64 bits, but on the individual items within the vector. This means that the register content is the same as it would have been on a little endian system.
It may seem that ``LD1`` should suffice to peform vector loads on a big endian machine. However there are pros and cons to the two approaches that make it less than simple which register format to pick.
There are two options:
1. The content of a vector register is the same *as if* it had been loaded with an ``LDR`` instruction.
2. The content of a vector register is the same *as if* it had been loaded with an ``LD1`` instruction.
Because ``LD1 == LDR + REV`` and similarly ``LDR == LD1 + REV`` (on a big endian system), we can simulate either type of load with the other type of load plus a ``REV`` instruction. So we're not deciding which instructions to use, but which format to use (which will then influence which instruction is best to use).
.. The 'clearer' container is required to make the following section header come after the floated
images above.
.. container:: clearer
Note that throughout this section we only mention loads. Stores have exactly the same problems as their associated loads, so have been skipped for brevity.
Considerations
==============
LLVM IR Lane ordering
---------------------
LLVM IR has first class vector types. In LLVM IR, the zero'th element of a vector resides at the lowest memory address. The optimizer relies on this property in certain areas, for example when concatenating vectors together. The intention is for arrays and vectors to have identical memory layouts - ``[4 x i8]`` and ``<4 x i8>`` should be represented the same in memory. Without this property there would be many special cases that the optimizer would have to cleverly handle.
Use of ``LDR`` would break this lane ordering property. This doesn't preclude the use of ``LDR``, but we would have to do one of two things:
1. Insert a ``REV`` instruction to reverse the lane order after every ``LDR``.
2. Disable all optimizations that rely on lane layout, and for every access to an individual lane (``insertelement``/``extractelement``/``shufflevector``) reverse the lane index.
AAPCS
-----
The ARM procedure call standard (AAPCS) defines the ABI for passing vectors between functions in registers. It states:
When a short vector is transferred between registers and memory it is treated as an opaque object. That is a short vector is stored in memory as if it were stored with a single ``STR`` of the entire register; a short vector is loaded from memory using the corresponding ``LDR`` instruction. On a little-endian system this means that element 0 will always contain the lowest addressed element of a short vector; on a big-endian system element 0 will contain the highest-addressed element of a short vector.
-- Procedure Call Standard for the ARM 64-bit Architecture (AArch64), 4.1.2 Short Vectors
The use of ``LDR`` and ``STR`` as the ABI defines has at least one advantage over ``LD1`` and ``ST1``. ``LDR`` and ``STR`` are oblivious to the size of the individual lanes of a vector. ``LD1`` and ``ST1`` are not - the lane size is encoded within them. This is important across an ABI boundary, because it would become necessary to know the lane width the callee expects. Consider the following code:
.. code-block:: c
<callee.c>
void callee(uint32x2_t v) {
...
}
<caller.c>
extern void callee(uint32x2_t);
void caller() {
callee(...);
}
If ``callee`` changed its signature to ``uint16x4_t``, which is equivalent in register content, if we passed as ``LD1`` we'd break this code until ``caller`` was updated and recompiled.
There is an argument that if the signatures of the two functions are different then the behaviour should be undefined. But there may be functions that are agnostic to the lane layout of the vector, and treating the vector as an opaque value (just loading it and storing it) would be impossible without a common format across ABI boundaries.
So to preserve ABI compatibility, we need to use the ``LDR`` lane layout across function calls.
Alignment
---------
In strict alignment mode, ``LDR qX`` requires its address to be 128-bit aligned, whereas ``LD1`` only requires it to be as aligned as the lane size. If we canonicalised on using ``LDR``, we'd still need to use ``LD1`` in some places to avoid alignment faults (the result of the ``LD1`` would then need to be reversed with ``REV``).
Most operating systems however do not run with alignment faults enabled, so this is often not an issue.
Summary
-------
The following table summarises the instructions that are required to be emitted for each property mentioned above for each of the two solutions.
+-------------------------------+-------------------------------+---------------------+
| | ``LDR`` layout | ``LD1`` layout |
+===============================+===============================+=====================+
| Lane ordering | ``LDR + REV`` | ``LD1`` |
+-------------------------------+-------------------------------+---------------------+
| AAPCS | ``LDR`` | ``LD1 + REV`` |
+-------------------------------+-------------------------------+---------------------+
| Alignment for strict mode | ``LDR`` / ``LD1 + REV`` | ``LD1`` |
+-------------------------------+-------------------------------+---------------------+
Neither approach is perfect, and choosing one boils down to choosing the lesser of two evils. The issue with lane ordering, it was decided, would have to change target-agnostic compiler passes and would result in a strange IR in which lane indices were reversed. It was decided that this was worse than the changes that would have to be made to support ``LD1``, so ``LD1`` was chosen as the canonical vector load instruction (and by inference, ``ST1`` for vector stores).
Implementation
==============
There are 3 parts to the implementation:
1. Predicate ``LDR`` and ``STR`` instructions so that they are never allowed to be selected to generate vector loads and stores. The exception is one-lane vectors [1]_ - these by definition cannot have lane ordering problems so are fine to use ``LDR``/``STR``.
2. Create code generation patterns for bitconverts that create ``REV`` instructions.
3. Make sure appropriate bitconverts are created so that vector values get passed over call boundaries as 1-element vectors (which is the same as if they were loaded with ``LDR``).
Bitconverts
-----------
.. image:: ARM-BE-bitcastfail.png
:align: right
The main problem with the ``LD1`` solution is dealing with bitconverts (or bitcasts, or reinterpret casts). These are pseudo instructions that only change the compiler's interpretation of data, not the underlying data itself. A requirement is that if data is loaded and then saved again (called a "round trip"), the memory contents should be the same after the store as before the load. If a vector is loaded and is then bitconverted to a different vector type before storing, the round trip will currently be broken.
Take for example this code sequence::
%0 = load <4 x i32> %x
%1 = bitcast <4 x i32> %0 to <2 x i64>
store <2 x i64> %1, <2 x i64>* %y
This would produce a code sequence such as that in the figure on the right. The mismatched ``LD1`` and ``ST1`` cause the stored data to differ from the loaded data.
.. container:: clearer
When we see a bitcast from type ``X`` to type ``Y``, what we need to do is to change the in-register representation of the data to be *as if* it had just been loaded by a ``LD1`` of type ``Y``.
.. image:: ARM-BE-bitcastsuccess.png
:align: right
Conceptually this is simple - we can insert a ``REV`` undoing the ``LD1`` of type ``X`` (converting the in-register representation to the same as if it had been loaded by ``LDR``) and then insert another ``REV`` to change the representation to be as if it had been loaded by an ``LD1`` of type ``Y``.
For the previous example, this would be::
LD1 v0.4s, [x]
REV64 v0.4s, v0.4s // There is no REV128 instruction, so it must be synthesizedcd
EXT v0.16b, v0.16b, v0.16b, #8 // with a REV64 then an EXT to swap the two 64-bit elements.
REV64 v0.2d, v0.2d
EXT v0.16b, v0.16b, v0.16b, #8
ST1 v0.2d, [y]
It turns out that these ``REV`` pairs can, in almost all cases, be squashed together into a single ``REV``. For the example above, a ``REV128 4s`` + ``REV128 2d`` is actually a ``REV64 4s``, as shown in the figure on the right.
.. [1] One lane vectors may seem useless as a concept but they serve to distinguish between values held in general purpose registers and values held in NEON/VFP registers. For example, an ``i64`` would live in an ``x`` register, but ``<1 x i64>`` would live in a ``d`` register.

View File

@ -658,7 +658,7 @@ for each library name referenced.
MODULE_CODE_GLOBALVAR Record
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
``[GLOBALVAR, pointer type, isconst, initid, linkage, alignment, section, visibility, threadlocal, unnamed_addr]``
``[GLOBALVAR, pointer type, isconst, initid, linkage, alignment, section, visibility, threadlocal, unnamed_addr, dllstorageclass]``
The ``GLOBALVAR`` record (code 7) marks the declaration or definition of a
global variable. The operand fields are:
@ -688,7 +688,8 @@ global variable. The operand fields are:
* ``weak_odr``: code 10
* ``linkonce_odr``: code 11
* ``available_externally``: code 12
* ``linker_private``: code 13
* deprecated : code 13
* deprecated : code 14
* alignment*: The logarithm base 2 of the variable's requested alignment, plus 1
@ -713,12 +714,20 @@ global variable. The operand fields are:
* *unnamed_addr*: If present and non-zero, indicates that the variable has
``unnamed_addr``
.. _dllstorageclass:
* *dllstorageclass*: If present, an encoding of the DLL storage class of this variable:
* ``default``: code 0
* ``dllimport``: code 1
* ``dllexport``: code 2
.. _FUNCTION:
MODULE_CODE_FUNCTION Record
^^^^^^^^^^^^^^^^^^^^^^^^^^^
``[FUNCTION, type, callingconv, isproto, linkage, paramattr, alignment, section, visibility, gc, prefix]``
``[FUNCTION, type, callingconv, isproto, linkage, paramattr, alignment, section, visibility, gc, prefix, dllstorageclass]``
The ``FUNCTION`` record (code 8) marks the declaration or definition of a
function. The operand fields are:
@ -729,6 +738,10 @@ function. The operand fields are:
* ``ccc``: code 0
* ``fastcc``: code 8
* ``coldcc``: code 9
* ``webkit_jscc``: code 12
* ``anyregcc``: code 13
* ``preserve_mostcc``: code 14
* ``preserve_allcc``: code 15
* ``x86_stdcallcc``: code 64
* ``x86_fastcallcc``: code 65
* ``arm_apcscc``: code 66
@ -760,10 +773,12 @@ function. The operand fields are:
* *prefix*: If non-zero, the value index of the prefix data for this function,
plus 1.
* *dllstorageclass*: An encoding of the `dllstorageclass`_ of this function
MODULE_CODE_ALIAS Record
^^^^^^^^^^^^^^^^^^^^^^^^
``[ALIAS, alias type, aliasee val#, linkage, visibility]``
``[ALIAS, alias type, aliasee val#, linkage, visibility, dllstorageclass]``
The ``ALIAS`` record (code 9) marks the definition of an alias. The operand
fields are
@ -776,6 +791,8 @@ fields are
* *visibility*: If present, an encoding of the `visibility`_ of the alias
* *dllstorageclass*: If present, an encoding of the `dllstorageclass`_ of the alias
MODULE_CODE_PURGEVALS Record
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -1076,7 +1093,7 @@ named type.
VALUE_SYMTAB_BLOCK Contents
---------------------------
The ``VALUE_SYMTAB_BLOCK`` block (id 14) ...
The ``VALUE_SYMTAB_BLOCK`` block (id 14) ...
.. _METADATA_BLOCK:

View File

@ -0,0 +1,130 @@
================================
LLVM Block Frequency Terminology
================================
.. contents::
:local:
Introduction
============
Block Frequency is a metric for estimating the relative frequency of different
basic blocks. This document describes the terminology that the
``BlockFrequencyInfo`` and ``MachineBlockFrequencyInfo`` analysis passes use.
Branch Probability
==================
Blocks with multiple successors have probabilities associated with each
outgoing edge. These are called branch probabilities. For a given block, the
sum of its outgoing branch probabilities should be 1.0.
Branch Weight
=============
Rather than storing fractions on each edge, we store an integer weight.
Weights are relative to the other edges of a given predecessor block. The
branch probability associated with a given edge is its own weight divided by
the sum of the weights on the predecessor's outgoing edges.
For example, consider this IR:
.. code-block:: llvm
define void @foo() {
; ...
A:
br i1 %cond, label %B, label %C, !prof !0
; ...
}
!0 = metadata !{metadata !"branch_weights", i32 7, i32 8}
and this simple graph representation::
A -> B (edge-weight: 7)
A -> C (edge-weight: 8)
The probability of branching from block A to block B is 7/15, and the
probability of branching from block A to block C is 8/15.
See :doc:`BranchWeightMetadata` for details about the branch weight IR
representation.
Block Frequency
===============
Block frequency is a relative metric that represents the number of times a
block executes. The ratio of a block frequency to the entry block frequency is
the expected number of times the block will execute per entry to the function.
Block frequency is the main output of the ``BlockFrequencyInfo`` and
``MachineBlockFrequencyInfo`` analysis passes.
Implementation: a series of DAGs
================================
The implementation of the block frequency calculation analyses each loop,
bottom-up, ignoring backedges; i.e., as a DAG. After each loop is processed,
it's packaged up to act as a pseudo-node in its parent loop's (or the
function's) DAG analysis.
Block Mass
==========
For each DAG, the entry node is assigned a mass of ``UINT64_MAX`` and mass is
distributed to successors according to branch weights. Block Mass uses a
fixed-point representation where ``UINT64_MAX`` represents ``1.0`` and ``0``
represents a number just above ``0.0``.
After mass is fully distributed, in any cut of the DAG that separates the exit
nodes from the entry node, the sum of the block masses of the nodes succeeded
by a cut edge should equal ``UINT64_MAX``. In other words, mass is conserved
as it "falls" through the DAG.
If a function's basic block graph is a DAG, then block masses are valid block
frequencies. This works poorly in practise though, since downstream users rely
on adding block frequencies together without hitting the maximum.
Loop Scale
==========
Loop scale is a metric that indicates how many times a loop iterates per entry.
As mass is distributed through the loop's DAG, the (otherwise ignored) backedge
mass is collected. This backedge mass is used to compute the exit frequency,
and thus the loop scale.
Implementation: Getting from mass and scale to frequency
========================================================
After analysing the complete series of DAGs, each block has a mass (local to
its containing loop, if any), and each loop pseudo-node has a loop scale and
its own mass (from its parent's DAG).
We can get an initial frequency assignment (with entry frequency of 1.0) by
multiplying these masses and loop scales together. A given block's frequency
is the product of its mass, the mass of containing loops' pseudo nodes, and the
containing loops' loop scales.
Since downstream users need integers (not floating point), this initial
frequency assignment is shifted as necessary into the range of ``uint64_t``.
Block Bias
==========
Block bias is a proposed *absolute* metric to indicate a bias toward or away
from a given block during a function's execution. The idea is that bias can be
used in isolation to indicate whether a block is relatively hot or cold, or to
compare two blocks to indicate whether one is hotter or colder than the other.
The proposed calculation involves calculating a *reference* block frequency,
where:
* every branch weight is assumed to be 1 (i.e., every branch probability
distribution is even) and
* loop scales are ignored.
This reference frequency represents what the block frequency would be in an
unbiased graph.
The bias is the ratio of the block frequency to this reference block frequency.

View File

@ -8,10 +8,11 @@ LLVM Branch Weight Metadata
Introduction
============
Branch Weight Metadata represents branch weights as its likeliness to be
taken. Metadata is assigned to the ``TerminatorInst`` as a ``MDNode`` of the
``MD_prof`` kind. The first operator is always a ``MDString`` node with the
string "branch_weights". Number of operators depends on the terminator type.
Branch Weight Metadata represents branch weights as its likeliness to be taken
(see :doc:`BlockFrequencyTerminology`). Metadata is assigned to the
``TerminatorInst`` as a ``MDNode`` of the ``MD_prof`` kind. The first operator
is always a ``MDString`` node with the string "branch_weights". Number of
operators depends on the terminator type.
Branch weights might be fetch from the profiling file, or generated based on
`__builtin_expect`_ instruction.

View File

@ -17,7 +17,7 @@ optimization (or combination of optimizations) that causes the crash, and reduce
the file down to a small example which triggers the crash.
For detailed case scenarios, such as debugging ``opt``, or one of the LLVM code
generators, see `How To Submit a Bug Report document <HowToSubmitABug.html>`_.
generators, see :doc:`HowToSubmitABug`.
Design Philosophy
=================

View File

@ -87,7 +87,7 @@ names are case-sensitive. Example:
.. code-block:: console
$ cmake -G "Visual Studio 10" path/to/llvm/source/root
$ cmake -G "Visual Studio 11" path/to/llvm/source/root
For a given development platform there can be more than one adequate
generator. If you use Visual Studio "NMake Makefiles" is a generator you can use
@ -132,7 +132,7 @@ write the variable and the type on the CMake command line:
Frequently-used CMake variables
-------------------------------
Here are listed some of the CMake variables that are used often, along with a
Here are some of the CMake variables that are used often, along with a
brief explanation and LLVM-specific notes. For full documentation, check the
CMake docs or execute ``cmake --help-variable VARIABLE_NAME``.
@ -157,8 +157,8 @@ CMake docs or execute ``cmake --help-variable VARIABLE_NAME``.
Extra flags to use when compiling C++ source files.
**BUILD_SHARED_LIBS**:BOOL
Flag indicating is shared libraries will be built. Its default value is
OFF. Shared libraries are not supported on Windows and not recommended in the
Flag indicating if shared libraries will be built. Its default value is
OFF. Shared libraries are not supported on Windows and not recommended on the
other OSes.
.. _LLVM-specific variables:
@ -211,14 +211,25 @@ LLVM-specific variables
**LLVM_ENABLE_THREADS**:BOOL
Build with threads support, if available. Defaults to ON.
**LLVM_ENABLE_CXX1Y**:BOOL
Build in C++1y mode, if available. Defaults to OFF.
**LLVM_ENABLE_ASSERTIONS**:BOOL
Enables code assertions. Defaults to OFF if and only if ``CMAKE_BUILD_TYPE``
is *Release*.
**LLVM_ENABLE_EH**:BOOL
Build LLVM with exception handling support. This is necessary if you wish to
link against LLVM libraries and make use of C++ exceptions in your own code
that need to propagate through LLVM code. Defaults to OFF.
**LLVM_ENABLE_PIC**:BOOL
Add the ``-fPIC`` flag for the compiler command-line, if the compiler supports
this flag. Some systems, like Windows, do not need this flag. Defaults to ON.
**LLVM_ENABLE_RTTI**:BOOL
Build LLVM with run time type information. Defaults to OFF.
**LLVM_ENABLE_WARNINGS**:BOOL
Enable all compiler warnings. Defaults to ON.
@ -263,7 +274,7 @@ LLVM-specific variables
**LLVM_EXTERNAL_{CLANG,LLD,POLLY}_SOURCE_DIR**:PATH
Path to ``{Clang,lld,Polly}``\'s source directory. Defaults to
``tools/{clang,lld,polly}``. ``{Clang,lld,Polly}`` will not be built when it
is empty or it does not point valid path.
is empty or it does not point to a valid path.
**LLVM_USE_OPROFILE**:BOOL
Enable building OProfile JIT support. Defaults to OFF
@ -280,6 +291,78 @@ LLVM-specific variables
are ``Address``, ``Memory`` and ``MemoryWithOrigins``. Defaults to empty
string.
**LLVM_BUILD_DOCS**:BOOL
Enables all enabled documentation targets (i.e. Doxgyen and Sphinx targets) to
be built as part of the normal build. If the ``install`` target is run then
this also enables all built documentation targets to be installed. Defaults to
OFF.
**LLVM_ENABLE_DOXYGEN**:BOOL
Enables the generation of browsable HTML documentation using doxygen.
Defaults to OFF.
**LLVM_ENABLE_DOXYGEN_QT_HELP**:BOOL
Enables the generation of a Qt Compressed Help file. Defaults to OFF.
This affects the make target ``doxygen-llvm``. When enabled, apart from
the normal HTML output generated by doxygen, this will produce a QCH file
named ``org.llvm.qch``. You can then load this file into Qt Creator.
This option is only useful in combination with ``-DLLVM_ENABLE_DOXYGEN=ON``;
otherwise this has no effect.
**LLVM_DOXYGEN_QCH_FILENAME**:STRING
The filename of the Qt Compressed Help file that will be genrated when
``-DLLVM_ENABLE_DOXYGEN=ON`` and
``-DLLVM_ENABLE_DOXYGEN_QT_HELP=ON`` are given. Defaults to
``org.llvm.qch``.
This option is only useful in combination with
``-DLLVM_ENABLE_DOXYGEN_QT_HELP=ON``;
otherwise this has no effect.
**LLVM_DOXYGEN_QHP_NAMESPACE**:STRING
Namespace under which the intermediate Qt Help Project file lives. See `Qt
Help Project`_
for more information. Defaults to "org.llvm". This option is only useful in
combination with ``-DLLVM_ENABLE_DOXYGEN_QT_HELP=ON``; otherwise
this has no effect.
**LLVM_DOXYGEN_QHP_CUST_FILTER_NAME**:STRING
See `Qt Help Project`_ for
more information. Defaults to the CMake variable ``${PACKAGE_STRING}`` which
is a combination of the package name and version string. This filter can then
be used in Qt Creator to select only documentation from LLVM when browsing
through all the help files that you might have loaded. This option is only
useful in combination with ``-DLLVM_ENABLE_DOXYGEN_QT_HELP=ON``;
otherwise this has no effect.
.. _Qt Help Project: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom-filters
**LLVM_DOXYGEN_QHELPGENERATOR_PATH**:STRING
The path to the ``qhelpgenerator`` executable. Defaults to whatever CMake's
``find_program()`` can find. This option is only useful in combination with
``-DLLVM_ENABLE_DOXYGEN_QT_HELP=ON``; otherwise this has no
effect.
**LLVM_ENABLE_SPHINX**:BOOL
If enabled CMake will search for the ``sphinx-build`` executable and will make
the ``SPHINX_OUTPUT_HTML`` and ``SPHINX_OUTPUT_MAN`` CMake options available.
Defaults to OFF.
**SPHINX_EXECUTABLE**:STRING
The path to the ``sphinx-build`` executable detected by CMake.
**SPHINX_OUTPUT_HTML**:BOOL
If enabled (and ``LLVM_ENABLE_SPHINX`` is enabled) then the targets for
building the documentation as html are added (but not built by default unless
``LLVM_BUILD_DOCS`` is enabled). There is a target for each project in the
source tree that uses sphinx (e.g. ``docs-llvm-html``, ``docs-clang-html``
and ``docs-lld-html``). Defaults to ON.
**SPHINX_OUTPUT_MAN**:BOOL
If enabled (and ``LLVM_ENABLE_SPHINX`` is enabled) the targets for building
the man pages are added (but not built by default unless ``LLVM_BUILD_DOCS``
is enabled). Currently the only target added is ``docs-llvm-man``. Defaults
to ON.
Executing the test suite
========================
@ -306,69 +389,117 @@ for a quick solution.
Also see the `LLVM-specific variables`_ section for variables used when
cross-compiling.
.. _Embedding LLVM in your project:
Embedding LLVM in your project
==============================
The most difficult part of adding LLVM to the build of a project is to determine
the set of LLVM libraries corresponding to the set of required LLVM
features. What follows is an example of how to obtain this information:
From LLVM 3.5 onwards both the CMake and autoconf/Makefile build systems export
LLVM libraries as importable CMake targets. This means that clients of LLVM can
now reliably use CMake to develop their own LLVM based projects against an
installed version of LLVM regardless of how it was built.
Here is a simple example of CMakeLists.txt file that imports the LLVM libraries
and uses them to build a simple application ``simple-tool``.
.. code-block:: cmake
# A convenience variable:
set(LLVM_ROOT "" CACHE PATH "Root of LLVM install.")
cmake_minimum_required(VERSION 2.8.8)
project(SimpleProject)
# A bit of a sanity check:
if( NOT EXISTS ${LLVM_ROOT}/include/llvm )
message(FATAL_ERROR "LLVM_ROOT (${LLVM_ROOT}) is not a valid LLVM install")
endif()
find_package(LLVM REQUIRED CONFIG)
# We incorporate the CMake features provided by LLVM:
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${LLVM_ROOT}/share/llvm/cmake")
include(LLVMConfig)
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
# Now set the header and library paths:
include_directories( ${LLVM_INCLUDE_DIRS} )
link_directories( ${LLVM_LIBRARY_DIRS} )
add_definitions( ${LLVM_DEFINITIONS} )
# Set your project compile flags.
# E.g. if using the C++ header files
# you will need to enable C++11 support
# for your compiler.
# Let's suppose we want to build a JIT compiler with support for
# binary code (no interpreter):
llvm_map_components_to_libraries(REQ_LLVM_LIBRARIES jit native)
include_directories(${LLVM_INCLUDE_DIRS})
add_definitions(${LLVM_DEFINITIONS})
# Finally, we link the LLVM libraries to our executable:
target_link_libraries(mycompiler ${REQ_LLVM_LIBRARIES})
# Now build our tools
add_excutable(simple-tool tool.cpp)
This assumes that LLVM_ROOT points to an install of LLVM. The procedure works
too for uninstalled builds although we need to take care to add an
`include_directories` for the location of the headers on the LLVM source
directory (if we are building out-of-source.)
# Find the libraries that correspond to the LLVM components
# that we wish to use
llvm_map_components_to_libnames(llvm_libs support core irreader)
Alternativaly, you can utilize CMake's ``find_package`` functionality. Here is
an equivalent variant of snippet shown above:
# Link against LLVM libraries
target_link_libraries(simple-tool ${llvm_libs})
.. code-block:: cmake
The ``find_package(...)`` directive when used in CONFIG mode (as in the above
example) will look for the ``LLVMConfig.cmake`` file in various locations (see
cmake manual for details). It creates a ``LLVM_DIR`` cache entry to save the
directory where ``LLVMConfig.cmake`` is found or allows the user to specify the
directory (e.g. by passing ``-DLLVM_DIR=/usr/share/llvm/cmake`` to
the ``cmake`` command or by setting it directly in ``ccmake`` or ``cmake-gui``).
find_package(LLVM)
This file is available in two different locations.
if( NOT LLVM_FOUND )
message(FATAL_ERROR "LLVM package can't be found. Set CMAKE_PREFIX_PATH variable to LLVM's installation prefix.")
endif()
* ``<INSTALL_PREFIX>/share/llvm/cmake/LLVMConfig.cmake`` where
``<INSTALL_PREFIX>`` is the install prefix of an installed version of LLVM.
On Linux typically this is ``/usr/share/llvm/cmake/LLVMConfig.cmake``.
include_directories( ${LLVM_INCLUDE_DIRS} )
link_directories( ${LLVM_LIBRARY_DIRS} )
* ``<LLVM_BUILD_ROOT>/share/llvm/cmake/LLVMConfig.cmake`` where
``<LLVM_BUILD_ROOT>`` is the root of the LLVM build tree. **Note this only
available when building LLVM with CMake**
llvm_map_components_to_libraries(REQ_LLVM_LIBRARIES jit native)
If LLVM is installed in your operating system's normal installation prefix (e.g.
on Linux this is usually ``/usr/``) ``find_package(LLVM ...)`` will
automatically find LLVM if it is installed correctly. If LLVM is not installed
or you wish to build directly against the LLVM build tree you can use
``LLVM_DIR`` as previously mentioned.
target_link_libraries(mycompiler ${REQ_LLVM_LIBRARIES})
The ``LLVMConfig.cmake`` file sets various useful variables. Notable variables
include
``LLVM_CMAKE_DIR``
The path to the LLVM CMake directory (i.e. the directory containing
LLVMConfig.cmake).
``LLVM_DEFINITIONS``
A list of preprocessor defines that should be used when building against LLVM.
``LLVM_ENABLE_ASSERTIONS``
This is set to ON if LLVM was built with assertions, otherwise OFF.
``LLVM_ENABLE_EH``
This is set to ON if LLVM was built with exception handling (EH) enabled,
otherwise OFF.
``LLVM_ENABLE_RTTI``
This is set to ON if LLVM was built with run time type information (RTTI),
otherwise OFF.
``LLVM_INCLUDE_DIRS``
A list of include paths to directories containing LLVM header files.
``LLVM_PACKAGE_VERSION``
The LLVM version. This string can be used with CMake conditionals. E.g. ``if
(${LLVM_PACKAGE_VERSION} VERSION_LESS "3.5")``.
``LLVM_TOOLS_BINARY_DIR``
The path to the directory containing the LLVM tools (e.g. ``llvm-as``).
Notice that in the above example we link ``simple-tool`` against several LLVM
libraries. The list of libraries is determined by using the
``llvm_map_components_to_libnames()`` CMake function. For a list of available
components look at the output of running ``llvm-config --components``.
Note that for LLVM < 3.5 ``llvm_map_components_to_libraries()`` was
used instead of ``llvm_map_components_to_libnames()``. This is now deprecated
and will be removed in a future version of LLVM.
.. _cmake-out-of-source-pass:
Developing LLVM pass out of source
----------------------------------
Developing LLVM passes out of source
------------------------------------
It is possible to develop LLVM passes against installed LLVM. An example of
project layout provided below:
It is possible to develop LLVM passes out of LLVM's source tree (i.e. against an
installed or built LLVM). An example of a project layout is provided below.
.. code-block:: none
@ -385,19 +516,34 @@ Contents of ``<project dir>/CMakeLists.txt``:
.. code-block:: cmake
find_package(LLVM)
# Define add_llvm_* macro's.
include(AddLLVM)
find_package(LLVM REQUIRED CONFIG)
add_definitions(${LLVM_DEFINITIONS})
include_directories(${LLVM_INCLUDE_DIRS})
link_directories(${LLVM_LIBRARY_DIRS})
add_subdirectory(<pass name>)
Contents of ``<project dir>/<pass name>/CMakeLists.txt``:
.. code-block:: cmake
add_library(LLVMPassname MODULE Pass.cpp)
Note if you intend for this pass to be merged into the LLVM source tree at some
point in the future it might make more sense to use LLVM's internal
add_llvm_loadable_module function instead by...
Adding the following to ``<project dir>/CMakeLists.txt`` (after
``find_package(LLVM ...)``)
.. code-block:: cmake
list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}")
include(AddLLVM)
And then changing ``<project dir>/<pass name>/CMakeLists.txt`` to
.. code-block:: cmake
add_llvm_loadable_module(LLVMPassname
@ -412,7 +558,7 @@ into LLVM source tree. You can achieve it in two easy steps:
#. Adding ``add_subdirectory(<pass name>)`` line into
``<LLVM root>/lib/Transform/CMakeLists.txt``.
Compiler/Platform specific topics
Compiler/Platform-specific topics
=================================
Notes for specific compilers and/or platforms.

View File

@ -22,6 +22,40 @@ if (LLVM_ENABLE_DOXYGEN)
set(extra_search_mappings "")
endif()
# If asked, configure doxygen for the creation of a Qt Compressed Help file.
option(LLVM_ENABLE_DOXYGEN_QT_HELP
"Generate a Qt Compressed Help file." OFF)
if (LLVM_ENABLE_DOXYGEN_QT_HELP)
set(LLVM_DOXYGEN_QCH_FILENAME "org.llvm.qch" CACHE STRING
"Filename of the Qt Compressed help file")
set(LLVM_DOXYGEN_QHP_NAMESPACE "org.llvm" CACHE STRING
"Namespace under which the intermediate Qt Help Project file lives")
set(LLVM_DOXYGEN_QHP_CUST_FILTER_NAME "${PACKAGE_STRING}" CACHE STRING
"See http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom-filters")
set(LLVM_DOXYGEN_QHP_CUST_FILTER_ATTRS "${PACKAGE_NAME},${PACKAGE_VERSION}" CACHE STRING
"See http://qt-project.org/doc/qt-4.8/qthelpproject.html#filter-attributes")
find_program(LLVM_DOXYGEN_QHELPGENERATOR_PATH qhelpgenerator
DOC "Path to the qhelpgenerator binary")
if (NOT LLVM_DOXYGEN_QHELPGENERATOR_PATH)
message(FATAL_ERROR "Failed to find qhelpgenerator binary")
endif()
set(llvm_doxygen_generate_qhp "YES")
set(llvm_doxygen_qch_filename "${LLVM_DOXYGEN_QCH_FILENAME}")
set(llvm_doxygen_qhp_namespace "${LLVM_DOXYGEN_QHP_NAMESPACE}")
set(llvm_doxygen_qhelpgenerator_path "${LLVM_DOXYGEN_QHELPGENERATOR_PATH}")
set(llvm_doxygen_qhp_cust_filter_name "${LLVM_DOXYGEN_QHP_CUST_FILTER_NAME}")
set(llvm_doxygen_qhp_cust_filter_attrs "${LLVM_DOXYGEN_QHP_CUST_FILTER_ATTRS}")
else()
set(llvm_doxygen_generate_qhp "NO")
set(llvm_doxygen_qch_filename "")
set(llvm_doxygen_qhp_namespace "")
set(llvm_doxygen_qhelpgenerator_path "")
set(llvm_doxygen_qhp_cust_filter_name "")
set(llvm_doxygen_qhp_cust_filter_attrs "")
endif()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/doxygen.cfg.in
${CMAKE_CURRENT_BINARY_DIR}/doxygen.cfg @ONLY)
@ -33,6 +67,12 @@ if (LLVM_ENABLE_DOXYGEN)
set(enable_server_based_search)
set(enable_external_search)
set(extra_search_mappings)
set(llvm_doxygen_generate_qhp)
set(llvm_doxygen_qch_filename)
set(llvm_doxygen_qhp_namespace)
set(llvm_doxygen_qhelpgenerator_path)
set(llvm_doxygen_qhp_cust_filter_name)
set(llvm_doxygen_qhp_cust_filter_attrs)
add_custom_target(doxygen-llvm
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/doxygen.cfg
@ -49,3 +89,18 @@ if (LLVM_ENABLE_DOXYGEN)
endif()
endif()
endif()
if (LLVM_ENABLE_SPHINX)
if (SPHINX_FOUND)
include(AddSphinxTarget)
if (${SPHINX_OUTPUT_HTML})
add_sphinx_target(html llvm)
endif()
if (${SPHINX_OUTPUT_MAN})
add_sphinx_target(man llvm)
endif()
endif()
endif()

View File

@ -70,7 +70,7 @@ different pieces of this will be useful to you. In any case, you should be
familiar with the `target description`_ and `machine code representation`_
classes. If you want to add a backend for a new target, you will need to
`implement the target description`_ classes for your new target and understand
the `LLVM code representation <LangRef.html>`_. If you are interested in
the :doc:`LLVM code representation <LangRef>`. If you are interested in
implementing a new `code generation algorithm`_, it should only depend on the
target-description and machine code representation classes, ensuring that it is
portable.
@ -172,7 +172,7 @@ architecture. These target descriptions often have a large amount of common
information (e.g., an ``add`` instruction is almost identical to a ``sub``
instruction). In order to allow the maximum amount of commonality to be
factored out, the LLVM code generator uses the
:doc:`TableGen <TableGenFundamentals>` tool to describe big chunks of the
:doc:`TableGen/index` tool to describe big chunks of the
target machine, which allows the use of domain-specific and target-specific
abstractions to reduce the amount of repetition.
@ -277,7 +277,7 @@ an associated register class. When the register allocator runs, it replaces
virtual registers with a physical register in the set.
The target-specific implementations of these classes is auto-generated from a
`TableGen <TableGenFundamentals.html>`_ description of the register file.
:doc:`TableGen/index` description of the register file.
.. _TargetInstrInfo:
@ -434,12 +434,12 @@ For example, consider this simple LLVM example:
.. code-block:: llvm
define i32 @test(i32 %X, i32 %Y) {
%Z = udiv i32 %X, %Y
%Z = sdiv i32 %X, %Y
ret i32 %Z
}
The X86 instruction selector produces this machine code for the ``div`` and
``ret`` (use "``llc X.bc -march=x86 -print-machineinstrs``" to get this):
The X86 instruction selector might produce this machine code for the ``div`` and
``ret``:
.. code-block:: llvm
@ -454,8 +454,8 @@ The X86 instruction selector produces this machine code for the ``div`` and
%EAX = mov %reg1026 ;; 32-bit return value goes in EAX
ret
By the end of code generation, the register allocator has coalesced the
registers and deleted the resultant identity moves producing the following
By the end of code generation, the register allocator would coalesce the
registers and delete the resultant identity moves producing the following
code:
.. code-block:: llvm
@ -1228,7 +1228,7 @@ used. Each virtual register can only be mapped to physical registers of a
particular class. For instance, in the X86 architecture, some virtuals can only
be allocated to 8 bit registers. A register class is described by
``TargetRegisterClass`` objects. To discover if a virtual register is
compatible with a given physical, this code can be used:</p>
compatible with a given physical, this code can be used:
.. code-block:: c++
@ -1683,7 +1683,7 @@ ones supported by the matcher), through a Requires clause:
def : MnemonicAlias<"pushf", "pushfq">, Requires<[In64BitMode]>;
def : MnemonicAlias<"pushf", "pushfl">, Requires<[In32BitMode]>;
In this example, the mnemonic gets mapped into different a new one depending on
In this example, the mnemonic gets mapped into a different one depending on
the current instruction set.
Instruction Aliases
@ -1993,7 +1993,7 @@ Tail Calls
This box indicates whether the target supports guaranteed tail calls. These are
calls marked "`tail <LangRef.html#i_call>`_" and use the fastcc calling
convention. Please see the `tail call section more more details`_.
convention. Please see the `tail call section`_ for more details.
.. _feat_segstacks:
@ -2011,7 +2011,7 @@ Basic support exists on the X86 backend. Currently vararg doesn't work and the
object files are not marked the way the gold linker expects, but simple Go
programs can be built by dragonegg.
.. _tail call section more more details:
.. _tail call section:
Tail call optimization
----------------------
@ -2027,7 +2027,7 @@ supported on x86/x86-64 and PowerPC. It is performed if:
* Option ``-tailcallopt`` is enabled.
* Platform specific constraints are met.
* Platform-specific constraints are met.
x86/x86-64 constraints:

View File

@ -14,9 +14,9 @@ absolute requirements to be followed in all instances, coding standards are
particularly important for large-scale code bases that follow a library-based
design (like LLVM).
This document intentionally does not prescribe fixed standards for religious
issues such as brace placement and space usage. For issues like this, follow
the golden rule:
While this document may provide guidance for some mechanical formatting issues,
whitespace, or other "microscopic details", these are not fixed standards.
Always follow the golden rule:
.. _Golden Rule:
@ -43,6 +43,137 @@ The ultimate goal of these guidelines is the increase readability and
maintainability of our common source base. If you have suggestions for topics to
be included, please mail them to `Chris <mailto:sabre@nondot.org>`_.
Languages, Libraries, and Standards
===================================
Most source code in LLVM and other LLVM projects using these coding standards
is C++ code. There are some places where C code is used either due to
environment restrictions, historical restrictions, or due to third-party source
code imported into the tree. Generally, our preference is for standards
conforming, modern, and portable C++ code as the implementation language of
choice.
C++ Standard Versions
---------------------
LLVM, Clang, and LLD are currently written using C++11 conforming code,
although we restrict ourselves to features which are available in the major
toolchains supported as host compilers. The LLDB project is even more
aggressive in the set of host compilers supported and thus uses still more
features. Regardless of the supported features, code is expected to (when
reasonable) be standard, portable, and modern C++11 code. We avoid unnecessary
vendor-specific extensions, etc.
C++ Standard Library
--------------------
Use the C++ standard library facilities whenever they are available for
a particular task. LLVM and related projects emphasize and rely on the standard
library facilities for as much as possible. Common support libraries providing
functionality missing from the standard library for which there are standard
interfaces or active work on adding standard interfaces will often be
implemented in the LLVM namespace following the expected standard interface.
There are some exceptions such as the standard I/O streams library which are
avoided. Also, there is much more detailed information on these subjects in the
:doc:`ProgrammersManual`.
Supported C++11 Language and Library Features
---------------------------------------------
While LLVM, Clang, and LLD use C++11, not all features are available in all of
the toolchains which we support. The set of features supported for use in LLVM
is the intersection of those supported in MSVC 2012, GCC 4.7, and Clang 3.1.
The ultimate definition of this set is what build bots with those respective
toolchains accept. Don't argue with the build bots. However, we have some
guidance below to help you know what to expect.
Each toolchain provides a good reference for what it accepts:
* Clang: http://clang.llvm.org/cxx_status.html
* GCC: http://gcc.gnu.org/projects/cxx0x.html
* MSVC: http://msdn.microsoft.com/en-us/library/hh567368.aspx
In most cases, the MSVC list will be the dominating factor. Here is a summary
of the features that are expected to work. Features not on this list are
unlikely to be supported by our host compilers.
* Rvalue references: N2118_
* But *not* Rvalue references for ``*this`` or member qualifiers (N2439_)
* Static assert: N1720_
* ``auto`` type deduction: N1984_, N1737_
* Trailing return types: N2541_
* Lambdas: N2927_
* But *not* lambdas with default arguments.
* ``decltype``: N2343_
* Nested closing right angle brackets: N1757_
* Extern templates: N1987_
* ``nullptr``: N2431_
* Strongly-typed and forward declarable enums: N2347_, N2764_
* Local and unnamed types as template arguments: N2657_
* Range-based for-loop: N2930_
* But ``{}`` are required around inner ``do {} while()`` loops. As a result,
``{}`` are required around function-like macros inside range-based for
loops.
* ``override`` and ``final``: N2928_, N3206_, N3272_
* Atomic operations and the C++11 memory model: N2429_
.. _N2118: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2118.html
.. _N2439: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2439.htm
.. _N1720: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1720.html
.. _N1984: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1984.pdf
.. _N1737: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1737.pdf
.. _N2541: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2541.htm
.. _N2927: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2927.pdf
.. _N2343: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2343.pdf
.. _N1757: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1757.html
.. _N1987: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1987.htm
.. _N2431: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2431.pdf
.. _N2347: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2347.pdf
.. _N2764: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2764.pdf
.. _N2657: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2657.htm
.. _N2930: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2930.html
.. _N2928: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2928.htm
.. _N3206: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3206.htm
.. _N3272: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3272.htm
.. _N2429: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2429.htm
.. _MSVC-compatible RTTI: http://llvm.org/PR18951
The supported features in the C++11 standard libraries are less well tracked,
but also much greater. Most of the standard libraries implement most of C++11's
library. The most likely lowest common denominator is Linux support. For
libc++, the support is just poorly tested and undocumented but expected to be
largely complete. YMMV. For libstdc++, the support is documented in detail in
`the libstdc++ manual`_. There are some very minor missing facilities that are
unlikely to be common problems, and there are a few larger gaps that are worth
being aware of:
* Not all of the type traits are implemented
* No regular expression library.
* While most of the atomics library is well implemented, the fences are
missing. Fortunately, they are rarely needed.
* The locale support is incomplete.
* ``std::initializer_list`` (and the constructors and functions that take it as
an argument) are not always available, so you cannot (for example) initialize
a ``std::vector`` with a braced initializer list.
Other than these areas you should assume the standard library is available and
working as expected until some build bot tells you otherwise. If you're in an
uncertain area of one of the above points, but you cannot test on a Linux
system, your best approach is to minimize your use of these features, and watch
the Linux build bots to find out if your usage triggered a bug. For example, if
you hit a type trait which doesn't work we can then add support to LLVM's
traits header to emulate it.
.. _the libstdc++ manual:
http://gcc.gnu.org/onlinedocs/gcc-4.7.3/libstdc++/manual/manual/status.html#status.iso.2011
Mechanical Source Issues
========================
@ -335,11 +466,88 @@ Indent Code Consistently
^^^^^^^^^^^^^^^^^^^^^^^^
Okay, in your first year of programming you were told that indentation is
important. If you didn't believe and internalize this then, now is the time.
Just do it.
important. If you didn't believe and internalize this then, now is the time.
Just do it. With the introduction of C++11, there are some new formatting
challenges that merit some suggestions to help have consistent, maintainable,
and tool-friendly formatting and indentation.
Compiler Issues
---------------
Format Lambdas Like Blocks Of Code
""""""""""""""""""""""""""""""""""
When formatting a multi-line lambda, format it like a block of code, that's
what it is. If there is only one multi-line lambda in a statement, and there
are no expressions lexically after it in the statement, drop the indent to the
standard two space indent for a block of code, as if it were an if-block opened
by the preceding part of the statement:
.. code-block:: c++
std::sort(foo.begin(), foo.end(), [&](Foo a, Foo b) -> bool {
if (a.blah < b.blah)
return true;
if (a.baz < b.baz)
return true;
return a.bam < b.bam;
});
To take best advantage of this formatting, if you are designing an API which
accepts a continuation or single callable argument (be it a functor, or
a ``std::function``), it should be the last argument if at all possible.
If there are multiple multi-line lambdas in a statement, or there is anything
interesting after the lambda in the statement, indent the block two spaces from
the indent of the ``[]``:
.. code-block:: c++
dyn_switch(V->stripPointerCasts(),
[] (PHINode *PN) {
// process phis...
},
[] (SelectInst *SI) {
// process selects...
},
[] (LoadInst *LI) {
// process loads...
},
[] (AllocaInst *AI) {
// process allocas...
});
Braced Initializer Lists
""""""""""""""""""""""""
With C++11, there are significantly more uses of braced lists to perform
initialization. These allow you to easily construct aggregate temporaries in
expressions among other niceness. They now have a natural way of ending up
nested within each other and within function calls in order to build up
aggregates (such as option structs) from local variables. To make matters
worse, we also have many more uses of braces in an expression context that are
*not* performing initialization.
The historically common formatting of braced initialization of aggregate
variables does not mix cleanly with deep nesting, general expression contexts,
function arguments, and lambdas. We suggest new code use a simple rule for
formatting braced initialization lists: act as-if the braces were parentheses
in a function call. The formatting rules exactly match those already well
understood for formatting nested function calls. Examples:
.. code-block:: c++
foo({a, b, c}, {1, 2, 3});
llvm::Constant *Mask[] = {
llvm::ConstantInt::get(llvm::Type::getInt32Ty(getLLVMContext()), 0),
llvm::ConstantInt::get(llvm::Type::getInt32Ty(getLLVMContext()), 1),
llvm::ConstantInt::get(llvm::Type::getInt32Ty(getLLVMContext()), 2)};
This formatting scheme also makes it particularly easy to get predictable,
consistent, and automatic formatting with tools like `Clang Format`_.
.. _Clang Format: http://clang.llvm.org/docs/ClangFormat.html
Language and Compiler Issues
----------------------------
Treat Compiler Warnings Like Errors
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -399,7 +607,7 @@ is never used for a class. Because of this, we turn them off globally in the
code.
That said, LLVM does make extensive use of a hand-rolled form of RTTI that use
templates like `isa<>, cast<>, and dyn_cast<> <ProgrammersManual.html#isa>`_.
templates like :ref:`isa\<>, cast\<>, and dyn_cast\<> <isa>`.
This form of RTTI is opt-in and can be
:doc:`added to any class <HowToSetUpLLVMStyleRTTI>`. It is also
substantially more efficient than ``dynamic_cast<>``.
@ -451,12 +659,110 @@ members public by default.
Unfortunately, not all compilers follow the rules and some will generate
different symbols based on whether ``class`` or ``struct`` was used to declare
the symbol. This can lead to problems at link time.
the symbol (e.g., MSVC). This can lead to problems at link time.
So, the rule for LLVM is to always use the ``class`` keyword, unless **all**
members are public and the type is a C++ `POD
<http://en.wikipedia.org/wiki/Plain_old_data_structure>`_ type, in which case
``struct`` is allowed.
* All declarations and definitions of a given ``class`` or ``struct`` must use
the same keyword. For example:
.. code-block:: c++
class Foo;
// Breaks mangling in MSVC.
struct Foo { int Data; };
* As a rule of thumb, ``struct`` should be kept to structures where *all*
members are declared public.
.. code-block:: c++
// Foo feels like a class... this is strange.
struct Foo {
private:
int Data;
public:
Foo() : Data(0) { }
int getData() const { return Data; }
void setData(int D) { Data = D; }
};
// Bar isn't POD, but it does look like a struct.
struct Bar {
int Data;
Foo() : Data(0) { }
};
Do not use Braced Initializer Lists to Call a Constructor
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
In C++11 there is a "generalized initialization syntax" which allows calling
constructors using braced initializer lists. Do not use these to call
constructors with any interesting logic or if you care that you're calling some
*particular* constructor. Those should look like function calls using
parentheses rather than like aggregate initialization. Similarly, if you need
to explicitly name the type and call its constructor to create a temporary,
don't use a braced initializer list. Instead, use a braced initializer list
(without any type for temporaries) when doing aggregate initialization or
something notionally equivalent. Examples:
.. code-block:: c++
class Foo {
public:
// Construct a Foo by reading data from the disk in the whizbang format, ...
Foo(std::string filename);
// Construct a Foo by looking up the Nth element of some global data ...
Foo(int N);
// ...
};
// The Foo constructor call is very deliberate, no braces.
std::fill(foo.begin(), foo.end(), Foo("name"));
// The pair is just being constructed like an aggregate, use braces.
bar_map.insert({my_key, my_value});
If you use a braced initializer list when initializing a variable, use an equals before the open curly brace:
.. code-block:: c++
int data[] = {0, 1, 2, 3};
Use ``auto`` Type Deduction to Make Code More Readable
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Some are advocating a policy of "almost always ``auto``" in C++11, however LLVM
uses a more moderate stance. Use ``auto`` if and only if it makes the code more
readable or easier to maintain. Don't "almost always" use ``auto``, but do use
``auto`` with initializers like ``cast<Foo>(...)`` or other places where the
type is already obvious from the context. Another time when ``auto`` works well
for these purposes is when the type would have been abstracted away anyways,
often behind a container's typedef such as ``std::vector<T>::iterator``.
Beware unnecessary copies with ``auto``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The convenience of ``auto`` makes it easy to forget that its default behavior
is a copy. Particularly in range-based ``for`` loops, careless copies are
expensive.
As a rule of thumb, use ``auto &`` unless you need to copy the result, and use
``auto *`` when copying pointers.
.. code-block:: c++
// Typically there's no reason to copy.
for (const auto &Val : Container) { observe(Val); }
for (auto &Val : Container) { Val.change(); }
// Remove the reference if you really want a new copy.
for (auto Val : Container) { Val.change(); saveSomewhere(Val); }
// Copy pointers, but make it clear that they're pointers.
for (const auto *Ptr : Container) { observe(*Ptr); }
for (auto *Ptr : Container) { Ptr->change(); }
Style Issues
============
@ -844,7 +1150,7 @@ Here are more examples:
.. code-block:: c++
assert(Ty->isPointerType() && "Can't allocate a non pointer type!");
assert(Ty->isPointerType() && "Can't allocate a non-pointer type!");
assert((Opcode == Shl || Opcode == Shr) && "ShiftInst Opcode invalid!");
@ -977,9 +1283,9 @@ method will never be implemented. This enables other checks like
``-Wunused-private-field`` to run correctly on classes that contain these
methods.
To maintain compatibility with C++03, ``LLVM_DELETED_FUNCTION`` should be used
which will expand to ``= delete`` if the compiler supports it. These methods
should still be declared private. Example of the uncopyable pattern:
For compatibility with MSVC, ``LLVM_DELETED_FUNCTION`` should be used which
will expand to ``= delete`` on compilers that support it. These methods should
still be declared private. Example of the uncopyable pattern:
.. code-block:: c++
@ -1190,46 +1496,10 @@ Namespace Indentation
In general, we strive to reduce indentation wherever possible. This is useful
because we want code to `fit into 80 columns`_ without wrapping horribly, but
also because it makes it easier to understand the code. Namespaces are a funny
thing: they are often large, and we often desire to put lots of stuff into them
(so they can be large). Other times they are tiny, because they just hold an
enum or something similar. In order to balance this, we use different
approaches for small versus large namespaces.
If a namespace definition is small and *easily* fits on a screen (say, less than
35 lines of code), then you should indent its body. Here's an example:
.. code-block:: c++
namespace llvm {
namespace X86 {
/// \brief An enum for the x86 relocation codes. Note that
/// the terminology here doesn't follow x86 convention - word means
/// 32-bit and dword means 64-bit.
enum RelocationType {
/// \brief PC relative relocation, add the relocated value to
/// the value already in memory, after we adjust it for where the PC is.
reloc_pcrel_word = 0,
/// \brief PIC base relative relocation, add the relocated value to
/// the value already in memory, after we adjust it for where the
/// PIC base is.
reloc_picrel_word = 1,
/// \brief Absolute relocation, just add the relocated value to the
/// value already in memory.
reloc_absolute_word = 2,
reloc_absolute_dword = 3
};
}
}
Since the body is small, indenting adds value because it makes it very clear
where the namespace starts and ends, and it is easy to take the whole thing in
in one "gulp" when reading the code. If the blob of code in the namespace is
larger (as it typically is in a header in the ``llvm`` or ``clang`` namespaces),
do not indent the code, and add a comment indicating what namespace is being
closed. For example:
also because it makes it easier to understand the code. To facilitate this and
avoid some insanely deep nesting on occasion, don't indent namespaces. If it
helps readability, feel free to add a comment indicating what namespace is
being closed by a ``}``. For example:
.. code-block:: c++
@ -1251,12 +1521,12 @@ closed. For example:
} // end namespace knowledge
} // end namespace llvm
Because the class is large, we don't expect that the reader can easily
understand the entire concept in a glance, and the end of the file (where the
namespaces end) may be a long ways away from the place they open. As such,
indenting the contents of the namespace doesn't add any value, and detracts from
the readability of the class. In these cases it is best to *not* indent the
contents of the namespace.
Feel free to skip the closing comment when the namespace being closed is
obvious for any reason. For example, the outer-most namespace in a header file
is rarely a source of confusion. But namespaces both anonymous and named in
source files that are being closed half way through the file probably could use
clarification.
.. _static:
@ -1285,12 +1555,12 @@ good:
.. code-block:: c++
namespace {
class StringSort {
...
public:
StringSort(...)
bool operator<(const char *RHS) const;
};
class StringSort {
...
public:
StringSort(...)
bool operator<(const char *RHS) const;
};
} // end anonymous namespace
static void runHelper() {
@ -1306,6 +1576,7 @@ This is bad:
.. code-block:: c++
namespace {
class StringSort {
...
public:

View File

@ -49,6 +49,17 @@ OPTIONS
The :option:`--strict-whitespace` argument disables this behavior. End-of-line
sequences are canonicalized to UNIX-style ``\n`` in all modes.
.. option:: --implicit-check-not check-pattern
Adds implicit negative checks for the specified patterns between positive
checks. The option allows writing stricter tests without stuffing them with
``CHECK-NOT``\ s.
For example, "``--implicit-check-not warning:``" can be useful when testing
diagnostic messages from tools that don't have an option similar to ``clang
-verify``. With this option FileCheck will verify that input does not contain
warnings not covered by any ``CHECK:`` patterns.
.. option:: -version
Show the version number of this program.

View File

@ -124,10 +124,6 @@ OPTIONS
do not use this option, **bugpoint** will attempt to generate a reference output
by compiling the program with the "safe" backend and running it.
**--profile-info-file** *filename*
Profile file loaded by **--profile-loader**.
**--run-{int,jit,llc,custom}**
Whenever the test program is compiled, **bugpoint** should generate code for it

View File

@ -22,12 +22,13 @@ Basic Commands
llvm-link
llvm-ar
llvm-nm
llvm-prof
llvm-config
llvm-diff
llvm-cov
llvm-profdata
llvm-stress
llvm-symbolizer
llvm-dwarfdump
Debugging Tools
~~~~~~~~~~~~~~~

View File

@ -45,7 +45,7 @@ End-user Options
Generate code at different optimization levels. These correspond to the
``-O0``, ``-O1``, ``-O2``, and ``-O3`` optimization levels used by
:program:`llvm-gcc` and :program:`clang`.
:program:`clang`.
.. option:: -mtriple=<target triple>
@ -112,11 +112,6 @@ End-user Options
optimizations allow the code generator to make use of some instructions which
would otherwise not be usable (such as ``fsin`` on X86).
.. option:: --enable-correct-eh-support
Instruct the **lowerinvoke** pass to insert code for correct exception
handling support. This is expensive and is by default omitted for efficiency.
.. option:: --stats
Print statistics recorded by code-generation passes.

View File

@ -190,12 +190,6 @@ CODE GENERATION OPTIONS
**-enable-correct-eh-support**
Make the -lowerinvoke pass insert expensive, but correct, EH code.
**-jit-enable-eh**
Exception handling should be enabled in the just-in-time compiler.

View File

@ -4,32 +4,120 @@ llvm-cov - emit coverage information
SYNOPSIS
--------
:program:`llvm-cov` [-gcno=filename] [-gcda=filename] [dump]
:program:`llvm-cov` [options] SOURCEFILE
DESCRIPTION
-----------
The experimental :program:`llvm-cov` tool reads in description file generated
by compiler and coverage data file generated by instrumented program. This
program assumes that the description and data file uses same format as gcov
files.
The :program:`llvm-cov` tool reads code coverage data files and displays the
coverage information for a specified source file. It is compatible with the
``gcov`` tool from version 4.2 of ``GCC`` and may also be compatible with
some later versions of ``gcov``.
To use llvm-cov, you must first build an instrumented version of your
application that collects coverage data as it runs. Compile with the
``-fprofile-arcs`` and ``-ftest-coverage`` options to add the
instrumentation. (Alternatively, you can use the ``--coverage`` option, which
includes both of those other options.) You should compile with debugging
information (``-g``) and without optimization (``-O0``); otherwise, the
coverage data cannot be accurately mapped back to the source code.
At the time you compile the instrumented code, a ``.gcno`` data file will be
generated for each object file. These ``.gcno`` files contain half of the
coverage data. The other half of the data comes from ``.gcda`` files that are
generated when you run the instrumented program, with a separate ``.gcda``
file for each object file. Each time you run the program, the execution counts
are summed into any existing ``.gcda`` files, so be sure to remove any old
files if you do not want their contents to be included.
By default, the ``.gcda`` files are written into the same directory as the
object files, but you can override that by setting the ``GCOV_PREFIX`` and
``GCOV_PREFIX_STRIP`` environment variables. The ``GCOV_PREFIX_STRIP``
variable specifies a number of directory components to be removed from the
start of the absolute path to the object file directory. After stripping those
directories, the prefix from the ``GCOV_PREFIX`` variable is added. These
environment variables allow you to run the instrumented program on a machine
where the original object file directories are not accessible, but you will
then need to copy the ``.gcda`` files back to the object file directories
where llvm-cov expects to find them.
Once you have generated the coverage data files, run llvm-cov for each main
source file where you want to examine the coverage results. This should be run
from the same directory where you previously ran the compiler. The results for
the specified source file are written to a file named by appending a ``.gcov``
suffix. A separate output file is also created for each file included by the
main source file, also with a ``.gcov`` suffix added.
The basic content of an llvm-cov output file is a copy of the source file with
an execution count and line number prepended to every line. The execution
count is shown as ``-`` if a line does not contain any executable code. If
a line contains code but that code was never executed, the count is displayed
as ``#####``.
OPTIONS
-------
.. option:: -gcno=filename
.. option:: -a, --all-blocks
This option selects input description file generated by compiler while
instrumenting program.
Display all basic blocks. If there are multiple blocks for a single line of
source code, this option causes llvm-cov to show the count for each block
instead of just one count for the entire line.
.. option:: -gcda=filename
.. option:: -b, --branch-probabilities
This option selects coverage data file generated by instrumented compiler.
Display conditional branch probabilities and a summary of branch information.
.. option:: -dump
.. option:: -c, --branch-counts
This options enables output dump that is suitable for a developer to help
debug :program:`llvm-cov` itself.
Display branch counts instead of probabilities (requires -b).
.. option:: -f, --function-summaries
Show a summary of coverage for each function instead of just one summary for
an entire source file.
.. option:: --help
Display available options (--help-hidden for more).
.. option:: -l, --long-file-names
For coverage output of files included from the main source file, add the
main file name followed by ``##`` as a prefix to the output file names. This
can be combined with the --preserve-paths option to use complete paths for
both the main file and the included file.
.. option:: -n, --no-output
Do not output any ``.gcov`` files. Summary information is still
displayed.
.. option:: -o=<DIR|FILE>, --object-directory=<DIR>, --object-file=<FILE>
Find objects in DIR or based on FILE's path. If you specify a particular
object file, the coverage data files are expected to have the same base name
with ``.gcno`` and ``.gcda`` extensions. If you specify a directory, the
files are expected in that directory with the same base name as the source
file.
.. option:: -p, --preserve-paths
Preserve path components when naming the coverage output files. In addition
to the source file name, include the directories from the path to that
file. The directories are separate by ``#`` characters, with ``.`` directories
removed and ``..`` directories replaced by ``^`` characters. When used with
the --long-file-names option, this applies to both the main file name and the
included file name.
.. option:: -u, --unconditional-branches
Include unconditional branches in the output for the --branch-probabilities
option.
.. option:: -version
Display the version of llvm-cov.
EXIT STATUS
-----------

View File

@ -0,0 +1,30 @@
llvm-dwarfdump - print contents of DWARF sections
=================================================
SYNOPSIS
--------
:program:`llvm-dwarfdump` [*options*] [*filenames...*]
DESCRIPTION
-----------
:program:`llvm-dwarfdump` parses DWARF sections in the object files
and prints their contents in human-readable form.
OPTIONS
-------
.. option:: -debug-dump=section
Specify the DWARF section to dump.
For example, use ``abbrev`` to dump the contents of ``.debug_abbrev`` section,
``loc.dwo`` to dump the contents of ``.debug_loc.dwo`` etc.
See ``llvm-dwarfdump --help`` for the complete list of supported sections.
Use ``all`` to dump all DWARF sections. It is the default.
EXIT STATUS
-----------
:program:`llvm-dwarfdump` returns 0. Other exit codes imply internal
program error.

View File

@ -1,63 +0,0 @@
llvm-prof - print execution profile of LLVM program
===================================================
SYNOPSIS
--------
**llvm-prof** [*options*] [*bitcode file*] [*llvmprof.out*]
DESCRIPTION
-----------
The **llvm-prof** tool reads in an *llvmprof.out* file (which can
optionally use a specific file with the third program argument), a bitcode file
for the program, and produces a human readable report, suitable for determining
where the program hotspots are.
This program is often used in conjunction with the *utils/profile.pl*
script. This script automatically instruments a program, runs it with the JIT,
then runs **llvm-prof** to format a report. To get more information about
*utils/profile.pl*, execute it with the **-help** option.
OPTIONS
-------
**--annotated-llvm** or **-A**
In addition to the normal report printed, print out the code for the
program, annotated with execution frequency information. This can be
particularly useful when trying to visualize how frequently basic blocks
are executed. This is most useful with basic block profiling
information or better.
**--print-all-code**
Using this option enables the **--annotated-llvm** option, but it
prints the entire module, instead of just the most commonly executed
functions.
**--time-passes**
Record the amount of time needed for each pass and print it to standard
error.
EXIT STATUS
-----------
**llvm-prof** returns 1 if it cannot load the bitcode file or the profile
information. Otherwise, it exits with zero.

View File

@ -0,0 +1,102 @@
llvm-profdata - Profile data tool
=================================
SYNOPSIS
--------
:program:`llvm-profdata` *command* [*args...*]
DESCRIPTION
-----------
The :program:`llvm-profdata` tool is a small utility for working with profile
data files.
COMMANDS
--------
* `merge <profdata_merge_>`_
* `show <profdata_show_>`_
.. program:: llvm-profdata merge
.. _profdata_merge:
MERGE
-----
SYNOPSIS
^^^^^^^^
:program:`llvm-profdata merge` [*options*] [*filenames...*]
DESCRIPTION
^^^^^^^^^^^
:program:`llvm-profdata merge` takes several profile data files
generated by PGO instrumentation and merges them together into a single
indexed profile data file.
OPTIONS
^^^^^^^
.. option:: -help
Print a summary of command line options.
.. option:: -output=output, -o=output
Specify the output file name. *Output* cannot be ``-`` as the resulting
indexed profile data can't be written to standard output.
.. program:: llvm-profdata show
.. _profdata_show:
SHOW
----
SYNOPSIS
^^^^^^^^
:program:`llvm-profdata show` [*options*] [*filename*]
DESCRIPTION
^^^^^^^^^^^
:program:`llvm-profdata show` takes a profile data file and displays the
information about the profile counters for this file and
for any of the specified function(s).
If *filename* is omitted or is ``-``, then **llvm-profdata show** reads its
input from standard input.
OPTIONS
^^^^^^^
.. option:: -all-functions
Print details for every function.
.. option:: -counts
Print the counter values for the displayed functions.
.. option:: -function=string
Print details for a function if the function's name contains the given string.
.. option:: -help
Print a summary of command line options.
.. option:: -output=output, -o=output
Specify the output file name. If *output* is ``-`` or it isn't specified,
then the output is sent to standard output.
EXIT STATUS
-----------
:program:`llvm-profdata` returns 1 if the command is omitted or is invalid,
if it cannot read input files, or if there is a mismatch between their data.

View File

@ -10,7 +10,9 @@ DESCRIPTION
-----------
:program:`llvm-symbolizer` reads object file names and addresses from standard
input and prints corresponding source code locations to standard output. This
input and prints corresponding source code locations to standard output.
If object file is specified in command line, :program:`llvm-symbolizer` reads
only addresses from standard input. This
program uses debug info sections and symbol table in the object files.
EXAMPLE
@ -45,13 +47,28 @@ EXAMPLE
_main
/tmp/source_x86_64.cc:8
$ cat addr2.txt
0x4004f4
0x401000
$ llvm-symbolizer -obj=a.out < addr2.txt
main
/tmp/a.cc:4
foo(int)
/tmp/a.cc:12
OPTIONS
-------
.. option:: -functions
.. option:: -obj
Print function names as well as source file/line locations. Defaults to true.
Path to object file to be symbolized.
.. option:: -functions=[none|short|linkage]
Specify the way function names are printed (omit function name,
print short function name, or print full linkage name, respectively).
Defaults to ``linkage``.
.. option:: -use-symbol-table

View File

@ -65,9 +65,8 @@ OPTIONS
.. option:: -std-compile-opts
This is short hand for a standard list of *compile time optimization* passes.
This is typically used to optimize the output from the llvm-gcc front end. It
might be useful for other front end compilers as well. To discover the full
set of options available, use the following command:
It might be useful for other front end compilers as well. To discover the
full set of options available, use the following command:
.. code-block:: sh
@ -100,10 +99,6 @@ OPTIONS
:option:`-std-compile-opts` and :option:`-verify-each` can quickly track down
this kind of problem.
.. option:: -profile-info-file <filename>
Specify the name of the file loaded by the ``-profile-loader`` option.
.. option:: -stats
Print statistics.

View File

@ -15,7 +15,8 @@ users of LLVM will not need to use this program. It is only for assisting with
writing an LLVM target backend.
The input and output of :program:`tblgen` is beyond the scope of this short
introduction. Please see :doc:`../TableGenFundamentals`.
introduction; please see the :doc:`introduction to TableGen
<../TableGen/index>`.
The *filename* argument specifies the name of a Target Description (``.td``)
file to read as input.

View File

@ -1276,7 +1276,7 @@ The ``cl::getRegisteredOptions`` function
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The ``cl::getRegisteredOptions`` function is designed to give a programmer
access to declared non positional command line options so that how they appear
access to declared non-positional command line options so that how they appear
in ``-help`` can be modified prior to calling `cl::ParseCommandLineOptions`_.
Note this method should not be called during any static initialisation because
it cannot be guaranteed that all options will have been initialised. Hence it

View File

@ -80,8 +80,9 @@ R600
SPARC
-----
* `SPARC resources <http://www.sparc.org/resource.htm>`_
* `SPARC standards <http://www.sparc.org/standards.html>`_
* `SPARC standards <http://sparc.org/standards>`_
* `SPARC V9 ABI <http://sparc.org/standards/64.psabi.1.35.ps.Z>`_
* `SPARC V8 ABI <http://sparc.org/standards/psABI3rd.pdf>`_
SystemZ
-------
@ -108,6 +109,12 @@ Other x86-specific information
* `Calling conventions for different C++ compilers and operating systems <http://www.agner.org/optimize/calling_conventions.pdf>`_
XCore
-----
* `The XMOS XS1 Architecture (ISA) <https://www.xmos.com/en/download/public/The-XMOS-XS1-Architecture%28X7879A%29.pdf>`_
* `Tools Development Guide (includes ABI) <https://www.xmos.com/download/public/Tools-Development-Guide%28X9114A%29.pdf>`_
Other relevant lists
--------------------

View File

@ -74,8 +74,8 @@ that notices of confidentiality or non-disclosure cannot be respected.
.. _patch:
.. _one-off patches:
Making a Patch
--------------
Making and Submitting a Patch
-----------------------------
When making a patch for review, the goal is to make it as easy for the reviewer
to read it as possible. As such, we recommend that you:
@ -97,6 +97,12 @@ to read it as possible. As such, we recommend that you:
script, please separate out those changes into a separate patch from the rest
of your changes.
Once your patch is ready, submit it by emailing it to the appropriate project's
commit mailing list (or commit it directly if applicable). Alternatively, some
patches get sent to the project's development list or component of the LLVM bug
tracker, but the commit list is the primary place for reviews and should
generally be preferred.
When sending a patch to a mailing list, it is a good idea to send it as an
*attachment* to the message, not embedded into the text of the message. This
ensures that your mailer will not mangle the patch when it sends it (e.g. by
@ -125,7 +131,8 @@ software. We generally follow these policies:
#. All developers are required to have significant changes reviewed before they
are committed to the repository.
#. Code reviews are conducted by email, usually on the llvm-commits list.
#. Code reviews are conducted by email on the relevant project's commit mailing
list, or alternatively on the project's development list or bug tracker.
#. Code can be reviewed either before it is committed or after. We expect major
changes to be reviewed before being committed, but smaller changes (or
@ -205,13 +212,10 @@ features added. Some tips for getting your testcase approved:
directory. The appropriate sub-directory should be selected (see the
:doc:`Testing Guide <TestingGuide>` for details).
* Test cases should be written in `LLVM assembly language <LangRef.html>`_
unless the feature or regression being tested requires another language
(e.g. the bug being fixed or feature being implemented is in the llvm-gcc C++
front-end, in which case it must be written in C++).
* Test cases should be written in :doc:`LLVM assembly language <LangRef>`.
* Test cases, especially for regressions, should be reduced as much as possible,
by `bugpoint <Bugpoint.html>`_ or manually. It is unacceptable to place an
by :doc:`bugpoint <Bugpoint>` or manually. It is unacceptable to place an
entire failing program into ``llvm/test`` as this creates a *time-to-test*
burden on all developers. Please keep them short.
@ -332,7 +336,7 @@ Making a Major Change
---------------------
When a developer begins a major new project with the aim of contributing it back
to LLVM, s/he should inform the community with an email to the `llvmdev
to LLVM, they should inform the community with an email to the `llvmdev
<http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev>`_ email list, to the extent
possible. The reason for this is to:
@ -413,15 +417,24 @@ to go about making the change.
Attribution of Changes
----------------------
We believe in correct attribution of contributions to their contributors.
However, we do not want the source code to be littered with random attributions
"this code written by J. Random Hacker" (this is noisy and distracting). In
practice, the revision control system keeps a perfect history of who changed
what, and the CREDITS.txt file describes higher-level contributions. If you
commit a patch for someone else, please say "patch contributed by J. Random
Hacker!" in the commit message.
When contributors submit a patch to an LLVM project, other developers with
commit access may commit it for the author once appropriate (based on the
progression of code review, etc.). When doing so, it is important to retain
correct attribution of contributions to their contributors. However, we do not
want the source code to be littered with random attributions "this code written
by J. Random Hacker" (this is noisy and distracting). In practice, the revision
control system keeps a perfect history of who changed what, and the CREDITS.txt
file describes higher-level contributions. If you commit a patch for someone
else, please say "patch contributed by J. Random Hacker!" in the commit
message. Overall, please do not add contributor names to the source code.
Also, don't commit patches authored by others unless they have submitted the
patch to the project or you have been authorized to submit them on their behalf
(you work together and your company authorized you to contribute the patches,
etc.). The author should first submit them to the relevant project's commit
list, development list, or LLVM bug tracker component. If someone sends you
a patch privately, encourage them to submit it to the appropriate list first.
Overall, please do not add contributor names to the source code.
.. _copyright-license-patents:
@ -501,12 +514,12 @@ to move code from (e.g.) libc++ to the LLVM core without concern, but that code
cannot be moved from the LLVM core to libc++ without the copyright owner's
permission.
Note that the LLVM Project does distribute llvm-gcc and dragonegg, **which are
GPL.** This means that anything "linked" into llvm-gcc must itself be compatible
Note that the LLVM Project does distribute dragonegg, **which is
GPL.** This means that anything "linked" into dragonegg must itself be compatible
with the GPL, and must be releasable under the terms of the GPL. This implies
that **any code linked into llvm-gcc and distributed to others may be subject to
that **any code linked into dragonegg and distributed to others may be subject to
the viral aspects of the GPL** (for example, a proprietary code generator linked
into llvm-gcc must be made available under the GPL). This is not a problem for
into dragonegg must be made available under the GPL). This is not a problem for
code already distributed under a more liberal license (like the UIUC license),
and GPL-containing subprojects are kept in separate SVN repositories whose
LICENSE.txt files specifically indicate that they contain GPL code.

View File

@ -142,7 +142,7 @@ continuation points:
#. where to continue if the call raises an exception, either by a throw or the
unwinding of a throw
The term used to define a the place where an ``invoke`` continues after an
The term used to define the place where an ``invoke`` continues after an
exception is called a *landing pad*. LLVM landing pads are conceptually
alternative function entry points where an exception structure reference and a
type info index are passed in as arguments. The landing pad saves the exception
@ -157,12 +157,61 @@ the *selector value* respectively.
The ``landingpad`` instruction takes a reference to the personality function to
be used for this ``try``/``catch`` sequence. The remainder of the instruction is
a list of *cleanup*, *catch*, and *filter* clauses. The exception is tested
against the clauses sequentially from first to last. The selector value is a
positive number if the exception matched a type info, a negative number if it
matched a filter, and zero if it matched a cleanup. If nothing is matched, the
behavior of the program is `undefined`_. If a type info matched, then the
selector value is the index of the type info in the exception table, which can
be obtained using the `llvm.eh.typeid.for`_ intrinsic.
against the clauses sequentially from first to last. The clauses have the
following meanings:
- ``catch <type> @ExcType``
- This clause means that the landingpad block should be entered if the
exception being thrown is of type ``@ExcType`` or a subtype of
``@ExcType``. For C++, ``@ExcType`` is a pointer to the ``std::type_info``
object (an RTTI object) representing the C++ exception type.
- If ``@ExcType`` is ``null``, any exception matches, so the landingpad
should always be entered. This is used for C++ catch-all blocks ("``catch
(...)``").
- When this clause is matched, the selector value will be equal to the value
returned by "``@llvm.eh.typeid.for(i8* @ExcType)``". This will always be a
positive value.
- ``filter <type> [<type> @ExcType1, ..., <type> @ExcTypeN]``
- This clause means that the landingpad should be entered if the exception
being thrown does *not* match any of the types in the list (which, for C++,
are again specified as ``std::type_info`` pointers).
- C++ front-ends use this to implement C++ exception specifications, such as
"``void foo() throw (ExcType1, ..., ExcTypeN) { ... }``".
- When this clause is matched, the selector value will be negative.
- The array argument to ``filter`` may be empty; for example, "``[0 x i8**]
undef``". This means that the landingpad should always be entered. (Note
that such a ``filter`` would not be equivalent to "``catch i8* null``",
because ``filter`` and ``catch`` produce negative and positive selector
values respectively.)
- ``cleanup``
- This clause means that the landingpad should always be entered.
- C++ front-ends use this for calling objects' destructors.
- When this clause is matched, the selector value will be zero.
- The runtime may treat "``cleanup``" differently from "``catch <type>
null``".
In C++, if an unhandled exception occurs, the language runtime will call
``std::terminate()``, but it is implementation-defined whether the runtime
unwinds the stack and calls object destructors first. For example, the GNU
C++ unwinder does not call object destructors when an unhandled exception
occurs. The reason for this is to improve debuggability: it ensures that
``std::terminate()`` is called from the context of the ``throw``, so that
this context is not lost by unwinding the stack. A runtime will typically
implement this by searching for a matching non-``cleanup`` clause, and
aborting if it does not find one, before entering any landingpad blocks.
Once the landing pad has the type info selector, the code branches to the code
for the first catch. The catch then checks the value of the type info selector
@ -278,10 +327,19 @@ This intrinsic returns the type info index in the exception table of the current
function. This value can be used to compare against the result of
``landingpad`` instruction. The single argument is a reference to a type info.
Uses of this intrinsic are generated by the C++ front-end.
SJLJ Intrinsics
---------------
The ``llvm.eh.sjlj`` intrinsics are used internally within LLVM's
backend. Uses of them are generated by the backend's
``SjLjEHPrepare`` pass.
.. _llvm.eh.sjlj.setjmp:
``llvm.eh.sjlj.setjmp``
-----------------------
~~~~~~~~~~~~~~~~~~~~~~~
.. code-block:: llvm
@ -303,7 +361,7 @@ available for use in a target-specific manner.
.. _llvm.eh.sjlj.longjmp:
``llvm.eh.sjlj.longjmp``
------------------------
~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block:: llvm
@ -316,7 +374,7 @@ pointer are restored from the buffer, then control is transferred to the
destination address.
``llvm.eh.sjlj.lsda``
---------------------
~~~~~~~~~~~~~~~~~~~~~
.. code-block:: llvm
@ -328,7 +386,7 @@ function. The SJLJ front-end code stores this address in the exception handling
function context for use by the runtime.
``llvm.eh.sjlj.callsite``
-------------------------
~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block:: llvm

View File

@ -37,7 +37,7 @@ X86/COFF-Dependent
Relocations
^^^^^^^^^^^
The following additional relocation type is supported:
The following additional relocation types are supported:
**@IMGREL** (AT&T syntax only) generates an image-relative relocation that
corresponds to the COFF relocation types ``IMAGE_REL_I386_DIR32NB`` (32-bit) or
@ -54,13 +54,29 @@ corresponds to the COFF relocation types ``IMAGE_REL_I386_DIR32NB`` (32-bit) or
.long (fun@imgrel + 0x3F)
.long $unwind$fun@imgrel
**.secrel32** generates a relocation that corresponds to the COFF relocation
types ``IMAGE_REL_I386_SECREL`` (32-bit) or ``IMAGE_REL_AMD64_SECREL`` (64-bit).
**.secidx** relocation generates an index of the section that contains
the target. It corresponds to the COFF relocation types
``IMAGE_REL_I386_SECTION`` (32-bit) or ``IMAGE_REL_AMD64_SECTION`` (64-bit).
.. code-block:: gas
.section .debug$S,"rn"
.long 4
.long 242
.long 40
.secrel32 _function_name
.secidx _function_name
...
``.linkonce`` Directive
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Syntax:
``.linkonce [ comdat type [ section identifier ] ]``
``.linkonce [ comdat type ]``
Supported COMDAT types:
@ -79,16 +95,6 @@ Supported COMDAT types:
Duplicates are discarded, but the linker issues an error if any duplicates
do not have exactly the same content.
``associative``
Links the section if a certain other COMDAT section is linked. This other
section is indicated by its section identifier following the comdat type.
The following restrictions apply to the associated section:
1. It must be the name of a section already defined.
2. It must differ from the current section.
3. It must be a COMDAT section.
4. It cannot be another associative COMDAT section.
``largest``
Links the largest section from among the duplicates.
@ -102,10 +108,6 @@ Supported COMDAT types:
.linkonce
...
.section .xdata$foo
.linkonce associative .text$foo
...
``.section`` Directive
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -127,9 +129,9 @@ MC supports passing the information in ``.linkonce`` at the end of
Symbol1:
.long 1
Note that in the combined form the COMDAT symbol is explict. This
extension exits to support multiple sections with the same name in
different comdats:
Note that in the combined form the COMDAT symbol is explicit. This
extension exists to support multiple sections with the same name in
different COMDATs:
.. code-block:: gas
@ -143,3 +145,67 @@ different comdats:
.globl Symbol2
Symbol2:
.long 1
In addition to the types allowed with ``.linkonce``, ``.section`` also accepts
``associative``. The meaning is that the section is linked if a certain other
COMDAT section is linked. This other section is indicated by the comdat symbol
in this directive. It can be any symbol defined in the associated section, but
is usually the associated section's comdat.
The following restrictions apply to the associated section:
1. It must be a COMDAT section.
2. It cannot be another associative COMDAT section.
In the following example the symobl ``sym`` is the comdat symbol of ``.foo``
and ``.bar`` is associated to ``.foo``.
.. code-block:: gas
.section .foo,"bw",discard, "sym"
.section .bar,"rd",associative, "sym"
Target Specific Behaviour
=========================
Windows on ARM
--------------
Stack Probe Emission
^^^^^^^^^^^^^^^^^^^^
The reference implementation (Microsoft Visual Studio 2012) emits stack probes
in the following fashion:
.. code-block:: gas
movw r4, #constant
bl __chkstk
sub.w sp, sp, r4
However, this has the limitation of 32 MiB (±16MiB). In order to accommodate
larger binaries, LLVM supports the use of ``-mcode-model=large`` to allow a 4GiB
range via a slight deviation. It will generate an indirect jump as follows:
.. code-block:: gas
movw r4, #constant
movw r12, :lower16:__chkstk
movt r12, :upper16:__chkstk
blx r12
sub.w sp, sp, r4
Variable Length Arrays
^^^^^^^^^^^^^^^^^^^^^^
The reference implementation (Microsoft Visual Studio 2012) does not permit the
emission of Variable Length Arrays (VLAs).
The Windows ARM Itanium ABI extends the base ABI by adding support for emitting
a dynamic stack allocation. When emitting a variable stack allocation, a call
to ``__chkstk`` is emitted unconditionally to ensure that guard pages are setup
properly. The emission of this stack probe emission is handled similar to the
standard stack probe emission.
The MSVC environment does not emit code for VLAs currently.

View File

@ -184,14 +184,6 @@ This is `a bug in GCC <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13392>`_,
and affects projects other than LLVM. Try upgrading or downgrading your GCC.
Compiling LLVM with GCC succeeds, but the resulting tools do not work, what can be wrong?
-----------------------------------------------------------------------------------------
Several versions of GCC have shown a weakness in miscompiling the LLVM
codebase. Please consult your compiler version (``gcc --version``) to find
out whether it is `broken <GettingStarted.html#brokengcc>`_. If so, your only
option is to upgrade GCC to a known good version.
After Subversion update, rebuilding gives the error "No rule to make target".
-----------------------------------------------------------------------------
If the error is of the form:

View File

@ -500,8 +500,7 @@ This boilerplate collector does nothing. More specifically:
* The stack map is not compiled into the executable.
Using the LLVM makefiles (like the `sample project
<http://llvm.org/viewvc/llvm-project/llvm/trunk/projects/sample/>`__), this code
Using the LLVM makefiles, this code
can be compiled as a plugin using a simple makefile:
.. code-block:: make
@ -634,7 +633,7 @@ Threaded
Denotes a multithreaded mutator; the collector must still stop the mutator
("stop the world") before beginning reachability analysis. Stopping a
multithreaded mutator is a complicated problem. It generally requires highly
platform specific code in the runtime, and the production of carefully
platform-specific code in the runtime, and the production of carefully
designed machine code at safe points.
Concurrent

View File

@ -77,7 +77,7 @@ therefore be indexed and requires an index operand. Consider this example:
...
munge(Array);
In this "C" example, the front end compiler (llvm-gcc) will generate three GEP
In this "C" example, the front end compiler (Clang) will generate three GEP
instructions for the three indices through "P" in the assignment statement. The
function argument ``P`` will be the first operand of each of these GEP
instructions. The second operand indexes through that pointer. The third

View File

@ -87,13 +87,10 @@ Here's the short story for getting up and running quickly with LLVM:
* ``make check-all`` --- This run the regression tests to ensure everything
is in working order.
* ``make update`` --- This command is used to update all the svn repositories
at once, rather then having to ``cd`` into the individual repositories and
running ``svn update``.
* It is also possible to use CMake instead of the makefiles. With CMake it is
possible to generate project files for several IDEs: Xcode, Eclipse CDT4,
CodeBlocks, Qt-Creator (use the CodeBlocks generator), KDevelop3.
* It is also possible to use `CMake <CMake.html>`_ instead of the makefiles.
With CMake it is possible to generate project files for several IDEs:
Xcode, Eclipse CDT4, CodeBlocks, Qt-Creator (use the CodeBlocks
generator), KDevelop3.
* If you get an "internal compiler error (ICE)" or test failures, see
`below`.
@ -113,75 +110,32 @@ software you will need.
Hardware
--------
LLVM is known to work on the following platforms:
LLVM is known to work on the following host platforms:
+-----------------+----------------------+-------------------------+
|OS | Arch | Compilers |
+=================+======================+=========================+
|AuroraUX | x86\ :sup:`1` | GCC |
+-----------------+----------------------+-------------------------+
|Linux | x86\ :sup:`1` | GCC |
+-----------------+----------------------+-------------------------+
|Linux | amd64 | GCC |
+-----------------+----------------------+-------------------------+
|Linux | ARM\ :sup:`13` | GCC |
+-----------------+----------------------+-------------------------+
|Solaris | V9 (Ultrasparc) | GCC |
+-----------------+----------------------+-------------------------+
|FreeBSD | x86\ :sup:`1` | GCC |
+-----------------+----------------------+-------------------------+
|FreeBSD | amd64 | GCC |
+-----------------+----------------------+-------------------------+
|MacOS X\ :sup:`2`| PowerPC | GCC |
+-----------------+----------------------+-------------------------+
|MacOS X\ :sup:`9`| x86 | GCC |
+-----------------+----------------------+-------------------------+
|Cygwin/Win32 | x86\ :sup:`1, 8, 11` | GCC 3.4.X, binutils 2.20|
+-----------------+----------------------+-------------------------+
LLVM has partial support for the following platforms:
+-------------------+----------------------+-------------------------------------------+
|OS | Arch | Compilers |
+===================+======================+===========================================+
| Windows | x86\ :sup:`1` | Visual Studio 2000 or higher\ :sup:`4,5` |
+-------------------+----------------------+-------------------------------------------+
| AIX\ :sup:`3,4` | PowerPC | GCC |
+-------------------+----------------------+-------------------------------------------+
| Linux\ :sup:`3,5` | PowerPC | GCC |
+-------------------+----------------------+-------------------------------------------+
| Linux\ :sup:`7` | Alpha | GCC |
+-------------------+----------------------+-------------------------------------------+
| Linux\ :sup:`7` | Itanium (IA-64) | GCC |
+-------------------+----------------------+-------------------------------------------+
| HP-UX\ :sup:`7` | Itanium (IA-64) | HP aCC |
+-------------------+----------------------+-------------------------------------------+
| Windows x64 | x86-64 | mingw-w64's GCC-4.5.x\ :sup:`12` |
+-------------------+----------------------+-------------------------------------------+
================== ===================== =============
OS Arch Compilers
================== ===================== =============
AuroraUX x86\ :sup:`1` GCC
Linux x86\ :sup:`1` GCC, Clang
Linux amd64 GCC, Clang
Linux ARM\ :sup:`4` GCC, Clang
Linux PowerPC GCC, Clang
Solaris V9 (Ultrasparc) GCC
FreeBSD x86\ :sup:`1` GCC, Clang
FreeBSD amd64 GCC, Clang
MacOS X\ :sup:`2` PowerPC GCC
MacOS X x86 GCC, Clang
Cygwin/Win32 x86\ :sup:`1, 3` GCC
Windows x86\ :sup:`1` Visual Studio
Windows x64 x86-64 Visual Studio
================== ===================== =============
.. note::
#. Code generation supported for Pentium processors and up
#. Code generation supported for 32-bit ABI only
#. No native code generation
#. Build is not complete: one or more tools do not link or function
#. The GCC-based C/C++ frontend does not build
#. The port is done using the MSYS shell.
#. Native code generation exists but is not complete.
#. Binutils 2.20 or later is required to build the assembler generated by LLVM properly.
#. Xcode 2.5 and gcc 4.0.1 (Apple Build 5370) will trip internal LLVM assert
messages when compiled for Release at optimization levels greater than 0
(i.e., ``-O1`` and higher). Add ``OPTIMIZE_OPTION="-O0"`` to the build
command line if compiling for LLVM Release or bootstrapping the LLVM
toolchain.
#. For MSYS/MinGW on Windows, be sure to install the MSYS version of the perl
package, and be sure it appears in your path before any Windows-based
versions such as Strawberry Perl and ActivePerl, as these have
Windows-specifics that will cause the build to fail.
#. To use LLVM modules on Win32-based system, you may configure LLVM
with ``--enable-shared``.
#. To compile SPU backend, you need to add ``LDFLAGS=-Wl,--stack,16777216`` to
configure.
#. MCJIT not working well pre-v7, old JIT engine not supported any more.
Note that you will need about 1-3 GB of space for a full LLVM build in Debug
@ -206,44 +160,30 @@ for the software package that LLVM depends on. The Version column provides
"known to work" versions of the package. The Notes column describes how LLVM
uses the package and provides other details.
+--------------------------------------------------------------+-----------------+---------------------------------------------+
| Package | Version | Notes |
+==============================================================+=================+=============================================+
| `GNU Make <http://savannah.gnu.org/projects/make>`_ | 3.79, 3.79.1 | Makefile/build processor |
+--------------------------------------------------------------+-----------------+---------------------------------------------+
| `GCC <http://gcc.gnu.org/>`_ | 3.4.2 | C/C++ compiler\ :sup:`1` |
+--------------------------------------------------------------+-----------------+---------------------------------------------+
| `TeXinfo <http://www.gnu.org/software/texinfo/>`_ | 4.5 | For building the CFE |
+--------------------------------------------------------------+-----------------+---------------------------------------------+
| `SVN <http://subversion.tigris.org/project_packages.html>`_ | >=1.3 | Subversion access to LLVM\ :sup:`2` |
+--------------------------------------------------------------+-----------------+---------------------------------------------+
| `python <http://www.python.org/>`_ | >=2.5 | Automated test suite\ :sup:`3` |
+--------------------------------------------------------------+-----------------+---------------------------------------------+
| `GNU M4 <http://savannah.gnu.org/projects/m4>`_ | 1.4 | Macro processor for configuration\ :sup:`4` |
+--------------------------------------------------------------+-----------------+---------------------------------------------+
| `GNU Autoconf <http://www.gnu.org/software/autoconf/>`_ | 2.60 | Configuration script builder\ :sup:`4` |
+--------------------------------------------------------------+-----------------+---------------------------------------------+
| `GNU Automake <http://www.gnu.org/software/automake/>`_ | 1.9.6 | aclocal macro generator\ :sup:`4` |
+--------------------------------------------------------------+-----------------+---------------------------------------------+
| `libtool <http://savannah.gnu.org/projects/libtool>`_ | 1.5.22 | Shared library manager\ :sup:`4` |
+--------------------------------------------------------------+-----------------+---------------------------------------------+
| `zlib <http://zlib.net>`_ | >=1.2.3.4 | Compression library\ :sup:`5` |
+--------------------------------------------------------------+-----------------+---------------------------------------------+
=========================================================== ============ ==========================================
Package Version Notes
=========================================================== ============ ==========================================
`GNU Make <http://savannah.gnu.org/projects/make>`_ 3.79, 3.79.1 Makefile/build processor
`GCC <http://gcc.gnu.org/>`_ >=4.7.0 C/C++ compiler\ :sup:`1`
`python <http://www.python.org/>`_ >=2.5 Automated test suite\ :sup:`2`
`GNU M4 <http://savannah.gnu.org/projects/m4>`_ 1.4 Macro processor for configuration\ :sup:`3`
`GNU Autoconf <http://www.gnu.org/software/autoconf/>`_ 2.60 Configuration script builder\ :sup:`3`
`GNU Automake <http://www.gnu.org/software/automake/>`_ 1.9.6 aclocal macro generator\ :sup:`3`
`libtool <http://savannah.gnu.org/projects/libtool>`_ 1.5.22 Shared library manager\ :sup:`3`
`zlib <http://zlib.net>`_ >=1.2.3.4 Compression library\ :sup:`4`
=========================================================== ============ ==========================================
.. note::
#. Only the C and C++ languages are needed so there's no need to build the
other languages for LLVM's purposes. See `below` for specific version
info.
#. You only need Subversion if you intend to build from the latest LLVM
sources. If you're working from a release distribution, you don't need
Subversion.
#. Only needed if you want to run the automated test suite in the
``llvm/test`` directory.
#. If you want to make changes to the configure scripts, you will need GNU
autoconf (2.60), and consequently, GNU M4 (version 1.4 or higher). You
will also need automake (1.9.6). We only use aclocal from that package.
#. Optional, adds compression/uncompression capabilities to selected LLVM
#. Optional, adds compression / uncompression capabilities to selected LLVM
tools.
Additionally, your compilation host is expected to have the usual plethora of
@ -277,92 +217,32 @@ Unix utilities. Specifically:
.. _below:
.. _check here:
Broken versions of GCC and other tools
--------------------------------------
Host C++ Toolchain, both Compiler and Standard Library
------------------------------------------------------
LLVM is very demanding of the host C++ compiler, and as such tends to expose
bugs in the compiler. In particular, several versions of GCC crash when trying
to compile LLVM. We routinely use GCC 4.2 (and higher) or Clang. Other
versions of GCC will probably work as well. GCC versions listed here are known
to not work. If you are using one of these versions, please try to upgrade your
GCC to something more recent. If you run into a problem with a version of GCC
not listed here, please `let us know <mailto:llvmdev@cs.uiuc.edu>`_. Please use
the "``gcc -v``" command to find out which version of GCC you are using.
bugs in the compiler. We are also planning to follow improvements and
developments in the C++ language and library reasonably closely. As such, we
require a modern host C++ toolchain, both compiler and standard library, in
order to build LLVM.
**GCC versions prior to 3.0**: GCC 2.96.x and before had several problems in the
STL that effectively prevent it from compiling LLVM.
For the most popular host toolchains we check for specific minimum versions in
our build systems:
**GCC 3.2.2 and 3.2.3**: These versions of GCC fails to compile LLVM with a
bogus template error. This was fixed in later GCCs.
* Clang 3.1
* GCC 4.7
* Visual Studio 2012
**GCC 3.3.2**: This version of GCC suffered from a `serious bug
<http://gcc.gnu.org/PR13392>`_ which causes it to crash in the
"``convert_from_eh_region_ranges_1``" GCC function.
Anything older than these toolchains *may* work, but will require forcing the
build system with a special option and is not really a supported host platform.
Also note that older versions of these compilers have often crashed or
miscompiled LLVM.
**Cygwin GCC 3.3.3**: The version of GCC 3.3.3 commonly shipped with Cygwin does
not work.
For less widely used host toolchains such as ICC or xlC, be aware that a very
recent version may be required to support all of the C++ features used in LLVM.
**SuSE GCC 3.3.3**: The version of GCC 3.3.3 shipped with SuSE 9.1 (and possibly
others) does not compile LLVM correctly (it appears that exception handling is
broken in some cases). Please download the FSF 3.3.3 or upgrade to a newer
version of GCC.
**GCC 3.4.0 on linux/x86 (32-bit)**: GCC miscompiles portions of the code
generator, causing an infinite loop in the llvm-gcc build when built with
optimizations enabled (i.e. a release build).
**GCC 3.4.2 on linux/x86 (32-bit)**: GCC miscompiles portions of the code
generator at -O3, as with 3.4.0. However gcc 3.4.2 (unlike 3.4.0) correctly
compiles LLVM at -O2. A work around is to build release LLVM builds with
"``make ENABLE_OPTIMIZED=1 OPTIMIZE_OPTION=-O2 ...``"
**GCC 3.4.x on X86-64/amd64**: GCC `miscompiles portions of LLVM
<http://llvm.org/PR1056>`__.
**GCC 3.4.4 (CodeSourcery ARM 2005q3-2)**: this compiler miscompiles LLVM when
building with optimizations enabled. It appears to work with "``make
ENABLE_OPTIMIZED=1 OPTIMIZE_OPTION=-O1``" or build a debug build.
**IA-64 GCC 4.0.0**: The IA-64 version of GCC 4.0.0 is known to miscompile LLVM.
**Apple Xcode 2.3**: GCC crashes when compiling LLVM at -O3 (which is the
default with ENABLE_OPTIMIZED=1. To work around this, build with
"``ENABLE_OPTIMIZED=1 OPTIMIZE_OPTION=-O2``".
**GCC 4.1.1**: GCC fails to build LLVM with template concept check errors
compiling some files. At the time of this writing, GCC mainline (4.2) did not
share the problem.
**GCC 4.1.1 on X86-64/amd64**: GCC `miscompiles portions of LLVM
<http://llvm.org/PR1063>`__ when compiling llvm itself into 64-bit code. LLVM
will appear to mostly work but will be buggy, e.g. failing portions of its
testsuite.
**GCC 4.1.2 on OpenSUSE**: Seg faults during libstdc++ build and on x86_64
platforms compiling md5.c gets a mangled constant.
**GCC 4.1.2 (20061115 (prerelease) (Debian 4.1.1-21)) on Debian**: Appears to
miscompile parts of LLVM 2.4. One symptom is ValueSymbolTable complaining about
symbols remaining in the table on destruction.
**GCC 4.1.2 20071124 (Red Hat 4.1.2-42)**: Suffers from the same symptoms as the
previous one. It appears to work with ENABLE_OPTIMIZED=0 (the default).
**Cygwin GCC 4.3.2 20080827 (beta) 2**: Users `reported
<http://llvm.org/PR4145>`_ various problems related with link errors when using
this GCC version.
**Debian GCC 4.3.2 on X86**: Crashes building some files in LLVM 2.6.
**GCC 4.3.3 (Debian 4.3.3-10) on ARM**: Miscompiles parts of LLVM 2.6 when
optimizations are turned on. The symptom is an infinite loop in
``FoldingSetImpl::RemoveNode`` while running the code generator.
**SUSE 11 GCC 4.3.4**: Miscompiles LLVM, causing crashes in ValueHandle logic.
**GCC 4.3.5 and GCC 4.4.5 on ARM**: These can miscompile ``value >> 1`` even at
``-O0``. A test failure in ``test/Assembler/alignstack.ll`` is one symptom of
the problem.
We track certain versions of software that are *known* to fail when used as
part of the host toolchain. These even include linkers at times.
**GCC 4.6.3 on ARM**: Miscompiles ``llvm-readobj`` at ``-O3``. A test failure
in ``test/Object/readobj-shared-object.test`` is one symptom of the problem.
@ -391,6 +271,81 @@ recommend using the system GCC to compile LLVM and Clang in this case.
**Clang 3.0 on Mageia 2**. There's a packaging issue: Clang can not find at
least some (``cxxabi.h``) libstdc++ headers.
**Clang in C++11 mode and libstdc++ 4.7.2**. This version of libstdc++
contained `a bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53841>`__ which
causes Clang to refuse to compile condition_variable header file. At the time
of writing, this breaks LLD build.
Getting a Modern Host C++ Toolchain
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This section mostly applies to Linux and older BSDs. On Mac OS X, you should
have a sufficiently modern Xcode, or you will likely need to upgrade until you
do. On Windows, just use Visual Studio 2012 as the host compiler, it is
explicitly supported and widely available. FreeBSD 10.0 and newer have a modern
Clang as the system compiler.
However, some Linux distributions and some other or older BSDs sometimes have
extremely old versions of GCC. These steps attempt to help you upgrade you
compiler even on such a system. However, if at all possible, we encourage you
to use a recent version of a distribution with a modern system compiler that
meets these requirements. Note that it is tempting to to install a prior
version of Clang and libc++ to be the host compiler, however libc++ was not
well tested or set up to build on Linux until relatively recently. As
a consequence, this guide suggests just using libstdc++ and a modern GCC as the
initial host in a bootstrap, and then using Clang (and potentially libc++).
The first step is to get a recent GCC toolchain installed. The most common
distribution on which users have struggled with the version requirements is
Ubuntu Precise, 12.04 LTS. For this distribution, one easy option is to install
the `toolchain testing PPA`_ and use it to install a modern GCC. There is
a really nice discussions of this on the `ask ubuntu stack exchange`_. However,
not all users can use PPAs and there are many other distributions, so it may be
necessary (or just useful, if you're here you *are* doing compiler development
after all) to build and install GCC from source. It is also quite easy to do
these days.
.. _toolchain testing PPA:
https://launchpad.net/~ubuntu-toolchain-r/+archive/test
.. _ask ubuntu stack exchange:
http://askubuntu.com/questions/271388/how-to-install-gcc-4-8-in-ubuntu-12-04-from-the-terminal
Easy steps for installing GCC 4.8.2:
.. code-block:: console
% wget ftp://ftp.gnu.org/gnu/gcc/gcc-4.8.2/gcc-4.8.2.tar.bz2
% tar -xvjf gcc-4.8.2.tar.bz2
% cd gcc-4.8.2
% ./contrib/download_prerequisites
% cd ..
% mkdir gcc-4.8.2-build
% cd gcc-4.8.2-build
% $PWD/../gcc-4.8.2/configure --prefix=$HOME/toolchains --enable-languages=c,c++
% make -j$(nproc)
% make install
For more details, check out the excellent `GCC wiki entry`_, where I got most
of this information from.
.. _GCC wiki entry:
http://gcc.gnu.org/wiki/InstallingGCC
Once you have a GCC toolchain, use it as your host compiler. Things should
generally "just work". You may need to pass a special linker flag,
``-Wl,-rpath,$HOME/toolchains/lib`` or some variant thereof to get things to
find the libstdc++ DSO in this toolchain.
When you build Clang, you will need to give *it* access to modern C++11
standard library in order to use it as your new host in part of a bootstrap.
There are two easy ways to do this, either build (and install) libc++ along
with Clang and then use it with the ``-stdlib=libc++`` compile and link flag,
or install Clang into the same prefix (``$HOME/toolchains`` above) as GCC.
Clang will look within its own prefix for libstdc++ and use it if found. You
can also add an explicit prefix for Clang to look in for a GCC toolchain with
the ``--gcc-toolchain=/opt/my/gcc/prefix`` flag, passing it to both compile and
link commands when using your just-built-Clang to bootstrap.
.. _Getting Started with LLVM:
Getting Started with LLVM
@ -479,6 +434,7 @@ you can checkout it from the '``tags``' directory (instead of '``trunk``'). The
following releases are located in the following subdirectories of the '``tags``'
directory:
* Release 3.4: **RELEASE_34/final**
* Release 3.3: **RELEASE_33/final**
* Release 3.2: **RELEASE_32/final**
* Release 3.1: **RELEASE_31/final**
@ -725,7 +681,7 @@ The following options can be used to set or enable LLVM specific options:
Enables optimized compilation (debugging symbols are removed and GCC
optimization flags are enabled). Note that this is the default setting if you
are using the LLVM distribution. The default behavior of an Subversion
are using the LLVM distribution. The default behavior of a Subversion
checkout is to use an unoptimized build (also known as a debug build).
``--enable-debug-runtime``
@ -743,14 +699,12 @@ The following options can be used to set or enable LLVM specific options:
Controls which targets will be built and linked into llc. The default value
for ``target_options`` is "all" which builds and links all available targets.
The value "host-only" can be specified to build only a native compiler (no
cross-compiler targets available). The "native" target is selected as the
target of the build host. You can also specify a comma separated list of
target names that you want available in llc. The target names use all lower
case. The current set of targets is:
The "host" target is selected as the target of the build host. You can also
specify a comma separated list of target names that you want available in llc.
The target names use all lower case. The current set of targets is:
``arm, cpp, hexagon, mips, mipsel, msp430, powerpc, ptx, sparc, spu,
systemz, x86, x86_64, xcore``.
``aarch64, arm, arm64, cpp, hexagon, mips, mipsel, mips64, mips64el, msp430,
powerpc, nvptx, r600, sparc, systemz, x86, x86_64, xcore``.
``--enable-doxygen``
@ -759,13 +713,6 @@ The following options can be used to set or enable LLVM specific options:
generating the documentation can take a long time and producess 100s of
megabytes of output.
``--with-udis86``
LLVM can use external disassembler library for various purposes (now it's used
only for examining code produced by JIT). This option will enable usage of
`udis86 <http://udis86.sourceforge.net/>`_ x86 (both 32 and 64 bits)
disassembler library.
To configure LLVM, follow these steps:
#. Change directory into the object root directory:
@ -788,7 +735,7 @@ builds:
Debug Builds
These builds are the default when one is using an Subversion checkout and
These builds are the default when one is using a Subversion checkout and
types ``gmake`` (unless the ``--enable-optimized`` option was used during
configuration). The build system will compile the tools and libraries with
debugging information. To get a Debug Build using the LLVM distribution the
@ -1123,8 +1070,7 @@ different `tools`_.
This directory contains projects that are not strictly part of LLVM but are
shipped with LLVM. This is also the directory where you should create your own
LLVM-based projects. See ``llvm/projects/sample`` for an example of how to set
up your own project.
LLVM-based projects.
``llvm/runtime``
----------------

View File

@ -34,7 +34,7 @@ Most of the tools build and work. ``bugpoint`` does build, but does
not work.
Additional information about the LLVM directory structure and tool chain
can be found on the main `Getting Started <GettingStarted.html>`_ page.
can be found on the main :doc:`GettingStarted` page.
Requirements
@ -45,15 +45,13 @@ and software you will need.
Hardware
--------
Any system that can adequately run Visual Studio 2010 is fine. The LLVM
Any system that can adequately run Visual Studio 2012 is fine. The LLVM
source tree and object files, libraries and executables will consume
approximately 3GB.
Software
--------
You will need Visual Studio 2010 or higher. Earlier versions of Visual
Studio have bugs, are not completely compatible, or do not support the C++
standard well enough.
You will need Visual Studio 2012 or higher.
You will also need the `CMake <http://www.cmake.org/>`_ build system since it
generates the project files you will use to build with.
@ -99,8 +97,11 @@ Here's the short story for getting up and running quickly with LLVM:
using LLVM. Another important option is ``LLVM_TARGETS_TO_BUILD``,
which controls the LLVM target architectures that are included on the
build.
* See the `LLVM CMake guide <CMake.html>`_ for detailed information about
* See the :doc:`LLVM CMake guide <CMake>` for detailed information about
how to configure the LLVM build.
* CMake generates project files for all build types. To select a specific
build type, use the Configuration manager from the VS IDE or the
``/property:Configuration`` command line option when using MSBuild.
6. Start Visual Studio
@ -121,16 +122,14 @@ Here's the short story for getting up and running quickly with LLVM:
or run it from the command line. The program will print the
corresponding fibonacci value.
8. Test LLVM on Visual Studio:
8. Test LLVM in Visual Studio:
* If ``%PATH%`` does not contain GnuWin32, you may specify
``LLVM_LIT_TOOLS_DIR`` on CMake for the path to GnuWin32.
* You can run LLVM tests by merely building the project "check". The test
results will be shown in the VS output window.
.. FIXME: Is it up-to-date?
9. Test LLVM:
9. Test LLVM on the command line:
* The LLVM tests can be run by changing directory to the llvm source
directory and running:
@ -219,8 +218,8 @@ An Example Using the LLVM Tool Chain
Common Problems
===============
If you are having problems building or using LLVM, or if you have any other
general questions about LLVM, please consult the `Frequently Asked Questions
<FAQ.html>`_ page.
general questions about LLVM, please consult the :doc:`Frequently Asked Questions
<FAQ>` page.
Links

View File

@ -22,12 +22,15 @@ create the binary packages, please refer to the :doc:`ReleaseProcess` instead.
Release Timeline
================
LLVM is released on a time based schedule --- roughly every 6 months. We do
not normally have dot releases because of the nature of LLVM's incremental
development philosophy. That said, the only thing preventing dot releases for
critical bug fixes from happening is a lack of resources --- testers,
machines, time, etc. And, because of the high quality we desire for LLVM
releases, we cannot allow for a truncated form of release qualification.
LLVM is released on a time based schedule --- with major releases roughly
every 6 months. In between major releases there may be dot releases.
The release manager will determine if and when to make a dot release based
on feedback from the community. Typically, dot releases should be made if
there are large number of bug-fixes in the stable branch or a critical bug
has been discovered that affects a large number of users.
Unless otherwise stated, dot releases will follow the same procedure as
major releases.
The release process is roughly as follows:
@ -51,6 +54,10 @@ The release process is roughly as follows:
* Finally, release!
The release process will be accelerated for dot releases. If the first round
of testing finds no critical bugs and no regressions since the last major release,
then additional rounds of testing will not be required.
Release Process
===============
@ -139,25 +146,25 @@ following commands:
::
$ svn mkdir https://llvm.org/svn/llvm-project/llvm/tags/RELEASE_XY
$ svn mkdir https://llvm.org/svn/llvm-project/llvm/tags/RELEASE_XYZ
$ svn copy https://llvm.org/svn/llvm-project/llvm/branches/release_XY \
https://llvm.org/svn/llvm-project/llvm/tags/RELEASE_XY/rc1
https://llvm.org/svn/llvm-project/llvm/tags/RELEASE_XYZ/rc1
$ svn mkdir https://llvm.org/svn/llvm-project/cfe/tags/RELEASE_XY
$ svn mkdir https://llvm.org/svn/llvm-project/cfe/tags/RELEASE_XYZ
$ svn copy https://llvm.org/svn/llvm-project/cfe/branches/release_XY \
https://llvm.org/svn/llvm-project/cfe/tags/RELEASE_XY/rc1
https://llvm.org/svn/llvm-project/cfe/tags/RELEASE_XYZ/rc1
$ svn mkdir https://llvm.org/svn/llvm-project/dragonegg/tags/RELEASE_XY
$ svn mkdir https://llvm.org/svn/llvm-project/dragonegg/tags/RELEASE_XYZ
$ svn copy https://llvm.org/svn/llvm-project/dragonegg/branches/release_XY \
https://llvm.org/svn/llvm-project/dragonegg/tags/RELEASE_XY/rc1
https://llvm.org/svn/llvm-project/dragonegg/tags/RELEASE_XYZ/rc1
$ svn mkdir https://llvm.org/svn/llvm-project/test-suite/tags/RELEASE_XY
$ svn mkdir https://llvm.org/svn/llvm-project/test-suite/tags/RELEASE_XYZ
$ svn copy https://llvm.org/svn/llvm-project/test-suite/branches/release_XY \
https://llvm.org/svn/llvm-project/test-suite/tags/RELEASE_XY/rc1
https://llvm.org/svn/llvm-project/test-suite/tags/RELEASE_XYZ/rc1
Similarly, **Release Candidate 2** would be named ``RC2`` and so on. This keeps
a permanent copy of the release candidate around for people to export and build
as they wish. The final released sources will be tagged in the ``RELEASE_XY``
as they wish. The final released sources will be tagged in the ``RELEASE_XYZ``
directory as ``Final`` (c.f. :ref:`tag`).
The Release Manager may supply pre-packaged source tarballs for users. This can
@ -165,10 +172,10 @@ be done with the following commands:
::
$ svn export https://llvm.org/svn/llvm-project/llvm/tags/RELEASE_XY/rc1 llvm-X.Yrc1
$ svn export https://llvm.org/svn/llvm-project/cfe/tags/RELEASE_XY/rc1 clang-X.Yrc1
$ svn export https://llvm.org/svn/llvm-project/dragonegg/tags/RELEASE_XY/rc1 dragonegg-X.Yrc1
$ svn export https://llvm.org/svn/llvm-project/test-suite/tags/RELEASE_XY/rc1 llvm-test-X.Yrc1
$ svn export https://llvm.org/svn/llvm-project/llvm/tags/RELEASE_XYZ/rc1 llvm-X.Yrc1
$ svn export https://llvm.org/svn/llvm-project/cfe/tags/RELEASE_XYZ/rc1 clang-X.Yrc1
$ svn export https://llvm.org/svn/llvm-project/dragonegg/tags/RELEASE_XYZ/rc1 dragonegg-X.Yrc1
$ svn export https://llvm.org/svn/llvm-project/test-suite/tags/RELEASE_XYZ/rc1 llvm-test-X.Yrc1
$ tar -cvf - llvm-X.Yrc1 | gzip > llvm-X.Yrc1.src.tar.gz
$ tar -cvf - clang-X.Yrc1 | gzip > clang-X.Yrc1.src.tar.gz
@ -238,6 +245,8 @@ when qualifying the build of ``llvm``, ``clang``, and ``dragonegg``.
+--------------+---------------+----------------------+
| x86-64 | FreeBSD | gcc 4.2.X |
+--------------+---------------+----------------------+
| ARMv7 | Linux | gcc 4.6.X, gcc 4.7.X |
+--------------+---------------+----------------------+
Release Qualification Criteria
------------------------------
@ -298,6 +307,10 @@ Specific Target Qualification Details
| | | | clang regression tests, |
| | | | test-suite |
+--------------+-------------+----------------+-----------------------------+
| ARMv7A | Linux | last release | llvm regression tests, |
| | | | clang regression tests, |
| | | | test-suite |
+--------------+-------------+----------------+-----------------------------+
Community Testing
-----------------
@ -346,6 +359,9 @@ Below are the rules regarding patching the release branch:
#. During the remaining rounds of testing, only patches that fix critical
regressions may be applied.
#. For dot releases all patches must mantain both API and ABI compatibility with
the previous major release. Only bugfixes will be accepted.
Release Final Tasks
-------------------
@ -373,16 +389,16 @@ Tag the final release sources using the following procedure:
::
$ svn copy https://llvm.org/svn/llvm-project/llvm/branches/release_XY \
https://llvm.org/svn/llvm-project/llvm/tags/RELEASE_XY/Final
https://llvm.org/svn/llvm-project/llvm/tags/RELEASE_XYZ/Final
$ svn copy https://llvm.org/svn/llvm-project/cfe/branches/release_XY \
https://llvm.org/svn/llvm-project/cfe/tags/RELEASE_XY/Final
https://llvm.org/svn/llvm-project/cfe/tags/RELEASE_XYZ/Final
$ svn copy https://llvm.org/svn/llvm-project/dragonegg/branches/release_XY \
https://llvm.org/svn/llvm-project/dragonegg/tags/RELEASE_XY/Final
https://llvm.org/svn/llvm-project/dragonegg/tags/RELEASE_XYZ/Final
$ svn copy https://llvm.org/svn/llvm-project/test-suite/branches/release_XY \
https://llvm.org/svn/llvm-project/test-suite/tags/RELEASE_XY/Final
https://llvm.org/svn/llvm-project/test-suite/tags/RELEASE_XYZ/Final
Update the LLVM Demo Page
-------------------------

View File

@ -223,8 +223,8 @@ steps:
[...]
template <class T>
static bool classof(const T *,
::llvm::enable_if_c<
::llvm::is_base_of<Foo, T>::value
::std::enable_if<
::std::is_base_of<Foo, T>::value
>::type* = 0) { return true; }
[...]
};

View File

@ -43,15 +43,15 @@ the LLVM libraries (e.g. the optimizer or code generator) that has
problems.
To figure out which component is crashing (the front-end, optimizer or code
generator), run the ``llvm-gcc`` command line as you were when the crash
generator), run the ``clang`` command line as you were when the crash
occurred, but with the following extra command line options:
* ``-O0 -emit-llvm``: If ``llvm-gcc`` still crashes when passed these
* ``-O0 -emit-llvm``: If ``clang`` still crashes when passed these
options (which disable the optimizer and code generator), then the crash
is in the front-end. Jump ahead to the section on :ref:`front-end bugs
<front-end>`.
* ``-emit-llvm``: If ``llvm-gcc`` crashes with this option (which disables
* ``-emit-llvm``: If ``clang`` crashes with this option (which disables
the code generator), you found an optimizer bug. Jump ahead to
`compile-time optimization bugs`_.
@ -64,12 +64,12 @@ occurred, but with the following extra command line options:
Front-end bugs
--------------
If the problem is in the front-end, you should re-run the same ``llvm-gcc``
If the problem is in the front-end, you should re-run the same ``clang``
command that resulted in the crash, but add the ``-save-temps`` option.
The compiler will crash again, but it will leave behind a ``foo.i`` file
(containing preprocessed C source code) and possibly ``foo.s`` for each
compiled ``foo.c`` file. Send us the ``foo.i`` file, along with the options
you passed to ``llvm-gcc``, and a brief description of the error it caused.
you passed to ``clang``, and a brief description of the error it caused.
The `delta <http://delta.tigris.org/>`_ tool helps to reduce the
preprocessed file down to the smallest amount of code that still replicates
@ -92,7 +92,7 @@ Then run:
opt -std-compile-opts -debug-pass=Arguments foo.bc -disable-output
This command should do two things: it should print out a list of passes, and
then it should crash in the same way as llvm-gcc. If it doesn't crash, please
then it should crash in the same way as clang. If it doesn't crash, please
follow the instructions for a `front-end bug`_.
If this does crash, then you should be able to debug this with the following
@ -111,9 +111,9 @@ submit the "foo.bc" file and the list of passes printed by ``opt``.
Code generator bugs
-------------------
If you find a bug that crashes llvm-gcc in the code generator, compile your
If you find a bug that crashes clang in the code generator, compile your
source file to a .bc file by passing "``-emit-llvm -c -o foo.bc``" to
llvm-gcc (in addition to the options you already pass). Once your have
clang (in addition to the options you already pass). Once your have
foo.bc, one of the following commands should fail:
#. ``llc foo.bc``
@ -138,7 +138,7 @@ the "foo.bc" file and the option that llc crashes with.
Miscompilations
===============
If llvm-gcc successfully produces an executable, but that executable
If clang successfully produces an executable, but that executable
doesn't run right, this is either a bug in the code or a bug in the
compiler. The first thing to check is to make sure it is not using
undefined behavior (e.g. reading a variable before it is defined). In

160
docs/InAlloca.rst Normal file
View File

@ -0,0 +1,160 @@
==========================================
Design and Usage of the InAlloca Attribute
==========================================
Introduction
============
The :ref:`inalloca <attr_inalloca>` attribute is designed to allow
taking the address of an aggregate argument that is being passed by
value through memory. Primarily, this feature is required for
compatibility with the Microsoft C++ ABI. Under that ABI, class
instances that are passed by value are constructed directly into
argument stack memory. Prior to the addition of inalloca, calls in LLVM
were indivisible instructions. There was no way to perform intermediate
work, such as object construction, between the first stack adjustment
and the final control transfer. With inalloca, all arguments passed in
memory are modelled as a single alloca, which can be stored to prior to
the call. Unfortunately, this complicated feature comes with a large
set of restrictions designed to bound the lifetime of the argument
memory around the call.
For now, it is recommended that frontends and optimizers avoid producing
this construct, primarily because it forces the use of a base pointer.
This feature may grow in the future to allow general mid-level
optimization, but for now, it should be regarded as less efficient than
passing by value with a copy.
Intended Usage
==============
The example below is the intended LLVM IR lowering for some C++ code
that passes two default-constructed ``Foo`` objects to ``g`` in the
32-bit Microsoft C++ ABI.
.. code-block:: c++
// Foo is non-trivial.
struct Foo { int a, b; Foo(); ~Foo(); Foo(const Foo &); };
void g(Foo a, Foo b);
void f() {
g(Foo(), Foo());
}
.. code-block:: llvm
%struct.Foo = type { i32, i32 }
declare void @Foo_ctor(%struct.Foo* %this)
declare void @Foo_dtor(%struct.Foo* %this)
declare void @g(<{ %struct.Foo, %struct.Foo }>* inalloca %memargs)
define void @f() {
entry:
%base = call i8* @llvm.stacksave()
%memargs = alloca <{ %struct.Foo, %struct.Foo }>
%b = getelementptr <{ %struct.Foo, %struct.Foo }>* %memargs, i32 1
call void @Foo_ctor(%struct.Foo* %b)
; If a's ctor throws, we must destruct b.
%a = getelementptr <{ %struct.Foo, %struct.Foo }>* %memargs, i32 0
invoke void @Foo_ctor(%struct.Foo* %a)
to label %invoke.cont unwind %invoke.unwind
invoke.cont:
call void @g(<{ %struct.Foo, %struct.Foo }>* inalloca %memargs)
call void @llvm.stackrestore(i8* %base)
...
invoke.unwind:
call void @Foo_dtor(%struct.Foo* %b)
call void @llvm.stackrestore(i8* %base)
...
}
To avoid stack leaks, the frontend saves the current stack pointer with
a call to :ref:`llvm.stacksave <int_stacksave>`. Then, it allocates the
argument stack space with alloca and calls the default constructor. The
default constructor could throw an exception, so the frontend has to
create a landing pad. The frontend has to destroy the already
constructed argument ``b`` before restoring the stack pointer. If the
constructor does not unwind, ``g`` is called. In the Microsoft C++ ABI,
``g`` will destroy its arguments, and then the stack is restored in
``f``.
Design Considerations
=====================
Lifetime
--------
The biggest design consideration for this feature is object lifetime.
We cannot model the arguments as static allocas in the entry block,
because all calls need to use the memory at the top of the stack to pass
arguments. We cannot vend pointers to that memory at function entry
because after code generation they will alias.
The rule against allocas between argument allocations and the call site
avoids this problem, but it creates a cleanup problem. Cleanup and
lifetime is handled explicitly with stack save and restore calls. In
the future, we may want to introduce a new construct such as ``freea``
or ``afree`` to make it clear that this stack adjusting cleanup is less
powerful than a full stack save and restore.
Nested Calls and Copy Elision
-----------------------------
We also want to be able to support copy elision into these argument
slots. This means we have to support multiple live argument
allocations.
Consider the evaluation of:
.. code-block:: c++
// Foo is non-trivial.
struct Foo { int a; Foo(); Foo(const &Foo); ~Foo(); };
Foo bar(Foo b);
int main() {
bar(bar(Foo()));
}
In this case, we want to be able to elide copies into ``bar``'s argument
slots. That means we need to have more than one set of argument frames
active at the same time. First, we need to allocate the frame for the
outer call so we can pass it in as the hidden struct return pointer to
the middle call. Then we do the same for the middle call, allocating a
frame and passing its address to ``Foo``'s default constructor. By
wrapping the evaluation of the inner ``bar`` with stack save and
restore, we can have multiple overlapping active call frames.
Callee-cleanup Calling Conventions
----------------------------------
Another wrinkle is the existence of callee-cleanup conventions. On
Windows, all methods and many other functions adjust the stack to clear
the memory used to pass their arguments. In some sense, this means that
the allocas are automatically cleared by the call. However, LLVM
instead models this as a write of undef to all of the inalloca values
passed to the call instead of a stack adjustment. Frontends should
still restore the stack pointer to avoid a stack leak.
Exceptions
----------
There is also the possibility of an exception. If argument evaluation
or copy construction throws an exception, the landing pad must do
cleanup, which includes adjusting the stack pointer to avoid a stack
leak. This means the cleanup of the stack memory cannot be tied to the
call itself. There needs to be a separate IR-level instruction that can
perform independent cleanup of arguments.
Efficiency
----------
Eventually, it should be possible to generate efficient code for this
construct. In particular, using inalloca should not require a base
pointer. If the backend can prove that all points in the CFG only have
one possible stack level, then it can address the stack directly from
the stack pointer. While this is not yet implemented, the plan is that
the inalloca attribute should not change much, but the frontend IR
generation recommendations may change.

View File

@ -86,8 +86,8 @@ LLVM primarily uses the following types of components:
libraries that they build on top of.
- *Build Tools* - Build tools are applications which are designed to be run
as part of the build process (typically to generate other source files).
Currently, LLVM uses one main build tool called :doc:`TableGen
<TableGenFundamentals>` to generate a variety of source files.
Currently, LLVM uses one main build tool called :doc:`TableGen/index`
to generate a variety of source files.
- *Tools* - Command line applications which are built using the LLVM
component libraries. Most LLVM tools are small and are primarily
frontends to the library interfaces.
@ -315,7 +315,7 @@ the properties which are associated with that component.
``BuildTool`` components are like ``Tool`` components, except that the
tool is supposed to be built for the platform where the build is running
(instead of that platform being targetted). Build systems are expected
(instead of that platform being targeted). Build systems are expected
to handle the fact that required libraries may need to be built for
multiple platforms in order to be able to link this tool.

Some files were not shown because too many files have changed in this diff Show More