platform/upstream/llvm.git
3 years ago[libomptarget][nvptx][nfc] Move target_impl functions out of header
Jon Chesterfield [Fri, 15 Jan 2021 00:19:48 +0000 (00:19 +0000)]
[libomptarget][nvptx][nfc] Move target_impl functions out of header

[libomptarget][nvptx][nfc] Move target_impl functions out of header

This removes most of the differences between the two target_impl.h.

Also change name mangling from C to C++ for __kmpc_impl_*_lock.

Reviewed By: tianshilei1992

Differential Revision: https://reviews.llvm.org/D94728

3 years ago[mlir][Linalg] NFC: Verify tiling on linalg.generic operation on tensors.
MaheshRavishankar [Thu, 14 Jan 2021 23:41:12 +0000 (15:41 -0800)]
[mlir][Linalg] NFC: Verify tiling on linalg.generic operation on tensors.

With the recent changes to linalg on tensor semantics, the tiling
operations works out-of-the-box for generic operations. Add a test to
verify that and some minor refactoring.

Differential Revision: https://reviews.llvm.org/D93077

3 years ago[mlir][Linalg] Add canonicalization of linalg op -> dim op.
MaheshRavishankar [Thu, 14 Jan 2021 23:41:04 +0000 (15:41 -0800)]
[mlir][Linalg] Add canonicalization of linalg op -> dim op.

Add canonicalization to replace use of the result of a linalg
operation on tensors in a dim operation, to use one of the operands of
the linalg operations instead. This allows the linalg op itself to be
deleted when all its non-dim uses are removed (say through tiling, etc.)

Differential Revision: https://reviews.llvm.org/D93076

3 years ago[OpenMP] Remove omptarget-nvptx from deps as it is no longer a valid target
Shilei Tian [Fri, 15 Jan 2021 00:14:19 +0000 (19:14 -0500)]
[OpenMP] Remove omptarget-nvptx from deps as it is no longer a valid target

`omptarget-nvptx` is still a dependence for `check-libomptarget-nvtpx`
although it has been removed by D94573.

Reviewed By: JonChesterfield

Differential Revision: https://reviews.llvm.org/D94725

3 years ago[SLP] remove unnecessary state in matching reductions
Sanjay Patel [Thu, 14 Jan 2021 22:26:48 +0000 (17:26 -0500)]
[SLP] remove unnecessary state in matching reductions

This is NFC-intended. I'm still trying to figure out
how the loop where this is used works. It does not
seem like we require this data at all, but it's
hard to confirm given the complicated predicates.

3 years ago[mlir][Linalg] Add canonicalization to remove no-op linalg operations.
MaheshRavishankar [Thu, 14 Jan 2021 22:58:04 +0000 (14:58 -0800)]
[mlir][Linalg] Add canonicalization to remove no-op linalg operations.

linalg.generic/indexed_generic operations on tensors whose body is
just yielding the (non-induction variable) arguments of the operation
can be canonicalized by replacing uses of the result with the
corresponding arguments.

Differential Revision: https://reviews.llvm.org/D94581

3 years ago[clangd] Reduce logspam for CDB scanning
Sam McCall [Thu, 14 Jan 2021 22:54:51 +0000 (23:54 +0100)]
[clangd] Reduce logspam for CDB scanning

3 years ago[mlir] Remove over specified memory effects
Andrew Young [Thu, 14 Jan 2021 10:07:29 +0000 (02:07 -0800)]
[mlir] Remove over specified memory effects

The standard and gpu dialect both have `alloc` operations which use the
memory effect `MemAlloc`.  In both cases, it is specified on both  the
operation itself and on the result.  This results in two memory effects
being created for these operations.  When `MemAlloc` is defined on an
operation, it represents some background effect which the compiler
cannot reason about, and  inhibits the ability of the compiler to
remove dead `std.alloc` operations.  This change removes the uneeded
`MemAlloc` effect from these operations and leaves the effect on the
result, which allows dead allocs to be erased.

There is the same problem, but to a lesser extent, with MemFree, MemRead
and MemWrite. Over-specifying these traits is not currently inhibiting
any optimization.

Differential Revision: https://reviews.llvm.org/D94662

3 years ago[RISCV][NFC] Regenerate Calling Convention Tests
Sam Elliott [Thu, 14 Jan 2021 22:32:17 +0000 (22:32 +0000)]
[RISCV][NFC] Regenerate Calling Convention Tests

This regenerates these tests using utils/update_llc_test_checks.py so
that future changes in this area don't have the noise of lots of `@plt`
lines being added.

I also removed the `nounwind`s from the stack-realignment.ll test to
increase coverage on the generated call frame information.

3 years ago[LTO] Test format fix (NFC)
Teresa Johnson [Thu, 14 Jan 2021 22:07:11 +0000 (14:07 -0800)]
[LTO] Test format fix (NFC)

As requested in D91583, use ';;' instead of ';' to preceed comments in
lld test. I did this in the equivalent gold test as well.

3 years agoRe-land [Support] On Windows, take the affinity mask into account
Alexandre Ganea [Thu, 14 Jan 2021 22:03:13 +0000 (17:03 -0500)]
Re-land [Support] On Windows, take the affinity mask into account

The number of hardware threads available to a ThreadPool can be limited if setting an affinity mask.
For example:

    > start /B /AFFINITY 0xF lld-link.exe ...

Would let LLD only use 4 hyper-threads.

Previously, there was an outstanding issue on Windows Server 2019 on dual-CPU machines, which was preventing from using both CPU sockets. In normal conditions, when no affinity mask was set, ProcessorGroup::AllThreads was different from ProcessorGroup::UsableThreads. The previous code in llvm/lib/Support/Windows/Threading.inc L201 was improperly assuming those two values to be equal, and consequently was limiting the execution to only one CPU socket.

Differential Revision: https://reviews.llvm.org/D92419

3 years ago[RISCV] Optimize select_cc after fp compare expansion
Craig Topper [Thu, 14 Jan 2021 21:41:35 +0000 (13:41 -0800)]
[RISCV] Optimize select_cc after fp compare expansion

Some FP compares expand to a sequence ending with (xor X, 1) to invert the result. If
the consumer is a select_cc we can likely get rid of this xor by fixing
up the select_cc condition.

This patch combines (select_cc (xor X, 1), 0, setne, trueV, falseV) -
(select_cc X, 0, seteq, trueV, falseV) if we can prove X is 0/1.

Reviewed By: lenary

Differential Revision: https://reviews.llvm.org/D94546

3 years agoAdd -fexceptions to test as it uses them and fails on platforms where it is not on...
Douglas Yung [Thu, 14 Jan 2021 21:26:21 +0000 (13:26 -0800)]
Add -fexceptions to test as it uses them and fails on platforms where it is not on by default (like the PS4).

3 years ago[libc] Use #undef isascii in specific header
Roland McGrath [Thu, 14 Jan 2021 01:22:45 +0000 (17:22 -0800)]
[libc] Use #undef isascii in specific header

