platform/upstream/llvm.git
2 years ago[flang] add semantics test for sync all
Damian Rouson [Thu, 11 Nov 2021 19:27:15 +0000 (11:27 -0800)]
[flang] add semantics test for sync all

Test a range of acceptable forms of SYNC ALL statements,
including combinations with and without the stat-variable
and errmsg-variable present.  Also test that several invalid
forms of SYNC ALL call generate the correct error messages.

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

2 years ago[MemoryDependency] Relax the re-ordering of atomic store and unordered load/store
Serguei Katkov [Tue, 15 Feb 2022 11:12:22 +0000 (18:12 +0700)]
[MemoryDependency] Relax the re-ordering of atomic store and unordered load/store

Atomic store with Release semantic allows re-ordering of unordered load/store before the store.
Implement it.

Reviewers: reames
Reviewed By: reames
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D119844

2 years agoOn Windows, the function name contains the return parameter, so
Jim Ingham [Thu, 17 Feb 2022 03:09:01 +0000 (19:09 -0800)]
On Windows, the function name contains the return parameter, so
the test has to be "function name contains the name we used to specify
the breakpoint" not IS the name...

2 years ago[libc] Use '+' constraint on inline assembly
Alex Brachet [Thu, 17 Feb 2022 03:00:17 +0000 (03:00 +0000)]
[libc] Use '+' constraint on inline assembly

As suggested by @mcgrathr in D118099

Reviewed By: lntue

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

2 years agoAdd a test for breaking on overloaded functions by name.
Jim Ingham [Thu, 17 Feb 2022 01:46:53 +0000 (17:46 -0800)]
Add a test for breaking on overloaded functions by name.

2 years ago[flang] Allow tabs as white space in formats
V Donaldson [Wed, 16 Feb 2022 23:26:50 +0000 (15:26 -0800)]
[flang] Allow tabs as white space in formats

The fortran standard views blanks in IO formats as white space in
non-string contexts.  Other compilers extend this to also view horizontal
tabs as white space.  Some compilers additionally add other white space
characters to this group.

Add recognition of horizontal and vertical tabs to runtime format
validation code to match what the runtime code currently does.

2 years ago[mlir][sparse] avoid some codeup in sparsification transformation
Aart Bik [Thu, 17 Feb 2022 00:30:46 +0000 (16:30 -0800)]
[mlir][sparse] avoid some codeup in sparsification transformation

A very small refactoring, but a big impact on tests that expect an exact order.
This revision fixes the tests, but also makes them less brittle for similar
minor changes in the future!

Reviewed By: bixia

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

2 years ago[AArch64][GlobalISel] Implement support for clang.arc.attachedcall call operand bundles.
Amara Emerson [Wed, 16 Feb 2022 23:06:07 +0000 (15:06 -0800)]
[AArch64][GlobalISel] Implement support for clang.arc.attachedcall call operand bundles.

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

2 years ago[BPF] Fix a BTF type pruning bug
Yonghong Song [Wed, 16 Feb 2022 19:54:38 +0000 (11:54 -0800)]
[BPF] Fix a BTF type pruning bug

In BPF backend, BTF type generation may skip
some debuginfo types if they are the pointee
type of a struct member. For example,
  struct task_struct {
    ...
    struct mm_struct                *mm;
    ...
  };
BPF backend may generate a forward decl for
'struct mm_struct' instead of full type if
there are no other usage of 'struct mm_struct'.
The reason is to avoid bringing too much unneeded types
in BTF.

Alexei found a pruning bug where we may miss
some full type generation. The following is an illustrating
example:
   struct t1 { ... }
   struct t2 { struct t1 *p; };
   struct t2 g;
   void foo(struct t1 *arg) { ... }
In the above case, we will have partial debuginfo chain like below:
   struct t2 -> member p
                        \ -> ptr -> struct t1
                        /
     foo -> argument arg
During traversing
   struct t2 -> member p -> ptr -> struct t1
The corresponding BTF types are generated except 'struct t1' which
will be in FixUp stage. Later, when traversing
   foo -> argument arg -> ptr -> struct t1
The 'ptr' BTF type has been generated and currently implementation
ignores 'pointer' type hence 'struct t1' is not generated.

This patch fixed the issue not just for the above case, but for
general case with multiple derived types, e.g.,
   struct t2 -> member p
                        \ -> const -> ptr -> volatile -> struct t1
                        /
     foo -> argument arg

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

2 years ago[bazel] Add libc dependency.
Alina Sbirlea [Thu, 17 Feb 2022 00:28:05 +0000 (16:28 -0800)]
[bazel] Add libc dependency.

2 years ago[lld-macho] Don't include CommandFlags.h in CommonLinkerContext.h
Jez Ng [Thu, 17 Feb 2022 01:03:57 +0000 (20:03 -0500)]
[lld-macho] Don't include CommandFlags.h in CommonLinkerContext.h

Main motivation: including `llvm/CodeGen/CommandFlags.h` in
`CommonLinkerContext.h` means that the declaration of `llvm::Reloc` is
visible in any file that includes `CommonLinkerContext.h`. Since our
cpp files have both `using namespace llvm` and `using namespace
lld::macho`, this results in conflicts with `lld::macho::Reloc`.

I suppose we could put `llvm::Reloc` into a nested namespace, but in general,
I think we should avoid transitively including too many header files in
a very widely used header like `CommonLinkerContext.h`.

RegisterCodeGenFlags' ctor initializes a bunch of function-`static`
structures and does nothing else, so it should be fine to "initialize"
it as a temporary stack variable rather than as a file static.

Reviewed By: aganea

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

2 years ago[RewriteStatepointsForGC] Add a test exposing an incorrect assertion
Daniil Suchkov [Tue, 15 Feb 2022 23:46:21 +0000 (23:46 +0000)]
[RewriteStatepointsForGC] Add a test exposing an incorrect assertion

