platform/upstream/llvm.git
2 years ago[lldb] Add missing const to NativeRegisterContextLinux_x86_64
Jonas Devlieghere [Tue, 5 Apr 2022 21:24:32 +0000 (14:24 -0700)]
[lldb] Add missing const to NativeRegisterContextLinux_x86_64

Fixes error: invalid conversion from ‘const uint8_t*’ {aka ‘const
unsigned char*’} to ‘uint8_t*’ {aka ‘unsigned char*’}

2 years agoRevert "[VFS] RedirectingFileSystem only replace path if not already mapped"
Ben Barham [Mon, 4 Apr 2022 23:38:46 +0000 (16:38 -0700)]
Revert "[VFS] RedirectingFileSystem only replace path if not already mapped"

This reverts commit 3fda0edc51fd68192a30e302d45db081bb02d7f9, which
breaks crash reproducers in very specific circumstances. Specifically,
since crash reproducers have `UseExternalNames` set to false, the
`File->getFileEntry().getDir()->getName()` call in `DoFrameworkLookup`
would use the *cached* directory name instead of the directory of the
looked-up file.

The plan is to re-commit this patch but to *add*
`ExposesExternalVFSPath` rather than replace `IsVFSMapped`.

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

2 years ago[lldb] Update the NativeRegisterContext to take a WritableMemoryBuffer
Jonas Devlieghere [Tue, 5 Apr 2022 21:17:26 +0000 (14:17 -0700)]
[lldb] Update the NativeRegisterContext to take a WritableMemoryBuffer

2 years ago[PS4] Fix header search list
Paul Robinson [Tue, 5 Apr 2022 21:13:50 +0000 (14:13 -0700)]
[PS4] Fix header search list

A missing "break" in the initial implementation had us adding a
spurious "/usr/include" to the header search list. Later someone
introduced LLVM_FALLTHROUGH to prevent a warning.  Replace this with
the correct "break" and make sure the extra directory isn't added to
the PS4 header search list.

2 years agoEmit OpenCL metadata when targeting SPIR-V
Shangwu Yao [Mon, 4 Apr 2022 16:52:46 +0000 (16:52 +0000)]
Emit OpenCL metadata when targeting SPIR-V

This is required for converting function calls such as get_global_id()
into SPIR-V builtins.

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

2 years ago[mlir] Reinstate the variable
Bill Wendling [Tue, 5 Apr 2022 20:56:44 +0000 (13:56 -0700)]
[mlir] Reinstate the variable

Mid-air collition of patches.

2 years ago[lldb] Update reinterpret_cast in linux/Host.cpp
Jonas Devlieghere [Tue, 5 Apr 2022 20:50:12 +0000 (13:50 -0700)]
[lldb] Update reinterpret_cast in linux/Host.cpp

Fixes error: reinterpret_cast from type ‘const uint8_t*’ {aka ‘const
unsigned char*’} to type ‘char*’ casts away qualifiers

2 years agoReland "[ASTMatchers] Output currently matching node on crash"
Nathan James [Tue, 5 Apr 2022 20:47:06 +0000 (21:47 +0100)]
Reland "[ASTMatchers] Output currently matching node on crash"

Extend D120185 to also log the node being matched on in case of a crash.
This can help if a matcher is causing a crash or there are not enough interesting nodes bound.

Reviewed By: aaron.ballman

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

This reverts commit 61d67c8eecd2547bc690f9a6bba61b9ba814c71b.

This relands commit 6e33e45b943061f79ab6de1b60d04d4c6f32f8f9.

Fixing the build issue on 32bit machines due to not enough free bits in the PointerUnion.

2 years ago[lldb] Change CreateMemoryInstance to take a WritableDataBuffer
Jonas Devlieghere [Tue, 5 Apr 2022 20:33:55 +0000 (13:33 -0700)]
[lldb] Change CreateMemoryInstance to take a WritableDataBuffer

Change the CreateMemoryInstance interface to take a WritableDataBuffer.

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

2 years ago[lldb] Refactor DataBuffer so we can map files as read-only
Jonas Devlieghere [Fri, 1 Apr 2022 22:59:18 +0000 (15:59 -0700)]
[lldb] Refactor DataBuffer so we can map files as read-only

Currently, all data buffers are assumed to be writable. This is a
problem on macOS where it's not allowed to load unsigned binaries in
memory as writable. To be more precise, MAP_RESILIENT_CODESIGN and
MAP_RESILIENT_MEDIA need to be set for mapped (unsigned) binaries on our
platform.

Binaries are mapped through FileSystem::CreateDataBuffer which returns a
DataBufferLLVM. The latter is backed by a llvm::WritableMemoryBuffer
because every DataBuffer in LLDB is considered to be writable. In order
to use a read-only llvm::MemoryBuffer I had to split our abstraction
around it.

This patch distinguishes between a DataBuffer (read-only) and
WritableDataBuffer (read-write) and updates LLDB to use the appropriate
one.

rdar://74890607

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

2 years ago[mlir] Remove an unused variable and correct types.
Bill Wendling [Tue, 5 Apr 2022 20:43:45 +0000 (13:43 -0700)]
[mlir] Remove an unused variable and correct types.

No functionality change.

2 years ago[mlir-vscode] Add better support for multiple workspace folders
River Riddle [Thu, 31 Mar 2022 09:26:12 +0000 (02:26 -0700)]
[mlir-vscode] Add better support for multiple workspace folders

We currently only launch one set of language clients when starting the extension,
but this has the unfortunate effect of applying the same settings to all workspace
folders. This commit adds support for multiple workspace folders by launching
a server for each folder in the workspace. This allows for having different servers
for different workspace folders, e.g. when there are multiple MLIR projects in
the same workspace.

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

2 years ago[mlir-vscode] Add better resolution for server file paths
River Riddle [Thu, 31 Mar 2022 08:04:21 +0000 (01:04 -0700)]
[mlir-vscode] Add better resolution for server file paths

