platform/upstream/llvm.git
2 years agoManagedStatic: remove from Interpreter/ExternalFunctions
Nicolai Hähnle [Wed, 29 Jun 2022 14:20:03 +0000 (16:20 +0200)]
ManagedStatic: remove from Interpreter/ExternalFunctions

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

2 years ago[mlir] Fix Analysis/Presburger/Utils.cpp compilation with GCC 11
Rainer Orth [Wed, 3 Aug 2022 09:48:44 +0000 (11:48 +0200)]
[mlir] Fix Analysis/Presburger/Utils.cpp compilation with GCC 11

As reported in Issue #56850, mlir/lib/Analysis/Presburger/Utils.cpp doesn't
compile on Solaris 11.4/SPARC with the bundled GCC 11, as seen when testing
LLVM 15.0.0 rc1:

  /var/llvm/reltest/llvm-15.0.0-rc1/rc1/llvm-project/mlir/include/mlir/Analysis/Presburger/MPInt.h:260:47:
error: inlining failed in call to ‘always_inline’ ‘int64_t
mlir::presburger::int64FromMPInt(const mlir::presburger::MPInt&)’: indirect
function call with a yet undetermined callee

This patch hacks around this and allowed the build to finish.

Tested on `sparcv9-sun-solaris2.11`.

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

2 years agoFix compiler error: init-statements in if/switch.
Johannes Reifferscheid [Wed, 3 Aug 2022 09:34:51 +0000 (11:34 +0200)]
Fix compiler error: init-statements in if/switch.

Reviewed By: pifon2a

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

2 years ago[VP] Rename VP int<->float conversion ISD opcodes
Fraser Cormack [Tue, 2 Aug 2022 07:32:34 +0000 (08:32 +0100)]
[VP] Rename VP int<->float conversion ISD opcodes

These should be named like the non-VP versions for consistency.

Reviewed By: reames

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

2 years ago[X86][MC] Always emit `rep` prefix for `bsf`
Phoebe Wang [Wed, 3 Aug 2022 08:38:34 +0000 (16:38 +0800)]
[X86][MC] Always emit `rep` prefix for `bsf`

`BMI` new instruction `tzcnt` has better performance than `bsf` on new
processors. Its encoding has a mandatory prefix '0xf3' compared to
`bsf`. If we force emit `rep` prefix for `bsf`, we will gain better
performance when the same code run on new processors.

GCC has already done this way: https://c.godbolt.org/z/6xere6fs1

Fixes #34191

Reviewed By: skan

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

2 years agoFix a stack overflow in ScalarEvolution.
Johannes Reifferscheid [Wed, 3 Aug 2022 05:07:55 +0000 (07:07 +0200)]
Fix a stack overflow in ScalarEvolution.

Unfortunately, this overflow is extremely hard to reproduce reliably (in fact, I was unable to do so). The issue is that:

- getOperandsToCreate sometimes skips creating an SCEV for the LHS
- then, createSCEV is called for the BinaryOp
- ... which calls getNoWrapFlagsFromUB
- ... which under certain circumstances calls isSCEVExprNeverPoison
- ... which under certain circumstances requires the SCEVs of all operands

For certain deep dependency trees, this causes a stack overflow.

Reviewed By: bkramer, fhahn

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

2 years ago[clang][NFC] Try to fix the docs build
Timm Bäder [Wed, 3 Aug 2022 08:51:34 +0000 (10:51 +0200)]
[clang][NFC] Try to fix the docs build

2 years ago[CMake] Make split-file an utility instead of tool
Markus Böck [Wed, 3 Aug 2022 08:46:52 +0000 (10:46 +0200)]
[CMake] Make split-file an utility instead of tool

`split-file` is essentially a development tool used for writing tests. Other related tooling for this purpose such as `FileCheck`, `count`, `not` and more are already created via `add_llvm_utility` instead of `add_llvm_tool`. The later is more meant as LLVM tools used as part of a toolchain (eg. `llvm-ar`), not for tools for the development of LLVM itself.

The main semantic difference this makes is that `split-file` is now built and installed via the `LLVM_INSTALL_UTILS` and `LLVM_BUILD_UTILS` instead of `LLVM_BUILD_TOOLS` and `LLVM_INSTALL_TOOLS` cmake flags. That way one can use `LLVM_BUILD_TOOLS=OFF LLVM_INSTALL_UTILS=ON` and have `split-file` installed along side the other testing tools.

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

2 years agoManagedStatic: remove from PluginLoader
Nicolai Hähnle [Wed, 29 Jun 2022 14:14:55 +0000 (16:14 +0200)]
ManagedStatic: remove from PluginLoader

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

2 years agoManagedStatic: remove from TimeProfiler
Nicolai Hähnle [Wed, 29 Jun 2022 13:58:18 +0000 (15:58 +0200)]
ManagedStatic: remove from TimeProfiler

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

2 years ago[clang] Short-circuit trivial constructors when evaluating arrays
Timm Bäder [Fri, 29 Jul 2022 14:12:49 +0000 (16:12 +0200)]
[clang] Short-circuit trivial constructors when evaluating arrays

VisitCXXConstructExpr() will later do something similar, but for large
arrays, we should try to do it once an not for every element.

Fixes #56774

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

2 years ago[NFC] Remove some boilerplate from SmallVector unit tests
Dawid Jurczak [Wed, 3 Aug 2022 07:07:25 +0000 (09:07 +0200)]
[NFC] Remove some boilerplate from SmallVector unit tests

In SmallVector unit test, referring test suite members every time using 'this'
(due to how non-dependent name lookups works) is quite cumbersome and can be improved with aliases.
Some test cases already use this approach, in this change we expand that approach to whole test file.

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

