platform/upstream/llvm.git
3 years ago[openmp][nfc] Refactor GridValues
Jon Chesterfield [Fri, 20 Aug 2021 15:41:25 +0000 (16:41 +0100)]
[openmp][nfc] Refactor GridValues

Remove redundant fields and replace pointer with virtual function

Of fourteen fields, three are dead and four can be computed from the
remainder. This leaves a couple of currently dead fields in place as
they are expected to be used from the deviceRTL shortly. Two of the
fields that can be computed are only used from codegen and require a
log2() implementation so are inlined into codegen instead.

This change leaves the new methods in the same location in the struct
as the previous fields for convenience at review.

Reviewed By: jdoerfert

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

3 years agoMake wide multi-character character literals ill-formed
Corentin Jabot [Fri, 20 Aug 2021 15:10:53 +0000 (11:10 -0400)]
Make wide multi-character character literals ill-formed

This implements P2362, which has not yet been approved by the
C++ committee, but because wide-multi character literals are
implementation defined, clang might not have to wait for WG21.

This change is also being applied in C mode as the behavior is
implementation-defined in C as well and there's no benefit to
having different rules between the languages.

The other part of P2362, making non-representable character
literals ill-formed, is already implemented by clang

3 years agoUse DeclContext::getNonTransparentContext(); NFC
Aaron Ballman [Fri, 20 Aug 2021 15:08:58 +0000 (11:08 -0400)]
Use DeclContext::getNonTransparentContext(); NFC

3 years ago[RISCV] Optimize add in the zba extension with SH*ADD
Ben Shi [Tue, 17 Aug 2021 08:40:16 +0000 (16:40 +0800)]
[RISCV] Optimize add in the zba extension with SH*ADD

Optimize (add x, c) to (SH*ADD (c>>b), x) if c is not simm12
while (c>>b) is simm12 and c has b trailing zeros.

Reviewed By: luismarques

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

3 years ago[libc++] Fix XFAIL annotation
Louis Dionne [Fri, 20 Aug 2021 14:17:21 +0000 (10:17 -0400)]
[libc++] Fix XFAIL annotation

The triple can sometimes be arm64-apple-macos, where the previous XFAIL
annotation wouldn't match (and hence the test would fail unexpectedly).

3 years ago[asan] Implemented getAddressSanitizerParams used by the ASan callback optimization...
Kirill Stoimenov [Thu, 19 Aug 2021 18:11:10 +0000 (18:11 +0000)]
[asan] Implemented getAddressSanitizerParams used by the ASan callback optimization code.

Reviewed By: vitalybuka

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

3 years ago[mlir][ods] Skip adding TOC in doc gen when present
Jacques Pienaar [Fri, 20 Aug 2021 14:01:54 +0000 (07:01 -0700)]
[mlir][ods] Skip adding TOC in doc gen when present

Enables adding a TOC in the description to be able to interleave
documentation before and after the TOC.

3 years ago[msan] Hotfix clang/test/CodeGen/sanitize-memory-disable.c
Alexander Potapenko [Fri, 20 Aug 2021 13:50:47 +0000 (15:50 +0200)]
[msan] Hotfix clang/test/CodeGen/sanitize-memory-disable.c

Because KMSAN is not supported on many architectures, explicitly build
the test with -target x86_64-linux-gnu.