2 years ago[WebAssembly] Make __wasm_lpad_context thread-local
Heejin Ahn [Mon, 14 Feb 2022 23:13:07 +0000 (15:13 -0800)]
[WebAssembly] Make __wasm_lpad_context thread-local

This makes `__wasm_lpad_context`, a struct that is used as a
communication channel between compiler-generated code and personality
function in libunwind, thread local. The library code will be changed to
thread local in the emscripten side.

Reviewed By: sbc100, tlively

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

2 years agoAMDGPU: Always reserve VGPR for AGPR copies on gfx908
Matt Arsenault [Mon, 14 Feb 2022 22:22:55 +0000 (17:22 -0500)]
AMDGPU: Always reserve VGPR for AGPR copies on gfx908

Just because there aren't AGPRs in the original program doesn't mean
the register allocator can't choose to use them (unless we were to
forcibly reserve all AGPRs if there weren't any uses). This happens in
high pressure situations and introduces copies to avoid spills.

In this test, the allocator ends up introducing a copy from SGPR to
AGPR which requires an intermediate VGPR. I don't believe it would
introduce a copy from AGPR to AGPR in this situation, since it would
be trying to use an intermediate with a different class.

Theoretically this is also broken on gfx90a, but I have been unable to
come up with a testcase.

2 years ago[mlir][doc] Add passes docs to Passes.md
Jacques Pienaar [Wed, 16 Feb 2022 23:42:20 +0000 (15:42 -0800)]
[mlir][doc] Add passes docs to Passes.md

2 years ago[NFC] [MTE] [HWASan] Remove unnecessary member of AllocaInfo
Florian Mayer [Tue, 15 Feb 2022 20:02:35 +0000 (12:02 -0800)]
[NFC] [MTE] [HWASan] Remove unnecessary member of AllocaInfo

Reviewed By: eugenis

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

2 years ago[AMDGPU] Add agpr_count to metadata and AsmParser
Jacob Lambert [Wed, 2 Feb 2022 03:40:11 +0000 (19:40 -0800)]
[AMDGPU] Add agpr_count to metadata and AsmParser

gfx90a allows the number of ACC registers (AGPRs) to be set
independently to the VGPR registers. For both HSA and PAL metadata, we
now include an "agpr_count" key to report the number of AGPRs set for
supported devices (gfx90a, gfx908, as determined by hasMAIInsts()).
This is collected from SIProgramInfo.NumAccVGPR for both HSA and PAL.
The AsmParser also now recognizes ".kernel.agpr_count" for supported
devices.

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

2 years ago[libc++] Remove a few unneeded _LIBCPP_CXX03_LANG ifdefs
Nikolas Klauser [Wed, 16 Feb 2022 17:55:43 +0000 (18:55 +0100)]
[libc++] Remove a few unneeded _LIBCPP_CXX03_LANG ifdefs

Reviewed By: Quuxplusone, ldionne, #libc

Spies: libcxx-commits

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

2 years ago[SLPVectorizer][OpaquePtrs] Check GEP source element type
Arthur Eubanks [Wed, 16 Feb 2022 22:30:51 +0000 (14:30 -0800)]
[SLPVectorizer][OpaquePtrs] Check GEP source element type

Fixes a miscompile with opaque pointers.

Reviewed By: #opaque-pointers, nikic

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

2 years ago[test][SLPVectorizer][OpaquePtr] Precommit test
Arthur Eubanks [Wed, 16 Feb 2022 22:26:58 +0000 (14:26 -0800)]
[test][SLPVectorizer][OpaquePtr] Precommit test

2 years ago[mlir] Async: create async.group inside the scf.if branch
Eugene Zhulenev [Wed, 16 Feb 2022 18:40:28 +0000 (10:40 -0800)]
[mlir] Async: create async.group inside the scf.if branch

Reviewed By: cota

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

2 years ago[lld][WebAssembly] Apply global relocs before data relocs
Sam Clegg [Sun, 13 Feb 2022 16:00:42 +0000 (08:00 -0800)]
[lld][WebAssembly] Apply global relocs before data relocs

Since the code for apply data relocations can sometimes use
the values stored in he globals, they need to be relocated
before the data relocations can be run.

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

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

2 years ago[clang-format] Make checking for a record more robust and avoid a loop.
Marek Kurdej [Wed, 16 Feb 2022 22:05:34 +0000 (23:05 +0100)]
[clang-format] Make checking for a record more robust and avoid a loop.

2 years ago[Attributor][FIX] Heap2Stack needs to use the alloca AS
Johannes Doerfert [Tue, 15 Feb 2022 00:32:00 +0000 (18:32 -0600)]
[Attributor][FIX] Heap2Stack needs to use the alloca AS

When we move an allocation from the heap to the stack we need to
allocate it in the alloca AS and then cast the result. This also
prevents us from inserting the alloca after the allocation call but
rather right before.

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

2 years ago[Attributor][FIX] Use liveness information of the right function
Johannes Doerfert [Fri, 4 Feb 2022 09:17:20 +0000 (03:17 -0600)]
[Attributor][FIX] Use liveness information of the right function

When we use liveness for edges during the `genericValueTraversal` we
need to make sure to use the AAIsDead of the correct function. This
patch adds the proper logic and some simple caching scheme. We also
add an assertion to the `isEdgeDead` call to make sure future misuse
is detected earlier.

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

2 years ago[clang-format] Mark FormatToken::getPreviousNonComment() nodiscard. NFC.
Marek Kurdej [Wed, 16 Feb 2022 21:55:09 +0000 (22:55 +0100)]
[clang-format] Mark FormatToken::getPreviousNonComment() nodiscard. NFC.

2 years agotry to fix check-llvm after c5fb05f663f
Nico Weber [Wed, 16 Feb 2022 21:47:26 +0000 (16:47 -0500)]
try to fix check-llvm after c5fb05f663f