2 years ago[Docs] Improve cycle and closed path definitions
Jannik Silvanus [Mon, 1 Aug 2022 09:46:02 +0000 (11:46 +0200)]
[Docs] Improve cycle and closed path definitions

Improve the cycle definition, by avoiding usage of not yet defined
or only vaguely defined terminology inside definitions.
More precisely, the existing definition defined "outermost cycles",
and then proceeded to use the term "cycles" for further definitions,
which in turn were used to actually define "cycles".

Now, instead only define "cycles". This does not change the meaning
of a cycle, which depends on the chosen surrounding (subgraph) of a CFG.

Also mention the function CFG in the first definition, because later
later definitions require it anyways.

Also slightly improve the definition of a closed path, by explicitly
requiring the inner nodes to be distinct.

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

2 years ago[mlir] Disable `misc-const-correctness` clang-tidy check.
Alexander Belyaev [Wed, 3 Aug 2022 08:18:18 +0000 (10:18 +0200)]
[mlir] Disable `misc-const-correctness` clang-tidy check.

https://clang.llvm.org/extra/clang-tidy/checks/misc/const-correctness.html

2 years ago[X86] Using `X86MemOperand` instead of `Operand` for `i32mem_TC` and `i64mem_TC`
Liu, Chen3 [Wed, 3 Aug 2022 06:39:29 +0000 (14:39 +0800)]
[X86] Using `X86MemOperand` instead of `Operand` for `i32mem_TC` and `i64mem_TC`

To fix build fail when X86_GEN_FOLD_TABLES is enabled.

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

2 years ago[AA] Make ModRefInfo a bitmask enum (NFC)
Nikita Popov [Mon, 1 Aug 2022 06:16:54 +0000 (08:16 +0200)]
[AA] Make ModRefInfo a bitmask enum (NFC)

Mark ModRefInfo as a bitmask enum, which allows using normal
& and | operators on it. This supersedes various functions like
unionModRef() and intersectModRef(). I think this makes the code
cleaner than going through helper functions...

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

2 years ago[SCEV] Use context to strengthen flags of BinOps
Max Kazantsev [Wed, 3 Aug 2022 06:10:56 +0000 (13:10 +0700)]
[SCEV] Use context to strengthen flags of BinOps

Sometimes SCEV cannot infer nuw/nsw from something as simple as
```
  len in [0, MAX_INT]
...
  iv = phi(0, iv.next)
  guard(iv <s len)
  guard(iv <u len)
  iv.next = iv + 1
```
just because flag strenthening only relies on definition and does not use local facts.
This patch adds support for the simplest case: inference of flags of `add(x, constant)`
if we can contextually prove that `x <= max_int - constant`.

In case if it has negative CT impact, we can add an option to switch it off. I woudln't
expect that though.

Differential Revision: https://reviews.llvm.org/D129643
Reviewed By: apilipenko

2 years ago[clang][dataflow] Rename member to make it clear that it isn't stable
Stanislav Gatev [Tue, 2 Aug 2022 21:05:48 +0000 (21:05 +0000)]
[clang][dataflow] Rename member to make it clear that it isn't stable

Rename `DataflowAnalysisContext::getStableStorageLocation(QualType)`
to `createStorageLocation`, to make it clear that it doesn't return
a stable storage location.

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

Reviewed-by: ymandel, xazax.hun, gribozavr2
2 years agoAdd foldings for multi-line comment.
Utkarsh Saxena [Tue, 19 Jul 2022 12:42:10 +0000 (14:42 +0200)]
Add foldings for multi-line comment.

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

2 years ago[mlir][Math] Add constant folder for AtanOp.
jacquesguan [Tue, 2 Aug 2022 11:49:11 +0000 (19:49 +0800)]
[mlir][Math] Add constant folder for AtanOp.

This patch adds constant folder for AtanOp which only supports single and double precision floating-point.

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

2 years ago[clang][dataflow] Make the type of the post visit callback consistent
Stanislav Gatev [Tue, 2 Aug 2022 19:33:47 +0000 (19:33 +0000)]
[clang][dataflow] Make the type of the post visit callback consistent

Make the types of the post visit callbacks in `transferBlock` and
`runTypeErasedDataflowAnalysis` consistent.

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

Reviewed-by: ymandel, xazax.hun, gribozavr2
2 years ago[gn build] Port 68264b649461
LLVM GN Syncbot [Wed, 3 Aug 2022 05:46:25 +0000 (05:46 +0000)]
[gn build] Port 68264b649461

2 years ago[libc++][ranges] Implement `ranges::{prev, next}_permutation`.
Nikolas Klauser [Wed, 3 Aug 2022 05:40:13 +0000 (22:40 -0700)]
[libc++][ranges] Implement `ranges::{prev, next}_permutation`.

Co-authored-by: Konstantin Varlamov <varconst@apple.com>
Differential Revision: https://reviews.llvm.org/D129859

2 years ago[libc++][test] Replace `_LIBCPP_STD_VER` with `TEST_STD_VER`
cpplearner [Tue, 2 Aug 2022 10:38:17 +0000 (18:38 +0800)]
[libc++][test] Replace `_LIBCPP_STD_VER` with `TEST_STD_VER`

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

2 years ago[gn build] Port 6bdb64223473
LLVM GN Syncbot [Wed, 3 Aug 2022 05:36:28 +0000 (05:36 +0000)]
[gn build] Port 6bdb64223473

2 years ago[libc++][ranges] Implement `ranges::sample`.
Konstantin Varlamov [Wed, 3 Aug 2022 05:33:12 +0000 (22:33 -0700)]
[libc++][ranges] Implement `ranges::sample`.

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

2 years ago[libc++][ranges] Implement `ranges::replace_copy{,_if}`.
Nikolas Klauser [Wed, 3 Aug 2022 05:25:00 +0000 (22:25 -0700)]
[libc++][ranges] Implement `ranges::replace_copy{,_if}`.