We currently require that server paths are full paths, which is
fairly inconvenient for a myriad of reasons. This commit
attempts to resolve a given server path with the current workspace.

This has a nice additional affect that we can now actually have
default server paths. This means that mlir-lsp-server and
mlir-pdll-lsp-server can be transparently picked up from
build directories (i.e. generally no need for upstream users to
configure the extension).

Fixes #54627

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

2 years ago[BOLT] Check for !isTailCall in isUnconditionalBranch
Vladislav Khmelevsky [Fri, 1 Apr 2022 18:57:51 +0000 (21:57 +0300)]
[BOLT] Check for !isTailCall in isUnconditionalBranch

Add !isTailCall in isUnconditionalBranch check in order to sync the x86
and aarch64 and fix the fixDoubleJumps pass on aarch64.

Vladislav Khmelevsky,
Advanced Software Technology Lab, Huawei

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

2 years agoFix typo in new -config-file option
Aaron Siddhartha Mondal [Tue, 5 Apr 2022 20:27:56 +0000 (16:27 -0400)]
Fix typo in new -config-file option

The new -config-file option introduced by 9e1f4f1 was accidentally
referenced as args.config_path on the python side. This patch renames
args.config_path to args.config_file.

To avoid confusion with python file objects, the input argument for
get_tidy_invocation has been renamed from config_path to
config_file_path.

See GitHub issue #54728 for a discussion.

2 years ago[mlir][linalg] Move linalg.fill folding into linalg.generic pattern from canonicaliza...
Nirvedh [Thu, 31 Mar 2022 17:54:31 +0000 (17:54 +0000)]
[mlir][linalg] Move linalg.fill folding into linalg.generic pattern from canonicalization to elementwise fusion

Reviewed By: mravishankar

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

2 years agoMove BasicBlock::getTerminator definition to the header
Artur Pilipenko [Tue, 5 Apr 2022 19:32:58 +0000 (12:32 -0700)]
Move BasicBlock::getTerminator definition to the header

This way it can be inlined to its caller. This method
shows up in the profile and it is essentially a fancy
getter. It would benefit from inlining into its callers.

NFC.

2 years ago[JITLink] Fix sorting bug for PC-begin candidate symbols during EH-frame fixup.
Lang Hames [Tue, 5 Apr 2022 18:45:25 +0000 (11:45 -0700)]
[JITLink] Fix sorting bug for PC-begin candidate symbols during EH-frame fixup.

The sort should have been lexicographic, but wasn't. This resulted in us
choosing a common symbol at address zero over the intended target function,
leading to a crash.

This patch also moves sorting up to the start of the pass, which means that we
only need to hold on to the canonical symbol at each address rather than a list
of candidates.

2 years ago[PS5] Add PS5 as a legal triple component
Paul Robinson [Mon, 4 Apr 2022 20:55:35 +0000 (13:55 -0700)]
[PS5] Add PS5 as a legal triple component

2 years agoRefine memory buffer for importing shared cache objc class list
Jason Molenda [Tue, 5 Apr 2022 19:47:17 +0000 (12:47 -0700)]
Refine memory buffer for importing shared cache objc class list

In https://reviews.llvm.org/D118972 I increased this buffer to be
big enough to import 261,144 classes but this is a lot more than
we currently have, an allocating a too-large buffer can add memory
pressure even if it's only for a short time.  Reduce the size of
this memory buffer to big enough to import 163,840 classes.  I'll
probably move to a scheme where we read the objc classes in chunks,
with a smaller buffer and multiple inferior function calls.

rdar://91275493

2 years ago[clang] Emit target_clones resolver functions as COMDAT.
Tom Honermann [Fri, 25 Mar 2022 22:38:08 +0000 (15:38 -0700)]
[clang] Emit target_clones resolver functions as COMDAT.

Previously, resolver functions synthesized for target_clones multiversion
functions were not emitted as COMDAT. Now fixed.

2 years ago[clang] NFC: Extend comdat validation in target multiversion function tests.
Tom Honermann [Fri, 25 Mar 2022 22:35:16 +0000 (15:35 -0700)]
[clang] NFC: Extend comdat validation in target multiversion function tests.

2 years ago[Lint][Verifier] NFC: Rename 'Assert*' macros to 'Check*'.
Tom Honermann [Sat, 2 Apr 2022 01:52:29 +0000 (18:52 -0700)]
[Lint][Verifier] NFC: Rename 'Assert*' macros to 'Check*'.

The LLVM IR verifier and analysis linter defines and uses several macros in
code that performs validation of IR expectations. Previously, these macros
were named with an 'Assert' prefix. These names were misleading since the
macro definitions are not conditioned on build kind; they are defined
identically in builds that have asserts enabled and those that do not. This
was confusing since an LLVM developer might expect these macros to be
conditionally enabled as 'assert' is. Further confusion was possible since
the LLVM IR verifier is implicitly disabled (in Clang::ConstructJob()) for
builds without asserts enabled, but only for Clang driver invocations; not
for clang -cc1 invocations. This could make it appear that the macros were
not active for builds without asserts enabled, e.g. when investigating
behavior using the Clang driver, and thus lead to surprises when running
tests that exercise the clang -cc1 interface.

This change renames this set of macros as follows:
  Assert -> Check
  AssertDI -> CheckDI
  AssertTBAA -> CheckTBAA

2 years ago[PartiallyInlineLibCalls] Don't partially inline a musttail libcall.
Bert Abrath [Tue, 5 Apr 2022 19:20:52 +0000 (22:20 +0300)]
[PartiallyInlineLibCalls] Don't partially inline a musttail libcall.

Partially inlining a libcall that has the musttail attribute
leads to broken LLVM IR, triggering an assertion in the IR verifier.

Reviewed By: lebedev.ri

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

