Commit Graph

395219 Commits

Author SHA1 Message Date
Jesse Towner 68546c9d6f bugprone-forwarding-reference-overload: support non-type template parameters
Many concepts emulation libraries, such as the one found in Range v3, tend to
use non-type template parameters for the enable_if type expression, due to
their versatility in template functions and constructors containing variadic
template parameter packs.

Unfortunately the bugprone-forwarding-reference-overload check does not
handle non-type template parameters, as was first noted in this bug report:
https://bugs.llvm.org/show_bug.cgi?id=38081

This patch fixes this long standing issue and allows for the check to be suppressed
with the use of a non-type template parameter containing enable_if or enable_if_t in
the type expression, so long as it has a default literal value.
2021-07-29 07:01:19 -04:00
Jeremy Morse 2537120c87 Follow-up to D105207, only salvage affine SCEVs to avoid a crash
SCEVToIterCountExpr only expects to be fed affine expressions, but
DbgRewriteSalvageableDVIs is feeding it non-affine induction variables.
Following this up with an obvious fix, will add test coverage too if
this avoids D105207 being reverted.
2021-07-29 11:48:08 +01:00
Dmitry Vyukov 0d68cfc996 tsan: store ThreadRegistry in Context by value
It's unclear why we allocate ThreadRegistry separately,
I assume it's some historical leftover.
Embed ThreadRegistry into Context.

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D107045
2021-07-29 12:44:44 +02:00
Dmitry Vyukov 4e15ee2867 sanitizer_common: remove BlockingMutex and RWMutex
Remove the legacy typedefs and use Mutex/Lock types directly.

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D107043
2021-07-29 12:38:53 +02:00
Dmitry Vyukov b8f4232823 tsan: rename deadlock detector Mutex to UserMutex
It conflicts with sanitizer_common Mutex.

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D107053
2021-07-29 12:38:14 +02:00
Andrzej Warzynski 8bf0a40608 [flang][driver] Forward `-fopenmp`/`-fopenacc` to the host compiler
This patch only modifies `flang` - the bash wrapper script.

`-fopenmp`/`-fopenacc` are required to enable the OpenMP/OpenACC
extension in the frontend and to make sure that the required libraries
are linked when generating the final binary. This patch makes sure that
`-fopnemp`/`-fopenacc` is used for both unparsing and the code
generation (via the host compiler).

Differential Revision: https://reviews.llvm.org/D106871
2021-07-29 11:21:56 +01:00
Cullen Rhodes 08d92dbbff [AArch64][AsmParser] NFC: Parser.getTok() -> getTok()
Reviewed By: david-arm

Differential Revision: https://reviews.llvm.org/D106949
2021-07-29 10:18:54 +00:00
Amara Emerson da61ab8475 [AArch64][GlobalISel] More widenToNextPow2 changes, this time for arithmetic/bitwise ops. 2021-07-29 03:02:29 -07:00
Kirill Bobyrev d8fd2146da
NFC: Change quotes from Unicode to ASCII
This was causing some problems for Python scripts that we have.

Context: https://reviews.llvm.org/D106792
2021-07-29 11:37:10 +02:00
David Spickett d510b5f199 [lldb][AArch64] Annotate synchronous tag faults
In the latest Linux kernels synchronous tag faults
include the tag bits in their address.
This change adds logical and allocation tags to the
description of synchronous tag faults.
(asynchronous faults have no address)

Process 1626 stopped
* thread #1, name = 'a.out', stop reason = signal SIGSEGV: sync tag check fault (fault address: 0x900fffff7ff9010 logical tag: 0x9 allocation tag: 0x0)

This extends the existing description and will
show as much as it can on the rare occasion something
fails.

This change supports AArch64 MTE only but other
architectures could be added by extending the
switch at the start of AnnotateSyncTagCheckFault.
The rest of the function is generic code.

Tests have been added for synchronous and asynchronous
MTE faults.

Reviewed By: omjavaid

Differential Revision: https://reviews.llvm.org/D105178
2021-07-29 10:26:37 +01:00
Mirko Brkusanin 971f4173f8 [AMDGPU][GlobalISel] Insert an and with exec before s_cbranch_vccnz if necessary
While v_cmp will AND inactive lanes with 0, that is not the case for logical
operations.

This fixes a Vulkan CTS test that would hang otherwise.