llvm-config wants all libraries referenced in
llvm/lib/CMakeLists.txt to exist on disk.

But WindowsDriver is only referenced in clang and lld and hence
wasn't built as a dependency of check-llvm.

Add it as an explicit dependency to make llvm-config happy.

2 years ago[lldb/test] Disable scripted_crashlog_json.test on non darwin aarch64 systems
Med Ismail Bennani [Wed, 16 Feb 2022 21:49:48 +0000 (13:49 -0800)]
[lldb/test] Disable scripted_crashlog_json.test on non darwin aarch64 systems

This patch adds requirement for the `scripted_crashlog_json` test to
make sure it only runs on apple silicon systems.

This should fix the following green dragon failure:
https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/41454

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2 years ago[flang] Add Win32 to the list of supported triples
Andrzej Warzynski [Wed, 9 Feb 2022 14:19:22 +0000 (14:19 +0000)]
[flang] Add Win32 to the list of supported triples

This patch adds Win32 to the list of supported triples in
`fir::CodeGenSpecifics`. This change means that we can use the "native"
triple, even when running tests on Windows. Currently this affects only
1 test, but it will change once we start adding more tests for lowering
and code-generation.

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

2 years ago[OpenMP] Pass AMDGPU math libraries into the linker wrapper
Joseph Huber [Tue, 15 Feb 2022 14:57:54 +0000 (09:57 -0500)]
[OpenMP] Pass AMDGPU math libraries into the linker wrapper

This patch passes in the AMDPGU math libraries to the linker wrapper.
The wrapper already handles linking OpenMP bitcode libraries via the
`--target-library` option. This should be sufficient to link in math
libraries for the accompanying architecture.

Fixes #53526.

Reviewed By: jdoerfert

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

2 years ago[OpenMP] Properly save strings when doing LTO
Joseph Huber [Wed, 16 Feb 2022 21:30:45 +0000 (16:30 -0500)]
[OpenMP] Properly save strings when doing LTO

Summary:
We were not previously saving strings when saving symbol names during
LTO symbol resolution. This caused a crash inside the dense set when
some of the strings would rarely be moved internally by the object file
class.

2 years ago[clang-format] Fix formatting of struct-like records followed by variable declaration.
Marek Kurdej [Mon, 14 Feb 2022 21:25:36 +0000 (22:25 +0100)]
[clang-format] Fix formatting of struct-like records followed by variable declaration.

Fixes https://github.com/llvm/llvm-project/issues/24781.
Fixes https://github.com/llvm/llvm-project/issues/38160.

This patch splits `TT_RecordLBrace` for classes/enums/structs/unions (and other records, e.g. interfaces) and uses the brace type to avoid the error-prone scanning for record token.

The mentioned bugs were provoked by the scanning being too limited (and so not considering `const` or `constexpr`, or other qualifiers, on an anonymous struct variable declaration).

Moreover, the proposed solution is more efficient as we parse tokens once only (scanning being parsing too).

Reviewed By: MyDeveloperDay, HazardyKnusperkeks

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

2 years ago[NFC] Fix order in global_symbols.txt.
Florian Mayer [Wed, 16 Feb 2022 21:34:02 +0000 (13:34 -0800)]
[NFC] Fix order in global_symbols.txt.

I added posix_madvise out of order before.

2 years ago[libc++] Refactor the Apple build scripts
Louis Dionne [Thu, 3 Feb 2022 15:57:49 +0000 (10:57 -0500)]
[libc++] Refactor the Apple build scripts

This patch upstreams some changes we've made internally to how we're
building the libc++ dylib on Apple platforms. The goal is still to
eventually get rid of `apple-install-libcxx.sh` entirely and have a
proper way to mirror what we do internally with just the normal CMake
configuration.

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

2 years ago[libc++abi] Bump the libc++abi version and add it to the post-release list
Louis Dionne [Wed, 16 Feb 2022 15:44:39 +0000 (10:44 -0500)]
[libc++abi] Bump the libc++abi version and add it to the post-release list

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

2 years ago[NFC][PhaseOrdering] spurious-peeling.ll: also test -O1/-O2 results
Roman Lebedev [Wed, 16 Feb 2022 20:39:26 +0000 (23:39 +0300)]
[NFC][PhaseOrdering] spurious-peeling.ll: also test -O1/-O2 results

2 years ago[NFC][PhaseOrdering] Precommit tests from D119965
William S. Moses [Wed, 16 Feb 2022 20:29:42 +0000 (23:29 +0300)]
[NFC][PhaseOrdering] Precommit tests from D119965

2 years agoUse functions with prototypes when appropriate; NFC
Aaron Ballman [Wed, 16 Feb 2022 21:09:36 +0000 (16:09 -0500)]
Use functions with prototypes when appropriate; NFC

A significant number of our tests in C accidentally use functions
without prototypes. This patch converts the function signatures to have
a prototype for the situations where the test is not specific to K&R C
declarations. e.g.,

  void func();

becomes

  void func(void);

This is the twelfth batch of tests being updated (the end may be in
sight soon though).

2 years ago[clang-format] Fall through and avoid an unnecessary check. NFC.
Marek Kurdej [Wed, 16 Feb 2022 21:06:04 +0000 (22:06 +0100)]
[clang-format] Fall through and avoid an unnecessary check. NFC.

2 years agoFix build_symbolizer.sh.
Florian Mayer [Wed, 16 Feb 2022 21:04:37 +0000 (13:04 -0800)]
Fix build_symbolizer.sh.

We now use posix_madvise, so we need to allow this symbol.

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

2 years ago[OpenMP][FIX] Eliminate race on the IsSPMD global
Johannes Doerfert [Mon, 14 Feb 2022 23:19:33 +0000 (17:19 -0600)]
[OpenMP][FIX] Eliminate race on the IsSPMD global

