Nikolas Klauser [Wed, 3 Aug 2022 05:13:59 +0000 (22:13 -0700)]
[libc++][ranges] Implement `ranges::remove_copy{, _if}`.
Co-authored-by: Hui Xie <hui.xie1990@gmail.com>
Differential Revision: https://reviews.llvm.org/
D130599
(cherry picked from commit
760d2b462c04537d119d76d3cc37d2cb53774a05)
Michał Górny [Wed, 3 Aug 2022 01:52:25 +0000 (21:52 -0400)]
[libc++][test] Propagate host environment to libc++ test suite
Propagate the complete host environment to the tests run via the new
testconfig. This ensures that all envvars needed e.g. for the compiler
to work correctly are present. This mimics the behavior explicitly
implemented in the legacy config.
https://github.com/llvm/llvm-project/issues/56816
Differential Revision: https://reviews.llvm.org/
D130843
(cherry picked from commit
39d4e169d35b59a39ad2fcfe1a568ba979079d83)
Igor Zhukov [Wed, 3 Aug 2022 00:45:28 +0000 (20:45 -0400)]
[libc++][NFC] Don't rely on `<algorithm>` transitively including `<memory>` in tests
Found by @cpplearner (https://github.com/microsoft/STL/pull/2976#discussion_r935440806)
Differential Revision: https://reviews.llvm.org/
D130997
(cherry picked from commit
495519e5f8232d144ed26e9c18dbcbac6a5f25eb)
Igor Zhukov [Wed, 3 Aug 2022 00:42:05 +0000 (20:42 -0400)]
[libc++] Fix warning C4244 in std/numerics/rand/rand.dist/rand.dist.samp/rand.dist.samp.discrete/eval.pass.cpp
frederick-vs-ja noticed that https://github.com/microsoft/STL/pull/2976#issuecomment-
1201926893
while we are working on updating LLVM submodule for MS STL:
[...]\std\numerics\rand\rand.dist\rand.dist.samp\rand.dist.samp.discrete\eval.pass.cpp(33): error C2220: the following warning is treated as an error
[...]\std\numerics\rand\rand.dist\rand.dist.samp\rand.dist.samp.discrete\eval.pass.cpp(287): note: see reference to function template instantiation 'void tests<__int64>(void)' being compiled
[...]\std\numerics\rand\rand.dist\rand.dist.samp\rand.dist.samp.discrete\eval.pass.cpp(33): warning C4244: 'argument': conversion from '__int64' to 'const unsigned int', possible loss of data
Differential Revision: https://reviews.llvm.org/
D130963
(cherry picked from commit
db0ac307c9df26d26a629552aec0a78f1b492dfd)
Louis Dionne [Tue, 2 Aug 2022 20:15:55 +0000 (16:15 -0400)]
[libc++] Update documentation on testing libc++
(cherry picked from commit
ce6aff8d13894bdb6ec492858a66e8f8ab42c33b)
Casey Carter [Tue, 2 Aug 2022 19:03:25 +0000 (12:03 -0700)]
[libcxx][test] Test code should inspect `TEST_STD_VER`, not `_LIBCPP_STD_VER`.
(cherry picked from commit
a1a30dc933b928a7a8277d5b5f7bd25670e68884)
Mark de Wever [Fri, 29 Jul 2022 18:35:43 +0000 (20:35 +0200)]
[libc++][format] Enables feature-test macro.
The macro is only enabled when the Clang is used with
-fexperimental-library.
Reviewed By: ldionne, #libc
Differential Revision: https://reviews.llvm.org/
D130792
(cherry picked from commit
679169b7dd74c6f9161353f07e716ec25e80d1b8)
Mark de Wever [Tue, 26 Jul 2022 17:37:06 +0000 (19:37 +0200)]
[libc++][doc] Updates status documents.
Adds the papers and LWG issues voted in during the July 2022 plenary.
Note the updating of the project based statuses is left to the active
contributors of these projects.
Reviewed By: #libc, huixie90, philnik
Differential Revision: https://reviews.llvm.org/
D130595
(cherry picked from commit
759efa763abf0b9299683e8cf3ec161c0c97f13d)
Phoebe Wang [Thu, 4 Aug 2022 14:27:00 +0000 (22:27 +0800)]
[clang][llvm][doc] Add more information for the ABI change in FP16
Differential Revision: https://reviews.llvm.org/
D131172
Fangrui Song [Wed, 3 Aug 2022 17:23:54 +0000 (10:23 -0700)]
ReleaseNotes: add lld/ELF notes
For the release/15.x branch.
Differential Revision: https://reviews.llvm.org/
D130961
Martin Storsjö [Wed, 3 Aug 2022 09:08:32 +0000 (12:08 +0300)]
[lldb] [doc] Add release notes for a few noteworthy changes for Windows in 15.x
Martin Storsjö [Wed, 3 Aug 2022 09:07:48 +0000 (12:07 +0300)]
[LLD] [doc] Add release notes for MinGW changes for 15.x
Yuanfang Chen [Fri, 29 Jul 2022 21:50:40 +0000 (14:50 -0700)]
[CodeGen][inlineasm] assume the flag output of inline asm is boolean value
GCC inline asm document says that
"... the general rule is that the output variable must be a scalar
integer, and the value is boolean."
Commit
e5c37958f901cc9bec50624dbee85d40143e4bca lowers flag output of
inline asm on X86 with setcc, hence it is guaranteed that the flag
is of boolean value. Clang does not support ARM inline asm flag output
yet so nothing need to be worried about ARM.
See "Flag Output" section at
https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#OutputOperands
Fixes https://github.com/llvm/llvm-project/issues/56568
Reviewed By: nikic
Differential Revision: https://reviews.llvm.org/
D129954
(cherry picked from commit
92c1bc61586c9d6c7bf0c36b1005fe00b4f48cc0)
Konstantin Varlamov [Tue, 2 Aug 2022 03:43:28 +0000 (20:43 -0700)]
[libc++][ranges][NFC] Fix a few links on the Ranges status page.
(cherry picked from commit
c64c3d31c42869c258ad174d9a754279ef4aa07d)
Konstantin Varlamov [Sat, 30 Jul 2022 09:42:05 +0000 (02:42 -0700)]
[libc++][ranges] Implement `std::ranges::partial_sort_copy`.
Differential Revision: https://reviews.llvm.org/
D130532
(cherry picked from commit
db7d7959787ed68f037e2a6e5a70bb0d8c17ab27)
Nikolas Klauser [Sun, 24 Jul 2022 14:46:57 +0000 (16:46 +0200)]
[libc++] Fix reverse_iterator::iterator_concept
Fixes https://github.com/llvm/llvm-project/issues/56504
Reviewed By: ldionne, Mordante, huixie90, #libc
Spies: libcxx-commits, hewillk
Differential Revision: https://reviews.llvm.org/
D129794
(cherry picked from commit
7912b1f8e7c845a97411cbfc176db56861cdf116)
Louis Dionne [Mon, 25 Jul 2022 17:43:47 +0000 (13:43 -0400)]
[libc++] Rename __libcpp_assertion_handler to __libcpp_verbose_abort
With the goal of reusing that handler to do other things besides
handling assertions (such as terminating when an exception is thrown
under -fno-exceptions), the name `__libcpp_assertion_handler` doesn't
really make sense anymore.
Furthermore, I didn't want to use the name `__libcpp_abort_handler`,
since that would give the impression that the handler is called
whenever `std::abort()` is called, which is not the case at all.
Differential Revision: https://reviews.llvm.org/
D130562
(cherry picked from commit
507125af3d0b953cb56bce2e5b8000249fe1ef53)
Hui Xie [Sat, 23 Jul 2022 00:44:25 +0000 (01:44 +0100)]
[libc++][ranges] implement `std::ranges::unique{_copy}`
implement `std::ranges::unique` and `std::ranges::unique_copy`
Differential Revision: https://reviews.llvm.org/
D130404
(cherry picked from commit
72f57e3a30d597346feec74cf626796b0055680f)
Louis Dionne [Thu, 28 Jul 2022 14:25:30 +0000 (10:25 -0400)]
[libc++] Properly log crashes with the assertion handler on older Androids
This reintroduces the same workaround we have in libc++abi for older
Androids based on https://reviews.llvm.org/
D130507#inline-
1255914.
Differential Revision: https://reviews.llvm.org/
D130708
(cherry picked from commit
1422a9689d7907a4561da7b906ec392840d9e635)
Konstantin Varlamov [Thu, 28 Jul 2022 09:06:44 +0000 (02:06 -0700)]
[libc++] Make `_IterOps::__iter_move` more similar to `std::ranges::iter_move`.
Avoid relying on `iterator_traits` and instead deduce the return type of
dereferencing the iterator. Additionally, add a static check to reject
iterators with incorrect `iterator_traits` at compile time.
Differential Revision: https://reviews.llvm.org/
D130538
(cherry picked from commit
b3afea1ce0bd3c9293edae67c1839318eecdd7bf)
Nikolas Klauser [Thu, 28 Jul 2022 08:32:02 +0000 (10:32 +0200)]
[libc++] Fix merge-conflict in .clang-format
(cherry picked from commit
d5a3cc1d88d888e38633eb55e2afadb4cf788000)
Nikolas Klauser [Wed, 27 Jul 2022 21:52:45 +0000 (23:52 +0200)]
[libc++] Fix unwrapping ranges with different iterators and sentinels
Reviewed By: ldionne, huixie90, #libc
Spies: arichardson, sstefan1, libcxx-commits, mgorny
Differential Revision: https://reviews.llvm.org/
D129040
(cherry picked from commit
e01b4fe956dd038fed71cf3c552d3383905d022a)
Hui Xie [Wed, 27 Jul 2022 12:20:16 +0000 (13:20 +0100)]
[libc++][ranges] implement `std::ranges::inplace_merge`
Differential Revision: https://reviews.llvm.org/
D130627
(cherry picked from commit
8a61749f767e9af773051fc4f6dc99276fe189e3)
Michał Górny [Sat, 30 Jul 2022 18:53:02 +0000 (20:53 +0200)]
[openmp] [test] Fix prepending config.library_dir to LD_LIBRARY_PATH
Fix the LD_LIBRARY_PATH prepending order to make sure that
config.library_path ends up before any potentially-system directories
(e.g. config.hwloc_library_dir). This makes sure that we are testing
against the just-built openmp libraries rather than the version that is
already installed.
Also rename the function to `prepend_*` to make it clearer what it
actually does.
https://github.com/llvm/llvm-project/issues/56821
Differential Revision: https://reviews.llvm.org/
D130825
(cherry picked from commit
eb4612ca239bffbf1612e0bce442043e716bb9f5)
Michał Górny [Sun, 31 Jul 2022 11:02:57 +0000 (13:02 +0200)]
[libcxx] [test] Cover i386 & sparc64 in string.capacity test
Differential Revision: https://reviews.llvm.org/
D130837
(cherry picked from commit
09cf95bd3ec24c77a854a0e0d9431a6d4ba460bc)
Tom Stellard [Tue, 2 Aug 2022 09:02:15 +0000 (02:02 -0700)]
Simon Pilgrim [Tue, 2 Aug 2022 10:38:47 +0000 (11:38 +0100)]
[DAG] matchRotateSub - ensure the (pre-extended) shift amount is wide enough for the amount mask (PR56859)
matchRotateSub is given shift amounts that will already have stripped any/zero-extend nodes from - so make sure those values are wide enough to take a mask.
(cherry picked from commit
b651fdff79027064071db7c1d0250553e3e6a232)
Tom Stellard [Tue, 2 Aug 2022 09:02:15 +0000 (02:02 -0700)]
workflows: Remove symbol versions from libclang.so in the libclang ABI test
Now that the symbol version for libclang.so changes for each release again,
we need to remove the symbol versions from the shared library in order
for the ABI checker to be able to compare with an older version of the
shared library.
Nico Weber [Thu, 9 Jun 2022 16:13:31 +0000 (12:13 -0400)]
[lld/mac] Add support for $ld$previous symbols with explicit symbol name
A symbol `$ld$previous$/Another$1.2.3$1$3.0$14.0$_xxx$` means
"pretend symbol `_xxx` is in dylib `/Another` with version `1.2.3`
if the deployment target is between `3.0` and `14.0` and we're
targeting platform `1` (ie macOS)".
This means dylibs can now inject synthetic dylibs into the link, so
DylibFile needs to grow a 3rd constructor.
The only other interesting thing is that such an injected dylib
counts as a use of the original dylib. This patch gets this mostly
right (if _only_ `$ld$previous` symbols are used from a dylib,
we don't add a dep on the dylib itself, matching ld64), but one case
where we don't match ld64 yet is that ld64 even omits the original
dylib when linking it with `-needed-l`. Lld currently still adds a load
command for the original dylib in that case. (That's for a future
patch.)
Fixes #56074.
Differential Revision: https://reviews.llvm.org/
D130725
(cherry picked from commit
241f0e8b76d544a4a07a7f775b8421632539be19)
Rainer Orth [Fri, 29 Jul 2022 07:27:09 +0000 (09:27 +0200)]
[clang][Driver] Handle SPARC -mcpu=native etc.
To make use of SPARC support in `getHostCPUName` as implemented by
D130272
<https://reviews.llvm.org/
D130272>, this patch uses it to handle
`-mcpu=native` and `-mtune=native`. To match GCC, this patch rejects
`-march` instead of silently treating it as a no-op.
Tested on `sparcv9-sun-solaris2.11` and checking that those options are
passed on as `-target-cpu` resp. `-tune-cpu` as expected.
Differential Revision: https://reviews.llvm.org/
D130273
(cherry picked from commit
bf3714884ae4b4a0301bc6af78e8b4deff12558b)
Rainer Orth [Fri, 29 Jul 2022 07:19:38 +0000 (09:19 +0200)]
[Driver] Use libatomic for 32-bit SPARC atomics support on Linux
This is the Linux/sparc64 equivalent to
D118021
<https://reviews.llvm.org/
D118021>, necessary to provide an external
implementation of atomics on 32-bit SPARC which LLVM cannot inline even
with `-mcpu=v9` or an equivalent default.
Tested on `sparc64-unknown-linux-gnu`.
Differential Revision: https://reviews.llvm.org/
D130569
(cherry picked from commit
9b1897bbd0e3a6e9ef099e74c3d3ed35428c0460)
Rainer Orth [Wed, 27 Jul 2022 10:21:03 +0000 (12:21 +0200)]
[Support] Handle SPARC in sys::getHostCPUName
While working on
D118450 <https://reviews.llvm.org/
D118450>, I noticed that
`sys::getHostCPUName` lacks SPARC support.
This patch implements it. The code is taken from/inspired by GCC's
`gcc/config/sparc/driver-sparc.cc`. There's one caveat: since LLVM, unlike
GCC, doesn't support the SPARC-M7, -S7, and -M8 CPUs, I map all those to
the latest supported one (UltraSparc T4/`niagara4`).
Tested on `sparcv9-sun-solaris2.11` and `sparc64-unknown-linux-gnu` by
running `savcov --version` on
- Netra SPARC S7-2 (SPARC-S7, Solaris 11.4)
- SPARC T5-2 (SPARC T5, Solaris 11.4)
- SPARC Enterprise T5220 (UltraSPARC T2, Solaris 11.3)
- SPARC T5 (UltraSPARC T5, Debian sid)
- SPARC T3 (UltraSPARC T3, Debian sid)
- SPARC Enterprise T5220 (Debian sid)
Differential Revision: https://reviews.llvm.org/
D130272
(cherry picked from commit
979ddfff37d7e3bf258c2e5cbdc272fcb44c15f0)
Rainer Orth [Wed, 27 Jul 2022 10:30:18 +0000 (12:30 +0200)]
[compiler-rt][Sanitizer] Link sanitizer libs with -latomic on SPARC
When building on Linux/sparc64, the 32-bit `libclang_rt.asan.so`,
`libclang_rt.ubsan_minimal.so`, and `libclang_rt.ubsan_standalone.so`
failed to link with undefined references to 64-bit atomics, which `clang`
cannot inline. Even
D130569 <https://reviews.llvm.org/
D130569> didn't help
because those libraries are linked with `-nodefaultlibs`, so dependent
libraries need to be added explicitly.
That's what this patch does.
Tested on `sparc64-unknown-linux-gnu` and `sparcv9-sun-solaris2.11`.
Differential Revision: https://reviews.llvm.org/
D130571
(cherry picked from commit
0b2d5fd48bc281af89e5e7bfa33a3054b826ed52)
Sunho Kim [Mon, 1 Aug 2022 23:44:18 +0000 (08:44 +0900)]
[IntelJITEvents] Add missing include.
Fixes compilation error.
Differential Revision: https://reviews.llvm.org/
D130898
(cherry picked from commit
5680ef870f9058c4b52a09a6aec2ddf384c5a558)
Jez Ng [Sun, 31 Jul 2022 17:24:58 +0000 (13:24 -0400)]
[lld-macho] Release notes for 15.x
From inspection of
git log origin/release/14.x..origin/release/15.x -- lld/MachO
Reviewed By: #lld-macho, thakis
Differential Revision: https://reviews.llvm.org/
D130850
Joseph Huber [Wed, 27 Jul 2022 15:04:25 +0000 (11:04 -0400)]
Revert "[OpenMP] Remove noinline attributes in the device runtime"
The behaviour of this patch is not great, but it has some side-effects
that are required for OpenMPOpt to work. The problem is that when we use
`-mlink-builtin-bitcode` we only import used symbols from the runtime.
Then OpenMPOpt will insert calls to symbols that were not previously
included. This patch removed this implicit behaviour as these functions
were kept alive by the `noinline` simply because it kept calls to them
in the module. This caused regression in some tests that relied on some
OpenMPOpt passes without using LTO. Reverting for the LLVM15 release but
will try to fix it more correctly on main.
This reverts commit
d61d72dae604c3258e25c00622b1a85861450303.
Fixes #56752
(cherry picked from commit
b08369f7f288b6efb0897953da42ed54e60cfc0b)
Martin Storsjö [Thu, 14 Jul 2022 19:46:04 +0000 (22:46 +0300)]
[clang-tidy] Add CLANG_TIDY_CONFUSABLE_CHARS_GEN cmake cache variable to avoid building when cross compiling
This is similar to the LLVM_TABLEGEN, CLANG_TABLEGEN and
CLANG_PSEUDO_GEN cmake cache variables.
Differential Revision: https://reviews.llvm.org/
D129799
(cherry picked from commit
dc95d0c525636aed53a3b38258efa2dff4c83edf)
Martin Storsjö [Thu, 14 Jul 2022 19:39:55 +0000 (22:39 +0300)]
[clang-tidy] Rename the make-confusable-table executable
Rename it to clang-tidy-confusable-chars-gen, to make its role
clearer in a wider context.
In cross builds, the caller might want to provide this tool
externally (to avoid needing to rebuild it in the cross build).
In such a case, having the tool properly namespaced makes its role
clearer.
This matches how the clang-pseudo-gen tool was renamed in
a43fef05d4fae32f02365c7b8fef2aa631d23628 /
D126725.
Differential Revision: https://reviews.llvm.org/
D129798
(cherry picked from commit
18b4a8bcf3553174f770f09528c9bd01c8cebfe7)
Nikita Popov [Mon, 25 Jul 2022 13:12:10 +0000 (15:12 +0200)]
[ARM] Add target feature to force 32-bit atomics
This adds a +atomic-32 target feature, which instructs LLVM to assume
that lock-free 32-bit atomics are available for this target, even
if they usually wouldn't be.
If only atomic loads/stores are used, then this won't emit libcalls.
If atomic CAS is used, then the user is responsible for providing
any necessary __sync implementations (e.g. by masking interrupts
for single-core privileged use cases).
See https://reviews.llvm.org/
D120026#
3674333 for context on this
change. The tl;dr is that the thumbv6m target in Rust has
historically made atomic load/store only available, which is
incompatible with the change from
D120026, which switched these to
use libatomic.
Differential Revision: https://reviews.llvm.org/
D130480
(cherry picked from commit
b1b1086973d5be26f127540852ace59c5119e90a)
Fangrui Song [Wed, 27 Jul 2022 18:18:19 +0000 (11:18 -0700)]
[ELF][test] Fix compressed-debug-level.test with zlib-ng
The test is brittle but it seems unnecessary to remove size check now.
Close #56222
(cherry picked from commit
876af563e73a3c1d6b49e13b4c1791a4208c8546)
Amara Emerson [Wed, 27 Jul 2022 07:02:59 +0000 (00:02 -0700)]
[AArch64][GlobalISel] Lower vector G_CTTZ.
Fixes issue 56398
(cherry picked from commit
9cc1dd209d20eda51710f302800899730b419381)
Nikolas Klauser [Wed, 27 Jul 2022 12:41:40 +0000 (14:41 +0200)]
[libc++] Implement P1004R2 (constexpr std::vector)
Reviewed By: #libc, ldionne
Spies: mgorny, var-const, ormris, philnik, miscco, hiraditya, steven_wu, jkorous, ldionne, christof, libcxx-commits
Differential Revision: https://reviews.llvm.org/D68365
(cherry picked from commit
98d3d5b5da66e3cf7807c23a0294280bb796466b)
Sebastian Neubauer [Thu, 28 Jul 2022 12:34:59 +0000 (14:34 +0200)]
[CMake][OpenMP] Remove wrong backslash
outdir is defined in the line above, it will not exist in the install
command, so it should not be escaped.
(cherry picked from commit
50716ba2b337afe46ac256cc91673dc27356a776)
Tom Stellard [Wed, 27 Jul 2022 22:23:24 +0000 (15:23 -0700)]
workflows: Use macos-11 runners
macos-10.15 is deprecated and will be removed.
(cherry picked from commit
d9e02a30b16ea65a7da87913c40af03e22c9571f)
Tom Stellard [Wed, 27 Jul 2022 19:31:40 +0000 (12:31 -0700)]
workflows: Fix version check for X.0.0 releases
(cherry picked from commit
51ba98d058c24632b86b79af5a4ddf6c5ab4e614)
Tom Stellard [Wed, 27 Jul 2022 04:46:53 +0000 (21:46 -0700)]
Drop 'git' from version string
Weverything [Wed, 27 Jul 2022 04:02:31 +0000 (21:02 -0700)]
Inline function calls.
Fix unused variable in non-assert builds after
300fbf56f89aebbe2ef9ed490066bab23e5356d1
Keith Smiley [Tue, 26 Jul 2022 23:18:17 +0000 (16:18 -0700)]
[lld-macho] Fix -bitcode_process_mode arg type
This is still undocumented and unsupported, but if someone passed it
before you would end up with a missing file error since this takes an
argument that wouldn't be handled.
Differential Revision: https://reviews.llvm.org/
D130606
Konstantin Varlamov [Wed, 27 Jul 2022 02:45:06 +0000 (19:45 -0700)]
[libc++][ranges] Fix the CI.
Kai Luo [Wed, 27 Jul 2022 01:27:07 +0000 (01:27 +0000)]
[clang][AIX] Add option to control quadword lock free atomics ABI on AIX
We are supporting quadword lock free atomics on AIX. For the situation that users on AIX are using a libatomic that is lock-based for quadword types, we can't enable quadword lock free atomics by default on AIX in case user's new code and existing code accessing the same shared atomic quadword variable, we can't guarentee atomicity. So we need an option to enable quadword lock free atomics on AIX, thus we can build a quadword lock-free libatomic(also for advanced users considering atomic performance critical) for users to make the transition smooth.
Reviewed By: shchenz
Differential Revision: https://reviews.llvm.org/
D127189
Kirill Stoimenov [Wed, 27 Jul 2022 01:29:31 +0000 (18:29 -0700)]
[ASan] Use stack safety analysis to optimize allocas instrumentation.
Added alloca optimization which was missed during the implemenation of
D112098.
Reviewed By: vitalybuka
Differential Revision: https://reviews.llvm.org/
D130503
Vitaly Buka [Wed, 27 Jul 2022 01:26:59 +0000 (18:26 -0700)]
[asan][test] Check for __asan_stack_malloc
Jon Chesterfield [Wed, 27 Jul 2022 00:44:36 +0000 (01:44 +0100)]
[amdgpu][nfc] Separate processUsedLDS into independent pieces, rename it
Michael Kruse [Wed, 27 Jul 2022 00:02:21 +0000 (19:02 -0500)]
[Polly] Insert !dbg metadata for emitted CallInsts.
The IR Verifier requires that every call instruction to an inlineable
function (among other things, its implementation must be visible in the
translation unit) must also have !dbg metadata attached to it. When
parallelizing, Polly emits calls to OpenMP runtime function out of thin
air, or at least not directly derived from a bounded list of previous
instruction. While we could search for instructions in the SCoP that has
some debug info attached to it, there is no guarantee that we find any.
Our solution is to generate a new DILocation that points to line 0 to
represent optimized code.
The OpenMP function implementation is usually not available in the
user's translation unit, but can become visible in an LTO build. For
the bug to appear, libomp must also be built with debug symbols.
IMHO, the IR verifier rule is too strict. Runtime functions can
also be inserted by other optimization passes, such as
LoopIdiomRecognize. When inserting a call to e.g. memset, it uses the
DebugLoc from a StoreInst from the unoptimized code. It is not
required to have !dbg metadata attached either.
Fixes #56692
Jon Chesterfield [Wed, 27 Jul 2022 00:29:32 +0000 (01:29 +0100)]
[amdgpu][nfc] Extract kernel annotation from processUsedLDS
Tom Stellard [Wed, 27 Jul 2022 00:24:18 +0000 (17:24 -0700)]
workflows: Use sccache to speed up CI builds
Reviewed By: asl
Differential Revision: https://reviews.llvm.org/
D129880
Vitaly Buka [Wed, 27 Jul 2022 00:06:18 +0000 (17:06 -0700)]
[asan][test] Cleanup asan-stack-safety.ll test
Tom Stellard [Tue, 26 Jul 2022 23:52:53 +0000 (16:52 -0700)]
Import CI tests from the release branch
The tests still only run on pushes or pull requests for the release
branch, but having it in the main branch means we don't have to copy
the tests every time we create a new release branch.
Reviewed By: asl
Differential Revision: https://reviews.llvm.org/
D129526
Konstantin Varlamov [Tue, 26 Jul 2022 23:15:07 +0000 (16:15 -0700)]
[libc++][NFC] Add checks for lifetime issues in classic algorithms.
Differential Revision: https://reviews.llvm.org/
D130330
Konstantin Varlamov [Tue, 26 Jul 2022 23:11:09 +0000 (16:11 -0700)]
[libc++][ranges] Implement `ranges::is_heap{,_until}`.
Differential Revision: https://reviews.llvm.org/
D130547
Jakob Johnson [Tue, 26 Jul 2022 15:14:19 +0000 (08:14 -0700)]
Add string conversion for InstructionControlFlowKind enum
Refactor the string conversion of the `lldb::InstructionControlFlowKind` enum out
of `Instruction::Dump` to enable reuse of this logic by the
JSON TraceDumper (to be implemented in separate diff).
Will coordinate the landing of this change with
D130320 since there will be a minor merge conflict between
these changes.
Test Plan:
Run unittests
```
> ninja check-lldb
[4/5] Running lldb unit test suite
Testing Time: 10.13s
Passed: 1084
```
Verify '-k' flag's output
```
(lldb) thread trace dump instructions -k
thread #1: tid =
1375377
libstdc++.so.6`std::ostream::flush() + 43
7048: 0x00007ffff7b54dab return retq
7047: 0x00007ffff7b54daa other popq %rbx
7046: 0x00007ffff7b54da7 other movq %rbx, %rax
7045: 0x00007ffff7b54da5 cond jump je 0x11adb0 ; <+48>
7044: 0x00007ffff7b54da2 other cmpl $-0x1, %eax
libc.so.6`_IO_fflush + 249
7043: 0x00007ffff7161729 return retq
7042: 0x00007ffff7161728 other popq %rbp
7041: 0x00007ffff7161727 other popq %rbx
7040: 0x00007ffff7161725 other movl %edx, %eax
7039: 0x00007ffff7161721 other addq $0x8, %rsp
7038: 0x00007ffff7161709 cond jump je 0x87721 ; <+241>
7037: 0x00007ffff7161707 other decl (%rsi)
7036: 0x00007ffff71616fe cond jump je 0x87707 ; <+215>
7035: 0x00007ffff71616f7 other cmpl $0x0, 0x33de92(%rip) ; __libc_multiple_threads
7034: 0x00007ffff71616ef other movq $0x0, 0x8(%rsi)
7033: 0x00007ffff71616ed cond jump jne 0x87721 ; <+241>
7032: 0x00007ffff71616e9 other subl $0x1, 0x4(%rsi)
7031: 0x00007ffff71616e2 other movq 0x88(%rbx), %rsi
7030: 0x00007ffff71616e0 cond jump jne 0x87721 ; <+241>
7029: 0x00007ffff71616da other testl $0x8000, (%rbx) ; imm = 0x8000
```
Differential Revision: https://reviews.llvm.org/
D130580
Konstantin Varlamov [Tue, 26 Jul 2022 22:51:37 +0000 (15:51 -0700)]
[libc++][ranges] Make sure all range algorithms support differing projection types:
- for all algorithms taking more than one range, add a `robust` test to
check the case where the ranges have different value types and the
given projections are different, with each projection applying to
a different value type;
- fix `ranges::include` to apply the correct projection to each range.
Differential Revision: https://reviews.llvm.org/
D130515
Konstantin Varlamov [Tue, 26 Jul 2022 22:50:14 +0000 (15:50 -0700)]
[libc++][ranges] Implement `ranges::generate{,_n}`.
Differential Revision: https://reviews.llvm.org/
D130552
Tom Stellard [Tue, 26 Jul 2022 22:49:35 +0000 (15:49 -0700)]
Revert "[Support] Workaround compiler bug in MSVC"
This reverts commit
ec8f4fd68cd401a0ba41bb160d6acce670486fab.
This caused a failure in the mlir-windows bot.
Tom Stellard [Tue, 26 Jul 2022 22:36:48 +0000 (15:36 -0700)]
workflows: Add GitHub action for automating some release tasks
For each release tag, this action will create a new release on GitHub,
and for each -final tag, this action will build the documentation and
upload it to GitHub.
Reviewed By: hans, kwk
Differential Revision: https://reviews.llvm.org/D99780
Tom Stellard [Tue, 26 Jul 2022 22:18:23 +0000 (15:18 -0700)]
github: Automatically assign reviewers for backport requests
When there is a backport request, the GitHub Action that handles the
backport will now automatically assign the issue to the user(s) who
approved the commit in Phabricator and create an issue comment asking
them to review the request.
Reviewed By: thieta, kwk
Differential Revision: https://reviews.llvm.org/
D126423
Dmitry Vassiliev [Tue, 26 Jul 2022 22:21:57 +0000 (00:21 +0200)]
[CodeGen] Fixed ambiguous symbol ExtAddrMode in case of NDEBUG and LLVM_ENABLE_DUMP
This patch fixes the following error with MSVC 16.9.2 in case of NDEBUG and LLVM_ENABLE_DUMP:
llvm/lib/CodeGen/CodeGenPrepare.cpp(2581): error C2872: 'ExtAddrMode': ambiguous symbol
llvm/include/llvm/CodeGen/TargetInstrInfo.h(86): note: could be 'llvm::ExtAddrMode'
llvm/lib/CodeGen/CodeGenPrepare.cpp(2447): note: or '`anonymous-namespace'::ExtAddrMode'
llvm/lib/CodeGen/CodeGenPrepare.cpp(2581): error C2039: 'print': is not a member of 'llvm::ExtAddrMode'
Reviewed By: aaron.ballman
Differential Revision: https://reviews.llvm.org/
D130426
Tom Stellard [Tue, 26 Jul 2022 22:05:03 +0000 (15:05 -0700)]
github: Fix release automation /branch command with new repo
We started using the llvm/llvm-project-release-prs repo for
backport pull requests, but since this repo is not a fork of
llvm/llvm-project it will reject pull requests from other repos. In
order to fix this, when ever someone uses the /branch command to request
a branch be merged into the release branch, we first copy the branch to
the llvm-project-release-prs repo and then create the pull request.
Reviewed By: thieta
Differential Revision: https://reviews.llvm.org/
D126940
Fangrui Song [Tue, 26 Jul 2022 21:52:06 +0000 (14:52 -0700)]
[ELF] addDependentLibrary: fix a use-after-free bug in archiveName
River Riddle [Tue, 26 Jul 2022 20:22:19 +0000 (13:22 -0700)]
[mlir] Refactor SubElementInterface replace support
The current support was essentially the amount necessary
to support replacing SymbolRefAttrs, but suffers from various
deficiencies (both ergonomic and functional):
* Replace crashes if unsupported
This makes it really hard to use safely, given that you don't know
if you are going to crash or not when using it.
* Types aren't supported
This seems like a simple missed addition when the attribute replacement
support was originally added.
* The ergonomics are weird
It currently uses an index based replacement, which makes the implementations
quite clunky.
This commit refactors support to be a bit more ergonomic, and also
adds support for types in the process. This was also a great oppurtunity
to greatly simplify how replacement is done in the symbol table.
Fixes #56355
Differential Revision: https://reviews.llvm.org/
D130589
Fangrui Song [Tue, 26 Jul 2022 21:36:56 +0000 (14:36 -0700)]
[ELF] addLibrary: fix a use-after-free bug in archiveName
It manifests as an incorrect name in --print-archive-stats=.
Fangrui Song [Tue, 26 Jul 2022 21:36:09 +0000 (14:36 -0700)]
[ELF][test] Clean up print-archive-stats.s
Craig Topper [Tue, 26 Jul 2022 21:21:58 +0000 (14:21 -0700)]
[RISCV] Pre-commit tests for
D130146. NFC
Argyrios Kyrtzidis [Tue, 26 Jul 2022 21:05:22 +0000 (14:05 -0700)]
[lldb/ClangExpressionParser] Fix compiler error due to `clang::CreateLLVMCodeGen()` API change
Argyrios Kyrtzidis [Sat, 23 Jul 2022 07:11:44 +0000 (00:11 -0700)]
[CGDebugInfo] Access the current working directory from the `VFS`
...instead of calling `llvm::sys::fs::current_path()` directly.
Differential Revision: https://reviews.llvm.org/
D130443
Danny Mösch [Tue, 12 Jul 2022 21:33:01 +0000 (23:33 +0200)]
[clang-tidy] Avoid extra parentheses around MemberExpr
Fixes https://github.com/llvm/llvm-project/issues/55025.
Reviewed By: aaron.ballman
Differential Revision: https://reviews.llvm.org/
D129596
Martin Sebor [Thu, 7 Jul 2022 20:35:23 +0000 (14:35 -0600)]
[InstCombine] Fold strtoul and strtoull and avoid PR #56293
Reviewed By: efriedma
Differential Revision: https://reviews.llvm.org/
D129224
Augusto Noronha [Tue, 26 Jul 2022 19:59:57 +0000 (12:59 -0700)]
[lldb] Disable TestStackFromStdModule.py
TestStackFromStdModule.py started failing due to
f4fb72e6d4ce
(https://reviews.llvm.org/
D128146), with a clang assertion failure:
assert(isa<InjectedClassNameType>(Decl->TypeForDecl))
Jon Chesterfield [Tue, 26 Jul 2022 19:47:52 +0000 (20:47 +0100)]
[amdgpu][nfc] Separate LDS struct creation from RAUW
Tom Stellard [Tue, 26 Jul 2022 19:50:56 +0000 (12:50 -0700)]
[Support] Workaround compiler bug in MSVC
https://developercommunity.visualstudio.com/t/Prev-Issue---with-__assume-isnan-/
1597317
This was causing unittest failures on Windows for the GitHub actions
based CI we use in the release branches.
Failed Tests (2):
LLVM-Unit :: Support/./SupportTests.exe/FormatVariadicTest.BigTest
LLVM-Unit :: Support/./SupportTests.exe/NativeFormatTest.BoundaryTests
Reviewed By: RKSimon
Differential Revision: https://reviews.llvm.org/
D129822
Sanjay Patel [Tue, 26 Jul 2022 19:31:12 +0000 (15:31 -0400)]
[AggressiveInstCombine] convert sqrt libcalls with "nnan" to sqrt intrinsics
This is an alternate to
D129155 that uses TTI.haveFastSqrt() to avoid a
potential miscompile for programs with reads of errno. Moving the transform
to AggressiveInstCombine provides access to TTI.
If a sqrt call has "nnan", that implies that the input argument is never
negative because sqrt of {negative number} --> NAN.
If the argument is never negative and the call can be lowered without a
libcall, then we can assume that errno accesses are unchanged after lowering,
so the call can be translated to the LLVM intrinsic (which is expected to
become inline code).
This affects codegen for targets like x86 that have sqrt instructions, but
still have to conservatively assume that a libcall may be needed to set
errno as shown in issue #52620 and issue #56383.
This patch won't solve those examples - we will need to extend this to use
CannotBeOrderedLessThanZero or similar, enhance that analysis for new
operators, and/or deal with llvm.assume too.
Differential Revision: https://reviews.llvm.org/
D129167
Shilei Tian [Tue, 26 Jul 2022 19:39:00 +0000 (15:39 -0400)]
[Clang][Doc] Update the release note for clang
Add the support for `atomic compare` and `atomic compare capture` in the
release note of clang.
Reviewed By: jdoerfert
Differential Revision: https://reviews.llvm.org/
D129211
Danny Mösch [Sun, 17 Jul 2022 19:28:36 +0000 (21:28 +0200)]
[clang] Pass FoundDecl to DeclRefExpr creator for operator overloads
Without the "found declaration" it is later not possible to know where the operator declaration
was brought into the scope calling it.
The initial motivation for this fix came from #55095. However, this also has an influence on
`clang -ast-dump` which now prints a `UsingShadow` attribute for operators only visible through
`using` statements. Also, clangd now correctly references the `using` statement instead of the
operator directly.
Reviewed By: shafik
Differential Revision: https://reviews.llvm.org/
D129973
Walter Erquinigo [Tue, 26 Jul 2022 18:44:50 +0000 (11:44 -0700)]
Move GetControlFlowKind's logic to DisassemblerLLVMC.cpp
This diff move the logic of `GetControlFlowKind()` from Disassembler.cpp to DisassemblerLLVMC.cpp.
Here's details:
- Actual logic of GetControlFlowKind() move to `DisassemblerLLVMC.cpp`, and we can check underlying architecture using `DisassemblerScope` there.
- With this change, passing 'triple' to `GetControlFlowKind()` is no more required.
Reviewed By: wallace
Differential Revision: https://reviews.llvm.org/
D130320
Walter Erquinigo [Mon, 18 Jul 2022 23:56:01 +0000 (16:56 -0700)]
[trace][intel pt] Introduce wall clock time for each trace item
- Decouple TSCs from trace items
- Turn TSCs into events just like CPUs. The new name is HW clock tick, wich could be reused by other vendors.
- Add a GetWallTime that returns the wall time that the trace plug-in can infer for each trace item.
- For intel pt, we are doing the following interpolation: if an instruction takes less than 1 TSC, we use that duration, otherwise, we assume the instruction took 1 TSC. This helps us avoid having to handle context switches, changes to kernel, idle times, decoding errors, etc. We are just trying to show some approximation and not the real data. For the real data, TSCs are the way to go. Besides that, we are making sure that no two trace items will give the same interpolation value. Finally, we are using as time 0 the time at which tracing started.
Sample output:
```
(lldb) r
Process 750047 launched: '/home/wallace/a.out' (x86_64)
Process 750047 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
frame #0: 0x0000000000402479 a.out`main at main.cpp:29:20
26 };
27
28 int main() {
-> 29 std::vector<int> vvv;
30 for (int i = 0; i < 100; i++)
31 vvv.push_back(i);
32
(lldb) process trace start -s 64kb -t --per-cpu
(lldb) b 60
Breakpoint 2: where = a.out`main + 1689 at main.cpp:60:23, address = 0x0000000000402afe
(lldb) c
Process 750047 resuming
Process 750047 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 2.1
frame #0: 0x0000000000402afe a.out`main at main.cpp:60:23
57 map<int, int> m;
58 m[3] = 4;
59
-> 60 map<string, string> m2;
61 m2["5"] = "6";
62
63 std::vector<std::string> vs = {"2", "3"};
(lldb) thread trace dump instructions -t -f -e thread #1: tid = 750047
0: [379567.000 ns] (event) HW clock tick [
48599428476224707]
1: [379569.000 ns] (event) CPU core changed [new CPU=2]
2: [390487.000 ns] (event) HW clock tick [
48599428476246495]
3: [
1602508.000 ns] (event) HW clock tick [
48599428478664855]
4: [
1662745.000 ns] (event) HW clock tick [
48599428478785046]
libc.so.6`malloc
5: [
1662746.995 ns] 0x00007ffff7176660 endbr64
6: [
1662748.991 ns] 0x00007ffff7176664 movq 0x32387d(%rip), %rax ; + 408
7: [
1662750.986 ns] 0x00007ffff717666b pushq %r12
8: [
1662752.981 ns] 0x00007ffff717666d pushq %rbp
9: [
1662754.977 ns] 0x00007ffff717666e pushq %rbx
10: [
1662756.972 ns] 0x00007ffff717666f movq (%rax), %rax
11: [
1662758.967 ns] 0x00007ffff7176672 testq %rax, %rax
12: [
1662760.963 ns] 0x00007ffff7176675 jne 0x9c7e0 ; <+384>
13: [
1662762.958 ns] 0x00007ffff717667b leaq 0x17(%rdi), %rax
14: [
1662764.953 ns] 0x00007ffff717667f cmpq $0x1f, %rax
15: [
1662766.949 ns] 0x00007ffff7176683 ja 0x9c730 ; <+208>
16: [
1662768.944 ns] 0x00007ffff7176730 andq $-0x10, %rax
17: [
1662770.939 ns] 0x00007ffff7176734 cmpq $-0x41, %rax
18: [
1662772.935 ns] 0x00007ffff7176738 seta %dl
19: [
1662774.930 ns] 0x00007ffff717673b jmp 0x9c690 ; <+48>
20: [
1662776.925 ns] 0x00007ffff7176690 cmpq %rdi, %rax
21: [
1662778.921 ns] 0x00007ffff7176693 jb 0x9c7b0 ; <+336>
22: [
1662780.916 ns] 0x00007ffff7176699 testb %dl, %dl
23: [
1662782.911 ns] 0x00007ffff717669b jne 0x9c7b0 ; <+336>
24: [
1662784.906 ns] 0x00007ffff71766a1 movq 0x3236c0(%rip), %r12 ; + 24
(lldb) thread trace dump instructions -t -f -e -J -c 4
[
{
"id": 0,
"timestamp_ns": "379567.000000",
"event": "HW clock tick",
"hwClock":
48599428476224707
},
{
"id": 1,
"timestamp_ns": "379569.000000",
"event": "CPU core changed",
"cpuId": 2
},
{
"id": 2,
"timestamp_ns": "390487.000000",
"event": "HW clock tick",
"hwClock":
48599428476246495
},
{
"id": 3,
"timestamp_ns": "
1602508.000000",
"event": "HW clock tick",
"hwClock":
48599428478664855
},
{
"id": 4,
"timestamp_ns": "
1662745.000000",
"event": "HW clock tick",
"hwClock":
48599428478785046
},
{
"id": 5,
"timestamp_ns": "
1662746.995324",
"loadAddress": "0x7ffff7176660",
"module": "libc.so.6",
"symbol": "malloc",
"mnemonic": "endbr64"
},
{
"id": 6,
"timestamp_ns": "
1662748.990648",
"loadAddress": "0x7ffff7176664",
"module": "libc.so.6",
"symbol": "malloc",
"mnemonic": "movq"
},
{
"id": 7,
"timestamp_ns": "
1662750.985972",
"loadAddress": "0x7ffff717666b",
"module": "libc.so.6",
"symbol": "malloc",
"mnemonic": "pushq"
},
{
"id": 8,
"timestamp_ns": "
1662752.981296",
"loadAddress": "0x7ffff717666d",
"module": "libc.so.6",
"symbol": "malloc",
"mnemonic": "pushq"
}
]
```
Differential Revision: https://reviews.llvm.org/
D130054
Sanjay Patel [Tue, 26 Jul 2022 17:29:48 +0000 (13:29 -0400)]
[InstSimplify] remove redundant calls to 'isImplied'; NFCI
We already call the more general isImpliedCondition() (which calls
isImpliedTrueByMatchingCmp() internally) from simplifyAndInst()
and simplifyOrInst().
There was a difference visible with this change on a vector test
before
a925bef70c6c, but I can't find any gaps now.
LLVM GN Syncbot [Tue, 26 Jul 2022 18:27:34 +0000 (18:27 +0000)]
[gn build] Port
4638d7a28f62
Blue Gaston [Tue, 26 Jul 2022 03:47:15 +0000 (20:47 -0700)]
[Sanitizers][Darwin] Allows '-mtargetos' to used to set minimum deployment target.
Currently, m{platform}-version-min is default flag used to set min deployment target within compilter-rt and sanitizers.
However, clang uses flags -target and -mtargetos for setting target triple and minimum deployment targets.
-mtargetos will be the preferred flag to set min version in the future and the
${platform}-version-min flag will not be used for future platforms.
This change allows darwin platforms to use either ${platform}-min-version or -mtargetos
without breaking lit test flags that allows for overriding the default min value in lit tests
Tests using flags: 'darwin_min_target_with_tls_support', 'min_macos_deployment_target'
will no longer fail if they use mtargetos instead of version-min.
rdar://
81028225
Differential Revision: https://reviews.llvm.org/
D130542
Lambert, Jacob [Tue, 26 Jul 2022 18:22:31 +0000 (11:22 -0700)]
Revert "[clang-offload-bundler] Library-ize ClangOffloadBundler"
This reverts commit
8348c4095600ec2c0beee293267832799d2ebee3.
Francis Visoiu Mistrih [Wed, 20 Jul 2022 09:32:15 +0000 (11:32 +0200)]
[Matrix] Add assert to catch extracted vectors with poison elements
Assert when the extracted vector is wider than the row/column.
Differential Revision: https://reviews.llvm.org/
D130173
Craig Topper [Tue, 26 Jul 2022 17:56:37 +0000 (10:56 -0700)]
[RISCV] Add Predicate to c.lw/c.sw/c.lwsp/c.swsp InstAliases with no offset.
These are aliases that allow the immediate offset to be ommitted.
We had predicates for the RV64, RV32+F, and D versions, but
not the base versions.
I've also re-ordered them to share Predicate lines to improve
readability.
Francis Visoiu Mistrih [Wed, 20 Jul 2022 09:12:30 +0000 (11:12 +0200)]
[Matrix] Refactor tiled loops in a struct. NFC
The three loops have the same structure: index, header, latch.
Jessica Paquette [Tue, 26 Jul 2022 17:54:30 +0000 (10:54 -0700)]
[GlobalISel] Import patterns for G_FMAXIMUM + G_FMINIMUM
Allows us to select scalar instructions on AArch64.
Differential Revision: https://reviews.llvm.org/
D115381
Sam Estep [Tue, 26 Jul 2022 17:54:13 +0000 (17:54 +0000)]
[clang][dataflow] Analyze calls to in-TU functions
This patch adds initial support for context-sensitive analysis of simple functions whose definition is available in the translation unit, guarded by the `ContextSensitive` flag in the new `TransferOptions` struct. When this option is true, the `VisitCallExpr` case in the builtin transfer function has a fallthrough case which checks for a direct callee with a body. In that case, it constructs a CFG from that callee body, uses the new `pushCall` method on the `Environment` to make an environment to analyze the callee, and then calls `runDataflowAnalysis` with a `NoopAnalysis` (disabling context-sensitive analysis on that sub-analysis, to avoid problems with recursion). After the sub-analysis completes, the `Environment` from its exit block is simply assigned back to the environment at the callsite.
The `pushCall` method (which currently only supports non-method functions with some restrictions) maps the `SourceLocation`s for all the parameters to the existing source locations for the corresponding arguments from the callsite.
This patch adds a few tests to check that this context-sensitive analysis works on simple functions. More sophisticated functionality will be added later; the most important next step is to explicitly model context in some fields of the `DataflowAnalysisContext` class, as mentioned in a `FIXME` comment in the `pushCall` implementation.
Reviewed By: ymandel, xazax.hun
Differential Revision: https://reviews.llvm.org/
D130306
Craig Topper [Tue, 26 Jul 2022 17:39:20 +0000 (10:39 -0700)]
[RISCV] Minor fixes to rv64c-valid.s test.
-Missing CHECK-NO-EXT and CHECK-NO-RV64 on subw.
-Stray CHECK-NO-RV64 on c.slli.
-c.slli used immediate 1 instead of RV64 only immediate like 63.
-Missing CHECK-NO-EXT on c.srli and c.srai
Nico Weber [Tue, 26 Jul 2022 17:30:49 +0000 (13:30 -0400)]
[gn build] Port
8348c4095600
Jon Chesterfield [Tue, 26 Jul 2022 17:04:40 +0000 (18:04 +0100)]
[amdgpu][nfc] Skip operations on padding fields in LDS struct
Sam Estep [Tue, 26 Jul 2022 17:30:09 +0000 (17:30 +0000)]
Revert "[clang][dataflow] Analyze calls to in-TU functions"
This reverts commit
fa2b83d07ecab3b24b4c5ee2e7dc4b6bbc895317.
Sam Estep [Tue, 26 Jul 2022 17:26:58 +0000 (17:26 +0000)]
[clang][dataflow] Analyze calls to in-TU functions
Depends On
D130305
This patch adds initial support for context-sensitive analysis of simple functions whose definition is available in the translation unit, guarded by the `ContextSensitive` flag in the new `TransferOptions` struct. When this option is true, the `VisitCallExpr` case in the builtin transfer function has a fallthrough case which checks for a direct callee with a body. In that case, it constructs a CFG from that callee body, uses the new `pushCall` method on the `Environment` to make an environment to analyze the callee, and then calls `runDataflowAnalysis` with a `NoopAnalysis` (disabling context-sensitive analysis on that sub-analysis, to avoid problems with recursion). After the sub-analysis completes, the `Environment` from its exit block is simply assigned back to the environment at the callsite.
The `pushCall` method (which currently only supports non-method functions with some restrictions) first calls `initGlobalVars`, then maps the `SourceLocation`s for all the parameters to the existing source locations for the corresponding arguments from the callsite.
This patch adds a few tests to check that this context-sensitive analysis works on simple functions. More sophisticated functionality will be added later; the most important next step is to explicitly model context in some fields of the `DataflowAnalysisContext` class, as mentioned in a `TODO` comment in the `pushCall` implementation.
Reviewed By: ymandel, xazax.hun
Differential Revision: https://reviews.llvm.org/
D130306
Fangrui Song [Tue, 26 Jul 2022 17:16:49 +0000 (10:16 -0700)]
[MachineFunctionPass] Support -print-changed and -print-changed=quiet
-print-changed for new pass manager is handy beside -print-after-all.
Port it to MachineFunctionPass.
Note: lib/Passes/StandardInstrumentations.cpp implements a number of
misc features. If we want to use them for codegen, we may need to lift
some functionality to LLVMIR.
Reviewed By: aeubanks, jamieschmeiser
Differential Revision: https://reviews.llvm.org/
D130434