Differential Revision: https://reviews.llvm.org/D105709
2021-07-29 11:20:49 +02:00
Benjamin Kramer d81a843846 [mlir] Put back virtual ~ConversionTarget(), some users started relying on it 2021-07-29 11:10:07 +02:00
Benjamin Kramer 1c9c2c91d4 [mlir] Remove the default isDynamicallyLegal hook
This is redundant with the callback variant and untested. Also remove
the callback-less methods for adding a dynamically legal op, as they
are no longer useful.

Differential Revision: https://reviews.llvm.org/D106786
2021-07-29 11:00:57 +02:00
Tomasz Kamiński f1ab60e40d Fix FindZ3.cmake to support static libraries and Windows
Use absolute path to link z3 to allow builds both on windows and linux
since the library name is platform dependent for Z3 (libz3 on Windows
and z3 on Linux) and MSVC does not recognized -L and -l options.
Fix CMAKE_CROSSCOMPILING that does not work correctly since it uses
Z3_BUILD_VERSION instead of Z3_BUILD_NUMBER
Fix building with the static version of z3 library (supersedes D80227).

 - Build the Z3 version detection code as C++, since the static
   library brings in libstdc++ symbols
 - Detect threading support and link against threading, in the
   (likely) case Z3 was built with threads

Exposed compilation error from building a program that is used to detect
z3 version in the warning message, to simplify troubleshooting.

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D106131
2021-07-29 10:55:44 +02:00
Rosie Sumpter 2df8bf9339 [LoopFlatten] Fix missed LoopFlatten opportunity
When the trip count of the inner loop is a constant, the InstCombine
pass now causes the transformation e.g. imcp ult i32 %inc, tripcount ->
icmp ult %j, tripcount-step (where %j is the inner loop induction
variable and %inc is add %j, step), which is now accounted for when
identifying the trip count of the loop. This is also an acceptable use
of %j (provided the step is 1) so is ignored as long as the compare
that it's used in is also the condition of the inner branch.

Differential Revision: https://reviews.llvm.org/D105802
2021-07-29 09:47:41 +01:00
Fraser Cormack 02dd4b59bc [RISCV] Optimize floating-point "dominant value" BUILD_VECTORs
This patch aims to improve the performance of BUILD_VECTORs which are
identified as containing a dominant element. Given that most
floating-point constants themselves require a load from the constant
pool, it was possible for the optimization to actually increase the
number of individual loads on small vectors. The exception is the zero
constant -- +0.0 -- which can be materialized efficiently.

While this optimization could do with a proper cost model to weigh the
benfits of a single vector load vs. the manipulation of individual
elements -- even for integer vectors which often require several
instructions to materialize -- without a concrete RVV implementation to
work with any heuristic is likely to be both more obtuse and inaccurate.

Until then, this patch fixes at least one known obvious deficiency.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D106963
2021-07-29 09:22:34 +01:00
Fraser Cormack a33f60db39 [RISCV] Add test case showing suboptimal BUILD_VECTOR lowering
The second test case added here was pointed out to me by @craig.topper
and shows how we "optimize" a two-element BUILD_VECTOR from being one
load from the constant pool to two loads from the constant pool.

The first test case shows that since materialization for the
floating-point +0.0 value is cheap and doesn't involve a load, the
optimization is more clearly beneficial here.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D106962
2021-07-29 09:21:26 +01:00
Diana Picus 9ff030ca50 test-release.sh: Kill python2
Don't prefer python2's virtualenv when setting up the test-suite.
Always use python3 instead, since that's what we support everywhere else
anyway.

Differential Revision: https://reviews.llvm.org/D106941
2021-07-29 10:25:48 +02:00
Björn Schäpers 75f6a795ee [clang-format] Fix aligning with linebreaks #2
This amends c5243c63cd to fix formatting
continued function calls with BinPacking = false.

Differential Revision: https://reviews.llvm.org/D106773
2021-07-29 08:43:41 +02:00
Mark de Wever 92b758cf3d [libcxx][doc] Update the build documentation.
These are the hunks of
  D106770 [libc++][doc] Update the release notes
that are relevant for main.
2021-07-29 07:57:10 +02:00
Jun Ma e2fe26e77b [NFC][InstSimplify] Use more intuitive variable names. 2021-07-29 13:55:47 +08:00
Dmitry Vyukov cd0143c0f2 tsan: switch from SSE3 to SSE4.2
Switch x86_64 requirement for optimized code from SSE3 to SSE4.2.
The new tsan runtime will need few instructions that are only
supported by SSE4:

_mm_max_epu32
_mm_extract_epi8
_mm_insert_epi32