The `IsSPMD` global can only be read by threads other than the main
thread *after* initialization is complete. To allow usage of
`mapping::getBlockSize` before initialization is done, we can pass the
`IsSPMD` state explicitly. This is similar to other APIs that take
`IsSPMD` explicitly to avoid such a race, e.g.,
`mapping::isInitialThreadInLevel0(IsSPMD)`

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

2 years ago[Attributor][FIX] Pipe UsedAssumedInformation through more interfaces
Johannes Doerfert [Wed, 16 Feb 2022 17:05:09 +0000 (11:05 -0600)]
[Attributor][FIX] Pipe UsedAssumedInformation through more interfaces

`UsedAssumedInformation` is a return argument utilized to determine what
information is known. Most APIs used it already but
`genericValueTraversal` did not. This adds it to `genericValueTraversal`
and replaces `AllCallSitesKnown` of `checkForAllCallSites` with the
commonly used `UsedAssumedInformation`.

This was supposed to be a NFC commit, then the test change appeared.
Turns out, we had one user of `AllCallSitesKnown` (AANoReturn) and the
way we set `AllCallSitesKnown` was wrong as we ignored the fact some
call sites were optimistically assumed dead. Included a dedicated test
for this as well now.

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

2 years ago[MachineOutliner] NFC: Update LRU stuff for RISCV
Jessica Paquette [Wed, 16 Feb 2022 19:59:57 +0000 (11:59 -0800)]
[MachineOutliner] NFC: Update LRU stuff for RISCV

