platform/upstream/llvm.git
3 years ago[mlir][vector] Move transferOp on tensor opt to folder/canonicalization
thomasraoux [Thu, 15 Apr 2021 20:43:44 +0000 (13:43 -0700)]
[mlir][vector] Move transferOp on tensor opt to folder/canonicalization

Move the existing optimization for transfer op on tensor to folder and
canonicalization. This handles the write after write case and read after write
and also add write after read case.

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

3 years ago[OpenMP IRBuilder, MLIR] Add support for OpenMP do schedule dynamic
Mats Petersson [Fri, 16 Apr 2021 14:08:56 +0000 (15:08 +0100)]
[OpenMP IRBuilder, MLIR] Add support for OpenMP do schedule dynamic

The implementation supports static schedule for Fortran do loops. This
implements the dynamic variant of the same concept.

Reviewed By: Meinersbur

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

3 years ago[Driver] Allow both lib64 and lib in rocm-detect test.
Troy Johnson [Fri, 16 Apr 2021 14:48:55 +0000 (09:48 -0500)]
[Driver] Allow both lib64 and lib in rocm-detect test.

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

3 years ago[PhaseOrdering] add test for loop-invariant fdiv; NFC
Sanjay Patel [Fri, 16 Apr 2021 14:50:02 +0000 (10:50 -0400)]
[PhaseOrdering] add test for loop-invariant fdiv; NFC

Discussed in D87479 - disabling loop unrolling should
not mean that instcombine or other passes interfere
with LICM.

3 years ago[SystemZ][z/OS] Add IsText Argument to GetFile and GetFileOrSTDIN
Jonathan Crowther [Fri, 16 Apr 2021 14:02:48 +0000 (10:02 -0400)]
[SystemZ][z/OS] Add IsText Argument to GetFile and GetFileOrSTDIN