SSE3 was introcued in 2004 and SSE4 in 2006:
https://en.wikipedia.org/wiki/SSE3
https://en.wikipedia.org/wiki/SSE4

We are still providing non-optimized C++ version of the code,
so either way it's possible to build tsan runtime for any CPU.

But for Go this will bump strict requirement for -race because
Go contains prebuilt versions and these will be built with -msse4.2.
But requiring a CPU produced at least in 2006 looks reasonable for
a debugging tool (more reasonable than disabling optimizations
for everybody).

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D106948
2021-07-29 07:50:46 +02:00
Dmitry Vyukov a1a37ddc3f tsan: remove /**/ at the of multi-line macros
Prefer code readability over writeability.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D106982
2021-07-29 07:50:09 +02:00
Dmitry Vyukov 262cb5f5b4 tsan: fix java_symbolization test
We reliably remove bottom libc-guts frames only on linux/glibc.
Some bots failed on this test showing other bottom frames:

 .annobin_libc_start.c libc-start.c (libc.so.6+0x249f4)
 generic_start_main.isra.0 libc-start.c (libc.so.6+0x45b0c)

We can't reliably remove all of possible bottom frames.
So remove the assertion for that.

Differential Revision: https://reviews.llvm.org/D107037
2021-07-29 07:48:39 +02:00
Arthur O'Dwyer d4840175c9 [libc++] Remove excess whitespace in synopsis comment. NFCI. 2021-07-29 01:34:31 -04:00
Freddy Ye 58712987e5 [NFC][X86] add missing tests in clang/test/CodeGen/attr-target-mv.c
Reviewed By: pengfei

Differential Revision: https://reviews.llvm.org/D106849
2021-07-29 13:28:10 +08:00
Mehdi Amini 0be5d1a96c Implement recursive support into OperationEquivalence::isEquivalentTo()
This allows to use OperationEquivalence to track structural comparison for equality
between two operations.

Differential Revision: https://reviews.llvm.org/D106422
2021-07-29 05:06:37 +00:00
Mehdi Amini b70de61f48 Add `all_of_zip` to STLExtras
This takes two ranges and invokes a predicate on the element-wise pair in the
ranges. It returns true if all the pairs are matching the predicate and the ranges
have the same size.
It is useful with containers that aren't random iterator where we can't check the
sizes in O(1).

Differential Revision: https://reviews.llvm.org/D106605
2021-07-29 05:00:35 +00:00
Nathan Chancellor 5060224d9e
[test] Fix tools/gold/X86/comdat-nodeduplicate.ll on non-X86 hosts
When running this test on an aarch64 machine, it fails:

```
/usr/bin/ld.gold: error: .../test/tools/gold/X86/Output/comdat-nodeduplicate.ll.tmp/ab.lto.o: incompatible target
```

Specify the elf_x86_64 emulation as all of the other gold plugin tests
do.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D107020
2021-07-28 21:56:23 -07:00
Alfonso Gregory 640ed21cce [libc][NFC] Add noreturn and constexpr qualifiers where appropriate
These functions make it clear to the compiler and user what the intended
behavior is so llvm can make them go as fast as possible.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D106807
2021-07-29 04:50:05 +00:00
Tom Stellard a4edb2b1ba libcang: Add missing function to libclang.map
This function is marked with CINDEX_LINKAGE, but was never added to the
export list / linker script.

Reviewed By: jrtc27

Differential Revision: https://reviews.llvm.org/D106974
2021-07-28 21:06:40 -07:00
Michael Kruse c6b0b16c0f [Preprocessor] -E -P: Ensure newline after 8 skipped lines.
The implementation of -fminimize-whitespace (D104601) revised the logic
when to emit newlines. There was no case to handle when more than
8 lines were skippped in -P (DisableLineMarkers) mode and instead fell
through the case intended for -fminimize-whitespace, i.e. emit nothing.
This patch will emit one newline in this case.

The newline logic is slightly reorganized. The `-P -fminimize-whitespace`
case is handled explicitly and emitting at least one newline is the new
fallback case. The choice between emitting a line marker or up to
7 empty lines is now a choice only with enabled line markers. The up to
8 newlines likely are fewer characters than a line directive, but
in -P mode this had the paradoxic effect that it would print up to
7 empty lines, but none at all if more than 8 lines had to be skipped.
Now with DisableLineMarkers, we don't consider printing empty lines
(just start a new line) which matches gcc's behavior.