2 years ago[mlir] Fix unused variable warning. NFCI.
Benjamin Kramer [Tue, 5 Apr 2022 19:23:49 +0000 (21:23 +0200)]
[mlir] Fix unused variable warning. NFCI.

2 years ago[Darwin][ASan][Sanitizer] Enable dlclose-test for all darwin targets.
Roy Sundahl [Mon, 4 Apr 2022 22:33:56 +0000 (15:33 -0700)]
[Darwin][ASan][Sanitizer] Enable dlclose-test for all darwin targets.

Test was being skipped on non-x86 darwin architectures.

rdar://79795770

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

2 years agoChange the LLVM signpost category
Jonas Devlieghere [Tue, 5 Apr 2022 19:09:21 +0000 (12:09 -0700)]
Change the LLVM signpost category

Currently, the LLVM/LLDB timers are visible in Instruments for all apps.

The developer-visible "PointsOfInterest" category is reserved for
runtime issues and developer-authored "important" logging. These logs
are visible to developer almost always in Instruments

The LLVM/LLDB timers do not belong there. Having these present in the
system is noisy and confusing to developers. This patch moves them under
a new "toolchain" category.

rdar://91266582

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

2 years ago[GlobalISel] NFC: Regen some tests + improve test coverage for wide even types
Jessica Paquette [Tue, 5 Apr 2022 19:09:31 +0000 (12:09 -0700)]
[GlobalISel] NFC: Regen some tests + improve test coverage for wide even types

It turns out we don't do an awesome job with weird types like s318 (and other
types near them, like s316).

We don't have any test coverage for those types, so let's add some so it's
easier to see the impact of legalization improvements on them when we make
changes.

Since the test generator was changed, it's easier to update relevant tests prior
to changing things rather than squinting at a bunch of "ah, CHECK is now
CHECK-NEXT" lines. So, let's just regenerate a bunch of tests while we're
here.

Unfortunately the "CHECK-NEXT" scheme doesn't work with legalize-cmp for some
reason, and the test will fail. So keep that one having CHECK lines.

2 years ago[AMDGPU][OpenCL] Remove "printf and hostcall" diagnostic
Scott Linder [Tue, 5 Apr 2022 18:49:33 +0000 (18:49 +0000)]
[AMDGPU][OpenCL] Remove "printf and hostcall" diagnostic

The diagnostic is unreliable, and triggers even for dead uses of
hostcall that may exist when linking the device-libs at lower
optimization levels.

Eliminate the diagnostic, and directly document the limitation for
OpenCL before code object V5.

Make some NFC changes to clarify the related code in the
MetadataStreamer.

Add a clang test to tie OCL sources containing printf to the backend IR
tests for this situation.

Reviewed By: sameerds, arsenm, yaxunl

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

2 years ago[Clang] Do not warn on unused lifetime-extending vars with side effects...
Corentin Jabot [Tue, 29 Mar 2022 15:28:56 +0000 (17:28 +0200)]
[Clang] Do not warn on unused lifetime-extending vars with side effects...

const auto & var = ObjectWithSideEffects();

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

Reviewed By: aaron.ballman

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

2 years ago[mlir][vector] Separate high-D insert/extract strided slice rewrite
Lei Zhang [Tue, 5 Apr 2022 18:17:22 +0000 (14:17 -0400)]
[mlir][vector] Separate high-D insert/extract strided slice rewrite

Right now `populateVectorInsertExtractStridedSliceTransforms` contains
two categories of patterns, one for decomposing high-D insert/extract
strided slices, the other for lowering them to shuffle ops.
They are at different levels---the former is in the middle, while
the latter is a step of final lowering. Split them to give users
more control of which pattern to pick.

This means break down the previous `VectorExtractStridedSliceOpRewritePattern`,
which is doing two things together.

Also renamed those patterns to be clearer.

Reviewed By: ThomasRaoux

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

2 years agoCheck if register class was changed in constrainOperandRegClass()
Daniel Sanders [Tue, 5 Apr 2022 18:23:51 +0000 (11:23 -0700)]
Check if register class was changed in constrainOperandRegClass()

NFC
When no actual change happens there's no need to notify the
observers about the fact the register class is being constrained.
So we should avoid notifying observers when no change has
happened, because this can dramatically affect compile
time for particular test cases.

Reviewed By: dsanders, arsenm

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

2 years ago[lldb-vscode] Implement stderr/stdout on win32 and redirect lldb log to VSCode
Walter Erquinigo [Tue, 5 Apr 2022 18:21:22 +0000 (11:21 -0700)]
[lldb-vscode] Implement stderr/stdout on win32 and redirect lldb log to VSCode

This patch implements stderr/stdout forwarding on windows.
This was previously not implemented in D99974.
I added separate callbacks so the output can be sent to the different channels VSCode provides (OutputType::Stdout, OutputType::Stderr, OutputType::Console).

This patch also passes a log callback handler to SBDebugger::Create to be able to see logging output when it is enabled.

Since the output is now redirect on early startup I removed the calls to SetOutputFileHandle/SetErrorFileHandle, which set them to /dev/null.

I send the output of stderr/stdout/lldb log to OutputType::Console

Reviewed By: wallace

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

2 years ago[libc] Add holder class for va_lists
Michael Jones [Mon, 4 Apr 2022 18:47:22 +0000 (11:47 -0700)]
[libc] Add holder class for va_lists

This class is intended to be used in cases where a class is being used
on a va_list. It provides destruction and copy semantics with small
overhead. This is intended to be used in printf.

Reviewed By: sivachandra, lntue

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

2 years agoSpecify --format for tests to workaround AIX big archive write operation
Jake Egan [Tue, 5 Apr 2022 18:36:11 +0000 (14:36 -0400)]
Specify --format for tests to workaround AIX big archive write operation

D122746 missed the following tests, so this patch adds them.

This patch refactors D122949, which marked the following tests XFAIL, but it makes more sense to temporarily add `--format=gnu` option because these tests aren’t testing `llvm-ar` and AIX won’t lose their coverage.