Add the `IsText` argument to `GetFile` and `GetFileOrSTDIN` which will help z/OS distinguish between text and binary correctly. This is an extension to [this patch](https://reviews.llvm.org/D97785)

Reviewed By: abhina.sreeskantharajan, amccarth

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

3 years ago[TableGen] Allow mnemonics aliases with uppercase
paperchalice [Fri, 16 Apr 2021 13:55:42 +0000 (09:55 -0400)]
[TableGen] Allow mnemonics aliases with uppercase

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

3 years ago[mlir][ArmSVE] Cleanup dialect registration
Javier Setoain [Fri, 16 Apr 2021 13:51:17 +0000 (15:51 +0200)]
[mlir][ArmSVE] Cleanup dialect registration

ArmSVE dialect is behind the recent changes in how the Vector dialect
interacts with backend vector dialects and the MLIR -> LLVM IR
translation module. This patch cleans up ArmSVE initialization within
Vector and removes the need for an LLVMArmSVE dialect.

Reviewed By: ftynse

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

3 years ago[libc++] Fix LWG 2874: Constructor shared_ptr::shared_ptr(Y*) should be constrained.
Louis Dionne [Wed, 14 Apr 2021 19:07:14 +0000 (15:07 -0400)]
[libc++] Fix LWG 2874: Constructor shared_ptr::shared_ptr(Y*) should be constrained.

This patch fixes LWG2874. It is based on the original patch by Zoe Carver
originally uploaded at D81417.

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

3 years ago[mlir][python] Add simple debugging and printing helpers
Nicolas Vasilache [Fri, 16 Apr 2021 12:54:43 +0000 (12:54 +0000)]
[mlir][python] Add simple debugging and printing helpers

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

3 years ago[PhaseOrdering] add test to track PR49785; NFC
Sanjay Patel [Fri, 16 Apr 2021 13:30:25 +0000 (09:30 -0400)]
[PhaseOrdering] add test to track PR49785; NFC

See D99759 / D100573 / bb907b26e2bf for details.

3 years ago[OPENMP]Fix PR49115: Incorrect results for scan directive.
Alexey Bataev [Thu, 8 Apr 2021 17:13:15 +0000 (10:13 -0700)]
[OPENMP]Fix PR49115: Incorrect results for scan directive.

For combined worksharing directives need to emit the temp arrays outside
of the parallel region and update them in the master thread only.

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

3 years ago[docs] Add Pointer Authentication call info
Kristof Beyls [Fri, 16 Apr 2021 13:10:52 +0000 (15:10 +0200)]
[docs] Add Pointer Authentication call info

3 years ago[MLIR] Fix `isValidIndex`
Frederik Gossen [Fri, 16 Apr 2021 12:58:05 +0000 (14:58 +0200)]
[MLIR] Fix `isValidIndex`

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

3 years ago[OpenMP] Add omp_target_is_accessible() to header files
Hansang Bae [Tue, 13 Apr 2021 01:20:27 +0000 (20:20 -0500)]
[OpenMP] Add omp_target_is_accessible() to header files

-- Added omp_target_is_accessible to the header files
-- Added missing const qualifier to device memory routines

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

3 years ago[ValueTracking] don't recursively compute known bits using multiple llvm.assumes
Sanjay Patel [Fri, 16 Apr 2021 12:39:22 +0000 (08:39 -0400)]
[ValueTracking] don't recursively compute known bits using multiple llvm.assumes

This is an alternative to D99759 to avoid the compile-time explosion seen in:
https://llvm.org/PR49785

Another potential solution would make the exclusion logic stronger to avoid
blowing up, but note that we reduced the complexity of the exclusion mechanism
in D16204 because it was too costly.

So I'm questioning the need for recursion/exclusion entirely - what is the
optimization value vs. cost of recursively computing known bits based on
assumptions?
This was built into the implementation from the start with 60db058,
and we have kept adding code/cost to deal with that capability.

By clearing the query's AssumptionCache inside computeKnownBitsFromAssume(),
this patch retains all existing assume functionality except refining known
bits based on even more assumptions.

We have 1 regression test that shows a difference in optimization power.

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

3 years ago[X86][CostModel] Fix cost model for non-power-of-two vector load/stores
Roman Lebedev [Fri, 16 Apr 2021 12:25:23 +0000 (15:25 +0300)]
[X86][CostModel] Fix cost model for non-power-of-two vector load/stores

Sometimes LV has to produce really wide vectors,
and sometimes they end up being not powers of two.
As it can be seen from the diff, the cost computation
is currently completely non-sensical in those cases.

Instead of just scalarizing everything, split/factorize the wide vector
into a number of subvectors, each one having a power-of-two elements,
recurse to get the cost of op on this subvector. Also, check how we'd
legalize this subvector, and if the legalized type is scalar,
also account for the scalarization cost.

Note that for sub-vector loads, we might be able to do better,
when the vectors are properly aligned.

Reviewed By: RKSimon

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

3 years ago[SystemZ][z/OS][Windows] Add new functions that set Text/Binary mode for Stdin and...
Abhina Sreeskantharajan [Fri, 16 Apr 2021 12:06:35 +0000 (08:06 -0400)]
[SystemZ][z/OS][Windows] Add new functions that set Text/Binary mode for Stdin and Stdout based on OpenFlags

On Windows, we want to open a file in Binary mode if OF_CRLF bit is not set. On z/OS, we want to open a file in Binary mode if the OF_Text bit is not set.

This patch creates two new functions called ChangeStdinMode and ChangeStdoutMode which will take OpenFlags as an arg to determine which mode to set stdin and stdout to. This will enable patches like https://reviews.llvm.org/D100056 to not affect Windows when setting the OF_Text flag for raw_fd_streams.

Reviewed By: rnk

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

3 years agoRestore lit feature object-emission. Omit DebugInfo/Generic on XCore.
Nigel Perks [Tue, 18 Aug 2020 12:21:20 +0000 (13:21 +0100)]
Restore lit feature object-emission. Omit DebugInfo/Generic on XCore.

D73568 removed the lit feature object-emission, because it was introduced for a
target which did not support the integrated assembler, and that target no longer
required the feature. XCore still does not support the integrated assembler,
so a build with XCore as the default target fails tests requiring
object-emission. This issue was not publicly visible because there was not a
buildbot for XCore as the default target. We fixed the failures downstream. We
now have builder clang-xcore-ubuntu-20-x64 on the staging buildmaster, which
shows the failures. We would like to make upstream build green.

Omit DebugInfo/Generic on XCore to avoid annotating 70 separate files.

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

3 years ago[MLIR][Shape] Expose `getShapeVec` and add support for extent tensors
Frederik Gossen [Fri, 16 Apr 2021 11:50:14 +0000 (13:50 +0200)]
[MLIR][Shape] Expose `getShapeVec` and add support for extent tensors

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

3 years ago[llvm-objcopy] clang-format a line
Nico Weber [Fri, 16 Apr 2021 11:24:15 +0000 (07:24 -0400)]
[llvm-objcopy] clang-format a line

3 years ago[SimplifyCFG] Regenerate CHECK lines and add test for PR49982.
Florian Hahn [Fri, 16 Apr 2021 10:51:36 +0000 (11:51 +0100)]
[SimplifyCFG] Regenerate CHECK lines and add test for PR49982.

3 years ago[NFC][AArch64][SVE] Move select-sve.ll tests to sve-select.ll
Caroline Concatto [Fri, 16 Apr 2021 09:57:08 +0000 (10:57 +0100)]
[NFC][AArch64][SVE] Move select-sve.ll tests to sve-select.ll

This patch merges the two select tests: select-sve.ll and sve-select.ll into
sve-select.ll as they are both testing SELECT instruction

3 years ago[ARM] Combine sub 0, csinc X, Y, CC -> csinv -X, Y, CC
David Green [Fri, 16 Apr 2021 10:52:31 +0000 (11:52 +0100)]
[ARM] Combine sub 0, csinc X, Y, CC -> csinv -X, Y, CC

Combine sub 0, csinc X, Y, CC to csinv -X, Y, CC providing that the
negation of X is cheap, currently just handling constants. This comes up
during the splat of an i1 to a predicate, where we now generate csetm,
as opposed to cset; rsb.

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

3 years ago[RISCV] Rerun stack test through update_llc_test_checks.py
Fraser Cormack [Fri, 16 Apr 2021 09:58:41 +0000 (10:58 +0100)]
[RISCV] Rerun stack test through update_llc_test_checks.py

Adjusts formatting of comments only. Just to reduce diffs in future
patches.

3 years ago[CostModel][X86] Add fully aligned load/store tests
Simon Pilgrim [Fri, 16 Apr 2021 09:35:13 +0000 (10:35 +0100)]
[CostModel][X86] Add fully aligned load/store tests

As noted on D100099, if these illegal vector types are suitably aligned they should be much cheaper to load (but probably not store).

3 years agoRevert "[AMDGPU][OpenMP] Add amdgpu-arch tool to list AMD GPUs installed"
Pushpinder Singh [Fri, 16 Apr 2021 08:54:06 +0000 (08:54 +0000)]
Revert "[AMDGPU][OpenMP] Add amdgpu-arch tool to list AMD GPUs installed"

This reverts commit 7029cffc4e78556cfe820791c612968bb15b2ffb.

3 years ago[lld] Fix test crashing when AVR target is missing
LemonBoy [Fri, 16 Apr 2021 09:12:29 +0000 (11:12 +0200)]
[lld] Fix test crashing when AVR target is missing

Fixes buildbot error.

3 years ago[docs] Add vector predication call
Simon Moll [Fri, 16 Apr 2021 08:45:40 +0000 (10:45 +0200)]
[docs] Add vector predication call

Add the syncup call to the table

Reviewed By: craig.topper

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

3 years ago[mlir][Python][Linalg] Add support for captures in body builder.
Nicolas Vasilache [Tue, 13 Apr 2021 06:25:47 +0000 (06:25 +0000)]
[mlir][Python][Linalg] Add support for captures in body builder.

When Linalg named ops support was added, captures were omitted
from the body builder. This revision adds support for captures
which allows us to write FillOp in a more idiomatic fashion using
the _linalg_ops_ext mixin support.

This raises an issue in the generation of `_linalg_ops_gen.py` where
```
  @property
  def result(self):
    return self.operation.results[0] if len(self.operation.results) > 1 else None
```.
The condition should be `== 1`.

This will be fixed in a separate commit.

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

3 years ago[LLD][ELF][AVR] Propagate ELF flags to the linked image
LemonBoy [Fri, 16 Apr 2021 08:38:58 +0000 (10:38 +0200)]
[LLD][ELF][AVR] Propagate ELF flags to the linked image

The `e_flags` for a ELF file targeting the AVR ISA contains two fields at the time of writing:
- A 7-bit integer field specifying the ISA revision being targeted
- A 1-bit flag specifying whether the object files being linked are suited for applying the relaxations at link time

The linked ELF file is blessed with the arch revision shared among all the files.
The behaviour in case of mismatch is purposefully different than the one implemented in libbfd: LLD will raise a fatal error while libbfd silently picks a default value of `avr2`.
The relaxation-ready flag is handled as done by libbfd, in order for it to appear in the linked object every source object must be tagged with it.

Reviewed By: MaskRay

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

3 years ago[clang-format] Inconsistent behavior regarding line break before access modifier
Max Sagebaum [Fri, 16 Apr 2021 08:02:02 +0000 (10:02 +0200)]
[clang-format] Inconsistent behavior regarding line break before access modifier

Fixes https://llvm.org/PR41870.

Checks for newlines in option Style.EmptyLineBeforeAccessModifier are now based on the formatted new lines and not on the new lines in the file.

Reviewed By: HazardyKnusperkeks, curdeius

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

3 years ago[mlir][linalg] Add support for WAW fusion on tensors.
Nicolas Vasilache [Thu, 15 Apr 2021 22:47:25 +0000 (22:47 +0000)]
[mlir][linalg] Add support for WAW fusion on tensors.

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

3 years ago[libc] Fix typo
Guillaume Chatelet [Fri, 16 Apr 2021 08:09:28 +0000 (08:09 +0000)]
[libc] Fix typo

3 years ago[libc] Add slice/take/drop methods to ArrayRef
Guillaume Chatelet [Thu, 15 Apr 2021 15:31:15 +0000 (15:31 +0000)]
[libc] Add slice/take/drop methods to ArrayRef

Add various methods from llvm::ArrayRef. Refactor implementation to remove code duplication.

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

3 years ago[Aarch64] handle "o" inline asm memory constraints
Nick Desaulniers [Fri, 16 Apr 2021 06:10:16 +0000 (23:10 -0700)]
[Aarch64] handle "o" inline asm memory constraints

This Linux kernel is making use of this inline asm constraint which is
causing an ICE.

PR49956

Link: https://github.com/ClangBuiltLinux/linux/issues/1348
Reviewed By: MaskRay

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

3 years ago[libcxx] Make the GDB pretty printer test less strict
Petr Hosek [Mon, 29 Mar 2021 19:10:18 +0000 (12:10 -0700)]
[libcxx] Make the GDB pretty printer test less strict

This is a workaround for PR48937. GDB can sometimes print additional
warnings which currently fails the test. Use re.search instead of
re.match to ignore this additional output.

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

3 years ago[Polly][Ast] Partial refactoring of IslAst and IslAstInfo to use isl++. NFC.
patacca [Fri, 16 Apr 2021 04:34:57 +0000 (23:34 -0500)]
[Polly][Ast] Partial refactoring of IslAst and IslAstInfo to use isl++. NFC.

Polly use algorithms from the Integer Set Library (isl), which is a library written in C and which is incompatible with the rest of the LLVM as it is written in C++.

Changes made:
 - Refactoring the following methods of class `IslAst`
  - `getAst()` `getRunCondition()` `buildRunCondition()`
  - Removed the destructor in favor of the default one
 - Change the type of the attribute `IslAst.RunCondition` to `isl::ast_expr`
 - Change the type of the attribute `IslAst.Root` to `isl::ast_node`
 - Change the order of attributes in class `IslAst` to reflect the data dependencies so that the destructor won't complain
 - Refactoring the following methods of class `IslAstInfo`
  - `getAst()` `getRunCondition()`

Reviewed By: Meinersbur

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

3 years ago[AMDGPU][OpenMP] Add amdgpu-arch tool to list AMD GPUs installed
Pushpinder Singh [Tue, 6 Apr 2021 06:53:20 +0000 (06:53 +0000)]
[AMDGPU][OpenMP] Add amdgpu-arch tool to list AMD GPUs installed

This patch adds new clang tool named amdgpu-arch which uses
HSA to detect installed AMDGPU and report back latter's march.
This tool is built only if system has HSA installed.

The value printed by amdgpu-arch is used to fill -march when
latter is not explicitly provided in -Xopenmp-target.

Reviewed By: JonChesterfield, gregrodgers

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

3 years ago[RISCV] Don't emit save-restore call if function is a interrupt handler
Jim Lin [Fri, 16 Apr 2021 04:50:51 +0000 (12:50 +0800)]
[RISCV] Don't emit save-restore call if function is a interrupt handler

It has to save all caller-saved registers before a call in the handler.
So don't emit a call that save/restore registers.

Reviewed By: simoncook, luismarques, asb

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

3 years agoFix tile-and-pad when padding doesn't span all dimension
Ahmed Taei [Fri, 16 Apr 2021 00:03:17 +0000 (17:03 -0700)]
Fix tile-and-pad when padding doesn't span all dimension

Without this tile-and-pad will never terminate if pad-fails.

Reviewed By: nicolasvasilache

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

3 years agoDon't refer to allocation map entry after deallocating it
Jason Molenda [Fri, 16 Apr 2021 01:58:13 +0000 (18:58 -0700)]
Don't refer to allocation map entry after deallocating it

debugserver's MachTask::DeallocateMemory when removing an
allocate entry from our map (in resposne to an '_m' packet),
copy the size from the entry before removing it from the
map and then using the iterator to fix an ASAN error on
the bots when running TestGdbRemoteMemoryAllocation.py

rdar://76595998

3 years ago[libcxx] adds `cpp17-.*iterator` concepts for iterator_traits
Christopher Di Bella [Sun, 4 Apr 2021 05:12:46 +0000 (05:12 +0000)]
[libcxx] adds `cpp17-.*iterator` concepts for iterator_traits

The `iterator_traits` patch became too large for a concise review, so
the "bloat" —as it were— was moved into this patch. Also tests most
C++[98,17] iterator types to confirm backwards compatibility is
successful (regex iterators are intentionally not present, but directory
iterators are due to a peculiar error encountered while patching
`iterator_traits`).

Depends on D99461.

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

3 years ago[AMDGPU] Refactor ds_read/ds_write related select code for better readability.
hsmahesha [Fri, 16 Apr 2021 02:53:44 +0000 (08:23 +0530)]
[AMDGPU] Refactor ds_read/ds_write related select code for better readability.

Part of the code related to ds_read/ds_write ISel is refactored, and the
corresponding comment is re-written for better readability, which would help
while implementing any future ds_read/ds_write ISel related modifications.

Reviewed By: rampitec

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

3 years ago[MLGO] Fix use of AM.invalidate post D100519
Mircea Trofin [Fri, 16 Apr 2021 01:43:40 +0000 (18:43 -0700)]
[MLGO] Fix use of AM.invalidate post D100519

The ML inline advisors more aggressively invalidate certain analyses
after each call site inlining, to more accurately capture the problem
state.

3 years ago[LICM][NFC] Fix typo
Marcythm [Wed, 14 Apr 2021 11:52:35 +0000 (19:52 +0800)]
[LICM][NFC] Fix typo

fixed some typos which may lead to misunderstandings in LICM.cpp

Reviewed By: nikic, asbirlea
Differential Revision: https://reviews.llvm.org/D100470

3 years ago[LangRef] formatting
Juneyoung Lee [Fri, 16 Apr 2021 01:40:53 +0000 (10:40 +0900)]
[LangRef] formatting

3 years ago[Polly] Fix PM invalidate usage after D100519
Fangrui Song [Fri, 16 Apr 2021 01:41:20 +0000 (18:41 -0700)]
[Polly] Fix PM invalidate usage after D100519

3 years ago[gn build] Port 3bc88eb3924f
LLVM GN Syncbot [Fri, 16 Apr 2021 01:16:51 +0000 (01:16 +0000)]
[gn build] Port 3bc88eb3924f

3 years ago[lld-macho] Don't use arrays as template parameters
Jez Ng [Fri, 16 Apr 2021 01:14:36 +0000 (21:14 -0400)]
[lld-macho] Don't use arrays as template parameters

MSVC from VSCode 2017 appears unhappy with it (causes an
internal compiler error.)

This also means that we need to avoid doing `sizeof(stubCode)` as
`sizeof(int[N])` on function array parameters decays into `sizeof(int *)`.

Reviewed By: #lld-macho, gkm

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

3 years ago[lld-macho] Make load relaxation work for arm64_32
Jez Ng [Fri, 16 Apr 2021 01:14:34 +0000 (21:14 -0400)]
[lld-macho] Make load relaxation work for arm64_32

arm64_32 uses 32-bit GOT loads, so we should accept those
instructions in `ARM64Common::relaxGotLoad()` too.

Reviewed By: #lld-macho, gkm

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

3 years ago[lld-macho] Add 32-bit compact unwind support
Jez Ng [Fri, 16 Apr 2021 01:14:33 +0000 (21:14 -0400)]
[lld-macho] Add 32-bit compact unwind support

This could probably have been part of D99633, but I split it up to make
things a bit more reviewable. I also fixed some bugs in the implementation that
were masked through integer underflows when operating in 64-bit mode.

Reviewed By: #lld-macho, gkm

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

3 years ago[lld-macho] Add support for arm64_32
Jez Ng [Fri, 16 Apr 2021 01:14:32 +0000 (21:14 -0400)]
[lld-macho] Add support for arm64_32

From what I can tell, it's pretty similar to arm64. The two main differences
are:

1. No 64-bit relocations
2. Stub code writes to 32-bit registers instead of 64-bit

Plus of course the various on-disk structures like `segment_command` are using
the 32-bit instead of the 64-bit variants.

Reviewed By: #lld-macho, gkm

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

3 years ago[lld-macho] Re-root absolute input file paths if -syslibroot is specified
Jez Ng [Fri, 16 Apr 2021 01:14:30 +0000 (21:14 -0400)]
[lld-macho] Re-root absolute input file paths if -syslibroot is specified

Reviewed By: #lld-macho, gkm

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

3 years ago[lld-macho] LTO: Unset VisibleToRegularObj where possible
Jez Ng [Fri, 16 Apr 2021 01:14:29 +0000 (21:14 -0400)]
[lld-macho] LTO: Unset VisibleToRegularObj where possible

This allows LLVM's LTO to internalize symbols that are not referenced
directly by regular objects. Naturally, this means we need to track
which symbols are referenced by regular objects. The approach taken here
is similar to LLD-COFF's: like the COFF port, we extend
`SymbolTable::insert()` to set the isVisibleToRegularObj bit. (LLD-ELF
relies on the Symbol constructor and `Symbol::mergeProperties()`, but
the Mach-O port does not have a `mergeProperties()` equivalent.)

From what I can tell, ld64 (which uses libLTO) doesn't do this
optimization at all. I'm not even sure libLTO provides a way to do this.
Not having ld64's behavior as a reference implementation is unfortunate;
instead, I am relying on LLD-ELF/COFF's behavior as references while
erring on the conservative side. In particular, LLD-MachO will only do
this optimization for executables right now.

We also don't attempt it when `-flat_namespace` is used -- otherwise
we'd need scan the symbol table to find matches for every un-namespaced
symbol reference, which is expensive.

internalize.ll is based off the LLD-ELF tests `internalize-basic.ll` and
`internalize-undef.ll`. Looks like @davide added some of LLD-ELF's internalize
tests, so adding him as a reviewer...

Reviewed By: #lld-macho, gkm

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

3 years agoAdd triple to fix test failure.
Richard Smith [Fri, 16 Apr 2021 01:07:52 +0000 (18:07 -0700)]
Add triple to fix test failure.

This test uses `__regcall`, support for which is target-specific.

3 years ago[LangRef] fix unexepcted unindent errror
Juneyoung Lee [Fri, 16 Apr 2021 00:58:55 +0000 (09:58 +0900)]
[LangRef] fix unexepcted unindent errror

3 years ago[LangRef] clarify the semantics of nocapture
Juneyoung Lee [Tue, 13 Apr 2021 04:57:06 +0000 (13:57 +0900)]
[LangRef] clarify the semantics of nocapture

This patch clarifies the semantics of nocapture attribute.

A 'Pointer Capture' subsection is added to describe the semantics of pointer capture first.

For the nocapture example with two same pointer arguments, it is consistent with the semantics that Alive2 used to run lit tests.

Reviewed By: nlopes

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

3 years ago[dfsan] Remove hard-coded constant in release_shadow_space.c
George Balatsouras [Thu, 15 Apr 2021 23:49:54 +0000 (16:49 -0700)]
[dfsan] Remove hard-coded constant in release_shadow_space.c

Reviewed By: stephan.yichao.zhao

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

3 years agoRevert "[LLDB] Use path relative to binary for finding .dwo files."
Caroline Tice [Fri, 16 Apr 2021 00:17:04 +0000 (17:17 -0700)]
Revert "[LLDB] Use path relative to binary for finding .dwo files."

This reverts commit b241f3cb292d0ba1ad5a33b3bbd4a8a3a9c909dc.

Test case is breaking windows builder.

3 years agoImplemented [[clang::musttail]] attribute for guaranteed tail calls.
Joshua Haberman [Thu, 15 Apr 2021 23:49:19 +0000 (16:49 -0700)]
Implemented [[clang::musttail]] attribute for guaranteed tail calls.

This is a Clang-only change and depends on the existing "musttail"
support already implemented in LLVM.

The [[clang::musttail]] attribute goes on a return statement, not
a function definition. There are several constraints that the user
must follow when using [[clang::musttail]], and these constraints
are verified by Sema.

Tail calls are supported on regular function calls, calls through a
function pointer, member function calls, and even pointer to member.

Future work would be to throw a warning if a users tries to pass
a pointer or reference to a local variable through a musttail call.

Reviewed By: rsmith

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

3 years ago[libcxx] adds `std::indirectly_readable_traits` to <iterator>
Christopher Di Bella [Tue, 23 Mar 2021 20:48:41 +0000 (20:48 +0000)]
[libcxx] adds `std::indirectly_readable_traits` to <iterator>

Implements parts of:
    * P0896R4 The One Ranges Proposal
    * LWG3446 `indirectly_readable_traits` ambiguity for types with both `value_type` and `element_type`

Depends on D99141.

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

3 years ago[NFC][NewPM] Remove some AnalysisManager invalidate methods
Arthur Eubanks [Thu, 15 Apr 2021 01:40:07 +0000 (18:40 -0700)]
[NFC][NewPM] Remove some AnalysisManager invalidate methods

These were misleading, they're more of a "clear" than an "invalidate".

We shouldn't be individually clearing analysis results. Either we clear
all analyses when some IR becomes invalid, or we properly go through
invalidation.

There was only one use of this, which can be simulated with
AM.invalidate(F, PA).

Reviewed By: mtrofin

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

3 years agoAdd support for numpy arrays to memref conversions.
Prashant Kumar [Thu, 15 Apr 2021 19:55:56 +0000 (19:55 +0000)]
Add support for numpy arrays to memref conversions.

This offers the ability to pass numpy arrays to the corresponding
memref argument.

Reviewed By: mehdi_amini, nicolasvasilache

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

3 years ago[dfsan] Add test for origin tracking stack traces
George Balatsouras [Thu, 15 Apr 2021 00:59:48 +0000 (17:59 -0700)]
[dfsan] Add test for origin tracking stack traces

Reviewed By: stephan.yichao.zhao

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

3 years ago[mlir] Add support for walking locations similarly to Operations
River Riddle [Thu, 15 Apr 2021 23:09:08 +0000 (16:09 -0700)]
[mlir] Add support for walking locations similarly to Operations

This allows for walking all nested locations of a given location, and is generally useful when processing locations.

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

3 years ago[mlir][NFC] Add a using directive for llvm::SetVector
River Riddle [Thu, 15 Apr 2021 23:08:54 +0000 (16:08 -0700)]
[mlir][NFC] Add a using directive for llvm::SetVector

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

3 years agos/setGenerator/addGenerator/ in the JIT docs. NFC
Jon Roelofs [Thu, 15 Apr 2021 22:54:28 +0000 (15:54 -0700)]
s/setGenerator/addGenerator/ in the JIT docs. NFC

3 years agoNFC: Add a simple test for introspection call formatting
Stephen Kelly [Thu, 15 Apr 2021 22:27:49 +0000 (23:27 +0100)]
NFC: Add a simple test for introspection call formatting

3 years ago[OpenMP] Add info for device table changes
Joseph Huber [Thu, 15 Apr 2021 21:27:17 +0000 (17:27 -0400)]
[OpenMP] Add info for device table changes

Summary:
This patch adds a feature to print information whenever the host-device pointer
mapping table is changed by inserting or removing an entry. This introduces a
new bit field for LIBOMPTARGET_INFO at position 0x8.

Reviewed By: jdoerfert

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

3 years ago[sanitizer] Simplify GetTls with dl_iterate_phdr on Linux and use it on musl/FreeBSD
Fangrui Song [Thu, 15 Apr 2021 22:34:43 +0000 (15:34 -0700)]
[sanitizer] Simplify GetTls with dl_iterate_phdr on Linux and use it on musl/FreeBSD

... so that FreeBSD specific GetTls/glibc specific pthread_self code can be
removed. This also helps FreeBSD arm64/powerpc64 which don't have GetTls
implementation yet.

GetTls is the range of

* thread control block and optional TLS_PRE_TCB_SIZE
* static TLS blocks plus static TLS surplus

On glibc, lsan requires the range to include
`pthread::{specific_1stblock,specific}` so that allocations only referenced by
`pthread_setspecific` can be scanned.

This patch uses `dl_iterate_phdr` to collect TLS blocks. Find the one
with `dlpi_tls_modid==1` as one of the initially loaded module, then find
consecutive ranges. The boundaries give us addr and size.

This allows us to drop the glibc internal `_dl_get_tls_static_info` and
`InitTlsSize`. However, huge glibc x86-64 binaries with numerous shared objects
may observe time complexity penalty, so exclude them for now. Use the simplified
method with non-Android Linux for now, but in theory this can be used with *BSD
and potentially other ELF OSes.

This removal of RISC-V `__builtin_thread_pointer` makes the code compilable with
more compiler versions (added in Clang in 2020-03, added in GCC in 2020-07).

This simplification enables D99566 for TLS Variant I architectures.

Note: as of musl 1.2.2 and FreeBSD 12.2, dlpi_tls_data returned by
dl_iterate_phdr is not desired: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=254774
This can be worked around by using `__tls_get_addr({modid,0})` instead
of `dlpi_tls_data`. The workaround can be shared with the workaround for glibc<2.25.

This fixes some tests on Alpine Linux x86-64 (musl)

```
test/lsan/Linux/cleanup_in_tsd_destructor.c
test/lsan/Linux/fork.cpp
test/lsan/Linux/fork_threaded.cpp
test/lsan/Linux/use_tls_static.cpp
test/lsan/many_tls_keys_thread.cpp

test/msan/tls_reuse.cpp
```

and `test/lsan/TestCases/many_tls_keys_pthread.cpp` on glibc aarch64.

The number of sanitizer test failures does not change on FreeBSD/amd64 12.2.

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

3 years ago[lldb] Raise a CrashLogParseException when failing to parse JSON crashlog
Jonas Devlieghere [Thu, 15 Apr 2021 22:15:20 +0000 (15:15 -0700)]
[lldb] Raise a CrashLogParseException when failing to parse JSON crashlog

Throw an exception with an actually helpful message when we fail to
parse a JSON crashlog.

3 years agoNFC: Add missing matcher for test method
Stephen Kelly [Thu, 15 Apr 2021 20:56:39 +0000 (21:56 +0100)]
NFC: Add missing matcher for test method

The intention is to match the definition.

3 years ago[OpenMP5][DOCS] Update status of masked construct and correct the color
cchen [Thu, 15 Apr 2021 22:17:26 +0000 (17:17 -0500)]
[OpenMP5][DOCS] Update status of masked construct and correct the color
for omp_target_is_present, NFC.

3 years ago[AST] Fix location call storage with common last-invocation
Stephen Kelly [Thu, 15 Apr 2021 11:18:34 +0000 (12:18 +0100)]
[AST] Fix location call storage with common last-invocation

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

3 years ago[mlir][vector][avx] add AVX dot product to X86Vector dialect with lowering
Aart Bik [Thu, 15 Apr 2021 20:46:08 +0000 (13:46 -0700)]
[mlir][vector][avx] add AVX dot product to X86Vector dialect with lowering

In the long run, we want to unify the dot product codegen solutions between
all target architectures, but this intrinsic enables experimenting with AVX
specific implementations in the meantime.

Reviewed By: nicolasvasilache

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

3 years ago[InferAttrs] Do not mark first argument of str(n)cat as writeonly.
Florian Hahn [Thu, 15 Apr 2021 21:52:22 +0000 (22:52 +0100)]
[InferAttrs] Do not mark first argument of str(n)cat as writeonly.

str(n)cat appends a copy of the second argument to the end of the first
argument. To find the end of the first argument, str(n)cat has to read
from it until it finds the terminating 0. So it should not be marked as
writeonly. I think this means the argument should not be marked as
writeonly.

(This is causing a mis-compile with legacy DSE, before it got removed)

Reviewed By: efriedma

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

3 years ago[clang][AArch64] Correctly align HFA arguments when passed on the stack
Momchil Velikov [Thu, 15 Apr 2021 18:58:54 +0000 (19:58 +0100)]
[clang][AArch64] Correctly align HFA arguments when passed on the stack

When we pass a AArch64 Homogeneous Floating-Point
Aggregate (HFA) argument with increased alignment
requirements, for example

    struct S {
      __attribute__ ((__aligned__(16))) double v[4];
    };

Clang uses `[4 x double]` for the parameter, which is passed
on the stack at alignment 8, whereas it should be at
alignment 16, following Rule C.4 in
AAPCS (https://github.com/ARM-software/abi-aa/blob/master/aapcs64/aapcs64.rst#642parameter-passing-rules)

Currently we don't have a way to express in LLVM IR the
alignment requirements of the function arguments. The align
attribute is applicable to pointers only, and only for some
special ways of passing arguments (e..g byval). When
implementing AAPCS32/AAPCS64, clang resorts to dubious hacks
of coercing to types, which naturally have the needed
alignment. We don't have enough types to cover all the
cases, though.

This patch introduces a new use of the stackalign attribute
to control stack slot alignment, when and if an argument is
passed in memory.

The attribute align is left as an optimizer hint - it still
applies to pointer types only and pertains to the content of
the pointer, whereas the alignment of the pointer itself is
determined by the stackalign attribute.

For byval arguments, the stackalign attribute assumes the
role, previously perfomed by align, falling back to align if
stackalign` is absent.

On the clang side, when passing arguments using the "direct"
style (cf. `ABIArgInfo::Kind`), now we can optionally
specify an alignment, which is emitted as the new
`stackalign` attribute.

Patch by Momchil Velikov and Lucas Prates.

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

3 years ago[mlir][scf] NFC - Add a getIterOpOperands helper to scf::ForOp
Nicolas Vasilache [Thu, 15 Apr 2021 21:43:41 +0000 (21:43 +0000)]
[mlir][scf] NFC - Add a getIterOpOperands helper to scf::ForOp

3 years ago[LLDB] Use path relative to binary for finding .dwo files.
Caroline Tice [Thu, 15 Apr 2021 20:36:23 +0000 (13:36 -0700)]
[LLDB] Use path relative to binary for finding .dwo files.

DWARF allows .dwo file paths to be relative rather than absolute. When
they are relative, DWARF uses DW_AT_comp_dir to find the .dwo
file. DW_AT_comp_dir can also be relative, making the entire search
patch for the .dwo file relative. In this case, LLDB currently
searches relative to its current working directory, i.e. the directory
from which the debugger was launched. This is not right, as the
compiler, which generated the relative paths, can have no idea where
the debugger will be launched. The correct thing is to search relative
to the location of the executable binary. That is what this patch
does.

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

3 years ago[AST][Introspection] Add a check to detect if introspection is supported.
Nathan James [Thu, 15 Apr 2021 21:21:40 +0000 (22:21 +0100)]
[AST][Introspection] Add a check to detect if introspection is supported.

This could probably be made into a compile time constant, but that would involve generating a second inc file.

Reviewed By: steveire

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

3 years ago[AST] Add a print method to Introspection LocationCall
Nathan James [Thu, 15 Apr 2021 21:18:28 +0000 (22:18 +0100)]
[AST] Add a print method to Introspection LocationCall

Add a print method that takes a raw_ostream.
Change LocationCallFormatterCpp::format to call that method.

Reviewed By: steveire

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

3 years ago[scudo][standalone] Fuchsia related fixes
Kostya Kortchinsky [Thu, 15 Apr 2021 04:09:20 +0000 (21:09 -0700)]
[scudo][standalone] Fuchsia related fixes

While attempting to roll the latest Scudo in Fuchsia, some issues
arose. While trying to debug them, it appeared that `DCHECK`s were
also never exercised in Fuchsia. This CL fixes the following
problems:
- the size of a block in the TransferBatch class must be a multiple
  of the compact pointer scale. In some cases, it wasn't true, which
  lead to obscure crashes. Now, we round up `sizeof(TransferBatch)`.
  This only materialized in Fuchsia due to the specific parameters
  of the `DefaultConfig`;
- 2 `DCHECK` statements in Fuchsia were incorrect;
- `map()` & co. require a size multiple of a page (as enforced in
  Fuchsia `DCHECK`s), which wasn't the case for `PackedCounters`.
- In the Secondary, a parameter was marked as `UNUSED` while it is
  actually used.

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

3 years ago[TableGen] Reduce the number of map lookups in TypeSetByHwMode::getOrCreate. NFCI
Craig Topper [Thu, 15 Apr 2021 19:24:47 +0000 (12:24 -0700)]
[TableGen] Reduce the number of map lookups in TypeSetByHwMode::getOrCreate. NFCI

hasMode was looking up the map once. Then we'd either call get which
would look up again, or we'd insert into the map which requires
walking the map to find the insertion point.

I believe the hasMode was needed because get has a special case
to look for DefaultMode if the mode being asked for doesn't exist.
We don't want that here so we were using hasMode to make sure we
wouldn't hit that case.

Simplify to a regular operator[] access which will default
construct a SetType if the lookup fails.

3 years ago[AMDGPU] Factor out predicate FmaakFmamkF32Insts
Stanislav Mekhanoshin [Tue, 13 Apr 2021 19:48:53 +0000 (12:48 -0700)]
[AMDGPU] Factor out predicate FmaakFmamkF32Insts

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

3 years ago[libcxx][NFC] removes IndentRequires from .clang-format
Christopher Di Bella [Thu, 15 Apr 2021 19:27:26 +0000 (19:27 +0000)]
[libcxx][NFC] removes IndentRequires from .clang-format

IndentRequires is apparently breaking CI because it uses an older clang-format.

Partially rolls back 2e3a78b8ca10.

3 years ago[mlir][AsmPrinter] Fix multi-threaded segfault by using explicit null stream per...
River Riddle [Thu, 15 Apr 2021 19:14:16 +0000 (12:14 -0700)]
[mlir][AsmPrinter] Fix multi-threaded segfault by using explicit null stream per thread

We were using llvm::nulls, but that isn't thread safe so we switch to giving each thread it's own null stream.

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

3 years ago[clang] [AArch64] Fix handling of HFAs passed to Windows variadic functions
Martin Storsjö [Wed, 14 Apr 2021 10:45:09 +0000 (13:45 +0300)]
[clang] [AArch64] Fix handling of HFAs passed to Windows variadic functions

The documentation says that for variadic functions, all composites
are treated similarly, no special handling of HFAs/HVAs, not even
for the fixed arguments of a variadic function.

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

3 years ago[VPlan] Replace a few unnecessary includes with forward decls.
Florian Hahn [Thu, 15 Apr 2021 18:07:28 +0000 (19:07 +0100)]
[VPlan] Replace a few unnecessary includes with forward decls.

3 years ago[AMDGPU] Add new EmitDstSel field to VOPPofile. NFC.
Stanislav Mekhanoshin [Thu, 15 Apr 2021 18:45:45 +0000 (11:45 -0700)]
[AMDGPU] Add new EmitDstSel field to VOPPofile. NFC.

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

3 years ago[clang-format] Option for empty lines after an access modifier.
Max Sagebaum [Thu, 15 Apr 2021 15:27:20 +0000 (17:27 +0200)]
[clang-format] Option for empty lines after an access modifier.

The current logic for access modifiers in classes ignores the option 'MaxEmptyLinesToKeep=1'. It is therefore impossible to have a coding style that requests one empty line after an access modifier. The patch allows the user to configure how many empty lines clang-format should add after an access modifier. This will remove lines if there are to many and will add them if there are missing.

Reviewed By: MyDeveloperDay, curdeius

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

3 years ago[gn build] Port 82787eb2285d
LLVM GN Syncbot [Thu, 15 Apr 2021 18:54:08 +0000 (18:54 +0000)]
[gn build] Port 82787eb2285d

3 years ago[mlir] Add verification for `linalg.tiled_loop` op.
Alexander Belyaev [Thu, 15 Apr 2021 13:21:34 +0000 (15:21 +0200)]
[mlir] Add verification for `linalg.tiled_loop` op.

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

3 years ago[mlir] Expose `updateBoundsForCyclicDistribution` in Linalg/Utils.h.
Alexander Belyaev [Thu, 15 Apr 2021 17:49:43 +0000 (19:49 +0200)]
[mlir] Expose `updateBoundsForCyclicDistribution` in Linalg/Utils.h.

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

3 years ago[AMDGPU] Move LDS lowering related utility functions to a separate utils file.
hsmahesha [Thu, 15 Apr 2021 18:45:36 +0000 (00:15 +0530)]
[AMDGPU] Move LDS lowering related utility functions to a separate utils file.

Move some utility functions which are used within LDS lowering pass to a separate utils
file so that other LDS related passes can make use of them when required.

Reviewed By: JonChesterfield

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

3 years ago[mlir] Add helpers to set lbs, ubs, steps for linalg.tiled_loop.
Alexander Belyaev [Thu, 15 Apr 2021 17:48:38 +0000 (19:48 +0200)]
[mlir] Add helpers to set lbs, ubs, steps for linalg.tiled_loop.

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

3 years ago[mlir] Add support for adding attribute+type traits/interfaces to tablegen defs
River Riddle [Thu, 15 Apr 2021 18:29:23 +0000 (11:29 -0700)]
[mlir] Add support for adding attribute+type traits/interfaces to tablegen defs

This matches the current support provided to operations, and allows attaching traits, interfaces, and using the DeclareInterfaceMethods utility. This was missed when attribute/type generation was first added.

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

3 years ago[Hexagon] Avoid infinite loops in type legalization when lowering SETCC
Krzysztof Parzyszek [Thu, 15 Apr 2021 18:28:09 +0000 (13:28 -0500)]
[Hexagon] Avoid infinite loops in type legalization when lowering SETCC

Only widen SETCC if the operands can be widened. Not checking that caused
infinite widen-split loops in legalization.

3 years ago[flang][OpenMP] Remove `OmpEndLoopDirective` handles from code.
Sourabh Singh Tomar [Thu, 15 Apr 2021 16:25:43 +0000 (21:55 +0530)]
[flang][OpenMP] Remove `OmpEndLoopDirective` handles from code.

This directive is currently lowered as NOP.

Patch is an attempt upstream code from:
PR: https://github.com/flang-compiler/f18-llvm-project/pull/573

Reviewed By: kiranchandramohan, schweitz, clementval

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

3 years ago[RISCV] Share RVInstIShift and RVInstIShiftW instruction format classes with the...
Craig Topper [Thu, 15 Apr 2021 18:08:26 +0000 (11:08 -0700)]
[RISCV] Share RVInstIShift and RVInstIShiftW instruction format classes with the B extension.

This generalizes RVInstIShift/RVInstIShiftW to take the upper
5 or 7 bits of the immediate as an input instead of only bit 30. Then
we can share them.

For RVInstIShift I left a hardcoded 0 at bit 26 where RV128 gets
a 7th bit for the shift amount.

Reviewed By: frasercrmck

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

3 years ago[OpenMP] Added codegen for masked directive
cchen [Thu, 15 Apr 2021 17:54:15 +0000 (12:54 -0500)]
[OpenMP] Added codegen for masked directive

Reviewed By: ABataev

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