Fixes the 'unsupported architecture' and 'unsupported operating system'
errors reported by the clang-armv7-quick (https://lab.llvm.org/buildbot#builders/171/builds/2595)
and llvm-clang-x86_64-sie-ubuntu-fast (https://lab.llvm.org/buildbot#builders/139/builds/9079)
builders.

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

3 years ago[CVP] add tests for unreachable switch default; NFC
Sanjay Patel [Fri, 20 Aug 2021 13:27:26 +0000 (09:27 -0400)]
[CVP] add tests for unreachable switch default; NFC
Goes with the proposal at D106056.

3 years ago[DebugInfo][InstrRef] Correctly ignore DBG_VALUE_LIST in InstrRef mode
Jeremy Morse [Fri, 20 Aug 2021 13:48:45 +0000 (14:48 +0100)]
[DebugInfo][InstrRef] Correctly ignore DBG_VALUE_LIST in InstrRef mode

This patch makes InstrRefBasedLDV "safe" to work with DBG_VALUE_LISTs. It
doesn't actually interpret them, but it recognises that they specify
variable locations and avoids propagating false locations, which is better
than the current state. Observe the attached tes

 * We avoid propagating DBG_VALUE_LISTs into successor blocks, as they're
   not "currently" supported,
 * We don't propagate other variable locations across DBG_VALUE_LISTs,
   because we know that the variable location is terminated by the
   DBG_VALUE_LIST.

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

3 years agoFix assertion when generating diagnostic for inline namespaces
Aaron Ballman [Fri, 20 Aug 2021 13:49:07 +0000 (09:49 -0400)]
Fix assertion when generating diagnostic for inline namespaces

When calculating the name to display for inline namespaces, we have
custom logic to try to hide redundant inline namespaces from the
diagnostic. Calculating these redundancies requires performing a lookup
in the parent declaration context, but that lookup should not try to
look through transparent declaration contexts, like linkage
specifications. Instead, loop up the declaration context chain until we
find a non-transparent context and use that instead.

This fixes PR49954.

3 years ago[CostModel][X86] Add costs for f32/f64 scalar and vector types.
Simon Pilgrim [Fri, 20 Aug 2021 13:30:48 +0000 (14:30 +0100)]
[CostModel][X86] Add costs for f32/f64 scalar and vector types.

The f16 half types are still pretty useless as we don't have it as a legal type (we treat them as i16 most of the time)

3 years agoMainSwitch::isValidSelectInst - don't dereference dyn_cast<> results.
Simon Pilgrim [Fri, 20 Aug 2021 12:59:55 +0000 (13:59 +0100)]
MainSwitch::isValidSelectInst - don't dereference dyn_cast<> results.

We've already checked that the pointer isa<PHINode>, so we can use cast<Instruction> safely.

Fixes static analyser warning.

3 years agoClangOffloadBundler - getCompatibleOffloadTargets - Fix unknown parameter Wdocumentat...
Simon Pilgrim [Fri, 20 Aug 2021 12:49:58 +0000 (13:49 +0100)]
ClangOffloadBundler - getCompatibleOffloadTargets - Fix unknown parameter Wdocumentation warnings. NFC.

3 years ago[DebugInfo][InstrRef] Remove a faulty assertion
Jeremy Morse [Fri, 20 Aug 2021 13:13:37 +0000 (14:13 +0100)]
[DebugInfo][InstrRef] Remove a faulty assertion

This patch removes an assertion, and adds a regression test showing why the
assertion is broken.

For context, LocIdx is a key/index number for machine locations, so that we
can describe locations as a single integer and ignore whether they're on
the stack, in registers or otherwise. Back when InstrRefBasedLDV was added,
I happened to bake in a "special" zero number for various reasons, which
Vedant identified as undesirable in this review comment:
https://reviews.llvm.org/D83047#inline-765495 . I subsequently removed that
special zero number, but it looks like I didn't delete this assertion at
the time, which assumes that a zero LocIdx is invalid.

The attached test shows that this assertion is reachable on valid code --
on x86 $rsp always gets the LocIdx number zero, and if you transfer a
variable value into it, InstrRefBasedLDV crashes on that assertion. The
code might be a bit wild to be storing variables to $rsp like that, however
we shouldn't crash on it.

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

3 years ago[msan] Add support for disable_sanitizer_instrumentation attribute
Alexander Potapenko [Tue, 17 Aug 2021 09:34:22 +0000 (11:34 +0200)]
[msan] Add support for disable_sanitizer_instrumentation attribute

Unlike __attribute__((no_sanitize("memory"))), this one will cause MSan
to skip the entire function during instrumentation.

Depends on https://reviews.llvm.org/D108029

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

3 years ago[libc] Align to 32B instead of 16B for optimized memcmp
Guillaume Chatelet [Fri, 20 Aug 2021 13:09:35 +0000 (13:09 +0000)]
[libc] Align to 32B instead of 16B for optimized memcmp

3 years ago[NewPM] Use parameterized syntax for a couple of more passes
Bjorn Pettersson [Wed, 18 Aug 2021 21:22:35 +0000 (23:22 +0200)]
[NewPM] Use parameterized syntax for a couple of more passes

A couple of passes that are parameterized in new-PM used different
pass names (in cmd line interface) while using the same pass class
name. This patch updates the PassRegistry to model pass parameters
more properly using PASS_WITH_PARAMS.

Reason for the change is to ensure that we have a 1-1 mapping
between class name and pass name (when disregarding the params).
With a 1-1 mapping it is more obvious which pass name to use in
options such as -debug-only, -print-after etc.

The opt -passes syntax is changed for the following passes:
  early-cse-memssa => early-cse<memssa>
  post-inline-ee-instrument => ee-instrument<post-inline>
  loop-extract-single => loop-extract<single>
  lower-matrix-intrinsics-minimal => lower-matrix-intrinsics<minimal>

This patch is not updating pass names in docs/Passes.rst. Not quite
sure what the status is for that document (e.g. when it comes to
listing pass paramters). It is only loop-extract-single that is
mentioned in Passes.rst today, out of the passes mentioned above.

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

3 years ago[libc++] Update credits.txt per coment on D108263
Louis Dionne [Fri, 20 Aug 2021 12:42:36 +0000 (08:42 -0400)]
[libc++] Update credits.txt per coment on D108263

3 years ago[libc++] Bypass calling exception-throwing functions in the dylib with -fno-exceptions
Louis Dionne [Thu, 19 Aug 2021 16:39:16 +0000 (12:39 -0400)]
[libc++] Bypass calling exception-throwing functions in the dylib with -fno-exceptions

basic_string and vector currently have a hard dependency on the compiled
library because they need to call __vector_base_common::__throw_xxx(),
which are externally instantiated in the compiled library. That makes
sense when exceptions are enabled (because we're trying to localize the
exception-throwing code to the compiled library), but it doesn't really
make sense when exceptions are disabled, and the __throw_xxx functions
are just calling abort() anyways.

This patch simply overrides the __throw_xxx() functions so that they
don't rely on the compiled library when exceptions are disabled.

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

3 years ago[clang][Codegen] Introduce the disable_sanitizer_instrumentation attribute
Alexander Potapenko [Fri, 13 Aug 2021 12:17:41 +0000 (14:17 +0200)]
[clang][Codegen] Introduce the disable_sanitizer_instrumentation attribute

The purpose of __attribute__((disable_sanitizer_instrumentation)) is to
prevent all kinds of sanitizer instrumentation applied to a certain
function, Objective-C method, or global variable.

The no_sanitize(...) attribute drops instrumentation checks, but may
still insert code preventing false positive reports. In some cases
though (e.g. when building Linux kernel with -fsanitize=kernel-memory
or -fsanitize=thread) the users may want to avoid any kind of
instrumentation.

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

3 years ago[clangd] detectClangPath() - remove (dead) return. NFC.
Simon Pilgrim [Fri, 20 Aug 2021 11:41:38 +0000 (12:41 +0100)]
[clangd] detectClangPath() - remove (dead) return. NFC.

3 years agoMemProfilerPass::run - remove (dead) duplicate return. NFC.
Simon Pilgrim [Fri, 20 Aug 2021 11:36:28 +0000 (12:36 +0100)]
MemProfilerPass::run - remove (dead) duplicate return. NFC.

3 years ago[AST] getDeclLocForCommentSearch - remove dead return. NFC.
Simon Pilgrim [Fri, 20 Aug 2021 11:32:12 +0000 (12:32 +0100)]
[AST] getDeclLocForCommentSearch - remove dead return. NFC.

Don't use an else-block as the previous if-block always returns, and remove the (now more obvious) dead return {}.

3 years agoRevert "[hwasan] do not check if freed pointer belonged to allocator."
Florian Mayer [Fri, 20 Aug 2021 11:20:40 +0000 (12:20 +0100)]
Revert "[hwasan] do not check if freed pointer belonged to allocator."

This reverts commit 119146f8ae25c31ea630a15761a6fba6b7eb909c.

3 years ago[Sema] Remove dead return immediately after another return. NFC.
Simon Pilgrim [Fri, 20 Aug 2021 11:10:47 +0000 (12:10 +0100)]
[Sema] Remove dead return immediately after another return. NFC.

3 years ago[mlir][linalg] Fix __repr__ implementation in const from opdsl
Denys Shabalin [Fri, 20 Aug 2021 10:35:09 +0000 (12:35 +0200)]
[mlir][linalg] Fix __repr__ implementation in const from opdsl

Reviewed By: gysit

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

3 years agoAArch64: don't form indexed paired ops if base reg overlaps operands.
Tim Northover [Fri, 20 Aug 2021 10:16:07 +0000 (11:16 +0100)]
AArch64: don't form indexed paired ops if base reg overlaps operands.

The registers involved might not be identical, but can still overlap (e.g.
"str w0, [x0, #4]!").

3 years ago[NFCI][SimplifyCFG] Rewrite `createUnreachableSwitchDefault()`
Roman Lebedev [Fri, 20 Aug 2021 10:17:56 +0000 (13:17 +0300)]
[NFCI][SimplifyCFG] Rewrite `createUnreachableSwitchDefault()`

The only thing that function should do as per it's semantic,
is to ensure that the switch's default is a block consisting only of
an `unreachable` terminator.

So let's just create such a block and update switch's default
to point to it. There should be no need for all this weird dance
around predecessors/successors.

3 years ago[AArch64] Enable Upper bound unrolling universally
Jingu Kang [Wed, 14 Jul 2021 10:43:29 +0000 (11:43 +0100)]
[AArch64] Enable Upper bound unrolling universally

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

3 years ago[RISCV] Fix reporting of incorrect commutable operand indices
Fraser Cormack [Tue, 17 Aug 2021 14:01:19 +0000 (15:01 +0100)]
[RISCV] Fix reporting of incorrect commutable operand indices

This patch fixes an issue where RISCV's `findCommutedOpIndices` would
incorrectly return the pseudo `CommuteAnyOperandIndex` as a commutable
operand index, rather than fixing a specific index.

Reviewed By: rogfer01

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

3 years agoRevert "[flang] Refine output file generation"
Andrzej Warzynski [Fri, 20 Aug 2021 09:11:19 +0000 (09:11 +0000)]
Revert "[flang] Refine output file generation"

This reverts commit fd21d1e198e381a2b9e7af1701044462b2d386cd.

The test added in this patch [1] is failing on Windows and causing the
Windows BuildBot [2] to fail. I don't see any obvious way to fix this,
so reverting in order to investigate.

[1] llvm-project/flang/test/Driver/output-paths.f90
[2] https://lab.llvm.org/buildbot/#/builders/172/builds/2077

3 years ago[mlir] Fix ControlFlowInterfaces implementation for Async dialect
Vladislav Vinogradov [Thu, 19 Aug 2021 13:28:16 +0000 (16:28 +0300)]
[mlir] Fix ControlFlowInterfaces implementation for Async dialect

* Add `RegionBranchTerminatorOpInterface` to `YieldOp`.
* Implement `getSuccessorEntryOperands` in `ExecuteOp`.
* Fix `getSuccessorRegions` implementation in `ExecuteOp`.

Reviewed By: ezhulenev

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

3 years ago[hwasan] do not check if freed pointer belonged to allocator.
Florian Mayer [Thu, 19 Aug 2021 15:52:45 +0000 (16:52 +0100)]
[hwasan] do not check if freed pointer belonged to allocator.

In that case it is very likely that there will be a tag mismatch anyway.

We handle the case that the pointer belongs to neither of the allocators
by getting a nullptr from allocator.GetBlockBegin.

Reviewed By: hctim, eugenis

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

3 years ago[OpenMP][OMPD]Code movement required for OMPD
Vignesh Balasubramanian [Thu, 19 Aug 2021 07:16:07 +0000 (12:46 +0530)]
[OpenMP][OMPD]Code movement required for OMPD

These changes don't come under OMPD guard as it is a movement of existing code to capture parallel behavior correctly.
"Runtime Entry Points for OMPD" like "ompd_bp_parallel_begin" and "ompd_bp_parallel_begin" should be placed at the correct execution point for the debugging tool to access proper handles/data.
Without the below changes, in certain cases, debugging tool will pick the wrong parallel and task handle.

Reviewed By: @hbae
Differential Revision: https://reviews.llvm.org/D100366

3 years ago[mlir][NFC] Use explicit ::mlir namespace in mlir-tblgen generated code
Vladislav Vinogradov [Thu, 19 Aug 2021 14:33:58 +0000 (17:33 +0300)]
[mlir][NFC] Use explicit ::mlir namespace in mlir-tblgen generated code

Reviewed By: mehdi_amini

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

3 years agoPrecommit test for D108204
Jingu Kang [Fri, 20 Aug 2021 07:46:32 +0000 (08:46 +0100)]
Precommit test for D108204

3 years ago[OpenCL] Fix version reporting of C++ for OpenCL 2021
Justas Janickas [Thu, 19 Aug 2021 14:43:32 +0000 (15:43 +0100)]
[OpenCL] Fix version reporting of C++ for OpenCL 2021

C++ for OpenCL version 2021 and later are expected to consist of a
major version number only. Therefore, a different constructor for
`VersionTuple` needs to be called when reporting language version.

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

3 years ago[docs] Clarify how to run cmake and llvm-lit with Visual Studio addressing PR45978
Yaron Keren [Fri, 20 Aug 2021 05:28:45 +0000 (08:28 +0300)]
[docs] Clarify how to run cmake and llvm-lit with Visual Studio addressing PR45978

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

3 years ago[AST] Avoid single-trip loop in ClangAttrEmitter
Sam McCall [Fri, 20 Aug 2021 06:49:25 +0000 (08:49 +0200)]
[AST] Avoid single-trip loop in ClangAttrEmitter

This triggers coverity warnings, see https://reviews.llvm.org/D107703

3 years ago[flang] Refine output file generation
Andrzej Warzynski [Wed, 18 Aug 2021 16:14:09 +0000 (16:14 +0000)]
[flang] Refine output file generation

This patch refactors the file generation API in Flang's frontend driver.
It improves the layering between `CreateDefaultOutputFile`,
`CreateOutputFile` (`CompilerInstance` methods) and their various
clients.

List of changes:
* Rename `CreateOutputFile` as `CreateOutputFileImpl` and make it
private. This method is an implementation detail.
* Instead of passing an `std::error_code` out parameter into
`CreateOutputFileImpl`, have it return Expected<>. This is a bit shorter
and more idiomatic LLVM.
* Make `CreateDefaultOutputFile` (which calls `CreateOutputFileImpl`)
issue an error when file creation fails. The error code from
`CreateOutputFileImpl` is used to generate a meaningful diagnostic
message.
* Remove error reporting from `PrintPreprocessedAction::ExecuteAction`.
This is only for cases when output file generation fails. This is
handled in `CreateDefaultOutputFile` instead (see the previous point).
* Inline `AddOutputFile` into its only caller,
`CreateDefaultOutputFile`.
* Switch from `lvm::buffer_ostream` to `llvm::buffer_unique_ostream>`
for non-seekable output streams. This simplifies the logic in the driver
and was introduced for this very reason in [1]
* Moke sure that the diagnostics from the prescanner when running `-E`
(`PrintPreprocessedAction::ExecuteAction`) are printed before the actual
output is generated.
* Update comments, add test.

[1] https://reviews.llvm.org/D93260

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

3 years ago[libc] Add an optimized version for memcmp
Guillaume Chatelet [Thu, 19 Aug 2021 20:58:15 +0000 (20:58 +0000)]
[libc] Add an optimized version for memcmp

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

3 years ago[DWARF] Remove parseListTableHeader (NFC)
Kazu Hirata [Fri, 20 Aug 2021 06:34:22 +0000 (23:34 -0700)]
[DWARF] Remove parseListTableHeader (NFC)

The last use was removed on Oct 4, 2020 in commit
6d0be74af5555f7bc56ac72cbd98ff270fd1291b.

3 years ago[AMDGPU] Fix too many constants with flat scratch
Sebastian Neubauer [Thu, 19 Aug 2021 11:55:03 +0000 (13:55 +0200)]
[AMDGPU] Fix too many constants with flat scratch

Prevent SIFoldOperands from creating SALU instructions with a constant
and a frame index. Previously, only one operand was checked to be a
frame index, leading to too many constants when flat scratch is enabled
and stack offsets are large.

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

3 years ago[gn build] Port e6407356ba00
LLVM GN Syncbot [Fri, 20 Aug 2021 06:14:22 +0000 (06:14 +0000)]
[gn build] Port e6407356ba00

3 years ago[builtins] Move Windows/ARM frontends for fix/float functions into the individual...
Martin Storsjö [Tue, 10 Aug 2021 10:27:08 +0000 (13:27 +0300)]
[builtins] Move Windows/ARM frontends for fix/float functions into the individual source files

This avoids pulling in all of them if only one of them is needed
(if builtins are built without -ffunction-sections), and matches how
the similar aliases for AEABI are set up.

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

3 years agoUpdate bazel examples.
Christian Sigg [Thu, 19 Aug 2021 07:43:54 +0000 (09:43 +0200)]
Update bazel examples.

Use the simplified repo rules from https://github.com/llvm/llvm-project/commit/934f084.

Reviewed By: GMNGeoffrey

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

3 years ago[HIP] Allow target addr space in target builtins
Anshil Gandhi [Fri, 20 Aug 2021 05:25:34 +0000 (23:25 -0600)]
[HIP] Allow target addr space in target builtins

This patch allows target specific addr space in target builtins for HIP. It inserts implicit addr
space cast for non-generic pointer to generic pointer in general, and inserts implicit addr
space cast for generic to non-generic for target builtin arguments only.

It is NFC for non-HIP languages.

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

3 years agolibclc: Fix rounding during type conversion
Daniel Stone [Fri, 20 Aug 2021 05:24:19 +0000 (22:24 -0700)]
libclc: Fix rounding during type conversion

The rounding during type conversion uses multiple conversions, selecting
between them to try to discover if rounding occurred. This appears to
not have been tested, since it would generate code of the form:
    float convert_float_rtp(char x)
    {
      float r = convert_float(x);
      char y = convert_char(y);
      [...]
    }

which will access uninitialised data. The idea appears to have been to
have done a char -> float -> char roundtrip in order to discover the
rounding, so do this.

Discovered by inspection.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed By: jvesely

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

3 years ago[gn build] Port 642885710e20
LLVM GN Syncbot [Fri, 20 Aug 2021 05:16:08 +0000 (05:16 +0000)]
[gn build] Port 642885710e20

3 years ago[ORC] Add 'Async' suffix to ExecutorProcessControl::MemoryAccess methods.
Lang Hames [Fri, 20 Aug 2021 05:07:51 +0000 (15:07 +1000)]
[ORC] Add 'Async' suffix to ExecutorProcessControl::MemoryAccess methods.

This prevents the async methods (which shoud be overridden by subclasses) from
hiding the blocking helper methods, avoiding a lot of 'using MemoryAccess::...'
boilerplate.

3 years ago[ORC] Introduce lookupAndRecordAddrs utility.
Lang Hames [Thu, 19 Aug 2021 11:30:29 +0000 (21:30 +1000)]
[ORC] Introduce lookupAndRecordAddrs utility.

Accepts a vector of (SymbolStringPtr, ExecutorAddress*) pairs, looks up all the
symbols, then writes their address to each of the corresponding
ExecutorAddresses.

This idiom (looking up and recording addresses into a specific set of variables)
is used in MachOPlatform and the (temporarily reverted) ELFNixPlatform, and is
likely to be used in other places in the near future, so wrapping it in a
utility function should save us some boilerplate.

3 years ago[libc] Add bcmp to the windows config.
Siva Chandra Reddy [Fri, 20 Aug 2021 04:50:50 +0000 (04:50 +0000)]
[libc] Add bcmp to the windows config.

3 years ago[NFC][AggressiveInstCombine] Simplify code for shift truncation
Anton Afanasyev [Thu, 19 Aug 2021 16:33:54 +0000 (19:33 +0300)]
[NFC][AggressiveInstCombine] Simplify code for shift truncation

3 years ago[Test][AggressiveInstCombine] Split shift tests to `shl`, `lshr` and `ashr`
Anton Afanasyev [Fri, 20 Aug 2021 03:33:19 +0000 (06:33 +0300)]
[Test][AggressiveInstCombine] Split shift tests to `shl`, `lshr` and `ashr`

3 years ago[Test][AggressiveInstCombine] Add test for arithmetic shift
Anton Afanasyev [Thu, 19 Aug 2021 06:53:13 +0000 (09:53 +0300)]
[Test][AggressiveInstCombine] Add test for arithmetic shift

3 years ago[Remarks] [AMDGPU] Emit optimization remarks for atomics generating hardware instructions
Anshil Gandhi [Fri, 20 Aug 2021 02:50:36 +0000 (20:50 -0600)]
[Remarks] [AMDGPU] Emit optimization remarks for atomics generating hardware instructions

Produce remarks when atomic instructions are expanded into hardware instructions
in SIISelLowering.cpp. Currently, these remarks are only emitted for atomic fadd
instructions.

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

3 years ago[PowerPC] Implement cmplxl builtins
Albion Fung [Fri, 20 Aug 2021 02:36:43 +0000 (21:36 -0500)]
[PowerPC] Implement cmplxl builtins

This patch implements the builtins for cmplxl by utilising
__builtin_complex. This builtin is implemented to match XL
functionality.

Differential revision: https://reviews.llvm.org/D107138

3 years ago[mlir][tosa] Support UInt8 inputs and outputs for tosa.rescale
Rob Suderman [Fri, 20 Aug 2021 00:02:43 +0000 (17:02 -0700)]
[mlir][tosa] Support UInt8 inputs and outputs for tosa.rescale

Tosa rescale can contain uint8 types. Added support for these types
using an unrealized conversion cast. Optimistically it would be better to
use bitcast however it does not support unsigned integers.

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

3 years ago[AIX][XCOFF] 64-bit relocation reading support
Maryam Benimmar [Tue, 17 Aug 2021 18:22:29 +0000 (14:22 -0400)]
[AIX][XCOFF] 64-bit relocation reading support

Support XCOFFDumper relocation reading support
This patch is part of D103696 partition

Reviewed By: daltenty, Helflym

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

3 years ago[CRT][LIT] split target_cflags using shlex
Jinsong Ji [Thu, 19 Aug 2021 17:24:13 +0000 (13:24 -0400)]
[CRT][LIT]  split target_cflags using shlex

Update the commit to use shlex.split, as the win32 is not supported.

See https://reviews.llvm.org/D108329 for discussions.

3 years ago[DebugInfo] convert btf_tag attrs to annotations for DIComposite types
Yonghong Song [Thu, 19 Aug 2021 22:23:09 +0000 (15:23 -0700)]
[DebugInfo] convert btf_tag attrs to annotations for DIComposite types

Clang patch D106614 added attribute btf_tag support. This patch
generates btf_tag annotations for DIComposite types.
Each btf_tag annotation is represented as a 2D array of
meta strings. Each record may have more than one
btf_tag annotations.

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

3 years ago[OpenMP] Use `__kmpc_give_task` in `__kmp_push_task` when encountering a hidden helpe...
Shilei Tian [Fri, 20 Aug 2021 00:49:16 +0000 (20:49 -0400)]
[OpenMP] Use `__kmpc_give_task` in `__kmp_push_task` when encountering a hidden helper task

This patch replaces the current implementation, overwrites `gtid` and `thread`,
with `__kmpc_give_task`.

Reviewed By: AndreyChurbanov

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

3 years agoReland [DebugInfo] generate btf_tag annotations for DIComposite types
Yonghong Song [Mon, 19 Jul 2021 06:43:48 +0000 (23:43 -0700)]
Reland [DebugInfo] generate btf_tag annotations for DIComposite types

Clang patch D106614 added attribute btf_tag support. This patch
generates btf_tag annotations for DIComposite types.
A field "annotations" is introduced to DIComposite, and the
annotations are represented as an DINodeArray, similar to
DIComposite elements. The following example illustrates
how annotations are encoded in IR:
  distinct !DICompositeType(..., annotations: !10)
  !10 = !{!11, !12}
  !11 = !{!"btf_tag", !"a"}
  !12 = !{!"btf_tag", !"b"}
Each btf_tag annotation is represented as a 2D array of
meta strings. Each record may have more than one
btf_tag annotations, as in the above example.

Reland with additional fixes for llvm/unittests/IR/DebugTypeODRUniquingTest.cpp.

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

3 years ago[GlobalISel] Add IRTranslator support for @llvm.lround.* -> G_LROUND
Jessica Paquette [Thu, 19 Aug 2021 22:49:38 +0000 (15:49 -0700)]
[GlobalISel] Add IRTranslator support for @llvm.lround.* -> G_LROUND

Translate the `@llvm.lround.*` family to G_LROUND via
`IRTranslator::translateSimpleIntrinsic`.

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

3 years ago[GlobalISel] Add a G_LROUND instruction
Jessica Paquette [Thu, 19 Aug 2021 22:41:36 +0000 (15:41 -0700)]
[GlobalISel] Add a G_LROUND instruction

Meant to represent the `@llvm.lround.*` family.

Add the opcode, docs, and verification.

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

3 years ago[libomptarget][amdcgn] Add build dependency for llvm-link and opt
Joachim Protze [Thu, 19 Aug 2021 21:28:51 +0000 (23:28 +0200)]
[libomptarget][amdcgn] Add build dependency for llvm-link and opt

D107156 and D107320 are not sufficient when OpenMP is built as llvm runtime
(LLVM_ENABLE_RUNTIMES=openmp) because dependencies only work within the same
cmake instance.

We could limit the dependency to cases where libomptarget/plugins are really
built. But compared to the whole llvm project, building openmp runtime is
negligible and postponing the build of OpenMP runtime after the dependencies
are ready seems reasonable.

The direct dependency introduced in D107156 and D107320 is necessary for the
case where OpenMP is built as llvm project (LLVM_ENABLE_PROJECTS=openmp).

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

3 years agoRevert "[InstrProfiling] Make COFF use the ELF comdat scheme (drop link.exe compatibi...
Fangrui Song [Thu, 19 Aug 2021 23:42:57 +0000 (16:42 -0700)]
Revert "[InstrProfiling] Make COFF use the ELF comdat scheme (drop link.exe compatibility)"

This reverts commit fbb8e772ec501a1b71643db90e9c6445e17d7cac.

Accidentally pushed.

3 years ago[AArch64][GlobalISel] Add G_VECREDUCE fewerElements support for full scalarization.
Amara Emerson [Wed, 18 Aug 2021 07:19:58 +0000 (00:19 -0700)]
[AArch64][GlobalISel] Add G_VECREDUCE fewerElements support for full scalarization.

For some reductions like G_VECREDUCE_OR on AArch64, we need to scalarize
completely if the source is <= 64b. This change adds support for that in
the legalizer. If the source has a pow-2 num elements, then we can do
a tree reduction using the scalar operation in the individual elements.
Otherwise, we just create a sequential chain of operations.

For AArch64, we only need to scalarize if the input is <64b. If it's great than
64b then we can first do a fewElements step to 64b, taking advantage of vector
instructions until we reach the point of scalarization.

I also had to relax the verifier checks for reductions because the intrinsics
support <1 x EltTy> types, which we lower to scalars for GlobalISel.

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

3 years ago[InstrProfiling] Make COFF use the ELF comdat scheme (drop link.exe compatibility)
Fangrui Song [Thu, 19 Aug 2021 23:38:32 +0000 (16:38 -0700)]
[InstrProfiling] Make COFF use the ELF comdat scheme (drop link.exe compatibility)

The COFF specific `DataReferencedByCode` complexity (D103372 D103717) is due to
a link.exe limitation: an external symbol in IMAGE_COMDAT_SELECT_ASSOCIATIVE is
not really dropped, so it can cause duplicate definition error.

3 years ago[test] Split icall.ll into comdat/nocomdat variants
Fangrui Song [Thu, 19 Aug 2021 23:36:58 +0000 (16:36 -0700)]
[test] Split icall.ll into comdat/nocomdat variants

darwin/aix don't support comdat. Using IR comdat is incorrect.

3 years ago[lld][WebAssembly] Handle weakly defined symbols in shared libraries.
Sam Clegg [Wed, 18 Aug 2021 16:57:34 +0000 (12:57 -0400)]
[lld][WebAssembly] Handle weakly defined symbols in shared libraries.

In the case of weakly defined symbols in shared libraries we now
generate both an import and an export.  The dynamic linker can then
choose how a winner from among all the shared libraries that define a
given symbol.

Previously any direct usage of a weakly defined symbol would use the
DSO-local definition (For example, even through there would be single
address for a weakly defined function, each DSO could end up directly
calling its local version).

Fixes: https://github.com/emscripten-core/emscripten/issues/13773

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

3 years ago[WebAssembly] Make bitmask instructions return unsigned ints
Thomas Lively [Thu, 19 Aug 2021 23:23:47 +0000 (16:23 -0700)]
[WebAssembly] Make bitmask instructions return unsigned ints

Since they are bitmasks, it will be more common for them to be used and
potentially extended to 64-bit integers as unsigned values rather than signed
values.

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

3 years ago[AArch64][GlobalISel] Fix miscompile of <16 x s8> G_EXTRACT_VECTOR_ELT.
Amara Emerson [Thu, 19 Aug 2021 22:45:50 +0000 (15:45 -0700)]
[AArch64][GlobalISel] Fix miscompile of <16 x s8> G_EXTRACT_VECTOR_ELT.

When support for copying vector s8 lanes was added recently, this also
had the side effect of fixing a fallback for <16 x s8> extracts since
both used the same helper. However, there was a bug in another helper
to get the regclass for a specific FPR-native type, which was assigning
FPR16 to s8 instead of FPR8.

3 years ago[libc++][NFC] Update and alphabetize CREDITS.TXT
Kent Ross [Thu, 19 Aug 2021 23:12:37 +0000 (23:12 +0000)]
[libc++][NFC] Update and alphabetize CREDITS.TXT

Reviewed By: ldionne, #libc

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

3 years ago[libc++] [doc] Add issue tracking for spaceship operator<=> implementation
Kent Ross [Thu, 19 Aug 2021 23:10:47 +0000 (23:10 +0000)]
[libc++] [doc] Add issue tracking for spaceship operator<=> implementation

Add issue tracking and assignment for the implementation of P1614R2: The Mothership has Landed.

Reviewed By: cjdb, #libc, Mordante, Quuxplusone

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

3 years ago[libc++][NFC] Remove unused include in <compare>.
Kent Ross [Thu, 19 Aug 2021 23:06:52 +0000 (23:06 +0000)]
[libc++][NFC] Remove unused include in <compare>.

`<type_traits>` was included in the first iteration of `<compare>` when
it was created as a monolithic header, then never removed. Removing it
now is a beneficial no-op since it is not guaranteed by the standard
and is already included by all of its subheaders.

Reviewed By: cjdb, #libc, Quuxplusone

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

3 years ago[WebAssembly] Add explicit casts to silence -Wc++11-narrowing
Thomas Lively [Thu, 19 Aug 2021 23:00:07 +0000 (16:00 -0700)]
[WebAssembly] Add explicit casts to silence -Wc++11-narrowing

3 years agoRevert "[DebugInfo] generate btf_tag annotations for DIComposite types"
Yonghong Song [Thu, 19 Aug 2021 22:54:38 +0000 (15:54 -0700)]
Revert "[DebugInfo] generate btf_tag annotations for DIComposite types"

This reverts commit 2fded193e7a8fb5bd8fb339f00fd9de686390530.

Builtbot reports some test failures. Revert now so I can take time
to fix the issues.

3 years ago[DebugInfo] generate btf_tag annotations for DIComposite types
Yonghong Song [Mon, 19 Jul 2021 06:43:48 +0000 (23:43 -0700)]
[DebugInfo] generate btf_tag annotations for DIComposite types

Clang patch D106614 added attribute btf_tag support. This patch
generates btf_tag annotations for DIComposite types.
A field "annotations" is introduced to DIComposite, and the
annotations are represented as an DINodeArray, similar to
DIComposite elements. The following example illustrates
how annotations are encoded in IR:
  distinct !DICompositeType(..., annotations: !10)
  !10 = !{!11, !12}
  !11 = !{!"btf_tag", !"a"}
  !12 = !{!"btf_tag", !"b"}
Each btf_tag annotation is represented as a 2D array of
meta strings. Each record may have more than one
btf_tag annotations, as in the above example.

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

3 years ago[WebAssembly] More convert_low and promote_low codegen
Thomas Lively [Thu, 19 Aug 2021 22:37:12 +0000 (15:37 -0700)]
[WebAssembly] More convert_low and promote_low codegen

The convert_low and promote_low instructions can widen the lower two lanes of a
four-lane vector, but we were previously scalarizing patterns that widened lanes
besides the low two lanes. The commit adds a shuffle to move the widened lanes
into the low lane positions so the convert_low and promote_low instructions can
be used instead of scalarizing.

Depends on D108266.

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

3 years ago[WebAssembly] Pattern match SIMD convert_low and promote_low during ISel
Thomas Lively [Thu, 19 Aug 2021 22:24:28 +0000 (15:24 -0700)]
[WebAssembly] Pattern match SIMD convert_low and promote_low during ISel

Since the simplest DAG patterns for convert_low and promote_low instructions
involved v2i32, v2f32, v4i64, and v4f64 types, which are not legal in the
WebAssembly backend and would be eliminated by type legalization, we were
previously matching those patterns in a DAG combine before the type legalization
stage. However in cases where the vectors were wider than 128 bits, the patterns
we matched were not created until the type legalization stage when the wide
vectors were split up. Type legalization would continue to eliminate the illegal
types we were matching as well, so the code ended up scalarized.

To make the ISel for these instructions more robust, match the scalarized
patterns rather than the patterns containing illegal types. Add tests with
double-wide vectors to show that this works as intended.

Fixes PR51098.
Depends on D107502.

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

3 years agoRefactor inlineRetainOrClaimRVCalls. NFC
Akira Hatanaka [Thu, 19 Aug 2021 21:55:45 +0000 (14:55 -0700)]
Refactor inlineRetainOrClaimRVCalls. NFC

This is in preparation for committing https://reviews.llvm.org/D103000.

3 years agoUpdate logic to close inherited file descriptors.
Rumeet Dhindsa [Thu, 19 Aug 2021 21:38:04 +0000 (14:38 -0700)]
Update logic to close inherited file descriptors.

This patch adds the support to close all inherited fds into the child
process by iterating over /proc/self/fd entries.

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

3 years ago[NFC] Cleanup AttributeList::getStackAlignment()
Arthur Eubanks [Thu, 19 Aug 2021 21:20:59 +0000 (14:20 -0700)]
[NFC] Cleanup AttributeList::getStackAlignment()

So that we don't use a confusing index.

3 years ago[Support] Update `MD5` to follow other hashes.
Alexandre Rames [Wed, 18 Aug 2021 22:27:08 +0000 (15:27 -0700)]
[Support] Update `MD5` to follow other hashes.

Introduce `StringRef final()` and `StringRef result()`.

Reviewed By: dexonsmith

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

3 years ago[NFC] Replace some attribute methods that use confusing indexes
Arthur Eubanks [Thu, 19 Aug 2021 21:02:11 +0000 (14:02 -0700)]
[NFC] Replace some attribute methods that use confusing indexes

3 years ago[NFC][Support] Move `MD5` members in `InternalState`.
Alexandre Rames [Thu, 19 Aug 2021 17:09:53 +0000 (10:09 -0700)]
[NFC][Support] Move `MD5` members in `InternalState`.

This prepares an update to follow other hashes.

Reviewed By: dexonsmith

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

3 years ago[MLIR][SCF] Parenthesize multiple return types in scf.execute_region asm op
Morten Borup Petersen [Thu, 19 Aug 2021 19:34:43 +0000 (20:34 +0100)]
[MLIR][SCF] Parenthesize multiple return types in scf.execute_region asm op

Previously, ExecuteRegionOps with multiple return values would fail a round-trip test due to missing parenthesis around the types.

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

3 years ago[hwasan] re-enable stack safety by default.
Florian Mayer [Thu, 19 Aug 2021 15:37:02 +0000 (16:37 +0100)]
[hwasan] re-enable stack safety by default.

The failed assertion was fixed in D108337.

Reviewed By: vitalybuka, eugenis

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

3 years agoAdd implicit map for a list item appears in a reduction clause.
Jennifer Yu [Mon, 16 Aug 2021 14:18:34 +0000 (07:18 -0700)]
Add implicit map for a list item appears in a reduction clause.

A new rule is added in 5.0:
If a list item appears in a reduction, lastprivate or linear clause
on a combined target construct then it is treated as if it also appears
in a map clause with a map-type of tofrom.

Currently map clauses for all capture variables are added implicitly.
But missing for list item of expression for array elements or array
sections.

The change is to add implicit map clause for array of elements used in
reduction clause. Skip adding map clause if the expression is not
mappable.
Noted: For linear and lastprivate, since only variable name is
accepted, the map has been added though capture variables.

To do so:
During the mappable checking, if error, ignore diagnose and skip
adding implicit map clause.

The changes:
1> Add code to generate implicit map in ActOnOpenMPExecutableDirective,
   for omp 5.0 and up.
2> Add extra default parameter NoDiagnose in ActOnOpenMPMapClause:
Use that to skip error as well as skip adding implicit map during the
mappable checking.

Note: there are only tow places need to be check for NoDiagnose. Rest
of them either the check is for < omp 5.0 or the error already generated for
reduction clause.

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

3 years ago[openmp] Disable the tests that block CI for amdgpu and host offloading.
Jon Chesterfield [Thu, 19 Aug 2021 19:43:05 +0000 (20:43 +0100)]
[openmp] Disable the tests that block CI for amdgpu and host offloading.

3 years agoMove function definition out-of-line to fix the modularized build (NFC)
Adrian Prantl [Thu, 19 Aug 2021 19:24:36 +0000 (12:24 -0700)]
Move function definition out-of-line to fix the modularized build (NFC)

3 years ago[WebAssembly] Legalize vector types by widening
Thomas Lively [Thu, 19 Aug 2021 19:07:32 +0000 (12:07 -0700)]
[WebAssembly] Legalize vector types by widening

The default legalization of unsupported vector types is to promote the integers
in each lane, which leads to extra sign or zero extending and masking when
moving data into and out of vectors. Switch our preferred type legalization from
the default to vector widening, which keeps the data in the low lanes of the
vector rather than in the low bits of each lane. The unused high lanes can be
ignored.

Half-wide vectors are now loaded from memory into the low 64 bits of the v128
rather than spread out among the lanes. As a result, v128.load64_splat is a much
more common operation, so add new patterns to support it.

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

3 years ago[sanitizer] Fix for CMAKE_CXX_FLAGS update
Brian Cain [Thu, 19 Aug 2021 13:26:41 +0000 (06:26 -0700)]
[sanitizer] Fix for CMAKE_CXX_FLAGS update

With unquoted ${CMAKE_CXX_FLAGS}, the REGEX fails when it's empty:

```CMake Error at lib/scudo/standalone/CMakeLists.txt:14 (string):
string sub-command REGEX, mode REPLACE needs at least 6 arguments total to
command.```

3 years ago[libc][Obvious] Fix llvm_libc_ext.td.
Siva Chandra Reddy [Thu, 19 Aug 2021 18:41:18 +0000 (18:41 +0000)]
[libc][Obvious] Fix llvm_libc_ext.td.

3 years agoRevert "[mlir][Linalg] Allow all build methods of Structured ops to specify additiona...
MaheshRavishankar [Thu, 19 Aug 2021 18:52:46 +0000 (11:52 -0700)]
Revert "[mlir][Linalg] Allow all build methods of Structured ops to specify additional attributes."

This reverts commit 95ddc8341ae2c27229ad3dcf1d55abebcec15d02.

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

3 years ago[LLDB][GUI] Handle return key for compound fields
Omar Emara [Wed, 18 Aug 2021 22:07:55 +0000 (15:07 -0700)]
[LLDB][GUI] Handle return key for compound fields

This patch handles the return key for compound fields like lists and
mapping fields. The return key, if not handled by the field will select
the next primary element, skipping secondary elements like remove
buttons and the like.

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

3 years ago[runtimeunroll] Support multiple exits to latch exit w/prolog loop
Philip Reames [Thu, 19 Aug 2021 18:41:09 +0000 (11:41 -0700)]
[runtimeunroll] Support multiple exits to latch exit w/prolog loop

This patch extends the runtime unrolling infrastructure to support unrolling a loop with multiple exiting blocks branching to the same exit block used by the latch. It intentionally does not include a cost model change to enable this functionality unless appropriate force flags are used.

This is the prolog companion to D107381. Since this was LGTMed, a problem with DT updating was reported against that patch.  I roled in the analogous fix here as it seemed obvious, and not worth re-review.

As an aside, our prolog form leaves a lot of potential value on the floor when there is an invariant load or invariant condition in the loop being runtime unrolled. We should probably consider a "required prolog" heuristic.  (Alternatively, maybe we should be peeling these cases more aggressively?)

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

3 years ago[AMDGPU] Add alias.scope metadata to lowered LDS struct
Stanislav Mekhanoshin [Tue, 17 Aug 2021 19:58:07 +0000 (12:58 -0700)]
[AMDGPU] Add alias.scope metadata to lowered LDS struct

Alias analysis is unable to disambiguate accesses to the structure
fields without it unlike distinct variables. As a result we cannot
combine ds_read and ds_write operations in a case of any store in
between which always considered clobbering.

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