Standard C allows all standard headers to declare macros for all
their functions.  So after possibly including any standard header
like <ctype.h>, it's perfectly normal for any and all of the
functions it declares to be defined as macros.  Standard C requires
explicit `#undef` before using that identifier in a way that is not
compatible with function-like macro definitions.

The C standard's rules for this are extended to POSIX as well for
the interfaces it defines, and it's the expected norm for
nonstandard extensions declared by standard C library headers too.

So far the only place this has come up for llvm-libc's code is with
the isascii function in Fuchsia's libc.  But other cases can arise
for any standard (or common extension) function names that source
code in llvm-libc is using in nonstandard ways, i.e. as C++
identifiers.

The only correct and robust way to handle the possible inclusion of
standard C library headers when building llvm-libc source code is to
use `#undef` explicitly for each identifier before using it.  The
easy and obvious place to do that is in the per-function header.
This requires that all code, such as test code, that might include
any standard C library headers, e.g. via utils/UnitTest/Test.h, make
sure to include those *first* before the per-function header.

This change does that for isascii and its test.  But it should be
done uniformly for all the code and documented as a consistent
convention so new implementation files are sure to get this right.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D94642

3 years ago[gn build] (manually) port 387d3c24792f
Nico Weber [Thu, 14 Jan 2021 21:19:25 +0000 (16:19 -0500)]
[gn build] (manually) port 387d3c24792f

3 years ago[PowerPC] Only use some extend mne if assembler is modern enough
Jinsong Ji [Thu, 14 Jan 2021 20:35:56 +0000 (20:35 +0000)]
[PowerPC] Only use some extend mne if assembler is modern enough

Legacy AIX assembly might not support all extended mnes,
add one feature bit to control the generation in MC,
and avoid generating them by default on AIX.

Reviewed By: sfertile

Differential Revision: https://reviews.llvm.org/D94458

3 years ago[mlir][docs] Bring bufferization docs up to date.
Sean Silva [Sat, 9 Jan 2021 00:25:47 +0000 (16:25 -0800)]
[mlir][docs] Bring bufferization docs up to date.

This spilts out BufferDeallocationInternals.md, since buffer
deallocation is not part of bufferization per se.

Differential Revision: https://reviews.llvm.org/D94351

3 years ago[clang] Do not crash when CXXRecordDecl has a non-CXXRecordDecl base.
Adam Czachorowski [Thu, 14 Jan 2021 19:54:16 +0000 (20:54 +0100)]
[clang] Do not crash when CXXRecordDecl has a non-CXXRecordDecl base.

This can happen on some invalid code, like the included test case.

Differential Revision: https://reviews.llvm.org/D94704

3 years ago[mlir] Remove TosaToLinalg dependency on all Passes
Tres Popp [Thu, 14 Jan 2021 20:04:37 +0000 (21:04 +0100)]
[mlir] Remove TosaToLinalg dependency on all Passes

TosaToLinalg was depending on its header file indirectly through
Passes.h rather than directly. This removes that indirection.

Differential Revision: https://reviews.llvm.org/D94706

3 years ago[mlir][PatternRewriter] Add a new hook to selectively replace uses of an operation
River Riddle [Thu, 14 Jan 2021 19:57:17 +0000 (11:57 -0800)]
[mlir][PatternRewriter] Add a new hook to selectively replace uses of an operation

This revision adds a new `replaceOpWithIf` hook that replaces uses of an operation that satisfy a given functor. If all uses are replaced, the operation gets erased in a similar manner to `replaceOp`. DialectConversion support will be added in a followup as this requires adjusting how replacements are tracked there.

Differential Revision: https://reviews.llvm.org/D94632

3 years ago[RISCV] Merge Utils library into MCTargetDesc
Craig Topper [Thu, 14 Jan 2021 19:44:02 +0000 (11:44 -0800)]
[RISCV] Merge Utils library into MCTargetDesc

MCTargetDesc includes headers from Utils and Utils includes headers
from MCTargetDesc. So from a library layering perspective it makes sense
for them to be in the same library. I guess the other option might be to
move the tablegen includes from RISCVMCTargetDesc.h to RISCVBaseInfo.h
so that RISCVBaseInfo.h didn't need to include RISCVMCTargetDesc.h.
Everything else that depends on Utils also depends on MCTargetDesc so
having one library seemed simpler.

Differential Revision: https://reviews.llvm.org/D93168

3 years ago[Driver] -gsplit-dwarf: Produce .dwo regardless of -gN for IR input
Fangrui Song [Thu, 14 Jan 2021 19:46:22 +0000 (11:46 -0800)]
[Driver] -gsplit-dwarf: Produce .dwo regardless of -gN for IR input

This generalizes D94647 to IR input, as suggested by @tejohnson.
Ideally the driver should just forward split dwarf options, but doing this currently will cause `clang -gsplit-dwarf -c a.c` to create a .dwo with just `.strtab`.

Reviewed By: dblaikie, tejohnson

Differential Revision: https://reviews.llvm.org/D94655

3 years ago[mlir][OpFormatGen] Format enum attribute cases as keywords when possible
River Riddle [Thu, 14 Jan 2021 19:35:15 +0000 (11:35 -0800)]
[mlir][OpFormatGen] Format enum attribute cases as keywords when possible

In the overwhelmingly common case, enum attribute case strings represent valid identifiers in MLIR syntax. This revision updates the format generator to format as a keyword in these cases, removing the need to wrap values in a string. The parser still retains the ability to parse the string form, but the printer will use the keyword form when applicable.

Differential Revision: https://reviews.llvm.org/D94575

3 years ago[mlir][ODS] Add new RangedTypesMatchWith operation predicate
River Riddle [Thu, 14 Jan 2021 19:34:55 +0000 (11:34 -0800)]
[mlir][ODS] Add new RangedTypesMatchWith operation predicate

This is a variant of TypesMatchWith that provides support for variadic arguments. This is necessary because ranges generally can't use the default operator== comparators for checking equality.

Differential Revision: https://reviews.llvm.org/D94574

3 years ago[BasicAA] Handle recursive queries more efficiently
Nikita Popov [Tue, 10 Nov 2020 19:43:46 +0000 (20:43 +0100)]
[BasicAA] Handle recursive queries more efficiently

An alias query currently works out roughly like this:

 * Look up location pair in cache.
 * Perform BasicAA logic (including cache lookup and insertion...)
 * Perform a recursive query using BestAAResults.
   * Look up location pair in cache (and thus do not recurse into BasicAA)
   * Query all the other AA providers.
 * Query all the other AA providers.

This is a lot of unnecessary work, all ultimately caused by the
BestAAResults query at the end of aliasCheck(). The reason we perform
it, is that aliasCheck() is getting called recursively, and we of
course want those recursive queries to also make use of other AA
providers, not just BasicAA. We can solve this by making the recursive
queries directly use BestAAResults (which will check both BasicAA
and other providers), rather than recursing into aliasCheck().

