Petr Hosek [Sat, 9 Jul 2022 17:00:01 +0000 (17:00 +0000)]
[Fuchsia] Remove the test cflags to explicitly set the unwinder
These are no longer needed and cause issue when cross-compiling.
David Blaikie [Sat, 9 Jul 2022 17:04:01 +0000 (17:04 +0000)]
Fix -Warray-parameter warning
Remove the bound in the definition, since it's not guaranteed/could
provide a false sense of security (I'd be inclined to go further and
change this to a pointer parameter, since that's what it really is - but
figured I'd preserve some of the author's intent here)
Lang Hames [Sat, 9 Jul 2022 16:12:19 +0000 (09:12 -0700)]
Reapply
51c705fbe5d, "[JITLink] Include LinkGraph name in...", with fixes.
Original commit reverted in
976de7130b338aa0d0e63255826a79347635c107 due to test
failures. This commit includes fixes for the tests.
Paul Osmialowski [Sat, 9 Jul 2022 15:58:18 +0000 (11:58 -0400)]
[SimplifyLibCalls] refactor pow(x, n) expansion where n is a constant integer value
Since the backend's codegen is capable to expand powi into fmul's, it
is not needed anymore to do so in the ::optimizePow() function of
SimplifyLibCalls.cpp. What is sufficient is to always turn pow(x, n)
into powi(x, n) for the cases where n is a constant integer value.
Dropping the current expansion code allowed relaxation of the folding
conditions and now this can also happen at optimization levels below
Ofast.
The added CodeGen/AArch64/powi.ll test case ensures that powi is
actually expanded into fmul's, confirming that this refactor did not
cause any performance degradation.
Following an idea proposed by David Sherwood <david.sherwood@arm.com>.
Differential Revision: https://reviews.llvm.org/D128591
Lang Hames [Sat, 9 Jul 2022 15:30:04 +0000 (08:30 -0700)]
Revert "[JITLink] Include LinkGraph name in debugging output."
Revert
51c705fbe5d8cc85868fc0f35e9b86d7ec301ee5 while I investigate some
builder failures.
Joseph Huber [Thu, 7 Jul 2022 15:28:32 +0000 (11:28 -0400)]
[LinkerWrapper] Fix errors not exiting inside of the LTO pipeline
The LTO pipeline handles its errors using the diagnostics handler
callback function. We were not checking the results of these errors and
not properly returning an error code in the linker wrapper when errors
occured inside of the LTO pipeline. This patch adds a simple boolean
flag to indicate if the LTO backend failed to any reason and quit.
Reviewed By: ye-luo
Differential Revision: https://reviews.llvm.org/D129423
Corentin Jabot [Sat, 9 Jul 2022 15:18:35 +0000 (17:18 +0200)]
Revert "[Clang] Add a warning on invalid UTF-8 in comments."
It is probable thart this change crashes on the powerpc bots.
This reverts commit
355532a1499aa9b13a89fb5b5caaba2344d57cd7.
Lang Hames [Sat, 9 Jul 2022 01:55:43 +0000 (18:55 -0700)]
[JITLink][AArch64] Rename PointerToGOT and fix typo.
PointerToGOT lowering was accidentally changed from Delta32 to Delta64 in
db3722580335c. This patch moves it back to Delta32 and renames the generic
aarch64 edge to Delta32ToGOT to avoid the ambiguity.
No test case yet -- I haven't figured out how to write a succinct test case
(this typically appears in CIEs in eh-frames).
Lang Hames [Sat, 9 Jul 2022 01:36:29 +0000 (18:36 -0700)]
[JITLink] Include LinkGraph name in debugging output.
Makes it easier to identify the graph being fixed up at a glance.
Iain Sandoe [Sun, 3 Jul 2022 13:27:10 +0000 (14:27 +0100)]
[C++20][Modules] Update handling of implicit inlines [P1779R3]
This provides updates to
[class.mfct]:
Pre C++20 [class.mfct]p2:
A member function may be defined (8.4) in its class definition, in
which case it is an inline member function (7.1.2)
Post C++20 [class.mfct]p1:
If a member function is attached to the global module and is defined
in its class definition, it is inline.
and
[class.friend]:
Pre-C++20 [class.friend]p5
A function can be defined in a friend declaration of a
class . . . . Such a function is implicitly inline.
Post C++20 [class.friend]p7
Such a function is implicitly an inline function if it is attached
to the global module.
We add the output of implicit-inline to the TextNodeDumper, and amend
a couple of existing tests to account for this, plus add tests for the
cases covered above.
Differential Revision: https://reviews.llvm.org/D129045
Danny Mösch [Sat, 9 Jul 2022 13:45:19 +0000 (15:45 +0200)]
[clang-tidy] Sort release notes entries alphabetically by check name
Danny Mösch [Sat, 9 Jul 2022 12:38:41 +0000 (14:38 +0200)]
[clang-tidy] Initialize boolean variables with `false` in cppcoreguidelines-init-variables' fix-it
In case of a variable with a built-in boolean type, `false` is a better fit to default-initialize it.
Reviewed By: njames93
Differential Revision: https://reviews.llvm.org/D129420
Iain Sandoe [Sat, 9 Jul 2022 10:18:49 +0000 (11:18 +0100)]
[C++20][Modules] Fix two tests for CTORs that return pointers [NFC].
The test are to check that we call the correctly mangled CTORs, so that
the return values from them are irrelevant. I forgot that some targets
return a pointer, apologies for the breakage.
Corentin Jabot [Fri, 17 Jun 2022 14:23:41 +0000 (16:23 +0200)]
[Clang] Add a warning on invalid UTF-8 in comments.
Introduce an off-by default `-Winvalid-utf8` warning
that detects invalid UTF-8 code units sequences in comments.
Invalid UTF-8 in other places is already diagnosed,
as that cannot appear in identifiers and other grammar constructs.
The warning is off by default as its likely to be somewhat disruptive
otherwise.
This warning allows clang to conform to the yet-to be approved WG21
"P2295R5 Support for UTF-8 as a portable source file encoding"
paper.
Reviewed By: aaron.ballman, #clang-language-wg
Differential Revision: https://reviews.llvm.org/D128059
Petr Hosek [Sat, 9 Jul 2022 08:59:58 +0000 (08:59 +0000)]
[CMake] Set the common link flags for memprof tests
This was missed in
ba007f20bb4acf95262f49ab527ce35c4a1f5a19 by mistake.
Iain Sandoe [Sun, 15 May 2022 13:47:54 +0000 (14:47 +0100)]
[C++20][Modules] Build module static initializers per P1874R1.
Currently we only implement this for the Itanium ABI since the correct
mangling for the initializers in other ABIs is not yet known.
Intended result:
For a module interface [which includes partition interface and implementation
units] (instead of the generic CXX initializer) we emit a module init that:
- wraps the contained initializations in a control variable to ensure that
the inits only happen once, even if a module is imported many times by
imports of the main unit.
- calls module initializers for imported modules first. Note that the
order of module import is not significant, and therefore neither is the
order of imported module initializers.
- We then call initializers for the Global Module Fragment (if present)
- We then call initializers for the current module.
- We then call initializers for the Private Module Fragment (if present)
For a module implementation unit, or a non-module TU that imports at least one
module we emit a regular CXX init that:
- Calls the initializers for any imported modules first.
- Then proceeds as normal with remaining inits.
For all module unit kinds we include a global constructor entry, this allows
for the (in most cases unusual) possibility that a module object could be
included in a final binary without a specific call to its initializer.
Implementation:
- We provide the module pointer in the AST Context so that CodeGen can act
on it and its sub-modules.
- We need to account for module build lines like this:
` clang -cc1 -std=c++20 Foo.pcm -emit-obj -o Foo.o` or
` clang -cc1 -std=c++20 -xc++-module Foo.cpp -emit-obj -o Foo.o`
- in order to do this, we add to ParseAST to set the module pointer in
the ASTContext, once we establish that this is a module build and we
know the module pointer. To be able to do this, we make the query for
current module public in Sema.
- In CodeGen, we determine if the current build requires a CXX20-style module
init and, if so, we defer any module initializers during the "Eagerly
Emitted" phase.
- We then walk the module initializers at the end of the TU but before
emitting deferred inits (which adds any hidden and static ones, fixing
https://github.com/llvm/llvm-project/issues/51873 ).
- We then proceed to emit the deferred inits and continue to emit the CXX
init function.
Differential Revision: https://reviews.llvm.org/D126189
Nathan James [Sat, 9 Jul 2022 07:28:07 +0000 (08:28 +0100)]
[clang] Add a fixit for warn-self-assign if LHS is a field with the same name as parameter on RHS
Add a fix-it for the common case of setters/constructors using parameters with the same name as fields
```lang=c++
struct A{
int X;
A(int X) { /*this->*/X = X; }
void setX(int X) { /*this->*/X = X;
};
```
Reviewed By: aaron.ballman
Differential Revision: https://reviews.llvm.org/D129202
Matthias Springer [Sat, 9 Jul 2022 07:15:36 +0000 (09:15 +0200)]
[mlir][bufferization] Do not canonicalize to_tensor(to_memref(x))
This is a partial revert of D128615.
to_memref(to_tensor(x)) always be folded to x. But to_tensor(to_memref(x)) cannot be folded in the general case because writes to the intermediary memref may go unnoticed.
Differential Revision: https://reviews.llvm.org/D129354
serge-sans-paille [Sat, 9 Jul 2022 07:05:22 +0000 (09:05 +0200)]
[AMDGPU][NFC] Harmonize decl&def of R600TargetLowering::OptimizeSwizzle
The freshly baked -Warray-parameter warning discovered an inconsistency in
argument declaration, use the stricter one.
This fixes build issues like https://lab.llvm.org/buildbot#builders/18/builds/5305
owenca [Fri, 8 Jul 2022 06:34:44 +0000 (23:34 -0700)]
[clang-format] Fix an assertion failure on -lines=0:n
Also fixed the error message for start line > end line and added test cases.
Fixes #56438.
Differential Revision: https://reviews.llvm.org/D129348
Petr Hosek [Fri, 17 Jun 2022 08:11:32 +0000 (08:11 +0000)]
[CMake] Use explicit header path when using in-tree libc++ for tests
This is a follow up to D118200 which applies a similar cleanup to
headers when using in-tree libc++ to avoid accidentally picking up
the system headers.
Differential Revision: https://reviews.llvm.org/D128035
Wenlei He [Sat, 9 Jul 2022 00:17:11 +0000 (17:17 -0700)]
[Inliner] Make recusive inlinee stack size limit tunable
For recursive callers, we want to be conservative when inlining callees with large stack size. We currently have a limit `InlineConstants::TotalAllocaSizeRecursiveCaller`, but that is hard coded.
We found the current limit insufficient to suppress problematic inlining that bloats stack size for deep recursion. This change adds a switch to make the limit tunable as a mitigation.
Differential Revision: https://reviews.llvm.org/D129411
Petr Hosek [Sat, 9 Jul 2022 04:27:16 +0000 (04:27 +0000)]
Revert "[CMake] Use explicit header path when using in-tree libc++ for tests"
This reverts commit
61b410cb8b9af0aa265e730a3070b3154d869803 as this
appears to have broken some sanitizer tests.
Petr Hosek [Fri, 17 Jun 2022 08:11:32 +0000 (08:11 +0000)]
[CMake] Use explicit header path when using in-tree libc++ for tests
This is a follow up to D118200 which applies a similar cleanup to
headers when using in-tree libc++ to avoid accidentally picking up
the system headers.
Differential Revision: https://reviews.llvm.org/D128035
Christian Kandeler [Fri, 8 Jul 2022 08:12:31 +0000 (04:12 -0400)]
[clangd] Support "usedAsMutableReference" in member initializations
That is, mark constructor parameters being used to initialize
non-const reference members.
Reviewed By: nridge
Differential Revision: https://reviews.llvm.org/D128977
Brad Smith [Sat, 9 Jul 2022 01:33:57 +0000 (21:33 -0400)]
[libcxx] Uglify __support/openbsd
Uglify __support/openbsd
Reviewed By: philnik
Differential Revision: https://reviews.llvm.org/D129412
Shilei Tian [Sat, 9 Jul 2022 00:59:37 +0000 (20:59 -0400)]
[NFC][OpenMP][Offloading] Fix compilation warning caused by misuse of `static_cast`
River Riddle [Sat, 9 Jul 2022 00:56:48 +0000 (17:56 -0700)]
[mlir:LSP] Drop potentialy annoying completion commit characters
These can result in accidentally accepting a completion when it isn't intended.
River Riddle [Sat, 9 Jul 2022 00:55:30 +0000 (17:55 -0700)]
[mlir:LSP] Add code completions for builtin signed/unsigned integers
River Riddle [Thu, 7 Jul 2022 05:54:36 +0000 (22:54 -0700)]
[mlir:LSP] Add support for code completing attributes and types
This required changing a bit of how attributes/types are parsed. A new
`KeywordSwitch` class was added to AsmParser that provides a StringSwitch
like API for parsing keywords with a set of potential matches. It intends to
both provide a cleaner API, and enable injection for code completion. This
required changing the API of `generated(Attr|Type)Parser` to handle the
parsing of the keyword, instead of having the user do it. Most upstream
dialects use the autogenerated handling and didn't require a direct update.
Differential Revision: https://reviews.llvm.org/D129267
River Riddle [Wed, 6 Jul 2022 09:49:58 +0000 (02:49 -0700)]
[mlir:LSP] Add support for keyword code completions
This commit adds code completion results to the MLIR LSP when
parsing keywords. Keyword support is currently limited to the
case where the expected keyword is provided, but a followup will
work on expanding the set of keyword cases we handle (e.g. to
allow capturing attribute/type mnemonics).
Differential Revision: https://reviews.llvm.org/D129184
Michael Jones [Wed, 6 Jul 2022 23:53:34 +0000 (16:53 -0700)]
[libc] add printf hexadecimal float conversion
This patch adds the %a/A conversions to printf, as well as the compiler
flag to disable floating point handling entirely. This will allow our
printf implementation to display every type of argument allowed by
printf, although some formats are still incomplete.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D129240
Douglas Yung [Fri, 8 Jul 2022 22:47:03 +0000 (15:47 -0700)]
Replace hard coded number with regex so the test passes on downstream projects that may define additional opcodes.
Michael Jones [Fri, 8 Jul 2022 18:35:29 +0000 (11:35 -0700)]
[libc] add dependencies to generic sqrt tests
This adds dependencies on the corresponding sqrt function to each
generic sqrt test. This is so that on platforms that don't support the
math functions, the tests are not run.
Reviewed By: lntue
Differential Revision: https://reviews.llvm.org/D129388
Hubert Tong [Fri, 8 Jul 2022 22:30:48 +0000 (18:30 -0400)]
[AIX][clang/test] Set/propagate AIXTHREAD_STK for AIX
Some tests perform deep recursion, which requires a larger pthread stack
size than the relatively low default of 192 KiB for 64-bit processes on
AIX. The `AIXTHREAD_STK` environment variable provides a non-intrusive
way to request a larger pthread stack size for the tests. The required
pthread stack size depends on the build configuration.
A 4 MiB default is generous compared to the 512 KiB of macOS; however,
it is known that some compilers on AIX produce code that uses
comparatively more stack space.
This patch expands the solution from D65688 to apply to all Clang LIT
tests.
This also reverts commit
c3c75d805c2174388417080f762230961b3433d6,
"[clang][test] Mark test arm-float-abi-lto.c unsupported on AIX".
The problem was caused by the test running up against the per-thread
stack limit on AIX. This is resolved by having the tests run with
`AIXTHREAD_STK` set for 4 MiB.
Reviewed By: xingxue
Differential Revision: https://reviews.llvm.org/D129165
Vladislav Khmelevsky [Thu, 7 Jul 2022 11:48:47 +0000 (14:48 +0300)]
[BOLT][Runtime] Fix memset definition
Differential Revision: https://reviews.llvm.org/D129321
Jason Molenda [Fri, 8 Jul 2022 21:01:15 +0000 (14:01 -0700)]
jGetLoadedDynamicLibrariesInfos can inspect machos not yet loaded
jGetLoadedDynamicLibrariesInfos normally checks with dyld to find
the list of binaries loaded in the inferior, and getting the filepath,
before trying to parse the Mach-O binary in inferior memory.
This allows for debugserver to parse a Mach-O binary present in memory,
but not yet registered with dyld. This patch also adds some simple
sanity checks that we're reading a Mach-O header before we begin
stepping through load commands, because we won't have the sanity check
of consulting dyld for the list of loaded binaries before parsing.
Also adds a testcase.
Differential Revision: https://reviews.llvm.org/D128956
rdar://
95737734
Petr Hosek [Thu, 2 Jun 2022 21:52:56 +0000 (21:52 +0000)]
[CMake] Option to select C++ library for runtimes that use it
We currently have an option to select C++ ABI and C++ library for tests
but there are runtimes that use C++ library, specifically ORC and XRay,
which aren't covered by existing options. This change introduces a new
option to control the use of C++ libray for these runtimes.
Ideally, this option should become the default way to select C++ library
for all of compiler-rt replacing the existing options (the C++ ABI
option could remain as a hidden internal option).
Differential Revision: https://reviews.llvm.org/D128036
David Blaikie [Fri, 8 Jul 2022 21:37:24 +0000 (21:37 +0000)]
Remove unnecessary braces
Pedro Alves [Fri, 8 Jul 2022 21:15:52 +0000 (21:15 +0000)]
llvm-dwarfdump: Don't crash if DW_AT_{decl,call}_{file,line} uses signed form
The DWARF spec says:
Any debugging information entry representing the declaration of an object,
module, subprogram or type may have DW_AT_decl_file, DW_AT_decl_line and
DW_AT_decl_column attributes, each of whose value is an unsigned integer
^^^^^^^^
constant.
If however, a producer happens to emit DW_AT_decl_file /
DW_AT_decl_line using a signed integer form, llvm-dwarfdump crashes,
like so:
(... snip ...)
0x000000b4: DW_TAG_structure_type
DW_AT_name ("test_struct")
DW_AT_byte_size (136)
DW_AT_decl_file (llvm-dwarfdump: (... snip ...)/llvm/include/llvm/ADT/Optional.h:197: T& llvm::optional_detail::OptionalStorage<T, true>::getValue() &
[with T = long unsigned int]: Assertion `hasVal' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: /opt/rocm/llvm/bin/llvm-dwarfdump ./testsuite/outputs/gdb.rocm/lane-pc-vega20/lane-pc-vega20-kernel.so
#0 0x000055cc8e78315f PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
#1 0x000055cc8e780d3d SignalHandler(int) Signals.cpp:0:0
#2 0x00007f8f2cae8420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#3 0x00007f8f2c58d00b raise /build/glibc-SzIz7B/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
#4 0x00007f8f2c56c859 abort /build/glibc-SzIz7B/glibc-2.31/stdlib/abort.c:81:7
#5 0x00007f8f2c56c729 get_sysdep_segment_value /build/glibc-SzIz7B/glibc-2.31/intl/loadmsgcat.c:509:8
#6 0x00007f8f2c56c729 _nl_load_domain /build/glibc-SzIz7B/glibc-2.31/intl/loadmsgcat.c:970:34
#7 0x00007f8f2c57dfd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
#8 0x000055cc8e58ceb9 llvm::DWARFDie::dump(llvm::raw_ostream&, unsigned int, llvm::DIDumpOptions) const (/opt/rocm/llvm/bin/llvm-dwarfdump+0x2e0eb9)
#9 0x000055cc8e58bec3 llvm::DWARFDie::dump(llvm::raw_ostream&, unsigned int, llvm::DIDumpOptions) const (/opt/rocm/llvm/bin/llvm-dwarfdump+0x2dfec3)
#10 0x000055cc8e5b28a3 llvm::DWARFCompileUnit::dump(llvm::raw_ostream&, llvm::DIDumpOptions) (.part.21) DWARFCompileUnit.cpp:0:0
Likewise with DW_AT_call_file / DW_AT_call_line.
The problem is that the code in llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
dumping these attributes assumes that
FormValue.getAsUnsignedConstant() returns an armed optional. If in
debug mode, we get an assertion line the above. If in release mode,
and asserts are compiled out, then we proceed as if the optional had a
value, running into undefined behavior, printing whatever random
value.
Fix this by checking whether the optional returned by
FormValue.getAsUnsignedConstant() has a value, like done in other
places.
In addition, DWARFVerifier.cpp is validating DW_AT_call_file /
DW_AT_decl_file, but not AT_call_line / DW_AT_decl_line. This commit
fixes that too.
The llvm-dwarfdump/X86/verify_file_encoding.yaml testcase is extended
to cover these cases. Current llvm-dwarfdump crashes running the
newly-extended test.
"make check-llvm-tools-llvm-dwarfdump" shows no regressions, on x86-64
GNU/Linux.
Reviewed By: dblaikie
Differential Revision: https://reviews.llvm.org/D129392
Julian Lettner [Fri, 1 Jul 2022 18:05:40 +0000 (11:05 -0700)]
[Sanitizer][Darwin] Cleanup MaybeReexec() function and usage
While investigating another issue, I noticed that `MaybeReexec()` never
actually "re-executes via `execv()`" anymore. `DyldNeedsEnvVariable()`
only returned true on macOS 10.10 and below.
Usually, I try to avoid "unnecessary" cleanups (it's hard to be certain
that there truly is no fallout), but I decided to do this one because:
* I initially tricked myself into thinking that `MaybeReexec()` was
relevant to my original investigation (instead of being dead code).
* The deleted code itself is quite complicated.
* Over time a few other things were mushed into `MaybeReexec()`:
initializing `MonotonicNanoTime()`, verifying interceptors are
working, and stripping the `DYLD_INSERT_LIBRARIES` env var to avoid
problems when forking.
* This platform-specific thing leaked into `sanitizer_common.h`.
* The `ReexecDisabled()` config nob relies on the "strong overrides weak
pattern", which is now problematic and can be completely removed.
* `ReexecDisabled()` actually hid another issue with interceptors not
working in unit tests. I added an explicit `verify_interceptors`
(defaults to `true`) option instead.
Differential Revision: https://reviews.llvm.org/D129157
Joseph Huber [Fri, 8 Jul 2022 19:59:10 +0000 (15:59 -0400)]
[Clang] Fix the wrong features being derivec in the offload packager
The offload packager embeds the features in the offloading binary when
performing LTO. This had an incorrect interaction with the
`--cuda-feature` option because we weren't deriving the features from
the CUDA toolchain arguments when it was being specified. This patch
fixes this so the features are correctly overrideen when using this
argument.
However, this brings up a question of how best to handle conflicting
target features. The user could compile many libraries with different
features, in this case we do not know which one to pick. This was not
previously a problem when we simply passed the features in from the CUDA
installation at link-link because we just defaulted to whatever was
current on the system.
Reviewed By: ye-luo
Differential Revision: https://reviews.llvm.org/D129393
Joseph Huber [Fri, 8 Jul 2022 17:33:46 +0000 (13:33 -0400)]
[LinkerWrapper] Fix use of string savers and correctly pass bitcode libraries
This patch removes some uses of string savers that are no-longer needed.
We also create a new string saver when linking bitcode files. It seems
that occasionally the symbol string references can go out of scope when
they are added to the LTO input so we need to save these names that are
used for symbol resolution. Additionally, a previous patch added new
logic for handling bitcode libraries, but failed to actually add them to
the input. This bug has been fixed.
Fixes #56445
Reviewed By: ye-luo
Differential Revision: https://reviews.llvm.org/D129383
Martin Storsjö [Wed, 25 May 2022 12:07:18 +0000 (15:07 +0300)]
[clang] [Serialization] Fix swapped PPOpts/ExistingPPOpts parameters. NFC.
The two first parameters of checkPreprocessorOptions are "PPOpts, ExistingPPOpts".
All other callers of the function pass them consistently.
This avoids confusion when working on the code.
Differential Revision: https://reviews.llvm.org/D129277
Fangrui Song [Fri, 8 Jul 2022 21:04:19 +0000 (14:04 -0700)]
[ELF] Refactor ELFCOMPRESS_ZLIB handling and improve diagnostics
And add some tests.
LLVM GN Syncbot [Fri, 8 Jul 2022 20:59:26 +0000 (20:59 +0000)]
[gn build] Port
c945bd0da652
Louis Dionne [Thu, 30 Jun 2022 15:24:43 +0000 (11:24 -0400)]
[libc++] Always build c++experimental.a
This is the first part of a plan to ship experimental features
by default while guarding them behind a compiler flag to avoid
users accidentally depending on them. Subsequent patches will
also encompass incomplete features (such as <format> and <ranges>)
in that categorization. Basically, the idea is that we always
build and ship the c++experimental library, however users can't
use what's in it unless they pass the `-funstable` flag to Clang.
Note that this patch intentionally does not start guarding
existing <experimental/FOO> content behind the flag, because
that would merely break users that might be relying on such
content being in the headers unconditionally. Instead, we
should start guarding new TSes behind the flag, and get rid
of the existing TSes we have by shipping their Standard
counterpart.
Also, this patch must jump through a few hoops like defining
_LIBCPP_ENABLE_EXPERIMENTAL because we still support compilers
that do not implement -funstable yet.
Differential Revision: https://reviews.llvm.org/D128927
Konstantin Varlamov [Fri, 8 Jul 2022 20:46:27 +0000 (13:46 -0700)]
[libc++][ranges] Implement modifying heap algorithms:
- `ranges::make_heap`;
- `ranges::push_heap`;
- `ranges::pop_heap`;
- `ranges::sort_heap`.
Differential Revision: https://reviews.llvm.org/D128115
Leonard Chan [Fri, 8 Jul 2022 20:48:05 +0000 (13:48 -0700)]
Revert "[llvm] cmake config groundwork to have ZSTD in LLVM"
This reverts commit
f07caf20b9d35e45501c9d5d903fa182b3bdb95a which seems to break upstream https://lab.llvm.org/buildbot/#/builders/109/builds/42253.
Leonard Chan [Fri, 8 Jul 2022 20:46:44 +0000 (13:46 -0700)]
Revert "[llvm] cmake config groundwork to have ZSTD in LLVM"
This reverts commit
adf1ffe95854a245cbc48bbaea55f60b003d5f76 and
f07caf20b9d35e45501c9d5d903fa182b3bdb95a
which seem to break upstream https://lab.llvm.org/buildbot/#/builders/109/builds/42253.
serge-sans-paille [Thu, 23 Jun 2022 14:20:09 +0000 (16:20 +0200)]
[clang] Introduce -Warray-parameter
This warning exist in GCC[0] and warns about re-declarations of functions
involving arguments of array or pointer types of inconsistent kinds or forms.
This is not the exact same implementation as GCC's : there's no warning level
and that flag has no effect on -Warray-bounds.
[0] https://gcc.gnu.org/onlinedocs/gcc-12.1.0/gcc/Warning-Options.html#index-Wno-array-parameter
Differential Revision: https://reviews.llvm.org/D128449
Cole Kissane [Fri, 8 Jul 2022 19:36:27 +0000 (12:36 -0700)]
[llvm] cmake config groundwork to have ZSTD in LLVM
- added `FindZSTD.cmake`
- added a CMake option `LLVM_ENABLE_ZSTD` with behavior mirroring that of `LLVM_ENABLE_ZLIB`
- likewise added have_zstd to compiler-rt/test/lit.common.cfg.py, clang-tools-extra/clangd/test/lit.cfg.py, and several lit.site.cfg.py.in files mirroring have_zlib behavior
Reviewed By: leonardchan, MaskRay
Differential Revision: https://reviews.llvm.org/D128465
Cole Kissane [Fri, 8 Jul 2022 18:46:51 +0000 (11:46 -0700)]
[llvm] cmake config groundwork to have ZSTD in LLVM
- added `FindZSTD.cmake`
- added a CMake option `LLVM_ENABLE_ZSTD` with behavior mirroring that of `LLVM_ENABLE_ZLIB`
- likewise added have_zstd to compiler-rt/test/lit.common.cfg.py, clang-tools-extra/clangd/test/lit.cfg.py, and several lit.site.cfg.py.in files mirroring have_zlib behavior
Reviewed By: leonardchan, MaskRay
Differential Revision: https://reviews.llvm.org/D128465
Joseph Huber [Thu, 7 Jul 2022 18:46:49 +0000 (14:46 -0400)]
[Libomptarget][NFC] Move legacy functions to a separate file
This patch moves the old legacy interfaces into `libomptarget` to a
separate file. These do not need to be included anywhere and are simply
provided for backwards compatibility with the ABI. This cleans up the
interface greatly.
Depends on D128817
Reviewed By: JonChesterfield
Differential Revision: https://reviews.llvm.org/D128818
Joseph Huber [Mon, 27 Jun 2022 16:26:58 +0000 (12:26 -0400)]
[Libomptarget] Use new tripcount argument in the runtime.
The previous patch added an argument to the `__tgt_target_kernel`
runtime function which includes the tripcount used for the loop clause.
This was originally passed in via the `__kmpc_push_target_tripcount`
function. Now we move this logic to the kernel launch itself and remove
the need for the push function.
Depends on D128816
Reviewed By: jdoerfert
Differential Revision: https://reviews.llvm.org/D128817
Joseph Huber [Mon, 27 Jun 2022 16:23:50 +0000 (12:23 -0400)]
[OpenMP] Add loop tripcount argument to kernel launch and remove push function
Previously we added the `push_target_tripcount` function to send the
loop tripcount to the device runtime so we knew how to configure the
teams / threads for execute the loop for a teams distribute construct.
This was implemented as a separate function mostly to avoid changing the
interface for backwards compatbility. Now that we've changed it anyway
and the new interface can take an arbitrary number of arguments via the
struct without changing the ABI, we can move this to the new interface.
This will simplify the runtime by removing unnecessary state between
calls.
Depends on D128550
Reviewed By: jdoerfert
Differential Revision: https://reviews.llvm.org/D128816
Joseph Huber [Fri, 24 Jun 2022 13:13:53 +0000 (09:13 -0400)]
[OpenMP] Change OpenMP code generation for target region entries
This patch changes the code we generate to enter a target region on the
device. This is in-line with the new definition in the runtime that was
added previously. Additionally we implement this in the OpenMPIRBuilder
so that this code can be shared with Flang in the future.
Reviewed By: ABataev
Differential Revision: https://reviews.llvm.org/D128550
Joseph Huber [Thu, 23 Jun 2022 18:57:59 +0000 (14:57 -0400)]
[Libomptarget] Implement a unified kernel entry function
This patch implements a unified kernel entry function that will be
targeted from both teams and non-teams clauses. We introduce a new
interface and make the old functions call in using the new one. A
following patch will include the necessary changes to Clang to call
these new functions instead.
Reviewed By: jdoerfert
Differential Revision: https://reviews.llvm.org/D128549
LLVM GN Syncbot [Fri, 8 Jul 2022 18:34:42 +0000 (18:34 +0000)]
[gn build] Port
23c7328bad92
Jacques Pienaar [Fri, 8 Jul 2022 18:31:12 +0000 (11:31 -0700)]
[mlir] Add method to populate default attributes
Previously default attributes were only usable by way of the ODS generated
accessors, but this was undesirable as
1. The ODS getters could construct Attribute each get request;
2. For non-C++ uses this would require either duplicating some of tee default
attribute generating or generating additional bindings to generate methods;
3. Accessing op.getAttr("foo") and op.getFoo() would return different results;
Generate method to populate default attributes that can be used to address
these.
This merely adds this facility but does not employ by default on any path.
Differential Revision: https://reviews.llvm.org/D128962
Joseph Huber [Fri, 8 Jul 2022 18:29:04 +0000 (14:29 -0400)]
[Clang][Docs] Update the clang-linker-wrapper documentation.
Joseph Huber [Fri, 8 Jul 2022 18:15:18 +0000 (14:15 -0400)]
[llvm-objdump] Fix alignment issues when dumping offloading sections
Summary:
The `.llvm.offloading` section should always be aligned by `8`. However,
we may want to show the offloading data stored in a static library. In
this case, even though the section's alignment is correct, the offset
inside the archive will result in the memory buffer being misaligned. TO
combat this we simply check if the buffer does not have the proper
alignment and copies it to a new buffer if not. This copy should have
the proper alignment.
zoecarver [Fri, 8 Jul 2022 17:42:29 +0000 (10:42 -0700)]
[objcxx] Fix `std::addressof` for `id`.
Differential Revision: https://reviews.llvm.org/D129384
Konstantin Varlamov [Fri, 8 Jul 2022 03:35:51 +0000 (20:35 -0700)]
[libc++][ranges] Implement `ranges::nth_element`.
Differential Revision: https://reviews.llvm.org/D128149
Cole Kissane [Fri, 8 Jul 2022 18:24:45 +0000 (11:24 -0700)]
[llvm] Remove unused and redundant crc32 funcction from llvm::compression::zlib namespace
* Remove crc32 from zlib compression namespace, people should use the `llvm::crc32` instead.
Reviewed By: MaskRay, leonardchan
Differential Revision: https://reviews.llvm.org/D128754
Daniil Fukalov [Fri, 8 Jul 2022 18:19:10 +0000 (21:19 +0300)]
[NFC] Fix cvt_f32_ubyte.ll test.
Remove (unintended) infinite loop in the test.
Reviewed By: vangthao
Differential Revision: https://reviews.llvm.org/D129328
Cole Kissane [Fri, 8 Jul 2022 18:19:05 +0000 (11:19 -0700)]
[NFC] Refactor llvm::zlib namespace
* Refactor compression namespaces across the project, making way for a possible
introduction of alternatives to zlib compression.
Changes are as follows:
* Relocate the `llvm::zlib` namespace to `llvm::compression::zlib`.
Reviewed By: MaskRay, leonardchan, phosek
Differential Revision: https://reviews.llvm.org/D128953
tlattner [Fri, 1 Jul 2022 21:07:48 +0000 (14:07 -0700)]
Update references to Discourse instead of the mailing lists.
Update the references to the old Mailman mailing lists to point to Discourse forums.
Reviewed By: aaron.ballman
Differential Revision: https://reviews.llvm.org/D128766
Nicolai Hähnle [Mon, 4 Jul 2022 11:35:26 +0000 (13:35 +0200)]
Fix test: LLVMGetBitcodeModule takes ownership of memory buffer
Clarify this behavior in the C interface header file and fix a related
bug in a test.
Differential Revision: https://reviews.llvm.org/D129113
Iain Sandoe [Mon, 13 Jun 2022 09:15:50 +0000 (10:15 +0100)]
[C++20][Modules] Allow for redeclarations in partitions.
The existing provision is not sufficient, it did not allow for the cases
where an implementation partition includes the primary module interface,
or for the case that an exported interface partition is contains a decl
that is then implemented in a regular implementation unit.
It is somewhat unfortunate that we have to compare top level module names
to achieve this, since built modules are not necessarily available.
TODO: It might be useful to cache a hash of the primary module name if
this test proves to be a significant load.
Differential Revision: https://reviews.llvm.org/D127624
Ryan Thomas Lynch (@emosy) [Fri, 8 Jul 2022 17:58:20 +0000 (10:58 -0700)]
[vscode-mlir] add tablegen <> bracket colorization
Add support for colorizing angle brackets "<>" in TableGen files.
Reviewed By: rriddle
Differential Revision: https://reviews.llvm.org/D128229
Jacques Pienaar [Fri, 8 Jul 2022 17:57:04 +0000 (10:57 -0700)]
[mlir][tosa] Enable decomposing Conv2D also where 1 input dim is dynamic
Restricted to just 1 dynamic input dim as that worked all the way through to
codegen.
Differential Revision: https://reviews.llvm.org/D129334
Philip Reames [Fri, 8 Jul 2022 17:19:49 +0000 (10:19 -0700)]
[RISCV] Switch to using get.active.lane.mask when tail folding
The motivation here is to a) bring us closer into alignment with AArch64 under the assumption that codepath is better tested, and b) simplify pattern matching in an upcoming change.
The immediate impact is a significant IR reduction but a fairly minimal change in the generated assembly. Due to a difference in expansion behavior we get a saturating add vs an unsaturating one for the old code, but that's about it. This difference comes down to different handling of overflow, which doesn't seem to be possible here anyways, so the assembly codegen is arguably a minor regression. I don't expect that to matter in practice.
Differential Revision: https://reviews.llvm.org/D129221
Craig Topper [Fri, 8 Jul 2022 17:14:27 +0000 (10:14 -0700)]
[RISCV] Mark fminnum_vl and fmaxnum_vl as commutable.
Craig Topper [Fri, 8 Jul 2022 17:11:44 +0000 (10:11 -0700)]
[RISCV] Add commuted fixed vector vfmax.vf and vfmin.vf tests. NFC
The ISD opcodes aren't marked commutable so we don't match these
properly.
Philip Reames [Fri, 8 Jul 2022 17:09:49 +0000 (10:09 -0700)]
[RISCV] Mark vsadd(u)_vl as commutable
This allows fixed length vectors involving splats on the LHS to commute into the _vx form of the instruction. Oddly, the generic canonicalization rules appear to catch the scalable vector cases. I haven't fully dug in to understand why, but I suspect it's because of a difference in how we represent splats (splat_vector vs build_vector).
Differential Revision: https://reviews.llvm.org/D129302
Alexander Yermolovich [Thu, 7 Jul 2022 18:41:51 +0000 (11:41 -0700)]
[DWARF] Add linkagename to hash
Originally encountered with RUST, but also there are cases with distributed LTO
where debug info dwo units contain structurally the same debug information, with
difference in DW_AT_linkage_name. This causes collision on DWO ID.
Differential Revision: https://reviews.llvm.org/D129317
Nandor Licker [Fri, 8 Jul 2022 05:57:37 +0000 (08:57 +0300)]
[mlir] Fixed double-free bug in SymbolUserMap
`SymbolUserMap` relied on `try_emplace` and `std::move` to relocate an entry to another key. However, if this triggered the resizing of the `DenseMap`, the value was destroyed before it could be moved to the new storage location, leading to a dangling `users` reference to be inserted into the map. On destruction, since a new entry was created from one that was already freed, a double-free error occurred.
Fixed issue by re-fetching the iterator after the mutation of the container.
Differential Revision: https://reviews.llvm.org/D129345
Craig Topper [Fri, 8 Jul 2022 16:54:48 +0000 (09:54 -0700)]
[RISCV] Mark (s/u)min_vl and (s/u)max_vl as commutable.
Craig Topper [Fri, 8 Jul 2022 16:47:43 +0000 (09:47 -0700)]
[RISCV] Add fixed vector vmin(u).vx and vmax(u).vx tests. NFC
Simon Pilgrim [Fri, 8 Jul 2022 16:59:10 +0000 (17:59 +0100)]
[X86] Regenerate vec_shift6.ll to remove superfluous whitespace. NFC
Arthur Eubanks [Fri, 8 Jul 2022 16:48:41 +0000 (09:48 -0700)]
[gn build] Manually port
d2ead9e3
Slava Zakharin [Fri, 1 Jul 2022 21:22:29 +0000 (14:22 -0700)]
[flang] Changed lowering for allocatable assignment to make array-value-copy correct.
Array-value-copy fails to generate a temporary array for case like this:
subroutine bug(b)
real, allocatable :: b(:)
b = b(2:1:-1)
end subroutine
Since LHS may need to be reallocated, lowering produces the following FIR:
%rhs_load = fir.array_load %b %slice
%lhs_mem = fir.if %b_is_allocated_with_right_shape {
fir.result %b
} else {
%new_storage = fir.allocmem %rhs_shape
fir.result %new_storage
}
%lhs = fir.array_load %lhs_mem
%loop = fir.do_loop {
....
}
fir.array_merge_store %lhs, %loop to %lhs_mem
// deallocate old storage if reallocation occured,
// and update b descriptor if needed.
Since %b in array_load and %lhs_mem in array_merge_store are not the same SSA
values, array-value-copy does not detect the conflict and does not produce
a temporary array. This causes incorrect result in runtime.
The suggested change in lowering is to generate this:
%rhs_load = fir.array_load %b %slice
%lhs_mem = fir.if %b_is_allocated_with_right_shape {
%lhs = fir.array_load %b
%loop = fir.do_loop {
....
}
fir.array_merge_store %lhs, %loop to %b
fir.result %b
} else {
%new_storage = fir.allocmem %rhs_shape
%lhs = fir.array_load %new_storage
%loop = fir.do_loop {
....
}
fir.array_merge_store %lhs, %loop to %new_storage
fir.result %new_storage
}
// deallocate old storage if reallocation occured,
// and update b descriptor if needed.
Note that there are actually 3 branches in FIR, so the assignment loops
are currently produced in three copies, which is a code-size issue.
It is possible to generate just two branches with two copies of the loops,
but it is not addressed in this change-set.
Differential Revision: https://reviews.llvm.org/D129314
Florian Hahn [Fri, 8 Jul 2022 16:33:17 +0000 (09:33 -0700)]
[VPlan] Move VPWidenSelectRecipe::execute to VPlanRecipes.cpp (NFC).
Depends on D127968.
Reviewed By: Ayal
Differential Revision: https://reviews.llvm.org/D127970
Nikolas Klauser [Fri, 8 Jul 2022 16:17:26 +0000 (18:17 +0200)]
[libc++] Make parameter names consistent and enforce the naming style using readability-identifier-naming
Ensure that parameter names have the style `__lower_case`
Reviewed By: ldionne, #libc
Spies: aheejin, sstefan1, libcxx-commits, miyuki
Differential Revision: https://reviews.llvm.org/D129051
Matt Arsenault [Tue, 12 Apr 2022 16:41:16 +0000 (12:41 -0400)]
AArch64/GlobalISel: Stop using legal s1 values
As far as I can tell treating s1 values as legal makes no sense. There
are no allocatable 1-bit registers. SelectionDAG legalizes the usual
set of boolean operations to 32-bits, and this should do the
same. This avoids some special case handling in the selector of s1
values, and some extra code to look through truncates.
This makes some code worse at -O0, since nothing cleans up the and 1
the artifact combiner inserts. We could probably add some
non-essential combines or teach the artifact combiner to elide
intermediates betweeen boolean uses and defs.
Matt Arsenault [Tue, 12 Apr 2022 13:27:33 +0000 (09:27 -0400)]
GlobalISel: Add buildBoolExtInReg helper
Matt Arsenault [Sat, 9 Apr 2022 18:22:31 +0000 (14:22 -0400)]
GlobalISel: Allow forming atomic/volatile G_SEXTLOAD
Mirror the change to G_ZEXTLOAD.
Matt Arsenault [Sat, 9 Apr 2022 18:06:04 +0000 (14:06 -0400)]
GlobalISel: Allow forming atomic/volatile G_ZEXTLOAD
SelectionDAG has a target hook, getExtendForAtomicOps, which it uses
in the computeKnownBits implementation for ATOMIC_LOAD. This is pretty
ugly (as is having a separate load opcode for atomics), so instead
allow making use of atomic zextload. Enable this for AArch64 since the
DAG path defaults in to the zext behavior.
The tablegen changes are pretty ugly, but partially helps migrate
SelectionDAG from using ISD::ATOMIC_LOAD to regular ISD::LOAD with
atomic memory operands. For now the DAG emitter will emit matchers for
patterns which the DAG will not produce.
I'm still a bit confused by the intent of the isLoad/isStore/isAtomic
bits. The DAG implementation rejects trying to use any of these in
combination. For now I've opted to make the isLoad checks also check
isAtomic, although I think having isLoad and isAtomic set on these
makes most sense.
Joseph Huber [Fri, 8 Jul 2022 15:50:41 +0000 (11:50 -0400)]
[Clang] Fix test failing due to renamed arg
Nikita Popov [Fri, 8 Jul 2022 15:43:55 +0000 (17:43 +0200)]
[ConstantFolding] Guard against unfolded FP binop
Check that the operation actually folded before trying to flush
denormals. A minor variation of the pr33453 test exposed this
with the FP binops marked as undesirable.
Joseph Huber [Fri, 8 Jul 2022 15:37:15 +0000 (11:37 -0400)]
[LinkerWrapper] Fix save-temps and argument name
Summary:
The previous path reworked some handling of temporary files which
exposed some bugs related to capturing local state by reference in the
callback labmda. Squashing this by copying in everything instead. There
was also a problem where the argument name was changed for
`--bitcode-library=` but clang still used `--target-library=`.
Nikita Popov [Fri, 8 Jul 2022 15:19:04 +0000 (17:19 +0200)]
[InstCombine] Avoid ConstantExpr::get() in vector binop fold (NFCI)
Use the ConstantFoldBinaryOpOperands() API instead. This case
would bail out on a non-folded result anyway.
Joseph Huber [Fri, 8 Jul 2022 15:00:14 +0000 (11:00 -0400)]
[LinkerWrapper][NFC] Move error handling to a common function
Summary:
This patch merges all the error handling functions to a single function
call so we don't define the same lambda many times.
Joseph Huber [Thu, 7 Jul 2022 02:58:52 +0000 (22:58 -0400)]
[LinkerWrapper][NFC] Rework command line argument handling in the linker wrapper
Summary:
This patch reworks the command line argument handling in the linker
wrapper from using the LLVM `cl` interface to using the `Option`
interface with TableGen. This has several benefits compared to the old
method.
We use arguments from the linker arguments in the linker
wrapper, such as the libraries and input files, this allows us to
properly parse these. Additionally we can now easily set up aliases to
the linker wrapper arguments and pass them in the linker input directly.
That is, pass an option like `cuda-path=` as `--offload-arg=cuda-path=`
in the linker's inputs. This will allow us to handle offloading
compilation in the linker itself some day. Finally, this is also a much
cleaner interface for passing arguments to the individual device linking
jobs.
Nikita Popov [Fri, 8 Jul 2022 15:11:08 +0000 (17:11 +0200)]
[InstCombine] Avoid ConstantExpr::get() call
Avoid calling ConstantExpr::get() for associative/commutative
binops, call ConstantFoldBinaryOpOperands() instead. We only
want to perform the reassociation of the constants actually fold.
Simon Pilgrim [Fri, 8 Jul 2022 15:08:22 +0000 (16:08 +0100)]
[DAG] SimplifyDemandedBits - fold AND(INSERT_SUBVECTOR(C,X,I),M) -> INSERT_SUBVECTOR(AND(C,M),X,I)
If all the demanded bits of the AND mask covering the inserted subvector 'X' are known to be one, then the mask isn't affecting the subvector at all.
In which case, if the base vector 'C' is undef/constant, then move the AND mask up to just (constant) fold it directly.
Addresses some of the regressions from D129150, particularly the cases where we're attempting to zero the upper elements of a widened vector.
Differential Revision: https://reviews.llvm.org/D129290
Ye Luo [Fri, 8 Jul 2022 13:52:08 +0000 (08:52 -0500)]
[libomptarget] compile DeviceRTL bc files with -O3
bc files of DeviceRTL are compiled with -O3, the same as the static library.
Differential Revision: https://reviews.llvm.org/D129344
Nikita Popov [Fri, 8 Jul 2022 14:37:34 +0000 (16:37 +0200)]
[ConstantExpr] Don't create float binop expressions
Mark the fadd, fsub, fmul, fdiv, and frem expressions as
undesirable, so they are not created automatically. This is in
preparation for their removal.
Nikita Popov [Fri, 8 Jul 2022 14:04:21 +0000 (16:04 +0200)]
[InstCombine] Avoid creating float binop ConstantExprs
Replace ConstantExpr:getFAdd etc with call to
ConstantFoldBinaryOpOperands(). I'm using the constant folding API
rather than IRBuilder here to ensure that this does actually
constant fold. These transforms don't use m_ImmConstant(), so this
would not otherwise be guaranteed (and apparently, they can't use
m_ImmConstant because they want to handle scalable vector splats).
There is an opportunity here to further migrate these to the
ConstantFoldFPInstOperands() API, which would respect the denormal
mode. I've held off on doing so here, because some of this code
explicitly checks for denormal results, and I don't want to touch
it in a mostly NFC change.