platform/upstream/llvm.git
3 years ago[X86][SLM] Fix PSAD/MPSAD uops, latency and throughput
Simon Pilgrim [Sat, 11 Sep 2021 10:11:37 +0000 (11:11 +0100)]
[X86][SLM] Fix PSAD/MPSAD uops, latency and throughput

Noticed while trying to improve generic reduction costs via the D103695 helper script. Confirmed with Intel AoM / Agner / InstLatX64.

3 years ago[X86][SLM] Fix HADD/HSUB uops, latency and throughput
Simon Pilgrim [Tue, 7 Sep 2021 21:30:21 +0000 (22:30 +0100)]
[X86][SLM] Fix HADD/HSUB uops, latency and throughput

Noticed while trying to improve generic reduction costs via the D103695 helper script. Confirmed with Intel AoM / Agner / InstLatX64.

3 years ago[X86][SLM] Swap LoadLat and LoadUOps in the SLMWriteResPair<> helper. NFC.
Simon Pilgrim [Tue, 7 Sep 2021 20:51:52 +0000 (21:51 +0100)]
[X86][SLM] Swap LoadLat and LoadUOps in the SLMWriteResPair<> helper. NFC.

We set the LoadUOps argument a lot more frequently that LoadLat, by swapping them we can simplify a number of declarations.

3 years ago[X86] Support *_set1_pch(Float16 _Complex h)
Wang, Pengfei [Sat, 11 Sep 2021 09:45:30 +0000 (17:45 +0800)]
[X86] Support *_set1_pch(Float16 _Complex h)

Reviewed By: LuoYuanke

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

3 years ago[gn build] Port 2269a941a450
LLVM GN Syncbot [Sat, 11 Sep 2021 09:02:52 +0000 (09:02 +0000)]
[gn build] Port 2269a941a450

3 years agoRevert 5629afea910 and bb27e456435 while I look into bot failures.
Lang Hames [Sat, 11 Sep 2021 08:58:30 +0000 (18:58 +1000)]
Revert 5629afea910 and bb27e456435 while I look into bot failures.