There are some tradeoffs:

 * We can no longer pass through the precomputed underlying object
   to aliasCheck(). This is not a major concern, because nowadays
   getUnderlyingObject() is quite cheap.
 * Results from other AA providers are no longer cached inside
   BasicAA. The way this worked was already a bit iffy, in that a
   result could be cached, but if it was MayAlias, we'd still end
   up re-querying other providers anyway. If we want to cache
   non-BasicAA results, we should do that in a more principled manner.

In any case, despite those tradeoffs, this works out to be a decent
compile-time improvment. I think it also simplifies the mental model
of how BasicAA works. It took me quite a while to fully understand
how these things interact.

Differential Revision: https://reviews.llvm.org/D90094

3 years agoAdd newline to terminate debug message (NFC)
Mehdi Amini [Thu, 14 Jan 2021 19:28:49 +0000 (19:28 +0000)]
Add newline to terminate debug message (NFC)

3 years ago[MLIR][TOSA] First lowerings from Tosa to Linalg
Rob Suderman [Tue, 5 Jan 2021 22:26:48 +0000 (14:26 -0800)]
[MLIR][TOSA] First lowerings from Tosa to Linalg

Initial commit to add support for lowering from TOSA to Linalg. The focus is on
the essential infrastructure for these lowerings and integration with existing
passes.

Includes lowerings for a subset of operations including:
  abs, add, sub, pow, and, or, xor, left shift, right shift, tanh

Lit tests are used to validate correctness.

Differential Revision: https://reviews.llvm.org/D94247

3 years ago[NFC] Update test to not check for 'opaque' in the file name.
Erich Keane [Thu, 14 Jan 2021 19:00:49 +0000 (11:00 -0800)]
[NFC] Update test to not check for 'opaque' in the file name.

The intent presumably is to avoid generating 'opaque' in the IR, but the
header contains the filename. Thus, having the workspace in a directory
with opaque in it causes this test to fail.

This just adds a 'CHECK' line on target-triple, which is the last line
of the IR-header.

3 years ago[openacc] Rename generated file from ACC.cpp.inc to ACC.inc to match D92955
Valentin Clement [Thu, 14 Jan 2021 19:19:35 +0000 (14:19 -0500)]
[openacc] Rename generated file from ACC.cpp.inc to ACC.inc to match D92955

This patch rename the tablegen generated file ACC.cpp.inc to ACC.inc in order
to match what was done in D92955. This file is included in header file as well as .cpp
file so it make more sense.

Reviewed By: sameeranjoshi

Differential Revision: https://reviews.llvm.org/D93485

3 years ago[GWP-ASan] Minor refactor of optional components.
Mitch Phillips [Thu, 14 Jan 2021 01:28:10 +0000 (17:28 -0800)]
[GWP-ASan] Minor refactor of optional components.

In preparation for the inbuilt options parser, this is a minor refactor
of optional components including:
 - Putting certain optional elements in the right header files,
 according to their function and their dependencies.
 - Cleaning up some old and mostly-dead code.
 - Moving some functions into anonymous namespaces to prevent symbol
 export.

Reviewed By: cryptoad, eugenis

Differential Revision: https://reviews.llvm.org/D94117

3 years ago[OpenMP] Dropped unnecessary define when compiling deviceRTLs for NVPTX
Shilei Tian [Thu, 14 Jan 2021 18:55:05 +0000 (13:55 -0500)]
[OpenMP] Dropped unnecessary define when compiling deviceRTLs for NVPTX

The comment said CUDA 9 header files use the `nv_weak` attribute which
`clang` is not yet prepared to handle. It's three years ago and now things have
changed. Based on my test, removing the definition doesn't have any problem on
my machine with CUDA 11.1 installed.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D94700

3 years ago[X86] Add the FSRM feature (Fast Short Rep Mov) to Zen3.
Hiroshi Yamauchi [Mon, 11 Jan 2021 19:02:37 +0000 (11:02 -0800)]
[X86] Add the FSRM feature (Fast Short Rep Mov) to Zen3.

Note -x86-use-fsrm-for-memcpy is still disabled by default and there's no
default behavior change.

Differential Revision: https://reviews.llvm.org/D94436

3 years ago[clang][MSVC] Fix missing MSInheritanceAttr in template specialization.
Zequan Wu [Thu, 14 Jan 2021 03:14:25 +0000 (19:14 -0800)]
[clang][MSVC] Fix missing MSInheritanceAttr in template specialization.

Fix PR48687.

Differential Revision: https://reviews.llvm.org/D94646

3 years ago[OpenMP] Drop the static library libomptarget-nvptx
Shilei Tian [Thu, 14 Jan 2021 18:34:18 +0000 (13:34 -0500)]
[OpenMP] Drop the static library libomptarget-nvptx

For NVPTX target, OpenMP provides a static library `libomptarget-nvptx`
built by NVCC, and another bitcode `libomptarget-nvptx-sm_{$sm}.bc` generated by
Clang. When compiling an OpenMP program, the `.bc` file will be fed to `clang`
in the second run on the program that compiles the target part. Then the generated
PTX file will be fed to `ptxas` to generate the object file, and finally the driver
invokes `nvlink` to generate the binary, where the static library will be appened
to `nvlink`.

One question is, why do we need two libraries? The only difference is, the static
library contains `omp_data.cu` and the bitcode library doesn't. It's unclear why
they were implemented in this way, but per D94565, there is no issue if we also
include the file into the bitcode library. Therefore, we can safely drop the
static library.

This patch is about the change in OpenMP. The driver will be updated as well if
this patch is accepted.

Reviewed By: jdoerfert, JonChesterfield

Differential Revision: https://reviews.llvm.org/D94573

3 years agoSupport emptiness checks for unbounded FlatAffineConstraints.
Arjun P [Thu, 14 Jan 2021 18:29:51 +0000 (19:29 +0100)]
Support emptiness checks for unbounded FlatAffineConstraints.

With this, we have complete support for emptiness checks. This also paves the way for future support to check if two FlatAffineConstraints are equal.

Reviewed By: ftynse

Differential Revision: https://reviews.llvm.org/D94272

3 years ago[HIP] Add signbit(long double) decl
Aaron En Ye Shi [Thu, 14 Jan 2021 17:52:27 +0000 (17:52 +0000)]
[HIP] Add signbit(long double) decl

An _MSC_VER version of signbit(long double) is required for MSVC headers.

Fixes: SWDEV-256409

Differential Revision: https://reviews.llvm.org/D93062

3 years ago[LLDB] MinidumpParser: Prefer executable module even at higher address
Joseph Tremoulet [Thu, 14 Jan 2021 18:17:02 +0000 (13:17 -0500)]
[LLDB] MinidumpParser: Prefer executable module even at higher address

When a program maps one of its own modules for reading, and then
crashes, breakpad can emit two entries for that module in the
ModuleList.  We have logic to identify this case by checking permissions
on mapped memory regions and report just the module with an executable
region.  As currently written, though, the check is asymmetric -- the
entry with the executable region must be the second one encountered for
the preference to kick in.