Reviewed By: jhenderson, MaskRay, DiggerLin

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

2 years ago[mlir] Add the Emacs support for MLIR's LSP server
Mehdi Amini [Tue, 5 Apr 2022 17:51:29 +0000 (17:51 +0000)]
[mlir] Add the Emacs support for MLIR's LSP server

In order to use the MLIR LSP server in Emacs, first the `mlir-lsp-client.el`
has to be loaded via elisp and then, one should call `lsp-mlir-setup` function
to setup the LSP client. After that simply calling the `lsp` function while
the `mlir-mode` is active with result in finding the language server (default
to `mlir-lsp-server`) via the `lsp-mlir-server-executable` customization variable
and connecting to it by the LSP library. Users who use MLIR's language server
library to create their own server can simply set the variable `lsp-mlir-server-executable`
to point to their own implementation executable.

Reviewed By: tschuett

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

2 years ago[DFSan] Add dfsan-combine-taint-lookup-table option as work around for
Andrew Browne [Thu, 31 Mar 2022 07:13:53 +0000 (00:13 -0700)]
[DFSan] Add dfsan-combine-taint-lookup-table option as work around for
false negatives when dfsan-combine-pointer-labels-on-load=0 and
dfsan-combine-offset-labels-on-gep=0 miss data flows through lookup tables.

Example case:
https://github.com/abseil/abseil-cpp/blob/628a2825f8dc0219964886e7cc3f7f519e3bd950/absl/strings/ascii.h#L182

Reviewed By: vitalybuka

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

2 years ago[M68k] Adopt VarLenCodeEmitter for rest of the data instructions
Min-Yih Hsu [Sun, 19 Dec 2021 05:55:45 +0000 (13:55 +0800)]
[M68k] Adopt VarLenCodeEmitter for rest of the data instructions

This wraps up the encoding refactoring of all M68k instructions.

2 years agoFileManager: std::map => BumpPtrAllocator + DenseMap of pointers. NFC
Sam McCall [Tue, 5 Apr 2022 16:56:05 +0000 (18:56 +0200)]
FileManager: std::map => BumpPtrAllocator + DenseMap of pointers. NFC

This is both smaller and faster.

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

2 years ago[MLIR][Presburger] IntegerPolyhedron: add support for symbolic integer lexmin
Arjun P [Mon, 4 Apr 2022 22:31:28 +0000 (23:31 +0100)]
[MLIR][Presburger] IntegerPolyhedron: add support for symbolic integer lexmin

Add support for computing the symbolic integer lexmin of a polyhedron.
This finds, for every assignment to the symbols, the lexicographically
minimum value attained by the dimensions. For example, the symbolic lexmin
of the set

`(x, y)[a, b, c] : (a <= x, b <= x, x <= c)`

can be written as

```
x = a if b <= a, a <= c
x = b if a <  b, b <= c
```

This also finds the set of assignments to the symbols that make the lexmin unbounded.

This was previously landed in da92f92621e28a56fe8ad79d82eb60e436bf1d39 and
reverted in b238c252e8b1bbebc7ed79c08e06c23514d0dfb4 due to a build failure
in the code. Re-landing now with a fixed build.

Reviewed By: Groverkss

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

2 years ago[clangd] Add support to extract method for ExtractFunction Tweak
Fabio Rossini Sluzala [Tue, 5 Apr 2022 17:08:34 +0000 (19:08 +0200)]
[clangd] Add support to extract method for ExtractFunction Tweak

I miss more automatically refactoring functions when working with already running code, so I am making some small addition that I hope help more people.

This works by checking if the function is a method (CXXMethodDecl), then collecting information about the function that the code is being extracted, looking for the declaration if it is out-of-line, creating the declaration if it is necessary and putting the extracted function as a class-method.

This is my first code review request, sorry if I did something wrong.

Reviewed By: sammccall

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

2 years ago[OpenMPIRBuilder] Detect and fix ambiguous InsertPoints for createSections.
Michael Kruse [Tue, 5 Apr 2022 01:13:02 +0000 (20:13 -0500)]
[OpenMPIRBuilder] Detect and fix ambiguous InsertPoints for createSections.

Follow-up on D117226 for createSections.

Reviewed By: shraiysh

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

2 years agoDebugInfo: Don't use enumerators in template names for debug info as they are not...
David Blaikie [Tue, 5 Apr 2022 17:16:42 +0000 (17:16 +0000)]
DebugInfo: Don't use enumerators in template names for debug info as they are not canonical