The line-directive-output-mincol.c test is replaced with a more
comprehensive test skip-empty-lines.c also testing the more than
8 skipped lines behaviour with all flag combinations.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D106924
2021-07-28 22:50:54 -05:00
Stella Laurenzo 768f562641 Update file names and extensions for MLIR Python execution engine changes. 2021-07-29 03:19:14 +00:00
Stella Laurenzo 7e2174c253 NFC: Add missing import to integration test. 2021-07-29 02:44:01 +00:00
LLVM GN Syncbot ecd5dc6dcc [gn build] Port 61c35fb0c2 2021-07-29 02:29:22 +00:00
Ruslan Arutyunyan 61c35fb0c2 [libc++][modularisation] Split <compare> into internal headers.
Differential Revision: https://reviews.llvm.org/D106107
2021-07-28 22:28:26 -04:00
Arthur O'Dwyer 20c6ddc5bc [libc++] Remove unused variables in generate_private_header_tests.py. NFCI. 2021-07-28 22:28:25 -04:00
Jason Liu 363a8a0598 [libc++] money_get::do_get() set failbit and eofbit if iterator begin equals end
Summary:
Currently, if we pass in the same iterator for begin and end,
the long double version of do_get would throw a runtime error.

However, according to standard (https://eel.is/c++draft/locale.money.get#virtuals-1),
we should set the failbit and eofbit when no more characters are available.

Differential Revision: https://reviews.llvm.org/D100510
2021-07-28 22:23:09 -04:00
Guozhi Wei 50b6273145 [MBP] findBestLoopTopHelper should exit if OldTop is not a chain header
Function findBestLoopTopHelper tries to find a new loop top block which can also
fall through to OldTop, but it's impossible if OldTop is not a chain header, so
it should exit immediately.

Differential Revision: https://reviews.llvm.org/D106329
2021-07-28 19:00:45 -07:00
Ben Shi 264b8e2a20 [RISCV] Optimize mul in the zba extension with SH*ADD
This patch makes the following optimization, if the
immediate multiplier is not a simm12.

(mul x, (power_of_2 + 2)) => (SH1ADD x, (SLLI x, bits))
(mul x, (power_of_2 + 4)) => (SH2ADD x, (SLLI x, bits))
(mul x, (power_of_2 + 8)) => (SH3ADD x, (SLLI x, bits))

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D106648
2021-07-29 09:46:41 +08:00
Ben Shi 2a2d83d916 [RISCV][test] Add new tests for mul optimization in the zba extension with SH*ADD
These test will show the following optimization by future patches.

(mul x, (power_of_2 + 2)) => (SH1ADD x, (SLLI x, bits))
(mul x, (power_of_2 + 4)) => (SH2ADD x, (SLLI x, bits))
(mul x, (power_of_2 + 8)) => (SH3ADD x, (SLLI x, bits))

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D106647
2021-07-29 09:46:41 +08:00
Arthur O'Dwyer 3894a8a476 [libc++] Implement the resolutions of LWG3506 and LWG3522.
Implement the changes in all language modes.

LWG3506 "Missing allocator-extended constructors for priority_queue"
makes the following changes:
- New allocator-extended constructors for priority_queue.
- New deduction guides targeting those constructors.

LWG3522: "Missing requirement on InputIterator template parameter
for priority_queue constructors". The iterator parameter should be
constrained to actually be an iterator type. `priority_queue{1,2}`
should be SFINAE-friendly ill-formed.

Also, do a drive-by fix in the allocator-extended move constructor:
there's no need to do a `make_heap` after moving from `__q.c` into
our own `c`, because that container was already heapified when it
was part of `__q`. [priqueue.cons.alloc] actually specifies the
behavior and does *not* mention calling `make_heap`. I think this
was just a copy-paste thinko. It dates back to the initial import
of libc++.

Differential Revision: https://reviews.llvm.org/D106824
Differential Revision: https://reviews.llvm.org/D106827
2021-07-28 21:15:20 -04:00
Wenlei He 1a8087adaf [ThinLTO] Disallow importing for functions with indir branch to block address
We don't allowing inlining for functions with blockaddress with uses other than strictly callbr. This is because if the blockaddress escapes the function via a global variable, inlining may lead to an invalid cross-function reference.

We check against such cases during inlining, however the check can fail for ThinLTO post-link because CFG simplification can incorrectly removes blocks based on wrong block reachability.

When we import a function with blockaddress taken in a global variable but without importing that variable, we won't go through value mapping to reflect the real address-taken-ness of the cloned blocks. For the imported clone, this leads to blocks reachable from indirect branch through global variable being incorrectly treated as unreachable and removed by SimplifyCFG.

Since inlining for such cases shouldn't be allowed in the first place, I'm marking them as ineligible for importing during pre-link to save the problem of missing address-taken-ness of imported clone as well as bad DCE and inlining.

Differential Revision: https://reviews.llvm.org/D106930
2021-07-28 18:02:48 -07:00
Marco Vanotti c6ad3f2157 [asan][fuchsia] Implement PlatformUnpoisonStacks
This CL modifies the PlatformUnpoisonStacks so that fuchsia can
implement its own logic for unpoisoning the stacks.

For the general case, the behavior is the same as with regular asan: it
will unpoison everything from the current stack pointer until the base
of the stack (stack top).

In some situations, the current stack might not be the same as the
default stack. In those cases, the code will now unpoison the entire
default stack, and will also unpoison the current page of the stack.

Reviewed By: mcgrathr

Differential Revision: https://reviews.llvm.org/D106835
2021-07-28 18:02:19 -07:00
Marco Vanotti a9c515983d [libFuzzer] Fix CFI Directives for fuchsia
This commit fixes the CFI directives in the crash trampoline so
libunwind can get a backtrace during a crash.

In order to get a backtrace from a libfuzzer crash in fuchsia, we
resume execution in the crashed thread, forcing it to call the
StaticCrashHandler. We do this by setting a "crash trampoline" that has
all the necessary cfi directives for an unwinder to get full backtrace
for that thread.

Due to a bug in libunwind, it was not possible to restore the RSP
pointer, as it was always set to the call frame address (CFA). The
previous version worked around this issue by setting the CFA to the
value of the stack pointer at the point of the crash.

The bug in libunwind is now fixed[0], so I am correcting the CFI
annotations so that the CFA correctly points to the beginning of the
trampoline's call frame.

[0]: https://reviews.llvm.org/D106626

Reviewed By: mcgrathr

Differential Revision: https://reviews.llvm.org/D106725
2021-07-28 17:59:02 -07:00
Daniel Rodríguez Troitiño d6704e5ed9 [llvm-objcopy][MachO] Ignore all LC_SUB_* commands.
The LC_SUB_FRAMEWORK, LC_SUB_UMBRELLA, LC_SUB_CLIENT, and LC_SUB_LIBRARY
are used to indicate related libraries, binaries or framework names.
Their only payload is the string with the name of the object. Adding
those commands to the list of ignored/skipped load commands will avoid
an error that stop the process of copying/stripping and will copy their
contents verbatim.

Additionally, in order to have a test for this case, `yaml2obj` now
allows those four commands to contain a `Content`.

Differential Revision: https://reviews.llvm.org/D106412
2021-07-28 17:35:26 -07:00
Jessica Paquette 5a333dc5da [AArch64][GlobalISel] Improve legalization for odd-type G_LOAD
Swap the order of widening so that we widen to the next power-of-2 first when
legalizing G_LOAD.

Also, provide a minimum type for the power of 2 to disallow s2 + s1. Clamping
ought to disallow s2 and s1, but I think it's better to be explicit about the
expected minimum size.

We probably need a similar change for G_STORE, but it seems to be a bit more
finnicky. So, let's just handle G_LOAD for now.

Differential Revision: https://reviews.llvm.org/D107013
2021-07-28 17:19:14 -07:00
Stella Laurenzo 0cdf491501 Break apart the MLIR ExecutionEngine from core python module.
* For python projects that don't need JIT/ExecutionEngine, cuts the number of files to compile roughly in half (with similar reduction in end binary size).

Differential Revision: https://reviews.llvm.org/D106992
2021-07-28 23:59:32 +00:00
Mehdi Amini 4bb0ad2382 Emit strong definition for TypeID storage in Op/Type/Attributes definition
By making an explicit template specialization for the TypeID provided by these classes,
the compiler will not emit an inline weak definition and rely on the linker to unique it.
Instead a single definition will be emitted in the C++ file alongside the implementation
for these classes. That will turn into a linker error what is now a hard-to-debug runtime
behavior where instances of the same class may be using a different TypeID inside of
different DSOs.

Recommit 660a56956c after fixing gcc5
build.

Differential Revision: https://reviews.llvm.org/D105903
2021-07-28 23:58:39 +00:00
Stella Laurenzo dad10a9afb NFC: Adapt operation.py to builtin operation print format changes. 2021-07-28 23:57:08 +00:00