This change makes the logic symmetric, so that the first-encountered
module will similarly be preferred if it has an executable region but
the second-encountered module does not.  This happens for example when
the module in question is the executable itself, which breakpad likes to
report first -- we need to ignore the other entry for that module when
we see it later, even though it may be mapped at a lower virtual
address.

Reviewed By: clayborg

Differential Revision: https://reviews.llvm.org/D94629

3 years ago[SelectionDAG] Remove an early-out from computeKnownBits for smin/smax
Jay Foad [Thu, 3 Sep 2020 18:22:33 +0000 (19:22 +0100)]
[SelectionDAG] Remove an early-out from computeKnownBits for smin/smax

Even if we know nothing about LHS, it can still be useful to know that
smax(LHS, RHS) >= RHS and smin(LHS, RHS) <= RHS.

Differential Revision: https://reviews.llvm.org/D87145

3 years ago[libomptarget][amdgpu] Fix kernel launch tracing to match previous behavior
Jon Chesterfield [Thu, 14 Jan 2021 18:13:22 +0000 (18:13 +0000)]
[libomptarget][amdgpu] Fix kernel launch tracing to match previous behavior

Restore control of kernel launch tracing to be >= 1 as it was before

export LIBOMPTARGET_KERNEL_TRACE=1

Reviewed By: JonChesterfield

Differential Revision: https://reviews.llvm.org/D94695

3 years ago[X86][AVX] Adjust unsigned saturation downconvert negative test
Simon Pilgrim [Thu, 14 Jan 2021 17:51:06 +0000 (17:51 +0000)]
[X86][AVX] Adjust unsigned saturation downconvert negative test

D87145 was showing that this test (added in D45315) could always be constant folded (with suitable value tracking).

What we actually needed was smax(smin()) negative test coverage, the invert of negative_test2_smax_usat_trunc_wb_256_mem, so I've tweaked the test to provide that instead.

3 years ago[NewPM] Fix placement of LoopFlatten
Arthur Eubanks [Thu, 14 Jan 2021 05:46:25 +0000 (21:46 -0800)]
[NewPM] Fix placement of LoopFlatten

https://reviews.llvm.org/D90402 was inconsistent with where it put
LoopFlatten between the two pass managers. It also missed adding it to
the non-O1 function simplification pipeline.

PR48738

Reviewed By: SjoerdMeijer

Differential Revision: https://reviews.llvm.org/D94650

3 years ago[NFC] Disallow unused prefixes under MC/AArch64
Mircea Trofin [Wed, 13 Jan 2021 18:39:25 +0000 (10:39 -0800)]
[NFC] Disallow unused prefixes under MC/AArch64

Differential Revision: https://reviews.llvm.org/D94616

3 years ago[flang] Fix some module file issues exposed by Whizard
peter klausler [Wed, 13 Jan 2021 22:12:23 +0000 (14:12 -0800)]
[flang] Fix some module file issues exposed by Whizard

Generic type-bound interfaces for user-defined operators need to be formatted
as "OPERATOR(.op.)", not just ".op."

PRIVATE generics need to be marked as such.

Declaration ordering: when a generic interface shadows a
derived type of the same name, it needs to be emitted to the
module file at the point of definition of the derived type;
otherwise, the derived type's definition may appear after its
first use.

The module symbol for a module read from a module file needs
to be marked as coming from a module file before semantic
processing is performed on the contents of the module so that
any special handling for declarations in module files can be
properly activated.

IMPORT statements were sometimes missing for use-associated
symbols in surrounding scopes; fine-tune NeedImport().

Differential Revision: https://reviews.llvm.org/D94636

3 years ago[gn build] Port 2f395b7092bd
LLVM GN Syncbot [Thu, 14 Jan 2021 17:39:58 +0000 (17:39 +0000)]
[gn build] Port 2f395b7092bd

3 years ago[clangd] Trivial: Documentation fix in ASTSignals.
Utkarsh Saxena [Thu, 14 Jan 2021 17:38:42 +0000 (18:38 +0100)]
[clangd] Trivial: Documentation fix in ASTSignals.

3 years ago[clangd] Make AST-based signals available to runWithPreamble.
Utkarsh Saxena [Sun, 10 Jan 2021 15:23:03 +0000 (16:23 +0100)]
[clangd] Make AST-based signals available to runWithPreamble.

Many useful signals can be derived from a valid AST which is regularly updated by
the ASTWorker. `runWithPreamble` does not have access to the ParsedAST
but it can be provided access to some signals derived from a (possibly
stale) AST.

Differential Revision: https://reviews.llvm.org/D94424

3 years ago[NFC] Disallow unused prefixes under MC/ARM
Mircea Trofin [Wed, 13 Jan 2021 19:02:10 +0000 (11:02 -0800)]
[NFC] Disallow unused prefixes under MC/ARM

Differential Revision: https://reviews.llvm.org/D94620

3 years ago[flang][driver] Use __FLANG_VERISION__ in f18.cpp (nfc)
Andrzej Warzynski [Thu, 14 Jan 2021 16:39:16 +0000 (16:39 +0000)]
[flang][driver] Use __FLANG_VERISION__ in f18.cpp (nfc)

Just a minor improvement suggested in a post-commit review here:
https://reviews.llvm.org/D94422

3 years agoRevert "[RISCV] Legalize select when Zbt extension available"
Sam Elliott [Thu, 14 Jan 2021 16:44:34 +0000 (16:44 +0000)]
Revert "[RISCV] Legalize select when Zbt extension available"

We found issues with this patch in additional testing. Backing out while
we work on a fix.

This reverts commit 71ed4b6ce57d8843ef705af8f98305976a8f107a.

3 years ago[clangd] Remove another option that was effectively always true. NFC
Sam McCall [Thu, 14 Jan 2021 16:19:39 +0000 (17:19 +0100)]
[clangd] Remove another option that was effectively always true. NFC

3 years ago[SystemZ] misched-cutoff tests can only be tested on non-NDEBUG (assertion) builds
Simon Pilgrim [Thu, 14 Jan 2021 15:46:09 +0000 (15:46 +0000)]
[SystemZ] misched-cutoff tests can only be tested on non-NDEBUG (assertion) builds

Fixes clang-with-thin-lto-ubuntu buildbot after D94383/rGddd03842c347

3 years ago[Support] Remove redundant sign bit tests from KnownBits::getSignedMinValue/getSigned...
Simon Pilgrim [Thu, 14 Jan 2021 15:39:55 +0000 (15:39 +0000)]
[Support] Remove redundant sign bit tests from KnownBits::getSignedMinValue/getSignedMaxValue

As noted by @foad on rG6895581fd2c1

3 years agoRevert "[AArch64] Attempt to sink mul operands"
Martin Storsjö [Thu, 14 Jan 2021 15:05:36 +0000 (17:05 +0200)]
Revert "[AArch64] Attempt to sink mul operands"

This reverts commit dda60035e9f0769c8907cdf6561489e0435c2275.

This commit caused failures to compile some sources, erroring out
with "error in backend: Cannot select: t85: v2i32 = AArch64ISD::DUP t15",
see https://reviews.llvm.org/D91271 for the full reproduction case.