This reverts commit 5629afea9109d3b72064cbe70e1ca91ffb9dc0a2 ("[ORC] Add missing
include."), and bb27e4564355243e479cab40885d6e0f7f640572 ("[ORC] Add
SimpleRemoteEPC: ExecutorProcessControl over SPS + abstract transport.").

The SimpleRemoteEPC patch currently assumes availability of threads, and needs
to be rewritten with LLVM_ENABLE_THREADS guards.

3 years ago[gn build] Port bb27e4564355
LLVM GN Syncbot [Sat, 11 Sep 2021 08:51:51 +0000 (08:51 +0000)]
[gn build] Port bb27e4564355

3 years ago[ORC] Add missing include.
Lang Hames [Sat, 11 Sep 2021 08:51:16 +0000 (18:51 +1000)]
[ORC] Add missing include.

3 years ago[ORC] Add SimpleRemoteEPC: ExecutorProcessControl over SPS + abstract transport.
Lang Hames [Tue, 7 Sep 2021 23:24:45 +0000 (09:24 +1000)]
[ORC] Add SimpleRemoteEPC: ExecutorProcessControl over SPS + abstract transport.

SimpleRemoteEPC is an ExecutorProcessControl implementation (with corresponding
new server class) that uses ORC SimplePackedSerialization (SPS) to serialize and
deserialize EPC-messages to/from byte-buffers. The byte-buffers are sent and
received via a new SimpleRemoteEPCTransport interface that can be implemented to
run SimpleRemoteEPC over whatever underlying transport system (IPC, RPC, network
sockets, etc.) best suits your use case.

The SimpleRemoteEPCServer class provides executor-side support. It uses a
customizable SimpleRemoteEPCServer::Dispatcher object to dispatch wrapper
function calls to prevent the RPC thread from being blocked (a problem in some
earlier remote-JIT server implementations). Almost all functionality (beyond the
bare basics needed to bootstrap) is implemented as wrapper functions to keep the
implementation simple and uniform.

Compared to previous remote JIT utilities (OrcRemoteTarget*,
OrcRPCExecutorProcessControl), more consideration has been given to
disconnection and error handling behavior: Graceful disconnection is now always
initiated by the ORC side of the connection, and failure at either end (or in
the transport) will result in Errors being delivered to both ends to enable
controlled tear-down of the JIT and Executor (in the Executor's case this means
"as controlled as the JIT'd code allows").

The introduction of SimpleRemoteEPC will allow us to remove other remote-JIT
support from ORC (including the legacy OrcRemoteTarget* code used by lli, and
the OrcRPCExecutorProcessControl and OrcRPCEPCServer classes), and then remove
ORC RPC itself.

The llvm-jitlink and llvm-jitlink-executor tools have been updated to use
SimpleRemoteEPC over file descriptors. Future commits will move lli and other
tools and example code to this system, and remove ORC RPC.

3 years agoFix python 2-vs-3 issues in add_new_check.py and rename_check.py
Matt Beardsley [Sat, 11 Sep 2021 07:52:47 +0000 (09:52 +0200)]
Fix python 2-vs-3 issues in add_new_check.py and rename_check.py

As of this commit:
  https://github.com/llvm/llvm-project/commit/307b1fdd

If either of those scripts are invoked with python 2, neither works due to:
  "TypeError: write() argument 1 must be unicode, not str"

And if rename_check.py is invoked with python 3:
  "ValueError: binary mode doesn't take an encoding argument"
(referring to `with io.open(filename, 'wb', encoding='utf8') as f:`), and

Another issue in rename_check.py in python 2:
  "TypeError: list object is not an iterator"
(referring to `next(filter( ... os.listdir(old_module_path)))`)

(so, rename_check doesn't work with either 2 or 3, and add_new_check
doesn't work with 2, but does work with 3)

I ran these steps to test both python versions:
(manually - appears to be the "status quo" for these files)

  python3 clang-tools-extra/clang-tidy/add_new_check.py readability ggggg
  python3 clang-tools-extra/clang-tidy/rename_check.py readability-ggggg readability-hhhhh

  git checkout HEAD -- clang-tools-extra/clang-tidy/readability/CMakeLists.txt clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp clang-tools-extra/docs/ReleaseNotes.rst clang-tools-extra/docs/clang-tidy/checks/list.rst
  rm -f clang-tools-extra/clang-tidy/readability/GggggCheck.cpp clang-tools-extra/clang-tidy/readability/GggggCheck.h clang-tools-extra/docs/clang-tidy/checks/readability-ggggg.rst clang-tools-extra/test/clang-tidy/checkers/readability-ggggg.cpp clang-tools-extra/clang-tidy/readability/HhhhhCheck.cpp clang-tools-extra/clang-tidy/readability/HhhhhCheck.h clang-tools-extra/docs/clang-tidy/checks/readability-hhhhh.rst

  python2 clang-tools-extra/clang-tidy/add_new_check.py readability ggggg
  python2 clang-tools-extra/clang-tidy/rename_check.py readability-ggggg readability-hhhhh

  git checkout HEAD -- clang-tools-extra/clang-tidy/readability/CMakeLists.txt clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp clang-tools-extra/docs/ReleaseNotes.rst clang-tools-extra/docs/clang-tidy/checks/list.rst
  rm -f clang-tools-extra/clang-tidy/readability/GggggCheck.cpp clang-tools-extra/clang-tidy/readability/GggggCheck.h clang-tools-extra/docs/clang-tidy/checks/readability-ggggg.rst clang-tools-extra/test/clang-tidy/checkers/readability-ggggg.cpp clang-tools-extra/clang-tidy/readability/HhhhhCheck.cpp clang-tools-extra/clang-tidy/readability/HhhhhCheck.h clang-tools-extra/docs/clang-tidy/checks/readability-hhhhh.rst

Reviewed By: kbobyrev

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

3 years ago[AArch64][GlobalISel] Select full-fp16 s16 G_FCONSTANT as a constant pool load
Jessica Paquette [Mon, 30 Aug 2021 23:36:47 +0000 (16:36 -0700)]
[AArch64][GlobalISel] Select full-fp16 s16 G_FCONSTANT as a constant pool load

When we have full-fp16 support, we should (manually select) s16 G_FCONSTANT to
a constant pool load.

Add support for that to `emitLoadFromConstantPool` + the existing constant
selection code.

Also tidy up the constant selection code a little. There were some out-of-date
comments + some dead code.

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

3 years ago[llvm-cov] Add error for invalid -path-equivalence format
Keith Smiley [Wed, 1 Sep 2021 05:35:44 +0000 (22:35 -0700)]
[llvm-cov] Add error for invalid -path-equivalence format

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

3 years ago[JITLink] Working memory shouldn't be subject to alignment constraints.
Lang Hames [Wed, 8 Sep 2021 12:30:08 +0000 (22:30 +1000)]
[JITLink] Working memory shouldn't be subject to alignment constraints.

Refactors copyBlockContentToWorkingMemory to use offsets rather than direct
pointers to working memory. This simplifies the problem of maintaining
alignments between blocks in working memory, without requiring the working
memory itself to be aligned.

3 years ago[ORC] Fix missing newline in debugging output.
Lang Hames [Tue, 7 Sep 2021 11:41:39 +0000 (21:41 +1000)]
[ORC] Fix missing newline in debugging output.

3 years ago[ORC] Merge LLVMSPSSerializers.h into SimplePackedSerialization.h.
Lang Hames [Mon, 6 Sep 2021 00:02:56 +0000 (10:02 +1000)]
[ORC] Merge LLVMSPSSerializers.h into SimplePackedSerialization.h.

Since the ORC runtime and LLVM are no longer sharing SPS code (the ORC runtime
has its own copy) there is no reason to keep these separate.

3 years ago[ORC] Use EPC for EPCGeneric MemoryAccess / JITLinkMemoryManager construction.
Lang Hames [Sun, 5 Sep 2021 08:29:05 +0000 (18:29 +1000)]
[ORC] Use EPC for EPCGeneric MemoryAccess / JITLinkMemoryManager construction.

This allows these classes to be created during EPC construction, before an
ExecutionSession is available.

3 years agoRevert "Revert "[AArch64][SVE][InstCombine] Canonicalize aarch64_sve_dup_x intrinsic...
Usman Nadeem [Sat, 11 Sep 2021 00:57:29 +0000 (17:57 -0700)]
Revert "Revert "[AArch64][SVE][InstCombine] Canonicalize aarch64_sve_dup_x intrinsic to IR splat operation""

This reverts commit eee7d225ded98f42d37c05ec292bbb18560ce06b.
Effectively relanding 98c37247d81dfc967ecc49eee7a15612b6510f67
after fixing the failing tests.

Change-Id: I5d7461aeb820a2d5f1895457d824a8de4d316ee5

3 years agonullptr initialize variables, spotted on msan bots.
Eric Christopher [Sat, 11 Sep 2021 01:10:16 +0000 (18:10 -0700)]
nullptr initialize variables, spotted on msan bots.

3 years ago[docs] Improve description of LLVM_BUILD_TESTS
Keith Smiley [Thu, 2 Sep 2021 00:20:13 +0000 (17:20 -0700)]
[docs] Improve description of LLVM_BUILD_TESTS

This makes it clear that this only has an effect if you use the all
build target.

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

3 years agoRecognize namespaced all_image_infos symbol name from dyld
Jason Molenda [Fri, 10 Sep 2021 23:56:48 +0000 (16:56 -0700)]
Recognize namespaced all_image_infos symbol name from dyld

In macOS 12, the symbol name for the dyld_all_image_infos struct
in dyld has a namespace qualifier.  Search for it without qualification,
then with qualification when doing a by-name search.  (lldb will
only search for it by name when loading a user process Mach-O corefile)

rdar://76270013

3 years ago[clang-format] Restrict the special handling for K&R C to C/C++
owenca [Fri, 10 Sep 2021 08:03:01 +0000 (01:03 -0700)]
[clang-format] Restrict the special handling for K&R C to C/C++

Commits 58494c856a15f6bc614546e1, and 0fc27ef19670 added special
handlings for K&R C function definitions and caused some
JavaScript/TypeScript regressions which were addressed in D107267,
D108538, and D108620. This patch would have prevented these known
regressions and will fix any unknown ones.

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

3 years ago[OpenMP] Add flag for setting debug in the offloading device
Joseph Huber [Thu, 9 Sep 2021 20:40:59 +0000 (16:40 -0400)]
[OpenMP] Add flag for setting debug in the offloading device

This patch introduces the flags `-fopenmp-target-debug` and
`-fopenmp-target-debug=` to set the value of a global in the device.
This will be used to enable or disable debugging features statically in
the device runtime library.

Reviewed By: jdoerfert

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

3 years ago[OpenMP] Add more verbose remarks for runtime folding
Joseph Huber [Fri, 10 Sep 2021 20:17:54 +0000 (16:17 -0400)]
[OpenMP] Add more verbose remarks for runtime folding

We peform runtime folding, but do not currently emit remarks when it is
performed. This is because it comes from the runtime library and is
beyond the users control. However, people may still wish to view  this
and similar information easily, so we can enable this behaviour using a
special flag to enable verbose remarks.

Reviewed By: jdoerfert

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

3 years ago[lldb] Remove unused typedefs from lldb-forward.h
Alex Langford [Fri, 10 Sep 2021 20:37:39 +0000 (13:37 -0700)]
[lldb] Remove unused typedefs from lldb-forward.h

3 years ago[OpenMP][libomptarget] Add __tgt_target_return_t enum for __tgt_target_XXX return int
Ye Luo [Mon, 6 Sep 2021 05:55:30 +0000 (00:55 -0500)]
[OpenMP][libomptarget] Add __tgt_target_return_t enum for __tgt_target_XXX return int

The defintion of OFFLOAD_SUCCESS and OFFLOAD_FAIL used in plugin APIs and libomptarget public APIs are not consistent.
Create __tgt_target_return_t for libomptarget public APIs.

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

3 years agoReapply "[OpenMP] Group side-effects to improve guarding efficiency"
Johannes Doerfert [Fri, 10 Sep 2021 19:09:10 +0000 (14:09 -0500)]
Reapply "[OpenMP] Group side-effects to improve guarding efficiency"

This reapplies ca134c3963d310c2868f08c211011d610b4eefb5, effectively
reverting commit d2f206e0afeba2b08a42903cfb8ad97a7de8a92c.

Minor test changes to make the test pass.

3 years agoReapply "[GlobalOpt][FIX] Do not embed initializers into AS!=0 globals""
Johannes Doerfert [Fri, 10 Sep 2021 18:44:41 +0000 (13:44 -0500)]
Reapply "[GlobalOpt][FIX] Do not embed initializers into AS!=0 globals""

This reapplies commit 7dbba3376f633cabcf4df568bc9ca95f44a35203, or, put
differently, this reverts commit d9a8d20827dcddad831751bc38ff178e70f0b2f5.

The test now requires the amdgpu and nvptx backend explicitly as it
won't work without properly.

3 years ago[mlir][tosa] Add shape inference for tosa.while
Rob Suderman [Fri, 27 Aug 2021 02:21:29 +0000 (19:21 -0700)]
[mlir][tosa] Add shape inference for tosa.while

Tosa.while shape inference requires repeatedly running shape inference across
the body of the loop until the types become static as we do not know the number
of iterations required by the loop body. Once the least specific arguments are
known they are propagated to both regions.

To determine the final end type, the least restrictive types are determined
from all yields.

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

3 years ago[ARC] Improve code generated for i32 ADDC/ADDE and SUBC/SUBE
Mark Schimmel [Fri, 10 Sep 2021 20:01:51 +0000 (13:01 -0700)]
[ARC] Improve code generated for i32 ADDC/ADDE and SUBC/SUBE
This change improves the code generated for long long addition and subtraction

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

3 years agoRevert "[AArch64][SVE][InstCombine] Canonicalize aarch64_sve_dup_x intrinsic to IR...
Usman Nadeem [Fri, 10 Sep 2021 20:01:48 +0000 (13:01 -0700)]
Revert "[AArch64][SVE][InstCombine] Canonicalize aarch64_sve_dup_x intrinsic to IR splat operation"

This reverts commit 98c37247d81dfc967ecc49eee7a15612b6510f67.

3 years ago[AArch64][SVE][InstCombine] Canonicalize aarch64_sve_dup_x intrinsic to IR splat...
Usman Nadeem [Fri, 10 Sep 2021 19:22:40 +0000 (12:22 -0700)]
[AArch64][SVE][InstCombine] Canonicalize aarch64_sve_dup_x intrinsic to IR splat operation

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

Change-Id: I47adc1984a54bea02bf5a0a767b765afe7e16aa3

3 years ago[clang][deps] Move tests to the Clang subdirectory
Jan Svoboda [Fri, 10 Sep 2021 19:36:49 +0000 (21:36 +0200)]
[clang][deps] Move tests to the Clang subdirectory

3 years ago[InstCombine] add tests for sub of min/max intrinsics; NFC
Sanjay Patel [Fri, 10 Sep 2021 17:01:45 +0000 (13:01 -0400)]
[InstCombine] add tests for sub of min/max intrinsics; NFC

3 years ago[OpenMP] Check OpenMP assumptions on call-sites as well
Joseph Huber [Fri, 10 Sep 2021 18:11:18 +0000 (14:11 -0400)]
[OpenMP] Check OpenMP assumptions on call-sites as well

This patch adds functionality to check assumption attributes on call
sites as well.

Reviewed By: jdoerfert

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

3 years ago[OpenMP] Make CUDA math library functions SPMD amenable
Joseph Huber [Mon, 30 Aug 2021 23:52:48 +0000 (19:52 -0400)]
[OpenMP] Make CUDA math library functions SPMD amenable

This patch adds the SPMD amenable assumption to the CUDA math library
defintions in Clang. Previously these functions would block SPMD
execution on the device because they're intrinsic calls into the library
and can't be calculated. These functions don't have side-effects so they
are safe to execute in SPMD mode.

Depends on D105937

Reviewed By: jdoerfert

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

3 years ago[libc] Add extension functions fedisableexcept, feenableexcept and fegetexcept.
Siva Chandra Reddy [Thu, 9 Sep 2021 19:11:54 +0000 (19:11 +0000)]
[libc] Add extension functions fedisableexcept, feenableexcept and fegetexcept.

Reviewed By: michaelrj

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

3 years ago[hwasan] Do not instrument accesses to uninteresting allocas.
Florian Mayer [Thu, 9 Sep 2021 09:09:26 +0000 (10:09 +0100)]
[hwasan] Do not instrument accesses to uninteresting allocas.

This leads to a statistically significant improvement when using -hwasan-instrument-stack=0: https://bit.ly/3AZUIKI.
When enabling stack instrumentation, the data appears gets better but not statistically significantly so. This is consistent
with the very moderate improvements I have seen for stack safety otherwise, so I expect it to improve when the underlying
issue of that is resolved.

Reviewed By: eugenis

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

3 years ago[Sanitizers] intercept netent, protoent and mincore on FreeBSD.
David Carlier [Fri, 10 Sep 2021 18:23:14 +0000 (19:23 +0100)]
[Sanitizers] intercept netent, protoent and mincore on FreeBSD.
netent on Linux in addition as well.

Reviewd By: vitalybuka

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

3 years ago[stack-safety] Allow to determine safe accesses.
Florian Mayer [Fri, 10 Sep 2021 08:49:07 +0000 (09:49 +0100)]
[stack-safety] Allow to determine safe accesses.

Reviewed By: vitalybuka

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

3 years ago[clang] Fix typo in test from a723310b4
Nico Weber [Fri, 10 Sep 2021 18:13:42 +0000 (14:13 -0400)]
[clang] Fix typo in test from a723310b4

We want the driver-level flag here, else the test passes for the wrong reasons.
See comments on https://reviews.llvm.org/D99901.

3 years ago[CodeGen, Target] Use pred_empty and succ_empty (NFC)
Kazu Hirata [Fri, 10 Sep 2021 18:11:31 +0000 (11:11 -0700)]
[CodeGen, Target] Use pred_empty and succ_empty (NFC)

3 years ago[lldb] Add support for debugging via the dynamic linker.
Rumeet Dhindsa [Fri, 10 Sep 2021 17:59:31 +0000 (10:59 -0700)]
[lldb] Add support for debugging via the dynamic linker.

This patch adds support for shared library load when the executable is
called through ld.so.

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

3 years ago[clang] `aligned_alloc` allocation function specifies alignment in first arg, manifes...
Roman Lebedev [Fri, 10 Sep 2021 17:20:10 +0000 (20:20 +0300)]
[clang] `aligned_alloc` allocation function specifies alignment in first arg, manifest that knowledge

Mainly, if a constant value was passed as an alignment,
then we correctly annotate the alignment of the returned value
of @aligned_alloc. And if it wasn't constant,
then we also don't loose that, but emit an assumption.

3 years ago[NFCI][clang] Move allocation alignment manifestation for malloc-like into Sema from...
Roman Lebedev [Fri, 10 Sep 2021 16:35:38 +0000 (19:35 +0300)]
[NFCI][clang] Move allocation alignment manifestation for malloc-like into Sema from Codegen

... so that it happens right next to `AddKnownFunctionAttributesForReplaceableGlobalAllocationFunction()`,
which is good for consistency.

3 years ago[NFC][clang] Improve test coverage for alignment manifestation on aligned allocation...
Roman Lebedev [Fri, 10 Sep 2021 16:35:31 +0000 (19:35 +0300)]
[NFC][clang] Improve test coverage for alignment manifestation on aligned allocation functions

3 years ago[AArch64ISelLowering] Fix null pointer access in performSVEAndCombine.
Huihui Zhang [Fri, 10 Sep 2021 17:18:04 +0000 (10:18 -0700)]
[AArch64ISelLowering] Fix null pointer access in performSVEAndCombine.

When combining 'and' of an unsigned unpack and shuffle instruction,
bail early if shuffle is not constructed from a constant integer.

Reviewed By: paulwalker-arm

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

3 years ago[openmp][amdgpu] Update SupportAndFAQ docs
Jon Chesterfield [Fri, 10 Sep 2021 17:35:29 +0000 (18:35 +0100)]
[openmp][amdgpu] Update SupportAndFAQ docs

3 years ago[AggressiveInstCombine] Add `udiv` and `urem` instrs to TruncInstCombine DAG
Anton Afanasyev [Tue, 7 Sep 2021 10:16:55 +0000 (13:16 +0300)]
[AggressiveInstCombine] Add `udiv` and `urem` instrs to TruncInstCombine DAG

Add `udiv` and `urem` instructions to the DAG post-dominated by `trunc`,
allowing TruncInstCombine to reduce bitwidth of expressions containing these
instructions. It is sufficient to require that all truncated bits of both
operands are zeros: https://alive2.llvm.org/ce/z/yiithn
(`urem` case is identical).

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

3 years ago[Test][AggressiveInstCombine] Add test for `udiv` and `urem`
Anton Afanasyev [Thu, 9 Sep 2021 13:52:24 +0000 (16:52 +0300)]
[Test][AggressiveInstCombine] Add test for `udiv` and `urem`

Precommit test for D109515

3 years agoRevert "[OpenMP] Group side-effects to improve guarding efficiency"
Johannes Doerfert [Fri, 10 Sep 2021 17:24:00 +0000 (12:24 -0500)]
Revert "[OpenMP] Group side-effects to improve guarding efficiency"

This reverts commit ca134c3963d310c2868f08c211011d610b4eefb5.

There seems to be a problem with the tests, investigating now:
  https://lab.llvm.org/buildbot/#/builders/61/builds/14574

3 years agoRevert "[GlobalOpt][FIX] Do not embed initializers into AS!=0 globals"
Johannes Doerfert [Fri, 10 Sep 2021 17:23:08 +0000 (12:23 -0500)]
Revert "[GlobalOpt][FIX] Do not embed initializers into AS!=0 globals"

This reverts commit 7dbba3376f633cabcf4df568bc9ca95f44a35203.

There seems to be a problem with the tests, investigating now:
  https://lab.llvm.org/buildbot/#/builders/61/builds/14574

3 years ago[OpenMP][Docs] Remove old/outdated webpage
Johannes Doerfert [Mon, 23 Aug 2021 21:55:14 +0000 (16:55 -0500)]
[OpenMP][Docs] Remove old/outdated webpage

This should have happened a long time ago, now that openmp.llvm.org
redirects to openmp.llvm.org/docs we completely switched over to the
sphinx documentation page instead.

Reviewed By: JonChesterfield

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

3 years ago[OpenMP] Encode `omp [...] assume[...]` assumptions with `omp[x]` prefix
Johannes Doerfert [Tue, 13 Jul 2021 20:35:58 +0000 (15:35 -0500)]
[OpenMP] Encode `omp [...] assume[...]` assumptions with `omp[x]` prefix

Since these assumptions are coming from OpenMP it makes sense to mark
them as such in the generic IR encoding. Standardized assumptions will
be named
  omp_ASSUMPTION_NAME
and extensions will be named
  ompx_ASSUMPTION_NAME
which is the OpenMP 5.2 syntax for "extensions" of any kind.

This also matches what the OpenMP-Opt pass expects.

Summarized,
  #pragma omp [...] assume[s] no_parallelism
now generates the same IR assumption annotation as
  __attribute__((assume("omp_no_parallelism")))

Reviewed By: jhuber6

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

3 years ago[GlobalOpt][FIX] Do not embed initializers into AS!=0 globals
Johannes Doerfert [Thu, 2 Sep 2021 19:12:22 +0000 (14:12 -0500)]
[GlobalOpt][FIX] Do not embed initializers into AS!=0 globals

Not all address spaces support initializers for globals and we can
therefore not set them without checking if they are allowed. This
patch adds a hook into TTI to check if an AS allows non-undef
initializers. We disable it for all but address space 0 by default,
NVPTX and AMDGPU targets allow all but address space 3.

Reviewed By: tra

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

3 years ago[OpenMP] Group side-effects to improve guarding efficiency
Johannes Doerfert [Wed, 11 Aug 2021 05:03:42 +0000 (00:03 -0500)]
[OpenMP] Group side-effects to improve guarding efficiency

When we guard side-effects as part of SPMDzation we do it for
consecutive instructions that need guarding. This patch will try to
reorder guarded side-effects in a block to decrease the number of
guarded regions we need. It does not use any smarts, e.g., alias
analysis, to move side-effects over non-interfering reads. Instead,
it only moves side-effects downwards to the next guarded side-effect
if there was nothing in between that could have possibly be affected.

Reviewed By: ggeorgakoudis

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

3 years ago[ARM] Remove unused tblgen arguments. NFC
David Green [Fri, 10 Sep 2021 17:03:54 +0000 (18:03 +0100)]
[ARM] Remove unused tblgen arguments. NFC

As per D109359, this removes or makes use of some of the existing unused
NEON and base ARM tblgn arguments.

3 years ago[CallLowering] Support opaque pointers
Nikita Popov [Fri, 10 Sep 2021 16:13:08 +0000 (18:13 +0200)]
[CallLowering] Support opaque pointers

Always use the byval/inalloca/preallocated type (which is required
nowadays), don't fall back on the pointer element type.

This requires adding Function::getParamPreallocatedType() to
mirror the CallBase API, so that the templated code can work with
both.

3 years ago[IR] Remove unused parameter (NFC)
Nikita Popov [Fri, 10 Sep 2021 16:15:40 +0000 (18:15 +0200)]
[IR] Remove unused parameter (NFC)

3 years ago[RISCV] Enable CGP to sink splat operands of Add/Sub/Mul/Shl/LShr/AShr
Craig Topper [Fri, 10 Sep 2021 16:03:59 +0000 (09:03 -0700)]
[RISCV] Enable CGP to sink splat operands of Add/Sub/Mul/Shl/LShr/AShr

LICM may have pulled out a splat, but with .vx instructions we
can fold it into an operation.

This patch enables CGP to reverse the LICM transform and move the
splat back into the loop.

I've started with the commutable integer operations and shifts, but we can
extend this with more operations in future patches.

Reviewed By: frasercrmck

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

3 years ago[RISCV] Teach vsetvli insertion that stores don't use the policy bits in vtype.
Craig Topper [Thu, 9 Sep 2021 22:17:51 +0000 (15:17 -0700)]
[RISCV] Teach vsetvli insertion that stores don't use the policy bits in vtype.

This can avoid a vsetvl after a tail undisturbed operation.

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

3 years ago[lldb] [test] Remove parent check in Subprocess/clone-follow-child-softbp.test
Michał Górny [Fri, 10 Sep 2021 16:02:21 +0000 (18:02 +0200)]
[lldb] [test] Remove parent check in Subprocess/clone-follow-child-softbp.test

Hopefully this will resolve the remaining flakiness.

3 years ago[lld][WebAssembly] Cleanup output of --verbose
Sam Clegg [Fri, 10 Sep 2021 08:46:03 +0000 (04:46 -0400)]
[lld][WebAssembly] Cleanup output of --verbose

Remove some unnecessary logging from wasm-ld when running under
`--verbose`.  Unlike `-debug` this logging is available in release
builds.  This change makes it little more minimal/readable.

Also, avoid compiling the `debugWrite` function in releaase builds
where it does nothing.  This should remove a lot debug strings from
the binary, and avoid having to construct unused debug strings at
runtime.

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

3 years ago[lldb] [test] Skip A/vRun/QEnvironment* tests on Windows, and fix them
Michał Górny [Fri, 10 Sep 2021 14:34:20 +0000 (16:34 +0200)]
[lldb] [test] Skip A/vRun/QEnvironment* tests on Windows, and fix them

Skip A/vRun/QEnvironment* tests on Windows as testing for output is
known not to work there.  Add a missing output check to the vRun test.

3 years ago[lldb] [test] Attempt to fix gdb_remote_client A/vRun tests on Windows
Michał Górny [Fri, 10 Sep 2021 14:27:29 +0000 (16:27 +0200)]
[lldb] [test] Attempt to fix gdb_remote_client A/vRun tests on Windows

3 years ago[lldb] [test] Mark new launch/QEnvironment tests as llgs category
Michał Górny [Fri, 10 Sep 2021 14:06:29 +0000 (16:06 +0200)]
[lldb] [test] Mark new launch/QEnvironment tests as llgs category

3 years ago[lldb] [test] Skip file permission tests on Windows
Michał Górny [Fri, 10 Sep 2021 14:03:02 +0000 (16:03 +0200)]
[lldb] [test] Skip file permission tests on Windows

3 years ago[ARM] Remove unused tblgen arguments. NFCI
David Green [Fri, 10 Sep 2021 14:06:31 +0000 (15:06 +0100)]
[ARM] Remove unused tblgen arguments. NFCI

As per D109359, this removes or makes use of some of the existing unused
MVE tblgn arguments.

3 years ago[WebAssembly][libObject] Avoid re-use of Section object during parsing
Sam Clegg [Tue, 31 Aug 2021 11:04:31 +0000 (07:04 -0400)]
[WebAssembly][libObject] Avoid re-use of Section object during parsing

The re-use of this struct across iterations of the loop was causing
fields (specifically Name) to be incorrectly shared between multiple
sections.

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

3 years ago[clang-offload-bundler] Fix compatibility testing for non-assert builds
Saiyedul Islam [Fri, 10 Sep 2021 11:16:13 +0000 (16:46 +0530)]
[clang-offload-bundler] Fix compatibility testing for non-assert builds

Test using debug-only=CodeObjectComaptibility was failing in
non-assert builds, so it has been moved to a different file which
requires assert.

Reviewed By: RKSimon

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

3 years ago[OpaquePtr] Forbid mixing typed and opaque pointers
Nikita Popov [Sat, 4 Sep 2021 10:18:52 +0000 (12:18 +0200)]
[OpaquePtr] Forbid mixing typed and opaque pointers

Currently, opaque pointers are supported in two forms: The
-force-opaque-pointers mode, where all pointers are opaque and
typed pointers do not exist. And as a simple ptr type that can
coexist with typed pointers.

This patch removes support for the mixed mode. You either get
typed pointers, or you get opaque pointers, but not both. In the
(current) default mode, using ptr is forbidden. In -opaque-pointers
mode, all pointers are opaque.

The motivation here is that the mixed mode introduces additional
issues that don't exist in fully opaque mode. D105155 is an example
of a design problem. Looking at D109259, it would probably need
additional work to support mixed mode (e.g. to generate GEPs for
typed base but opaque result). Mixed mode will also end up
inserting many casts between i8* and ptr, which would require
significant additional work to consistently avoid.

I don't think the mixed mode is particularly valuable, as it
doesn't align with our end goal. The only thing I've found it to
be moderately useful for is adding some opaque pointer tests in
between typed pointer tests, but I think we can live without that.

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

3 years ago[InstCombine] add tests for X == 0 ? 0 : X * Y ; NFC
Filipp Zhinkin [Fri, 10 Sep 2021 13:06:48 +0000 (09:06 -0400)]
[InstCombine] add tests for X == 0 ? 0 : X * Y ; NFC

These are the tests for D108408 with current baseline results.

3 years ago[AArch64] Regenerate some test checks. NFC
David Green [Fri, 10 Sep 2021 12:48:15 +0000 (13:48 +0100)]
[AArch64] Regenerate some test checks. NFC

This updates some mostly update_test_check test files and generates the
check lines with the script, making them more maintainable.

3 years ago[clang][deps] Test diagnostic options are being respected
Jan Svoboda [Fri, 10 Sep 2021 12:44:18 +0000 (14:44 +0200)]
[clang][deps] Test diagnostic options are being respected

This patch tests code in D108976. This split is necessary to avoid temporary regression.

Depends on D108974,

Reviewed By: dexonsmith

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

3 years ago[clang][deps] Sanitize both instances of DiagnosticOptions
Jan Svoboda [Fri, 10 Sep 2021 12:42:11 +0000 (14:42 +0200)]
[clang][deps] Sanitize both instances of DiagnosticOptions

During dependency scanning, we generally want to suppress -Werror. Apply the same logic to the DiagnosticOptions instance used for command-line parsing.

This fixes a test failure on the PS4 bot, where the system header directory could not be found, which was reported due to -Werror being on the command line and not being sanitized.

3 years ago[SelectionDAG] PromoteIntRes_EXTRACT_SUBVECTOR for scalable vectors (widening).
Sander de Smalen [Fri, 10 Sep 2021 11:54:22 +0000 (12:54 +0100)]
[SelectionDAG] PromoteIntRes_EXTRACT_SUBVECTOR for scalable vectors (widening).

This patch implements legalization of EXTRACT_SUBVECTOR for the case
where the result needs promoting, and the input type requires widening.

Reviewed By: frasercrmck

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

3 years ago[SelectionDAG] PromoteIntRes_EXTRACT_SUBVECTOR for scalable vectors.
Sander de Smalen [Fri, 10 Sep 2021 11:13:54 +0000 (12:13 +0100)]
[SelectionDAG] PromoteIntRes_EXTRACT_SUBVECTOR for scalable vectors.

This patch implements legalization of EXTRACT_SUBVECTOR for the case
where the result needs promoting, and the input type is either legal
or requires splitting.

The idea is that the operation is broken down into simpler steps,
by first extracting a smaller subvector until the input vector
becomes legal or requires promotion.

Reviewed By: CarolineConcatto

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

3 years ago[lldb] Clean up Platform/CMakeLists.txt
Pavel Labath [Fri, 10 Sep 2021 12:16:00 +0000 (14:16 +0200)]
[lldb] Clean up Platform/CMakeLists.txt

Remove comments looking like preprocessor directives (thankfully cmake
does not have those yet), and sort the file.

3 years ago[mlir] spelling and style changes in ReconcileUnrealizedCasts.cpp. NFC.
Alex Zinenko [Fri, 10 Sep 2021 12:08:15 +0000 (14:08 +0200)]
[mlir] spelling and style changes in ReconcileUnrealizedCasts.cpp. NFC.

3 years ago[lldb] [gdb-remote] Use standardized GDB errno values
Michał Górny [Mon, 16 Aug 2021 17:33:07 +0000 (19:33 +0200)]
[lldb] [gdb-remote] Use standardized GDB errno values

GDB uses normalized errno values for vFile errors.  Implement
the translation between them and system errno values in the gdb-remote
plugin.

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

3 years ago[lldb] [gdb-remote] Support QEnvironment fallback to hex-encoded
Michał Górny [Thu, 12 Aug 2021 15:01:30 +0000 (17:01 +0200)]
[lldb] [gdb-remote] Support QEnvironment fallback to hex-encoded

Fall back to QEnvironmentHexEncoded if QEnvironment is not supported.
The latter packet is an LLDB extension, while the former is universally
supported.

Add tests for both QEnvironment and QEnvironmentHexEncoded packets,
including both use due to characters that need escaping and fallback
when QEnvironment is not supported.

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

3 years ago[lldb] [gdb-remote] Implement the vRun packet
Michał Górny [Wed, 11 Aug 2021 20:58:11 +0000 (22:58 +0200)]
[lldb] [gdb-remote] Implement the vRun packet

Implement the simpler vRun packet and prefer it over the A packet.
Unlike the latter, it tranmits command-line arguments without redundant
indices and lengths.  This also improves GDB compatibility since modern
versions of gdbserver do not implement the A packet at all.

Make qLaunchSuccess not obligatory when using vRun.  It is not
implemented by gdbserver, and since vRun returns the stop reason,
we can assume it to be successful.

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

3 years ago[lldb] [gdb-remote] Add fallbacks for vFile:mode and vFile:exists
Michał Górny [Tue, 10 Aug 2021 11:01:34 +0000 (13:01 +0200)]
[lldb] [gdb-remote] Add fallbacks for vFile:mode and vFile:exists

Add a GDB-compatible fallback to vFile:fstat for vFile:mode, and to
vFile:open for vFile:exists.  Note that this is only partial fallback,
as it fails if the file cannot be opened.

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

3 years ago[lldb] Add new commands and tests for getting file perms & exists
Michał Górny [Tue, 10 Aug 2021 10:03:35 +0000 (12:03 +0200)]
[lldb] Add new commands and tests for getting file perms & exists

Add two new commands 'platform get-file-permissions' and 'platform
file-exists' for the respective bits of LLDB protocol.  Add tests for
them.  Fix error handling in GetFilePermissions().

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

3 years ago[lldb] [test] Move "platform connect" logic into a common class
Michał Górny [Fri, 10 Sep 2021 09:17:08 +0000 (11:17 +0200)]
[lldb] [test] Move "platform connect" logic into a common class

Create a common GDBPlatformClientTestBase class and move the platform
select/connect logic there to reduce duplication.

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

3 years ago[OpenCL][Docs] Update OpenCL 3.0 status info.
Anastasia Stulova [Fri, 10 Sep 2021 12:05:03 +0000 (13:05 +0100)]
[OpenCL][Docs] Update OpenCL 3.0 status info.

Update info on OpenCLSupport page to reflect changes
committed after release 13 branched.

3 years ago[clang][tooling] Properly initialize DiagnosticsEngine for cc1 command-line construction
Jan Svoboda [Fri, 10 Sep 2021 11:46:01 +0000 (13:46 +0200)]
[clang][tooling] Properly initialize DiagnosticsEngine for cc1 command-line construction

In `ToolInvocation::run`, the driver -> cc1 command-line transformation uses `DiagnosticsEngine` that wasn't completely initialized. This patch ensures `ProcessWarningOptions(DiagnosticsEngine&, const DiagnosticOptions &)` is called.

Depends on D108982.

Reviewed By: dexonsmith

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

3 years ago[Test][NFC] Regenerate checks in test
Max Kazantsev [Fri, 10 Sep 2021 11:45:03 +0000 (18:45 +0700)]
[Test][NFC] Regenerate checks in test

3 years ago[clang][deps] Use correct DiagnosticOptions for command-line handling
Jan Svoboda [Fri, 10 Sep 2021 11:43:48 +0000 (13:43 +0200)]
[clang][deps] Use correct DiagnosticOptions for command-line handling

In this patch the dependency scanner starts using proper `DiagnosticOptions` parsed from the actual TU command-line in order to mimic what the actual compiler would do. The actual functionality will be enabled and tested in follow-up patches. (This split is necessary to avoid temporary regression.)

Depends on D108976.

Reviewed By: dexonsmith, arphaman

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

3 years ago[mlir][linalg] Fix bufferize pattern to allow unknown operations in body of generic
Stephan Herhut [Fri, 10 Sep 2021 10:58:18 +0000 (12:58 +0200)]
[mlir][linalg] Fix bufferize pattern to allow unknown operations in body of generic

The original version of the bufferization pattern for linalg.generic would
manually clone operations within the region to the bufferized clone of the
operation. This triggers legality requirements on those operations in the
conversion infra. Instead, this now uses the rewriter to inline the region
instead, avoiding those legality requirements.

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

3 years ago[LoopFlatten] Make the analysis more robust after IV widening
Sjoerd Meijer [Fri, 3 Sep 2021 14:05:09 +0000 (15:05 +0100)]
[LoopFlatten] Make the analysis more robust after IV widening

LoopFlatten wasn't triggering on this motivating case after IV widening:

  void foo(int *A, int N, int M) {
    for (int i = 0; i < N; ++i)
      for (int j = 0; j < M; ++j)
        f(A[i*M+j]);
  }

The reason was that the old induction phi nodes were getting in the way. These
narrow and dead induction phis are not always trivially dead, and having both
the narrow and wide IVs confused the analysis and caused it to bail. This adds
some extra bookkeeping for these old phis, so we can filter them out when
checks on phi nodes are performed. Other clean up passes will get rid of these
old phis and increment instructions.

As this was one of the motivating examples from the beginning, it was
surprising this wasn't triggering from C/C++ code. It looks like the IR and CFG
is just slightly different.

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

3 years ago[clang][tooling] Accept custom diagnostic options in ToolInvocation
Jan Svoboda [Fri, 10 Sep 2021 10:50:51 +0000 (12:50 +0200)]
[clang][tooling] Accept custom diagnostic options in ToolInvocation

This patch allows the clients of `ToolInvocation` to provide custom diagnostic options to be used during driver -> cc1 command-line transformation and parsing.

Tests covering this functionality are in a follow-up commit. To make this testable, the `DiagnosticsEngine` needs to be properly initialized via `CompilerInstance::createDiagnostics`.

Reviewed By: dexonsmith, arphaman

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

3 years ago[OpenCL][Docs] Added ref to libclcxx
Anastasia Stulova [Fri, 10 Sep 2021 11:29:11 +0000 (12:29 +0100)]
[OpenCL][Docs] Added ref to libclcxx

Linked libclcxx GitHub project page in C++ libraries
for OpenCL section on OpenCLSupport page.

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

3 years ago[OpenCL][Docs] Update OpenCL 3.0 implementation status.
Anastasia Stulova [Mon, 6 Sep 2021 12:44:23 +0000 (13:44 +0100)]
[OpenCL][Docs] Update OpenCL 3.0 implementation status.

Update a section of OpenCLSupport page to reflect the latest
development in OpenCL 3.0 support for release 13.

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

3 years ago[lldb] Fix Clang modules build after D101329
Raphael Isemann [Fri, 10 Sep 2021 11:10:09 +0000 (13:10 +0200)]
[lldb] Fix Clang modules build after D101329

D101329 introduces the Process:SaveCore function returning a
`llvm::Expected<bool>`. That function causes that Clang with -fmodules crashes
while compiling LLDB's PythonDataObjects.cpp. With enabled asserts Clang fails
because of:

    Assertion failed: (CachedFieldIndex && "failed to find field in parent")

Crash can be reproduced by building via -DLLVM_ENABLE_MODULES=On with Clang
12.0.1 and then building PythonDataObjects.cpp.o .

Clang bug is tracked at rdar://82901462

3 years ago[flang] Signal EOR in non advancing IO and move to next record
Jean Perier [Fri, 10 Sep 2021 11:07:13 +0000 (13:07 +0200)]
[flang] Signal EOR in non advancing IO and move to next record

When an end of record is met in non advancing IO:
- Set IOSTAT if present according to 12.11.4 (5).
- Position the file to the next record (12.11.4 (4)).

The previous code was only signaling EOR for fixed record length IO.
Reading at 12.11.4, I do not find the rational for this condition, so I
removed it.
It also does not seem the presence of padding should prevent
the EOR signaling.

The positionning to the next record was block when EOR is signaling
in FinishReadingRecord because ErrorHandler.isError() is true in this
case.
EOR in input is not an error, but I am not confident to modify
ErrorHandler.isError() to cover that. However, In FinishReadingRecord,
the code should not bail if the error is simply an end of record.

I did not check the SIZE requirements here because GetSize runtime is
not yet implemented.

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

3 years ago[lldb] [test] Synchronize before the breakpoint in fork tests
Michał Górny [Fri, 10 Sep 2021 10:51:13 +0000 (12:51 +0200)]
[lldb] [test] Synchronize before the breakpoint in fork tests

We set breakpoint on child_func, so synchronization inside it is too
late to guarantee ordering between the parent output and child
breakpoint.  Split the function in two, and perform synchronization
before the breakpoint.

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

3 years ago[SVE][LoopVectorize] Optimise code generated by widenPHIInstruction
Rosie Sumpter [Wed, 8 Sep 2021 12:42:33 +0000 (13:42 +0100)]
[SVE][LoopVectorize] Optimise code generated by widenPHIInstruction

For SVE, when scalarising the PHI instruction the whole vector part is
generated as opposed to creating instructions for each lane for fixed-
width vectors. However, in some cases the lane values may be needed
later (e.g for a load instruction) so we still need to calculate
these values to avoid extractelement being called on the vector part.

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

3 years ago[Lanai] implement wide immediate support
Serge Bazanski [Fri, 10 Sep 2021 10:54:43 +0000 (10:54 +0000)]
[Lanai] implement wide immediate support

This fixes LanaiTTIImpl::getIntImmCost to return valid costs for i128
(and wider) values. Previously any immediate wider than
64 bits would cause Lanai llc to crash.

A regression test is also added that exercises this functionality.

Reviewed By: jpienaar

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

3 years ago[Lanai] fix MC / objdump
Serge Bazanski [Fri, 10 Sep 2021 10:45:25 +0000 (10:45 +0000)]
[Lanai] fix MC / objdump

D78776 removed is{Call,Branch,UnconditionalBranch} guards in objdump
before calling MCInstrAnalysis::evaluateBranch. This is fine for other
architectures as they gracefully handle evaluateBranch being called on
non-branches. However, the Lanai MCInstrAnalysis implementation didn't
and that change caused it to crash.

This inserts the same guards back into Lanai's evaluateBranch
implementation and adds a smoke test that exercises `llc | objdump` so
this kind of regression is hopefully caught next time.

Reviewed By: jpienaar, MaskRay

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

3 years ago[clang][deps] NFC: Extract ModuleName initialization
Jan Svoboda [Fri, 10 Sep 2021 10:44:17 +0000 (12:44 +0200)]
[clang][deps] NFC: Extract ModuleName initialization