Co-authored-by: Konstantin Varlamov <varconst@apple.com>
Differential Revision: https://reviews.llvm.org/D129806

2 years ago[libc++][ranges] Fix the return value of `{copy,move}_backward`.
Konstantin Varlamov [Wed, 3 Aug 2022 05:22:49 +0000 (22:22 -0700)]
[libc++][ranges] Fix the return value of `{copy,move}_backward`.

The return value for both of these algorithms is specified as
```
`{last, result - N}` for the overloads in namespace `ranges`.
```
But the current implementation instead returns `{first, result - N}`.

Also add both algorithms to the relevant "robust" tests.

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

2 years ago[libc++][ranges] Implement `ranges::remove_copy{, _if}`.
Nikolas Klauser [Wed, 3 Aug 2022 05:13:59 +0000 (22:13 -0700)]
[libc++][ranges] Implement `ranges::remove_copy{, _if}`.

Co-authored-by: Hui Xie <hui.xie1990@gmail.com>
Differential Revision: https://reviews.llvm.org/D130599

2 years ago[mlir] Add has_value and value to OptionalParseResult
Kazu Hirata [Wed, 3 Aug 2022 05:16:55 +0000 (22:16 -0700)]
[mlir] Add has_value and value to OptionalParseResult

llvm::Optional is in the process of switching to the
std::optional-like interface with has_value/value as opposed to
hasValue/getValue.

This patch adds has_value and value to enable the same transition.

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

2 years agooops-- I pushed previous commit from a fresh checkout and forgot to
John Regehr [Wed, 3 Aug 2022 04:27:20 +0000 (22:27 -0600)]
oops-- I pushed previous commit from a fresh checkout and forgot to
git add the new test case, here it is

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

2 years agoavoid a bug where we remove a BB and then the next one becomes the
John Regehr [Wed, 3 Aug 2022 04:22:07 +0000 (22:22 -0600)]
avoid a bug where we remove a BB and then the next one becomes the
entry block and is illegal due to having more then one predecessor
block

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

2 years agoworkflows: Fix typo from 2d3d0f50ceb938c155a7283e684f28190d24d6ba
Tom Stellard [Tue, 2 Aug 2022 09:02:15 +0000 (02:02 -0700)]
workflows: Fix typo from 2d3d0f50ceb938c155a7283e684f28190d24d6ba

2 years ago[RISCV] Use InstVisitor in RISCVCodeGenPrepare. NFC
Craig Topper [Wed, 3 Aug 2022 04:19:30 +0000 (21:19 -0700)]
[RISCV] Use InstVisitor in RISCVCodeGenPrepare. NFC

Makes it easy to add new instructions to look at without dispatching
manually.

2 years ago[NFC][trace] format source files
Walter Erquinigo [Wed, 3 Aug 2022 04:15:17 +0000 (21:15 -0700)]
[NFC][trace] format source files

Cleanup formatting diff

2 years agoworkflows: Remove symbol versions from libclang.so in the libclang ABI test
Tom Stellard [Tue, 2 Aug 2022 09:02:15 +0000 (02:02 -0700)]
workflows: Remove symbol versions from libclang.so in the libclang ABI test

Now that the symbol version for libclang.so changes for each release again,
we need to remove the symbol versions from the shared library in order
for the ABI checker to be able to compare with an older version of the
shared library.

2 years ago[IRBuilder] Handle constexpr-bitcast for IRBuilder::CreateThreadLocalAddress
Chuanqi Xu [Wed, 3 Aug 2022 03:11:27 +0000 (11:11 +0800)]
[IRBuilder] Handle constexpr-bitcast for IRBuilder::CreateThreadLocalAddress

In case that opaque pointers not enabled, there may be some constexpr
bitcast uses for thread local variables and the design of llvm allow
people to sink constant arbitrarily. This breaks the assumption of
IRBuilder::CreateThreadLocalAddress. This patch tries to handle the
case.

2 years agofix f9b4ea0ce9efb4132a75551c40b2efc049e5b9f7
Walter Erquinigo [Wed, 3 Aug 2022 02:22:58 +0000 (19:22 -0700)]
fix f9b4ea0ce9efb4132a75551c40b2efc049e5b9f7

This fixes https://lab.llvm.org/buildbot/#/builders/68/builds/37077.

2 years ago[libc++][test] Propagate host environment to libc++ test suite
Michał Górny [Wed, 3 Aug 2022 01:52:25 +0000 (21:52 -0400)]
[libc++][test] Propagate host environment to libc++ test suite

Propagate the complete host environment to the tests run via the new
testconfig. This ensures that all envvars needed e.g. for the compiler
to work correctly are present. This mimics the behavior explicitly
implemented in the legacy config.

https://github.com/llvm/llvm-project/issues/56816

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

2 years ago[libc++][NFC] Don't rely on `<algorithm>` transitively including `<memory>` in tests
Igor Zhukov [Wed, 3 Aug 2022 00:45:28 +0000 (20:45 -0400)]
[libc++][NFC] Don't rely on `<algorithm>` transitively including `<memory>` in tests