3 years ago[TableGen] Enhance !cast<string> to handle bit and bits types.
Paul C. Anagnostopoulos [Tue, 12 Jan 2021 17:55:57 +0000 (12:55 -0500)]
[TableGen] Enhance !cast<string> to handle bit and bits types.

Add a test for this.

Differential Revision: https://reviews.llvm.org/D94529

3 years ago[Support] Simplify KnownBits::sextInReg implementation.
Simon Pilgrim [Thu, 14 Jan 2021 15:14:11 +0000 (15:14 +0000)]
[Support] Simplify KnownBits::sextInReg implementation.

As noted by @foad in rG9cf4f493a72f all we need to do is sextInReg both KnownBits One and Zero.

3 years ago[mlir][linalg] Add docstring support for named op spec
Lei Zhang [Thu, 14 Jan 2021 14:52:22 +0000 (09:52 -0500)]
[mlir][linalg] Add docstring support for named op spec

Depends on D94335

Reviewed By: nicolasvasilache, hanchung

Differential Revision: https://reviews.llvm.org/D94548

3 years ago[OpenCL] Improve online documentation.
Anastasia Stulova [Thu, 14 Jan 2021 14:52:54 +0000 (14:52 +0000)]
[OpenCL] Improve online documentation.

Update UsersManual and OpenCLSupport pages to reflect
recent functionality i.e. SPIR-V generation,
C++ for OpenCL, OpenCL 3.0 development plans.

Tags: #clang

Differential Revision: https://reviews.llvm.org/D93942

3 years ago[flang] Fix dangling pointer in LabelEnforce
Tim Keith [Thu, 14 Jan 2021 14:52:18 +0000 (06:52 -0800)]
[flang] Fix dangling pointer in LabelEnforce

`DirectiveStructureChecker` was passing in a pointer to a temporary
string for the `construct` argument to the constructor for `LabelEnforce`.
The `LabelEnforce` object had a lifetime longer than the temporary,
resulting in accessing a dangling pointer when emitting an error message
for `omp-parallell01.f90`.

The fix is to make the lifetime of the temporary as long as the lifetime
of the `LabelEnforce` object.

Differential Revision: https://reviews.llvm.org/D94618

3 years ago[Support] Ensure KnownBits::sextInReg can handle the src == dst sext-in-reg case.
Simon Pilgrim [Thu, 14 Jan 2021 14:50:09 +0000 (14:50 +0000)]
[Support] Ensure KnownBits::sextInReg can handle the src == dst sext-in-reg case.

This was resulting in assertions inside APInt::zext that we were extending to the same bitwidth.

3 years ago[docs] Update DebuggingJITedCode page after fix in LLDB
Stefan Gränitz [Thu, 14 Jan 2021 14:40:42 +0000 (15:40 +0100)]
[docs] Update DebuggingJITedCode page after fix in LLDB

Generalize the documentation to include both, GDB and LLDB. Add a link to the interface
definition. Make a note on MCJIT's restriction to ELF. Mention the regression and bugfix
in LLDB as well as the jit-loader setting for macOS. Update the command line session to
use LLDB instead of GDB.

Reviewed By: lhames

Differential Revision: https://reviews.llvm.org/D90789

3 years ago[Support] Add KnownBits::sextInReg exhaustive tests
Simon Pilgrim [Thu, 14 Jan 2021 14:18:55 +0000 (14:18 +0000)]
[Support] Add KnownBits::sextInReg exhaustive tests

Requested by @foad in rG9cf4f493a72f

3 years ago[Support] Simplify KnownBits::icmp helpers. NFC.
Jay Foad [Wed, 13 Jan 2021 13:51:09 +0000 (13:51 +0000)]
[Support] Simplify KnownBits::icmp helpers. NFC.

Remove some special cases that aren't really any simpler than the
general case.

Differential Revision: https://reviews.llvm.org/D94595

3 years ago[Analysis,CodeGen] Make use of KnownBits::makeConstant. NFC.
Jay Foad [Wed, 13 Jan 2021 11:25:35 +0000 (11:25 +0000)]
[Analysis,CodeGen] Make use of KnownBits::makeConstant. NFC.

Differential Revision: https://reviews.llvm.org/D94588

3 years ago[SelectionDAG] Make use of KnownBits::commonBits. NFC.
Jay Foad [Wed, 13 Jan 2021 10:57:20 +0000 (10:57 +0000)]
[SelectionDAG] Make use of KnownBits::commonBits. NFC.

Differential Revision: https://reviews.llvm.org/D94587

3 years ago[InferFunctionAttrs] Improve CHECK variable names (NFC).
Florian Hahn [Thu, 14 Jan 2021 12:55:17 +0000 (12:55 +0000)]
[InferFunctionAttrs] Improve CHECK variable names (NFC).

3 years ago[flang][driver] Unify f18_version.h.in and Version.inc.in
Andrzej Warzynski [Mon, 11 Jan 2021 16:16:29 +0000 (16:16 +0000)]
[flang][driver] Unify f18_version.h.in and Version.inc.in