I missed it in my grep. Fixes broken buildbot.`

2 years ago[LLDB] Replace use of double underscore in identifiers
Shafik Yaghmour [Wed, 16 Feb 2022 19:51:50 +0000 (11:51 -0800)]
[LLDB] Replace use of double underscore in identifiers

Identifiers with __ anywhere are reserved. I picked this up via the
bugprone-reserved-identifier clang-tidy check but -Wreserved-identifier will
also flag these uses as well.

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

2 years ago[lldb/crashlog] Fix exception signal parsing
Med Ismail Bennani [Wed, 16 Feb 2022 19:43:53 +0000 (11:43 -0800)]
[lldb/crashlog] Fix exception signal parsing

In some cases, it can happen that crashlogs don't have any signal in
the exception, which causes the parser to crash.

This fixes the parsing by checking if the `signal` field is in the
`exception` dictionary before trying to access it.

rdar://84552251

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2 years ago[lldb/crashlog] Add CrashLogScriptedProcess & remove interactive mode
Med Ismail Bennani [Wed, 16 Feb 2022 19:43:44 +0000 (11:43 -0800)]
[lldb/crashlog] Add CrashLogScriptedProcess & remove interactive mode

This patch introduces a new type of ScriptedProcess: CrashLogScriptedProcess.
It takes advantage of lldb's crashlog parsers and Scripted Processes to
reconstruct a static debugging session with symbolicated stackframes, instead
of just dumping out everything in the user's terminal.

The crashlog command also has an interactive mode that only provide a
very limited experience. This is why this patch removes all the logic
for this interactive mode and creates CrashLogScriptedProcess instead.

This will fetch and load all the libraries that were used by the crashed
thread and re-create all the frames artificially.

rdar://88721117

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2 years ago[lldb/API] Add a way to check if the CommandInterpreter is interactive
Med Ismail Bennani [Fri, 11 Feb 2022 00:12:59 +0000 (16:12 -0800)]
[lldb/API] Add a way to check if the CommandInterpreter is interactive

This patch adds the ability for the user to check if the command
interpreter's IOHandler is interactive.

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2 years ago[lldb/Plugin] Add artificial stackframe loading in ScriptedThread
Med Ismail Bennani [Thu, 10 Feb 2022 03:04:21 +0000 (19:04 -0800)]
[lldb/Plugin] Add artificial stackframe loading in ScriptedThread

This patch adds the ability for ScriptedThread to load artificial stack
frames. To do so, the interpreter instance can create a list that will
contain the frame index and its pc address.

Then, when the Scripted Process plugin stops, it will refresh its
Scripted Threads state by invalidating their register context and load
to list from the interpreter object and reconstruct each frame.

This patch also removes all of the default implementation for
`get_stackframes` from the derived ScriptedThread classes, and add the
interface code for the Scripted Thread Interface.

rdar://88721095

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2 years ago[lldb/Plugins] Clean-up ScriptedProcess python script (NFC)
Med Ismail Bennani [Thu, 10 Feb 2022 00:24:39 +0000 (16:24 -0800)]
[lldb/Plugins] Clean-up ScriptedProcess python script (NFC)

This patch removes the `my_scripted_process.py` blueprint since it's not
used anymore.

The patch also updates the base ScriptedProcess and ScriptedThread
initializers to automatically initialize convinience variables, to
access debugger from the ScriptedProcess, access the SBProcess and
ScriptedProcess object from a ScriptedThread instance.

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2 years ago[MachineOutliner] NFC: Hide LRU-related stuff behind helper functions
Jessica Paquette [Wed, 16 Feb 2022 19:28:14 +0000 (11:28 -0800)]
[MachineOutliner] NFC: Hide LRU-related stuff behind helper functions

It's not particularly user-friendly to have to call `initLRU` everywhere. Also,
it wasn't particularly great that the LRU for registers used in a sequence was
also initialized by `initLRU`.

This patch hides this stuff behind some helper functions:

* `isAvailableAcrossAndOutOfSeq`
* `isAnyUnavailableAcrossOrOutOfSeq`
* `isAvailableInsideSeq`

This allows the user to avoid calling `initLRU` explicitly. Also, it allows
us to separate initializing the used-in-sequence LRU from the main LRU.

Since both ARM and AArch64 check LR liveness in `insertOutlinedCall`, this
refactor requires that we de-const the Candidate there.

Some other quality-of-code improvements:

* LRUs in outliner::Candidate now have more descriptive names
* Use `Register` instead of `unsigned` in some places
* Improve readability in some places by using ranges rather than `std::for_each`

This is a preparatory commit for a larger compile time related change for the
AArch64 outliner.

2 years agoDebugInfo: fix a couple of spurious spaces in simplified template name rebuilding
David Blaikie [Wed, 16 Feb 2022 19:18:31 +0000 (11:18 -0800)]
DebugInfo: fix a couple of spurious spaces in simplified template name rebuilding

2 years ago[flang] Handle lowering arguments in subroutine and function
Valentin Clement [Wed, 16 Feb 2022 19:27:23 +0000 (20:27 +0100)]
[flang] Handle lowering arguments in subroutine and function

This patch adds infrsatrcutrue to be able to lower
arguments in functions and subroutines.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: PeteSteinfeld

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

Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: Jean Perier <jperier@nvidia.com>
2 years ago[NFC][SCEV] Recognize umin_seq when operand is zext'ed in zero-check
Roman Lebedev [Wed, 16 Feb 2022 18:57:04 +0000 (21:57 +0300)]
[NFC][SCEV] Recognize umin_seq when operand is zext'ed in zero-check

zext(umin(x,y)) == umin(zext(x),zext(y))
zext(x) == 0  ->  x == 0

While it is not a very likely scenario, we probably should not expect
that instcombine already dropped such a redundant zext,
but handle directly. Moreover, perhaps there was no ZExtInst,
and SCEV somehow managed to  pull out said zext out of the SCEV expression.

2 years ago[NFC][SCEV] Recognize umin_seq when operand is zext'ed in umin but not in zero-check
Roman Lebedev [Wed, 16 Feb 2022 18:46:39 +0000 (21:46 +0300)]
[NFC][SCEV] Recognize umin_seq when operand is zext'ed in umin but not in zero-check

zext(umin(x,y)) == umin(zext(x),zext(y))
zext(x) == 0  ->  x == 0

Extra leading zeros do not affect the result of comparison with zero,
nor do they matter for the unsigned min/max,
so we should not be dissuaded when we find a zero-extensions,
but instead we should just skip it.

2 years ago[NFC][SCEV] Add tests for umin_seq recognition with interfering zext's
Roman Lebedev [Wed, 16 Feb 2022 18:31:40 +0000 (21:31 +0300)]
[NFC][SCEV] Add tests for umin_seq recognition with interfering zext's

2 years agoHoist getTotalNumVGPRs into AMDGPUBaseInfo for use in both codegen and MC
Jacob Lambert [Wed, 16 Feb 2022 03:07:20 +0000 (19:07 -0800)]
Hoist getTotalNumVGPRs into AMDGPUBaseInfo for use in both codegen and MC

Reviewed By: arsenm

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

2 years ago[HWASan] Improve dbg-value-tag-offset test.
Florian Mayer [Wed, 16 Feb 2022 00:10:00 +0000 (16:10 -0800)]
[HWASan] Improve dbg-value-tag-offset test.

Reviewed By: hctim

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

2 years ago[polly] Match function definitions and header declarations. NFC.
Michael Kruse [Wed, 16 Feb 2022 17:56:25 +0000 (11:56 -0600)]
[polly] Match function definitions and header declarations. NFC.

Ensure that function definitions match their declrations in header
files, even if they have no effect on linking. This includes

 1. Both have the same __isl_* annotations

 2. Both use the same type alias

 3. Remove unused declarations that have no definition

 4. Use explicit polly namespace qualifier for definitions; generally,
    the .cpp file should use at most an anon namespace region since
    only symbols declared in the header file can be accessed from other
    translation units anyway. For defintions that have been declared in
    the header file, the explicit namespace qualifier ensures that both
    match.

2 years ago[mlir][tensor] Add a pattern to split tensor.pad ops
Lei Zhang [Wed, 16 Feb 2022 16:26:47 +0000 (11:26 -0500)]
[mlir][tensor] Add a pattern to split tensor.pad ops

This commit adds a pattern to wrap a tensor.pad op with
an scf.if op to separate the cases where we don't need padding
(all pad sizes are actually zeros) and where we indeed need
padding.

This pattern is meant to handle padding inside tiled loops.
Under such cases the padding sizes typically depend on the
loop induction variables. Splitting them would allow treating
perfect tiles and edge tiles separately.

Reviewed By: nicolasvasilache

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

2 years ago[lldb] BreakpointResolver::CreateFromStructuredData Gardening (NFC)
Jonas Devlieghere [Wed, 16 Feb 2022 18:16:24 +0000 (10:16 -0800)]
[lldb] BreakpointResolver::CreateFromStructuredData Gardening (NFC)

 - Use an early return.
 - Check for error.Fail() instead of !error.Success().
 - Check the resolver pointer before using instead of relying on the
   error being set.

2 years ago[lldb] Default initialize DWARFDebugMacroHeader
Jonas Devlieghere [Wed, 16 Feb 2022 18:01:04 +0000 (10:01 -0800)]
[lldb] Default initialize DWARFDebugMacroHeader

Default initialize the DWARFDebugMacroHeader to avoid returning a header
with uninitialized variables from DWARFDebugMacroHeader::ParseHeader.

2 years ago[llvm] [bindings/OCaml] Remove unused dep on ounit2
Michał Górny [Tue, 15 Feb 2022 20:21:12 +0000 (21:21 +0100)]
[llvm] [bindings/OCaml] Remove unused dep on ounit2

Remove the dependency on ounit2 and the relevant lit code.  It seems
that ounit2 is not used at all and all OCaml binding tests pass without
it installed.

Thanks for Shiwei Weng and Josh Berdine for bringing this to
my attention.

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

2 years ago[libcxxabi] [test] Depend on unwind only if available
Michał Górny [Fri, 11 Feb 2022 11:48:31 +0000 (12:48 +0100)]
[libcxxabi] [test] Depend on unwind only if available

When building libcxxabi via LLVM_ENABLE_RUNTIMES=libcxxabi the CMake
invocation fails because of missing "unwind" target.  However,
if the extraneous dependency is removed, the library builds just fine
against installed libunwind and tests work fine.  To fix this,
add the dependency only if the target actually exists.

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

2 years ago[test] Mark archive-as-start-lib.s as unsupported on Windows
Arthur Eubanks [Wed, 16 Feb 2022 17:32:45 +0000 (09:32 -0800)]
[test] Mark archive-as-start-lib.s as unsupported on Windows

gnuwin32 tail does not support the `tail -c +9` syntax.

Reviewed By: MaskRay

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

2 years agoAdd an include that is required on some hosts. This should fix the bot
Kevin P. Neal [Wed, 16 Feb 2022 18:10:14 +0000 (13:10 -0500)]
Add an include that is required on some hosts. This should fix the bot
failures.

2 years ago[ifs] Add the invalid STRSZ test to llvm-ifs
Haowei Wu [Mon, 14 Feb 2022 18:42:18 +0000 (10:42 -0800)]
[ifs] Add the invalid STRSZ test to llvm-ifs

This patch adds an addition test to test llvm-ifs's behavior when
DT_STRSZ value from .dynamic is invalid

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

2 years ago[gn build] (semi-manually) port f87aa19be644
Nico Weber [Wed, 16 Feb 2022 17:56:02 +0000 (12:56 -0500)]
[gn build] (semi-manually) port f87aa19be644

2 years ago[libc++] Move everything related solely to _LIBCPP_ASSERT to its own file
Louis Dionne [Mon, 14 Feb 2022 18:41:09 +0000 (13:41 -0500)]
[libc++] Move everything related solely to _LIBCPP_ASSERT to its own file

This is the first step towards disentangling the debug mode and assertions
in libc++. This patch doesn't make any functional change: it simply moves
_LIBCPP_ASSERT-related stuff to its own file so as to make it clear that
libc++ assertions and the debug mode are different things. Future patches
will make it possible to enable assertions without enabling the debug
mode.

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

2 years ago[ELF][test] Add --undefine-glob test to lto/duplicated.ll
Fangrui Song [Wed, 16 Feb 2022 17:40:55 +0000 (09:40 -0800)]
[ELF][test] Add --undefine-glob test to lto/duplicated.ll

2 years ago[FPEnv][FMF] Move helper function to header, move fast math flags to new include...
Kevin P. Neal [Mon, 14 Feb 2022 16:49:43 +0000 (11:49 -0500)]
[FPEnv][FMF] Move helper function to header, move fast math flags to new include file.

In a prior review I was asked to move the helper function canIgnoreSNaN()
out to FPEnv.h. This wasn't possible at the time because that function
needs the fast math flags, and including them includes lots of other stuff
that isn't needed.

This patch moves the fast math flags out into a new FMF.h file unchanged,
and moves the helper function out to FPEnv.h also unchanged. This ticket
only moves code around.

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

2 years agoReverting ce420820c815e806bab9c5f17cb3b829a616548a because it fails expensive checks
Rashmi Mudduluru [Mon, 14 Feb 2022 19:09:43 +0000 (11:09 -0800)]
Reverting ce420820c815e806bab9c5f17cb3b829a616548a because it fails expensive checks

2 years ago[RISCV] Improve lowering of SHL_PARTS/SRL_PARTS/SRA_PARTS.
Craig Topper [Wed, 16 Feb 2022 17:13:32 +0000 (09:13 -0800)]
[RISCV] Improve lowering of SHL_PARTS/SRL_PARTS/SRA_PARTS.

Part of the shift lowering creates a (sub XLEN-1, ShAmt). When this
value is used we know that ShAmt is [0..XLEN-1]. Since XLEN is a power
of 2 we can replace the sub with an xor. This allows us to use XORI
instead of LI+SUB.

Reviewed By: asb

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

2 years ago[SelectionDAG] Add SPLAT_VECTOR to SelectionDAG::isConstantFPBuildVectorOrConstantFP.
Craig Topper [Wed, 16 Feb 2022 17:13:01 +0000 (09:13 -0800)]
[SelectionDAG] Add SPLAT_VECTOR to SelectionDAG::isConstantFPBuildVectorOrConstantFP.

Matches what is done for the int version.

Reviewed By: sdesmalen

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

2 years ago[InstCombine] add tests for min/max reassociation; NFC
Sanjay Patel [Wed, 16 Feb 2022 17:02:03 +0000 (12:02 -0500)]
[InstCombine] add tests for min/max reassociation; NFC

D119851

2 years ago[llvm-libgcc] initial commit
Christopher Di Bella [Tue, 17 Aug 2021 20:23:22 +0000 (20:23 +0000)]
[llvm-libgcc] initial commit

Note: the term "libgcc" refers to the all of `libgcc.a`, `libgcc_eh.a`,
and `libgcc_s.so`.

Enabling libunwind as a replacement for libgcc on Linux has proven to be
challenging since libgcc_s.so is a required dependency in the [Linux
standard base][5]. Some software is transitively dependent on libgcc
because glibc makes hardcoded calls to functions in libgcc_s. For example,
the function `__GI___backtrace` eventually makes its way to a [hardcoded
dlopen to libgcc_s' _Unwind_Backtrace][1]. Since libgcc_{eh.a,s.so} and
libunwind have the same ABI, but different implementations, the two
libraries end up [cross-talking, which ultimately results in a
segfault][2].

To solve this problem, libunwind needs to build a “libgcc”. That is, link
the necessary functions from compiler-rt and libunwind into an archive
and shared object that advertise themselves as `libgcc.a`, `libgcc_eh.a`,
and `libgcc_s.so`, so that glibc’s baked calls are diverted to the
correct objects in memory. Fortunately for us, compiler-rt and libunwind
use the same ABI as the libgcc family, so the problem is solvable at the
llvm-project configuration level: no program source needs to be edited.
Thus, the end result is for a user to configure their LLVM build with a
flag that indicates they want to archive compiler-rt/unwind as libgcc.
We achieve this by compiling libunwind with all the symbols necessary
for compiler-rt to emulate the libgcc family, and then generate symlinks
named for our "libgcc" that point to their corresponding libunwind
counterparts.

We alternatively considered patching glibc so that the source doesn't
directly refer to libgcc, but rather _defaults_ to libgcc, so that a
system preferring compiler-rt/libunwind can point to these libraries
at the config stage instead. Even if we modified the Linux standard
base, this alternative won't work because binaries that are built using
libgcc will still end up having crosstalk between the differing
implementations.

This problem has been solved in this manner for [FreeBSD][3], and this
CL has been tested against [Chrome OS][4].

[1]: https://github.com/bminor/glibc/blob/master/sysdeps/arm/backtrace.c#L68
[2]: https://bugs.chromium.org/p/chromium/issues/detail?id=1162190#c16
[3]: https://github.com/freebsd/freebsd-src/tree/main/lib/libgcc_s
[4]: https://chromium-review.googlesource.com/c/chromiumos/overlays/chromiumos-overlay/+/2945947
[5]: https://refspecs.linuxbase.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-generic/libgcc-s.html

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

2 years ago[lldb] Fix memory leak in CommandObjectType
Jonas Devlieghere [Wed, 16 Feb 2022 16:58:38 +0000 (08:58 -0800)]
[lldb] Fix memory leak in CommandObjectType

Avoid leaking the ScriptAddOptions or SynthAddOptions when we return
early because of an empty type name.

2 years ago[runtimes] Move warning messages for FOO_SYSROOT & friends above their default value
Louis Dionne [Wed, 16 Feb 2022 16:59:32 +0000 (11:59 -0500)]
[runtimes] Move warning messages for FOO_SYSROOT & friends above their default value

Otherwise, the warnings always trigger.

2 years agoclang-analyzer plugins require LLVM_ENABLE_PLUGINS also
Jameson Nash [Fri, 11 Feb 2022 21:42:37 +0000 (16:42 -0500)]
clang-analyzer plugins require LLVM_ENABLE_PLUGINS also

The clang-analyzer plugins are not linked to a particular tool, so they
can only be compiled if plugins are broadly supported. We could opt
instead to decide whether to link them to specifically against clang or
with undefined symbols, depending on the value of LLVM_ENABLE_PLUGINS,
but we do not currently expect there to be a use case for that rather
niche configuration.

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

2 years ago[demangler] Fix build breakage
Nathan Sidwell [Wed, 16 Feb 2022 16:03:24 +0000 (08:03 -0800)]
[demangler] Fix build breakage

The copy and pristine versions of Utility diverged and one didn't
include <algorithm>.  As that's a rather large header, let's just open
code the comparisons.

Reviewed By:

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

2 years agoRevert "[OpenMP] Pass AMDGPU math libraries into the linker wrapper"
Joseph Huber [Wed, 16 Feb 2022 16:53:31 +0000 (11:53 -0500)]
Revert "[OpenMP] Pass AMDGPU math libraries into the linker wrapper"

This hits an assertion in the linker wrapper. Revert for now, will fix
later.

This reverts commit 61fb260d9d8c26a61a8dfd64e94d51f2c9a06830.

2 years ago[AMDGPU][MC][GFX10] Added an alias for HW_REG_HW_ID1
Dmitry Preobrazhensky [Wed, 16 Feb 2022 16:43:19 +0000 (19:43 +0300)]
[AMDGPU][MC][GFX10] Added an alias for HW_REG_HW_ID1

Enabled HW_REG_HW_ID as an alias for HW_REG_HW_ID1. This is required for compatibility with existing code.

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

2 years ago[OpenMP] Pass AMDGPU math libraries into the linker wrapper
Joseph Huber [Tue, 15 Feb 2022 14:57:54 +0000 (09:57 -0500)]
[OpenMP] Pass AMDGPU math libraries into the linker wrapper

This patch passes in the AMDPGU math libraries to the linker wrapper.
The wrapper already handles linking OpenMP bitcode libraries via the
`--target-library` option. This should be sufficient to link in math
libraries for the accompanying architecture.

Fixes #53526.

Reviewed By: jdoerfert

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

2 years agoDarwin: introduce a global override for debug prefix map entries.
Adrian Prantl [Tue, 15 Feb 2022 16:23:16 +0000 (08:23 -0800)]
Darwin: introduce a global override for debug prefix map entries.

This patch adds a new Darwin clang driver environment variable in the
spirit of RC_DEBUG_OPTIONS, called RC_DEBUG_PREFIX_MAP, which allows a
meta build tool to add one additional -fdebug-prefix-map entry without
the knowledge of the build system.

rdar://85224675

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

2 years ago[libc++][ci] Allow updating packages and config files on macOS CI nodes
Louis Dionne [Wed, 16 Feb 2022 16:23:48 +0000 (11:23 -0500)]
[libc++][ci] Allow updating packages and config files on macOS CI nodes

2 years ago[PowerPC] Rename PPCInstrPrefix.td to PPCInstrP10.td
Lei Huang [Wed, 16 Feb 2022 15:36:04 +0000 (09:36 -0600)]
[PowerPC] Rename PPCInstrPrefix.td to PPCInstrP10.td

2 years ago[mlir][linalg] Add control to pad-slice swap pattern
Lei Zhang [Wed, 16 Feb 2022 15:28:51 +0000 (10:28 -0500)]
[mlir][linalg] Add control to pad-slice swap pattern

The pad-slice swap pattern generates `scf.if` and `tensor.generate`
to guard against zero-sized slices if it cannot prove the slice is
always non-zero. This is safe but quite conservative. It can be
unnecessary for cases where we know by problem definition such cases
does not exist, even if with dynamic shaped ops or unknown tile/slice
sizes, e.g., convolution padding size = 1 with kernel dim size = 3.

So this commit introduces a control to the pattern to specify
whether to generate the if constructs to handle such cases better,
given that once the if constructs is materialized, it's very hard
to analyze and simplify.

Reviewed By: mravishankar

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

2 years ago[mlir][MemRef] Lower memref.copy with an offset to memcpy
Benjamin Kramer [Wed, 16 Feb 2022 13:52:53 +0000 (14:52 +0100)]
[mlir][MemRef] Lower memref.copy with an offset to memcpy

memcpy can handle them as long as they're contiguous.

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

2 years ago[libc++] [test] Qualify calls to std::get(tuple). NFC.
Arthur O'Dwyer [Mon, 14 Feb 2022 03:52:25 +0000 (22:52 -0500)]
[libc++] [test] Qualify calls to std::get(tuple). NFC.

It actually *is* important (for structured bindings) that `get(tuple)`
be ADL-able; but that's not the point of this test in particular.

Reviewed as part of D119860.

2 years ago[libc++] [test] Qualify calls to std::rethrow_exception. NFC.
Arthur O'Dwyer [Mon, 14 Feb 2022 03:44:23 +0000 (22:44 -0500)]
[libc++] [test] Qualify calls to std::rethrow_exception. NFC.

We shouldn't be calling `rethrow_exception` via ADL -- and neither should anybody
in the wild be calling it via ADL, so it's not like we need to test
this ADL ability of `rethrow_exception` in particular.

Reviewed as part of D119860.

2 years ago[libc++] [test] Qualify calls to std::atomic_flag_{clear,test} functions. NFCI.
Arthur O'Dwyer [Mon, 14 Feb 2022 02:53:20 +0000 (21:53 -0500)]
[libc++] [test] Qualify calls to std::atomic_flag_{clear,test} functions. NFCI.

We shouldn't be calling these functions via ADL -- and neither should anybody
in the wild be calling it via ADL, so it's not like we need to test
the ADL ability of these functions in particular.

Reviewed as part of D119860.

2 years ago[libc++] [test] Qualify calls to std::getline. NFCI.
Arthur O'Dwyer [Mon, 14 Feb 2022 02:48:39 +0000 (21:48 -0500)]
[libc++] [test] Qualify calls to std::getline. NFCI.

Reviewed as part of D119860.

2 years ago[libc++] [test] Qualify calls to iomanip functions in std/input.output/iostream.forma...
Arthur O'Dwyer [Mon, 14 Feb 2022 02:46:06 +0000 (21:46 -0500)]
[libc++] [test] Qualify calls to iomanip functions in std/input.output/iostream.format/. NFCI.

Reviewed as part of D119860.

2 years ago[libc++] [test] Qualify calls to iomanip functions in std/localization/. NFCI.
Arthur O'Dwyer [Mon, 14 Feb 2022 01:36:36 +0000 (20:36 -0500)]
[libc++] [test] Qualify calls to iomanip functions in std/localization/. NFCI.

Reviewed as part of D119860.

2 years ago[libc++] [test] Qualify `prev` as `std::prev` in a lot of tests. NFCI.
Arthur O'Dwyer [Mon, 14 Feb 2022 01:09:41 +0000 (20:09 -0500)]
[libc++] [test] Qualify `prev` as `std::prev` in a lot of tests. NFCI.

We shouldn't be calling `prev` via ADL -- and neither should anybody
in the wild be calling it via ADL, so it's not like we need to test
this ADL ability of `prev` in particular.

Reviewed as part of D119860.

2 years ago[libc++] [test] Qualify `next` as `std::next` in a lot of tests. NFCI.
Arthur O'Dwyer [Sun, 13 Feb 2022 19:50:33 +0000 (14:50 -0500)]
[libc++] [test] Qualify `next` as `std::next` in a lot of tests. NFCI.

We shouldn't be calling `next` via ADL -- and neither should anybody
in the wild be calling it via ADL, so it's not like we need to test
this ADL ability of `next` in particular.

Reviewed as part of D119860.

2 years ago[libc++] [test] Qualify `move` as `std::move` in a lot of tests. NFCI.
Arthur O'Dwyer [Sun, 13 Feb 2022 19:58:27 +0000 (14:58 -0500)]
[libc++] [test] Qualify `move` as `std::move` in a lot of tests. NFCI.

We shouldn't be calling `move` via ADL -- and neither should anybody
in the wild be calling it via ADL, so it's not like we need to test
this ADL ability of `move` in particular.

Reviewed as part of D119860.

2 years ago[libc++] LWG2148, LWG2543: Enable std::hash<Enum> in C++03 and C++11.
Arthur O'Dwyer [Tue, 15 Feb 2022 21:38:34 +0000 (16:38 -0500)]
[libc++] LWG2148, LWG2543: Enable std::hash<Enum> in C++03 and C++11.

Fixes #49601.

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

2 years ago[libc++] [test] Remove `using std::any{,_cast}` from std/utilities/any/. NFCI.
Arthur O'Dwyer [Mon, 14 Feb 2022 01:45:23 +0000 (20:45 -0500)]
[libc++] [test] Remove `using std::any{,_cast}` from std/utilities/any/. NFCI.

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

2 years ago[libc++] [test] Remove `using std::{make_,}optional` from the optional tests.
Arthur O'Dwyer [Mon, 14 Feb 2022 01:23:39 +0000 (20:23 -0500)]
[libc++] [test] Remove `using std::{make_,}optional` from the optional tests.

Drive-by remove some use of raw `new`, and expand test coverage a tiny bit.

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

2 years agoPrecommit tests from D119844, expanded with additional coverage
Philip Reames [Wed, 16 Feb 2022 15:55:35 +0000 (07:55 -0800)]
Precommit tests from D119844, expanded with additional coverage