diff options
author | Stephen Hines <srhines@google.com> | 2014-12-01 14:51:49 -0800 |
---|---|---|
committer | Stephen Hines <srhines@google.com> | 2014-12-02 16:08:10 -0800 |
commit | 37ed9c199ca639565f6ce88105f9e39e898d82d0 (patch) | |
tree | 8fb36d3910e3ee4c4e1b7422f4f017108efc52f5 /docs | |
parent | d2327b22152ced7bc46dc629fc908959e8a52d03 (diff) | |
download | external_llvm-37ed9c199ca639565f6ce88105f9e39e898d82d0.zip external_llvm-37ed9c199ca639565f6ce88105f9e39e898d82d0.tar.gz external_llvm-37ed9c199ca639565f6ce88105f9e39e898d82d0.tar.bz2 |
Update aosp/master LLVM for rebase to r222494.
Change-Id: Ic787f5e0124df789bd26f3f24680f45e678eef2d
Diffstat (limited to 'docs')
42 files changed, 1865 insertions, 1041 deletions
diff --git a/docs/Atomics.rst b/docs/Atomics.rst index 5f17c61..6c8303b 100644 --- a/docs/Atomics.rst +++ b/docs/Atomics.rst @@ -18,16 +18,16 @@ clarified in the IR. The atomic instructions are designed specifically to provide readable IR and optimized code generation for the following: -* The new C++0x ``<atomic>`` header. (`C++0x draft available here - <http://www.open-std.org/jtc1/sc22/wg21/>`_.) (`C1x draft available here +* The new C++11 ``<atomic>`` header. (`C++11 draft available here + <http://www.open-std.org/jtc1/sc22/wg21/>`_.) (`C11 draft available here <http://www.open-std.org/jtc1/sc22/wg14/>`_.) * Proper semantics for Java-style memory, for both ``volatile`` and regular shared variables. (`Java Specification - <http://java.sun.com/docs/books/jls/third_edition/html/memory.html>`_) + <http://docs.oracle.com/javase/specs/jls/se8/html/jls-17.html>`_) * gcc-compatible ``__sync_*`` builtins. (`Description - <http://gcc.gnu.org/onlinedocs/gcc/Atomic-Builtins.html>`_) + <https://gcc.gnu.org/onlinedocs/gcc/_005f_005fsync-Builtins.html>`_) * Other scenarios with atomic semantics, including ``static`` variables with non-trivial constructors in C++. @@ -115,7 +115,10 @@ memory operation can happen on any thread between the load and store. A ``fence`` provides Acquire and/or Release ordering which is not part of another operation; it is normally used along with Monotonic memory operations. A Monotonic load followed by an Acquire fence is roughly equivalent to an -Acquire load. +Acquire load, and a Monotonic store following a Release fence is roughly +equivalent to a Release store. SequentiallyConsistent fences behave as both +an Acquire and a Release fence, and offer some additional complicated +guarantees, see the C++11 standard for details. Frontends generating atomic instructions generally need to be aware of the target to some degree; atomic instructions are guaranteed to be lock-free, and @@ -177,10 +180,10 @@ Unordered Unordered is the lowest level of atomicity. It essentially guarantees that races produce somewhat sane results instead of having undefined behavior. It also -guarantees the operation to be lock-free, so it do not depend on the data being -part of a special atomic structure or depend on a separate per-process global -lock. Note that code generation will fail for unsupported atomic operations; if -you need such an operation, use explicit locking. +guarantees the operation to be lock-free, so it does not depend on the data +being part of a special atomic structure or depend on a separate per-process +global lock. Note that code generation will fail for unsupported atomic +operations; if you need such an operation, use explicit locking. Relevant standard This is intended to match the Java memory model for shared variables. @@ -221,7 +224,7 @@ essentially guarantees that if you take all the operations affecting a specific address, a consistent ordering exists. Relevant standard - This corresponds to the C++0x/C1x ``memory_order_relaxed``; see those + This corresponds to the C++11/C11 ``memory_order_relaxed``; see those standards for the exact definition. Notes for frontends @@ -251,8 +254,8 @@ Acquire provides a barrier of the sort necessary to acquire a lock to access other memory with normal loads and stores. Relevant standard - This corresponds to the C++0x/C1x ``memory_order_acquire``. It should also be - used for C++0x/C1x ``memory_order_consume``. + This corresponds to the C++11/C11 ``memory_order_acquire``. It should also be + used for C++11/C11 ``memory_order_consume``. Notes for frontends If you are writing a frontend which uses this directly, use with caution. @@ -281,7 +284,7 @@ Release is similar to Acquire, but with a barrier of the sort necessary to release a lock. Relevant standard - This corresponds to the C++0x/C1x ``memory_order_release``. + This corresponds to the C++11/C11 ``memory_order_release``. Notes for frontends If you are writing a frontend which uses this directly, use with caution. @@ -307,7 +310,7 @@ AcquireRelease (``acq_rel`` in IR) provides both an Acquire and a Release barrier (for fences and operations which both read and write memory). Relevant standard - This corresponds to the C++0x/C1x ``memory_order_acq_rel``. + This corresponds to the C++11/C11 ``memory_order_acq_rel``. Notes for frontends If you are writing a frontend which uses this directly, use with caution. @@ -330,7 +333,7 @@ and Release semantics for stores. Additionally, it guarantees that a total ordering exists between all SequentiallyConsistent operations. Relevant standard - This corresponds to the C++0x/C1x ``memory_order_seq_cst``, Java volatile, and + This corresponds to the C++11/C11 ``memory_order_seq_cst``, Java volatile, and the gcc-compatible ``__sync_*`` builtins which do not specify otherwise. Notes for frontends @@ -368,6 +371,11 @@ Predicates for optimizer writers to query: that they return true for any operation which is volatile or at least Monotonic. +* ``isAtLeastAcquire()``/``isAtLeastRelease()``: These are predicates on + orderings. They can be useful for passes that are aware of atomics, for + example to do DSE across a single atomic access, but not across a + release-acquire pair (see MemoryDependencyAnalysis for an example of this) + * Alias analysis: Note that AA will return ModRef for anything Acquire or Release, and for the address accessed by any Monotonic operation. @@ -389,7 +397,9 @@ operations: * DSE: Unordered stores can be DSE'ed like normal stores. Monotonic stores can be DSE'ed in some cases, but it's tricky to reason about, and not especially - important. + important. It is possible in some case for DSE to operate across a stronger + atomic operation, but it is fairly tricky. DSE delegates this reasoning to + MemoryDependencyAnalysis (which is also used by other passes like GVN). * Folding a load: Any atomic load from a constant global can be constant-folded, because it cannot be observed. Similar reasoning allows scalarrepl with @@ -400,7 +410,8 @@ Atomics and Codegen Atomic operations are represented in the SelectionDAG with ``ATOMIC_*`` opcodes. On architectures which use barrier instructions for all atomic ordering (like -ARM), appropriate fences are split out as the DAG is built. +ARM), appropriate fences can be emitted by the AtomicExpand Codegen pass if +``setInsertFencesForAtomic()`` was used. The MachineMemOperand for all atomic operations is currently marked as volatile; this is not correct in the IR sense of volatile, but CodeGen handles anything @@ -415,11 +426,6 @@ error when given an operation which cannot be implemented. (The LLVM code generator is not very helpful here at the moment, but hopefully that will change.) -The implementation of atomics on LL/SC architectures (like ARM) is currently a -bit of a mess; there is a lot of copy-pasted code across targets, and the -representation is relatively unsuited to optimization (it would be nice to be -able to optimize loops involving cmpxchg etc.). - On x86, all atomic loads generate a ``MOV``. SequentiallyConsistent stores generate an ``XCHG``, other stores generate a ``MOV``. SequentiallyConsistent fences generate an ``MFENCE``, other fences do not cause any code to be @@ -435,3 +441,19 @@ operation. Loads and stores generate normal instructions. ``cmpxchg`` and ``atomicrmw`` can be represented using a loop with LL/SC-style instructions which take some sort of exclusive lock on a cache line (``LDREX`` and ``STREX`` on ARM, etc.). + +It is often easiest for backends to use AtomicExpandPass to lower some of the +atomic constructs. Here are some lowerings it can do: + +* cmpxchg -> loop with load-linked/store-conditional + by overriding ``hasLoadLinkedStoreConditional()``, ``emitLoadLinked()``, + ``emitStoreConditional()`` +* large loads/stores -> ll-sc/cmpxchg + by overriding ``shouldExpandAtomicStoreInIR()``/``shouldExpandAtomicLoadInIR()`` +* strong atomic accesses -> monotonic accesses + fences + by using ``setInsertFencesForAtomic()`` and overriding ``emitLeadingFence()`` + and ``emitTrailingFence()`` +* atomic rmw -> loop with cmpxchg or load-linked/store-conditional + by overriding ``expandAtomicRMWInIR()`` + +For an example of all of these, look at the ARM backend. diff --git a/docs/BitCodeFormat.rst b/docs/BitCodeFormat.rst index fce1e37..34485b5 100644 --- a/docs/BitCodeFormat.rst +++ b/docs/BitCodeFormat.rst @@ -28,8 +28,9 @@ Unlike XML, the bitstream format is a binary encoding, and unlike XML it provides a mechanism for the file to self-describe "abbreviations", which are effectively size optimizations for the content. -LLVM IR files may be optionally embedded into a `wrapper`_ structure that makes -it easy to embed extra data along with LLVM IR files. +LLVM IR files may be optionally embedded into a `wrapper`_ structure, or in a +`native object file`_. Both of these mechanisms make it easy to embed extra +data along with LLVM IR files. This document first describes the LLVM bitstream format, describes the wrapper format, then describes the record structure used by LLVM IR files. @@ -460,6 +461,19 @@ to the start of the bitcode stream in the file, and the Size field is the size in bytes of the stream. CPUType is a target-specific value that can be used to encode the CPU of the target. +.. _native object file: + +Native Object File Wrapper Format +================================= + +Bitcode files for LLVM IR may also be wrapped in a native object file +(i.e. ELF, COFF, Mach-O). The bitcode must be stored in a section of the +object file named ``.llvmbc``. This wrapper format is useful for accommodating +LTO in compilation pipelines where intermediate objects must be native object +files which contain metadata in other sections. + +Not all tools support this format. + .. _encoding of LLVM IR: LLVM IR Encoding @@ -714,7 +728,7 @@ global variable. The operand fields are: * *unnamed_addr*: If present and non-zero, indicates that the variable has ``unnamed_addr`` -.. _dllstorageclass: +.. _bcdllstorageclass: * *dllstorageclass*: If present, an encoding of the DLL storage class of this variable: @@ -773,7 +787,8 @@ function. The operand fields are: * *prefix*: If non-zero, the value index of the prefix data for this function, plus 1. -* *dllstorageclass*: An encoding of the `dllstorageclass`_ of this function +* *dllstorageclass*: An encoding of the + :ref:`dllstorageclass<bcdllstorageclass>` of this function MODULE_CODE_ALIAS Record ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -791,7 +806,8 @@ fields are * *visibility*: If present, an encoding of the `visibility`_ of the alias -* *dllstorageclass*: If present, an encoding of the `dllstorageclass`_ of the alias +* *dllstorageclass*: If present, an encoding of the + :ref:`dllstorageclass<bcdllstorageclass>` of the alias MODULE_CODE_PURGEVALS Record ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/docs/CMake.rst b/docs/CMake.rst index bfc9cb9..653fa16 100644 --- a/docs/CMake.rst +++ b/docs/CMake.rst @@ -218,10 +218,18 @@ LLVM-specific variables Enables code assertions. Defaults to OFF if and only if ``CMAKE_BUILD_TYPE`` is *Release*. +**LLVM_ENABLE_EH**:BOOL + Build LLVM with exception handling support. This is necessary if you wish to + link against LLVM libraries and make use of C++ exceptions in your own code + that need to propagate through LLVM code. Defaults to OFF. + **LLVM_ENABLE_PIC**:BOOL Add the ``-fPIC`` flag for the compiler command-line, if the compiler supports this flag. Some systems, like Windows, do not need this flag. Defaults to ON. +**LLVM_ENABLE_RTTI**:BOOL + Build LLVM with run time type information. Defaults to OFF. + **LLVM_ENABLE_WARNINGS**:BOOL Enable all compiler warnings. Defaults to ON. @@ -280,8 +288,14 @@ LLVM-specific variables **LLVM_USE_SANITIZER**:STRING Define the sanitizer used to build LLVM binaries and tests. Possible values - are ``Address``, ``Memory`` and ``MemoryWithOrigins``. Defaults to empty - string. + are ``Address``, ``Memory``, ``MemoryWithOrigins`` and ``Undefined``. + Defaults to empty string. + +**LLVM_PARALLEL_COMPILE_JOBS**:STRING + Define the maximum number of concurrent compilation jobs. + +**LLVM_PARALLEL_LINK_JOBS**:STRING + Define the maximum number of concurrent link jobs. **LLVM_BUILD_DOCS**:BOOL Enables all enabled documentation targets (i.e. Doxgyen and Sphinx targets) to @@ -355,6 +369,10 @@ LLVM-specific variables is enabled). Currently the only target added is ``docs-llvm-man``. Defaults to ON. +**SPHINX_WARNINGS_AS_ERRORS**:BOOL + If enabled then sphinx documentation warnings will be treated as + errors. Defaults to ON. + Executing the test suite ======================== @@ -384,66 +402,112 @@ cross-compiling. Embedding LLVM in your project ============================== -The most difficult part of adding LLVM to the build of a project is to determine -the set of LLVM libraries corresponding to the set of required LLVM -features. What follows is an example of how to obtain this information: +From LLVM 3.5 onwards both the CMake and autoconf/Makefile build systems export +LLVM libraries as importable CMake targets. This means that clients of LLVM can +now reliably use CMake to develop their own LLVM based projects against an +installed version of LLVM regardless of how it was built. + +Here is a simple example of CMakeLists.txt file that imports the LLVM libraries +and uses them to build a simple application ``simple-tool``. .. code-block:: cmake - # A convenience variable: - set(LLVM_ROOT "" CACHE PATH "Root of LLVM install.") + cmake_minimum_required(VERSION 2.8.8) + project(SimpleProject) + + find_package(LLVM REQUIRED CONFIG) + + message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}") + message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}") - # A bit of a sanity check: - if( NOT EXISTS ${LLVM_ROOT}/include/llvm ) - message(FATAL_ERROR "LLVM_ROOT (${LLVM_ROOT}) is not a valid LLVM install") - endif() + # Set your project compile flags. + # E.g. if using the C++ header files + # you will need to enable C++11 support + # for your compiler. - # We incorporate the CMake features provided by LLVM: - set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${LLVM_ROOT}/share/llvm/cmake") - include(LLVMConfig) + include_directories(${LLVM_INCLUDE_DIRS}) + add_definitions(${LLVM_DEFINITIONS}) - # Now set the header and library paths: - include_directories( ${LLVM_INCLUDE_DIRS} ) - link_directories( ${LLVM_LIBRARY_DIRS} ) - add_definitions( ${LLVM_DEFINITIONS} ) + # Now build our tools + add_excutable(simple-tool tool.cpp) - # Let's suppose we want to build a JIT compiler with support for - # binary code (no interpreter): - llvm_map_components_to_libraries(REQ_LLVM_LIBRARIES jit native) + # Find the libraries that correspond to the LLVM components + # that we wish to use + llvm_map_components_to_libnames(llvm_libs support core irreader) - # Finally, we link the LLVM libraries to our executable: - target_link_libraries(mycompiler ${REQ_LLVM_LIBRARIES}) + # Link against LLVM libraries + target_link_libraries(simple-tool ${llvm_libs}) -This assumes that LLVM_ROOT points to an install of LLVM. The procedure works -too for uninstalled builds although we need to take care to add an -`include_directories` for the location of the headers on the LLVM source -directory (if we are building out-of-source.) +The ``find_package(...)`` directive when used in CONFIG mode (as in the above +example) will look for the ``LLVMConfig.cmake`` file in various locations (see +cmake manual for details). It creates a ``LLVM_DIR`` cache entry to save the +directory where ``LLVMConfig.cmake`` is found or allows the user to specify the +directory (e.g. by passing ``-DLLVM_DIR=/usr/share/llvm/cmake`` to +the ``cmake`` command or by setting it directly in ``ccmake`` or ``cmake-gui``). -Alternativaly, you can utilize CMake's ``find_package`` functionality. Here is -an equivalent variant of snippet shown above: +This file is available in two different locations. -.. code-block:: cmake +* ``<INSTALL_PREFIX>/share/llvm/cmake/LLVMConfig.cmake`` where + ``<INSTALL_PREFIX>`` is the install prefix of an installed version of LLVM. + On Linux typically this is ``/usr/share/llvm/cmake/LLVMConfig.cmake``. + +* ``<LLVM_BUILD_ROOT>/share/llvm/cmake/LLVMConfig.cmake`` where + ``<LLVM_BUILD_ROOT>`` is the root of the LLVM build tree. **Note this only + available when building LLVM with CMake** + +If LLVM is installed in your operating system's normal installation prefix (e.g. +on Linux this is usually ``/usr/``) ``find_package(LLVM ...)`` will +automatically find LLVM if it is installed correctly. If LLVM is not installed +or you wish to build directly against the LLVM build tree you can use +``LLVM_DIR`` as previously mentioned. + +The ``LLVMConfig.cmake`` file sets various useful variables. Notable variables +include + +``LLVM_CMAKE_DIR`` + The path to the LLVM CMake directory (i.e. the directory containing + LLVMConfig.cmake). + +``LLVM_DEFINITIONS`` + A list of preprocessor defines that should be used when building against LLVM. - find_package(LLVM) +``LLVM_ENABLE_ASSERTIONS`` + This is set to ON if LLVM was built with assertions, otherwise OFF. - if( NOT LLVM_FOUND ) - message(FATAL_ERROR "LLVM package can't be found. Set CMAKE_PREFIX_PATH variable to LLVM's installation prefix.") - endif() +``LLVM_ENABLE_EH`` + This is set to ON if LLVM was built with exception handling (EH) enabled, + otherwise OFF. - include_directories( ${LLVM_INCLUDE_DIRS} ) - link_directories( ${LLVM_LIBRARY_DIRS} ) +``LLVM_ENABLE_RTTI`` + This is set to ON if LLVM was built with run time type information (RTTI), + otherwise OFF. - llvm_map_components_to_libraries(REQ_LLVM_LIBRARIES jit native) +``LLVM_INCLUDE_DIRS`` + A list of include paths to directories containing LLVM header files. - target_link_libraries(mycompiler ${REQ_LLVM_LIBRARIES}) +``LLVM_PACKAGE_VERSION`` + The LLVM version. This string can be used with CMake conditionals. E.g. ``if + (${LLVM_PACKAGE_VERSION} VERSION_LESS "3.5")``. + +``LLVM_TOOLS_BINARY_DIR`` + The path to the directory containing the LLVM tools (e.g. ``llvm-as``). + +Notice that in the above example we link ``simple-tool`` against several LLVM +libraries. The list of libraries is determined by using the +``llvm_map_components_to_libnames()`` CMake function. For a list of available +components look at the output of running ``llvm-config --components``. + +Note that for LLVM < 3.5 ``llvm_map_components_to_libraries()`` was +used instead of ``llvm_map_components_to_libnames()``. This is now deprecated +and will be removed in a future version of LLVM. .. _cmake-out-of-source-pass: -Developing LLVM pass out of source ----------------------------------- +Developing LLVM passes out of source +------------------------------------ -It is possible to develop LLVM passes against installed LLVM. An example of -project layout provided below: +It is possible to develop LLVM passes out of LLVM's source tree (i.e. against an +installed or built LLVM). An example of a project layout is provided below. .. code-block:: none @@ -460,14 +524,10 @@ Contents of ``<project dir>/CMakeLists.txt``: .. code-block:: cmake - find_package(LLVM) - - # Define add_llvm_* macro's. - include(AddLLVM) + find_package(LLVM REQUIRED CONFIG) add_definitions(${LLVM_DEFINITIONS}) include_directories(${LLVM_INCLUDE_DIRS}) - link_directories(${LLVM_LIBRARY_DIRS}) add_subdirectory(<pass name>) @@ -475,6 +535,25 @@ Contents of ``<project dir>/<pass name>/CMakeLists.txt``: .. code-block:: cmake + add_library(LLVMPassname MODULE Pass.cpp) + +Note if you intend for this pass to be merged into the LLVM source tree at some +point in the future it might make more sense to use LLVM's internal +add_llvm_loadable_module function instead by... + + +Adding the following to ``<project dir>/CMakeLists.txt`` (after +``find_package(LLVM ...)``) + +.. code-block:: cmake + + list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}") + include(AddLLVM) + +And then changing ``<project dir>/<pass name>/CMakeLists.txt`` to + +.. code-block:: cmake + add_llvm_loadable_module(LLVMPassname Pass.cpp ) diff --git a/docs/CodeGenerator.rst b/docs/CodeGenerator.rst index 5736e43..b0a1059 100644 --- a/docs/CodeGenerator.rst +++ b/docs/CodeGenerator.rst @@ -290,10 +290,10 @@ the opcode, the number of operands, the list of implicit register uses and defs, whether the instruction has certain target-independent properties (accesses memory, is commutable, etc), and holds any target-specific flags. -The ``TargetFrameInfo`` class ------------------------------ +The ``TargetFrameLowering`` class +--------------------------------- -The ``TargetFrameInfo`` class is used to provide information about the stack +The ``TargetFrameLowering`` class is used to provide information about the stack frame layout of the target. It holds the direction of stack growth, the known stack alignment on entry to each function, and the offset to the local area. The offset to the local area is the offset from the stack pointer on function @@ -769,7 +769,9 @@ provide an ordering between nodes that have side effects (such as loads, stores, calls, returns, etc). All nodes that have side effects should take a token chain as input and produce a new one as output. By convention, token chain inputs are always operand #0, and chain results are always the last value -produced by an operation. +produced by an operation. However, after instruction selection, the +machine nodes have their chain after the instruction's operands, and +may be followed by glue nodes. A SelectionDAG has designated "Entry" and "Root" nodes. The Entry node is always a marker node with an Opcode of ``ISD::EntryToken``. The Root node is diff --git a/docs/CodingStandards.rst b/docs/CodingStandards.rst index 3cfa1f6..0552c71 100644 --- a/docs/CodingStandards.rst +++ b/docs/CodingStandards.rst @@ -162,6 +162,8 @@ being aware of: * ``std::initializer_list`` (and the constructors and functions that take it as an argument) are not always available, so you cannot (for example) initialize a ``std::vector`` with a braced initializer list. +* ``std::equal()`` (and other algorithms) incorrectly assert in MSVC when given + ``nullptr`` as an iterator. Other than these areas you should assume the standard library is available and working as expected until some build bot tells you otherwise. If you're in an @@ -174,6 +176,25 @@ traits header to emulate it. .. _the libstdc++ manual: http://gcc.gnu.org/onlinedocs/gcc-4.7.3/libstdc++/manual/manual/status.html#status.iso.2011 +Other Languages +--------------- + +Any code written in the Go programming language is not subject to the +formatting rules below. Instead, we adopt the formatting rules enforced by +the `gofmt`_ tool. + +Go code should strive to be idiomatic. Two good sets of guidelines for what +this means are `Effective Go`_ and `Go Code Review Comments`_. + +.. _gofmt: + https://golang.org/cmd/gofmt/ + +.. _Effective Go: + https://golang.org/doc/effective_go.html + +.. _Go Code Review Comments: + https://code.google.com/p/go-wiki/wiki/CodeReviewComments + Mechanical Source Issues ======================== diff --git a/docs/CommandGuide/FileCheck.rst b/docs/CommandGuide/FileCheck.rst index 5a60d60..af01503 100644 --- a/docs/CommandGuide/FileCheck.rst +++ b/docs/CommandGuide/FileCheck.rst @@ -49,6 +49,17 @@ OPTIONS The :option:`--strict-whitespace` argument disables this behavior. End-of-line sequences are canonicalized to UNIX-style ``\n`` in all modes. +.. option:: --implicit-check-not check-pattern + + Adds implicit negative checks for the specified patterns between positive + checks. The option allows writing stricter tests without stuffing them with + ``CHECK-NOT``\ s. + + For example, "``--implicit-check-not warning:``" can be useful when testing + diagnostic messages from tools that don't have an option similar to ``clang + -verify``. With this option FileCheck will verify that input does not contain + warnings not covered by any ``CHECK:`` patterns. + .. option:: -version Show the version number of this program. diff --git a/docs/CommandGuide/lit.rst b/docs/CommandGuide/lit.rst index 4d84be6..2708e9d 100644 --- a/docs/CommandGuide/lit.rst +++ b/docs/CommandGuide/lit.rst @@ -84,6 +84,14 @@ OUTPUT OPTIONS Do not use curses based progress bar. +.. option:: --show-unsupported + + Show the names of unsupported tests. + +.. option:: --show-xfail + + Show the names of tests that were expected to fail. + .. _execution-options: EXECUTION OPTIONS @@ -262,7 +270,7 @@ Once a test suite is discovered, its config file is loaded. Config files themselves are Python modules which will be executed. When the config file is executed, two important global variables are predefined: -**lit** +**lit_config** The global **lit** configuration object (a *LitConfig* instance), which defines the builtin test formats, global configuration parameters, and other helper @@ -307,14 +315,6 @@ executed, two important global variables are predefined: **root** The root configuration. This is the top-most :program:`lit` configuration in the project. - **on_clone** The config is actually cloned for every subdirectory inside a test - suite, to allow local configuration on a per-directory basis. The *on_clone* - variable can be set to a Python function which will be called whenever a - configuration is cloned (for a subdirectory). The function should takes three - arguments: (1) the parent configuration, (2) the new configuration (which the - *on_clone* function will generally modify), and (3) the test path to the new - directory being scanned. - **pipefail** Normally a test using a shell pipe fails if any of the commands on the pipe fail. If this is not desired, setting this variable to false makes the test fail only if the last command in the pipe fails. diff --git a/docs/CommandGuide/llvm-config.rst b/docs/CommandGuide/llvm-config.rst index 0ebb344..34075d0 100644 --- a/docs/CommandGuide/llvm-config.rst +++ b/docs/CommandGuide/llvm-config.rst @@ -151,7 +151,7 @@ libraries. Useful "virtual" components include: **all** - Includes all LLVM libaries. The default if no components are specified. + Includes all LLVM libraries. The default if no components are specified. diff --git a/docs/CommandGuide/llvm-profdata.rst b/docs/CommandGuide/llvm-profdata.rst index 6b8e4d7..0762e2c 100644 --- a/docs/CommandGuide/llvm-profdata.rst +++ b/docs/CommandGuide/llvm-profdata.rst @@ -1,29 +1,102 @@ -llvm-profdata - work with profile data -====================================== +llvm-profdata - Profile data tool +================================= SYNOPSIS -------- -:program:`llvm-profdata` [-output=output] file1 file2 +:program:`llvm-profdata` *command* [*args...*] DESCRIPTION ----------- -The experimental :program:`llvm-profdata` tool reads two profile data files -generated by PGO instrumentation and generates a file with merged data. +The :program:`llvm-profdata` tool is a small utility for working with profile +data files. -The profile data format itself is currently textual. +COMMANDS +-------- + +* `merge <profdata_merge_>`_ +* `show <profdata_show_>`_ + +.. program:: llvm-profdata merge + +.. _profdata_merge: + +MERGE +----- + +SYNOPSIS +^^^^^^^^ + +:program:`llvm-profdata merge` [*options*] [*filenames...*] + +DESCRIPTION +^^^^^^^^^^^ + +:program:`llvm-profdata merge` takes several profile data files +generated by PGO instrumentation and merges them together into a single +indexed profile data file. OPTIONS -------- +^^^^^^^ + +.. option:: -help + + Print a summary of command line options. + +.. option:: -output=output, -o=output + + Specify the output file name. *Output* cannot be ``-`` as the resulting + indexed profile data can't be written to standard output. + +.. program:: llvm-profdata show + +.. _profdata_show: + +SHOW +---- + +SYNOPSIS +^^^^^^^^ + +:program:`llvm-profdata show` [*options*] [*filename*] + +DESCRIPTION +^^^^^^^^^^^ + +:program:`llvm-profdata show` takes a profile data file and displays the +information about the profile counters for this file and +for any of the specified function(s). + +If *filename* is omitted or is ``-``, then **llvm-profdata show** reads its +input from standard input. + +OPTIONS +^^^^^^^ + +.. option:: -all-functions + + Print details for every function. + +.. option:: -counts + + Print the counter values for the displayed functions. + +.. option:: -function=string + + Print details for a function if the function's name contains the given string. + +.. option:: -help + + Print a summary of command line options. -.. option:: -output=output +.. option:: -output=output, -o=output - This option selects the output filename. If not specified, output is to - stdout. + Specify the output file name. If *output* is ``-`` or it isn't specified, + then the output is sent to standard output. EXIT STATUS ----------- -:program:`llvm-profdata` returns 1 if it cannot read input files or there is a -mismatch between their data. +:program:`llvm-profdata` returns 1 if the command is omitted or is invalid, +if it cannot read input files, or if there is a mismatch between their data. diff --git a/docs/CommandGuide/llvm-symbolizer.rst b/docs/CommandGuide/llvm-symbolizer.rst index ce2d9c0..96720e6 100644 --- a/docs/CommandGuide/llvm-symbolizer.rst +++ b/docs/CommandGuide/llvm-symbolizer.rst @@ -92,6 +92,13 @@ OPTIONS input (see example above). If architecture is not specified in either way, address will not be symbolized. Defaults to empty string. +.. option:: -dsym-hint=<path/to/file.dSYM> + + (Darwin-only flag). If the debug info for a binary isn't present in the default + location, look for the debug info at the .dSYM path provided via the + ``-dsym-hint`` flag. This flag can be used multiple times. + + EXIT STATUS ----------- diff --git a/docs/CommandGuide/opt.rst b/docs/CommandGuide/opt.rst index ad5b62c..3a050f7 100644 --- a/docs/CommandGuide/opt.rst +++ b/docs/CommandGuide/opt.rst @@ -62,27 +62,14 @@ OPTIONS available. The order in which the options occur on the command line are the order in which they are executed (within pass constraints). -.. option:: -std-compile-opts - - This is short hand for a standard list of *compile time optimization* passes. - It might be useful for other front end compilers as well. To discover the - full set of options available, use the following command: - - .. code-block:: sh - - llvm-as < /dev/null | opt -std-compile-opts -disable-output -debug-pass=Arguments - .. option:: -disable-inlining - This option is only meaningful when :option:`-std-compile-opts` is given. It - simply removes the inlining pass from the standard list. + This option simply removes the inlining pass from the standard list. .. option:: -disable-opt - This option is only meaningful when :option:`-std-compile-opts` is given. It - disables most, but not all, of the :option:`-std-compile-opts`. The ones that - remain are :option:`-verify`, :option:`-lower-setjmp`, and - :option:`-funcresolve`. + This option is only meaningful when :option:`-std-link-opts` is given. It + disables most passes. .. option:: -strip-debug @@ -95,9 +82,7 @@ OPTIONS This option causes opt to add a verify pass after every pass otherwise specified on the command line (including :option:`-verify`). This is useful for cases where it is suspected that a pass is creating an invalid module but - it is not clear which pass is doing it. The combination of - :option:`-std-compile-opts` and :option:`-verify-each` can quickly track down - this kind of problem. + it is not clear which pass is doing it. .. option:: -stats diff --git a/docs/CommandLine.rst b/docs/CommandLine.rst index 1b342e3..1d85215 100644 --- a/docs/CommandLine.rst +++ b/docs/CommandLine.rst @@ -1630,13 +1630,13 @@ To start out, we declare our new ``FileSizeParser`` class: .. code-block:: c++ - struct FileSizeParser : public cl::basic_parser<unsigned> { + struct FileSizeParser : public cl::parser<unsigned> { // parse - Return true on error. - bool parse(cl::Option &O, const char *ArgName, const std::string &ArgValue, + bool parse(cl::Option &O, StringRef ArgName, const std::string &ArgValue, unsigned &Val); }; -Our new class inherits from the ``cl::basic_parser`` template class to fill in +Our new class inherits from the ``cl::parser`` template class to fill in the default, boiler plate code for us. We give it the data type that we parse into, the last argument to the ``parse`` method, so that clients of our custom parser know what object type to pass in to the parse method. (Here we declare @@ -1652,7 +1652,7 @@ implement ``parse`` as: .. code-block:: c++ - bool FileSizeParser::parse(cl::Option &O, const char *ArgName, + bool FileSizeParser::parse(cl::Option &O, StringRef ArgName, const std::string &Arg, unsigned &Val) { const char *ArgStart = Arg.c_str(); char *End; @@ -1698,7 +1698,7 @@ Which adds this to the output of our program: OPTIONS: -help - display available options (-help-hidden for more) ... - -max-file-size=<size> - Maximum file size to accept + -max-file-size=<size> - Maximum file size to accept And we can test that our parse works correctly now (the test program just prints out the max-file-size argument value): diff --git a/docs/CompilerWriterInfo.rst b/docs/CompilerWriterInfo.rst index 606b5f5..a012c32 100644 --- a/docs/CompilerWriterInfo.rst +++ b/docs/CompilerWriterInfo.rst @@ -74,6 +74,7 @@ R600 * `AMD Evergreen shader ISA <http://developer.amd.com/wordpress/media/2012/10/AMD_Evergreen-Family_Instruction_Set_Architecture.pdf>`_ * `AMD Cayman/Trinity shader ISA <http://developer.amd.com/wordpress/media/2012/10/AMD_HD_6900_Series_Instruction_Set_Architecture.pdf>`_ * `AMD Southern Islands Series ISA <http://developer.amd.com/wordpress/media/2012/12/AMD_Southern_Islands_Instruction_Set_Architecture.pdf>`_ +* `AMD Sea Islands Series ISA <http://developer.amd.com/wordpress/media/2013/07/AMD_Sea_Islands_Instruction_Set_Architecture.pdf>`_ * `AMD GPU Programming Guide <http://developer.amd.com/download/AMD_Accelerated_Parallel_Processing_OpenCL_Programming_Guide.pdf>`_ * `AMD Compute Resources <http://developer.amd.com/tools/heterogeneous-computing/amd-accelerated-parallel-processing-app-sdk/documentation/>`_ diff --git a/docs/CoverageMappingFormat.rst b/docs/CoverageMappingFormat.rst new file mode 100644 index 0000000..8fcffb8 --- /dev/null +++ b/docs/CoverageMappingFormat.rst @@ -0,0 +1,576 @@ +.. role:: raw-html(raw) + :format: html + +================================= +LLVM Code Coverage Mapping Format +================================= + +.. contents:: + :local: + +Introduction +============ + +LLVM's code coverage mapping format is used to provide code coverage +analysis using LLVM's and Clang's instrumenation based profiling +(Clang's ``-fprofile-instr-generate`` option). + +This document is aimed at those who use LLVM's code coverage mapping to provide +code coverage analysis for their own programs, and for those who would like +to know how it works under the hood. A prior knowledge of how Clang's profile +guided optimization works is useful, but not required. + +We start by showing how to use LLVM and Clang for code coverage analysis, +then we briefly desribe LLVM's code coverage mapping format and the +way that Clang and LLVM's code coverage tool work with this format. After +the basics are down, more advanced features of the coverage mapping format +are discussed - such as the data structures, LLVM IR representation and +the binary encoding. + +Quick Start +=========== + +Here's a short story that describes how to generate code coverage overview +for a sample source file called *test.c*. + +* First, compile an instrumented version of your program using Clang's + ``-fprofile-instr-generate`` option with the additional ``-fcoverage-mapping`` + option: + + ``clang -o test -fprofile-instr-generate -fcoverage-mapping test.c`` +* Then, run the instrumented binary. The runtime will produce a file called + *default.profraw* containing the raw profile instrumentation data: + + ``./test`` +* After that, merge the profile data using the *llvm-profdata* tool: + + ``llvm-profdata merge -o test.profdata default.profraw`` +* Finally, run LLVM's code coverage tool (*llvm-cov*) to produce the code + coverage overview for the sample source file: + + ``llvm-cov show ./test -instr-profile=test.profdata test.c`` + +High Level Overview +=================== + +LLVM's code coverage mapping format is designed to be a self contained +data format, that can be embedded into the LLVM IR and object files. +It's described in this document as a **mapping** format because its goal is +to store the data that is required for a code coverage tool to map between +the specific source ranges in a file and the execution counts obtained +after running the instrumented version of the program. + +The mapping data is used in two places in the code coverage process: + +1. When clang compiles a source file with ``-fcoverage-mapping``, it + generates the mapping information that describes the mapping between the + source ranges and the profiling instrumentation counters. + This information gets embedded into the LLVM IR and conveniently + ends up in the final executable file when the program is linked. + +2. It is also used by *llvm-cov* - the mapping information is extracted from an + object file and is used to associate the execution counts (the values of the + profile instrumentation counters), and the source ranges in a file. + After that, the tool is able to generate various code coverage reports + for the program. + +The coverage mapping format aims to be a "universal format" that would be +suitable for usage by any frontend, and not just by Clang. It also aims to +provide the frontend the possibility of generating the minimal coverage mapping +data in order to reduce the size of the IR and object files - for example, +instead of emitting mapping information for each statement in a function, the +frontend is allowed to group the statements with the same execution count into +regions of code, and emit the mapping information only for those regions. + +Advanced Concepts +================= + +The remainder of this guide is meant to give you insight into the way the +coverage mapping format works. + +The coverage mapping format operates on a per-function level as the +profile instrumentation counters are associated with a specific function. +For each function that requires code coverage, the frontend has to create +coverage mapping data that can map between the source code ranges and +the profile instrumentation counters for that function. + +Mapping Region +-------------- + +The function's coverage mapping data contains an array of mapping regions. +A mapping region stores the `source code range`_ that is covered by this region, +the `file id <coverage file id_>`_, the `coverage mapping counter`_ and +the region's kind. +There are several kinds of mapping regions: + +* Code regions associate portions of source code and `coverage mapping + counters`_. They make up the majority of the mapping regions. They are used + by the code coverage tool to compute the execution counts for lines, + highlight the regions of code that were never executed, and to obtain + the various code coverage statistics for a function. + For example: + + :raw-html:`<pre class='highlight' style='line-height:initial;'><span>int main(int argc, const char *argv[]) </span><span style='background-color:#4A789C'>{ </span> <span class='c1'>// Code Region from 1:40 to 9:2</span> + <span style='background-color:#4A789C'> </span> + <span style='background-color:#4A789C'> if (argc > 1) </span><span style='background-color:#85C1F5'>{ </span> <span class='c1'>// Code Region from 3:17 to 5:4</span> + <span style='background-color:#85C1F5'> printf("%s\n", argv[1]); </span> + <span style='background-color:#85C1F5'> }</span><span style='background-color:#4A789C'> else </span><span style='background-color:#F6D55D'>{ </span> <span class='c1'>// Code Region from 5:10 to 7:4</span> + <span style='background-color:#F6D55D'> printf("\n"); </span> + <span style='background-color:#F6D55D'> }</span><span style='background-color:#4A789C'> </span> + <span style='background-color:#4A789C'> return 0; </span> + <span style='background-color:#4A789C'>}</span> + </pre>` +* Skipped regions are used to represent source ranges that were skipped + by Clang's preprocessor. They don't associate with + `coverage mapping counters`_, as the frontend knows that they are never + executed. They are used by the code coverage tool to mark the skipped lines + inside a function as non-code lines that don't have execution counts. + For example: + + :raw-html:`<pre class='highlight' style='line-height:initial;'><span>int main() </span><span style='background-color:#4A789C'>{ </span> <span class='c1'>// Code Region from 1:12 to 6:2</span> + <span style='background-color:#85C1F5'>#ifdef DEBUG </span> <span class='c1'>// Skipped Region from 2:1 to 4:2</span> + <span style='background-color:#85C1F5'> printf("Hello world"); </span> + <span style='background-color:#85C1F5'>#</span><span style='background-color:#4A789C'>endif </span> + <span style='background-color:#4A789C'> return 0; </span> + <span style='background-color:#4A789C'>}</span> + </pre>` +* Expansion regions are used to represent Clang's macro expansions. They + have an additional property - *expanded file id*. This property can be + used by the code coverage tool to find the mapping regions that are created + as a result of this macro expansion, by checking if their file id matches the + expanded file id. They don't associate with `coverage mapping counters`_, + as the code coverage tool can determine the execution count for this region + by looking up the execution count of the first region with a corresponding + file id. + For example: + + :raw-html:`<pre class='highlight' style='line-height:initial;'><span>int func(int x) </span><span style='background-color:#4A789C'>{ </span> + <span style='background-color:#4A789C'> #define MAX(x,y) </span><span style='background-color:#85C1F5'>((x) > (y)? </span><span style='background-color:#F6D55D'>(x)</span><span style='background-color:#85C1F5'> : </span><span style='background-color:#F4BA70'>(y)</span><span style='background-color:#85C1F5'>)</span><span style='background-color:#4A789C'> </span> + <span style='background-color:#4A789C'> return </span><span style='background-color:#7FCA9F'>MAX</span><span style='background-color:#4A789C'>(x, 42); </span> <span class='c1'>// Expansion Region from 3:10 to 3:13</span> + <span style='background-color:#4A789C'>}</span> + </pre>` + +.. _source code range: + +Source Range: +^^^^^^^^^^^^^ + +The source range record contains the starting and ending location of a certain +mapping region. Both locations include the line and the column numbers. + +.. _coverage file id: + +File ID: +^^^^^^^^ + +The file id an integer value that tells us +in which source file or macro expansion is this region located. +It enables Clang to produce mapping information for the code +defined inside macros, like this example demonstrates: + +:raw-html:`<pre class='highlight' style='line-height:initial;'><span>void func(const char *str) </span><span style='background-color:#4A789C'>{ </span> <span class='c1'>// Code Region from 1:28 to 6:2 with file id 0</span> +<span style='background-color:#4A789C'> #define PUT </span><span style='background-color:#85C1F5'>printf("%s\n", str)</span><span style='background-color:#4A789C'> </span> <span class='c1'>// 2 Code Regions from 2:15 to 2:34 with file ids 1 and 2</span> +<span style='background-color:#4A789C'> if(*str) </span> +<span style='background-color:#4A789C'> </span><span style='background-color:#F6D55D'>PUT</span><span style='background-color:#4A789C'>; </span> <span class='c1'>// Expansion Region from 4:5 to 4:8 with file id 0 that expands a macro with file id 1</span> +<span style='background-color:#4A789C'> </span><span style='background-color:#F6D55D'>PUT</span><span style='background-color:#4A789C'>; </span> <span class='c1'>// Expansion Region from 5:3 to 5:6 with file id 0 that expands a macro with file id 2</span> +<span style='background-color:#4A789C'>}</span> +</pre>` + +.. _coverage mapping counter: +.. _coverage mapping counters: + +Counter: +^^^^^^^^ + +A coverage mapping counter can represents a reference to the profile +instrumentation counter. The execution count for a region with such counter +is determined by looking up the value of the corresponding profile +instrumentation counter. + +It can also represent a binary arithmetical expression that operates on +coverage mapping counters or other expressions. +The execution count for a region with an expression counter is determined by +evaluating the expression's arguments and then adding them together or +subtracting them from one another. +In the example below, a subtraction expression is used to compute the execution +count for the compound statement that follows the *else* keyword: + +:raw-html:`<pre class='highlight' style='line-height:initial;'><span>int main(int argc, const char *argv[]) </span><span style='background-color:#4A789C'>{ </span> <span class='c1'>// Region's counter is a reference to the profile counter #0</span> +<span style='background-color:#4A789C'> </span> +<span style='background-color:#4A789C'> if (argc > 1) </span><span style='background-color:#85C1F5'>{ </span> <span class='c1'>// Region's counter is a reference to the profile counter #1</span> +<span style='background-color:#85C1F5'> printf("%s\n", argv[1]); </span><span> </span> +<span style='background-color:#85C1F5'> }</span><span style='background-color:#4A789C'> else </span><span style='background-color:#F6D55D'>{ </span> <span class='c1'>// Region's counter is an expression (reference to the profile counter #0 - reference to the profile counter #1)</span> +<span style='background-color:#F6D55D'> printf("\n"); </span> +<span style='background-color:#F6D55D'> }</span><span style='background-color:#4A789C'> </span> +<span style='background-color:#4A789C'> return 0; </span> +<span style='background-color:#4A789C'>}</span> +</pre>` + +Finally, a coverage mapping counter can also represent an execution count of +of zero. The zero counter is used to provide coverage mapping for +unreachable statements and expressions, like in the example below: + +:raw-html:`<pre class='highlight' style='line-height:initial;'><span>int main() </span><span style='background-color:#4A789C'>{ </span> +<span style='background-color:#4A789C'> return 0; </span> +<span style='background-color:#4A789C'> </span><span style='background-color:#85C1F5'>printf("Hello world!\n")</span><span style='background-color:#4A789C'>; </span> <span class='c1'>// Unreachable region's counter is zero</span> +<span style='background-color:#4A789C'>}</span> +</pre>` + +The zero counters allow the code coverage tool to display proper line execution +counts for the unreachable lines and highlight the unreachable code. +Without them, the tool would think that those lines and regions were still +executed, as it doesn't possess the frontend's knowledge. + +LLVM IR Representation +====================== + +The coverage mapping data is stored in the LLVM IR using a single global +constant structure variable called *__llvm_coverage_mapping* +with the *__llvm_covmap* section specifier. + +For example, let’s consider a C file and how it gets compiled to LLVM: + +.. _coverage mapping sample: + +.. code-block:: c + + int foo() { + return 42; + } + int bar() { + return 13; + } + +The coverage mapping variable generated by Clang is: + +.. code-block:: llvm + + @__llvm_coverage_mapping = internal constant { i32, i32, i32, i32, [2 x { i8*, i32, i32 }], [40 x i8] } + { i32 2, ; The number of function records + i32 20, ; The length of the string that contains the encoded translation unit filenames + i32 20, ; The length of the string that contains the encoded coverage mapping data + i32 0, ; Coverage mapping format version + [2 x { i8*, i32, i32 }] [ ; Function records + { i8*, i32, i32 } { i8* getelementptr inbounds ([3 x i8]* @__llvm_profile_name_foo, i32 0, i32 0), ; Function's name + i32 3, ; Function's name length + i32 9 ; Function's encoded coverage mapping data string length + }, + { i8*, i32, i32 } { i8* getelementptr inbounds ([3 x i8]* @__llvm_profile_name_bar, i32 0, i32 0), ; Function's name + i32 3, ; Function's name length + i32 9 ; Function's encoded coverage mapping data string length + }], + [40 x i8] c"..." ; Encoded data (dissected later) + }, section "__llvm_covmap", align 8 + +Version: +-------- + +The coverage mapping version number can have the following values: + +* 0 — The first (current) version of the coverage mapping format. + +.. _function records: + +Function record: +---------------- + +A function record is a structure of the following type: + +.. code-block:: llvm + + { i8*, i32, i32 } + +It contains the pointer to the function's name, function's name length, +and the length of the encoded mapping data for that function. + +Encoded data: +------------- + +The encoded data is stored in a single string that contains +the encoded filenames used by this translation unit and the encoded coverage +mapping data for each function in this translation unit. + +The encoded data has the following structure: + +``[filenames, coverageMappingDataForFunctionRecord0, coverageMappingDataForFunctionRecord1, ..., padding]`` + +If necessary, the encoded data is padded with zeroes so that the size +of the data string is rounded up to the nearest multiple of 8 bytes. + +Dissecting the sample: +^^^^^^^^^^^^^^^^^^^^^^ + +Here's an overview of the encoded data that was stored in the +IR for the `coverage mapping sample`_ that was shown earlier: + +* The IR contains the following string constant that represents the encoded + coverage mapping data for the sample translation unit: + + .. code-block:: llvm + + c"\01\12/Users/alex/test.c\01\00\00\01\01\01\0C\02\02\01\00\00\01\01\04\0C\02\02\00\00" + +* The string contains values that are encoded in the LEB128 format, which is + used throughout for storing integers. It also contains a string value. + +* The length of the substring that contains the encoded translation unit + filenames is the value of the second field in the *__llvm_coverage_mapping* + structure, which is 20, thus the filenames are encoded in this string: + + .. code-block:: llvm + + c"\01\12/Users/alex/test.c" + + This string contains the following data: + + * Its first byte has a value of ``0x01``. It stores the number of filenames + contained in this string. + * Its second byte stores the length of the first filename in this string. + * The remaining 18 bytes are used to store the first filename. + +* The length of the substring that contains the encoded coverage mapping data + for the first function is the value of the third field in the first + structure in an array of `function records`_ stored in the + fifth field of the *__llvm_coverage_mapping* structure, which is the 9. + Therefore, the coverage mapping for the first function record is encoded + in this string: + + .. code-block:: llvm + + c"\01\00\00\01\01\01\0C\02\02" + + This string consists of the following bytes: + + +----------+-------------------------------------------------------------------------------------------------------------------------+ + | ``0x01`` | The number of file ids used by this function. There is only one file id used by the mapping data in this function. | + +----------+-------------------------------------------------------------------------------------------------------------------------+ + | ``0x00`` | An index into the filenames array which corresponds to the file "/Users/alex/test.c". | + +----------+-------------------------------------------------------------------------------------------------------------------------+ + | ``0x00`` | The number of counter expressions used by this function. This function doesn't use any expressions. | + +----------+-------------------------------------------------------------------------------------------------------------------------+ + | ``0x01`` | The number of mapping regions that are stored in an array for the function's file id #0. | + +----------+-------------------------------------------------------------------------------------------------------------------------+ + | ``0x01`` | The coverage mapping counter for the first region in this function. The value of 1 tells us that it's a coverage | + | | mapping counter that is a reference ot the profile instrumentation counter with an index of 0. | + +----------+-------------------------------------------------------------------------------------------------------------------------+ + | ``0x01`` | The starting line of the first mapping region in this function. | + +----------+-------------------------------------------------------------------------------------------------------------------------+ + | ``0x0C`` | The starting column of the first mapping region in this function. | + +----------+-------------------------------------------------------------------------------------------------------------------------+ + | ``0x02`` | The ending line of the first mapping region in this function. | + +----------+-------------------------------------------------------------------------------------------------------------------------+ + | ``0x02`` | The ending column of the first mapping region in this function. | + +----------+-------------------------------------------------------------------------------------------------------------------------+ + +* The length of the substring that contains the encoded coverage mapping data + for the second function record is also 9. It's structured like the mapping data + for the first function record. + +* The two trailing bytes are zeroes and are used to pad the coverage mapping + data to give it the 8 byte alignment. + +Encoding +======== + +The per-function coverage mapping data is encoded as a stream of bytes, +with a simple structure. The structure consists of the encoding +`types <cvmtypes_>`_ like variable-length unsigned integers, that +are used to encode `File ID Mapping`_, `Counter Expressions`_ and +the `Mapping Regions`_. + +The format of the structure follows: + + ``[file id mapping, counter expressions, mapping regions]`` + +The translation unit filenames are encoded using the same encoding +`types <cvmtypes_>`_ as the per-function coverage mapping data, with the +following structure: + + ``[numFilenames : LEB128, filename0 : string, filename1 : string, ...]`` + +.. _cvmtypes: + +Types +----- + +This section describes the basic types that are used by the encoding format +and can appear after ``:`` in the ``[foo : type]`` description. + +.. _LEB128: + +LEB128 +^^^^^^ + +LEB128 is an unsigned interger value that is encoded using DWARF's LEB128 +encoding, optimizing for the case where values are small +(1 byte for values less than 128). + +.. _strings: + +Strings +^^^^^^^ + +``[length : LEB128, characters...]`` + +String values are encoded with a `LEB value <LEB128_>`_ for the length +of the string and a sequence of bytes for its characters. + +.. _file id mapping: + +File ID Mapping +--------------- + +``[numIndices : LEB128, filenameIndex0 : LEB128, filenameIndex1 : LEB128, ...]`` + +File id mapping in a function's coverage mapping stream +contains the indices into the translation unit's filenames array. + +Counter +------- + +``[value : LEB128]`` + +A `coverage mapping counter`_ is stored in a single `LEB value <LEB128_>`_. +It is composed of two things --- the `tag <counter-tag_>`_ +which is stored in the lowest 2 bits, and the `counter data`_ which is stored +in the remaining bits. + +.. _counter-tag: + +Tag: +^^^^ + +The counter's tag encodes the counter's kind +and, if the counter is an expression, the expression's kind. +The possible tag values are: + +* 0 - The counter is zero. + +* 1 - The counter is a reference to the profile instrumentation counter. + +* 2 - The counter is a subtraction expression. + +* 3 - The counter is an addition expression. + +.. _counter data: + +Data: +^^^^^ + +The counter's data is interpreted in the following manner: + +* When the counter is a reference to the profile instrumentation counter, + then the counter's data is the id of the profile counter. +* When the counter is an expression, then the counter's data + is the index into the array of counter expressions. + +.. _Counter Expressions: + +Counter Expressions +------------------- + +``[numExpressions : LEB128, expr0LHS : LEB128, expr0RHS : LEB128, expr1LHS : LEB128, expr1RHS : LEB128, ...]`` + +Counter expressions consist of two counters as they +represent binary arithmetic operations. +The expression's kind is determined from the `tag <counter-tag_>`_ of the +counter that references this expression. + +.. _Mapping Regions: + +Mapping Regions +--------------- + +``[numRegionArrays : LEB128, regionsForFile0, regionsForFile1, ...]`` + +The mapping regions are stored in an array of sub-arrays where every +region in a particular sub-array has the same file id. + +The file id for a sub-array of regions is the index of that +sub-array in the main array e.g. The first sub-array will have the file id +of 0. + +Sub-Array of Regions +^^^^^^^^^^^^^^^^^^^^ + +``[numRegions : LEB128, region0, region1, ...]`` + +The mapping regions for a specific file id are stored in an array that is +sorted in an ascending order by the region's starting location. + +Mapping Region +^^^^^^^^^^^^^^ + +``[header, source range]`` + +The mapping region record contains two sub-records --- +the `header`_, which stores the counter and/or the region's kind, +and the `source range`_ that contains the starting and ending +location of this region. + +.. _header: + +Header +^^^^^^ + +``[counter]`` + +or + +``[pseudo-counter]`` + +The header encodes the region's counter and the region's kind. + +The value of the counter's tag distinguishes between the counters and +pseudo-counters --- if the tag is zero, than this header contains a +pseudo-counter, otherwise this header contains an ordinary counter. + +Counter: +"""""""" + +A mapping region whose header has a counter with a non-zero tag is +a code region. + +Pseudo-Counter: +""""""""""""""" + +``[value : LEB128]`` + +A pseudo-counter is stored in a single `LEB value <LEB128_>`_, just like +the ordinary counter. It has the following interpretation: + +* bits 0-1: tag, which is always 0. + +* bit 2: expansionRegionTag. If this bit is set, then this mapping region + is an expansion region. + +* remaining bits: data. If this region is an expansion region, then the data + contains the expanded file id of that region. + + Otherwise, the data contains the region's kind. The possible region + kind values are: + + * 0 - This mapping region is a code region with a counter of zero. + * 2 - This mapping region is a skipped region. + +.. _source range: + +Source Range +^^^^^^^^^^^^ + +``[deltaLineStart : LEB128, columnStart : LEB128, numLines : LEB128, columnEnd : LEB128]`` + +The source range record contains the following fields: + +* *deltaLineStart*: The difference between the starting line of the + current mapping region and the starting line of the previous mapping region. + + If the current mapping region is the first region in the current + sub-array, then it stores the starting line of that region. + +* *columnStart*: The starting column of the mapping region. + +* *numLines*: The difference between the ending line and the starting line + of the current mapping region. + +* *columnEnd*: The ending column of the mapping region. diff --git a/docs/DeveloperPolicy.rst b/docs/DeveloperPolicy.rst index 74a8979..508a04f 100644 --- a/docs/DeveloperPolicy.rst +++ b/docs/DeveloperPolicy.rst @@ -436,6 +436,29 @@ list, development list, or LLVM bug tracker component. If someone sends you a patch privately, encourage them to submit it to the appropriate list first. +IR Backwards Compatibility +-------------------------- + +When the IR format has to be changed, keep in mind that we try to maintain some +backwards compatibility. The rules are intended as a balance between convenience +for llvm users and not imposing a big burden on llvm developers: + +* The textual format is not backwards compatible. We don't change it too often, + but there are no specific promises. + +* The bitcode format produced by a X.Y release will be readable by all following + X.Z releases and the (X+1).0 release. + +* Newer releases can ignore features from older releases, but they cannot + miscompile them. For example, if nsw is ever replaced with something else, + dropping it would be a valid way to upgrade the IR. + +* Debug metadata is special in that it is currently dropped during upgrades. + +* Non-debug metadata is defined to be safe to drop, so a valid way to upgrade + it is to drop it. That is not very user friendly and a bit more effort is + expected, but no promises are made. + .. _copyright-license-patents: Copyright, License, and Patents diff --git a/docs/GarbageCollection.rst b/docs/GarbageCollection.rst index dc6dab1..49d3496 100644 --- a/docs/GarbageCollection.rst +++ b/docs/GarbageCollection.rst @@ -923,7 +923,7 @@ a realistic example: void MyGCPrinter::finishAssembly(AsmPrinter &AP) { MCStreamer &OS = AP.OutStreamer; - unsigned IntPtrSize = AP.TM.getDataLayout()->getPointerSize(); + unsigned IntPtrSize = AP.TM.getSubtargetImpl()->getDataLayout()->getPointerSize(); // Put this in the data section. OS.SwitchSection(AP.getObjFileLowering().getDataSection()); diff --git a/docs/GettingStarted.rst b/docs/GettingStarted.rst index 6de9b90..140210d 100644 --- a/docs/GettingStarted.rst +++ b/docs/GettingStarted.rst @@ -115,7 +115,6 @@ LLVM is known to work on the following host platforms: ================== ===================== ============= OS Arch Compilers ================== ===================== ============= -AuroraUX x86\ :sup:`1` GCC Linux x86\ :sup:`1` GCC, Clang Linux amd64 GCC, Clang Linux ARM\ :sup:`4` GCC, Clang @@ -331,10 +330,23 @@ of this information from. .. _GCC wiki entry: http://gcc.gnu.org/wiki/InstallingGCC -Once you have a GCC toolchain, use it as your host compiler. Things should -generally "just work". You may need to pass a special linker flag, -``-Wl,-rpath,$HOME/toolchains/lib`` or some variant thereof to get things to -find the libstdc++ DSO in this toolchain. +Once you have a GCC toolchain, configure your build of LLVM to use the new +toolchain for your host compiler and C++ standard library. Because the new +version of libstdc++ is not on the system library search path, you need to pass +extra linker flags so that it can be found at link time (``-L``) and at runtime +(``-rpath``). If you are using CMake, this invocation should produce working +binaries: + +.. code-block:: console + + % mkdir build + % cd build + % CC=$HOME/toolchains/bin/gcc CXX=$HOME/toolchains/bin/g++ \ + cmake .. -DCMAKE_CXX_LINK_FLAGS="-Wl,-rpath,$HOME/toolchains/lib64 -L$HOME/toolchains/lib64" + +If you fail to set rpath, most LLVM binaries will fail on startup with a message +from the loader similar to ``libstdc++.so.6: version `GLIBCXX_3.4.20' not +found``. This means you need to tweak the -rpath linker flag. When you build Clang, you will need to give *it* access to modern C++11 standard library in order to use it as your new host in part of a bootstrap. @@ -713,13 +725,6 @@ The following options can be used to set or enable LLVM specific options: generating the documentation can take a long time and producess 100s of megabytes of output. -``--with-udis86`` - - LLVM can use external disassembler library for various purposes (now it's used - only for examining code produced by JIT). This option will enable usage of - `udis86 <http://udis86.sourceforge.net/>`_ x86 (both 32 and 64 bits) - disassembler library. - To configure LLVM, follow these steps: #. Change directory into the object root directory: @@ -1013,7 +1018,7 @@ This directory contains most of the source files of the LLVM system. In LLVM, almost all code exists in libraries, making it very easy to share code among the different `tools`_. -``llvm/lib/VMCore/`` +``llvm/lib/IR/`` This directory holds the core LLVM source files that implement core classes like Instruction and BasicBlock. diff --git a/docs/GoldPlugin.rst b/docs/GoldPlugin.rst index 28b202a..6328934 100644 --- a/docs/GoldPlugin.rst +++ b/docs/GoldPlugin.rst @@ -44,9 +44,11 @@ will either need to build gold or install a version with plugin support. the ``-plugin`` option. Running ``make`` will additionally build ``build/binutils/ar`` and ``nm-new`` binaries supporting plugins. -* Build the LLVMgold plugin: Configure LLVM with - ``--with-binutils-include=/path/to/binutils/include`` and run - ``make``. +* Build the LLVMgold plugin. If building with autotools, run configure with + ``--with-binutils-include=/path/to/binutils/include`` and run ``make``. + If building with CMake, run cmake with + ``-DLLVM_BINUTILS_INCDIR=/path/to/binutils/include``. The correct include + path will contain the file ``plugin-api.h``. Usage ===== diff --git a/docs/HowToReleaseLLVM.rst b/docs/HowToReleaseLLVM.rst index 61aa9e8..26e9f3b 100644 --- a/docs/HowToReleaseLLVM.rst +++ b/docs/HowToReleaseLLVM.rst @@ -146,25 +146,25 @@ following commands: :: - $ svn mkdir https://llvm.org/svn/llvm-project/llvm/tags/RELEASE_XY + $ svn mkdir https://llvm.org/svn/llvm-project/llvm/tags/RELEASE_XYZ $ svn copy https://llvm.org/svn/llvm-project/llvm/branches/release_XY \ - https://llvm.org/svn/llvm-project/llvm/tags/RELEASE_XY/rc1 + https://llvm.org/svn/llvm-project/llvm/tags/RELEASE_XYZ/rc1 - $ svn mkdir https://llvm.org/svn/llvm-project/cfe/tags/RELEASE_XY + $ svn mkdir https://llvm.org/svn/llvm-project/cfe/tags/RELEASE_XYZ $ svn copy https://llvm.org/svn/llvm-project/cfe/branches/release_XY \ - https://llvm.org/svn/llvm-project/cfe/tags/RELEASE_XY/rc1 + https://llvm.org/svn/llvm-project/cfe/tags/RELEASE_XYZ/rc1 - $ svn mkdir https://llvm.org/svn/llvm-project/dragonegg/tags/RELEASE_XY + $ svn mkdir https://llvm.org/svn/llvm-project/dragonegg/tags/RELEASE_XYZ $ svn copy https://llvm.org/svn/llvm-project/dragonegg/branches/release_XY \ - https://llvm.org/svn/llvm-project/dragonegg/tags/RELEASE_XY/rc1 + https://llvm.org/svn/llvm-project/dragonegg/tags/RELEASE_XYZ/rc1 - $ svn mkdir https://llvm.org/svn/llvm-project/test-suite/tags/RELEASE_XY + $ svn mkdir https://llvm.org/svn/llvm-project/test-suite/tags/RELEASE_XYZ $ svn copy https://llvm.org/svn/llvm-project/test-suite/branches/release_XY \ - https://llvm.org/svn/llvm-project/test-suite/tags/RELEASE_XY/rc1 + https://llvm.org/svn/llvm-project/test-suite/tags/RELEASE_XYZ/rc1 Similarly, **Release Candidate 2** would be named ``RC2`` and so on. This keeps a permanent copy of the release candidate around for people to export and build -as they wish. The final released sources will be tagged in the ``RELEASE_XY`` +as they wish. The final released sources will be tagged in the ``RELEASE_XYZ`` directory as ``Final`` (c.f. :ref:`tag`). The Release Manager may supply pre-packaged source tarballs for users. This can @@ -172,10 +172,10 @@ be done with the following commands: :: - $ svn export https://llvm.org/svn/llvm-project/llvm/tags/RELEASE_XY/rc1 llvm-X.Yrc1 - $ svn export https://llvm.org/svn/llvm-project/cfe/tags/RELEASE_XY/rc1 clang-X.Yrc1 - $ svn export https://llvm.org/svn/llvm-project/dragonegg/tags/RELEASE_XY/rc1 dragonegg-X.Yrc1 - $ svn export https://llvm.org/svn/llvm-project/test-suite/tags/RELEASE_XY/rc1 llvm-test-X.Yrc1 + $ svn export https://llvm.org/svn/llvm-project/llvm/tags/RELEASE_XYZ/rc1 llvm-X.Yrc1 + $ svn export https://llvm.org/svn/llvm-project/cfe/tags/RELEASE_XYZ/rc1 clang-X.Yrc1 + $ svn export https://llvm.org/svn/llvm-project/dragonegg/tags/RELEASE_XYZ/rc1 dragonegg-X.Yrc1 + $ svn export https://llvm.org/svn/llvm-project/test-suite/tags/RELEASE_XYZ/rc1 llvm-test-X.Yrc1 $ tar -cvf - llvm-X.Yrc1 | gzip > llvm-X.Yrc1.src.tar.gz $ tar -cvf - clang-X.Yrc1 | gzip > clang-X.Yrc1.src.tar.gz @@ -389,16 +389,16 @@ Tag the final release sources using the following procedure: :: $ svn copy https://llvm.org/svn/llvm-project/llvm/branches/release_XY \ - https://llvm.org/svn/llvm-project/llvm/tags/RELEASE_XY/Final + https://llvm.org/svn/llvm-project/llvm/tags/RELEASE_XYZ/Final $ svn copy https://llvm.org/svn/llvm-project/cfe/branches/release_XY \ - https://llvm.org/svn/llvm-project/cfe/tags/RELEASE_XY/Final + https://llvm.org/svn/llvm-project/cfe/tags/RELEASE_XYZ/Final $ svn copy https://llvm.org/svn/llvm-project/dragonegg/branches/release_XY \ - https://llvm.org/svn/llvm-project/dragonegg/tags/RELEASE_XY/Final + https://llvm.org/svn/llvm-project/dragonegg/tags/RELEASE_XYZ/Final $ svn copy https://llvm.org/svn/llvm-project/test-suite/branches/release_XY \ - https://llvm.org/svn/llvm-project/test-suite/tags/RELEASE_XY/Final + https://llvm.org/svn/llvm-project/test-suite/tags/RELEASE_XYZ/Final Update the LLVM Demo Page ------------------------- diff --git a/docs/HowToSubmitABug.rst b/docs/HowToSubmitABug.rst index 702dc0c..9f997d2 100644 --- a/docs/HowToSubmitABug.rst +++ b/docs/HowToSubmitABug.rst @@ -89,7 +89,7 @@ Then run: .. code-block:: bash - opt -std-compile-opts -debug-pass=Arguments foo.bc -disable-output + opt -O3 -debug-pass=Arguments foo.bc -disable-output This command should do two things: it should print out a list of passes, and then it should crash in the same way as clang. If it doesn't crash, please diff --git a/docs/LangRef.rst b/docs/LangRef.rst index cc9656a..3b7d80b 100644 --- a/docs/LangRef.rst +++ b/docs/LangRef.rst @@ -75,11 +75,12 @@ identifiers, for different purposes: #. Named values are represented as a string of characters with their prefix. For example, ``%foo``, ``@DivisionByZero``, ``%a.really.long.identifier``. The actual regular expression used is - '``[%@][a-zA-Z$._][a-zA-Z$._0-9]*``'. Identifiers which require other + '``[%@][a-zA-Z$._][a-zA-Z$._0-9]*``'. Identifiers that require other characters in their names can be surrounded with quotes. Special characters may be escaped using ``"\xx"`` where ``xx`` is the ASCII code for the character in hexadecimal. In this way, any character can - be used in a name value, even quotes themselves. + be used in a name value, even quotes themselves. The ``"\01"`` prefix + can be used on global variables to suppress mangling. #. Unnamed values are represented as an unsigned numeric value with their prefix. For example, ``%12``, ``@2``, ``%44``. #. Constants, which are described in the section Constants_ below. @@ -128,9 +129,10 @@ lexical features of LLVM: #. Unnamed temporaries are created when the result of a computation is not assigned to a named value. #. Unnamed temporaries are numbered sequentially (using a per-function - incrementing counter, starting with 0). Note that basic blocks are - included in this numbering. For example, if the entry basic block is not - given a label name, then it will get number 0. + incrementing counter, starting with 0). Note that basic blocks and unnamed + function parameters are included in this numbering. For example, if the + entry basic block is not given a label name and all function parameters are + named, then it will get number 0. It also shows a convention that we follow in this document. When demonstrating instructions, we will follow an instruction with a comment @@ -168,8 +170,8 @@ symbol table entries. Here is an example of the "hello world" module: } ; Named metadata - !1 = metadata !{i32 42} - !foo = !{!1, null} + !0 = metadata !{i32 42, null, metadata !"string"} + !foo = !{!0} This example is made up of a :ref:`global variable <globalvars>` named "``.str``", an external declaration of the "``puts``" function, a @@ -500,7 +502,7 @@ Structure Types LLVM IR allows you to specify both "identified" and "literal" :ref:`structure types <t_struct>`. Literal types are uniqued structurally, but identified types are never uniqued. An :ref:`opaque structural type <t_opaque>` can also be used -to forward declare a type which is not yet available. +to forward declare a type that is not yet available. An example of a identified structure specification is: @@ -582,7 +584,7 @@ to over-align the global if the global has an assigned section. In this case, the extra alignment could be observable: for example, code could assume that the globals are densely packed in their section and try to iterate over them as an array, alignment padding would break this -iteration. +iteration. The maximum alignment is ``1 << 29``. Globals can also have a :ref:`DLL storage class <dllstorageclass>`. @@ -680,6 +682,14 @@ Syntax:: [unnamed_addr] [fn Attrs] [section "name"] [comdat $<ComdatName>] [align N] [gc] [prefix Constant] { ... } +The argument list is a comma seperated sequence of arguments where each +argument is of the following form + +Syntax:: + + <type> [parameter Attrs] [name] + + .. _langref_aliases: Aliases @@ -697,7 +707,7 @@ Aliases may have an optional :ref:`linkage type <linkage>`, an optional Syntax:: - @<Name> = [Visibility] [DLLStorageClass] [ThreadLocal] [unnamed_addr] alias [Linkage] <AliaseeTy> @<Aliasee> + @<Name> = [Linkage] [Visibility] [DLLStorageClass] [ThreadLocal] [unnamed_addr] alias <AliaseeTy> @<Aliasee> The linkage must be one of ``private``, ``internal``, ``linkonce``, ``weak``, ``linkonce_odr``, ``weak_odr``, ``external``. Note that some system linkers @@ -727,7 +737,7 @@ Comdats Comdat IR provides access to COFF and ELF object file COMDAT functionality. -Comdats have a name which represents the COMDAT key. All global objects which +Comdats have a name which represents the COMDAT key. All global objects that specify this key will only end up in the final object file if the linker chooses that key over some other key. Aliases are placed in the same COMDAT that their aliasee computes to, if any. @@ -773,7 +783,7 @@ In a COFF object file, this will create a COMDAT section with selection kind ``IMAGE_COMDAT_SELECT_LARGEST`` containing the contents of the ``@foo`` symbol and another COMDAT section with selection kind ``IMAGE_COMDAT_SELECT_ASSOCIATIVE`` which is associated with the first COMDAT -section and contains the contents of the ``@baz`` symbol. +section and contains the contents of the ``@bar`` symbol. There are some restrictions on the properties of the global object. It, or an alias to it, must have the same name as the COMDAT group when @@ -891,7 +901,7 @@ Currently, only the following parameter attributes are defined: address of outgoing stack arguments. An ``inalloca`` argument must be a pointer to stack memory produced by an ``alloca`` instruction. The alloca, or argument allocation, must also be tagged with the - inalloca keyword. Only the past argument may have the ``inalloca`` + inalloca keyword. Only the last argument may have the ``inalloca`` attribute, and that argument is guaranteed to be passed in memory. An argument allocation may be used by a call at most once because @@ -921,11 +931,18 @@ Currently, only the following parameter attributes are defined: the first parameter. This is not a valid attribute for return values. +``align <n>`` + This indicates that the pointer value may be assumed by the optimizer to + have the specified alignment. + + Note that this attribute has additional semantics when combined with the + ``byval`` attribute. + .. _noalias: ``noalias`` This indicates that pointer values :ref:`based <pointeraliasing>` on - the argument or return value do not alias pointer values which are + the argument or return value do not alias pointer values that are not *based* on it, ignoring certain "irrelevant" dependencies. For a call to the parent function, dependencies between memory references from before or after the call and from those during the call are @@ -969,6 +986,17 @@ Currently, only the following parameter attributes are defined: passed in is non-null, or the callee must ensure that the returned pointer is non-null. +``dereferenceable(<n>)`` + This indicates that the parameter or return pointer is dereferenceable. This + attribute may only be applied to pointer typed parameters. A pointer that + is dereferenceable can be loaded from speculatively without a risk of + trapping. The number of bytes known to be dereferenceable must be provided + in parentheses. It is legal for the number of bytes to be less than the + size of the pointee type. The ``nonnull`` attribute does not imply + dereferenceability (consider a pointer to one element past the end of an + array), however ``dereferenceable(<n>)`` does imply ``nonnull`` in + ``addrspace(0)`` (which is the default address space). + .. _gc: Garbage Collector Names @@ -982,7 +1010,7 @@ string: define void @f() gc "name" { ... } The compiler declares the supported values of *name*. Specifying a -collector which will cause the compiler to alter its output in order to +collector will cause the compiler to alter its output in order to support the named garbage collection algorithm. .. _prefixdata: @@ -1098,7 +1126,7 @@ example: This indicates that the callee function at a call site should be recognized as a built-in function, even though the function's declaration uses the ``nobuiltin`` attribute. This is only valid at call sites for - direct calls to functions which are declared with the ``nobuiltin`` + direct calls to functions that are declared with the ``nobuiltin`` attribute. ``cold`` This attribute indicates that this function is rarely called. When @@ -1593,7 +1621,7 @@ Given that definition, R\ :sub:`byte` is defined as follows: - If R is volatile, the result is target-dependent. (Volatile is supposed to give guarantees which can support ``sig_atomic_t`` in - C/C++, and may be used for accesses to addresses which do not behave + C/C++, and may be used for accesses to addresses that do not behave like normal memory. It does not generally provide cross-thread synchronization.) - Otherwise, if there is no write to the same byte that happens before @@ -1681,7 +1709,7 @@ For a simpler introduction to the ordering constraints, see the address. This corresponds to the C++0x/C1x ``memory_order_acq_rel``. ``seq_cst`` (sequentially consistent) In addition to the guarantees of ``acq_rel`` (``acquire`` for an - operation which only reads, ``release`` for an operation which only + operation that only reads, ``release`` for an operation that only writes), there is a global total order on all sequentially-consistent operations on all addresses, which is consistent with the *happens-before* partial order and with the @@ -1730,6 +1758,52 @@ otherwise unsafe floating point operations dramatically change results in floating point (e.g. reassociate). This flag implies all the others. +.. _uselistorder: + +Use-list Order Directives +------------------------- + +Use-list directives encode the in-memory order of each use-list, allowing the +order to be recreated. ``<order-indexes>`` is a comma-separated list of +indexes that are assigned to the referenced value's uses. The referenced +value's use-list is immediately sorted by these indexes. + +Use-list directives may appear at function scope or global scope. They are not +instructions, and have no effect on the semantics of the IR. When they're at +function scope, they must appear after the terminator of the final basic block. + +If basic blocks have their address taken via ``blockaddress()`` expressions, +``uselistorder_bb`` can be used to reorder their use-lists from outside their +function's scope. + +:Syntax: + +:: + + uselistorder <ty> <value>, { <order-indexes> } + uselistorder_bb @function, %block { <order-indexes> } + +:Examples: + +:: + + define void @foo(i32 %arg1, i32 %arg2) { + entry: + ; ... instructions ... + bb: + ; ... instructions ... + + ; At function scope. + uselistorder i32 %arg1, { 1, 0, 2 } + uselistorder label %bb, { 1, 0 } + } + + ; At global scope. + uselistorder i32* @global, { 1, 2, 0 } + uselistorder i32 7, { 1, 0 } + uselistorder i32 (i32) @bar, { 1, 0 } + uselistorder_bb @foo, %bb, { 5, 1, 3, 2, 0, 4 } + .. _typesystem: Type System @@ -1948,8 +2022,8 @@ type. Vector types are considered :ref:`first class <t_firstclass>`. < <# elements> x <elementtype> > The number of elements is a constant integer value larger than 0; -elementtype may be any integer or floating point type, or a pointer to -these types. Vectors of size zero are not allowed. +elementtype may be any integer, floating point or pointer type. Vectors +of size zero are not allowed. :Examples: @@ -2202,7 +2276,9 @@ constants and smaller complex constants. square brackets (``[]``)). For example: "``[ i32 42, i32 11, i32 74 ]``". Array constants must have :ref:`array type <t_array>`, and the number and types of elements must - match those specified by the type. + match those specified by the type. As a special case, character array + constants may also be represented as a double-quoted string using the ``c`` + prefix. For example: "``c"Hello World\0A\00"``". **Vector constants** Vector constants are represented with notation similar to vector type definitions (a comma separated list of elements, surrounded by @@ -2319,7 +2395,7 @@ allowed to assume that the '``undef``' operand could be the same as %C = xor %B, %B %D = undef - %E = icmp lt %D, 4 + %E = icmp slt %D, 4 %F = icmp gte %D, 4 Safe: @@ -2384,8 +2460,8 @@ Poison Values Poison values are similar to :ref:`undef values <undefvalues>`, however they also represent the fact that an instruction or constant expression -which cannot evoke side effects has nevertheless detected a condition -which results in undefined behavior. +that cannot evoke side effects has nevertheless detected a condition +that results in undefined behavior. There is currently no way of representing a poison value in the IR; they only exist when produced by operations such as :ref:`add <i_add>` with @@ -2422,8 +2498,8 @@ Poison value behavior is defined in terms of value *dependence*: successor. - Dependence is transitive. -Poison Values have the same behavior as :ref:`undef values <undefvalues>`, -with the additional affect that any instruction which has a *dependence* +Poison values have the same behavior as :ref:`undef values <undefvalues>`, +with the additional effect that any instruction that has a *dependence* on a poison value has undefined behavior. Here are some examples: @@ -2811,6 +2887,67 @@ Note that the fields need not be contiguous. In this example, there is a 4 byte gap between the two fields. This gap represents padding which does not carry useful data and need not be preserved. +'``noalias``' and '``alias.scope``' Metadata +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +``noalias`` and ``alias.scope`` metadata provide the ability to specify generic +noalias memory-access sets. This means that some collection of memory access +instructions (loads, stores, memory-accessing calls, etc.) that carry +``noalias`` metadata can specifically be specified not to alias with some other +collection of memory access instructions that carry ``alias.scope`` metadata. +Each type of metadata specifies a list of scopes where each scope has an id and +a domain. When evaluating an aliasing query, if for some some domain, the set +of scopes with that domain in one instruction's ``alias.scope`` list is a +subset of (or qual to) the set of scopes for that domain in another +instruction's ``noalias`` list, then the two memory accesses are assumed not to +alias. + +The metadata identifying each domain is itself a list containing one or two +entries. The first entry is the name of the domain. Note that if the name is a +string then it can be combined accross functions and translation units. A +self-reference can be used to create globally unique domain names. A +descriptive string may optionally be provided as a second list entry. + +The metadata identifying each scope is also itself a list containing two or +three entries. The first entry is the name of the scope. Note that if the name +is a string then it can be combined accross functions and translation units. A +self-reference can be used to create globally unique scope names. A metadata +reference to the scope's domain is the second entry. A descriptive string may +optionally be provided as a third list entry. + +For example, + +.. code-block:: llvm + + ; Two scope domains: + !0 = metadata !{metadata !0} + !1 = metadata !{metadata !1} + + ; Some scopes in these domains: + !2 = metadata !{metadata !2, metadata !0} + !3 = metadata !{metadata !3, metadata !0} + !4 = metadata !{metadata !4, metadata !1} + + ; Some scope lists: + !5 = metadata !{metadata !4} ; A list containing only scope !4 + !6 = metadata !{metadata !4, metadata !3, metadata !2} + !7 = metadata !{metadata !3} + + ; These two instructions don't alias: + %0 = load float* %c, align 4, !alias.scope !5 + store float %0, float* %arrayidx.i, align 4, !noalias !5 + + ; These two instructions also don't alias (for domain !1, the set of scopes + ; in the !alias.scope equals that in the !noalias list): + %2 = load float* %c, align 4, !alias.scope !5 + store float %2, float* %arrayidx.i2, align 4, !noalias !6 + + ; These two instructions don't alias (for domain !0, the set of scopes in + ; the !noalias list is not a superset of, or equal to, the scopes in the + ; !alias.scope list): + %2 = load float* %c, align 4, !alias.scope !6 + store float %0, float* %arrayidx.i, align 4, !noalias !7 + '``fpmath``' Metadata ^^^^^^^^^^^^^^^^^^^^^ @@ -2889,17 +3026,121 @@ constructs: !0 = metadata !{ metadata !0 } !1 = metadata !{ metadata !1 } -The loop identifier metadata can be used to specify additional per-loop -metadata. Any operands after the first operand can be treated as user-defined -metadata. For example the ``llvm.loop.vectorize.unroll`` metadata is understood -by the loop vectorizer to indicate how many times to unroll the loop: +The loop identifier metadata can be used to specify additional +per-loop metadata. Any operands after the first operand can be treated +as user-defined metadata. For example the ``llvm.loop.unroll.count`` +suggests an unroll factor to the loop unroller: .. code-block:: llvm br i1 %exitcond, label %._crit_edge, label %.lr.ph, !llvm.loop !0 ... !0 = metadata !{ metadata !0, metadata !1 } - !1 = metadata !{ metadata !"llvm.loop.vectorize.unroll", i32 2 } + !1 = metadata !{ metadata !"llvm.loop.unroll.count", i32 4 } + +'``llvm.loop.vectorize``' and '``llvm.loop.interleave``' +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Metadata prefixed with ``llvm.loop.vectorize`` or ``llvm.loop.interleave`` are +used to control per-loop vectorization and interleaving parameters such as +vectorization width and interleave count. These metadata should be used in +conjunction with ``llvm.loop`` loop identification metadata. The +``llvm.loop.vectorize`` and ``llvm.loop.interleave`` metadata are only +optimization hints and the optimizer will only interleave and vectorize loops if +it believes it is safe to do so. The ``llvm.mem.parallel_loop_access`` metadata +which contains information about loop-carried memory dependencies can be helpful +in determining the safety of these transformations. + +'``llvm.loop.interleave.count``' Metadata +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This metadata suggests an interleave count to the loop interleaver. +The first operand is the string ``llvm.loop.interleave.count`` and the +second operand is an integer specifying the interleave count. For +example: + +.. code-block:: llvm + + !0 = metadata !{ metadata !"llvm.loop.interleave.count", i32 4 } + +Note that setting ``llvm.loop.interleave.count`` to 1 disables interleaving +multiple iterations of the loop. If ``llvm.loop.interleave.count`` is set to 0 +then the interleave count will be determined automatically. + +'``llvm.loop.vectorize.enable``' Metadata +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This metadata selectively enables or disables vectorization for the loop. The +first operand is the string ``llvm.loop.vectorize.enable`` and the second operand +is a bit. If the bit operand value is 1 vectorization is enabled. A value of +0 disables vectorization: + +.. code-block:: llvm + + !0 = metadata !{ metadata !"llvm.loop.vectorize.enable", i1 0 } + !1 = metadata !{ metadata !"llvm.loop.vectorize.enable", i1 1 } + +'``llvm.loop.vectorize.width``' Metadata +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This metadata sets the target width of the vectorizer. The first +operand is the string ``llvm.loop.vectorize.width`` and the second +operand is an integer specifying the width. For example: + +.. code-block:: llvm + + !0 = metadata !{ metadata !"llvm.loop.vectorize.width", i32 4 } + +Note that setting ``llvm.loop.vectorize.width`` to 1 disables +vectorization of the loop. If ``llvm.loop.vectorize.width`` is set to +0 or if the loop does not have this metadata the width will be +determined automatically. + +'``llvm.loop.unroll``' +^^^^^^^^^^^^^^^^^^^^^^ + +Metadata prefixed with ``llvm.loop.unroll`` are loop unrolling +optimization hints such as the unroll factor. ``llvm.loop.unroll`` +metadata should be used in conjunction with ``llvm.loop`` loop +identification metadata. The ``llvm.loop.unroll`` metadata are only +optimization hints and the unrolling will only be performed if the +optimizer believes it is safe to do so. + +'``llvm.loop.unroll.count``' Metadata +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This metadata suggests an unroll factor to the loop unroller. The +first operand is the string ``llvm.loop.unroll.count`` and the second +operand is a positive integer specifying the unroll factor. For +example: + +.. code-block:: llvm + + !0 = metadata !{ metadata !"llvm.loop.unroll.count", i32 4 } + +If the trip count of the loop is less than the unroll count the loop +will be partially unrolled. + +'``llvm.loop.unroll.disable``' Metadata +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This metadata either disables loop unrolling. The metadata has a single operand +which is the string ``llvm.loop.unroll.disable``. For example: + +.. code-block:: llvm + + !0 = metadata !{ metadata !"llvm.loop.unroll.disable" } + +'``llvm.loop.unroll.full``' Metadata +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This metadata either suggests that the loop should be unrolled fully. The +metadata has a single operand which is the string ``llvm.loop.unroll.disable``. +For example: + +.. code-block:: llvm + + !0 = metadata !{ metadata !"llvm.loop.unroll.full" } '``llvm.mem``' ^^^^^^^^^^^^^^^ @@ -2984,55 +3225,6 @@ the loop identifier metadata node directly: !1 = metadata !{ metadata !1 } ; an identifier for the inner loop !2 = metadata !{ metadata !2 } ; an identifier for the outer loop -'``llvm.loop.vectorize``' -^^^^^^^^^^^^^^^^^^^^^^^^^ - -Metadata prefixed with ``llvm.loop.vectorize`` is used to control per-loop -vectorization parameters such as vectorization factor and unroll factor. - -``llvm.loop.vectorize`` metadata should be used in conjunction with -``llvm.loop`` loop identification metadata. - -'``llvm.loop.vectorize.unroll``' Metadata -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -This metadata instructs the loop vectorizer to unroll the specified -loop exactly ``N`` times. - -The first operand is the string ``llvm.loop.vectorize.unroll`` and the second -operand is an integer specifying the unroll factor. For example: - -.. code-block:: llvm - - !0 = metadata !{ metadata !"llvm.loop.vectorize.unroll", i32 4 } - -Note that setting ``llvm.loop.vectorize.unroll`` to 1 disables -unrolling of the loop. - -If ``llvm.loop.vectorize.unroll`` is set to 0 then the amount of -unrolling will be determined automatically. - -'``llvm.loop.vectorize.width``' Metadata -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -This metadata sets the target width of the vectorizer to ``N``. Without -this metadata, the vectorizer will choose a width automatically. -Regardless of this metadata, the vectorizer will only vectorize loops if -it believes it is valid to do so. - -The first operand is the string ``llvm.loop.vectorize.width`` and the -second operand is an integer specifying the width. For example: - -.. code-block:: llvm - - !0 = metadata !{ metadata !"llvm.loop.vectorize.width", i32 4 } - -Note that setting ``llvm.loop.vectorize.width`` to 1 disables -vectorization of the loop. - -If ``llvm.loop.vectorize.width`` is set to 0 then the width will be -determined automatically. - Module Flags Metadata ===================== @@ -4885,7 +5077,7 @@ Example: %agg1 = insertvalue {i32, float} undef, i32 1, 0 ; yields {i32 1, float undef} %agg2 = insertvalue {i32, float} %agg1, float %val, 1 ; yields {i32 1, float %val} - %agg3 = insertvalue {i32, {float}} %agg1, float %val, 1, 0 ; yields {i32 1, float %val} + %agg3 = insertvalue {i32, {float}} undef, float %val, 1, 0 ; yields {i32 undef, {float %val}} .. _memoryops: @@ -4925,9 +5117,10 @@ bytes of memory on the runtime stack, returning a pointer of the appropriate type to the program. If "NumElements" is specified, it is the number of elements allocated, otherwise "NumElements" is defaulted to be one. If a constant alignment is specified, the value result of the -allocation is guaranteed to be aligned to at least that boundary. If not -specified, or if zero, the target can choose to align the allocation on -any convenient boundary compatible with the type. +allocation is guaranteed to be aligned to at least that boundary. The +alignment may not be greater than ``1 << 29``. If not specified, or if +zero, the target can choose to align the allocation on any convenient +boundary compatible with the type. '``type``' may be any sized type. @@ -4964,7 +5157,7 @@ Syntax: :: - <result> = load [volatile] <ty>* <pointer>[, align <alignment>][, !nontemporal !<index>][, !invariant.load !<index>] + <result> = load [volatile] <ty>* <pointer>[, align <alignment>][, !nontemporal !<index>][, !invariant.load !<index>][, !nonnull !<index>] <result> = load atomic [volatile] <ty>* <pointer> [singlethread] <ordering>, align <alignment> !<index> = !{ i32 1 } @@ -5001,7 +5194,8 @@ or an omitted ``align`` argument means that the operation has the ABI alignment for the target. It is the responsibility of the code emitter to ensure that the alignment information is correct. Overestimating the alignment results in undefined behavior. Underestimating the alignment -may produce less efficient code. An alignment of 1 is always safe. +may produce less efficient code. An alignment of 1 is always safe. The +maximum possible alignment is ``1 << 29``. The optional ``!nontemporal`` metadata must reference a single metadata name ``<index>`` corresponding to a metadata node with one @@ -5019,6 +5213,14 @@ address points to memory which does not change value during program execution. The optimizer may then move this load around, for example, by hoisting it out of loops using loop invariant code motion. +The optional ``!nonnull`` metadata must reference a single +metadata name ``<index>`` corresponding to a metadata node with no +entries. The existence of the ``!nonnull`` metadata on the +instruction tells the optimizer that the value loaded is known to +never be null. This is analogous to the ''nonnull'' attribute +on parameters and return values. This metadata can only be applied +to loads of a pointer type. + Semantics: """""""""" @@ -5087,7 +5289,7 @@ alignment for the target. It is the responsibility of the code emitter to ensure that the alignment information is correct. Overestimating the alignment results in undefined behavior. Underestimating the alignment may produce less efficient code. An alignment of 1 is always -safe. +safe. The maximum possible alignment is ``1 << 29``. The optional ``!nontemporal`` metadata must reference a single metadata name ``<index>`` corresponding to a metadata node with one ``i32`` entry of @@ -6399,6 +6601,9 @@ This instruction requires several arguments: - The calling conventions of the caller and callee must match. - All ABI-impacting function attributes, such as sret, byval, inreg, returned, and inalloca, must match. + - The callee must be varargs iff the caller is varargs. Bitcasting a + non-varargs function to the appropriate varargs type is legal so + long as the non-varargs prefixes obey the other rules. Tail call optimization for calls marked ``tail`` is guaranteed to occur if the following conditions are met: @@ -6679,14 +6884,21 @@ variable argument handling intrinsic functions are used. .. code-block:: llvm + ; This struct is different for every platform. For most platforms, + ; it is merely an i8*. + %struct.va_list = type { i8* } + + ; For Unix x86_64 platforms, va_list is the following struct: + ; %struct.va_list = type { i32, i32, i8*, i8* } + define i32 @test(i32 %X, ...) { ; Initialize variable argument processing - %ap = alloca i8* - %ap2 = bitcast i8** %ap to i8* + %ap = alloca %struct.va_list + %ap2 = bitcast %struct.va_list* %ap to i8* call void @llvm.va_start(i8* %ap2) ; Read a single integer argument - %tmp = va_arg i8** %ap, i32 + %tmp = va_arg i8* %ap2, i32 ; Demonstrate usage of llvm.va_copy and llvm.va_end %aq = alloca i8* @@ -7823,9 +8035,9 @@ all types however. declare float @llvm.fabs.f32(float %Val) declare double @llvm.fabs.f64(double %Val) - declare x86_fp80 @llvm.fabs.f80(x86_fp80 %Val) + declare x86_fp80 @llvm.fabs.f80(x86_fp80 %Val) declare fp128 @llvm.fabs.f128(fp128 %Val) - declare ppc_fp128 @llvm.fabs.ppcf128(ppc_fp128 %Val) + declare ppc_fp128 @llvm.fabs.ppcf128(ppc_fp128 %Val) Overview: """"""""" @@ -7845,6 +8057,89 @@ Semantics: This function returns the same values as the libm ``fabs`` functions would, and handles error conditions in the same way. +'``llvm.minnum.*``' Intrinsic +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Syntax: +""""""" + +This is an overloaded intrinsic. You can use ``llvm.minnum`` on any +floating point or vector of floating point type. Not all targets support +all types however. + +:: + + declare float @llvm.minnum.f32(float %Val0, float %Val1) + declare double @llvm.minnum.f64(double %Val0, double %Val1) + declare x86_fp80 @llvm.minnum.f80(x86_fp80 %Val0, x86_fp80 %Val1) + declare fp128 @llvm.minnum.f128(fp128 %Val0, fp128 %Val1) + declare ppc_fp128 @llvm.minnum.ppcf128(ppc_fp128 %Val0, ppc_fp128 %Val1) + +Overview: +""""""""" + +The '``llvm.minnum.*``' intrinsics return the minimum of the two +arguments. + + +Arguments: +"""""""""" + +The arguments and return value are floating point numbers of the same +type. + +Semantics: +"""""""""" + +Follows the IEEE-754 semantics for minNum, which also match for libm's +fmin. + +If either operand is a NaN, returns the other non-NaN operand. Returns +NaN only if both operands are NaN. If the operands compare equal, +returns a value that compares equal to both operands. This means that +fmin(+/-0.0, +/-0.0) could return either -0.0 or 0.0. + +'``llvm.maxnum.*``' Intrinsic +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Syntax: +""""""" + +This is an overloaded intrinsic. You can use ``llvm.maxnum`` on any +floating point or vector of floating point type. Not all targets support +all types however. + +:: + + declare float @llvm.maxnum.f32(float %Val0, float %Val1l) + declare double @llvm.maxnum.f64(double %Val0, double %Val1) + declare x86_fp80 @llvm.maxnum.f80(x86_fp80 %Val0, x86_fp80 %Val1) + declare fp128 @llvm.maxnum.f128(fp128 %Val0, fp128 %Val1) + declare ppc_fp128 @llvm.maxnum.ppcf128(ppc_fp128 %Val0, ppc_fp128 %Val1) + +Overview: +""""""""" + +The '``llvm.maxnum.*``' intrinsics return the maximum of the two +arguments. + + +Arguments: +"""""""""" + +The arguments and return value are floating point numbers of the same +type. + +Semantics: +"""""""""" +Follows the IEEE-754 semantics for maxNum, which also match for libm's +fmax. + +If either operand is a NaN, returns the other non-NaN operand. Returns +NaN only if both operands are NaN. If the operands compare equal, +returns a value that compares equal to both operands. This means that +fmax(+/-0.0, +/-0.0) could return either -0.0 or 0.0. + '``llvm.copysign.*``' Intrinsic ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8651,14 +8946,14 @@ Syntax: :: - declare i16 @llvm.convert.to.fp16(float %a) + declare i16 @llvm.convert.to.fp16.f32(float %a) + declare i16 @llvm.convert.to.fp16.f64(double %a) Overview: """"""""" -The '``llvm.convert.to.fp16``' intrinsic function performs a conversion -from single precision floating point format to half precision floating -point format. +The '``llvm.convert.to.fp16``' intrinsic function performs a conversion from a +conventional floating point type to half precision floating point format. Arguments: """""""""" @@ -8669,17 +8964,16 @@ converted. Semantics: """""""""" -The '``llvm.convert.to.fp16``' intrinsic function performs a conversion -from single precision floating point format to half precision floating -point format. The return value is an ``i16`` which contains the -converted number. +The '``llvm.convert.to.fp16``' intrinsic function performs a conversion from a +conventional floating point format to half precision floating point format. The +return value is an ``i16`` which contains the converted number. Examples: """"""""" .. code-block:: llvm - %res = call i16 @llvm.convert.to.fp16(float %a) + %res = call i16 @llvm.convert.to.fp16.f32(float %a) store i16 %res, i16* @x, align 2 .. _int_convert_from_fp16: @@ -8692,7 +8986,8 @@ Syntax: :: - declare float @llvm.convert.from.fp16(i16 %a) + declare float @llvm.convert.from.fp16.f32(i16 %a) + declare double @llvm.convert.from.fp16.f64(i16 %a) Overview: """"""""" @@ -9291,6 +9586,46 @@ Semantics: This intrinsic is lowered to the ``val``. +'``llvm.assume``' Intrinsic +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Syntax: +""""""" + +:: + + declare void @llvm.assume(i1 %cond) + +Overview: +""""""""" + +The ``llvm.assume`` allows the optimizer to assume that the provided +condition is true. This information can then be used in simplifying other parts +of the code. + +Arguments: +"""""""""" + +The condition which the optimizer may assume is always true. + +Semantics: +"""""""""" + +The intrinsic allows the optimizer to assume that the provided condition is +always true whenever the control flow reaches the intrinsic call. No code is +generated for this intrinsic, and instructions that contribute only to the +provided condition are not used for code generation. If the condition is +violated during execution, the behavior is undefined. + +Please note that optimizer might limit the transformations performed on values +used by the ``llvm.assume`` intrinsic in order to preserve the instructions +only used to form the intrinsic's input argument. This might prove undesirable +if the extra information provided by the ``llvm.assume`` intrinsic does cause +sufficient overall improvement in code quality. For this reason, +``llvm.assume`` should not be used to document basic mathematical invariants +that the optimizer can otherwise deduce or facts that are of little use to the +optimizer. + '``llvm.donothing``' Intrinsic ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -9304,8 +9639,9 @@ Syntax: Overview: """"""""" -The ``llvm.donothing`` intrinsic doesn't perform any operation. It's the -only intrinsic that can be called with an invoke instruction. +The ``llvm.donothing`` intrinsic doesn't perform any operation. It's one of only +two intrinsics (besides ``llvm.experimental.patchpoint``) that can be called +with an invoke instruction. Arguments: """""""""" diff --git a/docs/Lexicon.rst b/docs/Lexicon.rst index fccfd5f..9a599da 100644 --- a/docs/Lexicon.rst +++ b/docs/Lexicon.rst @@ -133,6 +133,15 @@ M **MC** Machine Code +N +- + +**NFC** + "No functional change". Used in a commit message to indicate that a patch + is a pure refactoring/cleanup. + Usually used in the first line, so it is visible without opening the + actual commit email. + O - .. _object pointer: @@ -159,7 +168,7 @@ R ``Constant::replaceUsesOfWithOnConstant()`` implement the replacement of one Value with another by iterating over its def/use chain and fixing up all of the pointers to point to the new value. See - also `def/use chains <ProgrammersManual.html#iterate_chains>`_. + also `def/use chains <ProgrammersManual.html#iterating-over-def-use-use-def-chains>`_. **Reassociation** Rearranging associative expressions to promote better redundancy elimination diff --git a/docs/MCJITDesignAndImplementation.rst b/docs/MCJITDesignAndImplementation.rst index 2cb6296..237a5be 100644 --- a/docs/MCJITDesignAndImplementation.rst +++ b/docs/MCJITDesignAndImplementation.rst @@ -57,7 +57,7 @@ attempt to retrieve an object image from its ObjectCache member, if one has been set. If a cached object image cannot be retrieved, MCJIT will
call its emitObject method. MCJIT::emitObject uses a local PassManager
instance and creates a new ObjectBufferStream instance, both of which it
-passes to TargetManager::addPassesToEmitMC before calling PassManager::run
+passes to TargetMachine::addPassesToEmitMC before calling PassManager::run
on the Module with which it was created.
.. image:: MCJIT-load.png
diff --git a/docs/Makefile b/docs/Makefile index d973af5..690f772 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -1,10 +1,10 @@ ##===- docs/Makefile ---------------------------------------*- Makefile -*-===## -# +# # The LLVM Compiler Infrastructure # # This file is distributed under the University of Illinois Open Source # License. See LICENSE.TXT for details. -# +# ##===----------------------------------------------------------------------===## LEVEL := .. @@ -121,7 +121,8 @@ regen-ocamldoc: $(Verb) $(MKDIR) $(PROJ_OBJ_DIR)/ocamldoc/html $(Verb) \ $(OCAMLDOC) -d $(PROJ_OBJ_DIR)/ocamldoc/html -sort -colorize-code -html \ - `$(FIND) $(LEVEL)/bindings/ocaml -name "*.odoc" -exec echo -load '{}' ';'` + `$(FIND) $(LEVEL)/bindings/ocaml -name "*.odoc" \ + -path "*/$(BuildMode)/*.odoc" -exec echo -load '{}' ';'` uninstall-local:: $(Echo) Uninstalling Documentation diff --git a/docs/ProgrammersManual.rst b/docs/ProgrammersManual.rst index a7b28b3..85a4ad8 100644 --- a/docs/ProgrammersManual.rst +++ b/docs/ProgrammersManual.rst @@ -298,7 +298,9 @@ The ``function_ref`` (`doxygen <http://llvm.org/doxygen/classllvm_1_1function_ref.html>`__) class template represents a reference to a callable object, templated over the type of the callable. This is a good choice for passing a callback to a function, -if you don't need to hold onto the callback after the function returns. +if you don't need to hold onto the callback after the function returns. In this +way, ``function_ref`` is to ``std::function`` as ``StringRef`` is to +``std::string``. ``function_ref<Ret(Param1, Param2, ...)>`` can be implicitly constructed from any callable object that can be called with arguments of type ``Param1``, @@ -323,17 +325,11 @@ can be called using: return false; }); -Note that a ``function_ref`` object contains pointers to external memory, so -it is not generally safe to store an instance of the class (unless you know -that the external storage will not be freed). -``function_ref`` is small enough that it should always be passed by value. - -``std::function`` -^^^^^^^^^^^^^^^^^ - -You cannot use ``std::function`` within LLVM code, because it is not supported -by all our target toolchains. - +Note that a ``function_ref`` object contains pointers to external memory, so it +is not generally safe to store an instance of the class (unless you know that +the external storage will not be freed). If you need this ability, consider +using ``std::function``. ``function_ref`` is small enough that it should always +be passed by value. .. _DEBUG: @@ -426,9 +422,12 @@ to specify the debug type for the entire module (if you do this before you because there is no system in place to ensure that names do not conflict. If two different modules use the same string, they will all be turned on when the name is specified. This allows, for example, all debug information for -instruction scheduling to be enabled with ``-debug-type=InstrSched``, even if +instruction scheduling to be enabled with ``-debug-only=InstrSched``, even if the source lives in multiple files. +For performance reasons, -debug-only is not available in optimized build +(``--enable-optimized``) of LLVM. + The ``DEBUG_WITH_TYPE`` macro is also available for situations where you would like to set ``DEBUG_TYPE``, but only for one specific ``DEBUG`` statement. It takes an additional first parameter, which is the type to use. For example, the @@ -877,7 +876,7 @@ variety of customizations. llvm/ADT/ilist_node.h ^^^^^^^^^^^^^^^^^^^^^ -``ilist_node<T>`` implements a the forward and backward links that are expected +``ilist_node<T>`` implements the forward and backward links that are expected by the ``ilist<T>`` (and analogous containers) in the default manner. ``ilist_node<T>``\ s are meant to be embedded in the node type ``T``, usually @@ -1441,8 +1440,10 @@ order, making it an easy (but somewhat expensive) solution for non-deterministic iteration over maps of pointers. It is implemented by mapping from key to an index in a vector of key,value -pairs. This provides fast lookup and iteration, but has two main drawbacks: The -key is stored twice and it doesn't support removing elements. +pairs. This provides fast lookup and iteration, but has two main drawbacks: +the key is stored twice and removing elements takes linear time. If it is +necessary to remove elements, it's best to remove them in bulk using +``remove_if()``. .. _dss_inteqclasses: diff --git a/docs/R600Usage.rst b/docs/R600Usage.rst new file mode 100644 index 0000000..48a30c8 --- /dev/null +++ b/docs/R600Usage.rst @@ -0,0 +1,43 @@ +============================ +User Guide for R600 Back-end +============================ + +Introduction +============ + +The R600 back-end provides ISA code generation for AMD GPUs, starting with +the R600 family up until the current Sea Islands (GCN Gen 2). + + +Assembler +========= + +The assembler is currently a work in progress and not yet complete. Below +are the currently supported features. + +SOPP Instructions +----------------- + +Unless otherwise mentioned, all SOPP instructions that with an operand +accept a integer operand(s) only. No verification is performed on the +operands, so it is up to the programmer to be familiar with the range +or acceptable values. + +s_waitcnt +^^^^^^^^^ + +s_waitcnt accepts named arguments to specify which memory counter(s) to +wait for. + +.. code-block:: nasm + + // Wait for all counters to be 0 + s_waitcnt 0 + + // Equivalent to s_waitcnt 0. Counter names can also be delimited by + // '&' or ','. + s_waitcnt vmcnt(0) expcnt(0) lgkcmt(0) + + // Wait for vmcnt counter to be 1. + s_waitcnt vmcnt(1) + diff --git a/docs/ReleaseNotes.rst b/docs/ReleaseNotes.rst index fb2e248..be2954c 100644 --- a/docs/ReleaseNotes.rst +++ b/docs/ReleaseNotes.rst @@ -6,8 +6,8 @@ LLVM 3.5 Release Notes :local: .. warning:: - These are in-progress notes for the upcoming LLVM 3.5 release. You may - prefer the `LLVM 3.4 Release Notes <http://llvm.org/releases/3.4/docs + These are in-progress notes for the upcoming LLVM 3.6 release. You may + prefer the `LLVM 3.5 Release Notes <http://llvm.org/releases/3.5.0/docs /ReleaseNotes.html>`_. @@ -15,7 +15,7 @@ Introduction ============ This document contains the release notes for the LLVM Compiler Infrastructure, -release 3.5. Here we describe the status of LLVM, including major improvements +release 3.6. Here we describe the status of LLVM, including major improvements from the previous release, improvements in various subprojects of LLVM, and some of the current users of the code. All LLVM releases may be downloaded from the `LLVM releases web site <http://llvm.org/releases/>`_. @@ -34,35 +34,6 @@ page <http://llvm.org/releases/>`_. Non-comprehensive list of changes in this release ================================================= -* All backends have been changed to use the MC asm printer and support for the - non MC one has been removed. - -* Clang can now successfully self-host itself on Linux/Sparc64 and on - FreeBSD/Sparc64. - -* LLVM now assumes the assembler supports ``.loc`` for generating debug line - numbers. The old support for printing the debug line info directly was only - used by ``llc`` and has been removed. - -* All inline assembly is parsed by the integrated assembler when it is enabled. - Previously this was only the case for object-file output. It is now the case - for assembly output as well. The integrated assembler can be disabled with - the ``-no-integrated-as`` option, - -* llvm-ar now handles IR files like regular object files. In particular, a - regular symbol table is created for symbols defined in IR files, including - those in file scope inline assembly. - -* LLVM now always uses cfi directives for producing most stack - unwinding information. - -* The prefix for loop vectorizer hint metadata has been changed from - ``llvm.vectorizer`` to ``llvm.loop.vectorize``. - -* Some backends previously implemented Atomic NAND(x,y) as ``x & ~y``. Now - all backends implement it as ``~(x & y)``, matching the semantics of GCC 4.4 - and later. - .. NOTE For small 1-3 sentence descriptions, just add an entry at the end of this list. If your description won't fit comfortably in one bullet @@ -70,6 +41,11 @@ Non-comprehensive list of changes in this release functionality, or simply have a lot to talk about), see the `NOTE` below for adding a new subsection. +* Support for AuroraUX has been removed. + +* Added support for a `native object file-based bitcode wrapper format + <BitCodeFormat.html#native-object-file>`_. + * ... next change ... .. NOTE @@ -85,40 +61,27 @@ Non-comprehensive list of changes in this release Changes to the ARM Backend -------------------------- -Since release 3.3, a lot of new features have been included in the ARM -back-end but weren't production ready (ie. well tested) on release 3.4. -Just after the 3.4 release, we started heavily testing two major parts -of the back-end: the integrated assembler (IAS) and the ARM exception -handling (EHABI), and now they are enabled by default on LLVM/Clang. - -The IAS received a lot of GNU extensions and directives, as well as some -specific pre-UAL instructions. Not all remaining directives will be -implemented, as we made judgement calls on the need versus the complexity, -and have chosen simplicity and future compatibility where hard decisions -had to be made. The major difference is, as stated above, the IAS validates -all inline ASM, not just for object emission, and that cause trouble with -some uses of inline ASM as pre-processor magic. - -So, while the IAS is good enough to compile large projects (including most -of the Linux kernel), there are a few things that we can't (and probably -won't) do. For those cases, please use ``-fno-integrated-as`` in Clang. - -Exception handling is another big change. After extensive testing and -changes to cooperate with Dwarf unwinding, EHABI is enabled by default. -The options ``-arm-enable-ehabi`` and ``-arm-enable-ehabi-descriptors``, -which were used to enable EHABI in the previous releases, are removed now. - -This means all ARM code will emit EH unwind tables, or CFI unwinding (for -debug/profiling), or both. To avoid run-time inconsistencies, C code will -also emit EH tables (in case they interoperate with C++ code), as is the -case for other architectures (ex. x86_64). - -External Open Source Projects Using LLVM 3.5 + During this release ... + + +Changes to the MIPS Target +-------------------------- + +During this release ... + +Changes to the PowerPC Target +----------------------------- + +During this release ... + +External Open Source Projects Using LLVM 3.6 ============================================ An exciting aspect of LLVM is that it is used as an enabling technology for a lot of other language and tools projects. This section lists some of the -projects that have already been updated to work with LLVM 3.5. +projects that have already been updated to work with LLVM 3.6. + +* A project Additional Information diff --git a/docs/SourceLevelDebugging.rst b/docs/SourceLevelDebugging.rst index 869d3a3..3a5fa6e 100644 --- a/docs/SourceLevelDebugging.rst +++ b/docs/SourceLevelDebugging.rst @@ -186,11 +186,15 @@ the simple data types ``i32``, ``i1``, ``float``, ``double``, ``mdstring`` and ... } -<a name="LLVMDebugVersion">The first field of a descriptor is always an -``i32`` containing a tag value identifying the content of the descriptor. -The remaining fields are specific to the descriptor. The values of tags are -loosely bound to the tag values of DWARF information entries. However, that -does not restrict the use of the information supplied to DWARF targets. +Most of the string and integer fields in descriptors are packed into a single, +null-separated ``mdstring``. The first field of the header is always an +``i32`` containing the DWARF tag value identifying the content of the +descriptor. + +For clarity of definition in this document, these header fields are described +below split inside an imaginary ``DIHeader`` construct. This is invalid +assembly syntax. In valid IR, these fields are stringified and concatenated, +separated by ``\00``. The details of the various descriptors follow. @@ -200,19 +204,22 @@ Compile unit descriptors .. code-block:: llvm !0 = metadata !{ - i32, ;; Tag = 17 (DW_TAG_compile_unit) + DIHeader( + i32, ;; Tag = 17 (DW_TAG_compile_unit) + i32, ;; DWARF language identifier (ex. DW_LANG_C89) + mdstring, ;; Producer (ex. "4.0.1 LLVM (LLVM research group)") + i1, ;; True if this is optimized. + mdstring, ;; Flags + i32, ;; Runtime version + mdstring, ;; Split debug filename + i32 ;; Debug info emission kind (1 = Full Debug Info, 2 = Line Tables Only) + ), metadata, ;; Source directory (including trailing slash) & file pair - i32, ;; DWARF language identifier (ex. DW_LANG_C89) - metadata ;; Producer (ex. "4.0.1 LLVM (LLVM research group)") - i1, ;; True if this is optimized. - metadata, ;; Flags - i32 ;; Runtime version - metadata ;; List of enums types - metadata ;; List of retained types - metadata ;; List of subprograms - metadata ;; List of global variables + metadata, ;; List of enums types + metadata, ;; List of retained types + metadata, ;; List of subprograms + metadata, ;; List of global variables metadata ;; List of imported entities - metadata ;; Split debug filename } These descriptors contain a source language ID for the file (we use the DWARF @@ -235,8 +242,10 @@ File descriptors .. code-block:: llvm !0 = metadata !{ - i32, ;; Tag = 41 (DW_TAG_file_type) - metadata, ;; Source directory (including trailing slash) & file pair + DIHeader( + i32 ;; Tag = 41 (DW_TAG_file_type) + ), + metadata ;; Source directory (including trailing slash) & file pair } These descriptors contain information for a file. Global variables and top @@ -254,17 +263,18 @@ Global variable descriptors .. code-block:: llvm !1 = metadata !{ - i32, ;; Tag = 52 (DW_TAG_variable) - i32, ;; Unused field. + DIHeader( + i32, ;; Tag = 52 (DW_TAG_variable) + mdstring, ;; Name + mdstring, ;; Display name (fully qualified C++ name) + mdstring, ;; MIPS linkage name (for C++) + i32, ;; Line number where defined + i1, ;; True if the global is local to compile unit (static) + i1 ;; True if the global is defined in the compile unit (not extern) + ), metadata, ;; Reference to context descriptor - metadata, ;; Name - metadata, ;; Display name (fully qualified C++ name) - metadata, ;; MIPS linkage name (for C++) metadata, ;; Reference to file where defined - i32, ;; Line number where defined metadata, ;; Reference to type descriptor - i1, ;; True if the global is local to compile unit (static) - i1, ;; True if the global is defined in the compile unit (not extern) {}*, ;; Reference to the global variable metadata, ;; The static member declaration, if any } @@ -281,27 +291,29 @@ Subprogram descriptors .. code-block:: llvm !2 = metadata !{ - i32, ;; Tag = 46 (DW_TAG_subprogram) + DIHeader( + i32, ;; Tag = 46 (DW_TAG_subprogram) + mdstring, ;; Name + mdstring, ;; Display name (fully qualified C++ name) + mdstring, ;; MIPS linkage name (for C++) + i32, ;; Line number where defined + i1, ;; True if the global is local to compile unit (static) + i1, ;; True if the global is defined in the compile unit (not extern) + i32, ;; Virtuality, e.g. dwarf::DW_VIRTUALITY__virtual + i32, ;; Index into a virtual function + i32, ;; Flags - Artificial, Private, Protected, Explicit, Prototyped. + i1, ;; isOptimized + i32 ;; Line number where the scope of the subprogram begins + ), metadata, ;; Source directory (including trailing slash) & file pair metadata, ;; Reference to context descriptor - metadata, ;; Name - metadata, ;; Display name (fully qualified C++ name) - metadata, ;; MIPS linkage name (for C++) - i32, ;; Line number where defined metadata, ;; Reference to type descriptor - i1, ;; True if the global is local to compile unit (static) - i1, ;; True if the global is defined in the compile unit (not extern) - i32, ;; Virtuality, e.g. dwarf::DW_VIRTUALITY__virtual - i32, ;; Index into a virtual function metadata, ;; indicates which base type contains the vtable pointer for the ;; derived class - i32, ;; Flags - Artificial, Private, Protected, Explicit, Prototyped. - i1, ;; isOptimized {}*, ;; Reference to the LLVM function metadata, ;; Lists function template parameters metadata, ;; Function declaration descriptor - metadata, ;; List of function variables - i32 ;; Line number where the scope of the subprogram begins + metadata ;; List of function variables } These descriptors provide debug information about functions, methods and @@ -314,13 +326,14 @@ Block descriptors .. code-block:: llvm !3 = metadata !{ - i32, ;; Tag = 11 (DW_TAG_lexical_block) + DIHeader( + i32, ;; Tag = 11 (DW_TAG_lexical_block) + i32, ;; Line number + i32, ;; Column number + i32 ;; Unique ID to identify blocks from a template function + ), metadata, ;; Source directory (including trailing slash) & file pair - metadata, ;; Reference to context descriptor - i32, ;; Line number - i32, ;; Column number - i32, ;; DWARF path discriminator value - i32 ;; Unique ID to identify blocks from a template function + metadata ;; Reference to context descriptor } This descriptor provides debug information about nested blocks within a @@ -330,7 +343,10 @@ lexical blocks at same depth. .. code-block:: llvm !3 = metadata !{ - i32, ;; Tag = 11 (DW_TAG_lexical_block) + DIHeader( + i32, ;; Tag = 11 (DW_TAG_lexical_block) + i32 ;; DWARF path discriminator value + ), metadata, ;; Source directory (including trailing slash) & file pair metadata ;; Reference to the scope we're annotating with a file change } @@ -346,16 +362,18 @@ Basic type descriptors .. code-block:: llvm !4 = metadata !{ - i32, ;; Tag = 36 (DW_TAG_base_type) + DIHeader( + i32, ;; Tag = 36 (DW_TAG_base_type) + mdstring, ;; Name (may be "" for anonymous types) + i32, ;; Line number where defined (may be 0) + i64, ;; Size in bits + i64, ;; Alignment in bits + i64, ;; Offset in bits + i32, ;; Flags + i32 ;; DWARF type encoding + ), metadata, ;; Source directory (including trailing slash) & file pair (may be null) - metadata, ;; Reference to context - metadata, ;; Name (may be "" for anonymous types) - i32, ;; Line number where defined (may be 0) - i64, ;; Size in bits - i64, ;; Alignment in bits - i64, ;; Offset in bits - i32, ;; Flags - i32 ;; DWARF type encoding + metadata ;; Reference to context } These descriptors define primitive types used in the code. Example ``int``, @@ -389,22 +407,19 @@ Derived type descriptors .. code-block:: llvm !5 = metadata !{ - i32, ;; Tag (see below) + DIHeader( + i32, ;; Tag (see below) + mdstring, ;; Name (may be "" for anonymous types) + i32, ;; Line number where defined (may be 0) + i64, ;; Size in bits + i64, ;; Alignment in bits + i64, ;; Offset in bits + i32 ;; Flags to encode attributes, e.g. private + ), metadata, ;; Source directory (including trailing slash) & file pair (may be null) metadata, ;; Reference to context - metadata, ;; Name (may be "" for anonymous types) - i32, ;; Line number where defined (may be 0) - i64, ;; Size in bits - i64, ;; Alignment in bits - i64, ;; Offset in bits - i32, ;; Flags to encode attributes, e.g. private metadata, ;; Reference to type derived from - metadata, ;; (optional) Name of the Objective C property associated with - ;; Objective-C an ivar, or the type of which this - ;; pointer-to-member is pointing to members of. - metadata, ;; (optional) Name of the Objective C property getter selector. - metadata, ;; (optional) Name of the Objective C property setter selector. - i32 ;; (optional) Objective C property attributes. + metadata ;; (optional) Objective C property node } These descriptors are used to define types derived from other types. The value @@ -452,21 +467,23 @@ Composite type descriptors .. code-block:: llvm !6 = metadata !{ - i32, ;; Tag (see below) + DIHeader( + i32, ;; Tag (see below) + mdstring, ;; Name (may be "" for anonymous types) + i32, ;; Line number where defined (may be 0) + i64, ;; Size in bits + i64, ;; Alignment in bits + i64, ;; Offset in bits + i32, ;; Flags + i32 ;; Runtime languages + ), metadata, ;; Source directory (including trailing slash) & file pair (may be null) metadata, ;; Reference to context - metadata, ;; Name (may be "" for anonymous types) - i32, ;; Line number where defined (may be 0) - i64, ;; Size in bits - i64, ;; Alignment in bits - i64, ;; Offset in bits - i32, ;; Flags metadata, ;; Reference to type derived from metadata, ;; Reference to array of member descriptors - i32, ;; Runtime languages metadata, ;; Base type containing the vtable pointer for this type metadata, ;; Template parameters - metadata ;; A unique identifier for type uniquing purpose (may be null) + mdstring ;; A unique identifier for type uniquing purpose (may be null) } These descriptors are used to define types that are composed of 0 or more @@ -528,9 +545,11 @@ Subrange descriptors .. code-block:: llvm !42 = metadata !{ - i32, ;; Tag = 33 (DW_TAG_subrange_type) - i64, ;; Low value - i64 ;; High value + DIHeader( + i32, ;; Tag = 33 (DW_TAG_subrange_type) + i64, ;; Low value + i64 ;; High value + ) } These descriptors are used to define ranges of array subscripts for an array @@ -547,9 +566,11 @@ Enumerator descriptors .. code-block:: llvm !6 = metadata !{ - i32, ;; Tag = 40 (DW_TAG_enumerator) - metadata, ;; Name - i64 ;; Value + DIHeader( + i32, ;; Tag = 40 (DW_TAG_enumerator) + mdstring, ;; Name + i64 ;; Value + ) } These descriptors are used to define members of an enumeration :ref:`composite @@ -561,16 +582,17 @@ Local variables .. code-block:: llvm !7 = metadata !{ - i32, ;; Tag (see below) + DIHeader( + i32, ;; Tag (see below) + mdstring, ;; Name + i32, ;; 24 bit - Line number where defined + ;; 8 bit - Argument number. 1 indicates 1st argument. + i32 ;; flags + ), metadata, ;; Context - metadata, ;; Name metadata, ;; Reference to file where defined - i32, ;; 24 bit - Line number where defined - ;; 8 bit - Argument number. 1 indicates 1st argument. metadata, ;; Reference to the type descriptor - i32, ;; flags metadata ;; (optional) Reference to inline location - metadata ;; (optional) Reference to a complex expression (see below) } These descriptors are used to define variables local to a sub program. The @@ -589,6 +611,25 @@ The context is either the subprogram or block where the variable is defined. Name the source variable name. Context and line indicate where the variable was defined. Type descriptor defines the declared type of the variable. +Complex Expressions +^^^^^^^^^^^^^^^^^^^ +.. code-block:: llvm + + !8 = metadata !{ + i32, ;; DW_TAG_expression + ... + } + +Complex expressions describe variable storage locations in terms of +prefix-notated DWARF expressions. Currently the only supported +operators are ``DW_OP_plus``, ``DW_OP_deref``, and ``DW_OP_piece``. + +The ``DW_OP_piece`` operator is used for (typically larger aggregate) +variables that are fragmented across several locations. It takes two +i32 arguments, an offset and a size in bytes to describe which piece +of the variable is at this location. + + .. _format_common_intrinsics: Debugger intrinsic functions @@ -726,8 +767,7 @@ Compiled to LLVM, this function would be represented like this: !15 = metadata !{i32 786688, metadata !16, metadata !"Z", metadata !5, i32 5, metadata !11, i32 0, i32 0} ; [ DW_TAG_auto_variable ] [Z] \ [line 5] - !16 = metadata !{i32 786443, metadata !1, metadata !4, i32 4, i32 0, i32 0, - i32 0} \ + !16 = metadata !{i32 786443, metadata !1, metadata !4, i32 4, i32 0, i32 0} \ ; [ DW_TAG_lexical_block ] [/private/tmp/t.c] !17 = metadata !{i32 5, i32 0, metadata !16, null} !18 = metadata !{i32 6, i32 0, metadata !16, null} @@ -779,8 +819,7 @@ scope information for the variable ``Z``. .. code-block:: llvm - !16 = metadata !{i32 786443, metadata !1, metadata !4, i32 4, i32 0, i32 0, - i32 0} + !16 = metadata !{i32 786443, metadata !1, metadata !4, i32 4, i32 0, i32 0} \ ; [ DW_TAG_lexical_block ] [/private/tmp/t.c] !17 = metadata !{i32 5, i32 0, metadata !16, null} @@ -810,73 +849,15 @@ to provide completely different forms if they don't fit into the DWARF model. As support for debugging information gets added to the various LLVM source-language front-ends, the information used should be documented here. -The following sections provide examples of various C/C++ constructs and the -debug information that would best describe those constructs. +The following sections provide examples of a few C/C++ constructs and the debug +information that would best describe those constructs. The canonical +references are the ``DIDescriptor`` classes defined in +``include/llvm/IR/DebugInfo.h`` and the implementations of the helper functions +in ``lib/IR/DIBuilder.cpp``. C/C++ source file information ----------------------------- -Given the source files ``MySource.cpp`` and ``MyHeader.h`` located in the -directory ``/Users/mine/sources``, the following code: - -.. code-block:: c - - #include "MyHeader.h" - - int main(int argc, char *argv[]) { - return 0; - } - -a C/C++ front-end would generate the following descriptors: - -.. code-block:: llvm - - ... - ;; - ;; Define the compile unit for the main source file "/Users/mine/sources/MySource.cpp". - ;; - !0 = metadata !{ - i32 786449, ;; Tag - metadata !1, ;; File/directory name - i32 4, ;; Language Id - metadata !"clang version 3.4 ", - i1 false, ;; Optimized compile unit - metadata !"", ;; Compiler flags - i32 0, ;; Runtime version - metadata !2, ;; Enumeration types - metadata !2, ;; Retained types - metadata !3, ;; Subprograms - metadata !2, ;; Global variables - metadata !2, ;; Imported entities (declarations and namespaces) - metadata !"" ;; Split debug filename - } - - ;; - ;; Define the file for the file "/Users/mine/sources/MySource.cpp". - ;; - !1 = metadata !{ - metadata !"MySource.cpp", - metadata !"/Users/mine/sources" - } - !5 = metadata !{ - i32 786473, ;; Tag - metadata !1 - } - - ;; - ;; Define the file for the file "/Users/mine/sources/Myheader.h" - ;; - !14 = metadata !{ - i32 786473, ;; Tag - metadata !15 - } - !15 = metadata !{ - metadata !"./MyHeader.h", - metadata !"/Users/mine/sources", - } - - ... - ``llvm::Instruction`` provides easy access to metadata attached with an instruction. One can extract line number information encoded in LLVM IR using ``Instruction::getMetadata()`` and ``DILocation::getLineNumber()``. @@ -906,7 +887,7 @@ a C/C++ front-end would generate the following descriptors: ;; ;; Define the global itself. ;; - %MyGlobal = global int 100 + @MyGlobal = global i32 100, align 4 ... ;; ;; List of debug info of globals @@ -915,24 +896,35 @@ a C/C++ front-end would generate the following descriptors: ;; Define the compile unit. !0 = metadata !{ - i32 786449, ;; Tag - i32 0, ;; Context - i32 4, ;; Language - metadata !"foo.cpp", ;; File - metadata !"/Volumes/Data/tmp", ;; Directory - metadata !"clang version 3.1 ", ;; Producer - i1 true, ;; Deprecated field - i1 false, ;; "isOptimized"? - metadata !"", ;; Flags - i32 0, ;; Runtime Version - metadata !1, ;; Enum Types - metadata !1, ;; Retained Types - metadata !1, ;; Subprograms - metadata !3, ;; Global Variables - metadata !1, ;; Imported entities - "", ;; Split debug filename + ; Header( + ; i32 17, ;; Tag + ; i32 0, ;; Context + ; i32 4, ;; Language + ; metadata !"clang version 3.6.0 ", ;; Producer + ; i1 false, ;; "isOptimized"? + ; metadata !"", ;; Flags + ; i32 0, ;; Runtime Version + ; "", ;; Split debug filename + ; 1 ;; Full debug info + ; ) + metadata !"0x11\0012\00clang version 3.6.0 \000\00\000\00\001", + metadata !1, ;; File + metadata !2, ;; Enum Types + metadata !2, ;; Retained Types + metadata !2, ;; Subprograms + metadata !3, ;; Global Variables + metadata !2 ;; Imported entities } ; [ DW_TAG_compile_unit ] + ;; The file/directory pair. + !1 = metadata !{ + metadata !"foo.c", ;; Filename + metadata !"/Users/dexonsmith/data/llvm/debug-info" ;; Directory + } + + ;; An empty array. + !2 = metadata !{} + ;; The Array of Global Variables !3 = metadata !{ metadata !4 @@ -942,17 +934,19 @@ a C/C++ front-end would generate the following descriptors: ;; Define the global variable itself. ;; !4 = metadata !{ - i32 786484, ;; Tag - i32 0, ;; Unused + ; Header( + ; i32 52, ;; Tag + ; metadata !"MyGlobal", ;; Name + ; metadata !"MyGlobal", ;; Display Name + ; metadata !"", ;; Linkage Name + ; i32 1, ;; Line + ; i32 0, ;; IsLocalToUnit + ; i32 1 ;; IsDefinition + ; ) + metadata !"0x34\00MyGlobal\00MyGlobal\00\001\000\001", null, ;; Unused - metadata !"MyGlobal", ;; Name - metadata !"MyGlobal", ;; Display Name - metadata !"", ;; Linkage Name - metadata !6, ;; File - i32 1, ;; Line - metadata !7, ;; Type - i32 0, ;; IsLocalToUnit - i32 1, ;; IsDefinition + metadata !5, ;; File + metadata !6, ;; Type i32* @MyGlobal, ;; LLVM-IR Value null ;; Static member declaration } ; [ DW_TAG_variable ] @@ -961,28 +955,30 @@ a C/C++ front-end would generate the following descriptors: ;; Define the file ;; !5 = metadata !{ - metadata !"foo.cpp", ;; File - metadata !"/Volumes/Data/tmp", ;; Directory - } - !6 = metadata !{ - i32 786473, ;; Tag - metadata !5 ;; Unused + ; Header( + ; i32 41 ;; Tag + ; ) + metadata !"0x29", + metadata !1 ;; File/directory pair } ; [ DW_TAG_file_type ] ;; ;; Define the type ;; - !7 = metadata !{ - i32 786468, ;; Tag - null, ;; Unused - null, ;; Unused - metadata !"int", ;; Name - i32 0, ;; Line - i64 32, ;; Size in Bits - i64 32, ;; Align in Bits - i64 0, ;; Offset - i32 0, ;; Flags - i32 5 ;; Encoding + !6 = metadata !{ + ; Header( + ; i32 36, ;; Tag + ; metadata !"int", ;; Name + ; i32 0, ;; Line + ; i64 32, ;; Size in Bits + ; i64 32, ;; Align in Bits + ; i64 0, ;; Offset + ; i32 0, ;; Flags + ; i32 5 ;; Encoding + ; ) + metadata !"0x24\00int\000\0032\0032\000\000\005", + null, ;; Unused + null ;; Unused } ; [ DW_TAG_base_type ] C/C++ function information @@ -1004,26 +1000,31 @@ a C/C++ front-end would generate the following descriptors: ;; Define the anchor for subprograms. ;; !6 = metadata !{ - i32 786484, ;; Tag - metadata !1, ;; File - metadata !1, ;; Context - metadata !"main", ;; Name - metadata !"main", ;; Display name - metadata !"main", ;; Linkage name - i32 1, ;; Line number - metadata !4, ;; Type - i1 false, ;; Is local - i1 true, ;; Is definition - i32 0, ;; Virtuality attribute, e.g. pure virtual function - i32 0, ;; Index into virtual table for C++ methods - i32 0, ;; Type that holds virtual table. - i32 0, ;; Flags - i1 false, ;; True if this function is optimized - Function *, ;; Pointer to llvm::Function - null, ;; Function template parameters - null, ;; List of function variables (emitted when optimizing) - 1 ;; Line number of the opening '{' of the function + ; Header( + ; i32 46, ;; Tag + ; metadata !"main", ;; Name + ; metadata !"main", ;; Display name + ; metadata !"", ;; Linkage name + ; i32 1, ;; Line number + ; i1 false, ;; Is local + ; i1 true, ;; Is definition + ; i32 0, ;; Virtuality attribute, e.g. pure virtual function + ; i32 0, ;; Index into virtual table for C++ methods + ; i32 256, ;; Flags + ; i1 0, ;; True if this function is optimized + ; 1 ;; Line number of the opening '{' of the function + ; ) + metadata !"0x2e\00main\00main\00\001\000\001\000\000\00256\000\001", + metadata !1, ;; File + metadata !5, ;; Context + metadata !6, ;; Type + null, ;; Containing type + i32 (i32, i8**)* @main, ;; Pointer to llvm::Function + null, ;; Function template parameters + null, ;; Function declaration + metadata !2 ;; List of function variables (emitted when optimizing) } + ;; ;; Define the subprogram itself. ;; @@ -1031,443 +1032,6 @@ a C/C++ front-end would generate the following descriptors: ... } -C/C++ basic types ------------------ - -The following are the basic type descriptors for C/C++ core types: - -bool -^^^^ - -.. code-block:: llvm - - !2 = metadata !{ - i32 786468, ;; Tag - null, ;; File - null, ;; Context - metadata !"bool", ;; Name - i32 0, ;; Line number - i64 8, ;; Size in Bits - i64 8, ;; Align in Bits - i64 0, ;; Offset in Bits - i32 0, ;; Flags - i32 2 ;; Encoding - } - -char -^^^^ - -.. code-block:: llvm - - !2 = metadata !{ - i32 786468, ;; Tag - null, ;; File - null, ;; Context - metadata !"char", ;; Name - i32 0, ;; Line number - i64 8, ;; Size in Bits - i64 8, ;; Align in Bits - i64 0, ;; Offset in Bits - i32 0, ;; Flags - i32 6 ;; Encoding - } - -unsigned char -^^^^^^^^^^^^^ - -.. code-block:: llvm - - !2 = metadata !{ - i32 786468, ;; Tag - null, ;; File - null, ;; Context - metadata !"unsigned char", - i32 0, ;; Line number - i64 8, ;; Size in Bits - i64 8, ;; Align in Bits - i64 0, ;; Offset in Bits - i32 0, ;; Flags - i32 8 ;; Encoding - } - -short -^^^^^ - -.. code-block:: llvm - - !2 = metadata !{ - i32 786468, ;; Tag - null, ;; File - null, ;; Context - metadata !"short int", - i32 0, ;; Line number - i64 16, ;; Size in Bits - i64 16, ;; Align in Bits - i64 0, ;; Offset in Bits - i32 0, ;; Flags - i32 5 ;; Encoding - } - -unsigned short -^^^^^^^^^^^^^^ - -.. code-block:: llvm - - !2 = metadata !{ - i32 786468, ;; Tag - null, ;; File - null, ;; Context - metadata !"short unsigned int", - i32 0, ;; Line number - i64 16, ;; Size in Bits - i64 16, ;; Align in Bits - i64 0, ;; Offset in Bits - i32 0, ;; Flags - i32 7 ;; Encoding - } - -int -^^^ - -.. code-block:: llvm - - !2 = metadata !{ - i32 786468, ;; Tag - null, ;; File - null, ;; Context - metadata !"int", ;; Name - i32 0, ;; Line number - i64 32, ;; Size in Bits - i64 32, ;; Align in Bits - i64 0, ;; Offset in Bits - i32 0, ;; Flags - i32 5 ;; Encoding - } - -unsigned int -^^^^^^^^^^^^ - -.. code-block:: llvm - - !2 = metadata !{ - i32 786468, ;; Tag - null, ;; File - null, ;; Context - metadata !"unsigned int", - i32 0, ;; Line number - i64 32, ;; Size in Bits - i64 32, ;; Align in Bits - i64 0, ;; Offset in Bits - i32 0, ;; Flags - i32 7 ;; Encoding - } - -long long -^^^^^^^^^ - -.. code-block:: llvm - - !2 = metadata !{ - i32 786468, ;; Tag - null, ;; File - null, ;; Context - metadata !"long long int", - i32 0, ;; Line number - i64 64, ;; Size in Bits - i64 64, ;; Align in Bits - i64 0, ;; Offset in Bits - i32 0, ;; Flags - i32 5 ;; Encoding - } - -unsigned long long -^^^^^^^^^^^^^^^^^^ - -.. code-block:: llvm - - !2 = metadata !{ - i32 786468, ;; Tag - null, ;; File - null, ;; Context - metadata !"long long unsigned int", - i32 0, ;; Line number - i64 64, ;; Size in Bits - i64 64, ;; Align in Bits - i64 0, ;; Offset in Bits - i32 0, ;; Flags - i32 7 ;; Encoding - } - -float -^^^^^ - -.. code-block:: llvm - - !2 = metadata !{ - i32 786468, ;; Tag - null, ;; File - null, ;; Context - metadata !"float", - i32 0, ;; Line number - i64 32, ;; Size in Bits - i64 32, ;; Align in Bits - i64 0, ;; Offset in Bits - i32 0, ;; Flags - i32 4 ;; Encoding - } - -double -^^^^^^ - -.. code-block:: llvm - - !2 = metadata !{ - i32 786468, ;; Tag - null, ;; File - null, ;; Context - metadata !"double",;; Name - i32 0, ;; Line number - i64 64, ;; Size in Bits - i64 64, ;; Align in Bits - i64 0, ;; Offset in Bits - i32 0, ;; Flags - i32 4 ;; Encoding - } - -C/C++ derived types -------------------- - -Given the following as an example of C/C++ derived type: - -.. code-block:: c - - typedef const int *IntPtr; - -a C/C++ front-end would generate the following descriptors: - -.. code-block:: llvm - - ;; - ;; Define the typedef "IntPtr". - ;; - !2 = metadata !{ - i32 786454, ;; Tag - metadata !3, ;; File - metadata !1, ;; Context - metadata !"IntPtr", ;; Name - i32 0, ;; Line number - i64 0, ;; Size in bits - i64 0, ;; Align in bits - i64 0, ;; Offset in bits - i32 0, ;; Flags - metadata !4 ;; Derived From type - } - ;; - ;; Define the pointer type. - ;; - !4 = metadata !{ - i32 786447, ;; Tag - null, ;; File - null, ;; Context - metadata !"", ;; Name - i32 0, ;; Line number - i64 64, ;; Size in bits - i64 64, ;; Align in bits - i64 0, ;; Offset in bits - i32 0, ;; Flags - metadata !5 ;; Derived From type - } - ;; - ;; Define the const type. - ;; - !5 = metadata !{ - i32 786470, ;; Tag - null, ;; File - null, ;; Context - metadata !"", ;; Name - i32 0, ;; Line number - i64 0, ;; Size in bits - i64 0, ;; Align in bits - i64 0, ;; Offset in bits - i32 0, ;; Flags - metadata !6 ;; Derived From type - } - ;; - ;; Define the int type. - ;; - !6 = metadata !{ - i32 786468, ;; Tag - null, ;; File - null, ;; Context - metadata !"int", ;; Name - i32 0, ;; Line number - i64 32, ;; Size in bits - i64 32, ;; Align in bits - i64 0, ;; Offset in bits - i32 0, ;; Flags - i32 5 ;; Encoding - } - -C/C++ struct/union types ------------------------- - -Given the following as an example of C/C++ struct type: - -.. code-block:: c - - struct Color { - unsigned Red; - unsigned Green; - unsigned Blue; - }; - -a C/C++ front-end would generate the following descriptors: - -.. code-block:: llvm - - ;; - ;; Define basic type for unsigned int. - ;; - !5 = metadata !{ - i32 786468, ;; Tag - null, ;; File - null, ;; Context - metadata !"unsigned int", - i32 0, ;; Line number - i64 32, ;; Size in Bits - i64 32, ;; Align in Bits - i64 0, ;; Offset in Bits - i32 0, ;; Flags - i32 7 ;; Encoding - } - ;; - ;; Define composite type for struct Color. - ;; - !2 = metadata !{ - i32 786451, ;; Tag - metadata !1, ;; Compile unit - null, ;; Context - metadata !"Color", ;; Name - i32 1, ;; Line number - i64 96, ;; Size in bits - i64 32, ;; Align in bits - i64 0, ;; Offset in bits - i32 0, ;; Flags - null, ;; Derived From - metadata !3, ;; Elements - i32 0, ;; Runtime Language - null, ;; Base type containing the vtable pointer for this type - null ;; Template parameters - } - - ;; - ;; Define the Red field. - ;; - !4 = metadata !{ - i32 786445, ;; Tag - metadata !1, ;; File - metadata !1, ;; Context - metadata !"Red", ;; Name - i32 2, ;; Line number - i64 32, ;; Size in bits - i64 32, ;; Align in bits - i64 0, ;; Offset in bits - i32 0, ;; Flags - metadata !5 ;; Derived From type - } - - ;; - ;; Define the Green field. - ;; - !6 = metadata !{ - i32 786445, ;; Tag - metadata !1, ;; File - metadata !1, ;; Context - metadata !"Green", ;; Name - i32 3, ;; Line number - i64 32, ;; Size in bits - i64 32, ;; Align in bits - i64 32, ;; Offset in bits - i32 0, ;; Flags - metadata !5 ;; Derived From type - } - - ;; - ;; Define the Blue field. - ;; - !7 = metadata !{ - i32 786445, ;; Tag - metadata !1, ;; File - metadata !1, ;; Context - metadata !"Blue", ;; Name - i32 4, ;; Line number - i64 32, ;; Size in bits - i64 32, ;; Align in bits - i64 64, ;; Offset in bits - i32 0, ;; Flags - metadata !5 ;; Derived From type - } - - ;; - ;; Define the array of fields used by the composite type Color. - ;; - !3 = metadata !{metadata !4, metadata !6, metadata !7} - -C/C++ enumeration types ------------------------ - -Given the following as an example of C/C++ enumeration type: - -.. code-block:: c - - enum Trees { - Spruce = 100, - Oak = 200, - Maple = 300 - }; - -a C/C++ front-end would generate the following descriptors: - -.. code-block:: llvm - - ;; - ;; Define composite type for enum Trees - ;; - !2 = metadata !{ - i32 786436, ;; Tag - metadata !1, ;; File - metadata !1, ;; Context - metadata !"Trees", ;; Name - i32 1, ;; Line number - i64 32, ;; Size in bits - i64 32, ;; Align in bits - i64 0, ;; Offset in bits - i32 0, ;; Flags - null, ;; Derived From type - metadata !3, ;; Elements - i32 0 ;; Runtime language - } - - ;; - ;; Define the array of enumerators used by composite type Trees. - ;; - !3 = metadata !{metadata !4, metadata !5, metadata !6} - - ;; - ;; Define Spruce enumerator. - ;; - !4 = metadata !{i32 786472, metadata !"Spruce", i64 100} - - ;; - ;; Define Oak enumerator. - ;; - !5 = metadata !{i32 786472, metadata !"Oak", i64 200} - - ;; - ;; Define Maple enumerator. - ;; - !6 = metadata !{i32 786472, metadata !"Maple", i64 300} - Debugging information format ============================ @@ -1650,21 +1214,33 @@ New DWARF Attributes New DWARF Constants ^^^^^^^^^^^^^^^^^^^ -+--------------------------------+-------+ -| Name | Value | -+================================+=======+ -| DW_AT_APPLE_PROPERTY_readonly | 0x1 | -+--------------------------------+-------+ -| DW_AT_APPLE_PROPERTY_readwrite | 0x2 | -+--------------------------------+-------+ -| DW_AT_APPLE_PROPERTY_assign | 0x4 | -+--------------------------------+-------+ -| DW_AT_APPLE_PROPERTY_retain | 0x8 | -+--------------------------------+-------+ -| DW_AT_APPLE_PROPERTY_copy | 0x10 | -+--------------------------------+-------+ -| DW_AT_APPLE_PROPERTY_nonatomic | 0x20 | -+--------------------------------+-------+ ++--------------------------------------+-------+ +| Name | Value | ++======================================+=======+ +| DW_APPLE_PROPERTY_readonly | 0x01 | ++--------------------------------------+-------+ +| DW_APPLE_PROPERTY_getter | 0x02 | ++--------------------------------------+-------+ +| DW_APPLE_PROPERTY_assign | 0x04 | ++--------------------------------------+-------+ +| DW_APPLE_PROPERTY_readwrite | 0x08 | ++--------------------------------------+-------+ +| DW_APPLE_PROPERTY_retain | 0x10 | ++--------------------------------------+-------+ +| DW_APPLE_PROPERTY_copy | 0x20 | ++--------------------------------------+-------+ +| DW_APPLE_PROPERTY_nonatomic | 0x40 | ++--------------------------------------+-------+ +| DW_APPLE_PROPERTY_setter | 0x80 | ++--------------------------------------+-------+ +| DW_APPLE_PROPERTY_atomic | 0x100 | ++--------------------------------------+-------+ +| DW_APPLE_PROPERTY_weak | 0x200 | ++--------------------------------------+-------+ +| DW_APPLE_PROPERTY_strong | 0x400 | ++--------------------------------------+-------+ +| DW_APPLE_PROPERTY_unsafe_unretained | 0x800 | ++--------------------------------+-----+-------+ Name Accelerator Tables ----------------------- diff --git a/docs/TableGen/BackEnds.rst b/docs/TableGen/BackEnds.rst index 42de41d..e8544b6 100644 --- a/docs/TableGen/BackEnds.rst +++ b/docs/TableGen/BackEnds.rst @@ -78,8 +78,7 @@ returns the (currently, 32-bit unsigned) value of the instruction. **Output**: C++ code, implementing the target's CodeEmitter class by overriding the virtual functions as ``<Target>CodeEmitter::function()``. -**Usage**: Used to include directly at the end of ``<Target>CodeEmitter.cpp``, and -with option `-mc-emitter` to be included in ``<Target>MCCodeEmitter.cpp``. +**Usage**: Used to include directly at the end of ``<Target>MCCodeEmitter.cpp``. RegisterInfo ------------ diff --git a/docs/TableGen/LangIntro.rst b/docs/TableGen/LangIntro.rst index 3e74dff..85c74a5 100644 --- a/docs/TableGen/LangIntro.rst +++ b/docs/TableGen/LangIntro.rst @@ -94,7 +94,9 @@ supported include: uninitialized field ``0b1001011`` - binary integer value + binary integer value. + Note that this is sized by the number of bits given and will not be + silently extended/truncated. ``07654321`` octal integer value (indicated by a leading 0) @@ -116,8 +118,9 @@ supported include: In rare cases, TableGen is unable to deduce the element type in which case the user must specify it explicitly. -``{ a, b, c }`` - initializer for a "bits<3>" value +``{ a, b, 0b10 }`` + initializer for a "bits<4>" value. + 1-bit from "a", 1-bit from "b", 2-bits from 0b10. ``value`` value reference @@ -208,6 +211,9 @@ supported include: on string, int and bit objects. Use !cast<string> to compare other types of objects. +``!shl(a,b)`` ``!srl(a,b)`` ``!sra(a,b)`` ``!add(a,b)`` ``!and(a,b)`` + The usual binary and arithmetic operators. + Note that all of the values have rules specifying how they convert to values for different types. These rules allow you to assign a value like "``7``" to a "``bits<4>``" value, for example. diff --git a/docs/TableGen/LangRef.rst b/docs/TableGen/LangRef.rst index 9b074be..134afed 100644 --- a/docs/TableGen/LangRef.rst +++ b/docs/TableGen/LangRef.rst @@ -55,6 +55,10 @@ One aspect to note is that the :token:`DecimalInteger` token *includes* the ``+`` or ``-``, as opposed to having ``+`` and ``-`` be unary operators as most languages do. +Also note that :token:`BinInteger` creates a value of type ``bits<n>`` +(where ``n`` is the number of bits). This will implicitly convert to +integers when needed. + TableGen has identifier-like tokens: .. productionlist:: @@ -92,7 +96,7 @@ wide variety of meanings: .. productionlist:: BangOperator: one of :!eq !if !head !tail !con - :!add !shl !sra !srl + :!add !shl !sra !srl !and :!cast !empty !subst !foreach !listconcat !strconcat Syntax diff --git a/docs/TableGen/index.rst b/docs/TableGen/index.rst index 0860afa..cda41b5 100644 --- a/docs/TableGen/index.rst +++ b/docs/TableGen/index.rst @@ -273,7 +273,7 @@ that's only useful for debugging of the TableGen files themselves. The power in TableGen is, however, to interpret the source files into an internal representation that can be generated into anything you want. -Current usage of TableGen is to create include huge files with tables that you +Current usage of TableGen is to create huge include files with tables that you can either include directly (if the output is in the language you're coding), or be used in pre-processing via macros surrounding the include of the file. @@ -292,7 +292,7 @@ Despite being very generic, TableGen has some deficiencies that have been pointed out numerous times. The common theme is that, while TableGen allows you to build Domain-Specific-Languages, the final languages that you create lack the power of other DSLs, which in turn increase considerably the size -and complecity of TableGen files. +and complexity of TableGen files. At the same time, TableGen allows you to create virtually any meaning of the basic concepts via custom-made back-ends, which can pervert the original diff --git a/docs/TestingGuide.rst b/docs/TestingGuide.rst index 481be55..fa0b5dd 100644 --- a/docs/TestingGuide.rst +++ b/docs/TestingGuide.rst @@ -240,6 +240,58 @@ The recommended way to examine output to figure out if the test passes is using the :doc:`FileCheck tool <CommandGuide/FileCheck>`. *[The usage of grep in RUN lines is deprecated - please do not send or commit patches that use it.]* +Extra files +----------- + +If your test requires extra files besides the file containing the ``RUN:`` +lines, the idiomatic place to put them is in a subdirectory ``Inputs``. +You can then refer to the extra files as ``%S/Inputs/foo.bar``. + +For example, consider ``test/Linker/ident.ll``. The directory structure is +as follows:: + + test/ + Linker/ + ident.ll + Inputs/ + ident.a.ll + ident.b.ll + +For convenience, these are the contents: + +.. code-block:: llvm + + ;;;;; ident.ll: + + ; RUN: llvm-link %S/Inputs/ident.a.ll %S/Inputs/ident.b.ll -S | FileCheck %s + + ; Verify that multiple input llvm.ident metadata are linked together. + + ; CHECK-DAG: !llvm.ident = !{!0, !1, !2} + ; CHECK-DAG: "Compiler V1" + ; CHECK-DAG: "Compiler V2" + ; CHECK-DAG: "Compiler V3" + + ;;;;; Inputs/ident.a.ll: + + !llvm.ident = !{!0, !1} + !0 = metadata !{metadata !"Compiler V1"} + !1 = metadata !{metadata !"Compiler V2"} + + ;;;;; Inputs/ident.b.ll: + + !llvm.ident = !{!0} + !0 = metadata !{metadata !"Compiler V3"} + +For symmetry reasons, ``ident.ll`` is just a dummy file that doesn't +actually participate in the test besides holding the ``RUN:`` lines. + +.. note:: + + Some existing tests use ``RUN: true`` in extra files instead of just + putting the extra files in an ``Inputs/`` directory. This pattern is + deprecated. + Fragile tests ------------- diff --git a/docs/WritingAnLLVMBackend.rst b/docs/WritingAnLLVMBackend.rst index fb7c16f..fdadbb0 100644 --- a/docs/WritingAnLLVMBackend.rst +++ b/docs/WritingAnLLVMBackend.rst @@ -161,7 +161,7 @@ To get LLVM to actually build and link your target, you need to add it to the know about your target when parsing the ``--enable-targets`` option. Search the configure script for ``TARGETS_TO_BUILD``, add your target to the lists there (some creativity required), and then reconfigure. Alternatively, you can -change ``autotools/configure.ac`` and regenerate configure by running +change ``autoconf/configure.ac`` and regenerate configure by running ``./autoconf/AutoRegen.sh``. Target Machine diff --git a/docs/WritingAnLLVMPass.rst b/docs/WritingAnLLVMPass.rst index cfbda04..ef2b953 100644 --- a/docs/WritingAnLLVMPass.rst +++ b/docs/WritingAnLLVMPass.rst @@ -146,7 +146,7 @@ to avoid using expensive C++ runtime information. .. code-block:: c++ - virtual bool runOnFunction(Function &F) { + bool runOnFunction(Function &F) override { errs() << "Hello: "; errs().write_escaped(F.getName()) << "\n"; return false; @@ -194,7 +194,7 @@ As a whole, the ``.cpp`` file looks like: static char ID; Hello() : FunctionPass(ID) {} - virtual bool runOnFunction(Function &F) { + bool runOnFunction(Function &F) override { errs() << "Hello: "; errs().write_escaped(F.getName()) << '\n'; return false; @@ -434,9 +434,8 @@ The ``doFinalization(CallGraph &)`` method virtual bool doFinalization(CallGraph &CG); The ``doFinalization`` method is an infrequently used method that is called -when the pass framework has finished calling :ref:`runOnFunction -<writing-an-llvm-pass-runOnFunction>` for every function in the program being -compiled. +when the pass framework has finished calling :ref:`runOnSCC +<writing-an-llvm-pass-runOnSCC>` for every SCC in the program being compiled. .. _writing-an-llvm-pass-FunctionPass: @@ -456,7 +455,7 @@ To be explicit, ``FunctionPass`` subclasses are not allowed to: #. Inspect or modify a ``Function`` other than the one currently being processed. #. Add or remove ``Function``\ s from the current ``Module``. #. Add or remove global variables from the current ``Module``. -#. Maintain state across invocations of:ref:`runOnFunction +#. Maintain state across invocations of :ref:`runOnFunction <writing-an-llvm-pass-runOnFunction>` (including global data). Implementing a ``FunctionPass`` is usually straightforward (See the :ref:`Hello @@ -1163,7 +1162,7 @@ all! To fix this, we need to add the following :ref:`getAnalysisUsage .. code-block:: c++ // We don't modify the program, so we preserve all analyses - virtual void getAnalysisUsage(AnalysisUsage &AU) const { + void getAnalysisUsage(AnalysisUsage &AU) const override { AU.setPreservesAll(); } diff --git a/docs/conf.py b/docs/conf.py index 17d21f3..659c3e0 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -47,9 +47,9 @@ copyright = u'2003-2014, LLVM Project' # built documents. # # The short X.Y version. -version = '3.4' +version = '3.6' # The full version, including alpha/beta/rc tags. -release = '3.4' +release = '3.6' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/docs/index.rst b/docs/index.rst index 1d4fbd9..5ac5443 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -235,9 +235,11 @@ For API clients and LLVM developers. WritingAnLLVMPass HowToUseAttributes NVPTXUsage + R600Usage StackMaps InAlloca BigEndianNEON + CoverageMappingFormat :doc:`WritingAnLLVMPass` Information on how to write LLVM transformations and analyses. @@ -316,6 +318,9 @@ For API clients and LLVM developers. :doc:`NVPTXUsage` This document describes using the NVPTX back-end to compile GPU kernels. +:doc:`R600Usage` + This document describes how to use the R600 back-end. + :doc:`StackMaps` LLVM support for mapping instruction addresses to the location of values and allowing code to be patched. @@ -324,6 +329,8 @@ For API clients and LLVM developers. LLVM's support for generating NEON instructions on big endian ARM targets is somewhat nonintuitive. This document explains the implementation and rationale. +:doc:`CoverageMappingFormat` + This describes the format and encoding used for LLVM’s code coverage mapping. Development Process Documentation ================================= @@ -340,6 +347,7 @@ Information about LLVM's development process. HowToReleaseLLVM Packaging ReleaseProcess + Phabricator :doc:`DeveloperPolicy` The LLVM project's policy towards developers and their contributions. @@ -361,11 +369,15 @@ Information about LLVM's development process. This is a guide to preparing LLVM releases. Most developers can ignore it. :doc:`ReleaseProcess` - This is a validate a new release, during the release process. Most developers can ignore it. + This is a guide to validate a new release, during the release process. Most developers can ignore it. :doc:`Packaging` Advice on packaging LLVM into a distribution. +:doc:`Phabricator` + Describes how to use the Phabricator code review tool hosted on + http://reviews.llvm.org/ and its command line interface, Arcanist. + Community ========= diff --git a/docs/tutorial/LangImpl3.rst b/docs/tutorial/LangImpl3.rst index 7174c09..b7418cc 100644 --- a/docs/tutorial/LangImpl3.rst +++ b/docs/tutorial/LangImpl3.rst @@ -581,7 +581,7 @@ our makefile/command line about which options to use: .. code-block:: bash # Compile - clang++ -g -O3 toy.cpp `llvm-config --cppflags --ldflags --libs core` -o toy + clang++ -g -O3 toy.cpp `llvm-config --cxxflags --ldflags --system-libs --libs core` -o toy # Run ./toy diff --git a/docs/tutorial/LangImpl4.rst b/docs/tutorial/LangImpl4.rst index 44e0cc1..aa469ca 100644 --- a/docs/tutorial/LangImpl4.rst +++ b/docs/tutorial/LangImpl4.rst @@ -428,7 +428,7 @@ the LLVM JIT and optimizer. To build this example, use: .. code-block:: bash # Compile - clang++ -g toy.cpp `llvm-config --cppflags --ldflags --libs core jit native` -O3 -o toy + clang++ -g toy.cpp `llvm-config --cxxflags --ldflags --system-libs --libs core jit native` -O3 -o toy # Run ./toy diff --git a/docs/tutorial/LangImpl5.rst b/docs/tutorial/LangImpl5.rst index ed5b652..2a3a4ce 100644 --- a/docs/tutorial/LangImpl5.rst +++ b/docs/tutorial/LangImpl5.rst @@ -736,7 +736,7 @@ the if/then/else and for expressions.. To build this example, use: .. code-block:: bash # Compile - clang++ -g toy.cpp `llvm-config --cppflags --ldflags --libs core jit native` -O3 -o toy + clang++ -g toy.cpp `llvm-config --cxxflags --ldflags --system-libs --libs core jit native` -O3 -o toy # Run ./toy diff --git a/docs/tutorial/LangImpl6.rst b/docs/tutorial/LangImpl6.rst index 42839fb..cdceb03 100644 --- a/docs/tutorial/LangImpl6.rst +++ b/docs/tutorial/LangImpl6.rst @@ -729,7 +729,7 @@ the if/then/else and for expressions.. To build this example, use: .. code-block:: bash # Compile - clang++ -g toy.cpp `llvm-config --cppflags --ldflags --libs core jit native` -O3 -o toy + clang++ -g toy.cpp `llvm-config --cxxflags --ldflags --system-libs --libs core jit native` -O3 -o toy # Run ./toy diff --git a/docs/tutorial/LangImpl7.rst b/docs/tutorial/LangImpl7.rst index 849ce50..c4c7233 100644 --- a/docs/tutorial/LangImpl7.rst +++ b/docs/tutorial/LangImpl7.rst @@ -847,7 +847,7 @@ mutable variables and var/in support. To build this example, use: .. code-block:: bash # Compile - clang++ -g toy.cpp `llvm-config --cppflags --ldflags --libs core jit native` -O3 -o toy + clang++ -g toy.cpp `llvm-config --cxxflags --ldflags --system-libs --libs core jit native` -O3 -o toy # Run ./toy |