Ninja versions prior to 1.10 cannot handle depfile mode when CMake
generates build rules with implicit outputs (the `| ${cmake_ninja_workdir}`
syntax used for IDE support). Ninja's depslog interprets these as
multiple outputs and rejects them with the error:
ninja: error: build.ninja:XXXX: multiple outputs aren't (yet?) supported
by depslog; bring this up on the mailing list if it affects you
This primarily affected builds where CMake generates NATIVE subdirectory
builds for host tools.
This patch modifies TableGen.cmake to:
1. Detect the Ninja version at configure time
2. Disable depfile mode (fall back to globbing .td files) when:
- Ninja version is < 1.10, OR
- The tablegen invocation produces multiple outputs (e.g. -gen-register-info)
The fallback mode maintains correct dependency tracking by explicitly
globbing all .td files in include directories, ensuring tablegen reruns
when dependencies change.
Tested with:
- Ninja 1.8.2 (now works - previously failed with depslog error)
- Ninja 1.13.2
- CMake 4.2.3
- build scenarios with NATIVE tool builds
This commit used a significant amount of tooling to construct.
In the dependency tracking for TableGen-generated files, globbing was
previously limited to the root of include directories. This missed
transitive dependencies in subdirectories, such as the target-specific
intrinsic definitions located in llvm/IR/.
Modifying these untracked files could cause global state (like the
intrinsic enum) to shift without triggering a rebuild of downstream
instruction selectors. This resulted in "Cannot select: intrinsic"
errors during incremental builds. Using a recursive glob ensures all
relevant TableGen files are correctly tracked regardless of their
directory depth.
Fixes#156744
Hoist handling of Doxygen into the top-level cmake/ directory so it can
be shared between LLVM and RUNTIMES and a default/standalone runtimes
build can support building Doxygen documentation as well.
The openmp subproject currently supports doxygen documentation using an
`LLVM_ENABLE_PROJECTS=openmp` build, but not with
`LLVM_ENABLE_RUNTIMES=openmp` because of this missing boilerplate code
in the runtimes build. This is a step towards removing the
`LLVM_ENABLE_PROJECTS=openmp` build mode which was deprecated (#124014)
and already scheduled to be removed in LLVM 21 (#136314). Eventual
removal is planned with #176950.
Hoisting CMake code for shared use with runtimes has been done before in
e.g. #84641, 7017e6c9cfd2de3122ce9528f338a97d61e96373,
44e3365775101fec3fd355eda339282258d74415,
7017e6c9cfd2de3122ce9528f338a97d61e96373
---------
Co-authored-by: Petr Hosek <phosek@google.com>
https://github.com/llvm/llvm-project/pull/173869 accidentally dropped
rtti and eh flags from `llvm-config --cxxflags`. Then
https://github.com/llvm/llvm-project/pull/174084 restored the rtti
flags. The eh flags were not included with the rationale that they are
not ABI relevant.
This PR restores the eh flags as well. While they are not strictly
necessary, I believe that code that directly interfaces with LLVM almost
certainly does not want to build with exceptions if LLVM is not built
with exceptions. Building in the peculiar `-fexceptions -fno-rtti`
configuration is rarely useful and likely not intended.
On MacOS, this is also relevant because it's not possible to use C++17
headers without `-fno-exceptions` when using older deployment targets.
In that configuration, `-fno-exceptions` is required to interact with
LLVM.
gtest automatically determines GTEST_HAS_RTTI from pre-defined compiler
macros, there is no need to explicitly define this and especially no
need to define this for every single source file.
This avoids looking at the individual sources for mixed C/C++ libraries.
The previous code was written ~2014. Generator expressions were added in
CMake 3.3 (2015). We currently require CMake 3.20 and therefore can rely
on more modern features.
Apart from simplifying the code, this is preliminary work to make more
use of pre-compiled headers (#173868).
This is just a vestige of an old llvm-config.h configuration macro that
was removed long ago. LLVM_ON_UNIX remains, but its main purpose is to
enable targetting bare metal through -DCMAKE_SYSTEM_NAME=Generic (see
1422f1bf2b1).
Whenever I try to change anything in the OCaml bindings, I run into
errors like this when running tests:
```
File
"/home/npopov/repos/llvm-project/build/test/Bindings/OCaml/Output/debuginfo.ml.tmp/Testsuite.ml",
line 1:
Warning 70 [missing-mli]: Cannot find interface file.
File
"/home/npopov/repos/llvm-project/build/test/Bindings/OCaml/Output/debuginfo.ml.tmp/debuginfo.ml",
line 1:
Error: The files
"/home/npopov/repos/llvm-project/build/lib/ocaml/llvm/llvm.cmi"
and
"/home/npopov/repos/llvm-project/build/lib/ocaml/llvm/llvm_debuginfo.cmi"
make inconsistent assumptions over interface "Llvm"
```
The only reliable way of getting rid of these I have found is to do an
`rm -rf build` and just rebuild everything.
The root cause of this issue is that we currently add
target-dependencies between ocaml modules, but we don't have file-level
dependencies. This means that everything gets built in the correct
order, but targets don't get rebuilt if a dependency is changed.
To fix this, add file-level dependencies to the custom command. These
are generated via a target property that stores the ocaml outputs of the
target.
This tells the build system to check and regenerate the
*GenRegisterInfo*.inc files, should any of them be missing for
whatever reason.
A follow-up from
<https://github.com/llvm/llvm-project/pull/167700>.
DynamicLibraryTests has a workaround for AIX that calls
export_executable_symbols after add_llvm_unittest, instead of just
passing the `EXPORT_SYMBOLS` switch. At this point, the
default_gtest(_main) libraries is added to the linked library set.
However, default_gtest(_main) are ALIAS libraries. This PR replaces the
ALIAS libraries with the ALIASED_TARGET before passing it to
extract_symbols.py.
Fixes failure of the clang-ppc64-aix buildbot after #164794.
The LLVM-customized GTest has a dependency on LLVM to support
`llvm::raw_ostream` and hence has to link to LLVMSupport. The runtimes
use the LLVMSupport from the bootstrapping LLVM build. The problem is
that the boostrapping compiler and the runtimes target can diverge in
their ABI, even in the runtimes default build. For instance, Clang is
built using gcc which uses libstdc++, but the runtimes is built by Clang
which can be configured to use libcxx by default. Altough it does not
use gcc, this issue has caused
[flang-aarch64-libcxx](https://lab.llvm.org/buildbot/#/builders/89)) to
break, and is still (again?) broken.
This patch makes the runtimes' GTest independent from LLVMSupport so we
do not link any runtimes component with LLVM components.
Runtime projects that use GTest unittests:
* flang-rt
* libc
* compiler-rt: Adds `gtest-all.cpp` with
[GTEST_NO_LLVM_SUPPORT=1](f801b6f67e/compiler-rt/CMakeLists.txt (L723))
to each unittest without using `llvm_gtest`. Not touched by this PR.
* openmp: Handled by #159416. Not touched for now by this PR to avoid
conflict.
The current state of this PR tries to reuse
https://github.com/llvm/llvm-project/blob/main/third-party/unittest/CMakeLists.txt
as much as possible, altough personally I would prefer to make it use
"modern CMake" style. third-party/unittest/CMakeLists.txt will detect
whether it is used in runtimes build and adjaust accordingly. It creates
a different target for LLVM (`llvm_gtest`, NFCI) and another one for the
runtimes (`runtimes_gtest`). It is not possible to reuse `llvm_gtest`
for both since `llvm_gtest` is imported using `find_package(LLVM)` if
configured using LLVM_INSTALL_GTEST. An alias `default_gtest` is used to
select between the two. `default_gtest` could also be used for openmp
which also supports standalone and
[LLVM_ENABLE_PROJECTS](https://github.com/llvm/llvm-project/pull/152189)
build mode.
Ensure that the nested native build uses the same python interpreter as
the main build, in case the python that CMake detects first is not the
python that the user has specified explicitly.
For example, if the person building LLVM wants to use a different python
interpreter to build (eg, testing the build with `python3.14` when
`python3` is a link to `python3.8`, or the default python doesn't have
development headers available) then they could add
`-DPYTHON_EXECUTABLE=python3.14` when invoking CMake. This should be
forwarded to the native CMake build to ensure that the same python is
used.
Original fix by Anuj Mittal <anuj.mittal@intel.com>.
Flang also uses non-gtest based unittests, which don't go through the
usual add_unittest() helper. These currently do not use the usual linker
flags for unit tests. This means that in LTO builds, they do not disable
LTO when building unit tests, which increases the build time.
Since 4feae05c6abda364a9295aecfa600d7d4e7dfeb6, most of the handling of
warning options was rewritten to add such options based on hardcoded
knowledge about what compilers support which options, and since which
versions. This avoids a number of configure time checks, speeding up the
cmake configuration.
This avoids erroneously adding this option with GCC, which doesn't
really support it.
If testing for a warning option like -Wno-<foo> with GCC, GCC won't
print any diagnostic at all, leading to the options being accepted
incorrectly. However later, if compiling a file that actually prints
another warning, GCC will also print warnings about these -Wno-<foo>
options being unrecognized.
This avoids extra warning spam like this, for every source file that
does produce warnings with GCC:
At global scope:
cc1plus: note: unrecognized command-line option ‘-Wno-pass-failed’ may have been intended to silence earlier diagnostics
libstdc++15 makes use of an unroll pragma inside std::find_if(). This
produces a warning if clang fails to unroll the loop. As this pragma is
outside of our control, suppress the warning. Missed transforms are not
something we care about in this context.
Related to https://github.com/llvm/llvm-project/issues/157666.
Build on Clang-BOLT infrastructure to collect sample profile for CSSPGO.
Add CSSPGO.cmake and BOLT-CSSPGO.cmake to automate CSSPGO/+BOLT
Clang builds.
Note that `CLANG_PGO_TRAINING_DATA_SOURCE_DIR` is required as built-in
training set is inadequate for collecting sampled profile.
Hardware compatibility: CSSPGO requires synchronized (0-skid) call
and branch stacks, which is only available with Intel PEBS (Sandy
Bridge+),
AMD Zen3 with BRS, Zen4 with LBRv2+LBR_PMC_FREEZE, and Zen5 with LBRv2.
This patch adds support for Intel `br_inst_retired.near_taken:uppp`
event.
Test Plan:
Added BOLT-CSSPGO.cmake with same use as BOLT-PGO.cmake,
e.g. for bootstrapped ThinLTO+CSSPGO+BOLT, with CSSPGO profile collected
from LLVM build, and BOLT profile collected from Hello World
(instrumentation):
```
cmake -B clang-csspgo-bolt -S /path/to/llvm-project/llvm \
-DLLVM_ENABLE_LLD=ON -DBOOTSTRAP_LLVM_ENABLE_LLD=ON \
-DBOOTSTRAP_BOOTSTRAP_LLVM_ENABLE_LLD=ON \
-DPGO_INSTRUMENT_LTO=Thin \
-DBOOTSTRAP_CLANG_PGO_TRAINING_DATA_SOURCE_DIR=/path/to/llvm-project/llvm \
-GNinja -C /path/to/llvm-project/clang/cmake/caches/BOLT-CSSPGO.cmake
ninja stage2-clang-bolt
...
warning: Sample PGO is estimated to optimize better with 19.5x more samples. Please consider increasing sampling rate or profiling for longer duration to get more samples.
...
[2800/2801] Optimizing Clang with BOLT
BOLT-INFO: 8189 out of 106942 functions in the binary (7.7%) have non-empty execution profile
13776393 : taken branches (-42.1%)
```
Performance testing with Clang:
- Setup: Clang-BOLT testing harness
9f2b46f67a
- CSSPGO training: building LLVM,
- InstrPGO training: building Hello World,
- BOLT training: building Hello World, instrumentation,
- benchmark: building small LLVM tool (not),
- 2S Intel SKX Xeon 6138 with 40C/80T and 256GB RAM, using 20C/40T for
build,
- Results, wall time, lower is better
- Baseline (bootstrapped build): 10.36s,
- InstrPGO + ThinLTO: 9.34s,
- CSSPGO + ThinLTO: 8.85s.
- BOLT results, for reference:
- Baseline: 9.09s,
- InstrPGO + ThinLTO: 9.09s,
- CSSPGO + ThinLTO: 8.58s.
---------
Co-authored-by: Matthias Braun <matze@braunis.de>
Summary:
Ugly hacks abound, we can't actually test linker flags correctly
generically because not everyone has `nvlink` as a binary on their
machine which would then result in every single flag being unsupported.
This is the only 'linker flag' check we have, so just hard code it off.
Summary:
The AMDGPU hack can be removed, and we no longer need to skip 90% of the
`HandleLLVMOptions` if we work around NVPTX earlier. Simplifies the
interface by removing duplicated logic and keeps the GPU targets from
being weirdly divergent on some flags.
As a follow up to #159122, after figure out reason why CAS unit tests
are failing on Solaris, update the CMake configuration to build ondisk
CAS implementation. We now check the existance of `flock` before
enabling the configuration.
In the future, we can find ways to support OnDiskCAS on other platforms
that do not have `flock`. This can techinically be done with a POSIX
compilant file lock but that will put a restriction on the usage of CAS.
This disables the following very noisy warning:
In file included from /usr/include/c++/13/string:51,
from /usr/include/c++/13/bits/locale_classes.h:40,
from /usr/include/c++/13/bits/ios_base.h:41,
from /usr/include/c++/13/streambuf:43,
from /usr/include/c++/13/bits/streambuf_iterator.h:35,
from /usr/include/c++/13/iterator:66,
from ../include/llvm/ADT/ADL.h:13,
from ../include/llvm/ADT/DenseMap.h:17,
from ../lib/Transforms/Vectorize/VPlanAnalysis.h:12,
from ../lib/Transforms/Vectorize/VPlan.h:27,
from ../lib/Transforms/Vectorize/LoopVectorizationPlanner.h:27, from ../lib/Transforms/Vectorize/VPlanConstruction.cpp:14:
In static member function ‘static _Up* std::__copy_move<_IsMove, true, std::random_access_iterator_tag>::__copy_m(_Tp*, _Tp*, _Up*) [with _Tp = llvm::VPBlockBase*; _Up = llvm::VPBlockBase*; bool _IsMove = true]’,
inlined from ‘_OI std::__copy_move_a2(_II, _II, _OI) [with bool _IsMove = true; _II = llvm::VPBlockBase**; _OI = llvm::VPBlockBase**]’ at /usr/include/c++/13/bits/stl_algobase.h:506:30,
inlined from ‘_OI std::__copy_move_a1(_II, _II, _OI) [with bool _IsMove = true; _II = llvm::VPBlockBase**; _OI = llvm::VPBlockBase**]’ at /usr/include/c++/13/bits/stl_algobase.h:533:42,
inlined from ‘_OI std::__copy_move_a(_II, _II, _OI) [with bool _IsMove = true; _II = llvm::VPBlockBase**; _OI = llvm::VPBlockBase**]’ at /usr/include/c++/13/bits/stl_algobase.h:540:31,
inlined from ‘_OI std::move(_II, _II, _OI) [with _II = llvm::VPBlockBase**; _OI = llvm::VPBlockBase**]’ at /usr/include/c++/13/bits/stl_algobase.h:665:38,
inlined from ‘llvm::SmallVectorImpl<T>& llvm::SmallVectorImpl<T>::operator=(llvm::SmallVectorImpl<T>&&) [with T = llvm::VPBlockBase*]’ at ../include/llvm/ADT/SmallVector.h:1071:25,
inlined from ‘llvm::SmallVector<T, N>& llvm::SmallVector<T, N>::operator=(llvm::SmallVector<T, N>&&) [with T = llvm::VPBlockBase*; unsigned int N = 1]’ at ../include/llvm/ADT/SmallVector.h:1259:36,
inlined from ‘static void llvm::DomTreeBuilder::SemiNCAInfo<DomTreeT>::CalculateFromScratch(DomTreeT&, BatchUpdatePtr) [with DomTreeT = llvm::DominatorTreeBase<llvm::VPBlockBase, false>]’ at ../include/llvm/Support/GenericDomTreeConstruction.h:578:14:
/usr/include/c++/13/bits/stl_algobase.h:437:30: warning: ‘void* __builtin_memmove(void*, const void*, long unsigned int)’ forming offset 24 is out of the bounds [0, 24] of object ‘<anonymous>’ with type ‘llvm::DomTreeBuilder::SemiNCAInfo<llvm::DominatorTreeBase<llvm::VPBlockBase, false> >::RootsT’ {aka ‘llvm::SmallVector<llvm::VPBlockBase*, 1>’} [-Warray-bounds=]
437 | __builtin_memmove(__result, __first, sizeof(_Tp) * _Num);
| ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../lib/Transforms/Vectorize/VPlanDominatorTree.h:23,
from ../lib/Transforms/Vectorize/VPlanConstruction.cpp:17:
../include/llvm/Support/GenericDomTreeConstruction.h: In static member function ‘static void llvm::DomTreeBuilder::SemiNCAInfo<DomTreeT>::CalculateFromScratch(DomTreeT&, BatchUpdatePtr) [with DomTreeT = llvm::DominatorTreeBase<llvm::VPBlockBase, false>]’:
../include/llvm/Support/GenericDomTreeConstruction.h:578:25: note: ‘<anonymous>’ declared here
578 | DT.Roots = FindRoots(DT, PostViewBUI);
| ~~~~~~~~~^~~~~~~~~~~~~~~~~
In static member function ‘static _Up* std::__copy_move<_IsMove, true, std::random_access_iterator_tag>::__copy_m(_Tp*, _Tp*, _Up*) [with _Tp = llvm::VPBlockBase*; _Up = llvm::VPBlockBase*; bool _IsMove = true]’,
inlined from ‘_OI std::__copy_move_a2(_II, _II, _OI) [with bool _IsMove = true; _II = llvm::VPBlockBase**; _OI = llvm::VPBlockBase**]’ at /usr/include/c++/13/bits/stl_algobase.h:506:30,
inlined from ‘_OI std::__copy_move_a1(_II, _II, _OI) [with bool _IsMove = true; _II = llvm::VPBlockBase**; _OI = llvm::VPBlockBase**]’ at /usr/include/c++/13/bits/stl_algobase.h:533:42,
inlined from ‘_OI std::__copy_move_a(_II, _II, _OI) [with bool _IsMove = true; _II = llvm::VPBlockBase**; _OI = llvm::VPBlockBase**]’ at /usr/include/c++/13/bits/stl_algobase.h:540:31,
inlined from ‘_OI std::move(_II, _II, _OI) [with _II = llvm::VPBlockBase**; _OI = llvm::VPBlockBase**]’ at /usr/include/c++/13/bits/stl_algobase.h:665:38,
inlined from ‘llvm::SmallVectorImpl<T>& llvm::SmallVectorImpl<T>::operator=(llvm::SmallVectorImpl<T>&&) [with T = llvm::VPBlockBase*]’ at ../include/llvm/ADT/SmallVector.h:1094:14,
inlined from ‘llvm::SmallVector<T, N>& llvm::SmallVector<T, N>::operator=(llvm::SmallVector<T, N>&&) [with T = llvm::VPBlockBase*; unsigned int N = 1]’ at ../include/llvm/ADT/SmallVector.h:1259:36,
inlined from ‘static void llvm::DomTreeBuilder::SemiNCAInfo<DomTreeT>::CalculateFromScratch(DomTreeT&, BatchUpdatePtr) [with DomTreeT = llvm::DominatorTreeBase<llvm::VPBlockBase, false>]’ at ../include/llvm/Support/GenericDomTreeConstruction.h:578:14:
/usr/include/c++/13/bits/stl_algobase.h:437:30: warning: ‘void* __builtin_memmove(void*, const void*, long unsigned int)’ forming offset 24 is out of the bounds [0, 24] of object ‘<anonymous>’ with type ‘llvm::DomTreeBuilder::SemiNCAInfo<llvm::DominatorTreeBase<llvm::VPBlockBase, false> >::RootsT’ {aka ‘llvm::SmallVector<llvm::VPBlockBase*, 1>’} [-Warray-bounds=]
437 | __builtin_memmove(__result, __first, sizeof(_Tp) * _Num);
| ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../include/llvm/Support/GenericDomTreeConstruction.h: In static member function ‘static void llvm::DomTreeBuilder::SemiNCAInfo<DomTreeT>::CalculateFromScratch(DomTreeT&, BatchUpdatePtr) [with DomTreeT = llvm::DominatorTreeBase<llvm::VPBlockBase, false>]’:
../include/llvm/Support/GenericDomTreeConstruction.h:578:25: note: ‘<anonymous>’ declared here
578 | DT.Roots = FindRoots(DT, PostViewBUI);
| ~~~~~~~~~^~~~~~~~~~~~~~~~~
In a regular build, there's currently 14 such warning instances,
but since they are so large and noisy, they are very disruptive,
and they don't seem to be an actual issue in the LLVM code base.
With the -Warray-bounds warning disabled, the build instead ends
up with 9 similar warnings of the kind -Wstringop-overread:
In file included from /usr/include/c++/13/string:51,
from /usr/include/c++/13/bits/locale_classes.h:40,
from /usr/include/c++/13/bits/ios_base.h:41,
from /usr/include/c++/13/streambuf:43,
from /usr/include/c++/13/bits/streambuf_iterator.h:35,
from /usr/include/c++/13/iterator:66,
from ../include/llvm/ADT/ADL.h:13,
from ../include/llvm/ADT/DenseMap.h:17,
from ../lib/Transforms/Vectorize/VPlanAnalysis.h:12,
from ../lib/Transforms/Vectorize/VPlan.h:27,
from ../lib/Transforms/Vectorize/LoopVectorizationPlanner.h:27, from ../lib/Transforms/Vectorize/VPlanConstruction.cpp:14:
In static member function ‘static _Up* std::__copy_move<_IsMove, true, std::random_access_iterator_tag>::__copy_m(_Tp*, _Tp*, _Up*) [with _Tp = llvm::VPBlockBase*; _Up = llvm::VPBlockBase*; bool _IsMove = true]’,
inlined from ‘_OI std::__copy_move_a2(_II, _II, _OI) [with bool _IsMove = true; _II = llvm::VPBlockBase**; _OI = llvm::VPBlockBase**]’ at /usr/include/c++/13/bits/stl_algobase.h:506:30,
inlined from ‘_OI std::__copy_move_a1(_II, _II, _OI) [with bool _IsMove = true; _II = llvm::VPBlockBase**; _OI = llvm::VPBlockBase**]’ at /usr/include/c++/13/bits/stl_algobase.h:533:42,
inlined from ‘_OI std::__copy_move_a(_II, _II, _OI) [with bool _IsMove = true; _II = llvm::VPBlockBase**; _OI = llvm::VPBlockBase**]’ at /usr/include/c++/13/bits/stl_algobase.h:540:31,
inlined from ‘_OI std::move(_II, _II, _OI) [with _II = llvm::VPBlockBase**; _OI = llvm::VPBlockBase**]’ at /usr/include/c++/13/bits/stl_algobase.h:665:38,
inlined from ‘llvm::SmallVectorImpl<T>& llvm::SmallVectorImpl<T>::operator=(llvm::SmallVectorImpl<T>&&) [with T = llvm::VPBlockBase*]’ at ../include/llvm/ADT/SmallVector.h:1071:25,
inlined from ‘llvm::SmallVector<T, N>& llvm::SmallVector<T, N>::operator=(llvm::SmallVector<T, N>&&) [with T = llvm::VPBlockBase*; unsigned int N = 1]’ at ../include/llvm/ADT/SmallVector.h:1259:36,
inlined from ‘static void llvm::DomTreeBuilder::SemiNCAInfo<DomTreeT>::CalculateFromScratch(DomTreeT&, BatchUpdatePtr) [with DomTreeT = llvm::DominatorTreeBase<llvm::VPBlockBase, false>]’ at ../include/llvm/Support/GenericDomTreeConstruction.h:578:14:
/usr/include/c++/13/bits/stl_algobase.h:437:30: warning: ‘void* __builtin_memmove(void*, const void*, long unsigned int)’ reading between 9 and 34359738360 bytes from a region of size 8 [-Wstringop-overread]
437 | __builtin_memmove(__result, __first, sizeof(_Tp) * _Num);
| ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../lib/Transforms/Vectorize/VPlanDominatorTree.h:23,
from ../lib/Transforms/Vectorize/VPlanConstruction.cpp:17:
../include/llvm/Support/GenericDomTreeConstruction.h: In static member function ‘static void llvm::DomTreeBuilder::SemiNCAInfo<DomTreeT>::CalculateFromScratch(DomTreeT&, BatchUpdatePtr) [with DomTreeT = llvm::DominatorTreeBase<llvm::VPBlockBase, false>]’:
../include/llvm/Support/GenericDomTreeConstruction.h:578:25: note: at offset 16 into source object ‘<anonymous>’ of size 24
578 | DT.Roots = FindRoots(DT, PostViewBUI);
| ~~~~~~~~~^~~~~~~~~~~~~~~~~
In static member function ‘static _Up* std::__copy_move<_IsMove, true, std::random_access_iterator_tag>::__copy_m(_Tp*, _Tp*, _Up*) [with _Tp = llvm::VPBlockBase*; _Up = llvm::VPBlockBase*; bool _IsMove = true]’,
inlined from ‘_OI std::__copy_move_a2(_II, _II, _OI) [with bool _IsMove = true; _II = llvm::VPBlockBase**; _OI = llvm::VPBlockBase**]’ at /usr/include/c++/13/bits/stl_algobase.h:506:30,
inlined from ‘_OI std::__copy_move_a1(_II, _II, _OI) [with bool _IsMove = true; _II = llvm::VPBlockBase**; _OI = llvm::VPBlockBase**]’ at /usr/include/c++/13/bits/stl_algobase.h:533:42,
inlined from ‘_OI std::__copy_move_a(_II, _II, _OI) [with bool _IsMove = true; _II = llvm::VPBlockBase**; _OI = llvm::VPBlockBase**]’ at /usr/include/c++/13/bits/stl_algobase.h:540:31,
inlined from ‘_OI std::move(_II, _II, _OI) [with _II = llvm::VPBlockBase**; _OI = llvm::VPBlockBase**]’ at /usr/include/c++/13/bits/stl_algobase.h:665:38,
inlined from ‘llvm::SmallVectorImpl<T>& llvm::SmallVectorImpl<T>::operator=(llvm::SmallVectorImpl<T>&&) [with T = llvm::VPBlockBase*]’ at ../include/llvm/ADT/SmallVector.h:1094:14,
inlined from ‘llvm::SmallVector<T, N>& llvm::SmallVector<T, N>::operator=(llvm::SmallVector<T, N>&&) [with T = llvm::VPBlockBase*; unsigned int N = 1]’ at ../include/llvm/ADT/SmallVector.h:1259:36,
inlined from ‘static void llvm::DomTreeBuilder::SemiNCAInfo<DomTreeT>::CalculateFromScratch(DomTreeT&, BatchUpdatePtr) [with DomTreeT = llvm::DominatorTreeBase<llvm::VPBlockBase, false>]’ at ../include/llvm/Support/GenericDomTreeConstruction.h:578:14:
/usr/include/c++/13/bits/stl_algobase.h:437:30: warning: ‘void* __builtin_memmove(void*, const void*, long unsigned int)’ reading between 9 and 34359738352 bytes from a region of size 8 [-Wstringop-overread]
437 | __builtin_memmove(__result, __first, sizeof(_Tp) * _Num);
| ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../include/llvm/Support/GenericDomTreeConstruction.h: In static member function ‘static void llvm::DomTreeBuilder::SemiNCAInfo<DomTreeT>::CalculateFromScratch(DomTreeT&, BatchUpdatePtr) [with DomTreeT = llvm::DominatorTreeBase<llvm::VPBlockBase, false>]’:
../include/llvm/Support/GenericDomTreeConstruction.h:578:25: note: at offset 16 into source object ‘<anonymous>’ of size 24
578 | DT.Roots = FindRoots(DT, PostViewBUI);
| ~~~~~~~~~^~~~~~~~~~~~~~~~~
Disable both of these, as they are extremely spammy and seem to
alert on things that aren't an issue in LLVM.
This disables the following very noisy warning:
In file included from /usr/include/c++/13/string:51,
from /usr/include/c++/13/bits/locale_classes.h:40,
from /usr/include/c++/13/bits/ios_base.h:41,
from /usr/include/c++/13/streambuf:43,
from /usr/include/c++/13/bits/streambuf_iterator.h:35,
from /usr/include/c++/13/iterator:66,
from ../include/llvm/ADT/ADL.h:13,
from ../include/llvm/ADT/DenseMap.h:17,
from ../lib/Transforms/Vectorize/VPlanAnalysis.h:12,
from ../lib/Transforms/Vectorize/VPlan.h:27,
from ../lib/Transforms/Vectorize/LoopVectorizationPlanner.h:27, from
../lib/Transforms/Vectorize/VPlanConstruction.cpp:14:
In static member function ‘static _Up* std::__copy_move<_IsMove, true,
std::random_access_iterator_tag>::__copy_m(_Tp*, _Tp*, _Up*) [with _Tp =
llvm::VPBlockBase*; _Up = llvm::VPBlockBase*; bool _IsMove = true]’,
inlined from ‘_OI std::__copy_move_a2(_II, _II, _OI) [with bool _IsMove
= true; _II = llvm::VPBlockBase**; _OI = llvm::VPBlockBase**]’ at
/usr/include/c++/13/bits/stl_algobase.h:506:30,
inlined from ‘_OI std::__copy_move_a1(_II, _II, _OI) [with bool _IsMove
= true; _II = llvm::VPBlockBase**; _OI = llvm::VPBlockBase**]’ at
/usr/include/c++/13/bits/stl_algobase.h:533:42,
inlined from ‘_OI std::__copy_move_a(_II, _II, _OI) [with bool _IsMove =
true; _II = llvm::VPBlockBase**; _OI = llvm::VPBlockBase**]’ at
/usr/include/c++/13/bits/stl_algobase.h:540:31,
inlined from ‘_OI std::move(_II, _II, _OI) [with _II =
llvm::VPBlockBase**; _OI = llvm::VPBlockBase**]’ at
/usr/include/c++/13/bits/stl_algobase.h:665:38,
inlined from ‘llvm::SmallVectorImpl<T>&
llvm::SmallVectorImpl<T>::operator=(llvm::SmallVectorImpl<T>&&) [with T
= llvm::VPBlockBase*]’ at ../include/llvm/ADT/SmallVector.h:1071:25,
inlined from ‘llvm::SmallVector<T, N>& llvm::SmallVector<T,
N>::operator=(llvm::SmallVector<T, N>&&) [with T = llvm::VPBlockBase*;
unsigned int N = 1]’ at ../include/llvm/ADT/SmallVector.h:1259:36,
inlined from ‘static void
llvm::DomTreeBuilder::SemiNCAInfo<DomTreeT>::CalculateFromScratch(DomTreeT&,
BatchUpdatePtr) [with DomTreeT =
llvm::DominatorTreeBase<llvm::VPBlockBase, false>]’ at
../include/llvm/Support/GenericDomTreeConstruction.h:578:14:
/usr/include/c++/13/bits/stl_algobase.h:437:30: warning: ‘void*
__builtin_memmove(void*, const void*, long unsigned int)’ forming offset
24 is out of the bounds [0, 24] of object ‘<anonymous>’ with type
‘llvm::DomTreeBuilder::SemiNCAInfo<llvm::DominatorTreeBase<llvm::VPBlockBase,
false> >::RootsT’ {aka ‘llvm::SmallVector<llvm::VPBlockBase*, 1>’}
[-Warray-bounds=]
437 | __builtin_memmove(__result, __first, sizeof(_Tp) * _Num);
| ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from
../lib/Transforms/Vectorize/VPlanDominatorTree.h:23,
from ../lib/Transforms/Vectorize/VPlanConstruction.cpp:17:
../include/llvm/Support/GenericDomTreeConstruction.h: In static member
function ‘static void
llvm::DomTreeBuilder::SemiNCAInfo<DomTreeT>::CalculateFromScratch(DomTreeT&,
BatchUpdatePtr) [with DomTreeT =
llvm::DominatorTreeBase<llvm::VPBlockBase, false>]’:
../include/llvm/Support/GenericDomTreeConstruction.h:578:25: note:
‘<anonymous>’ declared here
578 | DT.Roots = FindRoots(DT, PostViewBUI);
| ~~~~~~~~~^~~~~~~~~~~~~~~~~
In static member function ‘static _Up* std::__copy_move<_IsMove, true,
std::random_access_iterator_tag>::__copy_m(_Tp*, _Tp*, _Up*) [with _Tp =
llvm::VPBlockBase*; _Up = llvm::VPBlockBase*; bool _IsMove = true]’,
inlined from ‘_OI std::__copy_move_a2(_II, _II, _OI) [with bool _IsMove
= true; _II = llvm::VPBlockBase**; _OI = llvm::VPBlockBase**]’ at
/usr/include/c++/13/bits/stl_algobase.h:506:30,
inlined from ‘_OI std::__copy_move_a1(_II, _II, _OI) [with bool _IsMove
= true; _II = llvm::VPBlockBase**; _OI = llvm::VPBlockBase**]’ at
/usr/include/c++/13/bits/stl_algobase.h:533:42,
inlined from ‘_OI std::__copy_move_a(_II, _II, _OI) [with bool _IsMove =
true; _II = llvm::VPBlockBase**; _OI = llvm::VPBlockBase**]’ at
/usr/include/c++/13/bits/stl_algobase.h:540:31,
inlined from ‘_OI std::move(_II, _II, _OI) [with _II =
llvm::VPBlockBase**; _OI = llvm::VPBlockBase**]’ at
/usr/include/c++/13/bits/stl_algobase.h:665:38,
inlined from ‘llvm::SmallVectorImpl<T>&
llvm::SmallVectorImpl<T>::operator=(llvm::SmallVectorImpl<T>&&) [with T
= llvm::VPBlockBase*]’ at ../include/llvm/ADT/SmallVector.h:1094:14,
inlined from ‘llvm::SmallVector<T, N>& llvm::SmallVector<T,
N>::operator=(llvm::SmallVector<T, N>&&) [with T = llvm::VPBlockBase*;
unsigned int N = 1]’ at ../include/llvm/ADT/SmallVector.h:1259:36,
inlined from ‘static void
llvm::DomTreeBuilder::SemiNCAInfo<DomTreeT>::CalculateFromScratch(DomTreeT&,
BatchUpdatePtr) [with DomTreeT =
llvm::DominatorTreeBase<llvm::VPBlockBase, false>]’ at
../include/llvm/Support/GenericDomTreeConstruction.h:578:14:
/usr/include/c++/13/bits/stl_algobase.h:437:30: warning: ‘void*
__builtin_memmove(void*, const void*, long unsigned int)’ forming offset
24 is out of the bounds [0, 24] of object ‘<anonymous>’ with type
‘llvm::DomTreeBuilder::SemiNCAInfo<llvm::DominatorTreeBase<llvm::VPBlockBase,
false> >::RootsT’ {aka ‘llvm::SmallVector<llvm::VPBlockBase*, 1>’}
[-Warray-bounds=]
437 | __builtin_memmove(__result, __first, sizeof(_Tp) * _Num);
| ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../include/llvm/Support/GenericDomTreeConstruction.h: In static member
function ‘static void
llvm::DomTreeBuilder::SemiNCAInfo<DomTreeT>::CalculateFromScratch(DomTreeT&,
BatchUpdatePtr) [with DomTreeT =
llvm::DominatorTreeBase<llvm::VPBlockBase, false>]’:
../include/llvm/Support/GenericDomTreeConstruction.h:578:25: note:
‘<anonymous>’ declared here
578 | DT.Roots = FindRoots(DT, PostViewBUI);
| ~~~~~~~~~^~~~~~~~~~~~~~~~~
In a regular build, there's currently 14 such warning instances, but
since they are so large and noisy, they are very disruptive, and they
don't seem to be an actual issue in the LLVM code base.
With the -Warray-bounds warning disabled, the build instead ends up with
9 similar warnings of the kind -Wstringop-overread:
In file included from /usr/include/c++/13/string:51,
from /usr/include/c++/13/bits/locale_classes.h:40,
from /usr/include/c++/13/bits/ios_base.h:41,
from /usr/include/c++/13/streambuf:43,
from /usr/include/c++/13/bits/streambuf_iterator.h:35,
from /usr/include/c++/13/iterator:66,
from ../include/llvm/ADT/ADL.h:13,
from ../include/llvm/ADT/DenseMap.h:17,
from ../lib/Transforms/Vectorize/VPlanAnalysis.h:12,
from ../lib/Transforms/Vectorize/VPlan.h:27,
from ../lib/Transforms/Vectorize/LoopVectorizationPlanner.h:27, from
../lib/Transforms/Vectorize/VPlanConstruction.cpp:14:
In static member function ‘static _Up* std::__copy_move<_IsMove, true,
std::random_access_iterator_tag>::__copy_m(_Tp*, _Tp*, _Up*) [with _Tp =
llvm::VPBlockBase*; _Up = llvm::VPBlockBase*; bool _IsMove = true]’,
inlined from ‘_OI std::__copy_move_a2(_II, _II, _OI) [with bool _IsMove
= true; _II = llvm::VPBlockBase**; _OI = llvm::VPBlockBase**]’ at
/usr/include/c++/13/bits/stl_algobase.h:506:30,
inlined from ‘_OI std::__copy_move_a1(_II, _II, _OI) [with bool _IsMove
= true; _II = llvm::VPBlockBase**; _OI = llvm::VPBlockBase**]’ at
/usr/include/c++/13/bits/stl_algobase.h:533:42,
inlined from ‘_OI std::__copy_move_a(_II, _II, _OI) [with bool _IsMove =
true; _II = llvm::VPBlockBase**; _OI = llvm::VPBlockBase**]’ at
/usr/include/c++/13/bits/stl_algobase.h:540:31,
inlined from ‘_OI std::move(_II, _II, _OI) [with _II =
llvm::VPBlockBase**; _OI = llvm::VPBlockBase**]’ at
/usr/include/c++/13/bits/stl_algobase.h:665:38,
inlined from ‘llvm::SmallVectorImpl<T>&
llvm::SmallVectorImpl<T>::operator=(llvm::SmallVectorImpl<T>&&) [with T
= llvm::VPBlockBase*]’ at ../include/llvm/ADT/SmallVector.h:1071:25,
inlined from ‘llvm::SmallVector<T, N>& llvm::SmallVector<T,
N>::operator=(llvm::SmallVector<T, N>&&) [with T = llvm::VPBlockBase*;
unsigned int N = 1]’ at ../include/llvm/ADT/SmallVector.h:1259:36,
inlined from ‘static void
llvm::DomTreeBuilder::SemiNCAInfo<DomTreeT>::CalculateFromScratch(DomTreeT&,
BatchUpdatePtr) [with DomTreeT =
llvm::DominatorTreeBase<llvm::VPBlockBase, false>]’ at
../include/llvm/Support/GenericDomTreeConstruction.h:578:14:
/usr/include/c++/13/bits/stl_algobase.h:437:30: warning: ‘void*
__builtin_memmove(void*, const void*, long unsigned int)’ reading
between 9 and 34359738360 bytes from a region of size 8
[-Wstringop-overread]
437 | __builtin_memmove(__result, __first, sizeof(_Tp) * _Num);
| ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from
../lib/Transforms/Vectorize/VPlanDominatorTree.h:23,
from ../lib/Transforms/Vectorize/VPlanConstruction.cpp:17:
../include/llvm/Support/GenericDomTreeConstruction.h: In static member
function ‘static void
llvm::DomTreeBuilder::SemiNCAInfo<DomTreeT>::CalculateFromScratch(DomTreeT&,
BatchUpdatePtr) [with DomTreeT =
llvm::DominatorTreeBase<llvm::VPBlockBase, false>]’:
../include/llvm/Support/GenericDomTreeConstruction.h:578:25: note: at
offset 16 into source object ‘<anonymous>’ of size 24
578 | DT.Roots = FindRoots(DT, PostViewBUI);
| ~~~~~~~~~^~~~~~~~~~~~~~~~~
In static member function ‘static _Up* std::__copy_move<_IsMove, true,
std::random_access_iterator_tag>::__copy_m(_Tp*, _Tp*, _Up*) [with _Tp =
llvm::VPBlockBase*; _Up = llvm::VPBlockBase*; bool _IsMove = true]’,
inlined from ‘_OI std::__copy_move_a2(_II, _II, _OI) [with bool _IsMove
= true; _II = llvm::VPBlockBase**; _OI = llvm::VPBlockBase**]’ at
/usr/include/c++/13/bits/stl_algobase.h:506:30,
inlined from ‘_OI std::__copy_move_a1(_II, _II, _OI) [with bool _IsMove
= true; _II = llvm::VPBlockBase**; _OI = llvm::VPBlockBase**]’ at
/usr/include/c++/13/bits/stl_algobase.h:533:42,
inlined from ‘_OI std::__copy_move_a(_II, _II, _OI) [with bool _IsMove =
true; _II = llvm::VPBlockBase**; _OI = llvm::VPBlockBase**]’ at
/usr/include/c++/13/bits/stl_algobase.h:540:31,
inlined from ‘_OI std::move(_II, _II, _OI) [with _II =
llvm::VPBlockBase**; _OI = llvm::VPBlockBase**]’ at
/usr/include/c++/13/bits/stl_algobase.h:665:38,
inlined from ‘llvm::SmallVectorImpl<T>&
llvm::SmallVectorImpl<T>::operator=(llvm::SmallVectorImpl<T>&&) [with T
= llvm::VPBlockBase*]’ at ../include/llvm/ADT/SmallVector.h:1094:14,
inlined from ‘llvm::SmallVector<T, N>& llvm::SmallVector<T,
N>::operator=(llvm::SmallVector<T, N>&&) [with T = llvm::VPBlockBase*;
unsigned int N = 1]’ at ../include/llvm/ADT/SmallVector.h:1259:36,
inlined from ‘static void
llvm::DomTreeBuilder::SemiNCAInfo<DomTreeT>::CalculateFromScratch(DomTreeT&,
BatchUpdatePtr) [with DomTreeT =
llvm::DominatorTreeBase<llvm::VPBlockBase, false>]’ at
../include/llvm/Support/GenericDomTreeConstruction.h:578:14:
/usr/include/c++/13/bits/stl_algobase.h:437:30: warning: ‘void*
__builtin_memmove(void*, const void*, long unsigned int)’ reading
between 9 and 34359738352 bytes from a region of size 8
[-Wstringop-overread]
437 | __builtin_memmove(__result, __first, sizeof(_Tp) * _Num);
| ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../include/llvm/Support/GenericDomTreeConstruction.h: In static member
function ‘static void
llvm::DomTreeBuilder::SemiNCAInfo<DomTreeT>::CalculateFromScratch(DomTreeT&,
BatchUpdatePtr) [with DomTreeT =
llvm::DominatorTreeBase<llvm::VPBlockBase, false>]’:
../include/llvm/Support/GenericDomTreeConstruction.h:578:25: note: at
offset 16 into source object ‘<anonymous>’ of size 24
578 | DT.Roots = FindRoots(DT, PostViewBUI);
| ~~~~~~~~~^~~~~~~~~~~~~~~~~
Disable both of these, as they are extremely spammy and seem to alert on
things that aren't an issue in LLVM.
LLVM has a mechanism to switch the default target:
LLVM_TARGET_TRIPLE_ENV. For example, regression tests with lit use this
CMake variable. It matters only when building LLVM, not the other
projects. Therefore, if they are built standalone, the value of the
CMake variable should be propagated. In fact, however, it is not.
This patch fixes it.
This gets rid of 99 warnings which mostly seem like false positives (in
a build of LLVM+Clang+LLDB, with GCC 13).
The warnings look e.g. like this:
../lib/ObjCopy/COFF/COFFObjcopy.cpp: In function ‘uint64_t
llvm::objcopy::coff::getNextRVA(const Object&)’:
../lib/ObjCopy/COFF/COFFObjcopy.cpp:38:18: warning: possibly dangling
reference to a temporary [-Wdangling-reference]
38 | const Section &Last = Obj.getSections().back();
| ^~~~
../lib/ObjCopy/COFF/COFFObjcopy.cpp:38:47: note: the temporary was
destroyed at the end of the full expression ‘(&
Obj)->llvm::objcopy::coff::Object::getSections().llvm::ArrayRef<llvm::objcopy::coff::Section>::back()’
38 | const Section &Last = Obj.getSections().back();
| ~~~~~~~~~~~~~~~~~~~~~~^~
In this example, the `Object::getSections()` method returns an
`ArrayRef<Section>` from a `std::vector<Section>`. We invoke `back()` on
that, and store a reference in a local variable. Even though the
temporary `ArrayRef<Section>` has been destroyed, the reference points
to something which still is alive in the `std::vector<Section>`.
See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109642 and
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110358 for some
preexisting discussion on this warning and how it can be silenced
selectively since GCC 14.
This PR adds `SKIP` to `add_lit_testsuites`. The purpose is to let
people filter the currently exhaustive inclusion of subdirectories which
might not all depend on the same `DEPENDS`. The immediate use case is
MLIR where we have a collection of Python tests that currently trigger
rebuilds of various tools (like `mlir-opt`) which they do not depend on.
That collection of tests is updated here too.
Reapplying now that buildbot has picked up the new configuration
that does not use -treat-scalable-fixed-error-as-warning.
-----
This removes the `LLVM_ENABLE_STRICT_FIXED_SIZE_VECTORS` cmake option
and the `-treat-scalable-fixed-error-as-warning` opt flag.
We stopped treating these as warnings by default a long time ago
(62f09d788f9fc540db12f3cfa2f98760071fca96), so I don't think it makes
sense to retain these options at this point. Accessing a scalable
TypeSize as fixed should always result in an error.
This removes the `LLVM_ENABLE_STRICT_FIXED_SIZE_VECTORS` cmake option
and the `-treat-scalable-fixed-error-as-warning` opt flag.
We stopped treating these as warnings by default a long time ago
(62f09d788f9fc540db12f3cfa2f98760071fca96), so I don't think it makes
sense to retain these options at this point. Accessing a scalable
TypeSize as fixed should always result in an error.
It appears that unconditionally using GLIBCXX_USE_CXX11_ABI=0 is slow on
modern libstdc++, while using GLIBCXX_USE_CXX11_ABI=1 breaks old
buildbots, so use the compiler default unless asked to do differently.
This is a follow on to #154537, which quoted the CMAKE_SYSTEM_NAME to avoid expanding it again when that CMAKE_SYSTEM_NAME expands to AIX.
But by the same logic, we also need to quote the plain string AIX as well.
libstdc++ can be configured to default to a different C++11 ABI, and
when the system that is used to build clang has a different default than
the system used to build a clang plugin, that leads to uses of different
ABIs, leading to breakage (missing symbols) when using clang APIs that
use types like std::string.
We arbitrarily choose to default to the old ABI, but the user can opt-in
to the new ABI. The important part is that whichever is picked is
reflected in llvm-config's output.
A CMake change included in CMake 4.0 makes `AIX` into a variable
(similar to `APPLE`, etc.)
ff03db6657
However, `${CMAKE_SYSTEM_NAME}` unfortunately also expands exactly to
`AIX` and `if` auto-expands variable names in CMake. That means you get
a double expansion if you write:
`if (${CMAKE_SYSTEM_NAME} MATCHES "AIX")`
which becomes:
`if (AIX MATCHES "AIX")`
which is as if you wrote:
`if (ON MATCHES "AIX")`
You can prevent this by quoting the expansion of "${CMAKE_SYSTEM_NAME}",
due to policy
[CMP0054](https://cmake.org/cmake/help/latest/policy/CMP0054.html#policy:CMP0054)
which is on by default in 4.0+. Most of the LLVM CMake already does
this, but this PR fixes the remaining cases where we do not.