Since enumerators may not be available in every translation unit they
can't be reliably used to name entities. (this also makes simplified
template name roundtripping infeasible - since the expected name could
only be rebuilt if the enumeration definition could be found (or only if
it couldn't be found, depending on the context of the original name))

2 years ago[libcxx] [test] Fix the locale ctype widen tests on Windows
Martin Storsjö [Thu, 20 Jan 2022 22:38:52 +0000 (22:38 +0000)]
[libcxx] [test] Fix the locale ctype widen tests on Windows

On Windows, like on macOS and FreeBSD, widening char(-5) in the
"C" locale succeeds and produces L'\u00fb'.

Switch widen_many to test \xfb instead of \x85; the mingw
version of btowc widens \x85 in the "C" locale into
\u2026 (which is the corresponding character according to the
Windows-1252 codepage), while Microsoft CRT's btowc widens it
into \u0085 (just like macOS and FreeBSD). Switch this to test \xfb
which is the character tested by the widen_1 test (as `char(-5)`),
which gets handled the same by all Windows implementations of btowc.

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

2 years ago[clang-format] Pass return code of git-clang-format by sys.exit()
owenca [Tue, 5 Apr 2022 16:34:06 +0000 (09:34 -0700)]
[clang-format] Pass return code of git-clang-format by sys.exit()

Fixes #54758

2 years agoAdd DXILPrepare CodeGen pass
Chris Bieneman [Wed, 23 Mar 2022 00:27:41 +0000 (19:27 -0500)]
Add DXILPrepare CodeGen pass

The DXIL Prepare pass handles the IR mutations required to convert
modern LLVM IR into something that more closely resembles LLVM-3.7 IR
so that the DXIL bitcode writer can emit 3.7 IR.

This change adds the codegen pass handling the first two IR
transformations:

* stripping new function attributes
* converting fneg into fsub

Reviewed By: nikic

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

2 years ago[MLIR][ROCm] Suppress warnings generated by HIP headers
Krzysztof Drewniak [Fri, 1 Apr 2022 18:23:02 +0000 (18:23 +0000)]
[MLIR][ROCm] Suppress warnings generated by HIP headers

This removes tens of warnings from build logs that we can't do
anything about.

Reviewed By: pcf000

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

2 years ago[RISCV] Add support for vp.fptosi where the result is a mask type.
Craig Topper [Tue, 5 Apr 2022 16:18:45 +0000 (09:18 -0700)]
[RISCV] Add support for vp.fptosi where the result is a mask type.

We can do this conversion by converting the same sized integer type, then compare the result with 0. The conversion is undefined if the converted FP value doesn't fit in an i1.

Reviewed By: frasercrmck

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

2 years ago[X86] fmaddsub/fmsubadd combines - add NOFMA target for reference
Simon Pilgrim [Tue, 5 Apr 2022 16:47:37 +0000 (17:47 +0100)]
[X86] fmaddsub/fmsubadd combines - add NOFMA target for reference

2 years ago[lldb] Improve documentation for some of the platform functions
Jonas Devlieghere [Tue, 5 Apr 2022 16:41:10 +0000 (09:41 -0700)]
[lldb] Improve documentation for some of the platform functions

Improve the documentation for the platform functions that take a process
host architecture as input.

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

2 years agoFix a mistyping introduced with the new container command.
Jim Ingham [Tue, 5 Apr 2022 16:40:11 +0000 (09:40 -0700)]
Fix a mistyping introduced with the new container command.

I also added a call to help in the test which was crashing before
the test, and not after.

2 years agoRevert "[Scudo] enabling anonymous named pages on Linux 5.17 and onwards."
Alex Brachet [Tue, 5 Apr 2022 16:38:49 +0000 (16:38 +0000)]
Revert "[Scudo] enabling anonymous named pages on Linux 5.17 and onwards."

This reverts commit 619499252307c520fd840a5f3c79ffa00eaf2264.

2 years ago[lldb] Fix undefined behavior: left shift of negative value
Jonas Devlieghere [Tue, 5 Apr 2022 16:35:46 +0000 (09:35 -0700)]
[lldb] Fix undefined behavior: left shift of negative value

Fix undefined behavior in AppleObjCRuntimeV2 where we were left shifting
a signed value. This also removes redundant casts of unobfuscated to
uint64_t which it already is.

rdar://91242879

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

2 years ago[x86] Fix infinite loop inside DAG combiner with lzcnt feature.
Pierre Gousseau [Tue, 5 Apr 2022 16:30:25 +0000 (17:30 +0100)]
[x86] Fix infinite loop inside DAG combiner with lzcnt feature.

The issue affects targets supporting fast-lzcnt such as btver2.
This removes extraneous zext/trunc node insertions to fix the infinite
loop.
This fixes Issue https://github.com/llvm/llvm-project/issues/54694

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

Reviewed By: RKSimon, spatel, lebedev.ri

2 years ago[lldb][intelpt] Remove `IntelPTInstruction` and move methods to `DecodedThread`
Alisamar Husain [Sun, 3 Apr 2022 09:52:21 +0000 (15:22 +0530)]
[lldb][intelpt] Remove `IntelPTInstruction` and move methods to `DecodedThread`

This is to reduce the size of the trace further and has appreciable results.

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

2 years ago[SVE] Extend support for folding select + masked gathers
Matt Devereau [Fri, 1 Apr 2022 03:57:04 +0000 (03:57 +0000)]
[SVE] Extend support for folding select + masked gathers

Extend the work done in D106376 to include masked gathers

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

2 years agoFix the test after D123031
Kirill Bobyrev [Tue, 5 Apr 2022 16:20:57 +0000 (18:20 +0200)]
Fix the test after D123031

2 years ago[MIPS] selectAddrFrameIndexOffset - use cast<> instead of dyn_cast<> to avoid derefer...
Simon Pilgrim [Tue, 5 Apr 2022 16:20:25 +0000 (17:20 +0100)]
[MIPS] selectAddrFrameIndexOffset - use cast<> instead of dyn_cast<> to avoid dereference of nullptr

The pointer is used immediately below, so assert the cast is correct instead of returning nullptr

2 years ago[libc++] add global variable template std::views::empty
Hui Xie [Tue, 5 Apr 2022 16:17:02 +0000 (18:17 +0200)]
[libc++] add global variable template std::views::empty

[libc++] add global variable template std::views::empty
Note it is neither a range adaptor, nor a CPO. It is simplify a global variable template.

Reviewed By: #libc, Mordante

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

2 years ago[MLIR] Check for static shape before bare pointer conversion
Lorenzo Chelini [Mon, 4 Apr 2022 13:22:30 +0000 (15:22 +0200)]
[MLIR] Check for static shape before bare pointer conversion

Originally in the returnOp conversion, the result type was changing to bare
pointer if the type was a memref. This is incorrect as conversion to bare
pointer can only be done if the memref has static shape, strides and offset.

Reviewed By: ftynse

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

2 years ago[libc++][test] Adds an cpp20_output_iterator.
Mark de Wever [Sat, 19 Mar 2022 16:37:15 +0000 (17:37 +0100)]
[libc++][test] Adds an cpp20_output_iterator.

This iterator is used to test code that only needs to satisfy the
output_iterator concept. Follow-up changes will use this iterator in
older language Standards.

Reviewed By: ldionne, #libc, philnik, var-const

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

2 years ago[flang] Fix fir.embox codegen with constant interior shape
Jean Perier [Tue, 5 Apr 2022 15:26:53 +0000 (17:26 +0200)]
[flang] Fix fir.embox codegen with constant interior shape

Fix https://github.com/flang-compiler/f18-llvm-project/issues/1416.

The `constRows` variable was being decremented too soon, causing the
last constant interior dimension extent being used to multiply the GEP
offset. This lead to wrong address computation and caused segfaults.

Note: also upstream fir.embox tests that can be upstreamed.

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

2 years ago[flang] Set lower bounds of array section fir.embox to one
Jean Perier [Tue, 5 Apr 2022 15:25:34 +0000 (17:25 +0200)]
[flang] Set lower bounds of array section fir.embox to one

Do not use the shift of a fir.embox to set lower bounds if there is
a fir.slice operand. This matches Fortran semantics where lower bounds
of array sections are ones.
Note that in case there is a fir.slice, the array shift may be provided
because it is used to calculate the origin/base address of an array slice.

Add a TODO for substring codegen since I noticed it was not upstreamed
yet and would cause some program to silently compile incorrectly.

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

2 years ago[clang-offload-bundler] add -input/-output options
Yaxun (Sam) Liu [Tue, 5 Apr 2022 14:44:13 +0000 (10:44 -0400)]
[clang-offload-bundler] add -input/-output options

Currently, clang-offload-bundler has -inputs and -outputs options that accept
values with comma as the delimiter. This causes issues with file paths
containing commas, which are valid file paths on Linux.

This add two new options -input and -output, which accept one single file,
and allow multiple instances. This allows arbitrary file paths. The old
-inputs and -outputs options will be kept for backward compatibility, but
are not allowed to be used with -input and -output options for simplicity.
In the future, -inputs and -outputs options will be phasing out.

RFC: https://discourse.llvm.org/t/rfc-adding-input-and-output-options-to-clang-offload-bundler/60049

Patch by: Siu Chi Chan

Reviewed by: Yaxun Liu

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

2 years agoReland "[clangd] IncludeCleaner: Add support for IWYU pragma private"
Kirill Bobyrev [Tue, 5 Apr 2022 14:54:52 +0000 (16:54 +0200)]
Reland "[clangd] IncludeCleaner: Add support for IWYU pragma private"

This lands 4cb38bfe76b7ef157485338623c931d04d17b958 again.

2 years ago[libc++] Tidy up tests for deduction guides and other compile-time failing properties...
Louis Dionne [Mon, 4 Apr 2022 17:35:41 +0000 (13:35 -0400)]
[libc++] Tidy up tests for deduction guides and other compile-time failing properties in std::string

Instead of using `.fail.cpp` tests, use `.verify.cpp` to check for the
exact reason of the failure. In the case of deduction guides, use SFINAE
based tests instead since that is our preferred way of testing those.

Finally, ensure that we actually run the test in `iter_alloc_deduction.pass.cpp`,
since we were not running anything before.

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

2 years ago[ValueTracking] Handle non-pow2 align assume bundle (PR53693)
Nikita Popov [Tue, 5 Apr 2022 14:48:40 +0000 (16:48 +0200)]
[ValueTracking] Handle non-pow2 align assume bundle (PR53693)

https://reviews.llvm.org/D119414 clarified that this is legal IR,
so handle it gracefully. (We could aggressively use the fact that
the pointer must be a null pointer in that case, but I'm not
bothering with that.)

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

2 years ago[X86] Regenerate test checks (NFC)
Nikita Popov [Tue, 5 Apr 2022 14:33:40 +0000 (16:33 +0200)]
[X86] Regenerate test checks (NFC)

2 years ago[clangd] Use stable keys for CanonicalIncludes mappings
Kirill Bobyrev [Tue, 5 Apr 2022 14:24:24 +0000 (16:24 +0200)]
[clangd] Use stable keys for CanonicalIncludes mappings

This patch switches CanonicalInclude mappings to use `llvm::sys::fs::UniqueID` for a stable file representation because the `FileEntry::getName()` results turn out to be changing throughout the lifetime of a program (exposed in D120306). This patch makes it possible for D120306 to be re-landed and increases overall stability.

Reviewed By: sammccall

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

2 years ago[libc++] Silence new deprecation warnings for C functions in tests
Louis Dionne [Tue, 5 Apr 2022 14:26:32 +0000 (10:26 -0400)]
[libc++] Silence new deprecation warnings for C functions in tests

2 years ago[clang][dataflow] Support integral casts
Yitzhak Mandelbaum [Mon, 4 Apr 2022 15:31:52 +0000 (15:31 +0000)]
[clang][dataflow] Support integral casts

Adds support for implicit casts `CK_IntegralCast` and `CK_IntegralToBoolean`.

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

2 years ago[clang] Document p1703 not needed
Nathan Sidwell [Tue, 5 Apr 2022 12:01:02 +0000 (05:01 -0700)]
[clang] Document p1703 not needed

We list p1703 as unimplemented, but it is subsumed by p1857.

Reviewed By: tbaeder

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

2 years agoAdding new tests to demonstrate code patterns with multiple or/and which can be combi...
Biplob Mishra [Tue, 5 Apr 2022 13:16:52 +0000 (14:16 +0100)]
Adding new tests to demonstrate code patterns with multiple or/and which can be combined with a single mask

2 years ago[gn build] (semi-automatically) Port 4661a65f4bea
Nico Weber [Tue, 5 Apr 2022 12:58:49 +0000 (08:58 -0400)]
[gn build] (semi-automatically) Port 4661a65f4bea

...and follow-up 970ae8376e53.

2 years ago[iwyu] Fix some header include regression
serge-sans-paille [Tue, 5 Apr 2022 13:01:06 +0000 (15:01 +0200)]
[iwyu] Fix some header include regression

Running iwyu-diff from https://github.com/serge-sans-paille/preprocessor-utils
makes it possible to quickly spot regression in unused includes. This patch
contains the few regressions since the last header cleanup.

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

2 years ago[BOLT] Fix plt relocations symbol match
Vladislav Khmelevsky [Sun, 3 Apr 2022 16:11:31 +0000 (19:11 +0300)]
[BOLT] Fix plt relocations symbol match

The bfd linker adds the symbol versioning string to the symbol name in symtab.
Skip the versioning part in order to find the registered PLT function.

Vladislav Khmelevsky,
Advanced Software Technology Lab, Huawei

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

2 years ago[clang][AArc64][SVE] Add support for comparison operators on SVE types
David Truby [Thu, 24 Mar 2022 14:51:39 +0000 (14:51 +0000)]
[clang][AArc64][SVE] Add support for comparison operators on SVE types

Comparison operators on SVE types return a signed integer vector
of the same width as the incoming SVE type. This matches the existing
behaviour for NEON types.

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

2 years ago[Hexagon] Fix out of range shift warning. NFC.
Simon Pilgrim [Tue, 5 Apr 2022 12:29:11 +0000 (13:29 +0100)]
[Hexagon] Fix out of range shift warning. NFC.

2 years agorev16 instruction is being generated for a half word byte swap on a 32-bit input...
Biplob Mishra [Tue, 5 Apr 2022 12:43:02 +0000 (13:43 +0100)]
rev16 instruction is being generated for a half word byte swap on a 32-bit input as a bswap+rotr. This is not true for a 64-bit input.

This patch implements the rev16 instruction for a AArch64 backend for a half word byte swap on a 64-bit input.

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

2 years ago[bazel] Try to fix the build after 4661a65f4b
Benjamin Kramer [Tue, 5 Apr 2022 12:40:52 +0000 (14:40 +0200)]
[bazel] Try to fix the build after 4661a65f4b

2 years agoReverting changes to correct the commit message
Biplob Mishra [Tue, 5 Apr 2022 12:38:14 +0000 (13:38 +0100)]
Reverting changes to correct the commit message

2 years ago[AArch64] Set maximum VF with shouldMaximizeVectorBandwidth
Jingu Kang [Tue, 5 Apr 2022 12:16:10 +0000 (13:16 +0100)]
[AArch64] Set maximum VF with shouldMaximizeVectorBandwidth

Set the maximum VF of AArch64 with 128 / the size of smallest type in loop.

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

2 years agoIn fast-math mode, when unsafe math optimizations are enabled, the
Zahira Ammarguellat [Sun, 3 Apr 2022 11:28:15 +0000 (04:28 -0700)]
In fast-math mode, when unsafe math optimizations are enabled, the
compiler is allowed to use optimizations that allow reassociation and
transformations that don’t guaranty accuracy.
For example (x+y)+z is transformed into x+(y+z) . Although
mathematically equivalent, these two expressions may not lead to the
same final result due to errors of summation.
Or x/x is transformed into 1.0 but x could be 0.0, INF or NaN. And so
this transformation also may not lead to the same final result.
Setting the eval method 'ffp-eval-method' or via '#pragma clang fp
eval_method' in this mode, doesn’t have any effect.
This patch adds code to warn the user of this.

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

2 years ago[ARM][AArch64] Optimize pattern for converting a half word byte swap in a 64-bit...
Biplob Mishra [Tue, 5 Apr 2022 11:06:17 +0000 (12:06 +0100)]
[ARM][AArch64] Optimize pattern for converting a half word byte swap in a 64-bit input to a rev16 instruction. Differential Revision: https://reviews.llvm.org/D122643

2 years ago[Tests] Use %clang_cc1 instead of %clang -cc1 in codegen tests (NFC)
Nikita Popov [Tue, 5 Apr 2022 11:21:44 +0000 (13:21 +0200)]
[Tests] Use %clang_cc1 instead of %clang -cc1 in codegen tests (NFC)

2 years ago[Test] Use cc1 interface in more tests (NFC)
Nikita Popov [Tue, 5 Apr 2022 10:46:45 +0000 (12:46 +0200)]
[Test] Use cc1 interface in more tests (NFC)

There doesn't seem to be any particular reason why these tests use
the driver interface rather than the cc1 interface, which is
typically used in CodeGen tests.

2 years ago[LV] Add vector.body block to parent loop during skeleton creation.
Florian Hahn [Tue, 5 Apr 2022 10:43:56 +0000 (11:43 +0100)]
[LV] Add vector.body block to parent loop during skeleton creation.

When creating induction resume values, SCEV queries may rely on
LoopInfo. Make sure vector.body gets added to the loop of the pre-header
during skeleton construction.

%vector.body will be moved to the vector preheader during VPlan
execution.

Fixes #54745.

2 years ago[clang][extract-api] Undefining macros should not result in a crash
Daniel Grumberg [Mon, 4 Apr 2022 17:53:51 +0000 (18:53 +0100)]
[clang][extract-api] Undefining macros should not result in a crash

This fixes the situation where a undefining a not previously defined
macro resulted in a crash. Before trying to remove a definition from
PendingMacros we first check to see if the macro did indeed have a
previous definition.

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

2 years agoNew regression test against expandMemCpyAsLoop utility
Evgeniy Brevnov [Wed, 26 Jan 2022 13:29:08 +0000 (20:29 +0700)]
New regression test against expandMemCpyAsLoop utility

Unit test for functionality going to be added by D118441

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

2 years ago[InstCombine] Add PR22303 test case
Simon Pilgrim [Tue, 5 Apr 2022 10:08:31 +0000 (11:08 +0100)]
[InstCombine] Add PR22303 test case

2 years ago[Docs] Update opaque pointers docs (NFC)
Nikita Popov [Tue, 5 Apr 2022 10:09:10 +0000 (12:09 +0200)]
[Docs] Update opaque pointers docs (NFC)

Point people to the cc1 instead of the mllvm flag, as the mllvm
flag will stop working for clang usage at some point.

Update transition state to mention that support in Clang/LLVM is
complete, and only the default switch is pending.

2 years ago[AArch64] Make PMMIR_EL1 read-only.
Simon Tatham [Tue, 5 Apr 2022 10:09:51 +0000 (11:09 +0100)]
[AArch64] Make PMMIR_EL1 read-only.

The Arm architecture reference manual (ARM DDI 0487H.a section
D13.5.12) lists every field in the register as RO, and does not list
an MSR instruction that writes it. So we should be defining it as an
ROSysReg, not an RWSysReg.

Reviewed By: vhscampos

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

2 years ago[Test] Use cc1 instead of mllvm -opaque-pointers option (NFC)
Nikita Popov [Tue, 5 Apr 2022 10:04:48 +0000 (12:04 +0200)]
[Test] Use cc1 instead of mllvm -opaque-pointers option (NFC)

2 years ago[LLVMContext] Replace enableOpaquePointers() with setOpaquePointers()
Nikita Popov [Tue, 5 Apr 2022 09:36:06 +0000 (11:36 +0200)]
[LLVMContext] Replace enableOpaquePointers() with setOpaquePointers()

This allows both explicitly enabling and explicitly disabling
opaque pointers, in anticipation of the default switching at some
point.

This also slightly changes the rules by allowing calls if either
the opaque pointer mode has not yet been set (explicitly or
implicitly) or if the value remains unchanged.

2 years agoRemove libc++ test from clang lib.
Benjamin Kramer [Tue, 5 Apr 2022 09:33:55 +0000 (11:33 +0200)]
Remove libc++ test from clang lib.

This was added in 3ba8548c8e04bb301c4243887362c54bfbd4af8b

2 years ago[CodeGen] Avoid unnecessary ConstantExpr cast
Nikita Popov [Tue, 5 Apr 2022 09:18:33 +0000 (11:18 +0200)]
[CodeGen] Avoid unnecessary ConstantExpr cast

With opaque pointers, this is not necessarily a ConstantExpr. And
we don't need one here either, just Constant is sufficient.

2 years ago[mlir] Update BUILD.bazel.
Alexander Belyaev [Tue, 5 Apr 2022 09:25:29 +0000 (11:25 +0200)]
[mlir] Update BUILD.bazel.

2 years agoRemove top-level using directives from Transforms/IPO headers
Pavel Labath [Tue, 15 Mar 2022 13:20:44 +0000 (14:20 +0100)]
Remove top-level using directives from Transforms/IPO headers

These directives pollute the namespace of all files which include the
header.

2 years ago[lldb] Avoid duplicate vdso modules when opening core files
Pavel Labath [Tue, 29 Mar 2022 08:47:32 +0000 (10:47 +0200)]
[lldb] Avoid duplicate vdso modules when opening core files

When opening core files (and also in some other situations) we could end
up with two vdso modules. This could happen because the vdso module is
very special, and over the years, we have accumulated various ways to
load it.

In D10800, we added one mechanism for loading it, which took the form of
a generic load-from-memory capability. Unfortunately loading an elf file
from memory is not possible (because the loader never loads the entire
file), and our attempts to do so were causing crashes. So, in D34352, we
partially reverted D10800 and implemented a custom mechanism specific to
the vdso.

Unfortunately, enough of D10800 remained such that, under the right
circumstances, it could end up loading a second (non-functional) copy of
the vdso module. This happened when the process plugin did not support
the extended MemoryRegionInfo query (added in D22219, to workaround a
different bug), which meant that the loader plugin was not able to
recognise that the linux-vdso.so.1 module (this is how the loader calls
it) is in fact the same as the [vdso] module (the name used in
/proc/$PID/maps) we loaded before. This typically happened in a core
file, as they don't store this kind of information.

This patch fixes the issue by completing the revert of D10800 -- the
memory loading code is removed completely. It also reduces the scope of
the hackaround introduced in D22219 -- it isn't completely sound and is
only relevant for fairly old (but still supported) versions of android.

I added the memory loading logic to the wasm dynamic loader, which has
since appeared and is relying on this feature (it even has a test). As
far as I can tell loading wasm modules from memory is possible and
reliable. MachO memory loading is not affected by this patch, as it uses
a completely different code path.

Since the scenarios/patches I described came without test cases, I have
created two new gdb-client tests cases for them. They're not
particularly readable, but right now, this is the best way we can
simulate the behavior (bugs) of a particular dynamic linker.

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

2 years ago[lldb/linux] Handle main thread exits
Pavel Labath [Wed, 30 Mar 2022 09:40:34 +0000 (11:40 +0200)]
[lldb/linux] Handle main thread exits

This patch handles the situation where the main thread exits (through
the SYS_exit syscall). In this case, the process as a whole continues
running until all of the other threads exit, or one of them issues an
exit_group syscall.

The patch consists of two changes:
- a moderate redesign of the handling of thread exit (WIFEXITED) events.
  Previously, we were removing (forgetting) a thread once we received
  the WIFEXITED (or WIFSIGNALED) event. This was problematic for the
  main thread, since the main thread WIFEXITED event (which is better thought
  of as a process-wide event) gets reported only after the entire process
  exits. This resulted in deadlocks, where we were waiting for the
  process to stop (because we still considered the main thread "live").

  This patch changes the logic such that the main thread is removed as
  soon as its PTRACE_EVENT_EXIT (the pre-exit) event is received. At
  this point we can consider the thread gone (for most purposes). As a
  corrolary, I needed to add special logic to catch process-wide exit
  events in the cases where we don't have the main thread around.

- The second part of the patch is the removal of the assumptions that
  the main thread is always available. This generally meant replacing
  the uses of GetThreadByID(process_id) with GetCurrentThread() in
  various process-wide operations (such as memory reads).

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