Found by @cpplearner (https://github.com/microsoft/STL/pull/2976#discussion_r935440806)

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

2 years ago[libc++] Fix warning C4244 in std/numerics/rand/rand.dist/rand.dist.samp/rand.dist...
Igor Zhukov [Wed, 3 Aug 2022 00:42:05 +0000 (20:42 -0400)]
[libc++] Fix warning C4244 in std/numerics/rand/rand.dist/rand.dist.samp/rand.dist.samp.discrete/eval.pass.cpp

frederick-vs-ja noticed that https://github.com/microsoft/STL/pull/2976#issuecomment-1201926893
while we are working on updating LLVM submodule for MS STL:

    [...]\std\numerics\rand\rand.dist\rand.dist.samp\rand.dist.samp.discrete\eval.pass.cpp(33): error C2220: the following warning is treated as an error
    [...]\std\numerics\rand\rand.dist\rand.dist.samp\rand.dist.samp.discrete\eval.pass.cpp(287): note: see reference to function template instantiation 'void tests<__int64>(void)' being compiled
    [...]\std\numerics\rand\rand.dist\rand.dist.samp\rand.dist.samp.discrete\eval.pass.cpp(33): warning C4244: 'argument': conversion from '__int64' to 'const unsigned int', possible loss of data

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

2 years ago[llvm][NFC] Refactor code to use ProfDataUtils
Paul Kirth [Wed, 27 Jul 2022 21:44:24 +0000 (21:44 +0000)]
[llvm][NFC] Refactor code to use ProfDataUtils

In this patch we replace common code patterns with the use of utility
functions for dealing with profiling metadata. There should be no change
in functionality, as the existing checks should be preserved in all
cases.

Reviewed By: bogner, davidxl

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

2 years ago[flang] Add stopped_images to list of intrinsics and add test
Katherine Rasmussen [Thu, 23 Jun 2022 22:41:41 +0000 (15:41 -0700)]
[flang] Add stopped_images to list of intrinsics and add test

Add stopped_images to the list of intrinsic functions. Add a
semantics test for stopped_images.

Reviewed By: klausler, ngeorge1098

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

2 years ago[gn build] Port f9b4ea0ce9ef
LLVM GN Syncbot [Tue, 2 Aug 2022 23:57:33 +0000 (23:57 +0000)]
[gn build] Port f9b4ea0ce9ef

2 years ago[trace] Add SBTraceCursor bindings
Jakob Johnson [Mon, 1 Aug 2022 19:23:22 +0000 (12:23 -0700)]
[trace] Add SBTraceCursor bindings

Add bindings for the `TraceCursor` to allow for programatic traversal of
traces.
This diff adds bindings for all public `TraceCursor` methods except
`GetHwClock` and also adds `SBTrace::CreateNewCursor`. A new unittest
has been added to TestTraceLoad.py that uses the new `SBTraceCursor` API
to test that the sequential and random access APIs of the `TraceCursor`
are equivalent.

This diff depends on D130925.

Test Plan:
`ninja lldb-dotest && ./bin/lldb-dotest -p TestTraceLoad`

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

2 years ago[AMDGPU] Add CL option for max-ilp scheduler.
Austin Kerbow [Tue, 2 Aug 2022 21:15:00 +0000 (14:15 -0700)]
[AMDGPU] Add CL option for max-ilp scheduler.

When compiling for multiple targets the scheduler that is selected via the
-misched option is applied globally. This patch adds a target CL option instead.

Reviewed By: rampitec

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

2 years ago[SPIRV] Fix style of LIT tests and remove metadata
Andrey Tretyakov [Tue, 2 Aug 2022 18:59:52 +0000 (21:59 +0300)]
[SPIRV] Fix style of LIT tests and remove metadata

Fix style, indentation, comments of LIT tests
and remove unnecessary metadata and attributes.

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

2 years ago[NFC] Remove no-op code from x86AssemblyInspectionEngine::jmp_to_reg_p
Jason Molenda [Tue, 2 Aug 2022 23:26:46 +0000 (16:26 -0700)]
[NFC] Remove no-op code from x86AssemblyInspectionEngine::jmp_to_reg_p

Slava Gurevich noticed this dead code I wrote in jmp_to_reg_p
is never executed, is duplicated, and has comments that seem to
describe the opposite behavior.  Remove the dead code that cannot
be executed.

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

2 years agoRevert "[lldb][modules] Disable Clang Modules in source/Host directory on macOS"
Jonas Devlieghere [Tue, 2 Aug 2022 22:51:25 +0000 (15:51 -0700)]
Revert "[lldb][modules] Disable Clang Modules in source/Host directory on macOS"

This reverts commit 7cf4ab13af8aa3183e551b3319399cddd9384948 as it was a
temporary workaround that's no longer needed.

2 years ago[LLDB][NFC] Fix incorrect return status Some functions always return 'false' for...
Slava Gurevich [Tue, 2 Aug 2022 18:54:52 +0000 (11:54 -0700)]
[LLDB][NFC] Fix incorrect return status Some functions always return 'false' for both success and fail return paths.

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

2 years ago[LLDB] Add SBInstruction::GetControlFlowKind()
Jakob Johnson [Tue, 2 Aug 2022 18:26:24 +0000 (11:26 -0700)]
[LLDB] Add SBInstruction::GetControlFlowKind()

D128477 adds the control flow kind for `Instruction` and displays this
in the `thread trace dump instruction -k` command.

This diff exposes the control flow kind via the new
`SBInstruction::GetControlFlowKind` method.

I've expanded `TestDisassembleRawData` to test this method, but please
let me know if there are any other unittests that should also be updated.

Test Plan:
`./bin/lldb-dotest -p TestDisassembleRawData`

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

2 years agoFix use-after-free in SymbolTable::replaceAllSymbolUses
Mehdi Amini [Tue, 2 Aug 2022 22:18:36 +0000 (22:18 +0000)]
Fix use-after-free in SymbolTable::replaceAllSymbolUses

In some cases the recursion will grow the `visited` hash table and
invalidate the cached iterator.
(caught with ASAN)

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

2 years ago[RISCV] Fix operand number in debug message in RISCVMergeBaseOffset.
Craig Topper [Tue, 2 Aug 2022 22:26:25 +0000 (15:26 -0700)]
[RISCV] Fix operand number in debug message in RISCVMergeBaseOffset.

This used to print from the ADDI where the operand number was
correct. It recently changed to print from the LUI or AUIPC which
needs to use operand 1 instead of 2.

This shows up as a crash with -debug.

2 years ago[Libomptarget] Deinitialize AMDGPU global state more intentionally
Joseph Huber [Tue, 2 Aug 2022 18:52:47 +0000 (14:52 -0400)]
[Libomptarget] Deinitialize AMDGPU global state more intentionally

A previous patch made the destruction of the HSA plugin more
deterministic. However, there were still other global values that are not
handled this way. When attempting to call a destructor kernel, the
device would have already been uninitialized and we could not find the
appropriate kernel to call. This is because they were stored in global
containers that had their destructors called already. Merges this global
state into the rest of the info state by putting those global values
inside of the global pointer already allocated and deallocated by the
constructor and destructor. This should allow the AMDGPU plugin to
correctly identify the destructors if we were to run them.

Reviewed By: JonChesterfield

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

2 years ago[OpenMP][libomp] Detect if test compiler has omp.h
Jonathan Peyton [Mon, 1 Aug 2022 18:43:18 +0000 (13:43 -0500)]
[OpenMP][libomp] Detect if test compiler has omp.h

omp50_taskdep_depobj.c relies on the test compiler's omp.h file.
If the test compiler does not have an omp.h file, then use the one
within the build tree.

Fixes: https://github.com/llvm/llvm-project/issues/56820
Differential Revision: https://reviews.llvm.org/D131000

2 years ago[DX] Remove IntrNoMem from create handle intrinsic
Chris Bieneman [Tue, 2 Aug 2022 21:55:46 +0000 (16:55 -0500)]
[DX] Remove IntrNoMem from create handle intrinsic

The create handle intrinsic calls can't be removed, so it was incorrect
to mark them as IntrNoMem.

2 years agoCommandLine: add and use cl::SubCommand::get{All,TopLevel}
Nicolai Hähnle [Wed, 29 Jun 2022 10:32:45 +0000 (12:32 +0200)]
CommandLine: add and use cl::SubCommand::get{All,TopLevel}

Prefer using these accessors to access the special sub-commands
corresponding to the top-level (no subcommand) and all sub-commands.

This is a preparatory step towards removing the use of ManagedStatic:
with a subsequent change, these global instances will be moved to
be regular function-scope statics.

It is split up to give downstream projects a (albeit short) window in
which they can switch to using the accessors in a forward-compatible
way.

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

2 years ago[flang] Add semantics test for ERROR STOP statement
Naje George [Sat, 16 Jul 2022 00:39:00 +0000 (17:39 -0700)]
[flang] Add semantics test for ERROR STOP statement

Reviewed By: ktras

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

2 years agoInline my uuid_is_null() implementation in a header file
Jason Molenda [Tue, 2 Aug 2022 21:23:00 +0000 (14:23 -0700)]
Inline my uuid_is_null() implementation in a header file

This either needs to be static, or forced inline, or in a separate
source file.  Given that we only have one function in this
UuidCompatibility.h, I think forced inline for the handful of uses
of it may be best.

2 years ago[LLD] [MachO] Fix GCC build warnings
Martin Storsjö [Tue, 2 Aug 2022 07:29:01 +0000 (10:29 +0300)]
[LLD] [MachO] Fix GCC build warnings

This fixes the following warnings produced by GCC 9:

    ../tools/lld/MachO/Arch/ARM64.cpp: In member function ‘void {anonymous}::OptimizationHintContext::applyAdrpLdr(const lld::macho::OptimizationHint&)’:
    ../tools/lld/MachO/Arch/ARM64.cpp:448:18: warning: comparison of integer expressions of different signedness: ‘int64_t’ {aka ‘long int’} and ‘uint64_t’ {aka ‘long unsigned int’} [-Wsign-compare]
      448 |   if (ldr.offset != (rel1->referentVA & 0xfff))
          |       ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ../tools/lld/MachO/UnwindInfoSection.cpp: In function ‘bool canFoldEncoding(compact_unwind_encoding_t)’:
    ../tools/lld/MachO/UnwindInfoSection.cpp:404:44: warning: comparison between ‘enum<unnamed>’ and ‘enum<unnamed>’ [-Wenum-compare]
      404 |   static_assert(UNWIND_X86_64_MODE_MASK == UNWIND_X86_MODE_MASK, "");
          |                                            ^~~~~~~~~~~~~~~~~~~~
    ../tools/lld/MachO/UnwindInfoSection.cpp:405:49: warning: comparison between ‘enum<unnamed>’ and ‘enum<unnamed>’ [-Wenum-compare]
      405 |   static_assert(UNWIND_X86_64_MODE_STACK_IND == UNWIND_X86_MODE_STACK_IND, "");
          |                                                 ^~~~~~~~~~~~~~~~~~~~~~~~~

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

2 years agoAllow firmware binaries to be specified only by load address
Jason Molenda [Tue, 2 Aug 2022 21:13:20 +0000 (14:13 -0700)]
Allow firmware binaries to be specified only by load address

Add support to Mach-O corefiles and to live gdb remote serial protocol
connections for the corefile/remote stub to provide a list of load
addresses of binaries that should be found & loaded by lldb, and nothing
else.  lldb will try to parse the binary out of memory, and if it can
find a UUID, try to find a binary & its debug information based on the
UUID, falling back to using the memory image if it must.

A bit of code unification from three parts of lldb that were loading
individual binaries already, so there is a shared method in
DynamicLoader to handle all of the variations they were doing.

Re-landing this with a uuid_is_null() implementation added to
Utility/UuidCompatibility.h for non-Darwin systems.

Differential Revision: https://reviews.llvm.org/D130813
rdar://94249937
rdar://94249384

2 years agoworkflows: Release Workflow - Avoid selecting random reviewers when no phab review
Tom Stellard [Tue, 2 Aug 2022 16:35:36 +0000 (16:35 +0000)]
workflows: Release Workflow - Avoid selecting random reviewers when no phab review

If you pass a NULL reivew ID to the differential.revision.search API,
it returns all revisions and we were just taking the first one and
assuming it was associated with the commit in the PR.

We need to exit early if we can't find a Phabricator review associated
with a commit.

2 years ago[gn build] Port 95a92995d45f
LLVM GN Syncbot [Tue, 2 Aug 2022 21:01:56 +0000 (21:01 +0000)]
[gn build] Port 95a92995d45f

2 years ago[mlir][GPU] Allow bare pointer memrefs when calling GPU kernels
Krzysztof Drewniak [Mon, 11 Jul 2022 18:29:01 +0000 (18:29 +0000)]
[mlir][GPU] Allow bare pointer memrefs when calling GPU kernels

In the ROCm runtime (and probably CUDA as well), all kernel arguments
are aligned. Therefore, enable using bare pointers for memref
arguments to kernels when these memrefs have static shape and a
trivial layout.

This is a substantial optimization to launching kernels that use
memrefs with known, static sizes, since it causes the kernel launch
packet to no longer include information already known to the kernel,
which can enable packing the kernel launch arguments into launch
packets instead of having to allocate an entire separate structure to
hold unneeded memref information.

Reviewed By: ftynse

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

2 years agoAdds the NSDateFormatter checker to clang-tidy
Rashmi Mudduluru [Tue, 2 Aug 2022 20:53:50 +0000 (13:53 -0700)]
Adds the NSDateFormatter checker to clang-tidy

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

2 years agoRevert "Allow firmware binaries to be specified only by load address"
Jason Molenda [Tue, 2 Aug 2022 20:53:34 +0000 (13:53 -0700)]
Revert "Allow firmware binaries to be specified only by load address"

This reverts commit d8879fba8825b9799166ba0ea552d4027bfb8ad1.

Debian bot failure; I included <uuid/uuid.h> to get uuid_is_null() but
don't get it there.  Will memcmp or whatever & recommit.

2 years agoAllow firmware binaries to be specified only by load address
Jason Molenda [Tue, 2 Aug 2022 20:46:18 +0000 (13:46 -0700)]
Allow firmware binaries to be specified only by load address

Add support to Mach-O corefiles and to live gdb remote serial protocol
connections for the corefile/remote stub to provide a list of load
addresses of binaries that should be found & loaded by lldb, and nothing
else.  lldb will try to parse the binary out of memory, and if it can
find a UUID, try to find a binary & its debug information based on the
UUID, falling back to using the memory image if it must.

A bit of code unification from three parts of lldb that were loading
individual binaries already, so there is a shared method in
DynamicLoader to handle all of the variations they were doing.

Differential Revision: https://reviews.llvm.org/D130813
rdar://94249937
rdar://94249384

2 years ago[AMDGPU] Add llvm_unreachable to switch statement added in d7100b398.
Austin Kerbow [Tue, 2 Aug 2022 20:41:02 +0000 (13:41 -0700)]
[AMDGPU] Add llvm_unreachable to switch statement added in d7100b398.

2 years ago[nfc] Remove unused parameter in TailDuplicator::duplicateSimpleBB
Mircea Trofin [Tue, 2 Aug 2022 19:14:24 +0000 (12:14 -0700)]
[nfc] Remove unused parameter in TailDuplicator::duplicateSimpleBB

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

2 years agoFix use-after-free in clang-apply-replacements
Ben Langmuir [Tue, 2 Aug 2022 20:33:12 +0000 (13:33 -0700)]
Fix use-after-free in clang-apply-replacements

Accidentally introduced a dangling StringRef in b4c6dc2e6637.

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

2 years ago[AMDGPU] Add GCNMaxILPSchedStrategy
Austin Kerbow [Sat, 30 Jul 2022 14:40:11 +0000 (07:40 -0700)]
[AMDGPU] Add GCNMaxILPSchedStrategy

Creates a new scheduling strategy that attempts to maximize ILP for a single
wave.

Reviewed By: rampitec

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

2 years ago[libc++] Update documentation on testing libc++
Louis Dionne [Tue, 2 Aug 2022 20:15:55 +0000 (16:15 -0400)]
[libc++] Update documentation on testing libc++

2 years ago[LLDB][NFC] Fix LLDB_WATCH_TYPE_IS_VALID macro
Slava Gurevich [Tue, 2 Aug 2022 08:33:01 +0000 (01:33 -0700)]
[LLDB][NFC] Fix LLDB_WATCH_TYPE_IS_VALID macro

LLDB_WATCH_TYPE_IS_VALID would always return true when validating watchpoint type
by using bitwise-or instead of bitwise-and to apply validation flags.

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

2 years ago[mlir][sparse] enable SDDMM-flavored fusion
Aart Bik [Tue, 2 Aug 2022 16:37:44 +0000 (09:37 -0700)]
[mlir][sparse] enable SDDMM-flavored fusion

This rewriting was no longer functional after recent migration to one shot
bufferization. However, this revision makes it work again, with a CHECK test
to ensure fusion happens. Note that functionality is tested by several
integration tests.

Reviewed By: Peiming

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

2 years ago[NFC][DirectX backend] Fix crash when emit_obj for DirectX backend.
Xiang Li [Sun, 31 Jul 2022 21:15:28 +0000 (14:15 -0700)]
[NFC][DirectX backend] Fix crash when emit_obj for DirectX backend.

When emit-obj from clang directly, DirectX backend will hit assert caused by not initialize passes for AsmPrinter.
The fix will initialize the passes by calling createPassConfig.
Also ignore global variable which not has section in DXILAsmPrinter::emitGlobalVariable to avoid hit llvm_unreachable in DXILTargetObjectFile::SelectSectionForGlobal.

Reviewed By: beanz

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

2 years ago[libcxx][test] Test code should inspect `TEST_STD_VER`, not `_LIBCPP_STD_VER`.
Casey Carter [Tue, 2 Aug 2022 19:03:25 +0000 (12:03 -0700)]
[libcxx][test] Test code should inspect `TEST_STD_VER`, not `_LIBCPP_STD_VER`.

2 years ago[SemaCXX] Validate destructor is valid for dependent classes
Roy Jacobson [Mon, 1 Aug 2022 20:47:30 +0000 (23:47 +0300)]
[SemaCXX] Validate destructor is valid for dependent classes

We didn't check that a destructor's name matches the directly enclosing class if the class was dependent.
I enabled the check we already had for non-dependent types, which seems to work. Added appropriate tests.

Fixes GitHub issue #56772

Reviewed By: erichkeane

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

2 years ago[CodeGen][inlineasm] assume the flag output of inline asm is boolean value
Yuanfang Chen [Fri, 29 Jul 2022 21:50:40 +0000 (14:50 -0700)]
[CodeGen][inlineasm] assume the flag output of inline asm is boolean value

GCC inline asm document says that
"... the general rule is that the output variable must be a scalar
integer, and the value is boolean."

Commit e5c37958f901cc9bec50624dbee85d40143e4bca lowers flag output of
inline asm on X86 with setcc, hence it is guaranteed that the flag
is of boolean value. Clang does not support ARM inline asm flag output
yet so nothing need to be worried about ARM.

See "Flag Output" section at
https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#OutputOperands

Fixes https://github.com/llvm/llvm-project/issues/56568

Reviewed By: nikic

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

2 years ago[mlir][sparse] remove singleton dimension level type (for now)
Aart Bik [Tue, 2 Aug 2022 17:36:05 +0000 (10:36 -0700)]
[mlir][sparse] remove singleton dimension level type (for now)

Although we have plans to support this, and many other, dimension level type(s), currently the tag is not supported. It will be easy to add this back once support is added.

NOTE: based on discussion in https://discourse.llvm.org/t/overcoming-sparsification-limitation-on-level-types/62585

https://github.com/llvm/llvm-project/issues/51658

Reviewed By: Peiming

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

2 years ago[libc++][format] Exposes basic-format-string
Mark de Wever [Fri, 15 Jul 2022 05:42:17 +0000 (07:42 +0200)]
[libc++][format] Exposes basic-format-string

This paper was accepted during the last plenary and is intended to be
backported to LLVM 15. When backporting the release notes in the branch
should be updated too.

Note the feature-test macro isn't updated since this will change; three
papers have updated the same macro in the same plenary.

Implements:
- P2508R1 Exposing std::basic-format-string

Reviewed By: ldionne, #libc

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

2 years agoThis patch fixes these errors while building BOLT.
Sriraman Tallam [Tue, 2 Aug 2022 18:21:36 +0000 (11:21 -0700)]
This patch fixes these errors while building BOLT.

Compiling llvm/llvm-project/bolt/include/bolt/Passes/RegReAssign.h failed:
...: error: invalid application of 'sizeof' to an incomplete type 'llvm::bolt::BinaryFunctionCallGraph'

static_assert(sizeof(_Tp) >= 0, "cannot delete an incomplete type");
error: type 'llvm::bolt::BinaryBasicBlock *' cannot be used prior to '::' because it has no members

using NodeRef = typename GraphType::UnknownGraphTypeError;
BinaryDomTree.h:31:14: error: no template named 'DomTreeGraphTraitsBase'

: public DomTreeGraphTraitsBase<bolt::BinaryDomTreeNode,

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

2 years ago[MLIR] Rename the generic LLVM allocation and deallocation functions
Michele Scuttari [Tue, 2 Aug 2022 18:21:05 +0000 (18:21 +0000)]
[MLIR] Rename the generic LLVM allocation and deallocation functions

The generic allocation and deallocation instructions, which are optionally used during the MemRef -> LLVM conversion, should have a name that is specifically bound to their origin, that is the conversion pass itself.

Reviewed By: silvas

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

2 years ago[libc++][doc] Update spaceship status page
Adrian Vogelsgesang [Tue, 2 Aug 2022 18:08:18 +0000 (20:08 +0200)]
[libc++][doc] Update spaceship status page

    * `operator<=>` for `iota_view::iterator` was enabled in 8320017b79eb8
    * Removed P2405R0 which was not accepted and seems inactive
      (https://github.com/cplusplus/papers/issues/1075)
    * Added the previously missing `operator==` for `filesystem::space_info`
      to the tracking list.
    * Updated the "Assignee" for `string_view`, `string` as Mark de Wever
      mentioned he is working on them in Discord
    * Updated the status of the items for which I sent review requests
      yesterday.

Reviewed By: #libc, Mordante

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

2 years ago[StandardInstrumentations] Assign names to basic blocks without names
Arthur Eubanks [Tue, 26 Jul 2022 17:18:57 +0000 (10:18 -0700)]
[StandardInstrumentations] Assign names to basic blocks without names

Fixes code in OrderedChangedData<T>::report which assumes that a string will only appear once in Before/After.

Reviewed By: jamieschmeiser

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

2 years ago[test] Update BoundsChecking/simple.ll
Arthur Eubanks [Tue, 2 Aug 2022 16:45:58 +0000 (09:45 -0700)]
[test] Update BoundsChecking/simple.ll

Use opaque pointers and update_test_checks.py

Precommit a test

2 years ago[GIsel] Add missing libcall for G_MUL to LegalizerHelper
Kai Nacke [Tue, 2 Aug 2022 17:12:38 +0000 (13:12 -0400)]
[GIsel] Add missing libcall for G_MUL to LegalizerHelper

The LegalizerHelper misses the code to lower G_MUL to a library call,
which this change adds.

Reviewed By: arsenm

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

2 years ago[GIsel] Add missing space between type and name in GICombinerHelperArg
Kai Nacke [Tue, 2 Aug 2022 17:08:54 +0000 (13:08 -0400)]
[GIsel] Add missing space between type and name in GICombinerHelperArg

When using AdditionalArguments in a GICombinerHelper, the generator
does not put a space between the type and the name.

E.g.

let AdditionalArguments = [GICombinerHelperArg<"bool", "IsSomething">];

ends up as

boolIsSomething) const;

in the generated file. This change adds a space between the type and the name.

Reviewed By: aemerson

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

2 years ago[AArch64] Treat x18 as callee-saved in functions with Windows calling convention...
Vladislav Dzhidzhoev [Wed, 27 Jul 2022 20:54:56 +0000 (23:54 +0300)]
[AArch64] Treat x18 as callee-saved in functions with Windows calling convention on Darwin

rGcf97e0ec42b8 makes $x18 to be treated as callee-saved in functions with
Windows calling convention on non-Windows OSes.

Here we mark $x18 as callee-saved for functions with Windows calling
convention on Darwin, as well as on other non-Windows platforms, in
order to prevent some miscompilations (like miscompilation of
win64cc-darwin-backup-x18.ll).

Since getCalleeSavedRegs doesn't return x18 in list of callee-saved
registers, assignCalleeSavedSpillSlots and determineCalleeSaves
consider different sets of registers as callee-saved. It causes an
error:
```
Assertion failed: ((!HasCalleeSavedStackSize || getCalleeSavedStackSize() == Size) && "Invalid size calculated for callee saves"), function getCalleeSavedStackSize, file
AArch64MachineFunctionInfo.h, line 292.
```

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

2 years ago[RISCV][Clang] Support policy functions for Vector Mask Instructions.
Zakk Chen [Tue, 2 Aug 2022 16:57:40 +0000 (16:57 +0000)]
[RISCV][Clang] Support policy functions for Vector Mask Instructions.

We will switch all UndefValue to PoisonValue in follow up patches.

Reviewed By: kito-cheng

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

2 years ago[RISCV][Clang] Support policy functions for Vector Reduction
Zakk Chen [Tue, 2 Aug 2022 16:39:17 +0000 (16:39 +0000)]
[RISCV][Clang] Support policy functions for Vector Reduction
Instructions.

We will switch all UndefValue to PoisonValue in follow up patches.

Thanks for Kito to help on verification with their interanl testsuite.

Reviewed By: kito-cheng

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

2 years ago[RISCV][Clang] Support policy functions for Vector Comparison
Zakk Chen [Tue, 2 Aug 2022 16:27:29 +0000 (16:27 +0000)]
[RISCV][Clang] Support policy functions for Vector Comparison
Instructions.

We will switch all UndefValue to PoisonValue in follow up patches.

Reviewed By: kito-cheng

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

2 years ago[RISCV][Clang] Support policy functions for vmerge, vfmerge and
Zakk Chen [Mon, 1 Aug 2022 17:59:53 +0000 (17:59 +0000)]
[RISCV][Clang] Support policy functions for vmerge, vfmerge and
vcompress.

We will switch all UndefValue to PoisonValue in follow up patches.

Reviewed By: kito-cheng

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

2 years ago[RISCV][Clang] Support policy functions for vneg, vnot, vncvt, vwcvt,
Zakk Chen [Mon, 1 Aug 2022 18:24:30 +0000 (18:24 +0000)]
[RISCV][Clang] Support policy functions for vneg, vnot, vncvt, vwcvt,
vwcvtu, vfabs and vfneg.

We will switch all UndefValue to PoisonValue in follow up patches.

Reviewed By: kito-cheng

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

2 years ago[test] Remove -fsanitize-coverage-whitelist=
Fangrui Song [Tue, 2 Aug 2022 17:25:44 +0000 (10:25 -0700)]
[test] Remove -fsanitize-coverage-whitelist=

2 years ago[SPIRV] Add tests to improve test coverage
Andrey Tretyakov [Tue, 2 Aug 2022 17:18:51 +0000 (20:18 +0300)]
[SPIRV] Add tests to improve test coverage

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

2 years ago[DebugInfo] Test commit: update irrelevant comments
Vladislav Dzhidzhoev [Tue, 2 Aug 2022 17:18:47 +0000 (20:18 +0300)]
[DebugInfo] Test commit: update irrelevant comments

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

2 years ago[LLDB][Reliability] Remove dead code.
Slava Gurevich [Mon, 1 Aug 2022 19:36:38 +0000 (12:36 -0700)]
[LLDB][Reliability] Remove dead code.

Remove redundant code that can never execute due to preceeding logic checks in the code.

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

2 years ago[MIPS] Expose the ZERO register as a constant physical register
Guozhi Wei [Tue, 2 Aug 2022 17:04:52 +0000 (17:04 +0000)]
[MIPS] Expose the ZERO register as a constant physical register

The ZERO register should be exposed as a constant physical register through the interface TargetRegisterInfo::isConstantPhysReg.

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

2 years ago[libc++][format] Improves generated files.
Mark de Wever [Mon, 1 Aug 2022 15:55:51 +0000 (17:55 +0200)]
[libc++][format] Improves generated files.

This improves the formatting of the generated files. That allows it to
remove the clang-format step in D129668.

Reviewed By: ldionne, #libc

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

2 years ago[libc++][format] Enables feature-test macro.
Mark de Wever [Fri, 29 Jul 2022 18:35:43 +0000 (20:35 +0200)]
[libc++][format] Enables feature-test macro.

The macro is only enabled when the Clang is used with
-fexperimental-library.

Reviewed By: ldionne, #libc

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