Flang has two CMake configurable header files that define compiler
version numbers:
* f18_version.h.in - only used in f18.cpp (uses version numbers from
  LLVM's macro definitions)
* Version.inc.in - not currently used (uses version numbers hard-coded
  in Flang's top CMake script)

Currently only f18_version.h.in provides version numbers consistent with
other subprojects in llvm-project. However, its location and name are
inconsistent with e.g. Clang. This patch merges the two headers
together:
  * hard-coded version numbers in Flang's top CMake script are deleted
  * Version.inc.in is updated to provide string versions of version
  numbers (required by f18.cpp)
  * f18_version.h.in is deleted as it's no longer needed

Differential Revision: https://reviews.llvm.org/D94422

3 years ago[clang-tidy] Use DenseSet<SourceLocation> in UpgradeDurationConversionsCheck, NFCI
Mikhail Maltsev [Thu, 14 Jan 2021 13:50:16 +0000 (13:50 +0000)]
[clang-tidy] Use DenseSet<SourceLocation> in UpgradeDurationConversionsCheck, NFCI

This change replaces `unordered_set<unsigned>` (which used to store
internal representation of `SourceLocation`-s) with
`DenseSet<SourceLocation>` (which stores `SourceLocation`-s directly).

Reviewed By: aaron.ballman, njames93

Differential Revision: https://reviews.llvm.org/D94601

3 years agoRevert "Fix llvm::Optional build breaks in MSVC using std::is_trivially_copyable"
Alexandre Ganea [Thu, 14 Jan 2021 13:35:38 +0000 (08:35 -0500)]
Revert "Fix llvm::Optional build breaks in MSVC using std::is_trivially_copyable"

This reverts commit 854f0984f0b7ab9a9a541a4bcda7ea173e4113d3.

This breaks compilation with clang-cl on Windows, while in a MSVC 16.8 cmd.exe.
This also breaks PPC: http://lab.llvm.org:8011/#/builders/93/builds/1435
And: https://reviews.llvm.org/D93510#2497737

3 years ago[clang][cli] Port more CodeGenOptions to marshalling infrastructure
Jan Svoboda [Tue, 12 Jan 2021 11:35:50 +0000 (12:35 +0100)]
[clang][cli] Port more CodeGenOptions to marshalling infrastructure

Leveraging the recently added TableGen constructs (ShouldParseIf and MarshallingInfoStringInt) to shift from manual command line parsing to automatic TableGen-driver marshalling.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D94488

3 years ago[clang][cli] NFC: Remove SSPBufferSize assignment
Jan Svoboda [Thu, 14 Jan 2021 12:07:52 +0000 (13:07 +0100)]
[clang][cli] NFC: Remove SSPBufferSize assignment

This should've been part of D84669, but got overlooked. Removing the assignment is NFC, as it's also done by the marshalling infrastructure for the stack_protector_buffer_size option.

Reviewed By: dexonsmith in D94488

3 years agoChange XCore code owner.
Nigel Perks [Thu, 14 Jan 2021 12:13:48 +0000 (12:13 +0000)]
Change XCore code owner.

Discussion: https://lists.llvm.org/pipermail/llvm-dev/2021-January/147603.html

3 years ago[clangd] Add main file macros into the main-file index.
Aleksandr Platonov [Thu, 14 Jan 2021 08:35:38 +0000 (11:35 +0300)]
[clangd] Add main file macros into the main-file index.

This patch is a try to fix `WorkspaceSymbols.Macros` test after D93796.
If a macro definition is in the preamble section, then it appears to be in the preamble (static) index and not in the main-file (dynamic) index.
Thus, a such macro could not be found at a symbol search according to the logic that we skip symbols from the static index if the location of these symbols is inside the dynamic index files.
To fix this behavior this patch adds main file macros into the main-file (dynamic) index.

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D94477

3 years ago[DAG] visitVECTOR_SHUFFLE - MergeInnerShuffle - reset shuffle ops and reorder early...
Simon Pilgrim [Thu, 14 Jan 2021 11:52:29 +0000 (11:52 +0000)]
[DAG] visitVECTOR_SHUFFLE - MergeInnerShuffle - reset shuffle ops and reorder early-out and second op matching. NFCI.

I'm hoping to reuse MergeInnerShuffle in some other folds - so ensure the candidate ops/mask are reset at the start of each run.

Also, move the second op matching before bailing to make it simpler to try to match other things afterward.

3 years ago[lldb/test] Ensure launched processes are ready to be attached
Pavel Labath [Thu, 14 Jan 2021 10:53:53 +0000 (11:53 +0100)]
[lldb/test] Ensure launched processes are ready to be attached

Linux systems can be configured (and most of them are configured that
way) to disable attaching to unrelated processes, /unless/ those
processes explicitly allow that.

Our test inferiors do that by explicitly calling prctl(PR_SET_PTRACER,
PR_SET_PTRACER_ANY) (a.k.a., lldb_enable_attach). This requires
additional synchronization to ensure that the test does not attempt
attach before that statement is executed.

This is working fine (albeit cumbersome) for most tests but
TestGdbRemoteAttachWait is special in that it wants to start the
inferior _after_ issuing the attach request. This means that the usual
synchronization method does not work.

This patch introduces a different solution -- enable attaching in the
test harness, before the process is launched. Besides fixing this
problem, this is also better because it avoids the need to add special
code to each attach test (which is a common error).

One gotcha here is that it won't work for remote test suites, as we
don't control launching there. However, we could add a similar option to
lldb-platform, or require that lldb-platform itself is started with
attaching enabled. At that point we could delete all lldb_enable_attach
logic.

3 years ago[X86] Improve sum-of-reductions v4f32 test coverage
Simon Pilgrim [Thu, 14 Jan 2021 11:05:04 +0000 (11:05 +0000)]
[X86] Improve sum-of-reductions v4f32 test coverage

Ensure that the v4f32 reductions use a -0.0f start value and add fast-math test variant.

3 years ago[DAG] visitVECTOR_SHUFFLE - pull out shuffle merging code into lambda helper. NFCI.
Simon Pilgrim [Wed, 13 Jan 2021 18:00:25 +0000 (18:00 +0000)]
[DAG] visitVECTOR_SHUFFLE - pull out shuffle merging code into lambda helper. NFCI.

Make it easier to reuse in a future patch.

3 years ago[clang] Use SourceLocations in unions [NFCI]
Mikhail Maltsev [Thu, 14 Jan 2021 10:56:53 +0000 (10:56 +0000)]
[clang] Use SourceLocations in unions [NFCI]

Currently, there are many instances where `SourceLocation` objects are
converted to raw representation to be stored in structs that are
used as fields of tagged unions.

This is done to make the corresponding structs trivial.
Triviality allows avoiding undefined behavior when implicitly changing
the active member of the union.

However, in most cases, we can explicitly construct an active member
using placement new. This patch adds the required active member
selections and replaces `SourceLocation`-s represented as
`unsigned int` with proper `SourceLocation`-s.

One notable exception is `DeclarationNameLoc`: the objects of this class
are often not properly initialized (so the code currently relies on
its default constructor which uses memset). This class will be fixed
in a separate patch.

Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D94237

3 years ago[SLP] Don't vectorize stores of non-packed types (like i1, i2)
Bjorn Pettersson [Mon, 28 Dec 2020 13:28:55 +0000 (14:28 +0100)]
[SLP] Don't vectorize stores of non-packed types (like i1, i2)

In the spirit of commit fc783e91e0c0696e (llvm-svn: 248943) we
shouldn't vectorize stores of non-packed types (i.e. types that
has padding between consecutive variables in a scalar layout,
but being packed in a vector layout).

The problem was detected as a miscompile in a downstream test case.

Reviewed By: anton-afanasyev

Differential Revision: https://reviews.llvm.org/D94446

3 years ago[lld][WebAssembly] Add support for handling table symbols
Andy Wingo [Tue, 5 Jan 2021 11:08:58 +0000 (12:08 +0100)]
[lld][WebAssembly] Add support for handling table symbols

This commit adds table symbol support in a partial way, while still
including some special cases for the __indirect_function_table symbol.
No change in tests.

Differential Revision: https://reviews.llvm.org/D94075

3 years ago[LTO] Expose opt() in LTOBackend (NFC).
Florian Hahn [Thu, 14 Jan 2021 09:53:41 +0000 (09:53 +0000)]
[LTO] Expose opt() in LTOBackend (NFC).

Exposing opt() which runs middle-end LTO optimzation allows re-using it
in LTOCodeGenerator.

Reviewed By: steven_wu

Differential Revision: https://reviews.llvm.org/D94486

3 years ago[AArch64] Adding ACLE intrinsics for the LS64 extension
Lucas Prates [Thu, 10 Dec 2020 16:43:36 +0000 (16:43 +0000)]
[AArch64] Adding ACLE intrinsics for the LS64 extension

This introduces the ARMv8.7-A LS64 extension's intrinsics for 64 bytes
atomic loads and stores: `__arm_ld64b`, `__arm_st64b`, `__arm_st64bv`,
and `__arm_st64bv0`. These are selected into the LS64 instructions
LD64B, ST64B, ST64BV and ST64BV0, respectively.

Based on patches written by Simon Tatham.

Reviewed By: tmatheson

Differential Revision: https://reviews.llvm.org/D93232

3 years ago[NFC][AsmPrinter] Windows warning: Use explicit cast
David Stuttard [Wed, 13 Jan 2021 10:02:08 +0000 (10:02 +0000)]
[NFC][AsmPrinter] Windows warning: Use explicit cast

static_cast for uint64_t to unsigned gives a MS VC build warning
for Windows:

warning C4309: 'static_cast': truncation of constant value

Use an explicit cast instead.

Change-Id: I692d335b4913070686a102780c1fb05b893a2f69

Differential Revision: https://reviews.llvm.org/D94592

3 years ago[lldb] Fix TestPlatformProcessConnect.py
Pavel Labath [Wed, 6 Jan 2021 16:05:27 +0000 (17:05 +0100)]
[lldb] Fix TestPlatformProcessConnect.py

The test was marked as remote-only, which means it was run ~never, and
accumulated various problems. This commit modifies the test to run
locally and includes a couple of other fixes necessary to make it run:
- moves the "invoke" method into the "Base" test class
- adds []'s around the IP address in a couple more places to make things
  work with IPv6

The test is now marked as skipped when running the remote test suite. It
would be possible to make it run both locally and remotely, but this
would require writing a lot special logic for the remote case, and that
is not worth it.

3 years ago[mlir] Update doc to omit the usage of LLVMIntegerType
lewuathe [Thu, 14 Jan 2021 08:28:08 +0000 (09:28 +0100)]
[mlir] Update doc to omit the usage of LLVMIntegerType

Since [[ https://reviews.llvm.org/D94178 | the LLVMIntegerType was replaced with build-in integer type ]], the usage in the tutorial should be also updated accordingly.
We need to update chapter 6 for Toy tutorial specifically.

See: https://reviews.llvm.org/D94178

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D94651

3 years agoImplement vAttachWait in lldb-server
Augusto Noronha [Thu, 14 Jan 2021 08:24:31 +0000 (09:24 +0100)]
Implement vAttachWait in lldb-server

This commit vAttachWait in lldb-server, so --waitfor can be used on
Linux

Reviewed By: labath, clayborg

Differential Revision: https://reviews.llvm.org/D93895

3 years ago[lldb][wasm] Parse DWO section names
Philip Pfaffe [Thu, 14 Jan 2021 07:44:47 +0000 (08:44 +0100)]
[lldb][wasm] Parse DWO section names

Mirror ELF section parsing to support DWARF section names for
debug fission.

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D93621

3 years agoAdd func call so we don't instruction-step into the builtin_trap
Jason Molenda [Thu, 14 Jan 2021 07:39:32 +0000 (23:39 -0800)]
Add func call so we don't instruction-step into the builtin_trap

The way this test is structured right now, I set a breakpoint on
the instruction before the __builtin_trap.  It hits the breakpoint,
disables the breakpoint, and instruction steps.  This hits the
builtin_trap instruction which debugserver (on arm64) now advances
to the next instruction and reports that address to lldb.  lldb
doesn't recognize this as a proper response to the instruction
step and continues executing until the next trap, and the test fails.

3 years agoFix unused variable in CoroFrame.cpp when building Release with GCC 10
Daniel Paoliello [Thu, 14 Jan 2021 06:52:40 +0000 (22:52 -0800)]
Fix unused variable in CoroFrame.cpp when building Release with GCC 10

When building with GCC 10, the following warning is reported:

```
/llvm-project/llvm/lib/Transforms/Coroutines/CoroFrame.cpp:1527:28: warning: unused variable ‘CS’ [-Wunused-variable]
 1527 |       if (CatchSwitchInst *CS =
```

This change adds a cast to `void` to avoid the warning.

Reviewed By: lxfind

Differential Revision: https://reviews.llvm.org/D94456

3 years agoADT: Reduce code duplication in SmallVector by calling reserve and clear, NFC
Duncan P. N. Exon Smith [Thu, 14 Jan 2021 05:08:54 +0000 (21:08 -0800)]
ADT: Reduce code duplication in SmallVector by calling reserve and clear, NFC

3 years ago[Driver] -gsplit-dwarf: Produce .dwo regardless of -gN for -fthinlto-index=
Fangrui Song [Thu, 14 Jan 2021 05:01:53 +0000 (21:01 -0800)]
[Driver] -gsplit-dwarf: Produce .dwo regardless of -gN for -fthinlto-index=

-g is an IR generation option while -gsplit-dwarf is an object file generation option.
For -gsplit-dwarf in the backend phase of a distributed ThinLTO (-fthinlto-index=) which does object file generation and no IR generation, -g should not be needed.

This patch makes `-fthinlto-index= -gsplit-dwarf` emit .dwo even in the absence of -g.
This should fix https://crbug.com/1158215 after D80391.

```
// Distributed ThinLTO usage
clang -g -O2 -c -flto=thin -fthin-link-bitcode=a.indexing.o a.c
clang -g -O2 -c -flto=thin -fthin-link-bitcode=b.indexing.o b.c
clang -fuse-ld=lld -Wl,--thinlto-index-only=a.rsp -Wl,--thinlto-prefix-replace=';lto/' -Wl,--thinlto-object-suffix-replace='.indexing.o;.o' a.indexing.o b.indexing.o
clang -gsplit-dwarf -O2 -c -fthinlto-index=lto/a.o.thinlto.bc a.o -o lto/a.o
clang -gsplit-dwarf -O2 -c -fthinlto-index=lto/b.o.thinlto.bc b.o -o lto/b.o
clang -fuse-ld=lld @a.rsp -o exe
```

Note: for implicit regular/Thin LTO, .dwo emission works without this patch:
`clang -flto=thin -gsplit-dwarf a.o b.o` passes `-plugin-opt=dwo_dir=` to the linker.
The linker forwards the option to LTO. LTOBackend.cpp emits `$dwo_dir/[01234].dwo`.

Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D94647

3 years agoADT: Reduce code duplication in SmallVector by reusing reserve, NFC
Duncan P. N. Exon Smith [Wed, 23 Dec 2020 20:45:17 +0000 (12:45 -0800)]
ADT: Reduce code duplication in SmallVector by reusing reserve, NFC

3 years agoADT: Reduce code duplication in SmallVector::resize by using pop_back_n, NFC
Duncan P. N. Exon Smith [Wed, 23 Dec 2020 20:41:29 +0000 (12:41 -0800)]
ADT: Reduce code duplication in SmallVector::resize by using pop_back_n, NFC

3 years agoADT: Fix reference invalidation in SmallVector::resize
Duncan P. N. Exon Smith [Fri, 20 Nov 2020 01:12:27 +0000 (17:12 -0800)]
ADT: Fix reference invalidation in SmallVector::resize

For small enough, trivially copyable `T`, take the parameter by-value in
`SmallVector::resize`.  Otherwise, when growing, update the arugment
appropriately.

Differential Revision: https://reviews.llvm.org/D93781

3 years ago[NFC] Fix -Wsometimes-uninitialized
Jordan Rupprecht [Thu, 14 Jan 2021 04:30:25 +0000 (20:30 -0800)]
[NFC] Fix -Wsometimes-uninitialized

After 49142991a685bd427d7e877c29c77371dfb7634c, clang detects that MUL may be uninitialized. Set it to nullptr to suppress this check.

Adding an assert to check that it is ultimately set fails two test cases. Since this is not a new issue, leave the assertion commented out until a code owner can fix the bug. The two failing test cases are noted in the assertion comment.

3 years agoADT: Fix reference invalidation in N-element SmallVector::append and insert
Duncan P. N. Exon Smith [Fri, 20 Nov 2020 00:58:16 +0000 (16:58 -0800)]
ADT: Fix reference invalidation in N-element SmallVector::append and insert

For small enough, trivially copyable `T`, take the parameter by-value in
`SmallVector::append` and `SmallVector::insert`.  Otherwise, when
growing, update the arugment appropriately.

Differential Revision: https://reviews.llvm.org/D93780

3 years agoReapply "ADT: Fix reference invalidation in SmallVector::push_back and single-element...
Duncan P. N. Exon Smith [Thu, 14 Jan 2021 03:08:42 +0000 (19:08 -0800)]
Reapply "ADT: Fix reference invalidation in SmallVector::push_back and single-element insert"

This reverts commit 56d1ffb927d03958a7a31442596df749264a7792, reapplying
9abac60309006db00eca0af406c2e16bef26807c, removing insert_one_maybe_copy
and using a helper called forward_value_param instead. This avoids use
of `std::is_same` (or any SFINAE), so I'm hoping it's more portable and
MSVC will be happier.

Original commit message follows:

For small enough, trivially copyable `T`, take the argument by value in
`SmallVector::push_back` and copy it when forwarding to
`SmallVector::insert_one_impl`. Otherwise, when growing, update the
argument appropriately.

Differential Revision: https://reviews.llvm.org/D93779

3 years ago[llvm] Use std::any_of (NFC)
Kazu Hirata [Thu, 14 Jan 2021 03:14:44 +0000 (19:14 -0800)]
[llvm] Use std::any_of (NFC)

3 years ago[llvm] Use llvm::stable_sort (NFC)
Kazu Hirata [Thu, 14 Jan 2021 03:14:42 +0000 (19:14 -0800)]
[llvm] Use llvm::stable_sort (NFC)

3 years ago[llvm] Use *Set::contains (NFC)
Kazu Hirata [Thu, 14 Jan 2021 03:14:41 +0000 (19:14 -0800)]
[llvm] Use *Set::contains (NFC)

3 years agoRevert "ADT: Fix reference invalidation in SmallVector::push_back and single-element...
Duncan P. N. Exon Smith [Thu, 14 Jan 2021 03:02:22 +0000 (19:02 -0800)]
Revert "ADT: Fix reference invalidation in SmallVector::push_back and single-element insert"

This reverts commit 9abac60309006db00eca0af406c2e16bef26807c since there
are some bot errors on Windows:
http://lab.llvm.org:8011/#/builders/127/builds/4489

```
FAILED: lib/Support/CMakeFiles/LLVMSupport.dir/IntervalMap.cpp.obj
C:\PROGRA~2\MIB055~1\2017\PROFES~1\VC\Tools\MSVC\1416~1.270\bin\Hostx64\x64\cl.exe  /nologo /TP -DGTEST_HAS_RTTI=0 -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Ilib\Support -IC:\b\slave\sanitizer-windows\llvm-project\llvm\lib\Support -Iinclude -IC:\b\slave\sanitizer-windows\llvm-project\llvm\include /DWIN32 /D_WINDOWS   /Zc:inline /Zc:__cplusplus /Zi /Zc:strictStrings /Oi /Zc:rvalueCast /bigobj /W4 -wd4141 -wd4146 -wd4244 -wd4267 -wd4291 -wd4351 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091 -wd4592 -wd4319 -wd4709 -wd4324 -w14062 -we4238 /Gw /MD /O2 /Ob2 -UNDEBUG -std:c++14  /EHs-c- /GR- /showIncludes /Folib\Support\CMakeFiles\LLVMSupport.dir\IntervalMap.cpp.obj /Fdlib\Support\CMakeFiles\LLVMSupport.dir\LLVMSupport.pdb /FS -c C:\b\slave\sanitizer-windows\llvm-project\llvm\lib\Support\IntervalMap.cpp
C:\b\slave\sanitizer-windows\llvm-project\llvm\include\llvm/ADT/SmallVector.h(746): error C2672: 'llvm::SmallVectorImpl<T>::insert_one_maybe_copy': no matching overloaded function found
        with
        [
            T=llvm::IntervalMapImpl::Path::Entry
        ]
C:\b\slave\sanitizer-windows\llvm-project\llvm\include\llvm/ADT/SmallVector.h(745): note: while compiling class template member function 'llvm::IntervalMapImpl::Path::Entry *llvm::SmallVectorImpl<T>::insert(llvm::IntervalMapImpl::Path::Entry *,T &&)'
        with
        [
            T=llvm::IntervalMapImpl::Path::Entry
        ]
C:\b\slave\sanitizer-windows\llvm-project\llvm\lib\Support\IntervalMap.cpp(22): note: see reference to function template instantiation 'llvm::IntervalMapImpl::Path::Entry *llvm::SmallVectorImpl<T>::insert(llvm::IntervalMapImpl::Path::Entry *,T &&)' being compiled
        with
        [
            T=llvm::IntervalMapImpl::Path::Entry
        ]
C:\b\slave\sanitizer-windows\llvm-project\llvm\include\llvm/ADT/SmallVector.h(1136): note: see reference to class template instantiation 'llvm::SmallVectorImpl<T>' being compiled
        with
        [
            T=llvm::IntervalMapImpl::Path::Entry
        ]
C:\b\slave\sanitizer-windows\llvm-project\llvm\include\llvm/ADT/IntervalMap.h(790): note: see reference to class template instantiation 'llvm::SmallVector<llvm::IntervalMapImpl::Path::Entry,4>' being compiled
C:\b\slave\sanitizer-windows\llvm-project\llvm\include\llvm/ADT/SmallVector.h(746): error C2783: 'llvm::IntervalMapImpl::Path::Entry *llvm::SmallVectorImpl<T>::insert_one_maybe_copy(llvm::IntervalMapImpl::Path::Entry *,ArgType &&)': could not deduce template argument for '__formal'
        with
        [
            T=llvm::IntervalMapImpl::Path::Entry
        ]
C:\b\slave\sanitizer-windows\llvm-project\llvm\include\llvm/ADT/SmallVector.h(727): note: see declaration of 'llvm::SmallVectorImpl<T>::insert_one_maybe_copy'
        with
        [
            T=llvm::IntervalMapImpl::Path::Entry
        ]
```