1
0
mirror of https://github.com/openbsd/src.git synced 2026-06-18 15:23:33 +02:00

import llvm from LLVM-21.1.6

This commit is contained in:
robert
2026-05-29 11:00:35 +00:00
parent 2d3bf90322
commit d93fb232b2
6923 changed files with 805915 additions and 306700 deletions
+1 -1
View File
@@ -1,2 +1,2 @@
BasedOnStyle: LLVM
LineEnding: LF
+2
View File
@@ -25,9 +25,11 @@ test/tools/llvm-mca/X86/directives-handle-crlf.s text eol=crlf
# These files must have LF line endings because the test requires exact matching
test/Object/Inputs/*.tbd eol=lf
test/tools/llvm-rc/Inputs/webpage*.html text eol=lf
test/tools/llvm-strings/radix.test text eol=lf
test/tools/llvm-tapi-diff/Inputs/*.tbd text eol=lf
test/tools/split-file/basic.test text eol=lf
test/tools/split-file/Inputs/basic-*.txt eol=lf
test/tools/split-file/basic.crlf.test text eol=crlf
test/tools/split-file/Inputs/basic-*.crlf eol=crlf
test/tools/llvm-objcopy/MachO/Inputs/macho_sections.s text eol=lf
+1
View File
@@ -32,6 +32,7 @@ autoconf/autom4te.cache
/CMakeSettings.json
# CLion project configuration
/.idea
/cmake-build*
# Qt Creator project configuration
/CMakeLists.txt.user
+212 -97
View File
@@ -1,7 +1,8 @@
# See docs/CMake.html for instructions about how to build LLVM with CMake.
cmake_minimum_required(VERSION 3.20.0)
include(CMakeDependentOption)
set(LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/../cmake)
include(${LLVM_COMMON_CMAKE_UTILS}/Modules/CMakePolicy.cmake
NO_POLICY_SCOPE)
@@ -25,7 +26,7 @@ if (NOT PACKAGE_VERSION)
endif()
if(NOT DEFINED LLVM_SHLIB_SYMBOL_VERSION)
# "Symbol version prefix for libLLVM.so"
# "Symbol version prefix for libLLVM.so and libclang-cpp.so"
set(LLVM_SHLIB_SYMBOL_VERSION "LLVM_${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}")
endif()
@@ -75,25 +76,13 @@ endif()
set(CMAKE_CXX_STANDARD ${LLVM_REQUIRED_CXX_STANDARD} CACHE STRING "C++ standard to conform to")
set(CMAKE_CXX_STANDARD_REQUIRED YES)
if (CYGWIN)
# Cygwin is a bit stricter and lack things like 'strdup', 'stricmp', etc in
# c++xx mode.
set(CMAKE_CXX_EXTENSIONS YES)
else()
set(CMAKE_CXX_EXTENSIONS NO)
endif()
set(CMAKE_CXX_EXTENSIONS NO)
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(FATAL_ERROR "
No build type selected. You need to pass -DCMAKE_BUILD_TYPE=<type> in order to configure LLVM.
Available options are:
* -DCMAKE_BUILD_TYPE=Release - For an optimized build with no assertions or debug info.
* -DCMAKE_BUILD_TYPE=Debug - For an unoptimized build with assertions and debug info.
* -DCMAKE_BUILD_TYPE=RelWithDebInfo - For an optimized build with no assertions but with debug info.
* -DCMAKE_BUILD_TYPE=MinSizeRel - For a build optimized for size instead of speed.
Learn more about these options in our documentation at https://llvm.org/docs/CMake.html#cmake-build-type
message(WARNING "No build type selected. Defaulted CMAKE_BUILD_TYPE=Release.
Learn more about the options in our documentation at https://llvm.org/docs/CMake.html#cmake-build-type
")
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel" FORCE)
endif()
# Set default build type for cmake's try_compile module.
@@ -114,9 +103,20 @@ endif()
# LLVM_EXTERNAL_${project}_SOURCE_DIR using LLVM_ALL_PROJECTS
# This allows an easy way of setting up a build directory for llvm and another
# one for llvm+clang+... using the same sources.
set(LLVM_ALL_PROJECTS "bolt;clang;clang-tools-extra;compiler-rt;cross-project-tests;libc;libclc;lld;lldb;mlir;openmp;polly;pstl")
# The flang project is not yet part of "all" projects (see C++ requirements)
set(LLVM_EXTRA_PROJECTS "flang")
# These projects will be included when "all" is included in LLVM_ENABLE_PROJECTS.
set(LLVM_ALL_PROJECTS "bolt;clang;clang-tools-extra;compiler-rt;cross-project-tests;libclc;lld;lldb;mlir;openmp;polly")
if ("${CMAKE_SYSTEM_NAME}" MATCHES "AIX")
# Disallow 'openmp' as a LLVM PROJECT on AIX as the supported way is to use
# LLVM_ENABLE_RUNTIMES.
list(REMOVE_ITEM LLVM_ALL_PROJECTS openmp)
endif()
# The "libc" project, which is not part of "all" projects, could be included in
# LLVM_ENABLE_PROJECTS. It is preferred to include "libc" in
# LLVM_ENABLE_RUNTIMES instead of LLVM_ENABLE_PROJECTS.
#
# The flang project is not yet part of "all" projects (see C++ requirements).
set(LLVM_EXTRA_PROJECTS "flang" "libc")
# List of all known projects in the mono repo
set(LLVM_KNOWN_PROJECTS "${LLVM_ALL_PROJECTS};${LLVM_EXTRA_PROJECTS}")
set(LLVM_ENABLE_PROJECTS "" CACHE STRING
@@ -125,29 +125,19 @@ set(LLVM_ENABLE_PROJECTS "" CACHE STRING
if( LLVM_ENABLE_PROJECTS STREQUAL "all" )
set( LLVM_ENABLE_PROJECTS ${LLVM_ALL_PROJECTS})
endif()
foreach(proj ${LLVM_ENABLE_PROJECTS})
if (NOT proj STREQUAL "llvm" AND NOT "${proj}" IN_LIST LLVM_KNOWN_PROJECTS)
MESSAGE(FATAL_ERROR "${proj} isn't a known project: ${LLVM_KNOWN_PROJECTS}. Did you mean to enable it as a runtime in LLVM_ENABLE_RUNTIMES?")
endif()
endforeach()
if ("flang" IN_LIST LLVM_ENABLE_PROJECTS)
if (NOT "mlir" IN_LIST LLVM_ENABLE_PROJECTS)
message(STATUS "Enabling MLIR as a dependency to flang")
list(APPEND LLVM_ENABLE_PROJECTS "mlir")
endif()
if (NOT "clang" IN_LIST LLVM_ENABLE_PROJECTS)
message(FATAL_ERROR "Clang is not enabled, but is required for the Flang driver")
endif()
endif()
# Select the runtimes to build
#
# As we migrate runtimes to using the bootstrapping build, the set of default runtimes
# should grow as we remove those runtimes from LLVM_ENABLE_PROJECTS above.
set(LLVM_DEFAULT_RUNTIMES "libcxx;libcxxabi;libunwind")
set(LLVM_SUPPORTED_RUNTIMES "libc;libunwind;libcxxabi;pstl;libcxx;compiler-rt;openmp;llvm-libgcc;offload")
set(LLVM_SUPPORTED_RUNTIMES "libc;libunwind;libcxxabi;libcxx;compiler-rt;openmp;llvm-libgcc;offload;flang-rt;libclc;libsycl;orc-rt")
set(LLVM_ENABLE_RUNTIMES "" CACHE STRING
"Semicolon-separated list of runtimes to build, or \"all\" (${LLVM_DEFAULT_RUNTIMES}). Supported runtimes are ${LLVM_SUPPORTED_RUNTIMES}.")
if(LLVM_ENABLE_RUNTIMES STREQUAL "all")
@@ -159,6 +149,72 @@ foreach(proj IN LISTS LLVM_ENABLE_RUNTIMES)
endif()
endforeach()
if ("flang" IN_LIST LLVM_ENABLE_PROJECTS)
if (NOT "mlir" IN_LIST LLVM_ENABLE_PROJECTS)
message(STATUS "Enabling MLIR as a dependency to flang")
list(APPEND LLVM_ENABLE_PROJECTS "mlir")
endif()
if (NOT "clang" IN_LIST LLVM_ENABLE_PROJECTS)
message(STATUS "Enabling clang as a dependency to flang")
list(APPEND LLVM_ENABLE_PROJECTS "clang")
endif()
option(FLANG_ENABLE_FLANG_RT "Implicitly add LLVM_ENABLE_RUNTIMES=flang-rt when compiling Flang" ON)
if (FLANG_ENABLE_FLANG_RT AND NOT "flang-rt" IN_LIST LLVM_ENABLE_RUNTIMES)
message(STATUS "Enabling Flang-RT as a dependency of Flang")
list(APPEND LLVM_ENABLE_RUNTIMES "flang-rt")
endif ()
endif()
if ("lldb" IN_LIST LLVM_ENABLE_PROJECTS)
if (NOT "clang" IN_LIST LLVM_ENABLE_PROJECTS)
message(STATUS "Enabling clang as a dependency of lldb")
list(APPEND LLVM_ENABLE_PROJECTS "clang")
endif()
endif ()
if ("libc" IN_LIST LLVM_ENABLE_PROJECTS)
message(WARNING "Using LLVM_ENABLE_PROJECTS=libc is deprecated now, and will "
"become a fatal error in a future release. Please use "
"-DLLVM_ENABLE_RUNTIMES=libc or see the instructions at "
"https://libc.llvm.org/ for building the runtimes.")
endif()
if ("compiler-rt" IN_LIST LLVM_ENABLE_PROJECTS)
message(WARNING "Using LLVM_ENABLE_PROJECTS=compiler-rt is deprecated now, and will "
"become a fatal error in a future release. Please use "
"-DLLVM_ENABLE_RUNTIMES=compiler-rt or see the instructions at "
"https://compiler-rt.llvm.org/ for building the runtimes.")
endif()
if ("offload" IN_LIST LLVM_ENABLE_PROJECTS)
message(WARNING "Using LLVM_ENABLE_PROJECTS=offload is deprecated now, and will "
"become a fatal error in a future release. Please use "
"-DLLVM_ENABLE_RUNTIMES=offload or see the instructions at "
"https://openmp.llvm.org/ for building the runtimes.")
endif()
if ("openmp" IN_LIST LLVM_ENABLE_PROJECTS)
message(WARNING "Using LLVM_ENABLE_PROJECTS=openmp is deprecated now, and will "
"become a fatal error in a future release. Please use "
"-DLLVM_ENABLE_RUNTIMES=openmp or see the instructions at "
"https://openmp.llvm.org/ for building the runtimes.")
endif()
if ("flang-rt" IN_LIST LLVM_ENABLE_RUNTIMES)
if (NOT "flang" IN_LIST LLVM_ENABLE_PROJECTS)
message(FATAL_ERROR "Flang is not enabled, but is required for the Flang-RT runtime")
endif ()
endif ()
if ("libclc" IN_LIST LLVM_ENABLE_PROJECTS)
message(WARNING "Using LLVM_ENABLE_PROJECTS=libclc is deprecated now, and will "
"become a fatal error in a future release. Please use "
"-DLLVM_ENABLE_RUNTIMES=libclc or see the instructions at "
"https://libclc.llvm.org/ for building the runtimes.")
endif()
# Set a shorthand option to enable the GPU build of the 'libc' project.
option(LIBC_GPU_BUILD "Enable the 'libc' project targeting the GPU" OFF)
if(LIBC_GPU_BUILD)
@@ -171,13 +227,8 @@ if(LIBC_GPU_BUILD)
list(APPEND RUNTIMES_amdgcn-amd-amdhsa_LLVM_ENABLE_RUNTIMES "libc")
endif()
set(NEED_LIBC_HDRGEN FALSE)
if("libc" IN_LIST LLVM_ENABLE_RUNTIMES)
set(NEED_LIBC_HDRGEN TRUE)
endif()
foreach(_name ${LLVM_RUNTIME_TARGETS})
if("libc" IN_LIST RUNTIMES_${_name}_LLVM_ENABLE_RUNTIMES)
set(NEED_LIBC_HDRGEN TRUE)
if("${_name}" STREQUAL "amdgcn-amd-amdhsa" OR "${_name}" STREQUAL "nvptx64-nvidia-cuda")
set(LLVM_LIBC_GPU_BUILD ON)
endif()
@@ -187,16 +238,6 @@ if("${LIBC_TARGET_TRIPLE}" STREQUAL "amdgcn-amd-amdhsa" OR
"${LIBC_TARGET_TRIPLE}" STREQUAL "nvptx64-nvidia-cuda")
set(LLVM_LIBC_GPU_BUILD ON)
endif()
if(NEED_LIBC_HDRGEN)
# To build the libc runtime, we need to be able to build few libc build
# tools from the "libc" project. So, we add it to the list of enabled
# projects.
if (NOT "libc" IN_LIST LLVM_ENABLE_PROJECTS)
message(STATUS "Enabling libc project to build libc build tools")
list(APPEND LLVM_ENABLE_PROJECTS "libc")
endif()
endif()
unset(NEED_LIBC_HDRGEN)
# LLVM_ENABLE_PROJECTS_USED is `ON` if the user has ever used the
# `LLVM_ENABLE_PROJECTS` CMake cache variable. This exists for
@@ -260,10 +301,10 @@ if(LLVM_CCACHE_BUILD)
if(CCACHE_PROGRAM)
set(LLVM_CCACHE_MAXSIZE "" CACHE STRING "Size of ccache")
set(LLVM_CCACHE_DIR "" CACHE STRING "Directory to keep ccached data")
set(LLVM_CCACHE_PARAMS "CCACHE_CPP2=yes CCACHE_HASHDIR=yes"
set(LLVM_CCACHE_PARAMS "CCACHE_CPP2=yes CCACHE_HASHDIR=yes CCACHE_SLOPPINESS=pch_defines,time_macros"
CACHE STRING "Parameters to pass through to ccache")
if(NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
if(NOT CMAKE_HOST_WIN32)
set(CCACHE_PROGRAM "${LLVM_CCACHE_PARAMS} ${CCACHE_PROGRAM}")
if (LLVM_CCACHE_MAXSIZE)
set(CCACHE_PROGRAM "CCACHE_MAXSIZE=${LLVM_CCACHE_MAXSIZE} ${CCACHE_PROGRAM}")
@@ -273,8 +314,15 @@ if(LLVM_CCACHE_BUILD)
endif()
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE_PROGRAM})
else()
# Until a way to reliably configure ccache on Windows is found,
# disable precompiled headers for Windows + ccache builds
if(NOT CMAKE_DISABLE_PRECOMPILE_HEADERS)
message(WARNING "Using ccache with precompiled headers on Windows is currently not supported.
CMAKE_DISABLE_PRECOMPILE_HEADERS will be set to ON.")
set(CMAKE_DISABLE_PRECOMPILE_HEADERS "ON")
endif()
if(LLVM_CCACHE_MAXSIZE OR LLVM_CCACHE_DIR OR
NOT LLVM_CCACHE_PARAMS MATCHES "CCACHE_CPP2=yes CCACHE_HASHDIR=yes")
NOT LLVM_CCACHE_PARAMS MATCHES "CCACHE_CPP2=yes CCACHE_HASHDIR=yes CCACHE_SLOPPINESS=pch_defines,time_macros")
message(FATAL_ERROR "Ccache configuration through CMake is not supported on Windows. Please use environment variables.")
endif()
# RULE_LAUNCH_COMPILE should work with Ninja but currently has issues
@@ -482,6 +530,7 @@ set(LLVM_ALL_TARGETS
PowerPC
RISCV
Sparc
SPIRV
SystemZ
VE
WebAssembly
@@ -494,7 +543,6 @@ set(LLVM_ALL_EXPERIMENTAL_TARGETS
CSKY
DirectX
M68k
SPIRV
Xtensa
)
@@ -524,6 +572,10 @@ endif()
option(LLVM_ENABLE_CRASH_DUMPS "Turn on memory dumps on crashes. Currently only implemented on Windows." OFF)
set(LLVM_ENABLE_DEBUGLOC_COVERAGE_TRACKING "DISABLED" CACHE STRING
"Enhance Debugify's line number coverage tracking; enabling this is ABI-breaking. Can be DISABLED, COVERAGE, or COVERAGE_AND_ORIGIN.")
set_property(CACHE LLVM_ENABLE_DEBUGLOC_COVERAGE_TRACKING PROPERTY STRINGS DISABLED COVERAGE COVERAGE_AND_ORIGIN)
set(WINDOWS_PREFER_FORWARD_SLASH_DEFAULT OFF)
if (MINGW)
# Cygwin doesn't identify itself as Windows, and thus gets path::Style::posix
@@ -552,6 +604,10 @@ else()
option(LLVM_ENABLE_THREADS "Use threads if available." ON)
endif()
set(LLVM_ENABLE_ICU "OFF" CACHE STRING "Use ICU for text encoding conversion support if available. Can be ON, OFF, or FORCE_ON")
set(LLVM_ENABLE_ICONV "OFF" CACHE STRING "Use iconv for text encoding conversion support if available. Can be ON, OFF, or FORCE_ON")
set(LLVM_ENABLE_ZLIB "ON" CACHE STRING "Use zlib for compression/decompression if available. Can be ON, OFF, or FORCE_ON")
set(LLVM_ENABLE_ZSTD "ON" CACHE STRING "Use zstd for compression/decompression if available. Can be ON, OFF, or FORCE_ON")
@@ -598,6 +654,13 @@ if(LLVM_EXPERIMENTAL_TARGETS_TO_BUILD STREQUAL "all")
set(LLVM_EXPERIMENTAL_TARGETS_TO_BUILD ${LLVM_ALL_EXPERIMENTAL_TARGETS})
endif()
if("flang" IN_LIST LLVM_ENABLE_PROJECTS AND
"AArch64" IN_LIST LLVM_TARGETS_TO_BUILD AND
NOT ("compiler-rt" IN_LIST LLVM_ENABLE_RUNTIMES OR "compiler-rt" IN_LIST LLVM_ENABLE_PROJECTS))
message(STATUS "Enabling compiler-rt as a dependency of Flang")
list(APPEND LLVM_ENABLE_RUNTIMES "compiler-rt")
endif()
set(LLVM_TARGETS_TO_BUILD
${LLVM_TARGETS_TO_BUILD}
${LLVM_EXPERIMENTAL_TARGETS_TO_BUILD})
@@ -607,7 +670,7 @@ if (NOT CMAKE_SYSTEM_NAME MATCHES "OS390")
option(LLVM_ENABLE_PIC "Build Position-Independent Code" ON)
endif()
option(LLVM_ENABLE_MODULES "Compile with C++ modules enabled." OFF)
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
if("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin")
option(LLVM_ENABLE_MODULE_DEBUGGING "Compile with -gmodules." ON)
else()
option(LLVM_ENABLE_MODULE_DEBUGGING "Compile with -gmodules." OFF)
@@ -629,20 +692,9 @@ else()
option(LLVM_ENABLE_ASSERTIONS "Enable assertions" ON)
endif()
option(LLVM_ENABLE_IO_SANDBOX "Enable IO sandboxing in supported tools" OFF)
option(LLVM_ENABLE_EXPENSIVE_CHECKS "Enable expensive checks" OFF)
# While adding scalable vector support to LLVM, we temporarily want to
# allow an implicit conversion of TypeSize to uint64_t, and to allow
# code to get the fixed number of elements from a possibly scalable vector.
# This CMake flag enables a more strict mode where it asserts that the type
# is not a scalable vector type.
#
# Enabling this flag makes it easier to find cases where the compiler makes
# assumptions on the size being 'fixed size', when building tests for
# SVE/SVE2 or other scalable vector architectures.
option(LLVM_ENABLE_STRICT_FIXED_SIZE_VECTORS
"Enable assertions that type is not scalable in implicit conversion from TypeSize to uint64_t and calls to getNumElements" OFF)
set(LLVM_ABI_BREAKING_CHECKS "WITH_ASSERTS" CACHE STRING
"Enable abi-breaking checks. Can be WITH_ASSERTS, FORCE_ON or FORCE_OFF.")
@@ -711,7 +763,7 @@ option(LLVM_USE_SPLIT_DWARF
# 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 OR ${CMAKE_SYSTEM_NAME} MATCHES "AIX"))
if( CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT (WIN32 OR "${CMAKE_SYSTEM_NAME}" MATCHES "AIX"))
# TODO: support other platforms and toolchains.
option(LLVM_BUILD_32_BITS "Build 32 bits executables and libraries." OFF)
endif()
@@ -796,10 +848,6 @@ option(LLVM_BUILD_EXAMPLES
"Build the LLVM example programs. If OFF, just generate build targets." OFF)
option(LLVM_INCLUDE_EXAMPLES "Generate build targets for the LLVM examples" ON)
if(LLVM_BUILD_EXAMPLES)
add_compile_definitions(BUILD_EXAMPLES)
endif(LLVM_BUILD_EXAMPLES)
option(LLVM_BUILD_TESTS
"Build LLVM unit tests. If OFF, just generate build targets." OFF)
option(LLVM_INCLUDE_TESTS "Generate build targets for the LLVM unit tests." ON)
@@ -818,6 +866,7 @@ option (LLVM_ENABLE_DOXYGEN "Use doxygen to generate llvm API documentation." OF
option (LLVM_ENABLE_SPHINX "Use Sphinx to generate llvm documentation." OFF)
option (LLVM_ENABLE_OCAMLDOC "Build OCaml bindings documentation." ON)
option (LLVM_ENABLE_BINDINGS "Build bindings." ON)
option (LLVM_ENABLE_TELEMETRY "Enable the telemetry library. If set to OFF, library cannot be enabled after build (eg., at runtime)" ON)
set(LLVM_INSTALL_DOXYGEN_HTML_DIR "${CMAKE_INSTALL_DOCDIR}/llvm/doxygen-html"
CACHE STRING "Doxygen-generated HTML documentation install directory")
@@ -843,20 +892,40 @@ endif()
if(MSVC)
option(LLVM_BUILD_LLVM_C_DYLIB "Build LLVM-C.dll (Windows only)" ON)
# Set this variable to OFF here so it can't be set with a command-line
# argument.
set (LLVM_LINK_LLVM_DYLIB OFF)
if (BUILD_SHARED_LIBS)
message(FATAL_ERROR "BUILD_SHARED_LIBS options is not supported on Windows.")
endif()
else()
option(LLVM_LINK_LLVM_DYLIB "Link tools against the libllvm dynamic library" OFF)
option(LLVM_BUILD_LLVM_C_DYLIB "Build libllvm-c re-export library (Darwin only)" OFF)
set(LLVM_BUILD_LLVM_DYLIB_default OFF)
if(LLVM_LINK_LLVM_DYLIB OR LLVM_BUILD_LLVM_C_DYLIB)
set(LLVM_BUILD_LLVM_DYLIB_default ON)
endif()
option(LLVM_BUILD_LLVM_DYLIB "Build libllvm dynamic library" ${LLVM_BUILD_LLVM_DYLIB_default})
endif()
# Used to test building the llvm shared library with explicit symbol visibility on
# Windows and Linux. For ELF platforms default symbols visibility is set to hidden.
set(LLVM_BUILD_LLVM_DYLIB_VIS FALSE CACHE BOOL "")
mark_as_advanced(LLVM_BUILD_LLVM_DYLIB_VIS)
set(CAN_BUILD_LLVM_DYLIB OFF)
if(NOT MSVC OR LLVM_BUILD_LLVM_DYLIB_VIS)
set(CAN_BUILD_LLVM_DYLIB ON)
endif()
cmake_dependent_option(LLVM_LINK_LLVM_DYLIB "Link tools against the libllvm dynamic library" OFF
"CAN_BUILD_LLVM_DYLIB" OFF)
set(LLVM_BUILD_LLVM_DYLIB_default OFF)
if(LLVM_LINK_LLVM_DYLIB OR LLVM_BUILD_LLVM_C_DYLIB)
set(LLVM_BUILD_LLVM_DYLIB_default ON)
endif()
cmake_dependent_option(LLVM_BUILD_LLVM_DYLIB "Build libllvm dynamic library" ${LLVM_BUILD_LLVM_DYLIB_default}
"CAN_BUILD_LLVM_DYLIB" OFF)
cmake_dependent_option(LLVM_DYLIB_EXPORT_INLINES "Force inline members of classes to be DLL exported when
building with clang-cl so the libllvm DLL is compatible with MSVC"
OFF
"MSVC;LLVM_BUILD_LLVM_DYLIB_VIS" OFF)
if(LLVM_BUILD_LLVM_DYLIB_VIS)
set(LLVM_BUILD_LLVM_DYLIB ON)
endif()
if (LLVM_LINK_LLVM_DYLIB AND BUILD_SHARED_LIBS)
@@ -864,7 +933,8 @@ if (LLVM_LINK_LLVM_DYLIB AND BUILD_SHARED_LIBS)
endif()
option(LLVM_OPTIMIZED_TABLEGEN "Force TableGen to be built with optimization" OFF)
if(CMAKE_CROSSCOMPILING OR (LLVM_OPTIMIZED_TABLEGEN AND (LLVM_ENABLE_ASSERTIONS OR CMAKE_CONFIGURATION_TYPES)))
if(CMAKE_CROSSCOMPILING OR (LLVM_OPTIMIZED_TABLEGEN AND (LLVM_ENABLE_ASSERTIONS
OR CMAKE_CONFIGURATION_TYPES OR LLVM_USE_SANITIZER)))
set(LLVM_USE_HOST_TOOLS ON)
endif()
@@ -919,7 +989,7 @@ endif()
set(LLVM_TARGET_TRIPLE_ENV CACHE STRING "The name of environment variable to override default target. Disabled by blank.")
mark_as_advanced(LLVM_TARGET_TRIPLE_ENV)
if(CMAKE_SYSTEM_NAME MATCHES "BSD|Linux|OS390")
if(CMAKE_SYSTEM_NAME MATCHES "BSD|Linux|OS390|AIX")
set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR_default ON)
else()
set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR_default OFF)
@@ -930,6 +1000,9 @@ set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR ${LLVM_ENABLE_PER_TARGET_RUNTIME_DIR_defa
set(LLVM_PROFDATA_FILE "" CACHE FILEPATH
"Profiling data file to use when compiling in order to improve runtime performance.")
set(LLVM_SPROFDATA_FILE "" CACHE FILEPATH
"Sampling profiling data file to use when compiling in order to improve runtime performance.")
if(LLVM_INCLUDE_TESTS)
# All LLVM Python files should be compatible down to this minimum version.
set(LLVM_MINIMUM_PYTHON_VERSION 3.8)
@@ -977,6 +1050,17 @@ else()
endif()
option(LLVM_ENABLE_PLUGINS "Enable plugin support" ${LLVM_ENABLE_PLUGINS_default})
set(LLVM_ENABLE_LLVM_EXPORT_ANNOTATIONS OFF)
if (LLVM_BUILD_LLVM_DYLIB OR LLVM_BUILD_SHARED_LIBS OR LLVM_ENABLE_PLUGINS)
# Export annotations for LLVM must be enabled if building as a shared lib or
# enabling plugins.
set(LLVM_ENABLE_LLVM_EXPORT_ANNOTATIONS ON)
endif()
# Because LLVM-C is built into the LLVM library, for now export its symbols
# whenever LLVM symbols are exported.
set(LLVM_ENABLE_LLVM_C_EXPORT_ANNOTATIONS ${LLVM_ENABLE_LLVM_EXPORT_ANNOTATIONS})
set(LLVM_ENABLE_NEW_PASS_MANAGER TRUE CACHE BOOL
"Enable the new pass manager by default.")
if(NOT LLVM_ENABLE_NEW_PASS_MANAGER)
@@ -1085,6 +1169,8 @@ if (LLVM_HAVE_TFLITE)
find_package(tensorflow-lite REQUIRED)
endif()
set(LLVM_ENABLE_PROFCHECK OFF CACHE BOOL "Enable profile checking in test tools")
# For up-to-date instructions for installing the Tensorflow dependency, refer to
# the bot setup script: https://github.com/google/ml-compiler-opt/blob/main/buildbot/buildbot_init.sh
# Specifically, assuming python3 is installed:
@@ -1103,6 +1189,8 @@ if (NOT TENSORFLOW_AOT_PATH STREQUAL "")
${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/tf_runtime)
install(TARGETS tf_xla_runtime EXPORT LLVMExports
ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX} COMPONENT tf_xla_runtime)
install(TARGETS tf_xla_runtime EXPORT LLVMDevelopmentExports
ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX} COMPONENT tf_xla_runtime)
set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS tf_xla_runtime)
# Once we add more modules, we should handle this more automatically.
if (DEFINED LLVM_OVERRIDE_MODEL_HEADER_INLINERSIZEMODEL)
@@ -1124,13 +1212,16 @@ if (NOT TENSORFLOW_AOT_PATH STREQUAL "")
endif()
# Configure the three LLVM configuration header files.
# Configure the LLVM configuration header files.
configure_file(
${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/config.h.cmake
${LLVM_INCLUDE_DIR}/llvm/Config/config.h)
configure_file(
${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/llvm-config.h.cmake
${LLVM_INCLUDE_DIR}/llvm/Config/llvm-config.h)
configure_file(
${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/Targets.h.cmake
${LLVM_INCLUDE_DIR}/llvm/Config/Targets.h)
configure_file(
${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/abi-breaking.h.cmake
${LLVM_INCLUDE_DIR}/llvm/Config/abi-breaking.h)
@@ -1146,9 +1237,10 @@ endif()
# Build with _XOPEN_SOURCE on AIX, as stray macros in _ALL_SOURCE mode tend to
# break things. In this case we need to enable the large-file API as well.
if (UNIX AND ${CMAKE_SYSTEM_NAME} MATCHES "AIX")
if (UNIX AND "${CMAKE_SYSTEM_NAME}" MATCHES "AIX")
add_compile_definitions(_XOPEN_SOURCE=700)
add_compile_definitions(_LARGE_FILE_API)
add_compile_options(-pthread)
# Modules should be built with -shared -Wl,-G, so we can use runtime linking
# with plugins.
@@ -1161,10 +1253,10 @@ endif()
# Build with _XOPEN_SOURCE on z/OS.
if (CMAKE_SYSTEM_NAME MATCHES "OS390")
add_compile_definitions(_XOPEN_SOURCE=600)
add_compile_definitions(_XPLATFORM_SOURCE) # Needed e.g. for O_CLOEXEC.
add_compile_definitions(_OPEN_SYS) # Needed for process information.
add_compile_definitions(_OPEN_SYS_FILE_EXT) # Needed for EBCDIC I/O.
add_compile_definitions(_EXT) # Needed for file data.
add_compile_definitions(_UNIX03_THREADS) # Multithreading support.
# Need to build LLVM as ASCII application.
# This can't be a global setting because other projects may
# need to be built in EBCDIC mode.
@@ -1173,7 +1265,7 @@ if (CMAKE_SYSTEM_NAME MATCHES "OS390")
endif()
# Build with _FILE_OFFSET_BITS=64 on Solaris to match g++ >= 9.
if (UNIX AND ${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
if (UNIX AND "${CMAKE_SYSTEM_NAME}" MATCHES "SunOS")
add_compile_definitions(_FILE_OFFSET_BITS=64)
endif()
@@ -1191,13 +1283,18 @@ if(LLVM_TARGET_IS_CROSSCOMPILE_HOST)
# (this is a variable that CrossCompile sets on recursive invocations)
endif()
if( ${CMAKE_SYSTEM_NAME} MATCHES SunOS )
# Special hack for z/OS for missing POSIX functions
if (CMAKE_SYSTEM_NAME MATCHES "OS390")
include_directories(SYSTEM "${LLVM_MAIN_INCLUDE_DIR}/llvm/Support/SystemZ/zos_wrappers" )
endif()
if( "${CMAKE_SYSTEM_NAME}" MATCHES SunOS )
# special hack for Solaris to handle crazy system sys/regset.h
include_directories("${LLVM_MAIN_INCLUDE_DIR}/llvm/Support/Solaris")
endif( ${CMAKE_SYSTEM_NAME} MATCHES SunOS )
endif( "${CMAKE_SYSTEM_NAME}" MATCHES SunOS )
# Make sure we don't get -rdynamic in every binary. For those that need it,
# use export_executable_symbols(target).
# use EXPORT_SYMBOLS argument.
set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")
include(AddLLVM)
@@ -1235,10 +1332,9 @@ if( LLVM_INCLUDE_UTILS )
add_subdirectory(utils/yaml-bench)
add_subdirectory(utils/split-file)
add_subdirectory(utils/mlgo-utils)
add_subdirectory(utils/llvm-test-mustache-spec)
if( LLVM_INCLUDE_TESTS )
set(LLVM_SUBPROJECT_TITLE "Third-Party/Google Test")
add_subdirectory(${LLVM_THIRD_PARTY_DIR}/unittest ${CMAKE_CURRENT_BINARY_DIR}/third-party/unittest)
set(LLVM_SUBPROJECT_TITLE)
endif()
else()
if ( LLVM_INCLUDE_TESTS )
@@ -1264,6 +1360,17 @@ if( LLVM_INCLUDE_TOOLS )
add_subdirectory(tools)
endif()
# We need to setup KillTheDoctor before setting up the runtimes build because
# the runtimes build needs to add a KillTheDoctor dep for compiler-rt on
# Windows.
if (LLVM_INCLUDE_TESTS)
if (WIN32)
# This utility is used to prevent crashing tests from calling Dr. Watson on
# Windows.
add_subdirectory(utils/KillTheDoctor)
endif()
endif()
if( LLVM_INCLUDE_RUNTIMES )
add_subdirectory(runtimes)
endif()
@@ -1288,12 +1395,6 @@ if( LLVM_INCLUDE_TESTS )
add_subdirectory(test)
add_subdirectory(unittests)
if (WIN32)
# This utility is used to prevent crashing tests from calling Dr. Watson on
# Windows.
add_subdirectory(utils/KillTheDoctor)
endif()
umbrella_lit_testsuite_end(check-all)
get_property(LLVM_ALL_LIT_DEPENDS GLOBAL PROPERTY LLVM_ALL_LIT_DEPENDS)
get_property(LLVM_ALL_ADDITIONAL_TEST_DEPENDS
@@ -1358,7 +1459,8 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
# Installing the headers needs to depend on generating any public
# tablegen'd headers.
add_custom_target(llvm-headers DEPENDS intrinsics_gen omp_gen)
add_custom_target(llvm-headers)
add_dependencies(llvm-headers intrinsics_gen omp_gen target_parser_gen)
set_target_properties(llvm-headers PROPERTIES FOLDER "LLVM/Resources")
if (NOT LLVM_ENABLE_IDE)
@@ -1423,3 +1525,16 @@ endif()
if (LLVM_INCLUDE_UTILS AND LLVM_INCLUDE_TOOLS)
add_subdirectory(utils/llvm-locstats)
endif()
if (XCODE)
# For additional targets that you would like to add schemes, specify e.g:
#
# -DLLVM_XCODE_EXTRA_TARGET_SCHEMES="TargetParserTests;SupportTests"
#
# at CMake configure time.
set(LLVM_XCODE_EXTRA_TARGET_SCHEMES "" CACHE STRING "Specifies an extra list of targets to turn into schemes")
foreach(target ${LLVM_XCODE_EXTRA_TARGET_SCHEMES})
set_target_properties(${target} PROPERTIES XCODE_GENERATE_SCHEME ON)
endforeach()
endif()
+90
View File
@@ -0,0 +1,90 @@
{
"version": 6,
"cmakeMinimumRequired": {
"major": 3,
"minor": 20,
"patch": 0
},
"configurePresets": [
{
"name": "llvm-build-shared-libs",
"hidden": true,
"description": "Build shared libraries",
"cacheVariables": {
"BUILD_SHARED_LIBS": true
}
},
{
"name": "llvm-build-tests",
"hidden": true,
"description": "Build tests",
"cacheVariables": {
"LLVM_BUILD_TESTS": true
}
},
{
"name": "llvm-enable-assertions",
"hidden": true,
"description": "Enable runtime assertions",
"cacheVariables": {
"LLVM_ENABLE_ASSERTIONS": true
}
},
{
"name": "llvm-enable-projects-clang",
"hidden": true,
"description": "Enable projects clang",
"cacheVariables": {
"LLVM_ENABLE_PROJECTS": "clang"
}
},
{
"name": "llvm-enable-projects-clang-tools-extra",
"hidden": true,
"description": "Enable projects clang, clang-tools-extra",
"cacheVariables": {
"LLVM_ENABLE_PROJECTS": "clang;clang-tools-extra"
}
},
{
"name": "llvm-enable-lto",
"hidden": true,
"description": "Enable link time optimizations (LTO)",
"cacheVariables": {
"LLVM_ENABLE_LTO": true
}
},
{
"name": "llvm-export-compile-commands",
"hidden": true,
"description": "Generate a compile_commands.json database",
"cacheVariables": {
"CMAKE_EXPORT_COMPILE_COMMANDS": true
}
},
{
"name": "llvm-no-build-testing",
"hidden": true,
"description": "Turn off building of tests",
"cacheVariables": {
"BUILD_TESTING": false
}
},
{
"name": "llvm-target-x86",
"hidden": true,
"description": "Only target x86 back end",
"cacheVariables": {
"LLVM_TARGETS_TO_BUILD": "X86"
}
},
{
"name": "llvm-use-sanitizer-asan",
"hidden": true,
"description": "Build with ASAN",
"cacheVariables": {
"LLVM_USE_SANITIZER": "Address"
}
}
]
}
+1 -17
View File
@@ -5,8 +5,7 @@ done!
The list is sorted by surname and formatted to allow easy grepping and
beautification by scripts. The fields are: name (N), email (E), web-address
(W), PGP key ID and fingerprint (P), description (D), snail-mail address
(S), and (I) IRC handle.
(W), PGP key ID and fingerprint (P), and description (D).
N: Vikram Adve
E: vadve@cs.uiuc.edu
@@ -24,12 +23,10 @@ D: MingW Win32 API portability layer
N: Aaron Ballman
E: aaron@aaronballman.com
D: Clang frontend, frontend attributes, Windows support, general bug fixing
I: AaronBallman
N: Alexey Bataev
E: a.bataev@outlook.com
D: Clang frontend, OpenMP in clang, SLP vectorizer, Loop vectorizer, InstCombine
I: ABataev
N: Nate Begeman
E: natebegeman@mac.com
@@ -180,7 +177,6 @@ D: Loop Vectorizer improvements
D: Regression and Test Suite improvements
D: Linux compatibility (GNU, musl, etc)
D: Initial Linux kernel / Android support effort
I: rengolin
N: David Goodwin
E: david@goodwinz.net
@@ -197,7 +193,6 @@ 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
@@ -250,7 +245,6 @@ D: Author of LLVM Ada bindings
N: Erich Keane
E: erich.keane@intel.com
D: A variety of Clang contributions including function multiversioning, regcall/vectorcall.
I: ErichKeane
N: Eric Kidd
W: http://randomhacks.net/
@@ -326,7 +320,6 @@ D: Backend for Qualcomm's Hexagon VLIW processor.
N: Bruno Cardoso Lopes
E: bruno.cardoso@gmail.com
I: bruno
W: http://brunocardoso.cc
D: Mips backend
D: Random ARM integrated assembler and assembly parser improvements
@@ -367,7 +360,6 @@ D: Support for implicit TLS model used with MS VC runtime
D: Dumping of Win64 EH structures
N: Takumi Nakamura
I: chapuni
E: geek4civic@gmail.com
E: chapuni@hf.rim.or.jp
D: Maintaining the Git monorepo
@@ -432,10 +424,6 @@ W: http://vladimir_prus.blogspot.com
E: ghost@cs.msu.su
D: Made inst_iterator behave like a proper iterator, LowerConstantExprs pass
N: QIU Chaofan
E: qiucofan@cn.ibm.com
D: PowerPC Backend Developer
N: Kalle Raiskila
E: kalle.rasikila@nokia.com
D: Some bugfixes to CellSPU
@@ -446,12 +434,10 @@ D: Cmake dependency chain and various bug fixes
N: Alex Rosenberg
E: alexr@leftfield.org
I: arosenberg
D: ARM calling conventions rewrite, hard float support
N: Chad Rosier
E: mcrosier@codeaurora.org
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
@@ -466,7 +452,6 @@ D: MSIL backend
N: Duncan Sands
E: baldrick@free.fr
I: baldrick
D: Ada support in llvm-gcc
D: Dragonegg plugin
D: Exception handling improvements
@@ -537,7 +522,6 @@ E: phoebe.wang@intel.com
D: X86 bug fixes and new instruction support.
N: Bill Wendling
I: wendling
E: isanbard@gmail.com
D: Release manager, IR Linker, LTO.
D: Bunches of stuff.
+565
View File
@@ -0,0 +1,565 @@
# LLVM Maintainers
This file is a list of the
[maintainers](https://llvm.org/docs/DeveloperPolicy.html#maintainers) for
LLVM.
## Current Maintainers
The following people are the active maintainers for the project. Please reach
out to them for code reviews, questions about their area of expertise, or other
assistance.
### Lead maintainer
The lead maintainer is responsible for all parts of LLVM not covered by somebody else.
Nikita Popov \
llvm@npopov.com, npopov@redhat.com (email), [nikic](https://github.com/nikic) (GitHub), nikic (Discourse)
### Transforms and analyses
#### AliasAnalysis
Nikita Popov \
llvm@npopov.com, npopov@redhat.com (email), [nikic](https://github.com/nikic) (GitHub), nikic (Discourse) \
Florian Hahn \
flo@fhahn.com (email), [fhahn](https://github.com/fhahn) (GitHub)
#### Attributor, OpenMPOpt
Johannes Doerfert \
jdoerfert@llnl.gov (email), [jdoerfert](https://github.com/jdoerfert) (GitHub)
#### ConstraintElimination
Florian Hahn \
flo@fhahn.com (email), [fhahn](https://github.com/fhahn) (GitHub)
#### HashRecognize
Ramkumar Ramachandra \
r@artagnon.com (email), [artagnon](https://github.com/artagnon) (GitHub), artagnon (Discourse) \
Piotr Fusik \
p.fusik@samsung.com (email), [pfusik](https://github.com/pfusik) (GitHub)
#### InferAddressSpaces
Matt Arsenault \
Matthew.Arsenault@amd.com, arsenm2@gmail.com (email), [arsenm](https://github.com/arsenm) (GitHub)
#### Inlining
Arthur Eubanks \
aeubanks@google.com (email), [aeubanks](https://github.com/aeubanks) (GitHub) \
Mircea Trofin (esp. ML inliner) \
mtrofin@google.com (email), [mtrofin](https://github.com/mtrofin) (GitHub) \
Kazu Hirata (esp. module inliner and inline order) \
kazu@google.com (email), [kazutakahirata](https://github.com/kazutakahirata) (GitHub)
#### InstCombine, InstSimplify, ValueTracking, ConstantFold
Nikita Popov \
llvm@npopov.com, npopov@redhat.com (email), [nikic](https://github.com/nikic) (GitHub), nikic (Discourse) \
Yingwei Zheng \
dtcxzyw2333@gmail.com (email), [dtcxzyw](https://github.com/dtcxzyw) (GitHub)
#### InstrProfiling and related parts of ProfileData
Justin Bogner \
mail@justinbogner.com (email), [bogner](https://github.com/bogner) (GitHub)
#### SampleProfile and related parts of ProfileData
Diego Novillo \
dnovillo@google.com (email), [dnovillo](https://github.com/dnovillo) (GitHub)
#### New pass manager, CGSCC, LazyCallGraph
Arthur Eubanks \
aeubanks@google.com (email), [aeubanks](https://github.com/aeubanks) (GitHub)
#### LoopStrengthReduce
Quentin Colombet \
quentin.colombet@gmail.com (email), [qcolombet](https://github.com/qcolombet) (GitHub)
#### LoopVectorize
Florian Hahn \
flo@fhahn.com (email), [fhahn](https://github.com/fhahn) (GitHub) \
David Sherwood \
david.sherwood@arm.com (email), [david-arm](https://github.com/david-arm) (GitHub)
#### MemorySSA
Alina Sbirlea \
asbirlea@google.com (email), [alinas](https://github.com/alinas) (GitHub)
#### LoopInterchange
Madhur Amilkanthwar \
madhura@nvidia.com (email), [madhur13490](https://github.com/madhur13490) (GitHub)
#### SandboxVectorizer
Vasileios Porpodas \
vporpodas@google.com (email), [vporpo](https://github.com/vporpo) (GitHub) \
Jorge Gorbe Moya \
jgorbe@google.com (email), [slackito](https://github.com/slackito) (GitHub)
#### ScalarEvolution, IndVarSimplify
Philip Reames \
listmail@philipreames.com (email), [preames](https://github.com/preames) (GitHub)
#### SLPVectorizer
Alexey Bataev \
a.bataev@outlook.com (email), [alexey-bataev](https://github.com/alexey-bataev) (GitHub)
#### SROA, Mem2Reg
Chandler Carruth \
chandlerc@gmail.com, chandlerc@google.com (email), [chandlerc](https://github.com/chandlerc) (GitHub)
#### DFAJumpThreading
Hongyu Chen \
xxs\_chy@outlook.com (email), [XChy](https://github.com/XChy) (Github) \
Usman Nadeem \
mnadeem@quicinc.com (email), [UsmanNadeem](https://github.com/UsmanNadeem) (Github)
### Instrumentation and sanitizers
#### Sanitizers not covered by someone else
Vitaly Buka \
vitalybuka@google.com (email), [vitalybuka](https://github.com/vitalybuka) (GitHub)
#### NumericalStabilitySanitizer
Alexander Shaposhnikov \
ashaposhnikov@google.com (email), [alexander-shaposhnikov](https://github.com/alexander-shaposhnikov) (GitHub)
#### RealtimeSanitizer
Christopher Apple \
cja-private@pm.me (email), [cjappl](https://github.com/cjappl) (GitHub) \
David Trevelyan \
david.trevelyan@gmail.com (email), [davidtrevelyan](https://github.com/davidtrevelyan) (GitHub)
### Generic backend and code generation
#### Parts of code generator not covered by someone else
Matt Arsenault \
Matthew.Arsenault@amd.com, arsenm2@gmail.com (email), [arsenm](https://github.com/arsenm) (GitHub)
#### SelectionDAG
Simon Pilgrim \
llvm-dev@redking.me.uk (email), [RKSimon](https://github.com/RKSimon) (GitHub) \
Craig Topper \
craig.topper@sifive.com (email), [topperc](https://github.com/topperc) (GitHub)
#### Instruction scheduling
Matthias Braun \
matze@braunis.de (email), [MatzeB](https://github.com/MatzeB) (GitHub)
#### VLIW Instruction Scheduling, Packetization
Sergei Larin \
slarin@codeaurora.org (email)
#### Register allocation
Quentin Colombet \
quentin.colombet@gmail.com (email), [qcolombet](https://github.com/qcolombet) (GitHub)
#### MC layer
Fangrui Song \
i@maskray.me (email), [MaskRay](https://github.com/MaskRay) (GitHub)
#### Windows ABI and codegen
Reid Kleckner \
rnk@google.com (email), [rnk](https://github.com/rnk) (GitHub)
### Backends / Targets
#### ARM and AArch64 backends
David Green \
david.green@arm.com (email), [davemgreen](https://github.com/davemgreen) (GitHub) \
Amara Emerson (esp. AArch64 GlobalISel) \
amara@apple.com (email), [aemerson](https://github.com/aemerson) (GitHub) \
Eli Friedman (esp. ARM64EC) \
efriedma@qti.qualcomm.com (email), [efriedma-quic](https://github.com/efriedma-quic) (GitHub) \
Sjoerd Meijer \
smeijer@nvidia.com (email), [sjoerdmeijer](https://github.com/sjoerdmeijer) (GitHub) \
Nashe Mncube \
nashe.mncube@arm.com (email), [nasherm](https://github.com/nasherm) (GitHub) \
Sander de Smalen (esp. scalable vectorization/SVE/SME) \
sander.desmalen@arm.com (email), [sdesmalen-arm](https://github.com/sdesmalen-arm) (GitHub) \
Peter Smith (Anything ABI) \
peter.smith@arm.com (email), [smithp35](https://github.com/smithp35) (GitHub) \
Oliver Stannard (esp. assembly/dissassembly) \
oliver.stannard@arm.com (email), [ostannard](https://github.com/ostannard) (GitHub) \
Ties Stuij (Arm GlobalISel and early arch support) \
ties.stuij@arm.com (email), [stuij](https://github.com/stuij) (GitHub)
#### AMDGPU backend
Matt Arsenault \
Matthew.Arsenault@amd.com, arsenm2@gmail.com (email), [arsenm](https://github.com/arsenm) (GitHub)
#### ARC backend
Mark Schimmel \
marksl@synopsys.com (email), [markschimmel](https://github.com/markschimmel) (GitHub)
#### AVR backend
Ben Shi \
2283975856@qq.com, powerman1st@163.com (email), [benshi001](https://github.com/benshi001) (GitHub)
#### BPF backend
Yonghong Song \
yhs@fb.com (email), [yonghong-song](https://github.com/yonghong-song) (GitHub) \
Eduard Zingerman \
eddyz87@gmail.com (email), [eddyz87](https://github.com/eddyz87) (GitHub)
#### CSKY backend
Zi Xuan Wu (Zeson) \
zixuan.wu@linux.alibaba.com (email), [zixuan-wu](https://github.com/zixuan-wu) (GitHub)
#### DirectX backend
Justin Bogner \
mail@justinbogner.com (email), [bogner](https://github.com/bogner) (GitHub)
#### Hexagon backend
Sundeep Kushwaha \
sundeepk@qti.qualcomm.com (email), [SundeepKushwaha](https://github.com/SundeepKushwaha) (GitHub)
#### Lanai backend
Jacques Pienaar \
jpienaar@google.com (email), [jpienaar](https://github.com/jpienaar) (GitHub)
#### LoongArch backend
Weining Lu \
luweining@loongson.cn (email), [SixWeining](https://github.com/SixWeining) (GitHub)
#### M68k backend
Min-Yih Hsu \
min@myhsu.dev (email), [mshockwave](https://github.com/mshockwave) (GitHub)
#### MSP430 backend
Anton Korobeynikov \
anton@korobeynikov.info (email), [asl](https://github.com/asl) (GitHub)
#### NVPTX backend
Justin Holewinski \
jholewinski@nvidia.com (email), [jholewinski](https://github.com/jholewinski) (GitHub) \
Artem Belevich \
tra@google.com (email), [Artem-B](https://github.com/Artem-B) (GitHub) \
Alex MacLean \
amaclean@nvidia.com (email), [AlexMaclean](https://github.com/AlexMaclean) (GitHub) \
#### PowerPC backend
Amy Kwan (esp. release issues) \
Amy.Kwan1@ibm.com (email), [amy-kwan](https://github.com/amy-kwan) (GitHub) \
Lei Huang \
lei@ca.ibm.com (email), [lei137](https://github.com/lei137) (GitHub) \
Sean Fertile (esp. ABI/ELF/XCOFF) \
sfertile@ca.ibm.com (email), [mandlebug](https://github.com/mandlebug) (GitHub) \
Zhijian Lin \
zhijian@ca.ibm.com (email), [diggerlin](https://github.com/diggerlin) (GitHub) \
Maryam Moghadas \
maryammo@ca.ibm.com (email), [maryammo](https://github.com/maryammo) (GitHub) \
Roland Froese \
froese@ca.ibm.com (email), [RolandF77](https://github.com/RolandF77) (GitHub) \
llvmonpower \
powerllvm@ca.ibm.com (email), [llvmonpower](https://github.com/llvmonpower) (GitHub)
#### RISCV backend
Alex Bradbury \
asb@igalia.com (email), [asb](https://github.com/asb) (GitHub) \
Craig Topper \
craig.topper@sifive.com (email), [topperc](https://github.com/topperc) (GitHub) \
Philip Reames \
listmail@philipreames.com (email), [preames](https://github.com/preames) (GitHub)
#### Sparc backend
Koakuma \
koachan@protonmail.com (email), [koachan](https://github.com/koachan) (GitHub)
#### SPIRV backend
Vyacheslav Levytskyy \
vyacheslav.levytskyy@intel.com, vyacheslav.levytskyy@gmail.com (email), [VyacheslavLevytskyy](https://github.com/VyacheslavLevytskyy) (GitHub)
Nathan Gauër \
brioche@google.com (email), [Keenuts](https://github.com/Keenuts) (GitHub)
#### SystemZ backend
Ulrich Weigand \
uweigand@de.ibm.com (email), [uweigand](https://github.com/uweigand) (GitHub)
#### VE backend
Kazushi Marukawa \
marukawa@nec.com (email), [kaz7](https://github.com/kaz7) (GitHub)
#### WebAssembly backend
Derek Schuff \
dschuff@chromium.org (email), [dschuff](https://github.com/dschuff) (GitHub) \
Heejin Ahn \
aheejin@gmail.com (email), [aheejin](https://github.com/aheejin) (GitHub)
#### X86 backend
Simon Pilgrim \
llvm-dev@redking.me.uk (email), [RKSimon](https://github.com/RKSimon) (GitHub) \
Phoebe Wang \
phoebe.wang@intel.com (email), [phoebewang](https://github.com/phoebewang) (GitHub)
#### XCore backend
Nigel Perks \
nigelp@xmos.com (email), [nigelp-xmos](https://github.com/nigelp-xmos) (GitHub)
#### Xtensa backend
Andrei Safronov \
andrei.safronov@espressif.com (email), [andreisfr](https://github.com/andreisfr) (GitHub)
### Libraries and shared infrastructure
#### ADT, Support
David Blaikie \
dblaikie@gmail.com (email), [dwblaikie](https://github.com/dwblaike) (GitHub) \
Jakub Kuderski \
jakub@nod-labs.com (email), [kuhar](https://github.com/kuhar) (GitHub)
#### Bitcode
Peter Collingbourne \
peter@pcc.me.uk (email), [pcc](https://github.com/pcc) (GitHub)
#### CMake
Petr Hosek \
phosek@google.com (email), [petrhosek](https://github.com/petrhosek) (GitHub)
#### Debug info and DWARF
Adrian Prantl \
aprantl@apple.com (email), [adrian-prantl](https://github.com/adrian-prantl) (GitHub) \
David Blaikie (especially type information) \
dblaikie@gmail.com (email), [dwblaikie](https://github.com/dwblaike) (GitHub) \
Jeremy Morse (especially variable information) \
jeremy.morse@sony.com (email), [jmorse](https://github.com/jmorse) (GitHub) \
Jonas Devlieghere (especially dsymutil/DWARFLinker) \
jonas@devlieghere.com (email), [JDevlieghere](https://github.com/JDevlieghere) (GitHub) \
Eric Christopher \
echristo@gmail.com (email), [echristo](https://github.com/echristo) (GitHub)
#### IR Linker and LTO
Teresa Johnson \
tejohnson@google.com (email), [teresajohnson](https://github.com/teresajohnson) (GitHub)
#### Library layering
Takumi Nakamura \
geek4civic@gmail.com (email), [chapuni](https://github.com/chapuni) (GitHub)
#### MCJIT, Orc, RuntimeDyld, PerfJITEvents
Lang Hames \
lhames@gmail.com (email), [lhames](https://github.com/lhames) (GitHub)
#### SandboxIR
Vasileios Porpodas \
vporpodas@google.com (email), [vporpo](https://github.com/vporpo) (GitHub) \
Jorge Gorbe Moya \
jgorbe@google.com (email), [slackito](https://github.com/slackito) (GitHub)
#### TableGen
Rahul Joshi \
rjoshi@nvidia.com (email), [jurahul](https://github.com/jurahul) (GitHub)
#### TextAPI
Cyndy Ishida \
cyndyishida@gmail.com (email), [cyndyishida](https://github.com/cyndyishida) (GitHub)
### Tools
#### llvm-mca and MCA library
Andrea Di Biagio \
andrea.dibiagio@sony.com, andrea.dibiagio@gmail.com (email), [adibiagio](https://github.com/adibiagio) (GitHub) \
Min-Yih Hsu \
min.hsu@sifive.com, min@myhsu.dev (email), [mshockwave](https://github.com/mshockwave) (GitHub)
#### llvm-cov and Coverage parts of ProfileData
Takumi Nakamura \
geek4civic@gmail.com (email), [chapuni](https://github.com/chapuni) (GitHub) \
Alan Phipps \
a-phipps@ti.com (email), [evodius96](https://github.com/evodius96) (GitHub)
#### Binary Utilities
James Henderson \
james.henderson@sony.com (email), [jh7370](https://github.com/jh7370) (GitHub) \
Fangrui Song \
i@maskray.me (email), [MaskRay](https://github.com/MaskRay) (GitHub)
#### Gold plugin
Teresa Johnson \
tejohnson@google.com (email), [teresajohnson](https://github.com/teresajohnson) (GitHub)
#### llvm-exegesis
Aiden Grossman \
agrossman154@yahoo.com (email), [boomanaiden154](https://github.com/boomanaiden154) (Github)
#### llvm-reduce
Matt Arsenault \
Matthew.Arsenault@amd.com, arsenm2@gmail.com (email), [arsenm](https://github.com/arsenm) (GitHub)
### Other
#### Release management
Odd releases:
Tobias Hieta \
tobias@hieta.se (email), [tru](https://github.com/tru) (GitHub)
Even releases:
Tom Stellard \
tstellar@redhat.com (email), [tstellar](https://github.com/tstellar) (GitHub)
#### MinGW support
Martin Storsjö \
martin@martin.st (email), [mstorsjo](https://github.com/mstorsjo) (GitHub)
#### Sony PlayStation support
Jeremy Morse \
jeremy.morse@sony.com (email), [jmorse](https://github.com/jmorse) (GitHub)
#### Inline assembly
Eric Christopher \
echristo@gmail.com (email), [echristo](https://github.com/echristo) (GitHub)
#### Exception handling
Reid Kleckner \
rnk@google.com (email), [rnk](https://github.com/rnk) (GitHub)
#### LLVM Buildbot
Galina Kistanova \
gkistanova@gmail.com (email), [gkistanova](https://github.com/gkistanova) (GitHub)
### Other subprojects
Some subprojects maintain their own list of per-component maintainers.
[BOLT maintainers](https://github.com/llvm/llvm-project/blob/main/bolt/Maintainers.md)
[Clang maintainers](https://github.com/llvm/llvm-project/blob/main/clang/Maintainers.rst)
[Clang-tools-extra maintainers](https://github.com/llvm/llvm-project/blob/main/clang-tools-extra/Maintainers.txt)
[Compiler-rt maintainers](https://github.com/llvm/llvm-project/blob/main/compiler-rt/Maintainers.md)
[Flang maintainers](https://github.com/llvm/llvm-project/blob/main/flang/Maintainers.md)
[libc++ maintainers](https://github.com/llvm/llvm-project/blob/main/libcxx/Maintainers.md)
[Libc maintainers](https://github.com/llvm/llvm-project/blob/main/libc/Maintainers.rst)
[libclc maintainers](https://github.com/llvm/llvm-project/blob/main/libclc/Maintainers.md)
[libsycl maintainers](https://github.com/llvm/llvm-project/blob/main/libsycl/Maintainers.md)
[LLD maintainers](https://github.com/llvm/llvm-project/blob/main/lld/Maintainers.md)
[LLDB maintainers](https://github.com/llvm/llvm-project/blob/main/lldb/Maintainers.md)
[LLVM OpenMP Library maintainers](https://github.com/llvm/llvm-project/blob/main/openmp/Maintainers.md)
[Polly maintainers](https://github.com/llvm/llvm-project/blob/main/polly/Maintainers.md)
## Inactive Maintainers
The following people have graciously spent time performing maintainer
responsibilities but are no longer active in that role. Thank you for all your
help with the success of the project!
### Emeritus lead maintainers
Chris Lattner \
sabre@nondot.org (email), [lattner](https://github.com/lattner) (GitHub), clattner (Discourse)
### Inactive or former component maintainers
Paul C. Anagnostopoulos (paul@windfall.com, [Paul-C-Anagnostopoulos](https://github.com/Paul-C-Anagnostopoulos)) -- TableGen \
Owen Anderson (resistor@mac.com, [resistor](https://github.com/resistor)) -- SelectionDAG \
Justin Bogner (mail@justinbogner.com, [bogner](https://github.com/bogner)) -- SelectionDAG \
Chandler Carruth (chandlerc@gmail.com, chandlerc@google.com, [chandlerc](https://github.com/chandlerc)) -- ADT, Support, Inlining, CMake and library layering \
Peter Collingbourne (peter@pcc.me.uk, [pcc](https://github.com/pcc)) -- LTO \
Evan Cheng (evan.cheng@apple.com) -- Parts of code generator not covered by someone else \
Jake Ehrlich (jakehehrlich@google.com, [jakehehrlich](https://github.com/jakehehrlich)) -- llvm-objcopy and ObjCopy library \
Hal Finkel (hfinkel@anl.gov, [hfinkel](https://github.com/hfinkel) -- AliasAnalysis \
Justin Fargnoli (jfargnoli@nvidia.com, [justinfargnoli](https://github.com/justinfargnoli)) -- NVPTX backend \
Renato Golin (rengolin@systemcall.eu, [rengolin](https://github.com/rengolin)) -- ARM backend \
Venkatraman Govindaraju (venkatra@cs.wisc.edu, [vegovin](https://github.com/vegovin) -- Sparc backend \
James Grosbach (grosbach@apple.com) -- MC layer \
Anton Korobeynikov (anton@korobeynikov.info, [asl](https://github.com/asl)) -- ARM EABI, Windows codegen, Exception handling \
Benjamin Kramer (benny.kra@gmail.com, [d0k](https://github.com/d0k)) -- DWARF Parser \
David Majnemer (david.majnemer@gmail.com, [majnemer](https://github.com/majnemer)) -- InstCombine, ConstantFold \
Tim Northover (t.p.northover@gmail.com, [TNorthover](https://github.com/TNorthover)) -- AArch64 backend \
Chad Rosier (mcrosier@codeaurora.org) -- FastISel \
Hans Wennborg (hans@chromium.org, [zmodem](https://github.com/zmodem)) -- Release management \
Kostya Serebryany ([kcc](https://github.com/kcc)) -- Sanitizers \
Michael Spencer (bigcheesegs@gmail.com), [Bigcheese](https://github.com/Bigcheese)) -- Windows support in object tools \
Alexei Starovoitov (alexei.starovoitov@gmail.com, [4ast](https://github.com/4ast)) -- BPF backend \
Evgeniy Stepanov ([eugenis](https://github.com/eugenis)) -- Sanitizers \
Zheng Chen (czhengsz@cn.ibm.com, [chenzheng1030](https://github.com/chenzheng1030)) -- PowerPC backend \
Dan Gohman (llvm@sunfishcode.online, [sunfishcode](https://github.com/sunfishcode)) -- WebAssembly backend
### Former maintainers of removed components
Duncan Sands (baldrick@free.fr, [CunningBaldrick](https://github.com/CunningBaldrick)) -- DragonEgg \
Hal Finkel (hfinkel@anl.gov, [hfinkel](https://github.com/hfinkel)) -- LoopReroll
+1 -1
View File
@@ -1,7 +1,7 @@
This file is a list of the people responsible for ensuring that targets and
environments get tested and validated during the release process.
They will also, in conjunction with the release manager and the code owners,
They will also, in conjunction with the release manager and the maintainers,
accept patches into stable release branches, tag critical bugs and release
stoppers as well as make sure that no regressions were observed on their
targets since the last release.
+39
View File
@@ -1,5 +1,44 @@
set(LLVM_LINK_COMPONENTS
AsmParser
Core
SandboxIR
Support)
add_benchmark(DummyYAML DummyYAML.cpp PARTIAL_SOURCES_INTENDED)
add_benchmark(xxhash xxhash.cpp PARTIAL_SOURCES_INTENDED)
add_benchmark(GetIntrinsicForClangBuiltin GetIntrinsicForClangBuiltin.cpp PARTIAL_SOURCES_INTENDED)
add_benchmark(FormatVariadicBM FormatVariadicBM.cpp PARTIAL_SOURCES_INTENDED)
add_benchmark(GetIntrinsicInfoTableEntriesBM GetIntrinsicInfoTableEntriesBM.cpp PARTIAL_SOURCES_INTENDED)
add_benchmark(SandboxIRBench SandboxIRBench.cpp PARTIAL_SOURCES_INTENDED)
add_benchmark(MustacheBench Mustache.cpp PARTIAL_SOURCES_INTENDED)
add_benchmark(SpecialCaseListBM SpecialCaseListBM.cpp PARTIAL_SOURCES_INTENDED)
add_benchmark(RuntimeLibcallsBench RuntimeLibcalls.cpp PARTIAL_SOURCES_INTENDED)
if(NOT LLVM_TOOL_LLVM_DRIVER_BUILD)
# TODO: Check if the tools are in LLVM_DISTRIBUTION_COMPONENTS with
# the driver build. Also support the driver build by invoking the
# tools through llvm-driver
get_host_tool_path(llvm-nm LLVM_NM llvm_nm_exe llvm_nm_target)
get_host_tool_path(llc LLC llc_exe llc_target)
if(llc_exe AND llvm_nm_exe)
# Extract the list of symbols in a random utility as sample data.
set(SYMBOL_TEST_DATA_FILE "sample_symbol_list.txt")
set(SYMBOL_TEST_DATA_SOURCE_BINARY ${llc_exe})
add_custom_command(OUTPUT ${SYMBOL_TEST_DATA_FILE}
COMMAND ${llvm_nm_exe} --no-demangle --no-sort
--format=just-symbols
${SYMBOL_TEST_DATA_SOURCE_BINARY} > ${SYMBOL_TEST_DATA_FILE}
DEPENDS ${llvm_nm_target} ${llc_target})
add_custom_target(generate-runtime-libcalls-sample-symbol-list
DEPENDS ${SYMBOL_TEST_DATA_FILE})
add_dependencies(RuntimeLibcallsBench
generate-runtime-libcalls-sample-symbol-list)
target_compile_definitions(RuntimeLibcallsBench PRIVATE
-DSYMBOL_TEST_DATA_FILE="${CMAKE_CURRENT_BINARY_DIR}/${SYMBOL_TEST_DATA_FILE}")
endif()
endif()
@@ -0,0 +1,63 @@
//===- FormatVariadicBM.cpp - formatv() benchmark ---------- --------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "benchmark/benchmark.h"
#include "llvm/Support/FormatVariadic.h"
#include <algorithm>
#include <string>
#include <vector>
using namespace llvm;
using namespace std;
// Generate a list of format strings that have `NumReplacements` replacements
// by permuting the replacements and some literal text.
static vector<string> getFormatStrings(int NumReplacements) {
vector<string> Components;
for (int I = 0; I < NumReplacements; I++)
Components.push_back("{" + to_string(I) + "}");
// Intersperse these with some other literal text (_).
const string_view Literal = "____";
for (char C : Literal)
Components.push_back(string(1, C));
vector<string> Formats;
do {
string Concat;
for (const string &C : Components)
Concat += C;
Formats.emplace_back(Concat);
} while (next_permutation(Components.begin(), Components.end()));
return Formats;
}
// Generate the set of formats to exercise outside the benchmark code.
static const vector<vector<string>> Formats = {
getFormatStrings(1), getFormatStrings(2), getFormatStrings(3),
getFormatStrings(4), getFormatStrings(5),
};
// Benchmark formatv() for a variety of format strings and 1-5 replacements.
static void BM_FormatVariadic(benchmark::State &state) {
for (auto _ : state) {
for (const string &Fmt : Formats[0])
formatv(Fmt.c_str(), 1).str();
for (const string &Fmt : Formats[1])
formatv(Fmt.c_str(), 1, 2).str();
for (const string &Fmt : Formats[2])
formatv(Fmt.c_str(), 1, 2, 3).str();
for (const string &Fmt : Formats[3])
formatv(Fmt.c_str(), 1, 2, 3, 4).str();
for (const string &Fmt : Formats[4])
formatv(Fmt.c_str(), 1, 2, 3, 4, 5).str();
}
}
BENCHMARK(BM_FormatVariadic);
BENCHMARK_MAIN();
@@ -0,0 +1,50 @@
#include "benchmark/benchmark.h"
#include "llvm/IR/Intrinsics.h"
using namespace llvm;
using namespace Intrinsic;
// Benchmark intrinsic lookup from a variety of targets.
static void BM_GetIntrinsicForClangBuiltin(benchmark::State &state) {
static const char *Builtins[] = {
"__builtin_adjust_trampoline",
"__builtin_trap",
"__builtin_arm_ttest",
"__builtin_amdgcn_cubetc",
"__builtin_amdgcn_udot2",
"__builtin_arm_stc",
"__builtin_bpf_compare",
"__builtin_HEXAGON_A2_max",
"__builtin_lasx_xvabsd_b",
"__builtin_mips_dlsa",
"__nvvm_floor_f",
"__builtin_altivec_vslb",
"__builtin_r600_read_tgid_x",
"__builtin_riscv_aes64im",
"__builtin_s390_vcksm",
"__builtin_ve_vl_pvfmksge_Mvl",
"__builtin_ia32_axor64",
"__builtin_bitrev",
};
static const char *Targets[] = {"", "aarch64", "amdgcn", "mips",
"nvvm", "r600", "riscv"};
for (auto _ : state) {
for (auto Builtin : Builtins)
for (auto Target : Targets)
getIntrinsicForClangBuiltin(Target, Builtin);
}
}
static void
BM_GetIntrinsicForClangBuiltinHexagonFirst(benchmark::State &state) {
// Exercise the worst case by looking for the first builtin for a target
// that has a lot of builtins.
for (auto _ : state)
getIntrinsicForClangBuiltin("hexagon", "__builtin_HEXAGON_A2_abs");
}
BENCHMARK(BM_GetIntrinsicForClangBuiltin);
BENCHMARK(BM_GetIntrinsicForClangBuiltinHexagonFirst);
BENCHMARK_MAIN();
@@ -0,0 +1,30 @@
//===- GetIntrinsicInfoTableEntries.cpp - IIT signature benchmark ---------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "benchmark/benchmark.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/IR/Intrinsics.h"
using namespace llvm;
using namespace Intrinsic;
static void BM_GetIntrinsicInfoTableEntries(benchmark::State &state) {
SmallVector<IITDescriptor> Table;
for (auto _ : state) {
for (ID ID = 1; ID < num_intrinsics; ++ID) {
// This makes sure the vector does not keep growing, as well as after the
// first iteration does not result in additional allocations.
Table.clear();
getIntrinsicInfoTableEntries(ID, Table);
}
}
}
BENCHMARK(BM_GetIntrinsicInfoTableEntries);
BENCHMARK_MAIN();
+289
View File
@@ -0,0 +1,289 @@
#include "llvm/Support/Mustache.h"
#include "benchmark/benchmark.h"
#include "llvm/Support/JSON.h"
#include "llvm/Support/raw_ostream.h"
#include <string>
// A large, raw string with many characters that require HTML escaping.
static const std::string LongHtmlString = [] {
std::string S;
S.reserve(500000);
for (int Idx = 0; Idx < 50000; ++Idx) {
S += "<script>alert('xss');</script>";
}
return S;
}();
// A deep AND wide JSON object for testing traversal.
static const llvm::json::Value DeepJsonData = [] {
llvm::json::Value Root = llvm::json::Object();
llvm::json::Object *Current = Root.getAsObject();
for (int i = 0; i < 50; ++i) { // 50 levels deep
for (int j = 0; j < 100; ++j) {
(*Current)["sibling_" + std::to_string(j)] = llvm::json::Value("noise");
}
std::string Key = "level_" + std::to_string(i);
(*Current)[Key] = llvm::json::Object();
Current = (*Current)[Key].getAsObject();
}
(*Current)["final_value"] = llvm::json::Value("Success!");
llvm::json::Array Arr;
for (int i = 0; i < 5000; ++i) { // 5,000 iterations
Arr.push_back(llvm::json::Value(i));
}
llvm::json::Object NewRoot;
NewRoot["deep_data"] = std::move(Root);
NewRoot["loop_array"] = std::move(Arr);
return llvm::json::Value(std::move(NewRoot));
}();
// A huge array for testing iteration performance.
static const llvm::json::Value HugeArrayData = [] {
llvm::json::Array Arr;
for (int i = 0; i < 100000; ++i) { // 100,000 array items
Arr.push_back(llvm::json::Object(
{{"id", llvm::json::Value(static_cast<long long>(i))},
{"is_even", llvm::json::Value(i % 2 == 0)},
{"data", llvm::json::Value("Item data for " + std::to_string(i))}}));
}
return llvm::json::Object({{"items", std::move(Arr)}});
}();
// The main template that includes a partial within a loop.
static const std::string ComplexPartialTemplate =
"Header\n"
"{{#items}}{{> item_partial}}{{/items}}\n"
"Footer";
// The partial template is now more complex, rendering multiple fields and a
// conditional section.
static const std::string ItemPartialTemplate =
"<div class=\"item\" id=\"{{id}}\">\n"
" <p>{{data}}</p>\n"
" {{#is_even}}<span>(Even)</span>{{/is_even}}\n"
"</div>\n";
// A single large string to stress the output buffer.
static const llvm::json::Value LargeOutputData = llvm::json::Object({
{"long_string",
llvm::json::Value(std::string(1024 * 1024, 'A'))} // 1MB string
});
// --- Static Data (Templates) ---
static const std::string BulkEscapingTemplate = "{{content}}";
static const std::string BulkUnescapedTemplate = "{{{content}}}";
static const std::string BulkUnescapedAmpersandTemplate = "{{& content}}";
static const std::string DeepTraversalTemplate = [] {
std::string LongKey =
"deep_data.level_0.level_1.level_2.level_3.level_4.level_5."
"level_6.level_7.level_8.level_9."
"level_10.level_11.level_12.level_13.level_14.level_"
"15.level_16.level_17.level_18.level_19."
"level_20.level_21.level_22.level_23.level_24.level_"
"25.level_26.level_27.level_28.level_29."
"level_30.level_31.level_32.level_33.level_34.level_"
"35.level_36.level_37.level_38.level_39."
"level_40.level_41.level_42.level_43.level_44.level_"
"45.level_46.level_47.level_48.level_49.final_value";
return "{{#loop_array}}{{" + LongKey + "}}{{/loop_array}}";
}();
static const std::string DeeplyNestedRenderingTemplate = [] {
std::string NestedTemplate = "{{#deep_data}}";
for (int i = 0; i < 50; ++i) {
NestedTemplate += "{{#level_" + std::to_string(i) + "}}";
}
NestedTemplate += "{{final_value}}";
for (int i = 49; i >= 0; --i) {
NestedTemplate += "{{/level_" + std::to_string(i) + "}}";
}
NestedTemplate += "{{/deep_data}}";
return NestedTemplate;
}();
static const std::string HugeArrayIterationTemplate =
"{{#items}}ID: {{id}}.{{/items}}";
static const std::string ComplexTemplateParsingTemplate = [] {
std::string LargeTemplate;
LargeTemplate.reserve(100000);
for (int i = 0; i < 1000; ++i) {
LargeTemplate += "{{var_" + std::to_string(i) +
"}}"
"{{#section_" +
std::to_string(i) + "}}Content{{/section_" +
std::to_string(i) +
"}}"
"{{!comment_" +
std::to_string(i) +
"}}"
"{{=<% %>=}}"
"<%var_tag_changed_to_percent_sign_" +
std::to_string(i) +
"%>"
"<%={{ }}=%>"
"{{^inverted_" +
std::to_string(i) + "}}Not Present{{/inverted_" +
std::to_string(i) + "}}";
}
return LargeTemplate;
}();
static const std::string SmallTemplateParsingTemplate =
"{{level_0.sibling_99}}\n"
"{{level_0.level_1.level_2.level_3.level_4.level_5.sibling_50}}\n"
"{{level_0.level_1.level_2.level_3.level_4.level_5."
"level_6.level_7.level_8.level_9."
"level_10.level_11.level_12.level_13.level_14.level_"
"15.level_16.level_17.level_18.level_19."
"level_20.level_21.level_22.level_23.level_24.level_"
"25.level_26.level_27.level_28.level_29."
"level_30.level_31.level_32.level_33.level_34.level_"
"35.level_36.level_37.level_38.level_39."
"level_40.level_41.level_42.level_43.level_44.level_"
"45.level_46.level_47.level_48.level_49.final_value}}\n";
static const std::string LargeOutputStringTemplate = "{{long_string}}";
// Tests the performance of rendering a large string with various escaping
// syntaxes.
static void BM_Mustache_StringRendering(benchmark::State &state,
const std::string &TplStr) {
llvm::BumpPtrAllocator Allocator;
llvm::StringSaver Saver(Allocator);
llvm::mustache::MustacheContext Ctx(Allocator, Saver);
llvm::mustache::Template Tpl(TplStr, Ctx);
llvm::json::Value Data =
llvm::json::Object({{"content", llvm::json::Value(LongHtmlString)}});
for (auto _ : state) {
std::string Result;
llvm::raw_string_ostream OS(Result);
Tpl.render(Data, OS);
benchmark::DoNotOptimize(Result);
}
}
BENCHMARK_CAPTURE(BM_Mustache_StringRendering, Escaped, BulkEscapingTemplate);
BENCHMARK_CAPTURE(BM_Mustache_StringRendering, Unescaped_Triple,
BulkUnescapedTemplate);
BENCHMARK_CAPTURE(BM_Mustache_StringRendering, Unescaped_Ampersand,
BulkUnescapedAmpersandTemplate);
// Tests the "hot render" cost of repeatedly traversing a deep and wide
// JSON object.
static void BM_Mustache_DeepTraversal(benchmark::State &state) {
llvm::BumpPtrAllocator Allocator;
llvm::StringSaver Saver(Allocator);
llvm::mustache::MustacheContext Ctx(Allocator, Saver);
llvm::mustache::Template Tpl(DeepTraversalTemplate, Ctx);
for (auto _ : state) {
std::string Result;
llvm::raw_string_ostream OS(Result);
Tpl.render(DeepJsonData, OS);
benchmark::DoNotOptimize(Result);
}
}
BENCHMARK(BM_Mustache_DeepTraversal);
// Tests the "hot render" cost of pushing and popping a deep context stack.
static void BM_Mustache_DeeplyNestedRendering(benchmark::State &state) {
llvm::BumpPtrAllocator Allocator;
llvm::StringSaver Saver(Allocator);
llvm::mustache::MustacheContext Ctx(Allocator, Saver);
llvm::mustache::Template Tpl(DeeplyNestedRenderingTemplate, Ctx);
for (auto _ : state) {
std::string Result;
llvm::raw_string_ostream OS(Result);
Tpl.render(DeepJsonData, OS);
benchmark::DoNotOptimize(Result);
}
}
BENCHMARK(BM_Mustache_DeeplyNestedRendering);
// Tests the performance of the loop logic when iterating over a huge number of
// items.
static void BM_Mustache_HugeArrayIteration(benchmark::State &state) {
llvm::BumpPtrAllocator Allocator;
llvm::StringSaver Saver(Allocator);
llvm::mustache::MustacheContext Ctx(Allocator, Saver);
llvm::mustache::Template Tpl(HugeArrayIterationTemplate, Ctx);
for (auto _ : state) {
std::string Result;
llvm::raw_string_ostream OS(Result);
Tpl.render(HugeArrayData, OS);
benchmark::DoNotOptimize(Result);
}
}
BENCHMARK(BM_Mustache_HugeArrayIteration);
// Tests the performance of the parser on a large, "wide" template.
static void BM_Mustache_ComplexTemplateParsing(benchmark::State &state) {
llvm::BumpPtrAllocator Allocator;
llvm::StringSaver Saver(Allocator);
llvm::mustache::MustacheContext Ctx(Allocator, Saver);
for (auto _ : state) {
llvm::mustache::Template Tpl(ComplexTemplateParsingTemplate, Ctx);
benchmark::DoNotOptimize(Tpl);
}
}
BENCHMARK(BM_Mustache_ComplexTemplateParsing);
// Tests the performance of the parser on a small, "deep" template.
static void BM_Mustache_SmallTemplateParsing(benchmark::State &state) {
llvm::BumpPtrAllocator Allocator;
llvm::StringSaver Saver(Allocator);
llvm::mustache::MustacheContext Ctx(Allocator, Saver);
for (auto _ : state) {
llvm::mustache::Template Tpl(SmallTemplateParsingTemplate, Ctx);
benchmark::DoNotOptimize(Tpl);
}
}
BENCHMARK(BM_Mustache_SmallTemplateParsing);
// Tests the performance of rendering a template that includes a partial.
static void BM_Mustache_PartialsRendering(benchmark::State &state) {
llvm::BumpPtrAllocator Allocator;
llvm::StringSaver Saver(Allocator);
llvm::mustache::MustacheContext Ctx(Allocator, Saver);
llvm::mustache::Template Tpl(ComplexPartialTemplate, Ctx);
Tpl.registerPartial("item_partial", ItemPartialTemplate);
llvm::json::Value Data = HugeArrayData;
for (auto _ : state) {
std::string Result;
llvm::raw_string_ostream OS(Result);
Tpl.render(Data, OS);
benchmark::DoNotOptimize(Result);
}
}
BENCHMARK(BM_Mustache_PartialsRendering);
// Tests the performance of the underlying buffer management when generating a
// very large output.
static void BM_Mustache_LargeOutputString(benchmark::State &state) {
llvm::BumpPtrAllocator Allocator;
llvm::StringSaver Saver(Allocator);
llvm::mustache::MustacheContext Ctx(Allocator, Saver);
llvm::mustache::Template Tpl(LargeOutputStringTemplate, Ctx);
for (auto _ : state) {
std::string Result;
llvm::raw_string_ostream OS(Result);
Tpl.render(LargeOutputData, OS);
benchmark::DoNotOptimize(Result);
}
}
BENCHMARK(BM_Mustache_LargeOutputString);
BENCHMARK_MAIN();
@@ -0,0 +1,118 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "llvm/IR/RuntimeLibcalls.h"
#include "benchmark/benchmark.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/LineIterator.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/TargetParser/Triple.h"
#include <random>
#include <string>
using namespace llvm;
static constexpr unsigned MaxFuncNameSize = 53;
static std::vector<StringRef> getLibcallNameStringRefs() {
std::vector<StringRef> Names(RTLIB::NumLibcallImpls);
// Keep the strlens on the StringRef construction out of the benchmark loop.
for (RTLIB::LibcallImpl LC : RTLIB::libcall_impls())
Names[LC] = RTLIB::RuntimeLibcallsInfo::getLibcallImplName(LC);
return Names;
}
static std::vector<std::string> getRandomFuncNames() {
std::mt19937_64 Rng;
std::uniform_int_distribution<> StringLengthDistribution(1, MaxFuncNameSize);
std::uniform_int_distribution<> CharDistribution(1, 255);
int NumTestFuncs = 1 << 10;
std::vector<std::string> TestFuncNames(NumTestFuncs);
for (std::string &TestFuncName : TestFuncNames) {
for (int I = 0, E = StringLengthDistribution(Rng); I != E; ++I)
TestFuncName += static_cast<char>(CharDistribution(Rng));
}
return TestFuncNames;
}
#ifdef SYMBOL_TEST_DATA_FILE
static std::vector<std::string> readSymbolsFromFile(StringRef InputFile) {
auto BufOrError = MemoryBuffer::getFileOrSTDIN(InputFile, /*IsText=*/true);
if (!BufOrError) {
reportFatalUsageError("failed to open \'" + Twine(InputFile) +
"\': " + BufOrError.getError().message());
}
// Hackily figure out if there's a prefix on the symbol names - llvm-nm
// appears to not have a flag to skip this.
llvm::Triple HostTriple(LLVM_HOST_TRIPLE);
DataLayout DL(HostTriple.computeDataLayout());
char GlobalPrefix = DL.getGlobalPrefix();
std::vector<std::string> Lines;
for (line_iterator LineIt(**BufOrError, /*SkipBlanks=*/true);
!LineIt.is_at_eof(); ++LineIt) {
StringRef SymbolName = *LineIt;
SymbolName.consume_front(StringRef(&GlobalPrefix, 1));
Lines.push_back(SymbolName.str());
}
return Lines;
}
#endif
static void BM_LookupRuntimeLibcallByNameKnownCalls(benchmark::State &State) {
std::vector<StringRef> Names = getLibcallNameStringRefs();
for (auto _ : State) {
for (StringRef Name : Names) {
benchmark::DoNotOptimize(
RTLIB::RuntimeLibcallsInfo::lookupLibcallImplName(Name).empty());
}
}
}
static void BM_LookupRuntimeLibcallByNameRandomCalls(benchmark::State &State) {
std::vector<std::string> TestFuncNames = getRandomFuncNames();
for (auto _ : State) {
for (const std::string &Name : TestFuncNames) {
benchmark::DoNotOptimize(
RTLIB::RuntimeLibcallsInfo::lookupLibcallImplName(StringRef(Name))
.empty());
}
}
}
#ifdef SYMBOL_TEST_DATA_FILE
// This isn't fully representative, it doesn't include any anonymous functions.
// nm -n --no-demangle --format=just-symbols sample-binary > sample.txt
static void BM_LookupRuntimeLibcallByNameSampleData(benchmark::State &State) {
std::vector<std::string> TestFuncNames =
readSymbolsFromFile(SYMBOL_TEST_DATA_FILE);
for (auto _ : State) {
for (const std::string &Name : TestFuncNames) {
benchmark::DoNotOptimize(
RTLIB::RuntimeLibcallsInfo::lookupLibcallImplName(StringRef(Name))
.empty());
}
}
}
#endif
BENCHMARK(BM_LookupRuntimeLibcallByNameKnownCalls);
BENCHMARK(BM_LookupRuntimeLibcallByNameRandomCalls);
#ifdef SYMBOL_TEST_DATA_FILE
BENCHMARK(BM_LookupRuntimeLibcallByNameSampleData);
#endif
BENCHMARK_MAIN();
+243
View File
@@ -0,0 +1,243 @@
//===- SandboxIRBench.cpp -------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// These tests measure the performance of some core SandboxIR functions and
// compare them against LLVM IR.
//
//===----------------------------------------------------------------------===//
#include "benchmark/benchmark.h"
#include "llvm/AsmParser/Parser.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/Module.h"
#include "llvm/SandboxIR/Function.h"
#include "llvm/SandboxIR/Instruction.h"
#include "llvm/SandboxIR/Module.h"
#include "llvm/Support/SourceMgr.h"
#include <memory>
#include <sstream>
using namespace llvm;
static std::unique_ptr<Module> parseIR(LLVMContext &C, const char *IR) {
SMDiagnostic Err;
std::unique_ptr<Module> M = parseAssemblyString(IR, Err, C);
if (!M)
Err.print("SandboxIRBench", errs());
return M;
}
enum class IR {
LLVM, ///> LLVM IR
SBoxNoTracking, ///> Sandbox IR with tracking disabled
SBoxTracking, ///> Sandbox IR with tracking enabled
};
// Traits to get llvm::BasicBlock/sandboxir::BasicBlock from IR::LLVM/IR::SBox.
template <IR IRTy> struct TypeSelect {};
template <> struct TypeSelect<IR::LLVM> {
using BasicBlock = llvm::BasicBlock;
};
template <> struct TypeSelect<IR::SBoxNoTracking> {
using BasicBlock = sandboxir::BasicBlock;
};
template <> struct TypeSelect<IR::SBoxTracking> {
using BasicBlock = sandboxir::BasicBlock;
};
template <IR IRTy>
static typename TypeSelect<IRTy>::BasicBlock *
genIR(std::unique_ptr<llvm::Module> &LLVMM, LLVMContext &LLVMCtx,
sandboxir::Context &Ctx,
std::function<std::string(unsigned)> GenerateIRStr,
unsigned NumInstrs = 0u) {
std::string IRStr = GenerateIRStr(NumInstrs);
LLVMM = parseIR(LLVMCtx, IRStr.c_str());
llvm::Function *LLVMF = &*LLVMM->getFunction("foo");
llvm::BasicBlock *LLVMBB = &*LLVMF->begin();
sandboxir::Function *F = Ctx.createFunction(LLVMF);
sandboxir::BasicBlock *BB = &*F->begin();
// Start tracking if we are testing with tracking enabled.
if constexpr (IRTy == IR::SBoxTracking)
Ctx.save();
if constexpr (IRTy == IR::LLVM)
return LLVMBB;
else
return BB;
}
template <IR IRTy> static void finalize(sandboxir::Context &Ctx) {
// Accept changes if we are tracking.
if constexpr (IRTy == IR::SBoxTracking)
Ctx.accept();
}
static std::string generateBBWalkIR(unsigned Size) {
std::stringstream SS;
SS << "define void @foo(i32 %v1, i32 %v2) {\n";
for (auto Cnt : seq<unsigned>(0, Size))
SS << " %add" << Cnt << " = add i32 %v1, %v2\n";
SS << "ret void";
SS << "}";
return SS.str();
}
template <IR IRTy> static void SBoxIRCreation(benchmark::State &State) {
static_assert(IRTy != IR::LLVM, "Expected SBoxTracking or SBoxNoTracking");
LLVMContext LLVMCtx;
unsigned NumInstrs = State.range(0);
std::unique_ptr<llvm::Module> LLVMM;
std::string IRStr = generateBBWalkIR(NumInstrs);
LLVMM = parseIR(LLVMCtx, IRStr.c_str());
llvm::Function *LLVMF = &*LLVMM->getFunction("foo");
for (auto _ : State) {
State.PauseTiming();
sandboxir::Context Ctx(LLVMCtx);
if constexpr (IRTy == IR::SBoxTracking)
Ctx.save();
State.ResumeTiming();
sandboxir::Function *F = Ctx.createFunction(LLVMF);
benchmark::DoNotOptimize(F);
State.PauseTiming();
if constexpr (IRTy == IR::SBoxTracking)
Ctx.accept();
State.ResumeTiming();
}
}
template <IR IRTy> static void BBWalk(benchmark::State &State) {
LLVMContext LLVMCtx;
sandboxir::Context Ctx(LLVMCtx);
unsigned NumInstrs = State.range(0);
std::unique_ptr<llvm::Module> LLVMM;
auto *BB = genIR<IRTy>(LLVMM, LLVMCtx, Ctx, generateBBWalkIR, NumInstrs);
for (auto _ : State) {
// Walk LLVM Instructions.
for (auto &I : *BB)
benchmark::DoNotOptimize(I);
}
}
static std::string generateGetTypeIR(unsigned Size) {
return R"IR(
define void @foo(i32 %v1, i32 %v2) {
%add = add i32 %v1, %v2
ret void
}
)IR";
}
template <IR IRTy> static void GetType(benchmark::State &State) {
LLVMContext LLVMCtx;
sandboxir::Context Ctx(LLVMCtx);
std::unique_ptr<llvm::Module> LLVMM;
auto *BB = genIR<IRTy>(LLVMM, LLVMCtx, Ctx, generateGetTypeIR);
auto *I = &*BB->begin();
for (auto _ : State)
benchmark::DoNotOptimize(I->getType());
}
static std::string generateRAUWIR(unsigned Size) {
std::stringstream SS;
SS << "define void @foo(i32 %v1, i32 %v2) {\n";
SS << " %def1 = add i32 %v1, %v2\n";
SS << " %def2 = add i32 %v1, %v2\n";
for (auto Cnt : seq<unsigned>(0, Size))
SS << " %add" << Cnt << " = add i32 %def1, %def1\n";
SS << "ret void";
SS << "}";
return SS.str();
}
template <IR IRTy> static void RAUW(benchmark::State &State) {
LLVMContext LLVMCtx;
sandboxir::Context Ctx(LLVMCtx);
std::unique_ptr<llvm::Module> LLVMM;
unsigned NumInstrs = State.range(0);
auto *BB = genIR<IRTy>(LLVMM, LLVMCtx, Ctx, generateRAUWIR, NumInstrs);
auto It = BB->begin();
auto *Def1 = &*It++;
auto *Def2 = &*It++;
for (auto _ : State) {
Def1->replaceAllUsesWith(Def2);
Def2->replaceAllUsesWith(Def1);
}
finalize<IRTy>(Ctx);
}
static std::string generateRUOWIR(unsigned NumOperands) {
std::stringstream SS;
auto GenOps = [&SS, NumOperands]() {
for (auto Cnt : seq<unsigned>(0, NumOperands)) {
SS << "i8 %arg" << Cnt;
bool IsLast = Cnt + 1 == NumOperands;
if (!IsLast)
SS << ", ";
}
};
SS << "define void @foo(";
GenOps();
SS << ") {\n";
SS << " call void @foo(";
GenOps();
SS << ")\n";
SS << "ret void";
SS << "}";
return SS.str();
}
template <IR IRTy> static void RUOW(benchmark::State &State) {
LLVMContext LLVMCtx;
sandboxir::Context Ctx(LLVMCtx);
std::unique_ptr<llvm::Module> LLVMM;
unsigned NumOperands = State.range(0);
auto *BB = genIR<IRTy>(LLVMM, LLVMCtx, Ctx, generateRUOWIR, NumOperands);
auto It = BB->begin();
auto *F = BB->getParent();
auto *Arg0 = F->getArg(0);
auto *Arg1 = F->getArg(1);
auto *Call = &*It++;
for (auto _ : State)
Call->replaceUsesOfWith(Arg0, Arg1);
finalize<IRTy>(Ctx);
}
// Measure the time it takes to create Sandbox IR without/with tracking.
BENCHMARK(SBoxIRCreation<IR::SBoxNoTracking>)
->Args({10})
->Args({100})
->Args({1000});
BENCHMARK(SBoxIRCreation<IR::SBoxTracking>)
->Args({10})
->Args({100})
->Args({1000});
BENCHMARK(GetType<IR::LLVM>);
BENCHMARK(GetType<IR::SBoxNoTracking>);
BENCHMARK(BBWalk<IR::LLVM>)->Args({1024});
BENCHMARK(BBWalk<IR::SBoxTracking>)->Args({1024});
BENCHMARK(RAUW<IR::LLVM>)->Args({512});
BENCHMARK(RAUW<IR::SBoxNoTracking>)->Args({512});
BENCHMARK(RAUW<IR::SBoxTracking>)->Args({512});
BENCHMARK(RUOW<IR::LLVM>)->Args({4096});
BENCHMARK(RUOW<IR::SBoxNoTracking>)->Args({4096});
BENCHMARK(RUOW<IR::SBoxTracking>)->Args({4096});
BENCHMARK_MAIN();
@@ -0,0 +1,235 @@
#include "benchmark/benchmark.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/SpecialCaseList.h"
#include "llvm/Support/raw_ostream.h"
#include <cassert>
#include <random>
#include <string>
#include <utility>
#include <vector>
using namespace llvm;
namespace {
constexpr int RNG_SEED = 123456;
constexpr int MAX_LIST_MIN = 10;
constexpr int MAX_LIST_MAX = 1000000;
constexpr int MAX_LIST_MUL = 10;
std::unique_ptr<SpecialCaseList> makeSpecialCaseList(StringRef List) {
std::string Error;
std::unique_ptr<MemoryBuffer> MB = MemoryBuffer::getMemBuffer(List);
auto SCL = SpecialCaseList::create(MB.get(), Error);
assert(SCL);
assert(Error == "");
return SCL;
}
static const std::string Dictionary[] = {
"orange", "tabby", "tortie", "tuxedo", "void",
"multiple", "spaces", "cute", "fluffy", "kittens",
};
std::vector<std::string> genFiles(size_t NumFiles) {
std::vector<std::string> R;
R.reserve(NumFiles);
std::minstd_rand Rng(RNG_SEED);
std::uniform_int_distribution<> DepthDistrib(8, 16);
std::uniform_int_distribution<> WordDistrib(0, std::size(Dictionary) - 1);
std::string S;
for (size_t I = 0; I < NumFiles; ++I) {
for (size_t D = DepthDistrib(Rng); D; --D) {
S += Dictionary[WordDistrib(Rng)];
if (D > 1)
S += "/";
}
R.push_back(std::move(S));
S.clear();
}
return R;
}
std::string genGlobNone(const std::vector<std::string> &Files) {
std::string S;
for (const auto &F : Files) {
S += "src:";
S += F;
S += "\n";
}
return S;
}
std::string genGlobInMid(const std::vector<std::string> &Files) {
std::string S;
std::minstd_rand Rng(RNG_SEED);
for (std::string F : Files) {
std::uniform_int_distribution<> PosDistrib(0, F.size() - 1);
F[PosDistrib(Rng)] = '*';
S += "src:";
S += F;
S += "\n";
}
return S;
}
std::string genGlobAtStart(const std::vector<std::string> &Files) {
std::string S;
for (std::string F : Files) {
F.front() = '*';
S += "src:";
S += F;
S += "\n";
}
return S;
}
std::string genGlobAtEnd(const std::vector<std::string> &Files) {
std::string S;
for (std::string F : Files) {
F.back() = '*';
S += "src:";
S += F;
S += "\n";
}
return S;
}
std::string genGlobAtBothSides(const std::vector<std::string> &Files) {
std::string S;
for (std::string F : Files) {
F.back() = '*';
F.front() = '*';
S += "src:";
S += F;
S += "\n";
}
return S;
}
std::string genGlobAtBothSidesAndMid(const std::vector<std::string> &Files) {
std::string S;
std::minstd_rand Rng(RNG_SEED);
for (std::string F : Files) {
std::uniform_int_distribution<> PosDistrib(0, F.size() - 1);
F[PosDistrib(Rng)] = '*';
std::uniform_int_distribution<> Ends(0, 1);
if (Ends(Rng)) {
F.back() = '*';
F.front() = '*';
}
S += "src:";
S += F;
S += "\n";
}
return S;
}
void BM_Make_(
benchmark::State &state,
std::string (*GenerateCaseList)(const std::vector<std::string> &Files)) {
std::vector<std::string> BigFileList = genFiles(state.range(0));
std::string BigCaseList = GenerateCaseList(BigFileList);
for (auto _ : state) {
auto SCL = makeSpecialCaseList(BigCaseList);
benchmark::DoNotOptimize(SCL);
}
}
void BM_True_(
benchmark::State &state,
std::string (*GenerateCaseList)(const std::vector<std::string> &Files)) {
std::vector<std::string> BigFileList = genFiles(state.range(0));
std::string BigCaseList = GenerateCaseList(BigFileList);
auto SCL = makeSpecialCaseList(BigCaseList);
std::minstd_rand Rng(RNG_SEED);
std::uniform_int_distribution<> LineDistrib(0, BigFileList.size() - 1);
for (auto _ : state) {
auto &Q = BigFileList[LineDistrib(Rng)];
bool R = SCL->inSection("", "src", Q);
if (!R)
abort();
benchmark::DoNotOptimize(R);
}
}
void BM_False(
benchmark::State &state,
std::string (*GenerateCaseList)(const std::vector<std::string> &Files)) {
std::vector<std::string> BigFileList = genFiles(state.range(0));
std::string BigCaseList = GenerateCaseList(BigFileList);
auto SCL = makeSpecialCaseList(BigCaseList);
std::minstd_rand Rng(RNG_SEED);
std::uniform_int_distribution<> LineDistrib(0, BigFileList.size() - 1);
for (auto _ : state) {
std::string Q = BigFileList[LineDistrib(Rng)];
std::uniform_int_distribution<> PosDistrib(0, Q.size() - 1);
Q[PosDistrib(Rng)] = '_';
bool R = SCL->inSection("", "src", Q);
benchmark::DoNotOptimize(R);
}
}
} // namespace
BENCHMARK_CAPTURE(BM_Make_, None_, genGlobNone)
->RangeMultiplier(MAX_LIST_MUL)
->Range(MAX_LIST_MIN, MAX_LIST_MAX);
BENCHMARK_CAPTURE(BM_Make_, Start, genGlobAtStart)
->RangeMultiplier(MAX_LIST_MUL)
->Range(MAX_LIST_MIN, MAX_LIST_MAX);
BENCHMARK_CAPTURE(BM_Make_, End__, genGlobAtEnd)
->RangeMultiplier(MAX_LIST_MUL)
->Range(MAX_LIST_MIN, MAX_LIST_MAX);
BENCHMARK_CAPTURE(BM_Make_, Mid__, genGlobInMid)
->RangeMultiplier(MAX_LIST_MUL)
->Range(MAX_LIST_MIN, MAX_LIST_MAX);
BENCHMARK_CAPTURE(BM_Make_, Both_, genGlobAtBothSides)
->RangeMultiplier(MAX_LIST_MUL)
->Range(MAX_LIST_MIN, MAX_LIST_MAX);
BENCHMARK_CAPTURE(BM_Make_, Mix__, genGlobAtBothSidesAndMid)
->RangeMultiplier(MAX_LIST_MUL)
->Range(MAX_LIST_MIN, MAX_LIST_MAX);
BENCHMARK_CAPTURE(BM_True_, None_, genGlobNone)
->RangeMultiplier(MAX_LIST_MUL)
->Range(MAX_LIST_MIN, MAX_LIST_MAX);
BENCHMARK_CAPTURE(BM_True_, Start, genGlobAtStart)
->RangeMultiplier(MAX_LIST_MUL)
->Range(MAX_LIST_MIN, MAX_LIST_MAX);
BENCHMARK_CAPTURE(BM_True_, End__, genGlobAtEnd)
->RangeMultiplier(MAX_LIST_MUL)
->Range(MAX_LIST_MIN, MAX_LIST_MAX);
BENCHMARK_CAPTURE(BM_True_, Mid__, genGlobInMid)
->RangeMultiplier(MAX_LIST_MUL)
->Range(MAX_LIST_MIN, MAX_LIST_MAX);
BENCHMARK_CAPTURE(BM_True_, Both_, genGlobAtBothSides)
->RangeMultiplier(MAX_LIST_MUL)
->Range(MAX_LIST_MIN, MAX_LIST_MAX);
BENCHMARK_CAPTURE(BM_True_, Mix__, genGlobAtBothSidesAndMid)
->RangeMultiplier(MAX_LIST_MUL)
->Range(MAX_LIST_MIN, MAX_LIST_MAX);
BENCHMARK_CAPTURE(BM_False, None_, genGlobNone)
->RangeMultiplier(MAX_LIST_MUL)
->Range(MAX_LIST_MIN, MAX_LIST_MAX);
BENCHMARK_CAPTURE(BM_False, Start, genGlobAtStart)
->RangeMultiplier(MAX_LIST_MUL)
->Range(MAX_LIST_MIN, MAX_LIST_MAX);
BENCHMARK_CAPTURE(BM_False, End__, genGlobAtEnd)
->RangeMultiplier(MAX_LIST_MUL)
->Range(MAX_LIST_MIN, MAX_LIST_MAX);
BENCHMARK_CAPTURE(BM_False, Mid__, genGlobInMid)
->RangeMultiplier(MAX_LIST_MUL)
->Range(MAX_LIST_MIN, MAX_LIST_MAX);
BENCHMARK_CAPTURE(BM_False, Both_, genGlobAtBothSides)
->RangeMultiplier(MAX_LIST_MUL)
->Range(MAX_LIST_MIN, MAX_LIST_MAX);
BENCHMARK_CAPTURE(BM_False, Mix__, genGlobAtBothSidesAndMid)
->RangeMultiplier(MAX_LIST_MUL)
->Range(MAX_LIST_MIN, MAX_LIST_MAX);
BENCHMARK_MAIN();
@@ -16,11 +16,22 @@ exception Error of string
(** [get_module context mb] reads the bitcode for a new module [m] from the
memory buffer [mb] in the context [context]. Returns [m] if successful, or
raises [Error msg] otherwise, where [msg] is a description of the error
encountered. See the function [llvm::getBitcodeModule]. *)
encountered.
If parsing succeeds, ownership of [mb] is transferred to the returned
module (for lazy deserialization); the caller must not dispose [mb]. If
parsing fails, ownership is retained by the caller, which must dispose it.
See the function [llvm::getBitcodeModule]. *)
val get_module : Llvm.llcontext -> Llvm.llmemorybuffer -> Llvm.llmodule
(** [parse_bitcode context mb] parses the bitcode for a new module [m] from the
memory buffer [mb] in the context [context]. Returns [m] if successful, or
raises [Error msg] otherwise, where [msg] is a description of the error
encountered. See the function [llvm::ParseBitcodeFile]. *)
encountered.
This function does not take ownership of [mb]; the caller should dispose it
(see {!Llvm.MemoryBuffer.dispose}) when it is no longer needed.
See the function [llvm::ParseBitcodeFile]. *)
val parse_bitcode : Llvm.llcontext -> Llvm.llmemorybuffer -> Llvm.llmodule
@@ -15,6 +15,7 @@
|* *|
\*===----------------------------------------------------------------------===*/
#include <assert.h>
#include <string.h>
#include "caml/memory.h"
@@ -137,6 +138,8 @@ static LLVMDIFlags map_DIFlag(LLVMDIFlag_i DIF) {
case i_DIFlagPtrToMemberRep:
return LLVMDIFlagPtrToMemberRep;
}
assert(0 && "Invalid LLVMDIFlag");
return 0;
}
/* unit -> int */
@@ -380,7 +383,6 @@ value llvm_dibuild_get_or_create_array(value Builder, value Data) {
value llvm_dibuild_create_subroutine_type(value Builder, value File,
value ParameterTypes, value Flags) {
mlsize_t Count = Wosize_val(ParameterTypes);
LLVMMetadataRef *Temp = from_val_array(ParameterTypes);
LLVMMetadataRef Metadata = LLVMDIBuilderCreateSubroutineType(
DIBuilder_val(Builder), Metadata_val(File), Temp,
@@ -616,9 +618,10 @@ value llvm_dibuild_create_member_pointer_type_bytecode(value *argv, int argn) {
);
}
value llvm_dibuild_create_object_pointer_type(value Builder, value Type) {
value llvm_dibuild_create_object_pointer_type(value Builder, value Type,
value Implicit) {
LLVMMetadataRef Metadata = LLVMDIBuilderCreateObjectPointerType(
DIBuilder_val(Builder), Metadata_val(Type));
DIBuilder_val(Builder), Metadata_val(Type), Bool_val(Implicit));
return to_val(Metadata);
}
@@ -139,6 +139,12 @@ module MetadataKind = struct
| DIMacroMetadataKind
| DIMacroFileMetadataKind
| DICommonBlockMetadataKind
| DIStringTypeMetadataKind
| DIGenericSubrangeMetadataKind
| DIArgListMetadataKind
| DIAssignIDMetadataKind
| DISubrangeTypeMetadataKind
| DIFixedPointTypeMetadataKind
end
(** The amount of debug information to emit. *)
@@ -398,7 +404,7 @@ external dibuild_create_member_pointer_type :
= "llvm_dibuild_create_member_pointer_type_bytecode" "llvm_dibuild_create_member_pointer_type_native"
external dibuild_create_object_pointer_type :
lldibuilder -> Llvm.llmetadata -> Llvm.llmetadata
lldibuilder -> Llvm.llmetadata -> implicit:bool -> Llvm.llmetadata
= "llvm_dibuild_create_object_pointer_type"
external dibuild_create_qualified_type :
@@ -143,6 +143,12 @@ module MetadataKind : sig
| DIMacroMetadataKind
| DIMacroFileMetadataKind
| DICommonBlockMetadataKind
| DIStringTypeMetadataKind
| DIGenericSubrangeMetadataKind
| DIArgListMetadataKind
| DIAssignIDMetadataKind
| DISubrangeTypeMetadataKind
| DIFixedPointTypeMetadataKind
end
(** The amount of debug information to emit. *)
@@ -471,10 +477,11 @@ val dibuild_create_member_pointer_type :
a pointer to member. See LLVMDIBuilderCreateMemberPointerType *)
val dibuild_create_object_pointer_type :
lldibuilder -> Llvm.llmetadata -> Llvm.llmetadata
lldibuilder -> Llvm.llmetadata -> implicit:bool -> Llvm.llmetadata
(** [dibuild_create_object_pointer_type dib ty] Create a uniqued DIType* clone
with FlagObjectPointer and FlagArtificial set. [dib] is the dibuilder
value and [ty] the underlying type to which this pointer points. *)
with FlagObjectPointer. [dib] is the dibuilder
value and [ty] the underlying type to which this pointer points. If
[implicit] is true, also set FlagArtificial. *)
val dibuild_create_qualified_type :
lldibuilder -> tag:int -> Llvm.llmetadata -> Llvm.llmetadata
@@ -24,12 +24,11 @@ void llvm_raise(value Prototype, char *Message);
/* Llvm.llcontext -> Llvm.llmemorybuffer -> Llvm.llmodule */
value llvm_parse_ir(value C, value MemBuf) {
CAMLparam0();
CAMLlocal2(Variant, MessageVal);
LLVMModuleRef M;
char *Message;
if (LLVMParseIRInContext(Context_val(C), MemoryBuffer_val(MemBuf), &M,
&Message))
if (LLVMParseIRInContext2(Context_val(C), MemoryBuffer_val(MemBuf), &M,
&Message))
llvm_raise(*caml_named_value("Llvm_irreader.Error"), Message);
CAMLreturn(to_val(M));
@@ -11,5 +11,6 @@ exception Error of string
let _ = Callback.register_exception "Llvm_irreader.Error" (Error "")
external parse_ir : Llvm.llcontext -> Llvm.llmemorybuffer -> Llvm.llmodule
= "llvm_parse_ir"
external parse_ir_bitcode_or_assembly
: Llvm.llcontext -> Llvm.llmemorybuffer -> Llvm.llmodule
= "llvm_parse_ir"
@@ -13,8 +13,14 @@
exception Error of string
(** [parse_ir context mb] parses the IR for a new module [m] from the
memory buffer [mb] in the context [context]. Returns [m] if successful, or
raises [Error msg] otherwise, where [msg] is a description of the error
encountered. See the function [llvm::ParseIR]. *)
val parse_ir : Llvm.llcontext -> Llvm.llmemorybuffer -> Llvm.llmodule
(** [parse_ir_bitcode_or_assembly context mb] parses the IR for a new module [m]
from the memory buffer [mb] in the context [context]. Returns [m] if
successful, or raises [Error msg] otherwise, where [msg] is a description
of the error encountered.
This function does not take ownership of [mb]; the caller should dispose it
(see {!Llvm.MemoryBuffer.dispose}) when it is no longer needed.
See the function [llvm::ParseIR]. *)
val parse_ir_bitcode_or_assembly
: Llvm.llcontext -> Llvm.llmemorybuffer -> Llvm.llmodule
+26 -10
View File
@@ -296,6 +296,14 @@ module AtomicRMWBinOp = struct
| UMin
| FAdd
| FSub
| FMax
| FMin
| UInc_Wrap
| UDec_Wrap
| USub_Cond
| USub_Sat
| FMaximum
| FMinimum
end
module ValueKind = struct
@@ -447,8 +455,8 @@ external module_context : llmodule -> llcontext = "llvm_get_module_context"
external get_module_identifier : llmodule -> string
= "llvm_get_module_identifier"
external set_module_identifer : llmodule -> string -> unit
= "llvm_set_module_identifier"
external set_module_identifier : llmodule -> string -> unit
= "llvm_set_module_identifier"
external get_module_flag : llmodule -> string -> llmetadata option
= "llvm_get_module_flag"
@@ -519,7 +527,9 @@ external vector_size : lltype -> int = "llvm_vector_size"
(*--... Operations on other types ..........................................--*)
external void_type : llcontext -> lltype = "llvm_void_type"
external label_type : llcontext -> lltype = "llvm_label_type"
external x86_mmx_type : llcontext -> lltype = "llvm_x86_mmx_type"
external x86_amx_type : llcontext -> lltype = "llvm_x86_amx_type"
external token_type : llcontext -> lltype = "llvm_token_type"
external metadata_type : llcontext -> lltype = "llvm_metadata_type"
external type_by_name : llmodule -> string -> lltype option = "llvm_type_by_name"
external classify_value : llvalue -> ValueKind.t = "llvm_classify_value"
@@ -639,7 +649,6 @@ external align_of : lltype -> llvalue = "llvm_align_of"
external size_of : lltype -> llvalue = "llvm_size_of"
external const_neg : llvalue -> llvalue = "llvm_const_neg"
external const_nsw_neg : llvalue -> llvalue = "llvm_const_nsw_neg"
external const_nuw_neg : llvalue -> llvalue = "llvm_const_nuw_neg"
external const_not : llvalue -> llvalue = "llvm_const_not"
external const_add : llvalue -> llvalue -> llvalue = "llvm_const_add"
external const_nsw_add : llvalue -> llvalue -> llvalue = "llvm_const_nsw_add"
@@ -647,9 +656,6 @@ external const_nuw_add : llvalue -> llvalue -> llvalue = "llvm_const_nuw_add"
external const_sub : llvalue -> llvalue -> llvalue = "llvm_const_sub"
external const_nsw_sub : llvalue -> llvalue -> llvalue = "llvm_const_nsw_sub"
external const_nuw_sub : llvalue -> llvalue -> llvalue = "llvm_const_nuw_sub"
external const_mul : llvalue -> llvalue -> llvalue = "llvm_const_mul"
external const_nsw_mul : llvalue -> llvalue -> llvalue = "llvm_const_nsw_mul"
external const_nuw_mul : llvalue -> llvalue -> llvalue = "llvm_const_nuw_mul"
external const_xor : llvalue -> llvalue -> llvalue = "llvm_const_xor"
external const_gep : lltype -> llvalue -> llvalue array -> llvalue
= "llvm_const_gep"
@@ -695,6 +701,8 @@ external global_copy_all_metadata : llvalue -> (llmdkind * llmetadata) array
external is_global_constant : llvalue -> bool = "llvm_is_global_constant"
external set_global_constant : bool -> llvalue -> unit
= "llvm_set_global_constant"
external global_set_metadata : llvalue -> llmdkind -> llmetadata -> unit
= "llvm_global_set_metadata"
(*--... Operations on global variables .....................................--*)
external declare_global : lltype -> string -> llmodule -> llvalue
@@ -784,7 +792,17 @@ external define_function : string -> lltype -> llmodule -> llvalue
external lookup_function : string -> llmodule -> llvalue option
= "llvm_lookup_function"
external delete_function : llvalue -> unit = "llvm_delete_function"
external is_intrinsic : llvalue -> bool = "llvm_is_intrinsic"
external lookup_intrinsic_id : string -> int = "llvm_lookup_intrinsic_id"
external intrinsic_id : llvalue -> int = "llvm_intrinsic_id"
let is_intrinsic v = intrinsic_id v <> 0
external intrinsic_declaration : llmodule -> int -> lltype array -> llvalue
= "llvm_intrinsic_declaration"
external intrinsic_type : llcontext -> int -> lltype array -> lltype
= "llvm_intrinsic_type"
external intrinsic_name : int -> string = "llvm_intrinsic_name"
external intrinsic_overloaded_name : llmodule -> int -> lltype array -> string
= "llvm_intrinsic_overloaded_name"
external intrinsic_is_overloaded : int -> bool = "llvm_intrinsic_is_overloaded"
external function_call_conv : llvalue -> int = "llvm_function_call_conv"
external set_function_call_conv : int -> llvalue -> unit
= "llvm_set_function_call_conv"
@@ -1255,8 +1273,6 @@ external build_neg : llvalue -> string -> llbuilder -> llvalue
= "llvm_build_neg"
external build_nsw_neg : llvalue -> string -> llbuilder -> llvalue
= "llvm_build_nsw_neg"
external build_nuw_neg : llvalue -> string -> llbuilder -> llvalue
= "llvm_build_nuw_neg"
external build_fneg : llvalue -> string -> llbuilder -> llvalue
= "llvm_build_fneg"
external build_not : llvalue -> string -> llbuilder -> llvalue
+60 -31
View File
@@ -331,6 +331,14 @@ module AtomicRMWBinOp : sig
| UMin
| FAdd
| FSub
| FMax
| FMin
| UInc_Wrap
| UDec_Wrap
| USub_Cond
| USub_Sat
| FMaximum
| FMinimum
end
(** The kind of an [llvalue], the result of [classify_value v].
@@ -552,7 +560,7 @@ val get_module_identifier : llmodule -> string
(** [set_module_identifier m id] sets the module identifier of [m]
to [id]. See the method [llvm::Module::setModuleIdentifier] *)
val set_module_identifer : llmodule -> string -> unit
val set_module_identifier : llmodule -> string -> unit
(** [get_module_flag m k] Return the corresponding value if key [k] appears in
the module flags of [m], otherwise return None
@@ -690,7 +698,7 @@ val named_struct_type : llcontext -> string -> lltype
(** [struct_set_body ty elts ispacked] sets the body of the named struct [ty]
to the [elts] elements.
See the moethd [llvm::StructType::setBody]. *)
See the method [llvm::StructType::setBody]. *)
val struct_set_body : lltype -> lltype array -> bool -> unit
(** [struct_element_types sty] returns the constituent types of the struct type
@@ -760,9 +768,17 @@ val void_type : llcontext -> lltype
[llvm::Type::LabelTy]. *)
val label_type : llcontext -> lltype
(** [x86_mmx_type c] returns the x86 64-bit MMX register type in the
context [c]. See [llvm::Type::X86_MMXTy]. *)
val x86_mmx_type : llcontext -> lltype
(** [x86_amx_type c] creates an X86 AMX type in the context [c]. See
[llvm::Type::getX86_AMXTy]. *)
val x86_amx_type : llcontext -> lltype
(** [token_type c] creates a token type in the context [c]. See
[llvm::Type::getTokenTy]. *)
val token_type : llcontext -> lltype
(** [metadata_type c] creates a metadata type in the context [c]. See
[llvm::Type::getMetadataTy]. *)
val metadata_type : llcontext -> lltype
(** [type_by_name m name] returns the specified type from the current module
if it exists.
@@ -1080,11 +1096,6 @@ val const_neg : llvalue -> llvalue
See the method [llvm::ConstantExpr::getNSWNeg]. *)
val const_nsw_neg : llvalue -> llvalue
(** [const_nuw_neg c] returns the arithmetic negation of the constant [c] with
no unsigned wrapping. The result is undefined if the negation overflows.
See the method [llvm::ConstantExpr::getNUWNeg]. *)
val const_nuw_neg : llvalue -> llvalue
(** [const_not c] returns the bitwise inverse of the constant [c].
See the method [llvm::ConstantExpr::getNot]. *)
val const_not : llvalue -> llvalue
@@ -1117,20 +1128,6 @@ val const_nsw_sub : llvalue -> llvalue -> llvalue
See the method [llvm::ConstantExpr::getNSWSub]. *)
val const_nuw_sub : llvalue -> llvalue -> llvalue
(** [const_mul c1 c2] returns the constant product of two constants.
See the method [llvm::ConstantExpr::getMul]. *)
val const_mul : llvalue -> llvalue -> llvalue
(** [const_nsw_mul c1 c2] returns the constant product of two constants with
no signed wrapping. The result is undefined if the sum overflows.
See the method [llvm::ConstantExpr::getNSWMul]. *)
val const_nsw_mul : llvalue -> llvalue -> llvalue
(** [const_nuw_mul c1 c2] returns the constant product of two constants with
no unsigned wrapping. The result is undefined if the sum overflows.
See the method [llvm::ConstantExpr::getNSWMul]. *)
val const_nuw_mul : llvalue -> llvalue -> llvalue
(** [const_xor c1 c2] returns the constant bitwise [XOR] of two integer
constants.
See the method [llvm::ConstantExpr::getXor]. *)
@@ -1358,6 +1355,12 @@ val is_global_constant : llvalue -> bool
See the method [llvm::GlobalVariable::setConstant]. *)
val set_global_constant : bool -> llvalue -> unit
(** [global_set_metadata g k md] sets the metadata attachment of the global
value [g] to the metadata [md] for the given kind [k], erasing the existing
metadata attachment if it already exists for the given kind.
See the method [llvm::GlobalObject::setMetadata]. *)
val global_set_metadata : llvalue -> llmdkind -> llmetadata -> unit
(** [global_initializer gv] If global variable [gv] has an initializer it is returned,
otherwise returns [None]. See the method [llvm::GlobalVariable::getInitializer]. *)
val global_initializer : llvalue -> llvalue option
@@ -1470,10 +1473,43 @@ val rev_iter_functions : (llvalue -> unit) -> llmodule -> unit
[f1,...,fN] are the functions of module [m]. Tail recursive. *)
val fold_right_functions : (llvalue -> 'a -> 'a) -> llmodule -> 'a -> 'a
(** [lookup_intrinsic_id name] obtains the intrinsic ID number for the given
function name. See the method [llvm::Intrinsic::lookupIntrinsicID].*)
val lookup_intrinsic_id : string -> int
(** [intrinsic_id] returns the ID of intrinsic function [f]. If [f] is not
an intrinsic, returns [0]. See the method
[llvm::Function::getIntrinsicID]. *)
val intrinsic_id : llvalue -> int
(** [is_intrinsic f] returns true if the function [f] is an intrinsic.
See the method [llvm::Function::isIntrinsic]. *)
val is_intrinsic : llvalue -> bool
(** [intrinsic_declaration m id overload_types] gets or inserts the
declaration of an intrinsic. For overloaded intrinsics, types must be
provided to uniquely identify an overload. See the method
[llvm::Intrinsic::getOrInsertDeclaration]. *)
val intrinsic_declaration : llmodule -> int -> lltype array -> llvalue
(** [intrinsic_type c id overload_types] returns the type of intrinsic [id] in
context [c]. For overloaded intrinsics, types must be provided to uniquely
identify an overload. See the method [llvm::Intrinsic::getType]. *)
val intrinsic_type : llcontext -> int -> lltype array -> lltype
(** [intrinsic_name id] returns the name of intrinsic [id]. See the method
[llvm::Intrinsic::getName()]. *)
val intrinsic_name : int -> string
(** [intrinsic_overloaded_name m id overload_types] returns the name of an
overloaded intrinsic [id] identified by the overload types
[overload_types]. See the method [llvm::Intrinsic::getName]. *)
val intrinsic_overloaded_name : llmodule -> int -> lltype array -> string
(** [intrinsic_is_overloaded id] returns if intrinsic [id] is overloaded. See
the method [llvm::Intrinsic::isOverloaded]. *)
val intrinsic_is_overloaded : int -> bool
(** [function_call_conv f] returns the calling convention of the function [f].
See the method [llvm::Function::getCallingConv]. *)
val function_call_conv : llvalue -> int
@@ -2204,13 +2240,6 @@ val build_neg : llvalue -> string -> llbuilder -> llvalue
See the method [llvm::LLVMBuilder::CreateNeg]. *)
val build_nsw_neg : llvalue -> string -> llbuilder -> llvalue
(** [build_nuw_neg x name b] creates a
[%name = nuw sub 0, %x]
instruction at the position specified by the instruction builder [b].
[-0.0] is used for floating point types to compute the correct sign.
See the method [llvm::LLVMBuilder::CreateNeg]. *)
val build_nuw_neg : llvalue -> string -> llbuilder -> llvalue
(** [build_fneg x name b] creates a
[%name = fsub 0, %x]
instruction at the position specified by the instruction builder [b].
+85 -43
View File
@@ -15,16 +15,16 @@
|* *|
\*===----------------------------------------------------------------------===*/
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "llvm_ocaml.h"
#include "caml/callback.h"
#include "caml/fail.h"
#include "caml/memory.h"
#include "llvm-c/Core.h"
#include "llvm-c/Support.h"
#include "llvm/Config/llvm-config.h"
#include "caml/memory.h"
#include "caml/fail.h"
#include "caml/callback.h"
#include "llvm_ocaml.h"
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#if OCAML_VERSION < 41200
value caml_alloc_some(value v) {
@@ -239,7 +239,9 @@ value llvm_dispose_context(value C) {
}
/* unit -> llcontext */
value llvm_global_context(value Unit) { return to_val(LLVMGetGlobalContext()); }
value llvm_global_context(value Unit) {
return to_val(LLVMGetGlobalContext());
}
/* llcontext -> string -> int */
value llvm_mdkind_id(value C, value Name) {
@@ -687,8 +689,18 @@ value llvm_label_type(value Context) {
}
/* llcontext -> lltype */
value llvm_x86_mmx_type(value Context) {
return to_val(LLVMX86MMXTypeInContext(Context_val(Context)));
value llvm_x86_amx_type(value Context) {
return to_val(LLVMX86AMXTypeInContext(Context_val(Context)));
}
/* llcontext -> lltype */
value llvm_token_type(value Context) {
return to_val(LLVMTokenTypeInContext(Context_val(Context)));
}
/* llcontext -> lltype */
value llvm_metadata_type(value Context) {
return to_val(LLVMMetadataTypeInContext(Context_val(Context)));
}
/* llmodule -> string -> lltype option */
@@ -1152,12 +1164,6 @@ value llvm_const_nsw_neg(value Value) {
return to_val(NegValue);
}
/* llvalue -> llvalue */
value llvm_const_nuw_neg(value Value) {
LLVMValueRef NegValue = LLVMConstNUWNeg(Value_val(Value));
return to_val(NegValue);
}
/* llvalue -> llvalue */
value llvm_const_not(value Value) {
LLVMValueRef NotValue = LLVMConstNot(Value_val(Value));
@@ -1200,24 +1206,6 @@ value llvm_const_nuw_sub(value LHS, value RHS) {
return to_val(Value);
}
/* llvalue -> llvalue -> llvalue */
value llvm_const_mul(value LHS, value RHS) {
LLVMValueRef Value = LLVMConstMul(Value_val(LHS), Value_val(RHS));
return to_val(Value);
}
/* llvalue -> llvalue -> llvalue */
value llvm_const_nsw_mul(value LHS, value RHS) {
LLVMValueRef Value = LLVMConstNSWMul(Value_val(LHS), Value_val(RHS));
return to_val(Value);
}
/* llvalue -> llvalue -> llvalue */
value llvm_const_nuw_mul(value LHS, value RHS) {
LLVMValueRef Value = LLVMConstNUWMul(Value_val(LHS), Value_val(RHS));
return to_val(Value);
}
/* llvalue -> llvalue -> llvalue */
value llvm_const_xor(value LHS, value RHS) {
LLVMValueRef Value = LLVMConstXor(Value_val(LHS), Value_val(RHS));
@@ -1554,6 +1542,14 @@ value llvm_set_global_constant(value Flag, value GlobalVar) {
return Val_unit;
}
/* llvalue -> llmdkind -> llmetadata -> unit */
value llvm_global_set_metadata(value Value, value MetadataKind,
value Metadata) {
LLVMGlobalSetMetadata(Value_val(Value), (unsigned int)Int_val(MetadataKind),
Metadata_val(Metadata));
return Val_unit;
}
/*--... Operations on aliases ..............................................--*/
/* llmodule -> lltype -> int -> llvalue -> string -> llvalue */
@@ -1599,9 +1595,61 @@ value llvm_delete_function(value Fn) {
return Val_unit;
}
/* llvalue -> bool */
value llvm_is_intrinsic(value Fn) {
return Val_bool(LLVMGetIntrinsicID(Value_val(Fn)));
/* string -> int */
value llvm_lookup_intrinsic_id(value Name) {
const char *NameCStr = String_val(Name);
size_t Len = caml_string_length(Name);
return Val_int(LLVMLookupIntrinsicID(NameCStr, Len));
}
/* llvalue -> int */
value llvm_intrinsic_id(value Fn) {
return Val_int(LLVMGetIntrinsicID(Value_val(Fn)));
}
/* llmodule -> int -> lltype array -> llvalue */
value llvm_intrinsic_declaration(value M, value ID, value OverloadTypes) {
mlsize_t Length = Wosize_val(OverloadTypes);
LLVMTypeRef *Temp = from_val_array(OverloadTypes);
LLVMValueRef Intrinsic =
LLVMGetIntrinsicDeclaration(Module_val(M), Int_val(ID), Temp, Length);
free(Temp);
return to_val(Intrinsic);
}
/* llcontext -> int -> lltype array -> lltype */
value llvm_intrinsic_type(value C, value ID, value OverloadTypes) {
mlsize_t Length = Wosize_val(OverloadTypes);
LLVMTypeRef *Temp = from_val_array(OverloadTypes);
LLVMTypeRef Type =
LLVMIntrinsicGetType(Context_val(C), Int_val(ID), Temp, Length);
free(Temp);
return to_val(Type);
}
/* int -> string */
value llvm_intrinsic_name(value ID) {
size_t Length = -1;
const char *NameCStr = LLVMIntrinsicGetName(Int_val(ID), &Length);
return caml_copy_string(NameCStr);
}
/* llmodule -> int -> lltype array -> string */
value llvm_intrinsic_overloaded_name(value M, value ID, value OverloadTypes) {
mlsize_t TypeCount = Wosize_val(OverloadTypes);
LLVMTypeRef *Temp = from_val_array(OverloadTypes);
size_t NameLength = -1;
char *OverloadedNameCStrOwned = LLVMIntrinsicCopyOverloadedName2(
Module_val(M), Int_val(ID), Temp, TypeCount, &NameLength);
value OverloadedName = caml_copy_string(OverloadedNameCStrOwned);
free(OverloadedNameCStrOwned);
free(Temp);
return OverloadedName;
}
/* int -> bool */
value llvm_intrinsic_is_overloaded(int ID) {
return Val_bool(LLVMIntrinsicIsOverloaded(Int_val(ID)));
}
/* llvalue -> int */
@@ -2358,12 +2406,6 @@ value llvm_build_nsw_neg(value X, value Name, value B) {
LLVMBuildNSWNeg(Builder_val(B), Value_val(X), String_val(Name)));
}
/* llvalue -> string -> llbuilder -> llvalue */
value llvm_build_nuw_neg(value X, value Name, value B) {
return to_val(
LLVMBuildNUWNeg(Builder_val(B), Value_val(X), String_val(Name)));
}
/* llvalue -> string -> llbuilder -> llvalue */
value llvm_build_fneg(value X, value Name, value B) {
return to_val(LLVMBuildFNeg(Builder_val(B), Value_val(X), String_val(Name)));
+130 -56
View File
@@ -1,8 +1,3 @@
if( WIN32 AND NOT CYGWIN )
# We consider Cygwin as another Unix
set(PURE_WINDOWS 1)
endif()
include(CheckIncludeFile)
include(CheckLibraryExists)
include(CheckSymbolExists)
@@ -17,6 +12,51 @@ include(CheckCompilerVersion)
include(CheckProblematicConfigurations)
include(HandleLLVMStdlib)
if (ANDROID OR CYGWIN OR CMAKE_SYSTEM_NAME MATCHES "AIX|DragonFly|FreeBSD|Haiku|Linux|NetBSD|OpenBSD|SunOS")
set(HAVE_MACH_MACH_H 0)
set(HAVE_MALLOC_MALLOC_H 0)
set(HAVE_PTHREAD_H 1)
set(HAVE_SYS_MMAN_H 1)
set(HAVE_SYSEXITS_H 1)
set(HAVE_UNISTD_H 1)
set(HAVE_SYS_IOCTL_H 1)
elseif (APPLE)
set(HAVE_MACH_MACH_H 1)
set(HAVE_MALLOC_MALLOC_H 1)
set(HAVE_PTHREAD_H 1)
set(HAVE_SYS_MMAN_H 1)
set(HAVE_SYSEXITS_H 1)
set(HAVE_UNISTD_H 1)
set(HAVE_SYS_IOCTL_H 1)
elseif (WIN32)
set(HAVE_MACH_MACH_H 0)
set(HAVE_MALLOC_MALLOC_H 0)
set(HAVE_PTHREAD_H 0)
set(HAVE_SYS_MMAN_H 0)
set(HAVE_SYSEXITS_H 0)
set(HAVE_UNISTD_H 0)
set(HAVE_SYS_IOCTL_H 0)
elseif (ZOS)
# Confirmed in
# https://github.com/llvm/llvm-project/pull/104706#issuecomment-2297109613
set(HAVE_MACH_MACH_H 0)
set(HAVE_MALLOC_MALLOC_H 0)
set(HAVE_PTHREAD_H 1)
set(HAVE_SYS_MMAN_H 1)
set(HAVE_SYSEXITS_H 0)
set(HAVE_UNISTD_H 1)
set(HAVE_SYS_IOCTL_H 1)
else()
# Other platforms that we don't promise support for.
check_include_file(mach/mach.h HAVE_MACH_MACH_H)
check_include_file(malloc/malloc.h HAVE_MALLOC_MALLOC_H)
check_include_file(pthread.h HAVE_PTHREAD_H)
check_include_file(sys/mman.h HAVE_SYS_MMAN_H)
check_include_file(sysexits.h HAVE_SYSEXITS_H)
check_include_file(unistd.h HAVE_UNISTD_H)
check_include_file(sys/ioctl.h HAVE_SYS_IOCTL_H)
endif()
if( UNIX AND NOT (APPLE OR BEOS OR HAIKU) )
# Used by check_symbol_exists:
list(APPEND CMAKE_REQUIRED_LIBRARIES "m")
@@ -29,39 +69,36 @@ endif()
# Do checks with _XOPEN_SOURCE and large-file API on AIX, because we will build
# with those too.
if (UNIX AND ${CMAKE_SYSTEM_NAME} MATCHES "AIX")
if (UNIX AND "${CMAKE_SYSTEM_NAME}" MATCHES "AIX")
list(APPEND CMAKE_REQUIRED_DEFINITIONS "-D_XOPEN_SOURCE=700")
list(APPEND CMAKE_REQUIRED_DEFINITIONS "-D_LARGE_FILE_API")
endif()
# Do checks with _FILE_OFFSET_BITS=64 on Solaris, because we will build
# with those too.
if (UNIX AND ${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
if (UNIX AND "${CMAKE_SYSTEM_NAME}" MATCHES "SunOS")
list(APPEND CMAKE_REQUIRED_DEFINITIONS "-D_FILE_OFFSET_BITS=64")
endif()
# include checks
check_include_file(dlfcn.h HAVE_DLFCN_H)
check_include_file(errno.h HAVE_ERRNO_H)
check_include_file(fcntl.h HAVE_FCNTL_H)
check_include_file(link.h HAVE_LINK_H)
check_include_file(malloc/malloc.h HAVE_MALLOC_MALLOC_H)
if( NOT PURE_WINDOWS )
check_include_file(pthread.h HAVE_PTHREAD_H)
# Newer POSIX functions aren't available without the appropriate defines.
# Usually those are set by the use of -std=gnuXX, but one can also use the
# newer functions with -std=c(++)XX, i.e. without the GNU language extensions.
# Keep this at the top to make sure we don't add _GNU_SOURCE dependent checks
# before adding it.
check_symbol_exists(__GLIBC__ stdio.h LLVM_USING_GLIBC)
if(LLVM_USING_GLIBC OR CYGWIN)
add_compile_definitions(_GNU_SOURCE)
list(APPEND CMAKE_REQUIRED_DEFINITIONS "-D_GNU_SOURCE")
endif()
check_include_file(signal.h HAVE_SIGNAL_H)
check_include_file(sys/ioctl.h HAVE_SYS_IOCTL_H)
check_include_file(sys/mman.h HAVE_SYS_MMAN_H)
check_include_file(sys/param.h HAVE_SYS_PARAM_H)
check_include_file(sys/resource.h HAVE_SYS_RESOURCE_H)
check_include_file(sys/stat.h HAVE_SYS_STAT_H)
check_include_file(sys/time.h HAVE_SYS_TIME_H)
check_include_file(sys/types.h HAVE_SYS_TYPES_H)
check_include_file(sysexits.h HAVE_SYSEXITS_H)
check_include_file(termios.h HAVE_TERMIOS_H)
check_include_file(unistd.h HAVE_UNISTD_H)
# enable 64bit off_t on 32bit systems using glibc
if(LLVM_USING_GLIBC AND CMAKE_SIZEOF_VOID_P EQUAL 4)
add_compile_definitions(_FILE_OFFSET_BITS=64)
list(APPEND CMAKE_REQUIRED_DEFINITIONS "-D_FILE_OFFSET_BITS=64")
endif()
# include checks
check_include_file(valgrind/valgrind.h HAVE_VALGRIND_VALGRIND_H)
check_include_file(fenv.h HAVE_FENV_H)
check_symbol_exists(FE_ALL_EXCEPT "fenv.h" HAVE_DECL_FE_ALL_EXCEPT)
check_symbol_exists(FE_INEXACT "fenv.h" HAVE_DECL_FE_INEXACT)
check_c_source_compiles("
@@ -76,7 +113,6 @@ check_c_source_compiles("
int main(void) { return 0; }"
HAVE_BUILTIN_THREAD_POINTER)
check_include_file(mach/mach.h HAVE_MACH_MACH_H)
check_include_file(CrashReporterClient.h HAVE_CRASHREPORTERCLIENT_H)
if(APPLE)
check_c_source_compiles("
@@ -86,7 +122,7 @@ if(APPLE)
HAVE_CRASHREPORTER_INFO)
endif()
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
check_include_file(linux/magic.h HAVE_LINUX_MAGIC_H)
if(NOT HAVE_LINUX_MAGIC_H)
# older kernels use split files
@@ -96,7 +132,7 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
endif()
# library checks
if( NOT PURE_WINDOWS )
if(NOT WIN32)
check_library_exists(pthread pthread_create "" HAVE_LIBPTHREAD)
if (HAVE_LIBPTHREAD)
check_library_exists(pthread pthread_rwlock_init "" HAVE_PTHREAD_RWLOCK_INIT)
@@ -110,7 +146,7 @@ if( NOT PURE_WINDOWS )
endif()
endif()
check_library_exists(dl dlopen "" HAVE_LIBDL)
check_library_exists(rt clock_gettime "" HAVE_LIBRT)
check_library_exists(rt shm_open "" HAVE_LIBRT)
endif()
# Check for libpfm.
@@ -159,8 +195,19 @@ if(LLVM_ENABLE_ZSTD)
elseif(NOT LLVM_USE_SANITIZER MATCHES "Memory.*")
find_package(zstd QUIET)
endif()
# If LLVM_USE_STATIC_ZSTD is specified, make sure we enable zstd only if static
# libraries are found.
if(LLVM_USE_STATIC_ZSTD AND NOT TARGET zstd::libzstd_static)
# Fail if LLVM_ENABLE_ZSTD is FORCE_ON.
if(LLVM_ENABLE_ZSTD STREQUAL FORCE_ON)
message(FATAL_ERROR "Failed to find static zstd libraries, but LLVM_USE_STATIC_ZSTD=ON and LLVM_ENABLE_ZSTD=FORCE_ON.")
endif()
set(LLVM_ENABLE_ZSTD OFF)
else()
set(LLVM_ENABLE_ZSTD ${zstd_FOUND})
endif()
endif()
set(LLVM_ENABLE_ZSTD ${zstd_FOUND})
if(LLVM_ENABLE_LIBXML2)
if(LLVM_ENABLE_LIBXML2 STREQUAL FORCE_ON)
@@ -228,7 +275,7 @@ endif()
# party code may call MSan interceptors like strlen, leading to false positives.
if(NOT LLVM_USE_SANITIZER MATCHES "Memory.*")
# Don't look for these libraries on Windows.
if (NOT PURE_WINDOWS)
if (NOT WIN32)
# Skip libedit if using ASan as it contains memory leaks.
if (LLVM_ENABLE_LIBEDIT AND NOT LLVM_USE_SANITIZER MATCHES ".*Address.*")
if(LLVM_ENABLE_LIBEDIT STREQUAL FORCE_ON)
@@ -258,6 +305,41 @@ if(LLVM_HAS_LOGF128)
set(LLVM_HAS_LOGF128 "${HAS_LOGF128}")
endif()
if (LLVM_ENABLE_ICU STREQUAL FORCE_ON AND LLVM_ENABLE_ICONV STREQUAL FORCE_ON)
message(FATAL_ERROR "LLVM_ENABLE_ICU and LLVM_ENABLE_ICONV should not both be FORCE_ON")
endif()
# Check for ICU. Only allow an optional, dynamic link for ICU so we don't impact LLVM's licensing.
if(LLVM_ENABLE_ICU AND NOT(LLVM_ENABLE_ICONV STREQUAL FORCE_ON))
set(LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
set(CMAKE_FIND_LIBRARY_SUFFIXES "${CMAKE_SHARED_LIBRARY_SUFFIX}")
if (LLVM_ENABLE_ICU STREQUAL FORCE_ON)
find_package(ICU REQUIRED COMPONENTS uc i18n)
if (NOT ICU_FOUND)
message(FATAL_ERROR "Failed to configure ICU, but LLVM_ENABLE_ICU is FORCE_ON")
endif()
else()
find_package(ICU COMPONENTS uc i18n)
endif()
set(HAVE_ICU ${ICU_FOUND})
set(CMAKE_FIND_LIBRARY_SUFFIXES ${LIBRARY_SUFFIXES})
endif()
# Check only for builtin iconv to avoid licensing issues.
if(LLVM_ENABLE_ICONV AND NOT HAVE_ICU)
if (LLVM_ENABLE_ICONV STREQUAL FORCE_ON)
find_package(Iconv REQUIRED)
if (NOT Iconv_FOUND OR NOT Iconv_IS_BUILT_IN)
message(FATAL_ERROR "Failed to configure iconv, but LLVM_ENABLE_ICONV is FORCE_ON")
endif()
else()
find_package(Iconv)
endif()
if(Iconv_FOUND AND Iconv_IS_BUILT_IN)
set(HAVE_ICONV 1)
endif()
endif()
# function checks
check_symbol_exists(arc4random "stdlib.h" HAVE_DECL_ARC4RANDOM)
find_package(Backtrace)
@@ -280,15 +362,15 @@ check_symbol_exists(_Unwind_Backtrace "unwind.h" HAVE__UNWIND_BACKTRACE)
check_symbol_exists(getpagesize unistd.h HAVE_GETPAGESIZE)
check_symbol_exists(sysconf unistd.h HAVE_SYSCONF)
check_symbol_exists(getrusage sys/resource.h HAVE_GETRUSAGE)
check_symbol_exists(setrlimit sys/resource.h HAVE_SETRLIMIT)
check_symbol_exists(isatty unistd.h HAVE_ISATTY)
check_symbol_exists(futimens sys/stat.h HAVE_FUTIMENS)
check_symbol_exists(futimes sys/time.h HAVE_FUTIMES)
check_symbol_exists(getauxval sys/auxv.h HAVE_GETAUXVAL)
# AddressSanitizer conflicts with lib/Support/Unix/Signals.inc
# Avoid sigaltstack on Apple platforms, where backtrace() cannot handle it
# (rdar://7089625) and _Unwind_Backtrace is unusable because it cannot unwind
# past the signal handler after an assertion failure (rdar://29866587).
if( HAVE_SIGNAL_H AND NOT LLVM_USE_SANITIZER MATCHES ".*Address.*" AND NOT APPLE )
if( NOT LLVM_USE_SANITIZER MATCHES ".*Address.*" AND NOT APPLE )
check_symbol_exists(sigaltstack signal.h HAVE_SIGALTSTACK)
endif()
check_symbol_exists(mallctl malloc_np.h HAVE_MALLCTL)
@@ -296,14 +378,13 @@ check_symbol_exists(mallinfo malloc.h HAVE_MALLINFO)
check_symbol_exists(mallinfo2 malloc.h HAVE_MALLINFO2)
check_symbol_exists(malloc_zone_statistics malloc/malloc.h
HAVE_MALLOC_ZONE_STATISTICS)
check_symbol_exists(getrlimit "sys/types.h;sys/time.h;sys/resource.h" HAVE_GETRLIMIT)
check_symbol_exists(posix_spawn spawn.h HAVE_POSIX_SPAWN)
check_symbol_exists(pread unistd.h HAVE_PREAD)
check_symbol_exists(sbrk unistd.h HAVE_SBRK)
check_symbol_exists(strerror_r string.h HAVE_STRERROR_R)
check_symbol_exists(strerror_s string.h HAVE_DECL_STRERROR_S)
check_symbol_exists(setenv stdlib.h HAVE_SETENV)
if( PURE_WINDOWS )
if(WIN32)
check_symbol_exists(_chsize_s io.h HAVE__CHSIZE_S)
check_function_exists(_alloca HAVE__ALLOCA)
@@ -330,7 +411,7 @@ endif()
CHECK_STRUCT_HAS_MEMBER("struct stat" st_mtimespec.tv_nsec
"sys/types.h;sys/stat.h" HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC)
if (UNIX AND ${CMAKE_SYSTEM_NAME} MATCHES "AIX")
if (UNIX AND "${CMAKE_SYSTEM_NAME}" MATCHES "AIX")
# The st_mtim.tv_nsec member of a `stat` structure is not reliable on some AIX
# environments.
set(HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC 0)
@@ -339,36 +420,29 @@ else()
"sys/types.h;sys/stat.h" HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC)
endif()
check_symbol_exists(__GLIBC__ stdio.h LLVM_USING_GLIBC)
if( LLVM_USING_GLIBC )
add_compile_definitions(_GNU_SOURCE)
list(APPEND CMAKE_REQUIRED_DEFINITIONS "-D_GNU_SOURCE")
# enable 64bit off_t on 32bit systems using glibc
if (CMAKE_SIZEOF_VOID_P EQUAL 4)
add_compile_definitions(_FILE_OFFSET_BITS=64)
list(APPEND CMAKE_REQUIRED_DEFINITIONS "-D_FILE_OFFSET_BITS=64")
endif()
endif()
# This check requires _GNU_SOURCE.
if (NOT PURE_WINDOWS)
if (NOT WIN32)
if (LLVM_PTHREAD_LIB)
list(APPEND CMAKE_REQUIRED_LIBRARIES ${LLVM_PTHREAD_LIB})
endif()
check_symbol_exists(pthread_getname_np pthread.h HAVE_PTHREAD_GETNAME_NP)
check_symbol_exists(pthread_setname_np pthread.h HAVE_PTHREAD_SETNAME_NP)
check_symbol_exists(pthread_get_name_np "pthread.h;pthread_np.h" HAVE_PTHREAD_GET_NAME_NP)
check_symbol_exists(pthread_set_name_np "pthread.h;pthread_np.h" HAVE_PTHREAD_SET_NAME_NP)
if (LLVM_PTHREAD_LIB)
list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES ${LLVM_PTHREAD_LIB})
endif()
endif()
# This check requires _GNU_SOURCE.
if( HAVE_DLFCN_H )
if( HAVE_LIBDL )
list(APPEND CMAKE_REQUIRED_LIBRARIES dl)
endif()
# Add the _XOPEN_SOURCE macro on z/OS, as certain test(s) use dlopen
if (ZOS)
list(APPEND CMAKE_REQUIRED_DEFINITIONS "-D_XOPEN_SOURCE=600")
endif()
check_symbol_exists(dlopen dlfcn.h HAVE_DLOPEN)
check_symbol_exists(dladdr dlfcn.h HAVE_DLADDR)
if (ZOS)
list(REMOVE_ITEM CMAKE_REQUIRED_DEFINITIONS "-D_XOPEN_SOURCE=600")
endif()
if( HAVE_LIBDL )
list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES dl)
endif()
@@ -436,7 +510,7 @@ set(USE_NO_UNINITIALIZED 0)
# false positives.
if (CMAKE_COMPILER_IS_GNUCXX)
# Disable all -Wuninitialized warning for old GCC versions.
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 12.0)
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 15.0)
set(USE_NO_UNINITIALIZED 1)
else()
set(USE_NO_MAYBE_UNINITIALIZED 1)
+4 -1
View File
@@ -908,6 +908,9 @@ EOF
crisv32:Linux:*:*)
echo crisv32-axis-linux-gnu
exit ;;
e2k:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
frv:Linux:*:*)
echo frv-unknown-linux-gnu
exit ;;
@@ -1003,7 +1006,7 @@ EOF
ppcle:Linux:*:*)
echo powerpcle-unknown-linux-gnu
exit ;;
riscv32:Linux:*:* | riscv64:Linux:*:*)
riscv32:Linux:*:* | riscv64:Linux:*:* | riscv32be:Linux:*:* | riscv64be:Linux:*:*)
LIBC=gnu
eval $set_cc_for_build
# Do not check for __GLIBC__ because uclibc defines it too
+229 -127
View File
@@ -19,13 +19,38 @@ function(get_subproject_title outvar)
endif ()
endfunction(get_subproject_title)
function(llvm_update_compile_flags name)
get_property(sources TARGET ${name} PROPERTY SOURCES)
if("${sources}" MATCHES "\\.c(;|$)")
set(update_src_props ON)
endif()
# Determine required flags to enable/disable RTTI.
set(LLVM_CXXFLAGS_RTTI_DISABLE "")
set(LLVM_CXXFLAGS_RTTI_ENABLE "")
if(LLVM_COMPILER_IS_GCC_COMPATIBLE)
set(LLVM_CXXFLAGS_RTTI_DISABLE "-fno-rtti")
elseif(MSVC)
set(LLVM_CXXFLAGS_RTTI_DISABLE "/GR-")
set(LLVM_CXXFLAGS_RTTI_ENABLE "/GR")
elseif(CMAKE_CXX_COMPILER_ID MATCHES "XL")
set(LLVM_CXXFLAGS_RTTI_DISABLE "-qnortti")
endif()
list(APPEND LLVM_COMPILE_CFLAGS " ${LLVM_COMPILE_FLAGS}")
# Determine required flags to enable/disable EH.
set(LLVM_CXXFLAGS_EH_DISABLE "")
set(LLVM_CXXFLAGS_EH_ENABLE "")
if(LLVM_COMPILER_IS_GCC_COMPATIBLE)
set(LLVM_CXXFLAGS_EH_DISABLE "-fno-exceptions")
if(LLVM_ENABLE_UNWIND_TABLES)
list(APPEND LLVM_CXXFLAGS_EH_DISABLE "-funwind-tables")
else()
list(APPEND LLVM_CXXFLAGS_EH_DISABLE "-fno-unwind-tables")
list(APPEND LLVM_CXXFLAGS_EH_DISABLE "-fno-asynchronous-unwind-tables")
endif()
elseif(MSVC)
set(LLVM_CXXFLAGS_EH_ENABLE "/EHsc")
set(LLVM_CXXFLAGS_EH_DISABLE "/EHs-c-")
elseif (CMAKE_CXX_COMPILER_ID MATCHES "XL")
set(LLVM_CXXFLAGS_EH_DISABLE "-qnoeh")
endif()
function(llvm_update_compile_flags name)
set(LLVM_COMPILE_CXXFLAGS "")
# LLVM_REQUIRES_EH is an internal flag that individual targets can use to
# force EH
@@ -34,72 +59,28 @@ function(llvm_update_compile_flags name)
message(AUTHOR_WARNING "Exception handling requires RTTI. Enabling RTTI for ${name}")
set(LLVM_REQUIRES_RTTI ON)
endif()
if(MSVC)
list(APPEND LLVM_COMPILE_FLAGS "/EHsc")
endif()
list(APPEND LLVM_COMPILE_CXXFLAGS ${LLVM_CXXFLAGS_EH_ENABLE})
else()
if(LLVM_COMPILER_IS_GCC_COMPATIBLE)
list(APPEND LLVM_COMPILE_FLAGS "-fno-exceptions")
if(LLVM_ENABLE_UNWIND_TABLES)
list(APPEND LLVM_COMPILE_FLAGS "-funwind-tables")
else()
list(APPEND LLVM_COMPILE_FLAGS "-fno-unwind-tables")
list(APPEND LLVM_COMPILE_FLAGS "-fno-asynchronous-unwind-tables")
endif()
elseif(MSVC)
if(MSVC)
list(APPEND LLVM_COMPILE_DEFINITIONS _HAS_EXCEPTIONS=0)
list(APPEND LLVM_COMPILE_FLAGS "/EHs-c-")
elseif (CMAKE_CXX_COMPILER_ID MATCHES "XL")
list(APPEND LLVM_COMPILE_FLAGS "-qnoeh")
endif()
list(APPEND LLVM_COMPILE_CXXFLAGS ${LLVM_CXXFLAGS_EH_DISABLE})
endif()
# LLVM_REQUIRES_RTTI is an internal flag that individual
# targets can use to force RTTI
set(LLVM_CONFIG_HAS_RTTI YES CACHE INTERNAL "")
if(NOT (LLVM_REQUIRES_RTTI OR LLVM_ENABLE_RTTI))
set(LLVM_CONFIG_HAS_RTTI NO CACHE INTERNAL "")
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-")
elseif (CMAKE_CXX_COMPILER_ID MATCHES "XL")
list(APPEND LLVM_COMPILE_FLAGS "-qnortti")
endif ()
elseif(MSVC)
list(APPEND LLVM_COMPILE_FLAGS "/GR")
endif()
# Assume that;
# - LLVM_COMPILE_FLAGS is list.
# - PROPERTY COMPILE_FLAGS is string.
string(REPLACE ";" " " target_compile_flags " ${LLVM_COMPILE_FLAGS}")
string(REPLACE ";" " " target_compile_cflags " ${LLVM_COMPILE_CFLAGS}")
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()
if("${suf}" STREQUAL ".c")
set_property(SOURCE ${fn} APPEND_STRING PROPERTY
COMPILE_FLAGS "${target_compile_cflags}")
endif()
endforeach()
list(APPEND LLVM_COMPILE_CXXFLAGS ${LLVM_CXXFLAGS_RTTI_DISABLE})
else()
# Update target props, since all sources are C++.
set_property(TARGET ${name} APPEND_STRING PROPERTY
COMPILE_FLAGS "${target_compile_flags}")
list(APPEND LLVM_COMPILE_CXXFLAGS ${LLVM_CXXFLAGS_RTTI_ENABLE})
endif()
set_property(TARGET ${name} APPEND PROPERTY COMPILE_DEFINITIONS ${LLVM_COMPILE_DEFINITIONS})
target_compile_options(${name} PRIVATE ${LLVM_COMPILE_FLAGS} $<$<COMPILE_LANGUAGE:CXX>:${LLVM_COMPILE_CXXFLAGS}>)
target_compile_definitions(${name} PRIVATE ${LLVM_COMPILE_DEFINITIONS})
endfunction()
function(add_llvm_symbol_exports target_name export_file)
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
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}
@@ -108,7 +89,7 @@ function(add_llvm_symbol_exports target_name export_file)
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(${CMAKE_SYSTEM_NAME} MATCHES "AIX")
elseif("${CMAKE_SYSTEM_NAME}" MATCHES "AIX")
# FIXME: `-Wl,-bE:` bypasses whatever handling there is in the build
# compiler driver to defer to the specified export list.
set(native_export_file "${export_file}")
@@ -137,7 +118,7 @@ function(add_llvm_symbol_exports target_name export_file)
set_property(TARGET ${target_name} APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,--version-script,\"${CMAKE_CURRENT_BINARY_DIR}/${native_export_file}\"")
endif()
elseif(WIN32)
elseif(WIN32 OR CYGWIN)
set(native_export_file "${target_name}.def")
add_custom_command(OUTPUT ${native_export_file}
@@ -149,20 +130,20 @@ function(add_llvm_symbol_exports target_name export_file)
set(export_file_linker_flag "${CMAKE_CURRENT_BINARY_DIR}/${native_export_file}")
if(MSVC)
# cl.exe or clang-cl, i.e. MSVC style command line interface
set(export_file_linker_flag "/DEF:\"${export_file_linker_flag}\"")
set(export_file_linker_flag "LINKER:/DEF:${export_file_linker_flag}")
elseif(CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC")
# clang in msvc mode, calling a link.exe/lld-link style linker
set(export_file_linker_flag "-Wl,/DEF:\"${export_file_linker_flag}\"")
elseif(MINGW)
set(export_file_linker_flag "-Wl,/DEF:${export_file_linker_flag}")
elseif(MINGW OR CYGWIN)
# ${export_file_linker_flag}, which is the plain file name, works as is
# when passed to the compiler driver, which then passes it on to the
# linker as an input file.
set(export_file_linker_flag "\"${export_file_linker_flag}\"")
set(export_file_linker_flag "${export_file_linker_flag}")
else()
message(FATAL_ERROR "Unsupported Windows toolchain")
endif()
set_property(TARGET ${target_name} APPEND_STRING PROPERTY
LINK_FLAGS " ${export_file_linker_flag}")
set_property(TARGET ${target_name} APPEND PROPERTY
LINK_OPTIONS "${export_file_linker_flag}")
endif()
add_custom_target(${target_name}_exports DEPENDS ${native_export_file})
@@ -257,12 +238,6 @@ if (NOT DEFINED LLVM_LINKER_DETECTED AND NOT WIN32)
set(LLVM_LINKER_DETECTED YES CACHE INTERNAL "")
set(LLVM_LINKER_IS_GNULD YES CACHE INTERNAL "")
message(STATUS "Linker detection: GNU ld")
elseif("${stderr}" MATCHES "(illumos)" OR
"${stdout}" MATCHES "(illumos)")
set(LLVM_LINKER_DETECTED YES CACHE INTERNAL "")
set(LLVM_LINKER_IS_SOLARISLD YES CACHE INTERNAL "")
set(LLVM_LINKER_IS_SOLARISLD_ILLUMOS YES CACHE INTERNAL "")
message(STATUS "Linker detection: Solaris ld (illumos)")
elseif("${stderr}" MATCHES "Solaris Link Editors" OR
"${stdout}" MATCHES "Solaris Link Editors")
set(LLVM_LINKER_DETECTED YES CACHE INTERNAL "")
@@ -274,7 +249,7 @@ if (NOT DEFINED LLVM_LINKER_DETECTED AND NOT WIN32)
endif()
endif()
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
if("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin")
include(CheckLinkerFlag)
# Linkers that support Darwin allow a setting to internalize all symbol exports,
# aiding in reducing binary size and often is applicable for executables.
@@ -296,6 +271,7 @@ if (NOT DEFINED LLVM_LINKER_DETECTED AND NOT WIN32)
endif()
function(add_link_opts target_name)
include(CheckLinkerFlag)
get_llvm_distribution(${target_name} in_distribution in_distribution_var)
if(NOT in_distribution)
# Don't LTO optimize targets that aren't part of any distribution.
@@ -320,15 +296,14 @@ function(add_link_opts target_name)
# linker in a context where the optimizations are not important.
if (NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG")
if(NOT LLVM_NO_DEAD_STRIP)
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
if("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin")
# ld64's implementation of -dead_strip breaks tools that use plugins.
set_property(TARGET ${target_name} APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,-dead_strip")
elseif(${CMAKE_SYSTEM_NAME} MATCHES "SunOS" AND LLVM_LINKER_IS_SOLARISLD)
elseif("${CMAKE_SYSTEM_NAME}" MATCHES "SunOS" AND LLVM_LINKER_IS_SOLARISLD)
# Support for ld -z discard-unused=sections was only added in
# Solaris 11.4. GNU ld ignores it, but warns every time.
include(LLVMCheckLinkerFlag)
llvm_check_linker_flag(CXX "-Wl,-z,discard-unused=sections" LINKER_SUPPORTS_Z_DISCARD_UNUSED)
check_linker_flag(CXX "-Wl,-z,discard-unused=sections" LINKER_SUPPORTS_Z_DISCARD_UNUSED)
if (LINKER_SUPPORTS_Z_DISCARD_UNUSED)
set_property(TARGET ${target_name} APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,-z,discard-unused=sections")
@@ -339,7 +314,7 @@ function(add_link_opts target_name)
LINK_FLAGS " -Wl,--gc-sections")
endif()
else() #LLVM_NO_DEAD_STRIP
if(${CMAKE_SYSTEM_NAME} MATCHES "AIX")
if("${CMAKE_SYSTEM_NAME}" MATCHES "AIX")
set_property(TARGET ${target_name} APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,-bnogc")
endif()
@@ -351,10 +326,16 @@ function(add_link_opts target_name)
LINK_FLAGS " -Wl,-no_warn_duplicate_libraries")
endif()
if(ARG_SUPPORT_PLUGINS AND ${CMAKE_SYSTEM_NAME} MATCHES "AIX")
if(ARG_SUPPORT_PLUGINS AND "${CMAKE_SYSTEM_NAME}" MATCHES "AIX")
set_property(TARGET ${target_name} APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,-brtl")
endif()
# Check for existence of symbolic functions flag. Not supported
# by the older BFD linker (such as on some OpenBSD archs), the
# MinGW driver for LLD, and the Solaris native linker.
check_linker_flag(CXX "-Wl,-Bsymbolic-functions"
LLVM_LINKER_SUPPORTS_B_SYMBOLIC_FUNCTIONS)
endfunction(add_link_opts)
# Set each output directory according to ${CMAKE_CONFIGURATION_TYPES}.
@@ -606,6 +587,10 @@ function(llvm_add_library name)
endif()
endforeach()
endif()
if(ARG_DISABLE_LLVM_LINK_LLVM_DYLIB)
target_compile_definitions(${obj_name} PRIVATE LLVM_BUILD_STATIC)
endif()
endif()
if(ARG_SHARED AND ARG_STATIC)
@@ -641,8 +626,36 @@ function(llvm_add_library name)
endif()
set_target_properties(${name} PROPERTIES FOLDER "${subproject_title}/Libraries")
## If were compiling with clang-cl use /Zc:dllexportInlines- to exclude inline
## class members from being dllexport'ed to reduce compile time.
## This will also keep us below the 64k exported symbol limit
## https://blog.llvm.org/2018/11/30-faster-windows-builds-with-clang-cl_14.html
if(LLVM_BUILD_LLVM_DYLIB AND NOT LLVM_DYLIB_EXPORT_INLINES AND
MSVC AND CMAKE_CXX_COMPILER_ID MATCHES Clang)
target_compile_options(${name} PUBLIC /Zc:dllexportInlines-)
if(TARGET ${obj_name})
target_compile_options(${obj_name} PUBLIC /Zc:dllexportInlines-)
endif()
endif()
if(ARG_COMPONENT_LIB)
set_target_properties(${name} PROPERTIES LLVM_COMPONENT TRUE)
if(LLVM_BUILD_LLVM_DYLIB OR BUILD_SHARED_LIBS)
target_compile_definitions(${name} PRIVATE LLVM_EXPORTS)
endif()
# When building shared objects for each target there are some internal APIs
# that are used across shared objects which we can't hide.
if (LLVM_BUILD_LLVM_DYLIB_VIS AND NOT BUILD_SHARED_LIBS AND NOT APPLE AND
(NOT (WIN32 OR CYGWIN) OR ((MINGW OR CYGWIN) AND CMAKE_CXX_COMPILER_ID MATCHES "Clang")) AND
NOT ("${CMAKE_SYSTEM_NAME}" MATCHES "AIX") AND
NOT DEFINED CMAKE_CXX_VISIBILITY_PRESET)
set_target_properties(${name} PROPERTIES
C_VISIBILITY_PRESET hidden
CXX_VISIBILITY_PRESET hidden
VISIBILITY_INLINES_HIDDEN YES)
endif()
set_property(GLOBAL APPEND PROPERTY LLVM_COMPONENT_LIBS ${name})
endif()
@@ -718,7 +731,7 @@ function(llvm_add_library name)
set(library_name ${output_name}-${LLVM_VERSION_MAJOR}${LLVM_VERSION_SUFFIX})
set(api_name ${output_name}-${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}${LLVM_VERSION_SUFFIX})
set_target_properties(${name} PROPERTIES OUTPUT_NAME ${library_name})
if(UNIX)
if(UNIX AND NOT CYGWIN)
llvm_install_library_symlink(${api_name} ${library_name} SHARED
COMPONENT ${name})
llvm_install_library_symlink(${output_name} ${library_name} SHARED
@@ -741,6 +754,9 @@ function(llvm_add_library name)
if (LLVM_LINK_LLVM_DYLIB AND NOT ARG_DISABLE_LLVM_LINK_LLVM_DYLIB)
set(llvm_libs LLVM)
else()
if(ARG_DISABLE_LLVM_LINK_LLVM_DYLIB)
target_compile_definitions(${name} PRIVATE LLVM_BUILD_STATIC)
endif()
llvm_map_components_to_libnames(llvm_libs
${ARG_LINK_COMPONENTS}
${LLVM_LINK_COMPONENTS}
@@ -897,7 +913,7 @@ endfunction()
macro(add_llvm_library name)
cmake_parse_arguments(ARG
"SHARED;BUILDTREE_ONLY;MODULE;INSTALL_WITH_TOOLCHAIN"
"SHARED;BUILDTREE_ONLY;MODULE;INSTALL_WITH_TOOLCHAIN;NO_EXPORT"
""
""
${ARGN})
@@ -932,7 +948,11 @@ macro(add_llvm_library name)
set(umbrella)
endif()
get_target_export_arg(${name} LLVM export_to_llvmexports ${umbrella})
if(ARG_NO_EXPORT)
set(export_to_llvmexports)
else()
get_target_export_arg(${name} LLVM export_to_llvmexports ${umbrella})
endif()
install(TARGETS ${name}
${export_to_llvmexports}
LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX} COMPONENT ${name}
@@ -945,7 +965,9 @@ macro(add_llvm_library name)
COMPONENT ${name})
endif()
endif()
set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS ${name})
if(NOT ARG_NO_EXPORT)
set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS ${name})
endif()
endif()
get_subproject_title(subproject_title)
@@ -1010,7 +1032,7 @@ endmacro()
macro(add_llvm_executable name)
cmake_parse_arguments(ARG
"DISABLE_LLVM_LINK_LLVM_DYLIB;IGNORE_EXTERNALIZE_DEBUGINFO;NO_INSTALL_RPATH;SUPPORT_PLUGINS"
"DISABLE_LLVM_LINK_LLVM_DYLIB;IGNORE_EXTERNALIZE_DEBUGINFO;NO_INSTALL_RPATH;SUPPORT_PLUGINS;EXPORT_SYMBOLS"
"ENTITLEMENTS;BUNDLE_PATH"
""
${ARGN})
@@ -1053,7 +1075,7 @@ macro(add_llvm_executable name)
llvm_update_compile_flags(${name})
endif()
if (ARG_SUPPORT_PLUGINS AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "AIX")
if (ARG_SUPPORT_PLUGINS AND NOT "${CMAKE_SYSTEM_NAME}" MATCHES "AIX")
set(LLVM_NO_DEAD_STRIP On)
endif()
@@ -1070,7 +1092,8 @@ macro(add_llvm_executable name)
endif(LLVM_EXPORTED_SYMBOL_FILE)
if (DEFINED LLVM_ENABLE_EXPORTED_SYMBOLS_IN_EXECUTABLES AND
NOT LLVM_ENABLE_EXPORTED_SYMBOLS_IN_EXECUTABLES)
NOT LLVM_ENABLE_EXPORTED_SYMBOLS_IN_EXECUTABLES AND
NOT ARG_EXPORT_SYMBOLS)
if(LLVM_LINKER_SUPPORTS_NO_EXPORTED_SYMBOLS)
set_property(TARGET ${name} APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,-no_exported_symbols")
@@ -1111,6 +1134,20 @@ macro(add_llvm_executable name)
endif()
llvm_codesign(${name} ENTITLEMENTS ${ARG_ENTITLEMENTS} BUNDLE_PATH ${ARG_BUNDLE_PATH})
if (ARG_EXPORT_SYMBOLS)
export_executable_symbols(${name})
endif()
if(ARG_DISABLE_LLVM_LINK_LLVM_DYLIB OR NOT LLVM_LINK_LLVM_DYLIB)
target_compile_definitions(${name} PRIVATE LLVM_BUILD_STATIC)
endif()
if(LLVM_BUILD_LLVM_DYLIB_VIS AND NOT LLVM_DYLIB_EXPORT_INLINES AND
MSVC AND CMAKE_CXX_COMPILER_ID MATCHES Clang)
# This has to match how the libraries the executable is linked to are built or there be linker errors.
target_compile_options(${name} PRIVATE /Zc:dllexportInlines-)
endif()
endmacro(add_llvm_executable name)
# add_llvm_pass_plugin(name [NO_MODULE] ...)
@@ -1164,9 +1201,9 @@ function(add_llvm_pass_plugin name)
endif()
set_property(GLOBAL APPEND PROPERTY LLVM_STATIC_EXTENSIONS ${name})
elseif(NOT ARG_NO_MODULE)
add_llvm_library(${name} MODULE ${ARG_UNPARSED_ARGUMENTS})
add_llvm_library(${name} MODULE NO_EXPORT ${ARG_UNPARSED_ARGUMENTS})
else()
add_llvm_library(${name} OBJECT ${ARG_UNPARSED_ARGUMENTS})
add_llvm_library(${name} OBJECT NO_EXPORT ${ARG_UNPARSED_ARGUMENTS})
endif()
message(STATUS "Registering ${name} as a pass plugin (static build: ${LLVM_${name_upper}_LINK_INTO_TOOLS})")
@@ -1303,6 +1340,14 @@ function(export_executable_symbols target)
while(NOT "${new_libs}" STREQUAL "")
foreach(lib ${new_libs})
if(TARGET ${lib})
# If this is a ALIAS target, continue with its aliasee instead.
get_target_property(aliased_lib ${lib} ALIASED_TARGET)
if(aliased_lib)
set(new_libs ${lib_aliased_target})
list(APPEND newer_libs ${aliased_lib})
continue()
endif()
get_target_property(lib_type ${lib} TYPE)
if("${lib_type}" STREQUAL "STATIC_LIBRARY")
list(APPEND static_libs ${lib})
@@ -1361,7 +1406,7 @@ function(export_executable_symbols target)
# CMake doesn't set CMAKE_EXE_EXPORTS_${lang}_FLAG on Solaris, so
# ENABLE_EXPORTS has no effect. While Solaris ld defaults to -rdynamic
# behaviour, GNU ld needs it.
if (APPLE OR ${CMAKE_SYSTEM_NAME} STREQUAL "SunOS")
if (APPLE OR "${CMAKE_SYSTEM_NAME}" STREQUAL "SunOS")
set_property(TARGET ${target} APPEND_STRING PROPERTY
LINK_FLAGS " -rdynamic")
endif()
@@ -1386,6 +1431,7 @@ if(NOT LLVM_TOOLCHAIN_TOOLS)
llvm-lib
llvm-mca
llvm-ml
llvm-ml64
llvm-nm
llvm-objcopy
llvm-objdump
@@ -1396,6 +1442,7 @@ if(NOT LLVM_TOOLCHAIN_TOOLS)
llvm-strings
llvm-strip
llvm-profdata
llvm-profgen
llvm-symbolizer
# symlink version of some of above tools that are enabled by
# LLVM_INSTALL_BINUTILS_SYMLINKS.
@@ -1415,6 +1462,9 @@ if(NOT LLVM_TOOLCHAIN_TOOLS)
if (LLVM_ENABLE_LIBXML2)
list(APPEND LLVM_TOOLCHAIN_TOOLS llvm-mt)
endif()
if (LLVM_TOOL_LLVM_DRIVER_BUILD)
list(APPEND LLVM_TOOLCHAIN_TOOLS llvm-driver)
endif()
endif()
macro(llvm_add_tool project name)
@@ -1433,11 +1483,16 @@ macro(llvm_add_tool project name)
if ( ${name} IN_LIST LLVM_TOOLCHAIN_TOOLS OR NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
if( LLVM_BUILD_TOOLS )
get_target_export_arg(${name} LLVM export_to_llvmexports)
get_target_export_arg(${name} ${project} export_to_llvmexports)
install(TARGETS ${name}
${export_to_llvmexports}
RUNTIME DESTINATION ${${project}_TOOLS_INSTALL_DIR}
COMPONENT ${name})
if (LLVM_ENABLE_PDB)
install(FILES $<TARGET_PDB_FILE:${name}>
DESTINATION "${${project}_TOOLS_INSTALL_DIR}" COMPONENT ${name}
OPTIONAL)
endif()
if (NOT LLVM_ENABLE_IDE)
add_llvm_install_targets(install-${name}
@@ -1447,11 +1502,13 @@ macro(llvm_add_tool project name)
endif()
endif()
if( LLVM_BUILD_TOOLS )
set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS ${name})
string(TOUPPER "${project}" project_upper)
set_property(GLOBAL APPEND PROPERTY ${project_upper}_EXPORTS ${name})
endif()
endif()
get_subproject_title(subproject_title)
set_target_properties(${name} PROPERTIES FOLDER "${subproject_title}/Tools")
set_target_properties(${name} PROPERTIES XCODE_GENERATE_SCHEME ON)
endmacro(llvm_add_tool project name)
macro(add_llvm_tool name)
@@ -1463,9 +1520,14 @@ macro(add_llvm_example name)
if( NOT LLVM_BUILD_EXAMPLES )
set(EXCLUDE_FROM_ALL ON)
endif()
add_llvm_executable(${name} ${ARGN})
add_llvm_executable(${name} EXPORT_SYMBOLS ${ARGN})
if( LLVM_BUILD_EXAMPLES )
install(TARGETS ${name} RUNTIME DESTINATION "${LLVM_EXAMPLES_INSTALL_DIR}")
if (LLVM_ENABLE_PDB)
install(FILES $<TARGET_PDB_FILE:${name}>
DESTINATION "${LLVM_EXAMPLES_INSTALL_DIR}" COMPONENT ${name}
OPTIONAL)
endif()
endif()
get_subproject_title(subproject_title)
set_target_properties(${name} PROPERTIES FOLDER "${subproject_title}/Examples")
@@ -1500,6 +1562,11 @@ macro(add_llvm_utility name)
${export_to_llvmexports}
RUNTIME DESTINATION ${LLVM_UTILS_INSTALL_DIR}
COMPONENT ${name})
if (LLVM_ENABLE_PDB)
install(FILES $<TARGET_PDB_FILE:${name}>
DESTINATION "${LLVM_UTILS_INSTALL_DIR}" COMPONENT ${name}
OPTIONAL)
endif()
if (NOT LLVM_ENABLE_IDE)
add_llvm_install_targets(install-${name}
@@ -1669,6 +1736,31 @@ function(add_llvm_implicit_projects)
llvm_add_implicit_projects(LLVM)
endfunction(add_llvm_implicit_projects)
function(set_unittest_link_flags target_name)
# The runtime benefits of LTO don't outweight the compile time costs for
# tests.
if(LLVM_ENABLE_LTO)
if((UNIX OR MINGW) AND LINKER_IS_LLD)
if(LLVM_ENABLE_FATLTO AND NOT APPLE)
# When using FatLTO, just use relocatable linking.
set_property(TARGET ${target_name} APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,--no-fat-lto-objects")
else()
set_property(TARGET ${target_name} APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,--lto-O0")
endif()
elseif(LINKER_IS_LLD_LINK)
set_property(TARGET ${target_name} APPEND_STRING PROPERTY
LINK_FLAGS " /opt:lldlto=0")
elseif(APPLE AND NOT uppercase_LLVM_ENABLE_LTO STREQUAL "THIN")
set_property(TARGET ${target_name} APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,-mllvm,-O0")
endif()
endif()
target_link_options(${target_name} PRIVATE "${LLVM_UNITTEST_LINK_FLAGS}")
endfunction(set_unittest_link_flags)
# Generic support for adding a unittest.
function(add_unittest test_suite test_name)
if( NOT LLVM_BUILD_TESTS )
@@ -1692,34 +1784,20 @@ function(add_unittest test_suite test_name)
get_subproject_title(subproject_title)
set_target_properties(${test_name} PROPERTIES FOLDER "${subproject_title}/Tests/Unit")
# The runtime benefits of LTO don't outweight the compile time costs for tests.
if(LLVM_ENABLE_LTO)
if((UNIX OR MINGW) AND LINKER_IS_LLD)
if(LLVM_ENABLE_FATLTO AND NOT APPLE)
# When using FatLTO, just use relocatable linking.
set_property(TARGET ${test_name} APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,--no-fat-lto-objects")
else()
set_property(TARGET ${test_name} APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,--lto-O0")
endif()
elseif(LINKER_IS_LLD_LINK)
set_property(TARGET ${test_name} APPEND_STRING PROPERTY
LINK_FLAGS " /opt:lldlto=0")
elseif(APPLE AND NOT uppercase_LLVM_ENABLE_LTO STREQUAL "THIN")
set_property(TARGET ${target_name} APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,-mllvm,-O0")
endif()
endif()
target_link_options(${test_name} PRIVATE "${LLVM_UNITTEST_LINK_FLAGS}")
set_unittest_link_flags(${test_name})
set(outdir ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR})
set_output_directory(${test_name} BINARY_DIR ${outdir} LIBRARY_DIR ${outdir})
# libpthreads overrides some standard library symbols, so main
# executable must be linked with it in order to provide consistent
# API for all shared libaries loaded by this executable.
target_link_libraries(${test_name} PRIVATE llvm_gtest_main llvm_gtest ${LLVM_PTHREAD_LIB})
# default_gtest should be an alias to either llvm_gtest or runtimes_gtest.
# If it is not defined, fall back to llvm_gtest.
if(TARGET default_gtest)
target_link_libraries(${test_name} PRIVATE default_gtest_main default_gtest ${LLVM_PTHREAD_LIB})
else ()
target_link_libraries(${test_name} PRIVATE llvm_gtest_main llvm_gtest ${LLVM_PTHREAD_LIB})
endif ()
add_dependencies(${test_suite} ${test_name})
endfunction()
@@ -2043,6 +2121,7 @@ function(add_lit_target target comment)
# Tests should be excluded from "Build Solution".
set_target_properties(${target} PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD ON)
set_target_properties(${target} PROPERTIES XCODE_GENERATE_SCHEME ON)
endfunction()
# Convert a target name like check-clang to a variable name like CLANG.
@@ -2114,7 +2193,12 @@ endfunction()
function(add_lit_testsuites project directory)
if (NOT LLVM_ENABLE_IDE)
cmake_parse_arguments(ARG "EXCLUDE_FROM_CHECK_ALL" "FOLDER" "PARAMS;DEPENDS;ARGS" ${ARGN})
cmake_parse_arguments(ARG
"EXCLUDE_FROM_CHECK_ALL"
"FOLDER;BINARY_DIR"
"PARAMS;DEPENDS;ARGS;SKIP"
${ARGN}
)
if (NOT ARG_FOLDER)
get_subproject_title(subproject_title)
@@ -2135,13 +2219,28 @@ function(add_lit_testsuites project directory)
endif()
# Create a check- target for the directory.
string(REPLACE ${directory} "" name_slash ${lit_suite})
string(REPLACE "${directory}/" "" name_slash ${lit_suite})
set(_should_skip FALSE)
foreach(skip IN LISTS ARG_SKIP)
if(name_slash MATCHES "${skip}")
set(_should_skip TRUE)
break()
endif()
endforeach()
if (_should_skip)
continue()
endif()
if (name_slash)
set(filter ${name_slash})
string(REPLACE "/" "-" name_slash ${name_slash})
string(REPLACE "\\" "-" name_dashes ${name_slash})
string(TOLOWER "${project}${name_dashes}" name_var)
string(TOLOWER "${project}-${name_dashes}" name_var)
set(lit_args ${lit_suite})
if (ARG_BINARY_DIR)
set(lit_args ${ARG_BINARY_DIR} --filter=${filter})
endif()
add_lit_target("check-${name_var}" "Running lit suite ${lit_suite}"
${lit_suite}
${lit_args}
${EXCLUDE_FROM_CHECK_ALL}
PARAMS ${ARG_PARAMS}
DEPENDS ${ARG_DEPENDS}
@@ -2181,7 +2280,7 @@ function(llvm_install_library_symlink name dest type)
endif()
set(output_dir lib${LLVM_LIBDIR_SUFFIX})
if(WIN32 AND "${type}" STREQUAL "SHARED")
if((WIN32 OR CYGWIN) AND "${type}" STREQUAL "SHARED")
set(output_dir "${CMAKE_INSTALL_BINDIR}")
endif()
@@ -2457,7 +2556,7 @@ function(llvm_setup_rpath name)
if (APPLE)
set(_install_name_dir INSTALL_NAME_DIR "@rpath")
set(_install_rpath "@loader_path/../lib${LLVM_LIBDIR_SUFFIX}" ${extra_libdir})
elseif(${CMAKE_SYSTEM_NAME} MATCHES "AIX" AND BUILD_SHARED_LIBS)
elseif("${CMAKE_SYSTEM_NAME}" MATCHES "AIX" AND BUILD_SHARED_LIBS)
# $ORIGIN is not interpreted at link time by aix ld.
# Since BUILD_SHARED_LIBS is only recommended for use by developers,
# hardcode the rpath to build/install lib dir first in this mode.
@@ -2466,7 +2565,7 @@ function(llvm_setup_rpath name)
elseif(UNIX)
set(_build_rpath "\$ORIGIN/../lib${LLVM_LIBDIR_SUFFIX}" ${extra_libdir})
set(_install_rpath "\$ORIGIN/../lib${LLVM_LIBDIR_SUFFIX}")
if(${CMAKE_SYSTEM_NAME} MATCHES "(FreeBSD|DragonFly)")
if("${CMAKE_SYSTEM_NAME}" MATCHES "(FreeBSD|DragonFly)")
set_property(TARGET ${name} APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,-z,origin ")
endif()
@@ -2484,7 +2583,7 @@ function(llvm_setup_rpath name)
# On AIX, the tool chain doesn't support modifying rpaths/libpaths for XCOFF
# on install at the moment, so BUILD_WITH_INSTALL_RPATH is required.
if("${CMAKE_BUILD_RPATH}" STREQUAL "")
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin|AIX")
if("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin|AIX")
set_property(TARGET ${name} PROPERTY BUILD_WITH_INSTALL_RPATH ON)
else()
set_property(TARGET ${name} APPEND PROPERTY BUILD_RPATH "${_build_rpath}")
@@ -2566,13 +2665,16 @@ function(get_host_tool_path tool_name setting_name exe_var_name target_var_name)
set(target_name "")
elseif(LLVM_USE_HOST_TOOLS)
get_native_tool_path(${tool_name} exe_name)
set(target_name ${exe_name})
set(target_name host_${tool_name})
else()
set(exe_name $<TARGET_FILE:${tool_name}>)
set(target_name ${tool_name})
endif()
set(${exe_var_name} "${exe_name}" CACHE STRING "")
set(${target_var_name} "${target_name}" CACHE STRING "")
# Force setting the cache variable because they are only used for being
# global in scope. Using regular variables would require careful audit of the
# code with several parent scope set commands.
set(${exe_var_name} "${exe_name}" CACHE STRING "" FORCE)
set(${target_var_name} "${target_name}" CACHE STRING "" FORCE)
endfunction()
function(setup_host_tool tool_name setting_name exe_var_name target_var_name)
@@ -2580,8 +2682,8 @@ function(setup_host_tool tool_name setting_name exe_var_name target_var_name)
# Set up a native tool build if necessary
if(LLVM_USE_HOST_TOOLS AND NOT ${setting_name})
build_native_tool(${tool_name} exe_name DEPENDS ${tool_name})
add_custom_target(${target_var_name} DEPENDS ${exe_name})
add_custom_target(${${target_var_name}} DEPENDS ${exe_name})
get_subproject_title(subproject_title)
set_target_properties(${target_var_name} PROPERTIES FOLDER "${subproject_title}/Native")
set_target_properties(${${target_var_name}} PROPERTIES FOLDER "${subproject_title}/Native")
endif()
endfunction()
+7 -2
View File
@@ -57,9 +57,12 @@ function(add_ocaml_library name)
"-ccopt" "-Wl,-rpath,\\$CAMLORIGIN/../.."
${ocaml_pkgs})
set(ocaml_dep_inputs)
foreach( ocaml_dep ${ARG_OCAMLDEP} )
get_target_property(dep_ocaml_flags "ocaml_${ocaml_dep}" OCAML_FLAGS)
list(APPEND ocaml_flags ${dep_ocaml_flags})
get_target_property(dep_ocaml_outputs "ocaml_${ocaml_dep}" OCAML_OUTPUTS)
list(APPEND ocaml_dep_inputs ${dep_ocaml_outputs})
endforeach()
if( NOT BUILD_SHARED_LIBS )
@@ -157,7 +160,7 @@ function(add_ocaml_library name)
OUTPUT ${ocaml_outputs}
COMMAND "${OCAMLFIND}" "ocamlmklib" "-ocamlcflags" "-bin-annot"
"-o" "${name}" ${ocaml_flags} ${ocaml_params}
DEPENDS ${ocaml_inputs} ${c_outputs}
DEPENDS ${ocaml_inputs} ${ocaml_dep_inputs} ${c_outputs}
COMMENT "Building OCaml library ${name}"
VERBATIM)
@@ -168,7 +171,7 @@ function(add_ocaml_library name)
"-I" "${LLVM_LIBRARY_DIR}/ocaml/llvm/"
"-dump" "${bin}/${name}.odoc"
${ocaml_pkgs} ${ocaml_inputs}
DEPENDS ${ocaml_inputs} ${ocaml_outputs}
DEPENDS ${ocaml_inputs} ${ocaml_dep_inputs} ${ocaml_outputs}
COMMENT "Building OCaml documentation for ${name}"
VERBATIM)
@@ -180,6 +183,8 @@ function(add_ocaml_library name)
OCAML_FLAGS "-I;${bin}")
set_target_properties("ocaml_${name}" PROPERTIES
OCAML_ODOC "${bin}/${name}.odoc")
set_target_properties("ocaml_${name}" PROPERTIES
OCAML_OUTPUTS "${ocaml_outputs}")
foreach( ocaml_dep ${ARG_OCAMLDEP} )
add_dependencies("ocaml_${name}" "ocaml_${ocaml_dep}")
@@ -36,6 +36,9 @@ endif()
if(omp_gen IN_LIST LLVM_COMMON_DEPENDS)
list(REMOVE_ITEM LLVM_COMMON_DEPENDS omp_gen)
endif()
if(vt_gen IN_LIST LLVM_COMMON_DEPENDS)
list(REMOVE_ITEM LLVM_COMMON_DEPENDS vt_gen)
endif()
#
# Generate LLVMConfig.cmake for the build tree.
@@ -12,9 +12,9 @@ set(APPLECLANG_MIN 10.0)
set(APPLECLANG_SOFT_ERROR 10.0)
# https://en.wikipedia.org/wiki/Microsoft_Visual_C#Internal_version_numbering
# _MSC_VER == 1927 MSVC++ 14.27 Visual Studio 2019 Version 16.7
set(MSVC_MIN 19.27)
set(MSVC_SOFT_ERROR 19.27)
# _MSC_VER == 1928 MSVC++ 19.27 Visual Studio 2019 Version 16.8 + 16.9
set(MSVC_MIN 19.28)
set(MSVC_SOFT_ERROR 19.28)
set(LIBSTDCXX_MIN 7)
set(LIBSTDCXX_SOFT_ERROR 7)
@@ -11,7 +11,7 @@ endmacro()
# MSVC and /arch:AVX is untested and have created problems before. See:
# https://github.com/llvm/llvm-project/issues/54645
if(${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC)
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
string(TOLOWER "${CMAKE_CXX_FLAGS} ${CMAKE_C_FLAGS}" _FLAGS)
if(_FLAGS MATCHES "/arch:avx[0-9]*")
log_problematic("Compiling LLVM with MSVC and the /arch:AVX flag is known to cause issues with parts of LLVM.\nSee https://github.com/llvm/llvm-project/issues/54645 for details.\nUse clang-cl if you want to enable AVX instructions.")
+22 -7
View File
@@ -12,6 +12,14 @@ function(llvm_create_cross_target project_name target_name toolchain buildtype)
message(STATUS "Setting native build dir to " ${${project_name}_${target_name}_BUILD})
endif(NOT DEFINED ${project_name}_${target_name}_BUILD)
if(NOT DEFINED ${project_name}_${target_name}_STAMP)
set(${project_name}_${target_name}_STAMP
"${CMAKE_CURRENT_BINARY_DIR}/${target_name}-stamps")
set(${project_name}_${target_name}_STAMP
${${project_name}_${target_name}_STAMP} PARENT_SCOPE)
message(STATUS "Setting native stamp dir to " ${${project_name}_${target_name}_STAMP})
endif(NOT DEFINED ${project_name}_${target_name}_STAMP)
if (EXISTS ${LLVM_MAIN_SRC_DIR}/cmake/platforms/${toolchain}.cmake)
set(CROSS_TOOLCHAIN_FLAGS_INIT
-DCMAKE_TOOLCHAIN_FILE=\"${LLVM_MAIN_SRC_DIR}/cmake/platforms/${toolchain}.cmake\")
@@ -61,6 +69,8 @@ function(llvm_create_cross_target project_name target_name toolchain buildtype)
"${LLVM_EXTERNAL_PROJECTS}")
string(REPLACE ";" "$<SEMICOLON>" llvm_enable_runtimes_arg
"${LLVM_ENABLE_RUNTIMES}")
string(REPLACE ";" "$<SEMICOLON>" llvm_tablegen_flags
"${LLVM_TABLEGEN_FLAGS}")
set(external_project_source_dirs)
foreach(project ${LLVM_EXTERNAL_PROJECTS})
@@ -69,15 +79,15 @@ function(llvm_create_cross_target project_name target_name toolchain buildtype)
"-DLLVM_EXTERNAL_${name}_SOURCE_DIR=${LLVM_EXTERNAL_${name}_SOURCE_DIR}")
endforeach()
if("libc" IN_LIST LLVM_ENABLE_PROJECTS AND NOT LIBC_HDRGEN_EXE)
set(libc_flags -DLLVM_LIBC_FULL_BUILD=ON -DLIBC_HDRGEN_ONLY=ON)
if(LLVM_LIBC_GPU_BUILD)
set(libc_flags -DLLVM_LIBC_GPU_BUILD=ON)
endif()
add_custom_command(OUTPUT ${${project_name}_${target_name}_BUILD}/CMakeCache.txt
COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}"
-DCMAKE_MAKE_PROGRAM="${CMAKE_MAKE_PROGRAM}"
-DCMAKE_C_COMPILER_LAUNCHER="${CMAKE_C_COMPILER_LAUNCHER}"
-DCMAKE_CXX_COMPILER_LAUNCHER="${CMAKE_CXX_COMPILER_LAUNCHER}"
"-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}"
"-DCMAKE_C_COMPILER_LAUNCHER=${CMAKE_C_COMPILER_LAUNCHER}"
"-DCMAKE_CXX_COMPILER_LAUNCHER=${CMAKE_CXX_COMPILER_LAUNCHER}"
${CROSS_TOOLCHAIN_FLAGS_${target_name}} ${CMAKE_CURRENT_SOURCE_DIR}
${CROSS_TOOLCHAIN_FLAGS_${project_name}_${target_name}}
-DLLVM_TARGET_IS_CROSSCOMPILE_HOST=TRUE
@@ -92,6 +102,8 @@ function(llvm_create_cross_target project_name target_name toolchain buildtype)
-DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN="${LLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN}"
-DLLVM_INCLUDE_BENCHMARKS=OFF
-DLLVM_INCLUDE_TESTS=OFF
-DLLVM_TABLEGEN_FLAGS="${llvm_tablegen_flags}"
-DPYTHON_EXECUTABLE="${PYTHON_EXECUTABLE}"
${build_type_flags} ${linker_flag} ${external_clang_dir} ${libc_flags}
${ARGN}
WORKING_DIRECTORY ${${project_name}_${target_name}_BUILD}
@@ -130,13 +142,16 @@ function(build_native_tool target output_path_var)
set_property(GLOBAL APPEND PROPERTY ${PROJECT_NAME}_HOST_TARGETS ${output_path})
endif()
llvm_ExternalProject_BuildCmd(build_cmd ${target} ${${PROJECT_NAME}_NATIVE_BUILD}
llvm_ExternalProject_BuildCmd(build_cmd ${target}
${${PROJECT_NAME}_NATIVE_BUILD}
${${PROJECT_NAME}_NATIVE_STAMP}
CONFIGURATION Release)
add_custom_command(OUTPUT "${output_path}"
COMMAND ${build_cmd}
DEPENDS CONFIGURE_${PROJECT_NAME}_NATIVE ${ARG_DEPENDS} ${host_targets}
WORKING_DIRECTORY "${${PROJECT_NAME}_NATIVE_BUILD}"
COMMENT "Building native ${target}..."
USES_TERMINAL)
USES_TERMINAL
VERBATIM)
set(${output_path_var} "${output_path}" PARENT_SCOPE)
endfunction()
@@ -0,0 +1,9 @@
# CMake script that synchronizes process execution on a given file lock.
#
# Input variables:
# LOCK_FILE_PATH - The file to be locked for the scope of the process of this cmake script.
# COMMAND - The command to be executed.
file(LOCK ${LOCK_FILE_PATH})
string(REPLACE "@" ";" command_args ${COMMAND})
execute_process(COMMAND ${command_args} COMMAND_ERROR_IS_FATAL ANY)
+6 -3
View File
@@ -23,7 +23,10 @@
# Additionally, the following import target will be defined:
# FFI::ffi
find_path(FFI_INCLUDE_DIRS ffi.h PATHS ${FFI_INCLUDE_DIR})
find_package(PkgConfig QUIET)
pkg_check_modules(PC_LIBFFI QUIET libffi)
find_path(FFI_INCLUDE_DIRS ffi.h PATHS ${FFI_INCLUDE_DIR} ${PC_LIBFFI_INCLUDE_DIRS})
if( EXISTS "${FFI_INCLUDE_DIRS}/ffi.h" )
set(FFI_HEADER ffi.h CACHE INTERNAL "")
set(HAVE_FFI_H 1 CACHE INTERNAL "")
@@ -35,8 +38,8 @@ else()
endif()
endif()
find_library(FFI_LIBRARIES NAMES ffi PATHS ${FFI_LIBRARY_DIR})
find_library(FFI_STATIC_LIBRARIES NAMES libffi.a PATHS ${FFI_LIBRARY_DIR})
find_library(FFI_LIBRARIES NAMES ffi PATHS ${FFI_LIBRARY_DIR} ${PC_LIBFFI_LIBRARY_DIRS})
find_library(FFI_STATIC_LIBRARIES NAMES libffi.a PATHS ${FFI_LIBRARY_DIR} ${PC_LIBFFI_LIBRARY_DIRS})
if(FFI_LIBRARIES)
include(CMakePushCheckState)
+2 -2
View File
@@ -29,11 +29,11 @@ find_package_handle_standard_args(
)
if(zstd_FOUND)
if(zstd_LIBRARY MATCHES "${zstd_STATIC_LIBRARY_SUFFIX}$")
if(zstd_LIBRARY MATCHES "${zstd_STATIC_LIBRARY_SUFFIX}$" AND NOT zstd_LIBRARY MATCHES "\\.dll\\.a$")
set(zstd_STATIC_LIBRARY "${zstd_LIBRARY}")
elseif (NOT TARGET zstd::libzstd_shared)
add_library(zstd::libzstd_shared SHARED IMPORTED)
if(MSVC OR "${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC")
if(WIN32 OR CYGWIN)
include(GNUInstallDirs) # For CMAKE_INSTALL_LIBDIR and friends.
# IMPORTED_LOCATION is the path to the DLL and IMPORTED_IMPLIB is the "library".
get_filename_component(zstd_DIRNAME "${zstd_LIBRARY}" DIRECTORY)
@@ -2,7 +2,7 @@
# Invokes config.guess
function( get_host_triple var )
if( MSVC )
if( MSVC OR CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC")
if( CMAKE_C_COMPILER_ARCHITECTURE_ID MATCHES "ARM64.*" )
set( value "aarch64-pc-windows-msvc" )
elseif( CMAKE_C_COMPILER_ARCHITECTURE_ID MATCHES "ARM.*" )
@@ -34,14 +34,14 @@ function( get_host_triple var )
endif()
elseif( CMAKE_SYSTEM_NAME MATCHES "OS390" )
set( value "s390x-ibm-zos" )
elseif( CMAKE_SYSTEM_NAME STREQUAL AIX )
elseif( CMAKE_SYSTEM_NAME STREQUAL "AIX" )
# We defer to dynamic detection of the host AIX version.
if( CMAKE_SIZEOF_VOID_P EQUAL 8 )
set( value "powerpc64-ibm-aix" )
else()
set( value "powerpc-ibm-aix" )
endif()
else( MSVC )
else()
if(CMAKE_HOST_SYSTEM_NAME STREQUAL Windows AND NOT MSYS)
message(WARNING "unable to determine host target triple")
else()
@@ -55,6 +55,6 @@ function( get_host_triple var )
endif( NOT TT_RV EQUAL 0 )
set( value ${TT_OUT} )
endif()
endif( MSVC )
endif()
set( ${var} ${value} PARENT_SCOPE )
endfunction( get_host_triple var )
@@ -144,12 +144,6 @@ if( LLVM_ENABLE_ASSERTIONS )
endif()
endif()
# If we are targeting a GPU architecture in a runtimes build we want to ignore
# all the standard flag handling.
if(LLVM_RUNTIMES_GPU_BUILD)
return()
endif()
if(LLVM_ENABLE_EXPENSIVE_CHECKS)
# When LLVM_ENABLE_EXPENSIVE_CHECKS is ON, LLVM will intercept errors
# using assert(). An explicit check is performed here.
@@ -175,8 +169,30 @@ if(LLVM_ENABLE_EXPENSIVE_CHECKS)
endif()
endif()
if (LLVM_ENABLE_STRICT_FIXED_SIZE_VECTORS)
add_compile_definitions(STRICT_FIXED_SIZE_VECTORS)
CHECK_CXX_SOURCE_COMPILES("
#include <iosfwd>
#if !defined(__GLIBCXX__)
#error Not libstdc++
#endif
int main() { return 0; }
" LLVM_USES_LIBSTDCXX)
CHECK_CXX_SOURCE_COMPILES("
#include <string>
#if _GLIBCXX_USE_CXX11_ABI == 0
#error _GLIBCXX_USE_CXX11_ABI not active
#endif
int main() { return 0; }
" LLVM_DEFAULT_TO_GLIBCXX_USE_CXX11_ABI)
option(GLIBCXX_USE_CXX11_ABI "Use new libstdc++ CXX11 ABI" ${LLVM_DEFAULT_TO_GLIBCXX_USE_CXX11_ABI})
if (LLVM_USES_LIBSTDCXX)
if (GLIBCXX_USE_CXX11_ABI)
add_compile_definitions(_GLIBCXX_USE_CXX11_ABI=1)
else()
add_compile_definitions(_GLIBCXX_USE_CXX11_ABI=0)
endif()
endif()
string(TOUPPER "${LLVM_ABI_BREAKING_CHECKS}" uppercase_LLVM_ABI_BREAKING_CHECKS)
@@ -196,29 +212,37 @@ else()
message(FATAL_ERROR "Unknown value for LLVM_ABI_BREAKING_CHECKS: \"${LLVM_ABI_BREAKING_CHECKS}\"!")
endif()
string(TOUPPER "${LLVM_ENABLE_DEBUGLOC_COVERAGE_TRACKING}" uppercase_LLVM_ENABLE_DEBUGLOC_COVERAGE_TRACKING)
if( uppercase_LLVM_ENABLE_DEBUGLOC_COVERAGE_TRACKING STREQUAL "COVERAGE" )
set( LLVM_ENABLE_DEBUGLOC_TRACKING_COVERAGE 1 )
elseif( uppercase_LLVM_ENABLE_DEBUGLOC_COVERAGE_TRACKING STREQUAL "COVERAGE_AND_ORIGIN" )
set( LLVM_ENABLE_DEBUGLOC_TRACKING_COVERAGE 1 )
set( LLVM_ENABLE_DEBUGLOC_TRACKING_ORIGIN 1 )
elseif( uppercase_LLVM_ENABLE_DEBUGLOC_COVERAGE_TRACKING STREQUAL "DISABLED" OR NOT DEFINED LLVM_ENABLE_DEBUGLOC_COVERAGE_TRACKING )
# The DISABLED setting is default.
set( LLVM_ENABLE_DEBUGLOC_TRACKING_COVERAGE 0 )
else()
message(FATAL_ERROR "Unknown value for LLVM_ENABLE_DEBUGLOC_COVERAGE_TRACKING: \"${LLVM_ENABLE_DEBUGLOC_COVERAGE_TRACKING}\"!")
endif()
# LLVM_ENABLE_DEBUGLOC_TRACKING_COVERAGE (non-cached) is expected to be
# 1 or 0 here, assuming referenced in #cmakedefine01.
if( LLVM_REVERSE_ITERATION )
set( LLVM_ENABLE_REVERSE_ITERATION 1 )
endif()
if(WIN32)
set(LLVM_HAVE_LINK_VERSION_SCRIPT 0)
if(CYGWIN)
set(LLVM_ON_WIN32 0)
set(LLVM_ON_UNIX 1)
else(CYGWIN)
set(LLVM_ON_WIN32 1)
set(LLVM_ON_UNIX 0)
endif(CYGWIN)
elseif(FUCHSIA OR UNIX)
set(LLVM_ON_WIN32 0)
set(LLVM_ON_UNIX 0)
elseif(FUCHSIA OR UNIX OR CYGWIN)
set(LLVM_ON_UNIX 1)
if(APPLE OR ${CMAKE_SYSTEM_NAME} MATCHES "AIX")
if(APPLE OR CYGWIN OR "${CMAKE_SYSTEM_NAME}" MATCHES "AIX")
set(LLVM_HAVE_LINK_VERSION_SCRIPT 0)
else()
set(LLVM_HAVE_LINK_VERSION_SCRIPT 1)
endif()
elseif(CMAKE_SYSTEM_NAME STREQUAL "Generic")
set(LLVM_ON_WIN32 0)
set(LLVM_ON_UNIX 0)
set(LLVM_HAVE_LINK_VERSION_SCRIPT 0)
else()
@@ -233,7 +257,7 @@ set(EXEEXT ${CMAKE_EXECUTABLE_SUFFIX})
set(LTDL_SHLIB_EXT ${CMAKE_SHARED_LIBRARY_SUFFIX})
# We use *.dylib rather than *.so on darwin, but we stick with *.so on AIX.
if(${CMAKE_SYSTEM_NAME} MATCHES "AIX")
if("${CMAKE_SYSTEM_NAME}" MATCHES "AIX")
set(LLVM_PLUGIN_EXT ${CMAKE_SHARED_MODULE_SUFFIX})
else()
set(LLVM_PLUGIN_EXT ${CMAKE_SHARED_LIBRARY_SUFFIX})
@@ -241,10 +265,10 @@ endif()
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")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,-flat_namespace -Wl,-undefined -Wl,dynamic_lookup")
endif()
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
if("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
# RHEL7 has ar and ranlib being non-deterministic by default. The D flag forces determinism,
# however only GNU version of ar and ranlib (2.27) have this option.
# RHEL DTS7 is also affected by this, which uses GNU binutils 2.28
@@ -276,7 +300,7 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
endif()
endif()
if(${CMAKE_SYSTEM_NAME} MATCHES "AIX")
if("${CMAKE_SYSTEM_NAME}" MATCHES "AIX")
# -fPIC does not enable the large code model for GCC on AIX but does for XL.
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
append("-mcmodel=large" CMAKE_CXX_FLAGS CMAKE_C_FLAGS)
@@ -302,7 +326,7 @@ endif()
# Pass -Wl,-z,defs. This makes sure all symbols are defined. Otherwise a DSO
# build might work on ELF but fail on MachO/COFF.
if(NOT (CMAKE_SYSTEM_NAME MATCHES "Darwin|FreeBSD|OpenBSD|DragonFly|AIX|OS390" OR
if(NOT (CMAKE_SYSTEM_NAME MATCHES "Darwin|FreeBSD|OpenBSD|DragonFly|AIX|OS390|Emscripten" OR
WIN32 OR CYGWIN) AND
NOT LLVM_USE_SANITIZER)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,defs")
@@ -312,7 +336,7 @@ endif()
# by dlclose(). We need that since the CLI API relies on cross-references
# between global objects which became horribly broken when one of the libraries
# is unloaded.
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
if("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,nodelete")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,-z,nodelete")
endif()
@@ -324,6 +348,12 @@ function(append value)
endforeach(variable)
endfunction()
function(prepend value)
foreach(variable ${ARGN})
set(${variable} "${value} ${${variable}}" PARENT_SCOPE)
endforeach(variable)
endfunction()
function(append_if condition value)
if (${condition})
foreach(variable ${ARGN})
@@ -412,13 +442,16 @@ if( LLVM_ENABLE_PIC )
# Enable interprocedural optimizations for non-inline functions which would
# otherwise be disabled due to GCC -fPIC's default.
# Note: GCC<10.3 has a bug on SystemZ.
#
# Note: Default on AIX is "no semantic interposition".
# Note: Clang allows IPO for -fPIC so this optimization is less effective.
# Clang 13 has a bug related to -fsanitize-coverage
# -fno-semantic-interposition (https://reviews.llvm.org/D117183).
if ((CMAKE_COMPILER_IS_GNUCXX AND
NOT (LLVM_NATIVE_ARCH STREQUAL "SystemZ" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 10.3))
OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND CMAKE_CXX_COMPILER_VERSION GREATER_EQUAL 14))
if ((NOT ("${CMAKE_SYSTEM_NAME}" MATCHES "AIX"))
AND ((CMAKE_COMPILER_IS_GNUCXX AND
NOT (LLVM_NATIVE_ARCH STREQUAL "SystemZ"
AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 10.3))
OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang"
AND CMAKE_CXX_COMPILER_VERSION GREATER_EQUAL 14)))
add_flag_if_supported("-fno-semantic-interposition" FNO_SEMANTIC_INTERPOSITION)
endif()
endif()
@@ -432,14 +465,14 @@ if( LLVM_ENABLE_PIC )
# to SEGV (GCC PR target/96607).
# clang with -O3 -fPIC generates code that SEGVs.
# Both can be worked around by compiling with -O instead.
if(${CMAKE_SYSTEM_NAME} STREQUAL "SunOS" AND LLVM_NATIVE_ARCH STREQUAL "Sparc")
if("${CMAKE_SYSTEM_NAME}" STREQUAL "SunOS" AND LLVM_NATIVE_ARCH STREQUAL "Sparc")
llvm_replace_compiler_option(CMAKE_CXX_FLAGS_RELEASE "-O[23]" "-O")
llvm_replace_compiler_option(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O[23]" "-O")
endif()
endif()
if((NOT (${CMAKE_SYSTEM_NAME} MATCHES "AIX")) AND
(NOT (WIN32 OR CYGWIN) OR (MINGW AND CMAKE_CXX_COMPILER_ID MATCHES "Clang")))
if((NOT ("${CMAKE_SYSTEM_NAME}" MATCHES "AIX")) AND
(NOT (WIN32 OR CYGWIN) OR ((MINGW OR CYGWIN) AND CMAKE_CXX_COMPILER_ID MATCHES "Clang")))
# GCC for MinGW does nothing about -fvisibility-inlines-hidden, but warns
# about use of the attributes. As long as we don't use the attributes (to
# override the default) we shouldn't set the command line options either.
@@ -526,7 +559,7 @@ if(MSVC)
# behavior was changed in CMake 2.8.11 (Issue 12437) to use the MSVC default
# value (1 MB) which is not enough for us in tasks such as parsing recursive
# C++ templates in Clang.
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /STACK:10000000")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_CXX_LINKER_WRAPPER_FLAG}/STACK:10000000")
elseif(MINGW OR CYGWIN)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--stack,16777216")
@@ -575,7 +608,7 @@ if( MSVC )
append("/Zc:inline" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
if (NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# Enable standards-conforming preprocessor.
# https://learn.microsoft.com/en-us/cpp/build/reference/zc-preprocessor
append("/Zc:preprocessor" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
@@ -672,21 +705,11 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
append("-Werror=unguarded-availability-new" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
endif()
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# LLVM data structures like llvm::User and llvm::MDNode rely on
# the value of object storage persisting beyond the lifetime of the
# object (#24952). This is not standard compliant and causes a runtime
# crash if LLVM is built with GCC and LTO enabled (#57740). Until
# these bugs are fixed, we need to disable dead store eliminations
# based on object lifetime.
append("-fno-lifetime-dse" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
endif ()
# Modules enablement for GCC-compatible compilers:
if ( LLVM_COMPILER_IS_GCC_COMPATIBLE AND LLVM_ENABLE_MODULES )
set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
set(module_flags "-fmodules -fmodules-cache-path=${PROJECT_BINARY_DIR}/module.cache")
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
if ("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin")
# On Darwin -fmodules does not imply -fcxx-modules.
set(module_flags "${module_flags} -fcxx-modules")
endif()
@@ -754,6 +777,12 @@ if (MSVC)
# any code that uses the LLVM_ALIGNAS macro), so this is must be disabled to
# avoid unwanted alignment warnings.
-wd4324 # Suppress 'structure was padded due to __declspec(align())'
# This is triggered for every variable that is a template type of a class even
# if there private when the class is dllexport'ed
-wd4251 # Suppress 'needs to have dll-interface to be used by clients'
# We only putting dll export on classes with out of line members so this
# warning gets triggered a lot for bases we haven't exported'
-wd4275 # non dll-interface class used as base for dll-interface class
# Promoted warnings.
-w14062 # Promote 'enumerator in switch of enum is not handled' to level 1 warning.
@@ -826,31 +855,45 @@ if (LLVM_ENABLE_WARNINGS AND (LLVM_COMPILER_IS_GCC_COMPATIBLE OR CLANG_CL))
append_if(USE_NO_UNINITIALIZED "-Wno-uninitialized" CMAKE_CXX_FLAGS)
append_if(USE_NO_MAYBE_UNINITIALIZED "-Wno-maybe-uninitialized" CMAKE_CXX_FLAGS)
# Disable -Wnonnull for GCC warning as it is emitting a lot of false positives.
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# Disable -Wnonnull for GCC warning as it is emitting a lot of false positives.
append("-Wno-nonnull" CMAKE_CXX_FLAGS)
endif()
# Disable -Wclass-memaccess, a C++-only warning from GCC 8 that fires on
# LLVM's ADT classes.
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# Disable -Wclass-memaccess, a C++-only warning from GCC 8 that fires on
# LLVM's ADT classes.
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.1)
append("-Wno-class-memaccess" CMAKE_CXX_FLAGS)
endif()
endif()
# Disable -Wredundant-move and -Wpessimizing-move on GCC>=9. GCC wants to
# remove std::move in code like
# "A foo(ConvertibleToA a) { return std::move(a); }",
# but this code does not compile (or uses the copy
# constructor instead) on clang<=3.8. Clang also has a -Wredundant-move and
# -Wpessimizing-move, but they only fire when the types match exactly, so we
# can keep them here.
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# Disable -Wdangling-reference, a C++-only warning from GCC 13 that seems
# to produce a large number of false positives.
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 13.1)
append("-Wno-dangling-reference" CMAKE_CXX_FLAGS)
endif()
# Disable -Wredundant-move and -Wpessimizing-move on GCC>=9. GCC wants to
# remove std::move in code like
# "A foo(ConvertibleToA a) { return std::move(a); }",
# but this code does not compile (or uses the copy
# constructor instead) on clang<=3.8. Clang also has a -Wredundant-move and
# -Wpessimizing-move, but they only fire when the types match exactly, so we
# can keep them here.
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 9.1)
append("-Wno-redundant-move" CMAKE_CXX_FLAGS)
append("-Wno-pessimizing-move" CMAKE_CXX_FLAGS)
endif()
# Disable -Warray-bounds on GCC; this warning exists since a very long time,
# but since GCC 11, it produces a lot of very noisy, seemingly false positive
# warnings (potentially originating in libstdc++).
append("-Wno-array-bounds" CMAKE_CXX_FLAGS)
# Disable -Wstringop-overread on GCC; this warning produces a number of very
# noisy diagnostics when -Warray-bounds is disabled above; this option exists
# since GCC 11.
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 11.1)
append("-Wno-stringop-overread" CMAKE_CXX_FLAGS)
endif()
endif()
# The LLVM libraries have no stable C++ API, so -Wnoexcept-type is not useful.
@@ -890,6 +933,15 @@ if (LLVM_ENABLE_WARNINGS AND (LLVM_COMPILER_IS_GCC_COMPATIBLE OR CLANG_CL))
# Enable -Wstring-conversion to catch misuse of string literals.
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
append("-Wstring-conversion" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
# Disable -Wno-pass-failed flag, which reports failure to perform
# optimizations suggested by pragmas. This warning is not relevant for LLVM
# projects and may be injected by pragmas in libstdc++.
# FIXME: Reconsider this choice if warnings from STL headers can be reliably
# avoided (https://github.com/llvm/llvm-project/issues/157666).
# This option has been available since Clang 3.5, and we do require a newer
# version.
append("-Wno-pass-failed" CMAKE_CXX_FLAGS)
endif()
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
@@ -1006,13 +1058,14 @@ if(LLVM_USE_SANITIZER)
# lld string tail merging interacts badly with ASAN on Windows, turn it off here
# See https://github.com/llvm/llvm-project/issues/62078
append("/opt:nolldtailmerge" CMAKE_EXE_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS)
# Static and dynamic C runtimes all load ASAN as a DLL
# See https://devblogs.microsoft.com/cppblog/msvc-address-sanitizer-one-dll-for-all-runtime-configurations/
append("clang_rt.asan_dynamic-${arch}.lib" CMAKE_EXE_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS)
if (${CMAKE_MSVC_RUNTIME_LIBRARY} MATCHES "^(MultiThreaded|MultiThreadedDebug)$")
append("/wholearchive:clang_rt.asan-${arch}.lib /wholearchive:clang_rt.asan_cxx-${arch}.lib"
CMAKE_EXE_LINKER_FLAGS)
append("/wholearchive:clang_rt.asan_dll_thunk-${arch}.lib"
CMAKE_MODULE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS)
append("/wholearchive:clang_rt.asan_static_runtime_thunk-${arch}.lib"
CMAKE_EXE_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS)
else()
append("clang_rt.asan_dynamic-${arch}.lib /wholearchive:clang_rt.asan_dynamic_runtime_thunk-${arch}.lib"
append("/wholearchive:clang_rt.asan_dynamic_runtime_thunk-${arch}.lib"
CMAKE_EXE_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS)
endif()
endif()
@@ -1061,8 +1114,8 @@ if (LLVM_USE_SPLIT_DWARF AND
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR
CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-gsplit-dwarf>)
include(LLVMCheckLinkerFlag)
llvm_check_linker_flag(CXX "-Wl,--gdb-index" LINKER_SUPPORTS_GDB_INDEX)
include(CheckLinkerFlag)
check_linker_flag(CXX "-Wl,--gdb-index" LINKER_SUPPORTS_GDB_INDEX)
append_if(LINKER_SUPPORTS_GDB_INDEX "-Wl,--gdb-index"
CMAKE_EXE_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS)
endif()
@@ -1082,9 +1135,9 @@ if (UNIX AND
endif()
# lld doesn't print colored diagnostics when invoked from Ninja
if (UNIX AND CMAKE_GENERATOR MATCHES "Ninja")
include(LLVMCheckLinkerFlag)
llvm_check_linker_flag(CXX "-Wl,--color-diagnostics" LINKER_SUPPORTS_COLOR_DIAGNOSTICS)
if (UNIX AND CMAKE_GENERATOR MATCHES "Ninja" AND NOT "${LLVM_RUNTIMES_TARGET}" MATCHES "^nvptx64")
include(CheckLinkerFlag)
check_linker_flag(CXX "-Wl,--color-diagnostics" LINKER_SUPPORTS_COLOR_DIAGNOSTICS)
append_if(LINKER_SUPPORTS_COLOR_DIAGNOSTICS "-Wl,--color-diagnostics"
CMAKE_EXE_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS)
endif()
@@ -1094,7 +1147,7 @@ endif()
# 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 MSVC)
if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND
if(NOT "${CMAKE_SYSTEM_NAME}" MATCHES "Darwin" AND
NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG")
if (CMAKE_CXX_COMPILER_ID MATCHES "XL")
append("-qfuncsect" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
@@ -1112,8 +1165,8 @@ 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-".
# them (see llvm_update_compile_flags).
# CL.EXE complains to override flags like "/GR /GR-". CMake adds them by default.
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()
@@ -1125,16 +1178,13 @@ 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()
option(LLVM_ENABLE_IR_PGO "Build LLVM and tools with IR PGO instrumentation (deprecated)" Off)
mark_as_advanced(LLVM_ENABLE_IR_PGO)
set(LLVM_BUILD_INSTRUMENTED OFF CACHE STRING "Build LLVM and tools with PGO instrumentation. May be specified as IR or Frontend")
set(LLVM_BUILD_INSTRUMENTED OFF CACHE STRING "Build LLVM and tools with PGO instrumentation. May be specified as IR, Frontend, CSIR, CSSPGO")
set(LLVM_VP_COUNTERS_PER_SITE "1.5" CACHE STRING "Value profile counters to use per site for IR PGO with Clang")
mark_as_advanced(LLVM_BUILD_INSTRUMENTED LLVM_VP_COUNTERS_PER_SITE)
string(TOUPPER "${LLVM_BUILD_INSTRUMENTED}" uppercase_LLVM_BUILD_INSTRUMENTED)
if (LLVM_BUILD_INSTRUMENTED)
if (LLVM_ENABLE_IR_PGO OR uppercase_LLVM_BUILD_INSTRUMENTED STREQUAL "IR")
if (uppercase_LLVM_BUILD_INSTRUMENTED STREQUAL "IR")
append("-fprofile-generate=\"${LLVM_PROFILE_DATA_DIR}\""
CMAKE_CXX_FLAGS
CMAKE_C_FLAGS)
@@ -1161,6 +1211,19 @@ if (LLVM_BUILD_INSTRUMENTED)
CMAKE_EXE_LINKER_FLAGS
CMAKE_SHARED_LINKER_FLAGS)
endif()
elseif(uppercase_LLVM_BUILD_INSTRUMENTED STREQUAL "CSSPGO")
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
append("-fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fno-optimize-sibling-calls -fpseudo-probe-for-profiling -fdebug-info-for-profiling"
CMAKE_CXX_FLAGS
CMAKE_C_FLAGS)
if(NOT LINKER_IS_LLD_LINK)
append("-fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fno-optimize-sibling-calls -fpseudo-probe-for-profiling -fdebug-info-for-profiling"
CMAKE_EXE_LINKER_FLAGS
CMAKE_SHARED_LINKER_FLAGS)
endif()
else()
message(FATAL_ERROR "LLVM_BUILD_INSTRUMENTED=CSSPGO can only be specified when compiling with clang")
endif()
else()
append("-fprofile-instr-generate=\"${LLVM_PROFILE_FILE_PATTERN}\""
CMAKE_CXX_FLAGS
@@ -1190,7 +1253,7 @@ if (CLANG_CL AND (LLVM_BUILD_INSTRUMENTED OR LLVM_USE_SANITIZER))
endif()
file(TO_CMAKE_PATH "${clang_compiler_rt_file}" clang_compiler_rt_file)
get_filename_component(clang_runtime_dir "${clang_compiler_rt_file}" DIRECTORY)
append("/libpath:\"${clang_runtime_dir}\""
prepend("${CMAKE_CXX_LINKER_WRAPPER_FLAG}/libpath:\"${clang_runtime_dir}\""
CMAKE_EXE_LINKER_FLAGS
CMAKE_MODULE_LINKER_FLAGS
CMAKE_SHARED_LINKER_FLAGS)
@@ -1209,6 +1272,23 @@ if(LLVM_PROFDATA_FILE AND EXISTS ${LLVM_PROFDATA_FILE})
else()
message(FATAL_ERROR "LLVM_PROFDATA_FILE can only be specified when compiling with clang")
endif()
elseif(LLVM_PROFDATA_FILE)
message(WARNING "LLVM_PROFDATA_FILE specified, but ${LLVM_PROFDATA_FILE} not found")
endif()
if(LLVM_SPROFDATA_FILE AND EXISTS ${LLVM_SPROFDATA_FILE})
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" )
append("-fpseudo-probe-for-profiling -fprofile-sample-use=\"${LLVM_SPROFDATA_FILE}\""
CMAKE_CXX_FLAGS
CMAKE_C_FLAGS)
if(NOT LINKER_IS_LLD_LINK)
append("-fpseudo-probe-for-profiling -fprofile-sample-use=\"${LLVM_SPROFDATA_FILE}\""
CMAKE_EXE_LINKER_FLAGS
CMAKE_SHARED_LINKER_FLAGS)
endif()
else()
message(FATAL_ERROR "LLVM_SPROFDATA_FILE can only be specified when compiling with clang")
endif()
endif()
option(LLVM_BUILD_INSTRUMENTED_COVERAGE "Build LLVM and tools with Code Coverage instrumentation" Off)
@@ -1226,7 +1306,7 @@ endif()
set(LLVM_THINLTO_CACHE_PATH "${PROJECT_BINARY_DIR}/lto.cache" CACHE STRING "Set ThinLTO cache path. This can be used when building LLVM from several different directiories.")
if(LLVM_ENABLE_LTO AND LLVM_ON_WIN32 AND NOT LINKER_IS_LLD_LINK AND NOT MINGW)
if(LLVM_ENABLE_LTO AND WIN32 AND NOT LINKER_IS_LLD_LINK AND NOT MINGW)
message(FATAL_ERROR "When compiling for Windows, LLVM_ENABLE_LTO requires using lld as the linker (point CMAKE_LINKER at lld-link.exe)")
endif()
if(uppercase_LLVM_ENABLE_LTO STREQUAL "THIN")
@@ -1241,6 +1321,9 @@ if(uppercase_LLVM_ENABLE_LTO STREQUAL "THIN")
if(APPLE)
append("-Wl,-cache_path_lto,${LLVM_THINLTO_CACHE_PATH}"
CMAKE_EXE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS)
elseif("${CMAKE_SYSTEM_NAME}" MATCHES "AIX")
append("-bplugin_opt:-legacy-thinlto-cache-dir=${LLVM_THINLTO_CACHE_PATH}"
CMAKE_EXE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS)
elseif((UNIX OR MINGW) AND LLVM_USE_LINKER STREQUAL "lld")
append("-Wl,--thinlto-cache-dir=${LLVM_THINLTO_CACHE_PATH}"
CMAKE_EXE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS)
@@ -1263,7 +1346,7 @@ elseif(LLVM_ENABLE_LTO)
endif()
endif()
if(LLVM_ENABLE_FATLTO AND UNIX AND NOT APPLE)
if(LLVM_ENABLE_FATLTO AND ((UNIX AND NOT APPLE) OR FUCHSIA))
append("-ffat-lto-objects" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
if(NOT LINKER_IS_LLD_LINK)
append("-ffat-lto-objects" CMAKE_EXE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS)
@@ -1284,9 +1367,14 @@ endif()
# linking (due to incompatibility). With MSVC, note that the plugin has to
# explicitly link against (exactly one) tool so we can't unilaterally turn on
# LLVM_ENABLE_PLUGINS when it's enabled.
if("${CMAKE_SYSTEM_NAME}" MATCHES "AIX")
set(LLVM_EXPORT_SYMBOLS_FOR_PLUGINS_OPTION OFF)
else()
set(LLVM_EXPORT_SYMBOLS_FOR_PLUGINS_OPTION ON)
endif()
CMAKE_DEPENDENT_OPTION(LLVM_EXPORT_SYMBOLS_FOR_PLUGINS
"Export symbols from LLVM tools so that plugins can import them" OFF
"NOT ${CMAKE_SYSTEM_NAME} MATCHES AIX" ${LLVM_EXPORT_SYMBOLS_FOR_PLUGINS_AIX_default})
"LLVM_EXPORT_SYMBOLS_FOR_PLUGINS_OPTION" ${LLVM_EXPORT_SYMBOLS_FOR_PLUGINS_AIX_default})
if(BUILD_SHARED_LIBS AND LLVM_EXPORT_SYMBOLS_FOR_PLUGINS)
message(FATAL_ERROR "BUILD_SHARED_LIBS not compatible with LLVM_EXPORT_SYMBOLS_FOR_PLUGINS")
endif()
@@ -1400,3 +1488,11 @@ if(LLVM_ENABLE_LLVM_LIBC)
message(WARNING "Unable to link against LLVM libc. LLVM will be built without linking against the LLVM libc overlay.")
endif()
endif()
check_symbol_exists(flock "sys/file.h" HAVE_FLOCK)
set(LLVM_ENABLE_ONDISK_CAS_default OFF)
if(HAVE_FLOCK OR WIN32)
# LLVM OnDisk CAS currently requires flock on Unix.
set(LLVM_ENABLE_ONDISK_CAS_default ON)
endif()
option(LLVM_ENABLE_ONDISK_CAS "Build OnDiskCAS." ${LLVM_ENABLE_ONDISK_CAS_default})
@@ -13,12 +13,12 @@ if(NOT DEFINED LLVM_STDLIB_HANDLED)
endfunction()
include(CheckCXXCompilerFlag)
include(LLVMCheckLinkerFlag)
include(CheckLinkerFlag)
set(LLVM_LIBCXX_USED 0)
if(LLVM_ENABLE_LIBCXX)
if(LLVM_COMPILER_IS_GCC_COMPATIBLE)
check_cxx_compiler_flag("-stdlib=libc++" CXX_COMPILER_SUPPORTS_STDLIB)
llvm_check_linker_flag(CXX "-stdlib=libc++" CXX_LINKER_SUPPORTS_STDLIB)
check_linker_flag(CXX "-stdlib=libc++" CXX_LINKER_SUPPORTS_STDLIB)
if(CXX_COMPILER_SUPPORTS_STDLIB AND CXX_LINKER_SUPPORTS_STDLIB)
append("-stdlib=libc++"
CMAKE_CXX_FLAGS CMAKE_EXE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS
@@ -36,7 +36,7 @@ if(NOT DEFINED LLVM_STDLIB_HANDLED)
if(LLVM_COMPILER_IS_GCC_COMPATIBLE)
check_cxx_compiler_flag("-static-libstdc++"
CXX_COMPILER_SUPPORTS_STATIC_STDLIB)
llvm_check_linker_flag(CXX "-static-libstdc++" CXX_LINKER_SUPPORTS_STATIC_STDLIB)
check_linker_flag(CXX "-static-libstdc++" CXX_LINKER_SUPPORTS_STATIC_STDLIB)
if(CXX_COMPILER_SUPPORTS_STATIC_STDLIB AND
CXX_LINKER_SUPPORTS_STATIC_STDLIB)
append("-static-libstdc++"
@@ -36,6 +36,8 @@ set(LLVM_TARGETS_WITH_JIT @LLVM_TARGETS_WITH_JIT@)
set(LLVM_TARGET_TRIPLE "@LLVM_TARGET_TRIPLE@")
set(LLVM_TARGET_TRIPLE_ENV "@LLVM_TARGET_TRIPLE_ENV@")
set(LLVM_HOST_TRIPLE "@LLVM_HOST_TRIPLE@")
set(LLVM_ABI_BREAKING_CHECKS @LLVM_ABI_BREAKING_CHECKS@)
@@ -100,6 +102,8 @@ set(LLVM_ENABLE_PIC @LLVM_ENABLE_PIC@)
set(LLVM_BUILD_32_BITS @LLVM_BUILD_32_BITS@)
set(LLVM_ENABLE_TELEMETRY @LLVM_ENABLE_TELEMETRY@)
if (NOT "@LLVM_PTHREAD_LIB@" STREQUAL "")
set(LLVM_PTHREAD_LIB "@LLVM_PTHREAD_LIB@")
endif()
@@ -151,20 +155,17 @@ endif()
if(NOT TARGET intrinsics_gen)
add_custom_target(intrinsics_gen)
endif()
if(NOT TARGET vt_gen)
add_custom_target(vt_gen)
endif()
if(NOT TARGET omp_gen)
add_custom_target(omp_gen)
endif()
if(NOT TARGET acc_gen)
add_custom_target(acc_gen)
endif()
if(NOT TARGET ARMTargetParserTableGen)
add_custom_target(ARMTargetParserTableGen)
endif()
if(NOT TARGET AArch64TargetParserTableGen)
add_custom_target(AArch64TargetParserTableGen)
endif()
if(NOT TARGET RISCVTargetParserTableGen)
add_custom_target(RISCVTargetParserTableGen)
if(NOT TARGET target_parser_gen)
add_custom_target(target_parser_gen)
endif()
set_property(GLOBAL PROPERTY LLVM_TARGETS_CONFIGURED On)
@@ -2,14 +2,18 @@ include(ExternalProject)
# llvm_ExternalProject_BuildCmd(out_var target)
# Utility function for constructing command lines for external project targets
function(llvm_ExternalProject_BuildCmd out_var target bin_dir)
function(llvm_ExternalProject_BuildCmd out_var target bin_dir stamp_dir)
cmake_parse_arguments(ARG "" "CONFIGURATION" "" ${ARGN})
if(NOT ARG_CONFIGURATION)
set(ARG_CONFIGURATION "$<CONFIG>")
endif()
if (CMAKE_GENERATOR MATCHES "Make")
# Use special command for Makefiles to support parallelism.
set(${out_var} "$(MAKE)" "-C" "${bin_dir}" "${target}" PARENT_SCOPE)
string(JOIN "@" make_cmd "$(MAKE)" "-C" "${bin_dir}" "${target}")
set(file_lock_script "${LLVM_CMAKE_DIR}/FileLock.cmake")
set(${out_var} ${CMAKE_COMMAND} "-DLOCK_FILE_PATH=${stamp_dir}/cmake.lock"
"-DCOMMAND=${make_cmd}"
"-P" "${file_lock_script}" PARENT_SCOPE)
else()
set(tool_args "${LLVM_EXTERNAL_PROJECT_BUILD_TOOL_ARGS}")
if(NOT tool_args STREQUAL "")
@@ -34,6 +38,8 @@ endfunction()
# llvm_ExternalProject_Add(name source_dir ...
# ENABLE_FORTRAN
# External project requires the Flang compiler
# USE_TOOLCHAIN
# Use just-built tools (see TOOLCHAIN_TOOLS)
# EXCLUDE_FROM_ALL
@@ -61,7 +67,7 @@ endfunction()
# )
function(llvm_ExternalProject_Add name source_dir)
cmake_parse_arguments(ARG
"USE_TOOLCHAIN;EXCLUDE_FROM_ALL;NO_INSTALL;ALWAYS_CLEAN"
"ENABLE_FORTRAN;USE_TOOLCHAIN;EXCLUDE_FROM_ALL;NO_INSTALL;ALWAYS_CLEAN"
"SOURCE_DIR;FOLDER"
"CMAKE_ARGS;TOOLCHAIN_TOOLS;RUNTIME_LIBRARIES;DEPENDS;EXTRA_TARGETS;PASSTHROUGH_PREFIXES;STRIP_TOOL;TARGET_TRIPLE"
${ARGN})
@@ -89,8 +95,11 @@ function(llvm_ExternalProject_Add name source_dir)
if(NOT ARG_TOOLCHAIN_TOOLS)
set(ARG_TOOLCHAIN_TOOLS clang)
if (ARG_ENABLE_FORTRAN)
list(APPEND ARG_TOOLCHAIN_TOOLS flang)
endif ()
# AIX 64-bit XCOFF and big AR format is not yet supported in some of these tools.
if(NOT _cmake_system_name STREQUAL AIX)
if(NOT _cmake_system_name STREQUAL "AIX")
list(APPEND ARG_TOOLCHAIN_TOOLS lld llvm-ar llvm-ranlib llvm-nm llvm-objdump)
if(_cmake_system_name STREQUAL Darwin)
list(APPEND ARG_TOOLCHAIN_TOOLS llvm-libtool-darwin llvm-lipo)
@@ -139,6 +148,10 @@ function(llvm_ExternalProject_Add name source_dir)
set(CLANG_IN_TOOLCHAIN On)
endif()
if(flang IN_LIST TOOLCHAIN_TOOLS)
set(FLANG_IN_TOOLCHAIN On)
endif()
if(RUNTIME_LIBRARIES AND CLANG_IN_TOOLCHAIN)
list(APPEND TOOLCHAIN_BINS ${RUNTIME_LIBRARIES})
endif()
@@ -156,6 +169,32 @@ function(llvm_ExternalProject_Add name source_dir)
set_target_properties(${name}-clear PROPERTIES FOLDER "${ARG_FOLDER}")
endif ()
set(DEFAULT_PASSTHROUGH_VARIABLES
LibEdit_INCLUDE_DIRS
LibEdit_LIBRARIES
ZLIB_INCLUDE_DIR
ZLIB_LIBRARY
zstd_INCLUDE_DIR
zstd_LIBRARY
LIBXML2_LIBRARY
LIBXML2_INCLUDE_DIR
CURL_INCLUDE_DIR
CURL_LIBRARY
HTTPLIB_INCLUDE_DIR
HTTPLIB_HEADER_PATH
Python3_EXECUTABLE
Python3_LIBRARIES
Python3_INCLUDE_DIRS
Python3_RPATH
)
foreach(variable ${DEFAULT_PASSTHROUGH_VARIABLES})
get_property(is_value_set CACHE ${variable} PROPERTY VALUE SET)
if(${is_value_set})
get_property(value CACHE ${variable} PROPERTY VALUE)
list(APPEND CMAKE_CACHE_DEFAULT_ARGS "-D${variable}:STRING=${value}")
endif()
endforeach()
# Find all variables that start with a prefix and propagate them through
get_cmake_property(variableNames VARIABLES)
@@ -195,6 +234,9 @@ function(llvm_ExternalProject_Add name source_dir)
-DCMAKE_ASM_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang${CMAKE_EXECUTABLE_SUFFIX})
endif()
endif()
if(FLANG_IN_TOOLCHAIN)
list(APPEND compiler_args -DCMAKE_Fortran_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/flang${CMAKE_EXECUTABLE_SUFFIX})
endif()
if(lld IN_LIST TOOLCHAIN_TOOLS)
if(is_msvc_target)
list(APPEND compiler_args -DCMAKE_LINKER=${LLVM_RUNTIME_OUTPUT_INTDIR}/lld-link${CMAKE_EXECUTABLE_SUFFIX})
@@ -278,6 +320,7 @@ function(llvm_ExternalProject_Add name source_dir)
set(compiler_args -DCMAKE_ASM_COMPILER=${CMAKE_ASM_COMPILER}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_Fortran_COMPILER=${CMAKE_Fortran_COMPILER}
-DCMAKE_LINKER=${CMAKE_LINKER}
-DCMAKE_AR=${CMAKE_AR}
-DCMAKE_RANLIB=${CMAKE_RANLIB}
@@ -327,6 +370,7 @@ function(llvm_ExternalProject_Add name source_dir)
if(ARG_TARGET_TRIPLE)
list(APPEND compiler_args -DCMAKE_C_COMPILER_TARGET=${ARG_TARGET_TRIPLE})
list(APPEND compiler_args -DCMAKE_CXX_COMPILER_TARGET=${ARG_TARGET_TRIPLE})
list(APPEND compiler_args -DCMAKE_Fortran_COMPILER_TARGET=${ARG_TARGET_TRIPLE})
list(APPEND compiler_args -DCMAKE_ASM_COMPILER_TARGET=${ARG_TARGET_TRIPLE})
endif()
@@ -363,6 +407,7 @@ function(llvm_ExternalProject_Add name source_dir)
-DCMAKE_EXPORT_COMPILE_COMMANDS=1
${cmake_args}
${PASSTHROUGH_VARIABLES}
CMAKE_CACHE_DEFAULT_ARGS ${CMAKE_CACHE_DEFAULT_ARGS}
INSTALL_COMMAND ""
STEP_TARGETS configure build
BUILD_ALWAYS 1
@@ -382,7 +427,7 @@ function(llvm_ExternalProject_Add name source_dir)
set(force_deps DEPENDS ${TOOLCHAIN_BINS})
endif()
llvm_ExternalProject_BuildCmd(run_clean clean ${BINARY_DIR})
llvm_ExternalProject_BuildCmd(run_clean clean ${BINARY_DIR} ${STAMP_DIR})
ExternalProject_Add_Step(${name} clean
COMMAND ${run_clean}
COMMENT "Cleaning ${name}..."
@@ -422,7 +467,7 @@ function(llvm_ExternalProject_Add name source_dir)
else()
set(external_target "${target}")
endif()
llvm_ExternalProject_BuildCmd(build_runtime_cmd ${external_target} ${BINARY_DIR})
llvm_ExternalProject_BuildCmd(build_runtime_cmd ${external_target} ${BINARY_DIR} ${STAMP_DIR})
add_custom_target(${target}
COMMAND ${build_runtime_cmd}
DEPENDS ${name}-configure
@@ -1,6 +1,3 @@
include(AddFileDependencies)
include(CMakeParseArguments)
function(llvm_replace_compiler_option var old new)
# Replaces a compiler option or switch `old' in `var' by `new'.
# If `old' is not in `var', appends `new' to `var'.
+71 -58
View File
@@ -4,10 +4,6 @@
# Adds the name of the generated file to TABLEGEN_OUTPUT.
include(LLVMDistributionSupport)
# Clear out any pre-existing compile_commands file before processing. This
# allows for generating a clean compile_commands on each configure.
file(REMOVE ${CMAKE_BINARY_DIR}/tablegen_compile_commands.yml)
function(tablegen project ofn)
cmake_parse_arguments(ARG "" "" "DEPENDS;EXTRA_INCLUDES" ${ARGN})
@@ -21,37 +17,44 @@ function(tablegen project ofn)
message(FATAL_ERROR "${project}_TABLEGEN_EXE not set")
endif()
# Use depfile instead of globbing arbitrary *.td(s) for Ninja.
if(CMAKE_GENERATOR MATCHES "Ninja")
# Make output path relative to build.ninja, assuming located on
# ${CMAKE_BINARY_DIR}.
# Set the include directories
get_directory_property(tblgen_includes INCLUDE_DIRECTORIES)
list(PREPEND tblgen_includes ${ARG_EXTRA_INCLUDES})
list(PREPEND tblgen_includes ${CMAKE_CURRENT_SOURCE_DIR})
# Filter out any empty include items.
list(REMOVE_ITEM tblgen_includes "")
# Use depfile instead of globbing arbitrary *.td(s) for Ninja. We force
# CMake versions older than v3.30 on Windows to use the fallback behavior
# due to a depfile parsing bug on Windows paths in versions prior to 3.30.
# https://gitlab.kitware.com/cmake/cmake/-/issues/25943
# CMake versions older than v3.23 on other platforms use the fallback
# behavior as v3.22 and earlier fail to parse some depfiles that get
# generated, and this behavior was fixed in CMake commit
# e04a352cca523eba2ac0d60063a3799f5bb1c69e.
cmake_policy(GET CMP0116 cmp0116_state)
if(CMAKE_GENERATOR MATCHES "Ninja" AND cmp0116_state STREQUAL NEW
AND NOT (CMAKE_HOST_WIN32 AND CMAKE_VERSION VERSION_LESS 3.30)
AND NOT (CMAKE_VERSION VERSION_LESS 3.23))
# CMake emits build targets as relative paths but Ninja doesn't identify
# absolute path (in *.d) as relative path (in build.ninja)
# Note that tblgen is executed on ${CMAKE_BINARY_DIR} as working directory.
file(RELATIVE_PATH ofn_rel
${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/${ofn})
# absolute path (in *.d) as relative path (in build.ninja). Post CMP0116,
# CMake handles this discrepancy for us, otherwise we use the fallback
# logic.
set(additional_cmdline
-o ${ofn_rel}
-d ${ofn_rel}.d
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
DEPFILE ${CMAKE_CURRENT_BINARY_DIR}/${ofn}.d
-o ${ofn}
-d ${ofn}.d
DEPFILE ${ofn}.d
)
set(local_tds)
set(global_tds)
else()
file(GLOB local_tds "*.td")
file(GLOB_RECURSE global_tds "${LLVM_MAIN_INCLUDE_DIR}/llvm/*.td")
set(include_td_dirs "${tblgen_includes}")
list(TRANSFORM include_td_dirs APPEND "/*.td")
file(GLOB global_tds ${include_td_dirs})
set(additional_cmdline
-o ${CMAKE_CURRENT_BINARY_DIR}/${ofn}
)
endif()
if (IS_ABSOLUTE ${LLVM_TARGET_DEFINITIONS})
set(LLVM_TARGET_DEFINITIONS_ABSOLUTE ${LLVM_TARGET_DEFINITIONS})
else()
set(LLVM_TARGET_DEFINITIONS_ABSOLUTE
${CMAKE_CURRENT_SOURCE_DIR}/${LLVM_TARGET_DEFINITIONS})
endif()
if (LLVM_ENABLE_DAGISEL_COV AND "-gen-dag-isel" IN_LIST ARGN)
list(APPEND LLVM_TABLEGEN_FLAGS "-instrument-coverage")
endif()
@@ -63,12 +66,24 @@ function(tablegen project ofn)
list(APPEND LLVM_TABLEGEN_FLAGS "-omit-comments")
endif()
set(EXTRA_OUTPUTS)
if("-gen-register-info" IN_LIST ARGN)
cmake_path(GET ofn STEM OUTPUT_BASENAME)
list(APPEND EXTRA_OUTPUTS
${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_BASENAME}Enums.inc
${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_BASENAME}Header.inc
${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_BASENAME}MCDesc.inc
${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_BASENAME}TargetDesc.inc)
endif()
# MSVC can't support long string literals ("long" > 65534 bytes)[1], so if there's
# a possibility of generated tables being consumed by MSVC, generate arrays of
# char literals, instead. If we're cross-compiling, then conservatively assume
# that the source might be consumed by MSVC.
# [1] https://docs.microsoft.com/en-us/cpp/cpp/compiler-limits?view=vs-2017
if (MSVC AND project STREQUAL LLVM)
# Don't pass this flag to mlir-src-sharder, since it doesn't support the
# flag, and it doesn't need it.
if (MSVC AND NOT "${project}" STREQUAL "MLIR_SRC_SHARDER")
list(APPEND LLVM_TABLEGEN_FLAGS "--long-string-literals=0")
endif()
if (CMAKE_GENERATOR MATCHES "Visual Studio")
@@ -84,6 +99,25 @@ function(tablegen project ofn)
list(APPEND LLVM_TABLEGEN_FLAGS "-no-warn-on-unused-template-args")
endif()
# Build the absolute path for the current input file.
if (IS_ABSOLUTE ${LLVM_TARGET_DEFINITIONS})
set(LLVM_TARGET_DEFINITIONS_ABSOLUTE ${LLVM_TARGET_DEFINITIONS})
else()
set(LLVM_TARGET_DEFINITIONS_ABSOLUTE
${CMAKE_CURRENT_SOURCE_DIR}/${LLVM_TARGET_DEFINITIONS})
endif()
# Append this file and its includes to the compile commands file.
# This file is used by the TableGen LSP Language Server (tblgen-lsp-server).
file(APPEND ${CMAKE_BINARY_DIR}/tablegen_compile_commands.yml
"--- !FileInfo:\n"
" filepath: \"${LLVM_TARGET_DEFINITIONS_ABSOLUTE}\"\n"
" includes: \"${tblgen_includes}\"\n"
)
# Prepend each include entry with -I for arguments.
list(TRANSFORM tblgen_includes PREPEND -I)
# We need both _TABLEGEN_TARGET and _TABLEGEN_EXE in the DEPENDS list
# (both the target and the file) to have .inc files rebuilt on
# a tablegen change, as cmake does not propagate file-level dependencies
@@ -93,35 +127,6 @@ function(tablegen project ofn)
# dependency twice in the result file when
# ("${${project}_TABLEGEN_TARGET}" STREQUAL "${${project}_TABLEGEN_EXE}")
# but lets us having smaller and cleaner code here.
get_directory_property(tblgen_includes INCLUDE_DIRECTORIES)
list(APPEND tblgen_includes ${ARG_EXTRA_INCLUDES})
# Get the current set of include paths for this td file.
cmake_parse_arguments(ARG "" "" "DEPENDS;EXTRA_INCLUDES" ${ARGN})
get_directory_property(tblgen_includes INCLUDE_DIRECTORIES)
list(APPEND tblgen_includes ${ARG_EXTRA_INCLUDES})
# Filter out any empty include items.
list(REMOVE_ITEM tblgen_includes "")
# Build the absolute path for the current input file.
if (IS_ABSOLUTE ${LLVM_TARGET_DEFINITIONS})
set(LLVM_TARGET_DEFINITIONS_ABSOLUTE ${LLVM_TARGET_DEFINITIONS})
else()
set(LLVM_TARGET_DEFINITIONS_ABSOLUTE ${CMAKE_CURRENT_SOURCE_DIR}/${LLVM_TARGET_DEFINITIONS})
endif()
# Append this file and its includes to the compile commands file.
# This file is used by the TableGen LSP Language Server (tblgen-lsp-server).
file(APPEND ${CMAKE_BINARY_DIR}/tablegen_compile_commands.yml
"--- !FileInfo:\n"
" filepath: \"${LLVM_TARGET_DEFINITIONS_ABSOLUTE}\"\n"
" includes: \"${CMAKE_CURRENT_SOURCE_DIR};${tblgen_includes}\"\n"
)
# Filter out empty items before prepending each entry with -I
list(REMOVE_ITEM tblgen_includes "")
list(TRANSFORM tblgen_includes PREPEND -I)
set(tablegen_exe ${${project}_TABLEGEN_EXE})
set(tablegen_depends ${${project}_TABLEGEN_TARGET} ${tablegen_exe})
@@ -131,8 +136,8 @@ function(tablegen project ofn)
set(LLVM_TABLEGEN_JOB_POOL "")
endif()
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${ofn}
COMMAND ${tablegen_exe} ${ARG_UNPARSED_ARGUMENTS} -I ${CMAKE_CURRENT_SOURCE_DIR}
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${ofn} ${EXTRA_OUTPUTS}
COMMAND ${tablegen_exe} ${ARG_UNPARSED_ARGUMENTS}
${tblgen_includes}
${LLVM_TABLEGEN_FLAGS}
${LLVM_TARGET_DEFINITIONS_ABSOLUTE}
@@ -142,7 +147,7 @@ function(tablegen project ofn)
# directory and local_tds may not contain it, so we must
# explicitly list it here:
DEPENDS ${ARG_DEPENDS} ${tablegen_depends}
${local_tds} ${global_tds}
${global_tds}
${LLVM_TARGET_DEFINITIONS_ABSOLUTE}
${LLVM_TARGET_DEPENDS}
${LLVM_TABLEGEN_JOB_POOL}
@@ -251,3 +256,11 @@ macro(add_tablegen target project)
set_property(GLOBAL APPEND PROPERTY ${export_upper}_EXPORTS ${target})
endif()
endmacro()
# Make sure 'tablegen_compile_commands.yml' is only deleted once the very
# first time this file is included.
include_guard(GLOBAL)
# Clear out any pre-existing compile_commands file before processing. This
# allows for generating a clean compile_commands on each configure.
file(REMOVE ${CMAKE_BINARY_DIR}/tablegen_compile_commands.yml)
@@ -39,6 +39,30 @@ function(get_source_info path revision repository)
OUTPUT_VARIABLE git_output
ERROR_QUIET)
if(git_result EQUAL 0)
# Passwords or tokens should not be stored in the remote URL at the
# risk of being leaked. In case we find one, error out and teach the
# user the best practices.
string(REGEX MATCH "https?://[^/]*:[^/]*@.*"
http_password "${git_output}")
if(http_password)
message(SEND_ERROR "The git remote repository URL has an embedded \
password. Remove the password from the URL or use \
`-DLLVM_FORCE_VC_REPOSITORY=<URL without password>` in order to avoid \
leaking your password (see https://git-scm.com/docs/gitcredentials for \
alternatives).")
endif()
# GitHub token formats are described at:
# https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/about-authentication-to-github#githubs-token-formats
string(REGEX MATCH
"https?://(gh[pousr]|github_pat)_[^/]+@github.com.*"
github_token "${git_output}")
if(github_token)
message(SEND_ERROR "The git remote repository URL has an embedded \
GitHub Token. Remove the token from the URL or use \
`-DLLVM_FORCE_VC_REPOSITORY=<URL without token>` in order to avoid leaking \
your token (see https://git-scm.com/docs/gitcredentials for alternatives).")
endif()
string(STRIP "${git_output}" git_output)
set(${repository} ${git_output} PARENT_SCOPE)
else()
+34 -1
View File
@@ -95,6 +95,7 @@ list(APPEND CMAKE_TRY_COMPILE_PLATFORM_VARIABLES
LLVM_WINSYSROOT
MSVC_VER
WINSDK_VER
msvc_lib_symlinks_dir
winsdk_lib_symlinks_dir
winsdk_vfs_overlay_path
)
@@ -156,6 +157,24 @@ function(generate_winsdk_lib_symlinks winsdk_um_lib_dir output_dir)
endforeach()
endfunction()
function(generate_msvc_lib_symlinks msvc_lib_dir output_dir)
execute_process(COMMAND "${CMAKE_COMMAND}" -E make_directory "${output_dir}")
file(GLOB libraries RELATIVE "${msvc_lib_dir}" "${msvc_lib_dir}/*.lib")
foreach(library ${libraries})
get_filename_component(name_wle "${library}" NAME_WLE)
get_filename_component(ext "${library}" LAST_EXT)
string(TOLOWER "${ext}" lowercase_ext)
string(TOUPPER "${name_wle}" all_uppercase_symlink_name_wle)
set(uppercase_symlink_name "${all_uppercase_symlink_name_wle}${lowercase_ext}")
if(NOT library STREQUAL uppercase_symlink_name)
execute_process(COMMAND "${CMAKE_COMMAND}"
-E create_symlink
"${msvc_lib_dir}/${library}"
"${output_dir}/${uppercase_symlink_name}")
endif()
endforeach()
endfunction()
function(get_highest_version the_dir the_ver)
file(GLOB entries LIST_DIRECTORIES true RELATIVE "${the_dir}" "${the_dir}/[0-9.]*")
foreach(entry ${entries})
@@ -240,6 +259,7 @@ set(CMAKE_C_COMPILER "${LLVM_NATIVE_TOOLCHAIN}/bin/clang-cl" CACHE FILEPATH "")
set(CMAKE_CXX_COMPILER "${LLVM_NATIVE_TOOLCHAIN}/bin/clang-cl" CACHE FILEPATH "")
set(CMAKE_LINKER "${LLVM_NATIVE_TOOLCHAIN}/bin/lld-link" CACHE FILEPATH "")
set(CMAKE_AR "${LLVM_NATIVE_TOOLCHAIN}/bin/llvm-lib" CACHE FILEPATH "")
set(CMAKE_ASM_MASM_COMPILER "${LLVM_NATIVE_TOOLCHAIN}/bin/llvm-ml" CACHE FILEPATH "")
# Even though we're cross-compiling, we need some native tools (e.g. llvm-tblgen), and those
# native tools have to be built before we can start doing the cross-build. LLVM supports
@@ -257,7 +277,7 @@ set(CROSS_TOOLCHAIN_FLAGS_NATIVE "${_CTF_NATIVE_DEFAULT}" CACHE STRING "")
set(COMPILE_FLAGS
-D_CRT_SECURE_NO_WARNINGS
--target=${TRIPLE_ARCH}-windows-msvc
-fms-compatibility-version=19.27
-fms-compatibility-version=19.28
-vctoolsversion ${MSVC_VER}
-winsdkversion ${WINSDK_VER}
-winsysroot ${LLVM_WINSYSROOT})
@@ -275,6 +295,9 @@ endif()
string(REPLACE ";" " " COMPILE_FLAGS "${COMPILE_FLAGS}")
string(APPEND CMAKE_C_FLAGS_INIT " ${COMPILE_FLAGS}")
string(APPEND CMAKE_CXX_FLAGS_INIT " ${COMPILE_FLAGS}")
if(TRIPLE_ARCH STREQUAL "x86_64")
string(APPEND CMAKE_ASM_MASM_FLAGS_INIT " -m64")
endif()
set(LINK_FLAGS
# Prevent CMake from attempting to invoke mt.exe. It only recognizes the slashed form and not the dashed form.
@@ -293,6 +316,16 @@ if(case_sensitive_filesystem)
endif()
list(APPEND LINK_FLAGS
-libpath:"${winsdk_lib_symlinks_dir}")
if(NOT msvc_lib_symlinks_dir)
set(msvc_lib_symlinks_dir "${CMAKE_BINARY_DIR}/msvc_lib_symlinks")
generate_msvc_lib_symlinks("${MSVC_LIB}/${WINSDK_ARCH}" "${msvc_lib_symlinks_dir}")
endif()
list(APPEND LINK_FLAGS
-libpath:"${msvc_lib_symlinks_dir}")
endif()
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.25")
list(TRANSFORM LINK_FLAGS PREPEND "${CMAKE_CXX_LINKER_WRAPPER_FLAG}")
endif()
string(REPLACE ";" " " LINK_FLAGS "${LINK_FLAGS}")
+36 -34
View File
@@ -18,8 +18,8 @@ This document describes how the SME ACLE attributes map to LLVM IR
attributes and how LLVM lowers these attributes to implement the rules and
requirements of the ABI.
Below we describe the LLVM IR attributes and their relation to the C/C++
level ACLE attributes:
Below, we describe the LLVM IR attributes and their relation to the
C/C++-level ACLE attributes:
``aarch64_pstate_sm_enabled``
is used for functions with ``__arm_streaming``
@@ -51,8 +51,8 @@ level ACLE attributes:
Clang must ensure that the above attributes are added both to the
function's declaration/definition as well as to their call-sites. This is
important for calls to attributed function pointers, where there is no
definition or declaration available.
important for calls to attributed function pointers, where no
definition or declaration is available.
2. Handling PSTATE.SM
@@ -77,7 +77,7 @@ and almost all parts of CodeGen we can assume that the runtime value for
``vscale`` does not. If we let the compiler insert the appropriate ``smstart``
and ``smstop`` instructions around call boundaries, then the effects on SVE
state can be mitigated. By limiting the state changes to a very brief window
around the call we can control how the operations are scheduled and how live
around the call, we can control how the operations are scheduled and how live
values remain preserved between state transitions.
In order to control PSTATE.SM at this level of granularity, we use function and
@@ -89,7 +89,7 @@ Restrictions on attributes
* It is undefined behaviour to pass or return (pointers to) scalable vector
objects to/from functions which may use a different SVE vector length.
This includes functions with a non-streaming interface, but marked with
This includes functions with a non-streaming interface but marked with
``aarch64_pstate_sm_body``.
* It is not allowed for a function to be decorated with both
@@ -100,7 +100,7 @@ Restrictions on attributes
``aarch64_new_za``, ``aarch64_in_za``, ``aarch64_out_za``, ``aarch64_inout_za``,
``aarch64_preserves_za``.
These restrictions also apply in the higher level SME ACLE, which means we can
These restrictions also apply in the higher-level SME ACLE, which means we can
emit diagnostics in Clang to signal users about incorrect behaviour.
@@ -124,7 +124,7 @@ In this table, we use the following abbreviations:
either 0 or 1 on entry, and is unchanged on return).
Functions with ``__attribute__((arm_locally_streaming))`` are excluded from this
table because for the caller the attribute is synonymous to 'streaming', and
table because for the caller the attribute is synonymous with 'streaming', and
for the callee it is merely an implementation detail that is explicitly not
exposed to the caller.
@@ -158,7 +158,7 @@ the function's body, so that it can place the mode changes in exactly the right
position. The suitable place to do this seems to be SelectionDAG, where it lowers
the call's arguments/return values to implement the specified calling convention.
SelectionDAG provides Chains and Glue to specify the order of operations and give
preliminary control over the instruction's scheduling.
preliminary control over instruction scheduling.
Example of preserving state
@@ -213,16 +213,18 @@ Instruction Selection Nodes
.. code-block:: none
AArch64ISD::SMSTART Chain, [SM|ZA|Both], CurrentState, ExpectedState[, RegMask]
AArch64ISD::SMSTOP Chain, [SM|ZA|Both], CurrentState, ExpectedState[, RegMask]
AArch64ISD::SMSTART Chain, [SM|ZA|Both][, RegMask]
AArch64ISD::SMSTOP Chain, [SM|ZA|Both][, RegMask]
AArch64ISD::COND_SMSTART Chain, [SM|ZA|Both], CurrentState, ExpectedState[, RegMask]
AArch64ISD::COND_SMSTOP Chain, [SM|ZA|Both], CurrentState, ExpectedState[, RegMask]
The ``SMSTART/SMSTOP`` nodes take ``CurrentState`` and ``ExpectedState`` operand for
the case of a conditional SMSTART/SMSTOP. The instruction will only be executed
if CurrentState != ExpectedState.
The ``COND_SMSTART/COND_SMSTOP`` nodes additionally take ``CurrentState`` and
``ExpectedState``, in this case the instruction will only be executed if
``CurrentState != ExpectedState``.
When ``CurrentState`` and ``ExpectedState`` can be evaluated at compile-time
(i.e. they are both constants) then an unconditional ``smstart/smstop``
instruction is emitted. Otherwise the node is matched to a Pseudo instruction
instruction is emitted. Otherwise, the node is matched to a Pseudo instruction
which expands to a compare/branch and a ``smstart/smstop``. This is necessary to
implement transitions from ``SC -> N`` and ``SC -> S``.
@@ -230,11 +232,11 @@ implement transitions from ``SC -> N`` and ``SC -> S``.
Unchained Function calls
------------------------
When a function with "``aarch64_pstate_sm_enabled``" calls a function that is not
streaming compatible, the compiler has to insert a SMSTOP before the call and
insert a SMSTOP after the call.
streaming compatible, the compiler has to insert an SMSTOP before the call and
insert an SMSTOP after the call.
If the function that is called is an intrinsic with no side-effects which in
turn is lowered to a function call (e.g. ``@llvm.cos()``), then the call to
turn is lowered to a function call (e.g., ``@llvm.cos()``), then the call to
``@llvm.cos()`` is not part of any Chain; it can be scheduled freely.
Lowering of a Callsite creates a small chain of nodes which:
@@ -295,11 +297,11 @@ To ensure we use the correct SVE vector length to allocate the locals with, we
can use the streaming vector-length to allocate the stack-slots through the
``ADDSVL`` instruction, even when the CPU is not yet in streaming mode.
This only works for locals and not callee-save slots, since LLVM doesn't support
This works only for locals and not callee-save slots, since LLVM doesn't support
mixing two different scalable vector lengths in one stack frame. That means that the
case where a function is marked ``arm_locally_streaming`` and needs to spill SVE
callee-saves in the prologue is currently unsupported. However, it is unlikely
for this to happen without user intervention, because ``arm_locally_streaming``
for this to happen without user intervention because ``arm_locally_streaming``
functions cannot take or return vector-length-dependent values. This would otherwise
require forcing both the SVE PCS using '``aarch64_sve_pcs``' combined with using
``arm_locally_streaming`` in order to encounter this problem. This combination
@@ -328,7 +330,7 @@ attributed with ``arm_locally_streaming``:
return array[N - 1] + arg;
}
should use ADDSVL for allocating the stack space and should avoid clobbering
should use ``ADDSVL`` for allocating the stack space and should avoid clobbering
the return/argument values.
.. code-block:: none
@@ -379,17 +381,17 @@ Preventing the use of illegal instructions in Streaming Mode
* When executing a program in normal mode (PSTATE.SM=0), a subset of SME
instructions are invalid.
* Streaming-compatible functions must only use instructions that are valid when
* Streaming-compatible functions must use only instructions that are valid when
either PSTATE.SM=0 or PSTATE.SM=1.
The value of PSTATE.SM is not controlled by the feature flags, but rather by the
function attributes. This means that we can compile for '``+sme``' and the compiler
function attributes. This means that we can compile for '``+sme``', and the compiler
will code-generate any instructions, even if they are not legal under the requested
streaming mode. The compiler needs to use the function attributes to ensure the
compiler doesn't do transformations under the assumption that certain operations
compiler doesn't perform transformations under the assumption that certain operations
are available at runtime.
We made a conscious choice not to model this with feature flags, because we
We made a conscious choice not to model this with feature flags because we
still want to support inline-asm in either mode (with the user placing
smstart/smstop manually), and this became rather complicated to implement at the
individual instruction level (see `D120261 <https://reviews.llvm.org/D120261>`_
@@ -397,16 +399,16 @@ and `D121208 <https://reviews.llvm.org/D121208>`_) because of limitations in
TableGen.
As a first step, this means we'll disable vectorization (LoopVectorize/SLP)
entirely when the a function has either of the ``aarch64_pstate_sm_enabled``,
entirely when a function has either of the ``aarch64_pstate_sm_enabled``,
``aarch64_pstate_sm_body`` or ``aarch64_pstate_sm_compatible`` attributes,
in order to avoid the use of vector instructions.
Later on we'll aim to relax these restrictions to enable scalable
Later on, we'll aim to relax these restrictions to enable scalable
auto-vectorization with a subset of streaming-compatible instructions, but that
requires changes to the CostModel, Legalization and SelectionDAG lowering.
We will also emit diagnostics in Clang to prevent the use of
non-streaming(-compatible) operations, e.g. through ACLE intrinsics, when a
non-streaming(-compatible) operations, e.g., through ACLE intrinsics, when a
function is decorated with the streaming mode attributes.
@@ -414,7 +416,7 @@ Other things to consider
------------------------
* Inlining must be disabled when the call-site needs to toggle PSTATE.SM or
when the callee's function body is executed in a different streaming mode than
when the callee's function body is executed in a different streaming mode from
its caller. This is needed because function calls are the boundaries for
streaming mode changes.
@@ -432,8 +434,8 @@ lazy-save mechanism for calls to private-ZA functions (i.e. functions that may
either directly or indirectly clobber ZA state).
For the purpose of handling functions marked with ``aarch64_new_za``,
we have introduced a new LLVM IR pass (SMEABIPass) that is run just before
SelectionDAG. Any such functions dealt with by this pass are marked with
we have introduced a new LLVM IR pass (SMEABIPass) that runs just before
SelectionDAG. Any such functions handled by this pass are marked with
``aarch64_expanded_pstate_za``.
Setting up a lazy-save
@@ -454,9 +456,9 @@ AArch64 Predicate-as-Counter Type
:Overview:
The predicate-as-counter type represents the type of a predicate-as-counter
value held in a AArch64 SVE predicate register. Such a value contains
value held in an AArch64 SVE predicate register. Such a value contains
information about the number of active lanes, the element width and a bit that
tells whether the generated mask should be inverted. ACLE intrinsics should be
indicates whether the generated mask should be inverted. ACLE intrinsics should be
used to move the predicate-as-counter value to/from a predicate vector.
There are certain limitations on the type:
@@ -464,7 +466,7 @@ There are certain limitations on the type:
* The type can be used for function parameters and return values.
* The supported LLVM operations on this type are limited to ``load``, ``store``,
``phi``, ``select`` and ``alloca`` instructions.
``phi``, ``select``, and ``alloca`` instructions.
The predicate-as-counter type is a scalable type.
@@ -695,12 +695,6 @@ MUBUF
buffer_load_format_xyzw :ref:`vdst<amdgpu_synid_gfx11_vdst_f47754>`, :ref:`vaddr<amdgpu_synid_gfx11_vaddr_b73dc0>`, :ref:`srsrc<amdgpu_synid_gfx11_srsrc_80eef6>`, :ref:`soffset<amdgpu_synid_gfx11_soffset_fef808>` :ref:`idxen<amdgpu_synid_idxen>` :ref:`offen<amdgpu_synid_offen>` :ref:`offset12<amdgpu_synid_buf_offset12>` :ref:`glc<amdgpu_synid_glc>` :ref:`slc<amdgpu_synid_slc>` :ref:`dlc<amdgpu_synid_dlc>` :ref:`tfe<amdgpu_synid_tfe>`
buffer_load_i16 :ref:`vdst<amdgpu_synid_gfx11_vdst_5d50a1>`, :ref:`vaddr<amdgpu_synid_gfx11_vaddr_b73dc0>`, :ref:`srsrc<amdgpu_synid_gfx11_srsrc_80eef6>`, :ref:`soffset<amdgpu_synid_gfx11_soffset_fef808>` :ref:`idxen<amdgpu_synid_idxen>` :ref:`offen<amdgpu_synid_offen>` :ref:`offset12<amdgpu_synid_buf_offset12>` :ref:`glc<amdgpu_synid_glc>` :ref:`slc<amdgpu_synid_slc>` :ref:`dlc<amdgpu_synid_dlc>` :ref:`tfe<amdgpu_synid_tfe>`
buffer_load_i8 :ref:`vdst<amdgpu_synid_gfx11_vdst_5d50a1>`, :ref:`vaddr<amdgpu_synid_gfx11_vaddr_b73dc0>`, :ref:`srsrc<amdgpu_synid_gfx11_srsrc_80eef6>`, :ref:`soffset<amdgpu_synid_gfx11_soffset_fef808>` :ref:`idxen<amdgpu_synid_idxen>` :ref:`offen<amdgpu_synid_offen>` :ref:`offset12<amdgpu_synid_buf_offset12>` :ref:`glc<amdgpu_synid_glc>` :ref:`slc<amdgpu_synid_slc>` :ref:`dlc<amdgpu_synid_dlc>` :ref:`tfe<amdgpu_synid_tfe>`
buffer_load_lds_b32 :ref:`vaddr<amdgpu_synid_gfx11_vaddr_b73dc0>`, :ref:`srsrc<amdgpu_synid_gfx11_srsrc_80eef6>`, :ref:`soffset<amdgpu_synid_gfx11_soffset_fef808>` :ref:`idxen<amdgpu_synid_idxen>` :ref:`offen<amdgpu_synid_offen>` :ref:`offset12<amdgpu_synid_buf_offset12>` :ref:`glc<amdgpu_synid_glc>` :ref:`slc<amdgpu_synid_slc>` :ref:`dlc<amdgpu_synid_dlc>`
buffer_load_lds_format_x :ref:`vaddr<amdgpu_synid_gfx11_vaddr_b73dc0>`, :ref:`srsrc<amdgpu_synid_gfx11_srsrc_80eef6>`, :ref:`soffset<amdgpu_synid_gfx11_soffset_fef808>` :ref:`idxen<amdgpu_synid_idxen>` :ref:`offen<amdgpu_synid_offen>` :ref:`offset12<amdgpu_synid_buf_offset12>` :ref:`glc<amdgpu_synid_glc>` :ref:`slc<amdgpu_synid_slc>` :ref:`dlc<amdgpu_synid_dlc>`
buffer_load_lds_i16 :ref:`vaddr<amdgpu_synid_gfx11_vaddr_b73dc0>`, :ref:`srsrc<amdgpu_synid_gfx11_srsrc_80eef6>`, :ref:`soffset<amdgpu_synid_gfx11_soffset_fef808>` :ref:`idxen<amdgpu_synid_idxen>` :ref:`offen<amdgpu_synid_offen>` :ref:`offset12<amdgpu_synid_buf_offset12>` :ref:`glc<amdgpu_synid_glc>` :ref:`slc<amdgpu_synid_slc>` :ref:`dlc<amdgpu_synid_dlc>`
buffer_load_lds_i8 :ref:`vaddr<amdgpu_synid_gfx11_vaddr_b73dc0>`, :ref:`srsrc<amdgpu_synid_gfx11_srsrc_80eef6>`, :ref:`soffset<amdgpu_synid_gfx11_soffset_fef808>` :ref:`idxen<amdgpu_synid_idxen>` :ref:`offen<amdgpu_synid_offen>` :ref:`offset12<amdgpu_synid_buf_offset12>` :ref:`glc<amdgpu_synid_glc>` :ref:`slc<amdgpu_synid_slc>` :ref:`dlc<amdgpu_synid_dlc>`
buffer_load_lds_u16 :ref:`vaddr<amdgpu_synid_gfx11_vaddr_b73dc0>`, :ref:`srsrc<amdgpu_synid_gfx11_srsrc_80eef6>`, :ref:`soffset<amdgpu_synid_gfx11_soffset_fef808>` :ref:`idxen<amdgpu_synid_idxen>` :ref:`offen<amdgpu_synid_offen>` :ref:`offset12<amdgpu_synid_buf_offset12>` :ref:`glc<amdgpu_synid_glc>` :ref:`slc<amdgpu_synid_slc>` :ref:`dlc<amdgpu_synid_dlc>`
buffer_load_lds_u8 :ref:`vaddr<amdgpu_synid_gfx11_vaddr_b73dc0>`, :ref:`srsrc<amdgpu_synid_gfx11_srsrc_80eef6>`, :ref:`soffset<amdgpu_synid_gfx11_soffset_fef808>` :ref:`idxen<amdgpu_synid_idxen>` :ref:`offen<amdgpu_synid_offen>` :ref:`offset12<amdgpu_synid_buf_offset12>` :ref:`glc<amdgpu_synid_glc>` :ref:`slc<amdgpu_synid_slc>` :ref:`dlc<amdgpu_synid_dlc>`
buffer_load_sbyte :ref:`vdst<amdgpu_synid_gfx11_vdst_5d50a1>`, :ref:`vaddr<amdgpu_synid_gfx11_vaddr_b73dc0>`, :ref:`srsrc<amdgpu_synid_gfx11_srsrc_80eef6>`, :ref:`soffset<amdgpu_synid_gfx11_soffset_fef808>` :ref:`idxen<amdgpu_synid_idxen>` :ref:`offen<amdgpu_synid_offen>` :ref:`offset12<amdgpu_synid_buf_offset12>` :ref:`glc<amdgpu_synid_glc>` :ref:`slc<amdgpu_synid_slc>` :ref:`dlc<amdgpu_synid_dlc>` :ref:`tfe<amdgpu_synid_tfe>`
buffer_load_sbyte_d16 :ref:`vdst<amdgpu_synid_gfx11_vdst_5d50a1>`, :ref:`vaddr<amdgpu_synid_gfx11_vaddr_b73dc0>`, :ref:`srsrc<amdgpu_synid_gfx11_srsrc_80eef6>`, :ref:`soffset<amdgpu_synid_gfx11_soffset_fef808>` :ref:`idxen<amdgpu_synid_idxen>` :ref:`offen<amdgpu_synid_offen>` :ref:`offset12<amdgpu_synid_buf_offset12>` :ref:`glc<amdgpu_synid_glc>` :ref:`slc<amdgpu_synid_slc>` :ref:`dlc<amdgpu_synid_dlc>` :ref:`tfe<amdgpu_synid_tfe>`
buffer_load_sbyte_d16_hi :ref:`vdst<amdgpu_synid_gfx11_vdst_5d50a1>`, :ref:`vaddr<amdgpu_synid_gfx11_vaddr_b73dc0>`, :ref:`srsrc<amdgpu_synid_gfx11_srsrc_80eef6>`, :ref:`soffset<amdgpu_synid_gfx11_soffset_fef808>` :ref:`idxen<amdgpu_synid_idxen>` :ref:`offen<amdgpu_synid_offen>` :ref:`offset12<amdgpu_synid_buf_offset12>` :ref:`glc<amdgpu_synid_glc>` :ref:`slc<amdgpu_synid_slc>` :ref:`dlc<amdgpu_synid_dlc>` :ref:`tfe<amdgpu_synid_tfe>`
File diff suppressed because it is too large Load Diff
@@ -6,7 +6,7 @@
**************************************************
====================================================================================
Syntax of gfx940 Instructions
Syntax of gfx942 Instructions
====================================================================================
.. contents::
@@ -15,7 +15,7 @@ Syntax of gfx940 Instructions
Introduction
============
This document describes the syntax of gfx940 instructions.
This document describes the syntax of gfx942 instructions.
Notation
========
+15
View File
@@ -0,0 +1,15 @@
..
**************************************************
* *
* Automatically generated file, do not edit! *
* *
**************************************************
.. _amdgpu_synid_gfx12_addr:
addr
====
*Size:* 1 dword.
*Operands:* :ref:`v<amdgpu_synid_v>`
+28
View File
@@ -0,0 +1,28 @@
..
**************************************************
* *
* Automatically generated file, do not edit! *
* *
**************************************************
.. _amdgpu_synid_gfx12_attr:
attr
====
Interpolation attribute and channel:
============== ===================================
Syntax Description
============== ===================================
attr{0..32}.x Attribute 0..32 with *x* channel.
attr{0..32}.y Attribute 0..32 with *y* channel.
attr{0..32}.z Attribute 0..32 with *z* channel.
attr{0..32}.w Attribute 0..32 with *w* channel.
============== ===================================
Examples:
.. parsed-literal::
ds_param_load v1, attr0.x
@@ -0,0 +1,7 @@
.. _amdgpu_synid_clause:
clause
======
Description of a clause following this instruction.
@@ -0,0 +1,17 @@
..
**************************************************
* *
* Automatically generated file, do not edit! *
* *
**************************************************
.. _amdgpu_synid_gfx12_data0_56f215:
data0
=====
Instruction input.
*Size:* 3 dwords.
*Operands:* :ref:`v<amdgpu_synid_v>`
@@ -0,0 +1,17 @@
..
**************************************************
* *
* Automatically generated file, do not edit! *
* *
**************************************************
.. _amdgpu_synid_gfx12_data0_6802ce:
data0
=====
Instruction input.
*Size:* 1 dword.
*Operands:* :ref:`v<amdgpu_synid_v>`
@@ -0,0 +1,17 @@
..
**************************************************
* *
* Automatically generated file, do not edit! *
* *
**************************************************
.. _amdgpu_synid_gfx12_data0_e016a1:
data0
=====
Instruction input.
*Size:* 4 dwords.
*Operands:* :ref:`v<amdgpu_synid_v>`
@@ -0,0 +1,17 @@
..
**************************************************
* *
* Automatically generated file, do not edit! *
* *
**************************************************
.. _amdgpu_synid_gfx12_data0_fd235e:
data0
=====
Instruction input.
*Size:* 2 dwords.
*Operands:* :ref:`v<amdgpu_synid_v>`
@@ -0,0 +1,17 @@
..
**************************************************
* *
* Automatically generated file, do not edit! *
* *
**************************************************
.. _amdgpu_synid_gfx12_data1_6802ce:
data1
=====
Instruction input.
*Size:* 1 dword.
*Operands:* :ref:`v<amdgpu_synid_v>`
@@ -0,0 +1,17 @@
..
**************************************************
* *
* Automatically generated file, do not edit! *
* *
**************************************************
.. _amdgpu_synid_gfx12_data1_731030:
data1
=====
Instruction input.
*Size:* 8 dwords.
*Operands:* :ref:`v<amdgpu_synid_v>`
@@ -0,0 +1,17 @@
..
**************************************************
* *
* Automatically generated file, do not edit! *
* *
**************************************************
.. _amdgpu_synid_gfx12_data1_e016a1:
data1
=====
Instruction input.
*Size:* 4 dwords.
*Operands:* :ref:`v<amdgpu_synid_v>`
@@ -0,0 +1,17 @@
..
**************************************************
* *
* Automatically generated file, do not edit! *
* *
**************************************************
.. _amdgpu_synid_gfx12_data1_fd235e:
data1
=====
Instruction input.
*Size:* 2 dwords.
*Operands:* :ref:`v<amdgpu_synid_v>`
+74
View File
@@ -0,0 +1,74 @@
.. _amdgpu_synid_delay:
delay
=====
A delay between dependent SALU/VALU instructions.
This operand may specify a delay for 2 instructions:
the one after the current *s_delay_alu* instruction
and for the second instruction indicated by *SKIP*.
The bits of this operand have the following meaning:
===== ========================================================== ============
Bits Description Value Range
===== ========================================================== ============
3:0 ID0: indicates a delay for the first instruction. 0..11
6:4 SKIP: indicates the position of the second instruction. 0..5
10:7 ID1: indicates a delay for the second instruction. 0..11
===== ========================================================== ============
This operand may be specified as one of the following:
* An :ref:`integer_number<amdgpu_synid_integer_number>` or an :ref:`absolute_expression<amdgpu_synid_absolute_expression>`. The value must be in the range 0..0xFFFF.
* A combination of *instid0*, *instskip*, *instid1* values described below.
======================== =========================== ===============
Syntax Description Default Value
======================== =========================== ===============
instid0(<*ID name*>) A symbolic *ID0* value. instid0(NO_DEP)
instskip(<*SKIP name*>) A symbolic *SKIP* value. instskip(SAME)
instid1(<*ID name*>) A symbolic *ID1* value. instid1(NO_DEP)
======================== =========================== ===============
These values may be specified in any order.
When more than one value is specified, the values must be separated from each other by a '|'.
Valid *ID names* are defined below.
=================== ===================================================================
Name Description
=================== ===================================================================
NO_DEP No dependency on any prior instruction. This is the default value.
VALU_DEP_1 Dependency on a previous VALU instruction, 1 opcode back.
VALU_DEP_2 Dependency on a previous VALU instruction, 2 opcodes back.
VALU_DEP_3 Dependency on a previous VALU instruction, 3 opcodes back.
VALU_DEP_4 Dependency on a previous VALU instruction, 4 opcodes back.
TRANS32_DEP_1 Dependency on a previous TRANS32 instruction, 1 opcode back.
TRANS32_DEP_2 Dependency on a previous TRANS32 instruction, 2 opcodes back.
TRANS32_DEP_3 Dependency on a previous TRANS32 instruction, 3 opcodes back.
FMA_ACCUM_CYCLE_1 Single cycle penalty for FMA accumulation.
SALU_CYCLE_1 1 cycle penalty for a prior SALU instruction.
SALU_CYCLE_2 2 cycle penalty for a prior SALU instruction.
SALU_CYCLE_3 3 cycle penalty for a prior SALU instruction.
=================== ===================================================================
Legal *SKIP names* are described in the following table.
======== ============================================================================
Name Description
======== ============================================================================
SAME Apply second dependency to the same instruction. This is the default value.
NEXT Apply second dependency to the next instruction.
SKIP_1 Skip 1 instruction then apply dependency.
SKIP_2 Skip 2 instructions then apply dependency.
SKIP_3 Skip 3 instructions then apply dependency.
SKIP_4 Skip 4 instructions then apply dependency.
======== ============================================================================
Examples:
.. parsed-literal::
s_delay_alu instid0(VALU_DEP_1)
s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
+76
View File
@@ -0,0 +1,76 @@
..
**************************************************
* *
* Automatically generated file, do not edit! *
* *
**************************************************
.. _amdgpu_synid_hwreg:
hwreg
=====
Bits of a hardware register being accessed.
The bits of this operand have the following meaning:
======= ===================== ============
Bits Description Value Range
======= ===================== ============
5:0 Register *id*. 0..63
10:6 First bit *offset*. 0..31
15:11 *Size* in bits. 1..32
======= ===================== ============
This operand may be specified as one of the following:
* An :ref:`integer_number<amdgpu_synid_integer_number>` or an :ref:`absolute_expression<amdgpu_synid_absolute_expression>`. The value must be in the range 0..0xFFFF.
* An *hwreg* value described below.
==================================== ============================================================================
Hwreg Value Syntax Description
==================================== ============================================================================
hwreg({0..63}) All bits of a register indicated by its *id*.
hwreg(<*name*>) All bits of a register indicated by its *name*.
hwreg({0..63}, {0..31}, {1..32}) Register bits indicated by register *id*, first bit *offset* and *size*.
hwreg(<*name*>, {0..31}, {1..32}) Register bits indicated by register *name*, first bit *offset* and *size*.
==================================== ============================================================================
Numeric values may be specified as positive :ref:`integer numbers<amdgpu_synid_integer_number>`
or :ref:`absolute expressions<amdgpu_synid_absolute_expression>`.
Defined register *names* include:
=================== ==========================================
Name Description
=================== ==========================================
HW_REG_MODE Shader writeable mode bits.
HW_REG_STATUS Shader read-only status.
HW_REG_TRAPSTS Trap status.
HW_REG_HW_ID1 Id of wave, simd, compute unit, etc.
HW_REG_HW_ID2 Id of queue, pipeline, etc.
HW_REG_GPR_ALLOC Per-wave SGPR and VGPR allocation.
HW_REG_LDS_ALLOC Per-wave LDS allocation.
HW_REG_IB_STS Counters of outstanding instructions.
HW_REG_SH_MEM_BASES Memory aperture.
HW_REG_FLAT_SCR_LO flat_scratch_lo register.
HW_REG_FLAT_SCR_HI flat_scratch_hi register.
=================== ==========================================
Examples:
.. parsed-literal::
reg = 1
offset = 2
size = 4
hwreg_enc = reg | (offset << 6) | ((size - 1) << 11)
s_getreg_b32 s2, 0x1881
s_getreg_b32 s2, hwreg_enc // the same as above
s_getreg_b32 s2, hwreg(1, 2, 4) // the same as above
s_getreg_b32 s2, hwreg(reg, offset, size) // the same as above
s_getreg_b32 s2, hwreg(15)
s_getreg_b32 s2, hwreg(51, 1, 31)
s_getreg_b32 s2, hwreg(HW_REG_LDS_ALLOC, 0, 1)
@@ -0,0 +1,7 @@
.. _amdgpu_synid_imm16:
imm16
======
An :ref:`integer_number<amdgpu_synid_integer_number>` or an :ref:`absolute_expression<amdgpu_synid_absolute_expression>`. The value must be in the range -32768..65535.
@@ -0,0 +1,15 @@
..
**************************************************
* *
* Automatically generated file, do not edit! *
* *
**************************************************
.. _amdgpu_synid_gfx12_ioffset:
ioffset
=======
*Size:* 1 dword.
*Operands:*
+29
View File
@@ -0,0 +1,29 @@
.. _amdgpu_synid_label:
label
=====
A branch target which is a 16-bit signed integer treated as a PC-relative dword offset.
This operand may be specified as one of the following:
* An :ref:`integer_number<amdgpu_synid_integer_number>` or an :ref:`absolute_expression<amdgpu_synid_absolute_expression>`. The value must be in the range -32768..65535.
* A :ref:`symbol<amdgpu_synid_symbol>` (for example, a label) representing a relocatable address in the same compilation unit where it is referred from. The value is handled as a 16-bit PC-relative dword offset to be resolved by a linker.
Examples:
.. parsed-literal::
offset = 30
label_1:
label_2 = . + 4
s_branch 32
s_branch offset + 2
s_branch label_1
s_branch label_2
s_branch label_3
s_branch label_4
label_3 = label_2 + 4
label_4:
@@ -0,0 +1,15 @@
..
**************************************************
* *
* Automatically generated file, do not edit! *
* *
**************************************************
.. _amdgpu_synid_gfx12_literal_1f74c7:
literal
=======
*Size:* 2 dwords.
*Operands:*
@@ -0,0 +1,15 @@
..
**************************************************
* *
* Automatically generated file, do not edit! *
* *
**************************************************
.. _amdgpu_synid_gfx12_literal_81e671:
literal
=======
*Size:* 1 dword.
*Operands:*
+13
View File
@@ -0,0 +1,13 @@
..
**************************************************
* *
* Automatically generated file, do not edit! *
* *
**************************************************
.. _amdgpu_synid_gfx12_m:
m
=
This operand may be used with floating point operand modifiers :ref:`abs<amdgpu_synid_abs>` and :ref:`neg<amdgpu_synid_neg>`.
@@ -0,0 +1,17 @@
..
**************************************************
* *
* Automatically generated file, do not edit! *
* *
**************************************************
.. _amdgpu_synid_gfx12_rsrc_5fe6d8:
rsrc
====
Instruction input.
*Size:* 4 dwords.
*Operands:* :ref:`s<amdgpu_synid_s>`, :ref:`ttmp<amdgpu_synid_ttmp>`, :ref:`null<amdgpu_synid_null>`
@@ -0,0 +1,17 @@
..
**************************************************
* *
* Automatically generated file, do not edit! *
* *
**************************************************
.. _amdgpu_synid_gfx12_rsrc_c9f929:
rsrc
====
Instruction input.
*Size:* 8 dwords.
*Operands:* :ref:`s<amdgpu_synid_s>`, :ref:`ttmp<amdgpu_synid_ttmp>`, :ref:`null<amdgpu_synid_null>`
@@ -0,0 +1,15 @@
..
**************************************************
* *
* Automatically generated file, do not edit! *
* *
**************************************************
.. _amdgpu_synid_gfx12_saddr_cdc95c:
saddr
=====
*Size:* 2 dwords.
*Operands:* :ref:`s<amdgpu_synid_s>`, :ref:`ttmp<amdgpu_synid_ttmp>`, :ref:`null<amdgpu_synid_null>`
@@ -0,0 +1,15 @@
..
**************************************************
* *
* Automatically generated file, do not edit! *
* *
**************************************************
.. _amdgpu_synid_gfx12_saddr_d42b64:
saddr
=====
*Size:* 1 dword.
*Operands:* :ref:`s<amdgpu_synid_s>`, :ref:`ttmp<amdgpu_synid_ttmp>`, :ref:`null<amdgpu_synid_null>`, :ref:`vcc_hi<amdgpu_synid_vcc_hi>`, :ref:`vcc_lo<amdgpu_synid_vcc_lo>`
+15
View File
@@ -0,0 +1,15 @@
..
**************************************************
* *
* Automatically generated file, do not edit! *
* *
**************************************************
.. _amdgpu_synid_gfx12_samp:
samp
====
*Size:* 4 dwords.
*Operands:* :ref:`s<amdgpu_synid_s>`, :ref:`ttmp<amdgpu_synid_ttmp>`, :ref:`null<amdgpu_synid_null>`
@@ -0,0 +1,17 @@
..
**************************************************
* *
* Automatically generated file, do not edit! *
* *
**************************************************
.. _amdgpu_synid_gfx12_sbase_453b95:
sbase
=====
A 128-bit buffer resource constant for scalar memory operations which provides a base address, a size and a stride.
*Size:* 4 dwords.
*Operands:* :ref:`s<amdgpu_synid_s>`, :ref:`ttmp<amdgpu_synid_ttmp>`, :ref:`null<amdgpu_synid_null>`
@@ -0,0 +1,17 @@
..
**************************************************
* *
* Automatically generated file, do not edit! *
* *
**************************************************
.. _amdgpu_synid_gfx12_sbase_47adb7:
sbase
=====
A 64-bit base address for scalar memory operations.
*Size:* 2 dwords.
*Operands:* :ref:`s<amdgpu_synid_s>`, :ref:`ttmp<amdgpu_synid_ttmp>`, :ref:`null<amdgpu_synid_null>`
@@ -0,0 +1,17 @@
..
**************************************************
* *
* Automatically generated file, do not edit! *
* *
**************************************************
.. _amdgpu_synid_gfx12_sdata_0974a4:
sdata
=====
Instruction output.
*Size:* 8 dwords.
*Operands:* :ref:`s<amdgpu_synid_s>`, :ref:`ttmp<amdgpu_synid_ttmp>`, :ref:`null<amdgpu_synid_null>`
@@ -0,0 +1,17 @@
..
**************************************************
* *
* Automatically generated file, do not edit! *
* *
**************************************************
.. _amdgpu_synid_gfx12_sdata_354189:
sdata
=====
Instruction output.
*Size:* 2 dwords.
*Operands:* :ref:`s<amdgpu_synid_s>`, :ref:`ttmp<amdgpu_synid_ttmp>`, :ref:`null<amdgpu_synid_null>`
@@ -0,0 +1,17 @@
..
**************************************************
* *
* Automatically generated file, do not edit! *
* *
**************************************************
.. _amdgpu_synid_gfx12_sdata_4585b8:
sdata
=====
Instruction output.
*Size:* 4 dwords.
*Operands:* :ref:`s<amdgpu_synid_s>`, :ref:`ttmp<amdgpu_synid_ttmp>`, :ref:`null<amdgpu_synid_null>`
@@ -0,0 +1,17 @@
..
**************************************************
* *
* Automatically generated file, do not edit! *
* *
**************************************************
.. _amdgpu_synid_gfx12_sdata_5c7b50:
sdata
=====
Instruction input.
*Size:* 1 dword.
*Operands:*
@@ -0,0 +1,17 @@
..
**************************************************
* *
* Automatically generated file, do not edit! *
* *
**************************************************
.. _amdgpu_synid_gfx12_sdata_6c003b:
sdata
=====
Instruction output.
*Size:* 16 dwords.
*Operands:* :ref:`s<amdgpu_synid_s>`, :ref:`ttmp<amdgpu_synid_ttmp>`, :ref:`null<amdgpu_synid_null>`
@@ -0,0 +1,17 @@
..
**************************************************
* *
* Automatically generated file, do not edit! *
* *
**************************************************
.. _amdgpu_synid_gfx12_sdata_836716:
sdata
=====
Instruction output.
*Size:* 1 dword.
*Operands:* :ref:`s<amdgpu_synid_s>`, :ref:`ttmp<amdgpu_synid_ttmp>`, :ref:`null<amdgpu_synid_null>`, :ref:`vcc_hi<amdgpu_synid_vcc_hi>`, :ref:`vcc_lo<amdgpu_synid_vcc_lo>`
@@ -0,0 +1,17 @@
..
**************************************************
* *
* Automatically generated file, do not edit! *
* *
**************************************************
.. _amdgpu_synid_gfx12_sdata_d725ab:
sdata
=====
Instruction output.
*Size:* 1 dword.
*Operands:* :ref:`simm8<amdgpu_synid_simm8>`
@@ -0,0 +1,17 @@
..
**************************************************
* *
* Automatically generated file, do not edit! *
* *
**************************************************
.. _amdgpu_synid_gfx12_sdata_dd9dd8:
sdata
=====
Instruction output.
*Size:* 3 dwords.
*Operands:* :ref:`s<amdgpu_synid_s>`, :ref:`ttmp<amdgpu_synid_ttmp>`, :ref:`null<amdgpu_synid_null>`
@@ -0,0 +1,17 @@
..
**************************************************
* *
* Automatically generated file, do not edit! *
* *
**************************************************
.. _amdgpu_synid_gfx12_sdst_006c40:
sdst
====
Instruction output.
*Size:* 2 dwords.
*Operands:* :ref:`vcc<amdgpu_synid_vcc>`
@@ -0,0 +1,15 @@
..
**************************************************
* *
* Automatically generated file, do not edit! *
* *
**************************************************
.. _amdgpu_synid_gfx12_sdst_20064d:
sdst
====
*Size:* 1 dword.
*Operands:* :ref:`s<amdgpu_synid_s>`, :ref:`ttmp<amdgpu_synid_ttmp>`, :ref:`null<amdgpu_synid_null>`, :ref:`m0<amdgpu_synid_m0>`, :ref:`exec_hi<amdgpu_synid_exec_hi>`, :ref:`exec_lo<amdgpu_synid_exec_lo>`, :ref:`vcc_hi<amdgpu_synid_vcc_hi>`, :ref:`vcc_lo<amdgpu_synid_vcc_lo>`
@@ -0,0 +1,17 @@
..
**************************************************
* *
* Automatically generated file, do not edit! *
* *
**************************************************
.. _amdgpu_synid_gfx12_sdst_354189:
sdst
====
Instruction output.
*Size:* 2 dwords.
*Operands:* :ref:`s<amdgpu_synid_s>`, :ref:`ttmp<amdgpu_synid_ttmp>`, :ref:`null<amdgpu_synid_null>`
@@ -0,0 +1,17 @@
..
**************************************************
* *
* Automatically generated file, do not edit! *
* *
**************************************************
.. _amdgpu_synid_gfx12_sdst_836716:
sdst
====
Instruction output.
*Size:* 1 dword.
*Operands:* :ref:`s<amdgpu_synid_s>`, :ref:`ttmp<amdgpu_synid_ttmp>`, :ref:`null<amdgpu_synid_null>`, :ref:`vcc_hi<amdgpu_synid_vcc_hi>`, :ref:`vcc_lo<amdgpu_synid_vcc_lo>`
@@ -0,0 +1,17 @@
..
**************************************************
* *
* Automatically generated file, do not edit! *
* *
**************************************************
.. _amdgpu_synid_gfx12_sdst_ced58d:
sdst
====
Instruction output.
*Size:* 1 dword.
*Operands:* :ref:`s<amdgpu_synid_s>`, :ref:`ttmp<amdgpu_synid_ttmp>`, :ref:`null<amdgpu_synid_null>`, :ref:`m0<amdgpu_synid_m0>`, :ref:`exec_hi<amdgpu_synid_exec_hi>`, :ref:`exec_lo<amdgpu_synid_exec_lo>`, :ref:`vcc_hi<amdgpu_synid_vcc_hi>`, :ref:`vcc_lo<amdgpu_synid_vcc_lo>`
@@ -0,0 +1,17 @@
..
**************************************************
* *
* Automatically generated file, do not edit! *
* *
**************************************************
.. _amdgpu_synid_gfx12_sdst_e701cc:
sdst
====
Instruction output.
*Size:* 1 dword if wavefront size is 32, otherwise 2 dwords.
*Operands:* :ref:`s<amdgpu_synid_s>`, :ref:`ttmp<amdgpu_synid_ttmp>`, :ref:`null<amdgpu_synid_null>`
@@ -0,0 +1,48 @@
.. _amdgpu_synid_sendmsg:
sendmsg
=======
An 8-bit value in simm16[7:0] encodes the message type.
This operand may be specified as one of the following:
* An :ref:`integer_number<amdgpu_synid_integer_number>` or an :ref:`absolute_expression<amdgpu_synid_absolute_expression>`. The value must be in the range 0..0xFFFF.
* A *sendmsg* value described below.
==================================== ====================================================
Sendmsg Value Syntax Description
==================================== ====================================================
sendmsg(<*type*>) A message identified by its *type*.
==================================== ====================================================
*Type* may be specified using message *name* or message *id*.
Numeric values may be specified as positive :ref:`integer numbers<amdgpu_synid_integer_number>`
or :ref:`absolute expressions<amdgpu_synid_absolute_expression>`.
Only the following message types are valid.
====================== ===========
Message type simm16[7:0]
====================== ===========
Reserved 0
MSG_INTERRUPT 1
MSG_HS_TESSFACTOR 2
MSG_DEALLOC_VGPRS 3
MSG_GS_ALLOC_REQ 9
====================== ===========
Examples:
.. parsed-literal::
// numeric message code
msg = 0x1
s_sendmsg 0x3
s_sendmsg msg + 2
// sendmsg with strict arguments validation
s_sendmsg sendmsg(MSG_INTERRUPT)
@@ -0,0 +1,30 @@
.. _amdgpu_synid_sendmsg_rtn:
sendmsg_rtn
===========
An 8-bit value in the instruction to encode the message type.
This operand may be specified as one of the following:
* An :ref:`integer_number<amdgpu_synid_integer_number>` or an :ref:`absolute_expression<amdgpu_synid_absolute_expression>`. The value must be in the range 0..0xFFFF.
* A *sendmsg* value described below.
==================================== ====================================================
Sendmsg Value Syntax Description
==================================== ====================================================
sendmsg(MSG_RTN_GET_DOORBELL) Get doorbell ID.
sendmsg(MSG_RTN_GET_DDID) Get Draw/Dispatch ID.
sendmsg(MSG_RTN_GET_TMA) Get TMA value.
sendmsg(MSG_RTN_GET_TBA) Get TBA value.
sendmsg(MSG_RTN_GET_REALTIME) Get REALTIME value.
sendmsg(MSG_RTN_SAVE_WAVE) Report that this wave is ready to be context-saved.
==================================== ====================================================
Examples:
.. parsed-literal::
s_sendmsg_rtn_b32 s0, 132
s_sendmsg_rtn_b32 s0, sendmsg(MSG_GET_REALTIME)
@@ -0,0 +1,15 @@
..
**************************************************
* *
* Automatically generated file, do not edit! *
* *
**************************************************
.. _amdgpu_synid_gfx12_simm16_15ccdd:
simm16
======
*Size:* 1 dword.
*Operands:* :ref:`version<amdgpu_synid_version>`
@@ -0,0 +1,15 @@
..
**************************************************
* *
* Automatically generated file, do not edit! *
* *
**************************************************
.. _amdgpu_synid_gfx12_simm16_218bea:
simm16
======
*Size:* 1 dword.
*Operands:* :ref:`waitcnt<amdgpu_synid_waitcnt>`
@@ -0,0 +1,15 @@
..
**************************************************
* *
* Automatically generated file, do not edit! *
* *
**************************************************
.. _amdgpu_synid_gfx12_simm16_39b593:
simm16
======
*Size:* 1 dword.
*Operands:* :ref:`imm16<amdgpu_synid_imm16>`
@@ -0,0 +1,15 @@
..
**************************************************
* *
* Automatically generated file, do not edit! *
* *
**************************************************
.. _amdgpu_synid_gfx12_simm16_3d2a4f:
simm16
======
*Size:* 1 dword.
*Operands:* :ref:`label<amdgpu_synid_label>`
@@ -0,0 +1,15 @@
..
**************************************************
* *
* Automatically generated file, do not edit! *
* *
**************************************************
.. _amdgpu_synid_gfx12_simm16_730a13:
simm16
======
*Size:* 1 dword.
*Operands:* :ref:`clause<amdgpu_synid_clause>`
@@ -0,0 +1,15 @@
..
**************************************************
* *
* Automatically generated file, do not edit! *
* *
**************************************************
.. _amdgpu_synid_gfx12_simm16_7ed651:
simm16
======
*Size:* 1 dword.
*Operands:* :ref:`hwreg<amdgpu_synid_hwreg>`
@@ -0,0 +1,15 @@
..
**************************************************
* *
* Automatically generated file, do not edit! *
* *
**************************************************
.. _amdgpu_synid_gfx12_simm16_81e671:
simm16
======
*Size:* 1 dword.
*Operands:*
@@ -0,0 +1,15 @@
..
**************************************************
* *
* Automatically generated file, do not edit! *
* *
**************************************************
.. _amdgpu_synid_gfx12_simm16_c98889:
simm16
======
*Size:* 1 dword.
*Operands:* :ref:`delay<amdgpu_synid_delay>`

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