platform/upstream/llvm.git
2 years ago[RISCV] Add patterns to MIR sign-extension removal pass.
Mohammed Nurul Hoque [Thu, 20 Jan 2022 01:27:02 +0000 (17:27 -0800)]
[RISCV] Add patterns to MIR sign-extension removal pass.

This patch adds a few instruction patterns that generate sign-extended values or propagate them, adding to the pass introduced in https://reviews.llvm.org/D116397

Reviewed By: craig.topper

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

2 years ago[flang] Accept BOZ literals for some actual arguments
Peter Klausler [Tue, 11 Jan 2022 18:38:26 +0000 (10:38 -0800)]
[flang] Accept BOZ literals for some actual arguments

Consistent with previously documented policy, in which
BOZ literals are accepted in non-standard-conforming circumstances
where they can be converted to an unambiguous known numeric type,
allow BOZ literals to be passed as an actual argument in a reference
to a procedure whose explicit interface has a corresponding dummy
argument with a numeric type to which the BOZ literal may be
converted.  Improve error messages associated with BOZ literal
actual arguments, too: don't emit multiple errors.

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

2 years ago[flang] Improve error message (initialized variable in pure subprogram)
Peter Klausler [Tue, 11 Jan 2022 19:01:12 +0000 (11:01 -0800)]
[flang] Improve error message (initialized variable in pure subprogram)

When variable with the SAVE attribute appears in a pure subprogram,
emit a more specialized error message if the SAVE attribute was acquired
from static initialization.

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

2 years ago[OpenMP] Expand short verisions of OpenMP offloading triples
Joseph Huber [Wed, 19 Jan 2022 19:52:08 +0000 (14:52 -0500)]
[OpenMP] Expand short verisions of OpenMP offloading triples

The OpenMP offloading libraries are built with fixed triples and linked
in during compile time. This would cause un-helpful errors if the user
passed in the wrong expansion of the triple used for the bitcode
library. because we only support these triples for OpenMP offloading we
can normalize them to the full verion used in the bitcode library.

Reviewed By: jdoerfert, JonChesterfield

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

2 years ago[docs] Fix typo in the example code in ProgrammersManual.
Hsiangkai Wang [Tue, 18 Jan 2022 07:44:27 +0000 (07:44 +0000)]
[docs] Fix typo in the example code in ProgrammersManual.

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

2 years ago[docs] Put define DEBUG_TYPE after include directives.
Hsiangkai Wang [Tue, 18 Jan 2022 11:51:53 +0000 (11:51 +0000)]
[docs] Put define DEBUG_TYPE after include directives.

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

2 years ago[LoopPeeling] Fix stale comments. NFC
Craig Topper [Thu, 20 Jan 2022 00:59:45 +0000 (16:59 -0800)]
[LoopPeeling] Fix stale comments. NFC

These comments were not updated when PeelingPreferences split from
UnrollingPreferences.

2 years agoRe-land [CodeView] Add full repro to LF_BUILDINFO record
Alexandre Ganea [Thu, 20 Jan 2022 00:44:18 +0000 (19:44 -0500)]
Re-land [CodeView] Add full repro to LF_BUILDINFO record

This patch writes the full -cc1 command into the resulting .OBJ, like MSVC does. This allows for external tools (Recode, Live++) to rebuild a source file without any external dependency but the .OBJ itself (other than the compiler) and without knowledge of the build system.

The LF_BUILDINFO record stores a full path to the compiler, the PWD (CWD at program startup), a relative or absolute path to the source, and the full CC1 command line. The stored command line is self-standing (does not depend on the environment). In the same way, MSVC doesn't exactly store the provided command-line, but an expanded version (a somehow equivalent of CC1) which is also self-standing.

For more information see PR36198 and D43002.

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

2 years ago[DWARF][FIX] Try not to crash for nvptx with missing debug information
Johannes Doerfert [Wed, 27 Oct 2021 22:00:41 +0000 (17:00 -0500)]
[DWARF][FIX] Try not to crash for nvptx with missing debug information

This prevents crashes in the OpenMP offload pipeline as not everything
is properly annotated with debug information, e.g., the runtimes we link
in. While we might want to have them annotated, it seems to be generally
useful to gracefully handle missing debug info rather than crashing.

TODO: A test is missing and can hopefully be distilled prior to landing.

This fixes #51079.

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

2 years ago[OpenMP][FIX] Replace ICVs only with values valid at the getter position
Johannes Doerfert [Wed, 19 Jan 2022 21:47:50 +0000 (15:47 -0600)]
[OpenMP][FIX] Replace ICVs only with values valid at the getter position

While we might know the value if an ICV at a getter position it is not
always clear that we can simply use it. Verify the value is valid first
to avoid invalid IR.

Fixes #53300.

2 years ago[lld-macho] Mention string literal deduplication as a difference from ld64
Jez Ng [Thu, 20 Jan 2022 00:30:52 +0000 (16:30 -0800)]
[lld-macho] Mention string literal deduplication as a difference from ld64

Reviewed By: keith

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

2 years ago[libc] Move type definitions to their own self contained header files.
Siva Chandra Reddy [Thu, 13 Jan 2022 23:40:49 +0000 (23:40 +0000)]
[libc] Move type definitions to their own self contained header files.

Reviewed By: michaelrj

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

2 years agoPreserve function argument locations.
Dominik Grewe [Wed, 19 Jan 2022 23:44:43 +0000 (23:44 +0000)]
Preserve function argument locations.

Previously the optional locations of function arguments were dropped in
`parseFunctionArgumentList`. This CL adds another output argument to the
function through which they are now returned. The values are then plumbed
through as an array of optional locations in the various places.

Reviewed By: rriddle

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

2 years ago[mlir] Don't print `// no predecessors` on entry blocks
River Riddle [Wed, 19 Jan 2022 20:18:30 +0000 (12:18 -0800)]
[mlir] Don't print `// no predecessors` on entry blocks

Entry blocks can never have predecessors, so this is unnecessary.

Fixes #53287

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

2 years ago[ORC] Fix typo in comment.
Lang Hames [Wed, 19 Jan 2022 23:54:56 +0000 (10:54 +1100)]
[ORC] Fix typo in comment.

2 years agoFix crash in MLIR opaque attribute parser
Mehdi Amini [Wed, 19 Jan 2022 19:44:13 +0000 (19:44 +0000)]
Fix crash in MLIR opaque attribute parser

An assertion is triggered when the dialect is malformed.

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

2 years agoFix modules build by moving implementation into .cpp file
Adrian Prantl [Wed, 19 Jan 2022 23:33:59 +0000 (15:33 -0800)]
Fix modules build by moving implementation into .cpp file

2 years ago[AMDGPU][NFC] Add autogenerated tests for vgpr-tuple-allocation.ll
Konstantina [Wed, 19 Jan 2022 16:57:09 +0000 (08:57 -0800)]
[AMDGPU][NFC] Add autogenerated tests for vgpr-tuple-allocation.ll

Reviewed By: arsenm

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

2 years ago[clang-tidy] Use literal block instead of code block (NFC)
Richard [Wed, 19 Jan 2022 22:04:11 +0000 (15:04 -0700)]
[clang-tidy] Use literal block instead of code block (NFC)

I used a C++ code block in check documentation to show example
output from clang-tidy, but since the example output isn't
kosher C++, sphinx didn't like that when it went to syntax
highlight the block.  So switch to a literal block instead
and forego any highlighting.

Fixes build error
<https://lab.llvm.org/buildbot/#/builders/115/builds/21145>

2 years ago[lldb] Fix LLDB_FULL_VERSION_STRING
Jonas Devlieghere [Wed, 19 Jan 2022 22:19:37 +0000 (14:19 -0800)]
[lldb] Fix LLDB_FULL_VERSION_STRING

Currently LLDB_FULL_VERSION_STRING is set to "LLDB_VERSION_STRING"
rather than the content of the CMake variable with that name.

2 years ago[libc] Add a naming rule for global constants.
Siva Chandra Reddy [Wed, 19 Jan 2022 08:33:05 +0000 (08:33 +0000)]
[libc] Add a naming rule for global constants.

Reviewed By: michaelrj

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

2 years ago[openmp] Always pass valid triple to openmp-targets when using newRTL
Jon Chesterfield [Wed, 19 Jan 2022 22:07:22 +0000 (22:07 +0000)]
[openmp] Always pass valid triple to openmp-targets when using newRTL

Previously, we sometimes pass fopenmp-targets=nvptx64-nvidia-cuda-newRTL

Reviewed By: jhuber6

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

2 years ago[cmake] Move HandleOutOfTreeLLVM to common cmake utils
John Ericson [Tue, 18 Jan 2022 22:58:31 +0000 (22:58 +0000)]
[cmake] Move HandleOutOfTreeLLVM to common cmake utils

This is better than libunwind and libcxxabi fishing it out of libcxx's
module directory.

It is done in prepartion for a better version of D117537 which deduplicates
CMake logic instead of just renaming to avoid a name clash.

Reviewed By: phosek, #libunwind, #libc_abi, Ericson2314

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

2 years ago[RISCV] Fix incomplete asm statement parsing
Luís Marques [Wed, 19 Jan 2022 21:55:35 +0000 (21:55 +0000)]
[RISCV] Fix incomplete asm statement parsing

For instructions without operands, the final `AsmToken::EndOfStatement`
wasn't being consumed. In the context of inline assembly, the resulting
empty statements would cause extraneous empty lines to be emitted. Fix
the issue by consuming the `EndOfStatement` token.

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

2 years ago[OpenMPOpt] Use SetVector to store list of kernels.
Eli Friedman [Wed, 19 Jan 2022 21:53:47 +0000 (13:53 -0800)]
[OpenMPOpt] Use SetVector to store list of kernels.

Fixes test failures on reverse-iteration buildbot.

2 years ago[docs][lli] Fix lli rst docs formatting
Luís Marques [Wed, 19 Jan 2022 21:53:43 +0000 (21:53 +0000)]
[docs][lli] Fix lli rst docs formatting

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

2 years ago[lld-macho] Silence XAR deprecation warning
Keith Smiley [Wed, 19 Jan 2022 21:34:04 +0000 (13:34 -0800)]
[lld-macho] Silence XAR deprecation warning

If you're building this on macOS 12.x+ this produces a deprecation
warning. I'm not sure what this means for the bitcode format going
forward, but it seems safe to silence for now.

Do we need to worry about GCC for this?

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

2 years ago[lld-macho] Implement -noall_load
Keith Smiley [Wed, 19 Jan 2022 01:17:28 +0000 (17:17 -0800)]
[lld-macho] Implement -noall_load

This flag is the default, so in ld64 it is not implemented, but it can
be useful to negate previous -all_load arguments. Specifically if your
build system has some global linker flags, that you may want to negate
for specific links. We use something like this today to make sure some
C++ symbols are automatically discovered for all links, which passing
-all_load hides.

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

2 years agoChange elided large constant syntax to make it more explicit
Mehdi Amini [Wed, 19 Jan 2022 19:57:59 +0000 (19:57 +0000)]
Change elided large constant syntax to make it more explicit

When the printer is requested to elide large constant, we emit an opaque
attribute instead. This patch fills the dialect name with
"elided_large_const" instead of "_" to remove some user confusion when
they later try to consume it.

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

2 years ago[ELF] Fix split-stack caller with hidden non-split-stack callee
Fangrui Song [Wed, 19 Jan 2022 20:25:01 +0000 (12:25 -0800)]
[ELF] Fix split-stack caller with hidden non-split-stack callee

Fix a regression after aabe901d57d6df4cd2786163359a7b2a7aae8c32 (`[ELF] Remove
one redundant computeBinding`): isLocal() does not indicate that the symbol is
originally local. For simplicity, just drop this optimization.

2 years ago[mlir] Configure mlir so that it can be directly included in a parent cmakelists.txt
Stella Stamenova [Wed, 19 Jan 2022 20:02:22 +0000 (12:02 -0800)]
[mlir] Configure mlir so that it can be directly included in a parent cmakelists.txt

The goal is to allow a project to directly include the `CMakeLists.txt` of mlir via something such as `add_directory`. This currently doesn't work because the exported targets then end up being imported in the same top-level project and `cmake` is not happy. LLVM works around this by guarding the exports based on the existence of the `LLVMSupport` library. This change does the same using `MLIRSupport`. In our experience, no targets need to be added to the export in the case.

If there's a preferred way of doing this or a better lib to use as the main target to check for, please let me know.

Reviewed By: stellaraccident

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

2 years agoFix build break introduced by D117147
Mircea Trofin [Wed, 19 Jan 2022 19:33:20 +0000 (11:33 -0800)]
Fix build break introduced by D117147

2 years ago[libcxx][test] Portably test that `{w,}format_context` is a specialization of `basic_...
Casey Carter [Wed, 29 Dec 2021 23:56:24 +0000 (15:56 -0800)]
[libcxx][test] Portably test that `{w,}format_context` is a specialization of `basic_format_context`

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

2 years ago[clang-tidy] Narrow cppguidelines-macro-usage to actual constants
Richard [Wed, 29 Dec 2021 23:49:36 +0000 (16:49 -0700)]
[clang-tidy] Narrow cppguidelines-macro-usage to actual constants

Previously, any macro that didn't look like a varargs macro
or a function style macro was reported with a warning that
it should be replaced with a constexpr const declaration.
This is only reasonable when the macro body contains constants
and not expansions like ",", "[[noreturn]]", "__declspec(xxx)",
etc.

So instead of always issuing a warning about every macro that
doesn't look like a varargs or function style macro, examine the
tokens in the macro and only warn about the macro if it contains
only comment and constant tokens.

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

Fixes #39945

2 years ago[mlir][sparse] Simplifying assertions in fromCOO
wren romano [Tue, 18 Jan 2022 19:39:54 +0000 (11:39 -0800)]
[mlir][sparse] Simplifying assertions in fromCOO

Hoisting invariant assertions to the top

Reviewed By: aartbik

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

2 years ago[tosa][mlir] Lowering for dynamic shapes in the reduce_x ops in tosa-to-linalg
natashaknk [Wed, 19 Jan 2022 19:06:00 +0000 (11:06 -0800)]
[tosa][mlir] Lowering for dynamic shapes in the reduce_x ops in tosa-to-linalg

Reviewed By: rsuderman

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

2 years ago[openmp] Unconditionally set march commandline argument
Joseph Huber [Wed, 19 Jan 2022 19:13:54 +0000 (19:13 +0000)]
[openmp] Unconditionally set march commandline argument

Extracted from D117246. This reflects the march value used by the
compile back into the toolchain arguments, letting downstream processes
such as LTO rely on it being present. Subsequent patches should also be able
to remove the two other calls to checkSystemForAMDGPU.

Reviewed By: jonchesterfield

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

2 years ago[BOLT] Remove unreachable uncond branch after return
Vladislav Khmelevsky [Wed, 19 Jan 2022 19:06:06 +0000 (22:06 +0300)]
[BOLT] Remove unreachable uncond branch after return

This patch fixes the removal of unreachable uncondtional branch located
after return instruction.

Vladislav Khmelevsky,
Advanced Software Technology Lab, Huawei

Reviewed By: Amir

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

2 years ago[MLGO] ML Regalloc Eviction Advisor
Mircea Trofin [Wed, 22 Dec 2021 20:46:06 +0000 (12:46 -0800)]
[MLGO] ML Regalloc Eviction Advisor

The bulk of the implementation is common between 'release' mode (==AOT-ed
model) and 'development' mode (for training), the main difference is
that in development mode, we may also log features (for training logs),
inject scoring information (currently after the Virtual Register
Rewriter) and then produce the log file.

This patch also introduces the score injection pass, 'Register
Allocation Pass Scoring', which is trivially just logging the score in
development mode.

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

2 years ago[PartialInline] Bail out on asm-goto/callbr
Wenlei He [Mon, 17 Jan 2022 19:59:37 +0000 (11:59 -0800)]
[PartialInline] Bail out on asm-goto/callbr

Fixing ICE when partial inline tries to deal with blockaddress uses of function which is typical for asm-goto/callbr. We ran into this with PGO multi-region partial inline.

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

2 years ago[mlir][spirv] Add math.fma lowering to spirv
Thomas Raoux [Wed, 19 Jan 2022 18:32:16 +0000 (10:32 -0800)]
[mlir][spirv] Add math.fma lowering to spirv

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

2 years ago[RISCV] Obey -riscv-v-fixed-length-vector-elen-max when lowering mask BUILD_VECTORs.
Craig Topper [Wed, 19 Jan 2022 18:31:56 +0000 (10:31 -0800)]
[RISCV] Obey -riscv-v-fixed-length-vector-elen-max when lowering mask BUILD_VECTORs.

We may not be allowed to use vXiXLen vectors. Consult ELEN to
determine what is allowed. This will become even more important
when Zve32 is added.

Reviewed By: frasercrmck, arcbbb

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

2 years ago[dsymutil] Print the swift interface modification time in warning
Jonas Devlieghere [Wed, 19 Jan 2022 17:57:08 +0000 (09:57 -0800)]
[dsymutil] Print the swift interface modification time in warning

The warning was printing the timestamp from the debug map twice rather
than both the file system modification time and debug map modification
time.

rdar://86036385

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

2 years ago[libc] improve error message for unsupported target platforms
Yannic Bonenberger [Wed, 19 Jan 2022 18:34:03 +0000 (10:34 -0800)]
[libc] improve error message for unsupported target platforms

Reviewed By: michaelrj

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

2 years agoFix broken comment in InstrProfData.inc
Ellis Hoag [Wed, 19 Jan 2022 18:36:49 +0000 (10:36 -0800)]
Fix broken comment in InstrProfData.inc

This comment was introduced in https://reviews.llvm.org/D117631

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

2 years ago[clang-tidy][NFC] replace some redundant std::string creations
Nathan James [Wed, 19 Jan 2022 18:36:35 +0000 (18:36 +0000)]
[clang-tidy][NFC] replace some redundant std::string creations

2 years ago[flang] Prevent any non constant result extent to be inlined on caller side
Jean Perier [Wed, 19 Jan 2022 18:12:12 +0000 (19:12 +0100)]
[flang] Prevent any non constant result extent to be inlined on caller side

UBOUND, SIZE, and SHAPE folding was still creating expressions that are
invalid on the caller side without the call expression context.
A previous patch intended to deal with this situation (https://reviews.llvm.org/D116933)
but it assumed the return expression would be a descriptor inquiry to
the result symbol, which is not the case if the extent expression is
"scope invariant" inside the called subroutine (e.g., referring to
intent(in) dummy arguments). Simply prevent folding from inlining non
constant extent expression on the caller side.

Folding could be later improved by having ad-hoc folding for UBOUND, SIZE, and
SHAPE on function references where it could try replacing the dummy symbols
by the actual expression, but this is left as a possible later improvement.

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

2 years ago[lld-macho] Add --start-lib --end-lib
Fangrui Song [Wed, 19 Jan 2022 18:14:49 +0000 (10:14 -0800)]
[lld-macho] Add --start-lib --end-lib

In ld.lld, when an ObjFile/BitcodeFile is read in --start-lib state, the file is
given archive semantics. --end-lib closes the previous --start-lib. A build
system can use this feature as an alternative to archives. This patch ports
the feature to lld-macho.

--start-lib and --end-lib are positional, unlike usual ld64 options.
I think the slight drawback does not matter as (a) reusing option names
make build systems convenient (b) `--start-lib a.o b.o --end-lib` conveys more
information than an alternative design: `-objlib a.o -objlib b.o` because
--start-lib makes it clear which objects are in the same conceptual archive.
This provides flexibility (c) `-objlib`/`-filelist` interaction may be weird.

Close https://github.com/llvm/llvm-project/issues/52931

Reviewed By: #lld-macho, Jez Ng, oontvoo

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

2 years ago[clang] support relative roots to vfs overlays
Richard Howell [Wed, 19 Jan 2022 18:12:32 +0000 (10:12 -0800)]
[clang] support relative roots to vfs overlays

This diff adds support for relative roots to VFS overlays. The directory root
will be made absolute from the current working directory and will be used to
determine the path style to use. This supports the use of VFS overlays with
remote build systems that might use a different working directory for each
compilation.

Reviewed By: benlangmuir

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

2 years ago[InstrProf] Restore InstrProfData.inc to fix Fuchsia builds
Ellis Hoag [Wed, 19 Jan 2022 18:09:56 +0000 (10:09 -0800)]
[InstrProf] Restore InstrProfData.inc to fix Fuchsia builds

https://reviews.llvm.org/D116179 introduced some changes to
`InstrProfData.inc` which broke some downstream builds. This commit
reverts those changes since they only changes two field names.

Reviewed By: phosek

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

2 years ago[DebugInfod] Prefix debuginfod cache directory
Petr Hosek [Wed, 19 Jan 2022 18:08:17 +0000 (10:08 -0800)]
[DebugInfod] Prefix debuginfod cache directory

This prevents the debuginfod client from dumping files directly into the
default cache directory (e.g., ~/.cache). Instead, these files are
placed in a subdirectory (e.g., ~/.cache/llvm-debuginfod/client).
Behavior is unaffected if the cache directory is provided by the
DEBUGINFO_CACHE_PATH environment variable.

Patch By: mysterymath

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

2 years ago[flang] Intrinsic assignment of distinct but "same" derived types
Peter Klausler [Mon, 10 Jan 2022 23:59:12 +0000 (15:59 -0800)]
[flang] Intrinsic assignment of distinct but "same" derived types

Subclause 7.5.2.4 lists conditions under which two distinct derived
types are to be considered the same type for purposes of argument
association, assignment, and so on.  These conditions are implemented
in evaluate::IsTkCompatibleWith(), but assignment semantics doesn't
use it for testing for intrinsic assignment compatibility.  Fix that.

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

2 years agoAMDGPU: Account for usage HIP-style dynamic LDS
Yaxun (Sam) Liu [Wed, 19 Jan 2022 17:56:21 +0000 (12:56 -0500)]
AMDGPU: Account for usage HIP-style dynamic LDS

Disable promote alloca to LDS when HIP-style dynamic LDS since the size
is unknown at compile time.

Patch by: Siu Chi Chan

Reviewed by: Matt Arsenault, Yaxun Liu

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

2 years ago[ELF] Allow non-bitcode archive with an empty index
Fangrui Song [Wed, 19 Jan 2022 18:01:53 +0000 (10:01 -0800)]
[ELF] Allow non-bitcode archive with an empty index

When an archive with an empty index contains only bitcode files, it is
handled as a group of lazy (--start-lib) object files. If there is a
non-bitcode file, there will be a diagnostic a la GNU ld.

For some programs, the archive member extraction ratio is high (e.g. for chrome,
79% archive members are extracted according to --print-archive-stats=). Because
symbol interning is cached for ObjFile::parseLazy but not for ArchiveFile,
parsing an archive as a group of --start-lib object files may be faster.

If the linker speculatively creates section representations for archive members,
the archive index will not be used.

If we take the above view, the archive index is essentially useless. If a user
wants a fast build without using --start-lib, they may just build thin archives
without index (`ar rcS --thin`).

Therefore, I suggest that we no longer treat the code as a hack, instead as a
supported feature. I believe we will do this anyway if we add parallel symbol
interning (parallel symbol interning for lazy object files is simpler than that
for archives).

Ecosystem issues:

* parseLazy actually has nearly the same behavior as ArchiveFile::parse, but the symbol order may be different.
* users may get addicted to the behavior and build archives not working with GNU ld and gold. I think it is easy to rebuild archives to be compatible.

Reviewed By: ikudrin

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

2 years ago[mlir][Linalg] Add a useLinalgCopy option to Linalg bufferization.
Nicolas Vasilache [Wed, 19 Jan 2022 17:49:06 +0000 (12:49 -0500)]
[mlir][Linalg] Add a useLinalgCopy option to Linalg bufferization.

Benchmarks show that memref::CopyOp is curently up to 200x slower than
tiled and vectorized versions of linalg::Copy.
Add a temporary flag to allow comprehensive bufferize to generate a
linalg::GenericOp that implements a copy until this performance bug is
resolved.

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

2 years agounique_ptrify the ModuleManager's VisitState linked list
David Blaikie [Wed, 19 Jan 2022 17:56:53 +0000 (09:56 -0800)]
unique_ptrify the ModuleManager's VisitState linked list

2 years ago[lldb] Initialize Python exactly once
Jonas Devlieghere [Wed, 19 Jan 2022 17:16:16 +0000 (09:16 -0800)]
[lldb] Initialize Python exactly once

We got a few crash reports that showed LLDB initializing Python on two
separate threads. Make sure Python is initialized exactly once.

rdar://87287005

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

2 years agoPrevent adding module flag amdgpu_hostcall multiple times
Yaxun (Sam) Liu [Wed, 19 Jan 2022 17:19:06 +0000 (12:19 -0500)]
Prevent adding module flag amdgpu_hostcall multiple times

HIP program with printf call fails to compile with -fsanitize=address
option, because of appending module flag - amdgpu_hostcall twice, one
for printf and one for sanitize option. This patch fixes that issue.

Patch by: Praveen Velliengiri

Reviewed by: Yaxun Liu, Roman Lebedev

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

2 years ago[CMake] Add explicit return to GetErrcMessages test program
John Brawn [Wed, 19 Jan 2022 17:05:14 +0000 (17:05 +0000)]
[CMake] Add explicit return to GetErrcMessages test program

2 years ago[DAG] SelectionDAG::computeKnownBits - add mul(x,x) self-multiply handling (PR48683)
Simon Pilgrim [Wed, 19 Jan 2022 17:16:31 +0000 (17:16 +0000)]
[DAG] SelectionDAG::computeKnownBits - add mul(x,x) self-multiply handling (PR48683)

Pass the SelfMultiply flag to KnownBits::mul() - added at D108992

https://alive2.llvm.org/ce/z/NN_eaR

2 years ago[X86] Add mul(x,x) self-multiply known bits test coverage (PR48683)
Simon Pilgrim [Wed, 19 Jan 2022 16:36:51 +0000 (16:36 +0000)]
[X86] Add mul(x,x) self-multiply known bits test coverage (PR48683)

D108992 added self-multiply handling to KnownBits::mul but we don't use it yet..

2 years ago[RISCV] Test expected inst opcode in sink-splat test
Fraser Cormack [Wed, 19 Jan 2022 17:18:24 +0000 (17:18 +0000)]
[RISCV] Test expected inst opcode in sink-splat test

The function's name suggests it should be testing 'sub' rather than
'add'. We test 'add' in an earlier test so we're not losing any coverage
here.

2 years ago[AIX] identify big archive magic as archive.
zhijian [Wed, 19 Jan 2022 17:18:45 +0000 (12:18 -0500)]
[AIX] identify big archive magic as archive.
Summary:

  identify big archive magic as archive.

Reviewers: Hubert Tong
Differential Revision: https://reviews.llvm.org/D117511

2 years ago[mlir][cmake] Use `GNUInstallDirs` to support custom installation dirs
John Ericson [Tue, 18 Jan 2022 07:03:10 +0000 (07:03 +0000)]
[mlir][cmake] Use `GNUInstallDirs` to support custom installation dirs

I am breaking apart D99484 so the cause of build failures is easier to
understand.

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

2 years ago[mlir] Rework subclass construction in PybindAdaptors.h
Alex Zinenko [Wed, 19 Jan 2022 11:21:42 +0000 (12:21 +0100)]
[mlir] Rework subclass construction in PybindAdaptors.h

The constructor function was being defined without indicating its "__init__"
name, which made it interpret it as a regular fuction rather than a
constructor. When overload resolution failed, Pybind would attempt to print the
arguments actually passed to the function, including "self", which is not
initialized since the constructor couldn't be called. This would result in
"__repr__" being called with "self" referencing an uninitialized MLIR C API
object, which in turn would cause undefined behavior when attempting to print
in C++. Even if the correct name is provided, the mechanism used by
PybindAdaptors.h to bind constructors directly as "__init__" functions taking
"self" is deprecated by Pybind. The new mechanism does not seem to have access
to a fully-constructed "self" object (i.e., the constructor in C++ takes a
`pybind11::detail::value_and_holder` that cannot be forwarded back to Python).

Instead, redefine "__new__" to perform the required checks (there are no
additional initialization needed for attributes and types as they are all
wrappers around a C++ pointer). "__new__" can call its equivalent on a
superclass without needing "self".

Bump pybind11 dependency to 3.8.0, which is the first version that allows one
to redefine "__new__".

Reviewed By: stellaraccident

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

2 years ago[LLVM-C] Use NameLen in LLVMGetNamedGlobalAlias
Jakob Bornecrantz [Wed, 19 Jan 2022 16:48:28 +0000 (08:48 -0800)]
[LLVM-C] Use NameLen in LLVMGetNamedGlobalAlias

I tried to look over the file and didn't see any other non-use of *Len variables.

Reviewed By: deadalnix

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

2 years ago[PowerPC] Fix issue with strict float to int conversion.
Stefan Pintilie [Wed, 19 Jan 2022 15:33:18 +0000 (09:33 -0600)]
[PowerPC] Fix issue with strict float to int conversion.

When doing the float to int conversion the strict conversion also needs to
retun a chain. This patch fixes that.

Reviewed By: nemanjai, #powerpc, qiucf

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

2 years ago[gn build] port c22329972f02 (lldb REPL/Clang)
Nico Weber [Wed, 19 Jan 2022 16:31:00 +0000 (11:31 -0500)]
[gn build] port c22329972f02 (lldb REPL/Clang)

Fixes `lldb-shell :: REPL/Basic.test` in the gn build, making
check-lldb pass (on Linux) again.

2 years ago[OMPIRBuilder] Add support for simd (loop) directive.
Arnamoy Bhattacharyya [Wed, 19 Jan 2022 16:18:35 +0000 (11:18 -0500)]
[OMPIRBuilder] Add support for simd (loop) directive.

This patch adds OMPIRBuilder support for the simd directive (without any clause).  This will be a first step towards lowering simd directive in LLVM_Flang.  The patch uses existing CanonicalLoop infrastructure of IRBuilder to add the support.  Also adds necessary code to add llvm.access.group and llvm.loop metadata wherever needed.

Reviewed By: Meinersbur

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

2 years ago[clang][dataflow] Add a transfer function for conditional operator
Stanislav Gatev [Wed, 19 Jan 2022 13:56:21 +0000 (13:56 +0000)]
[clang][dataflow] Add a transfer function for conditional operator

This is part of the implementation of the dataflow analysis framework.
See "[RFC] A dataflow analysis framework for Clang AST" on cfe-dev.

Reviewed-by: xazax.hun
Differential Revision: https://reviews.llvm.org/D117667

2 years ago[gn build] link lldb-vscode against ws2_32.lib
Nico Weber [Wed, 19 Jan 2022 16:06:01 +0000 (11:06 -0500)]
[gn build] link lldb-vscode against ws2_32.lib

Necessary after aaa50e54e60fd6c4.

2 years agoFix the use of -fno-approx-func along with -Ofast or -ffast-math
Masoud Ataei [Wed, 19 Jan 2022 16:05:08 +0000 (08:05 -0800)]
Fix the use of -fno-approx-func along with -Ofast or -ffast-math

Fix how -fapprox-func interact correctly with the other floating point options.
Reported bug Number 52565: https://bugs.llvm.org/show_bug.cgi?id=52565

Differential: https://reviews.llvm.org/D114564
Reviewer: @andrew.w.kaylor

2 years ago[lit] Fix compatibility with upstream gtest
Lukáš Zaoral [Wed, 19 Jan 2022 16:01:18 +0000 (08:01 -0800)]
[lit] Fix compatibility with upstream gtest

Upstream gtest now prints 'Running main() from FILE' instead of
plain 'Running main() from gtest_main.cc'. Thus, all such tests
ended-up being mistakenly marked as UNRESOLVED.

Patch by @lzaoral

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

2 years ago[openmp][amdgpu] Remove xfail from test using declare target variable
Jon Chesterfield [Wed, 19 Jan 2022 15:55:09 +0000 (15:55 +0000)]
[openmp][amdgpu] Remove xfail from test using declare target variable

2 years ago[gn build] port b2a162e63bd73 (liblldb.dll)
Nico Weber [Wed, 19 Jan 2022 15:49:13 +0000 (10:49 -0500)]
[gn build] port b2a162e63bd73 (liblldb.dll)

This requires making liblldb a dll on Windows.
Things still work with a static lib on non-Windows, so keep it a
static lib there for now.

2 years ago[openmp][amdgpu] Disable tests on old runtime, enable tests on new one
Jon Chesterfield [Wed, 19 Jan 2022 15:49:47 +0000 (15:49 +0000)]
[openmp][amdgpu] Disable tests on old runtime, enable tests on new one

2 years agoAMDGPU/GlobalISel: Fix introducing f16 fmed3 for gfx8
Matt Arsenault [Wed, 19 Jan 2022 01:46:51 +0000 (20:46 -0500)]
AMDGPU/GlobalISel: Fix introducing f16 fmed3 for gfx8

2 years ago[lldb] Make StatsDuration thread-safe
Pavel Labath [Mon, 17 Jan 2022 14:04:30 +0000 (15:04 +0100)]
[lldb] Make StatsDuration thread-safe

std::chrono::duration types are not thread-safe, and they cannot be
concurrently updated from multiple threads. Currently, we were doing
such a thing (only) in the DWARF indexing code
(DWARFUnit::ExtractDIEsRWLocked), but I think it can easily happen that
someone else tries to update another statistic like this without
bothering to check for thread safety.

This patch changes the StatsDuration type from a simple typedef into a
class in its own right. The class stores the duration internally as
std::atomic<uint64_t> (so it can be updated atomically), but presents it
to its users as the usual chrono type (duration<float>).

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

2 years ago[openmp][amdgpu] Temporarily disable tests on old runtime
Jon Chesterfield [Wed, 19 Jan 2022 15:35:22 +0000 (15:35 +0000)]
[openmp][amdgpu] Temporarily disable tests on old runtime

2 years ago[LangRef] Mangle all vector operands in insert/extract intrinsics
Fraser Cormack [Wed, 19 Jan 2022 14:22:11 +0000 (14:22 +0000)]
[LangRef] Mangle all vector operands in insert/extract intrinsics

This better matches the canonical mangling of these intrinsics.

Reviewed By: peterwaller-arm

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

2 years agoAMDGPU/GlobalISel: Fix legalize failure on i65 ctpop
Matt Arsenault [Wed, 19 Jan 2022 00:31:34 +0000 (19:31 -0500)]
AMDGPU/GlobalISel: Fix legalize failure on i65 ctpop

2 years ago[AMDGPU] Simplify SILoadStoreOptimizer::getSubRegIdxs. NFC.
Jay Foad [Wed, 19 Jan 2022 15:18:42 +0000 (15:18 +0000)]
[AMDGPU] Simplify SILoadStoreOptimizer::getSubRegIdxs. NFC.

2 years agoGlobalISel: Fix assert on unmerge to different element of casted vector
Matt Arsenault [Thu, 13 Jan 2022 02:13:15 +0000 (21:13 -0500)]
GlobalISel: Fix assert on unmerge to different element of casted vector

This was failing if a G_UNMERGE_VALUES produced a different element
type than the cast result type.

2 years agoAMDGPU/GlobalISel: Introduce pseudo to copy sp in call sequences
Matt Arsenault [Wed, 12 Jan 2022 14:05:12 +0000 (09:05 -0500)]
AMDGPU/GlobalISel: Introduce pseudo to copy sp in call sequences

Arbitrary stack pointers are accessed using MUBUF instructions with
the voffset field, which is interpreted as the swizzled address. We
want to fold fold into the MUBUF form to use the SP in the SGPR
offset, and previously we were special casing the interpretation of
the pointer value if the access memory operand said it was relative to
the stack pointer.

690f5b7a0128a210093e9b217932743ad35b5c5a removed this check, and moved
the DAG path to special casing copies from SGPRs. This is not an
entirely sound approach, since it's still changing the interpretation
of pointer values based the context.

Introduce a new pseudo which corresponds to the wave-to-vector address
transform. This way the memory instruction has consistent semantics
where the incoming pointer is always interpreted as a vector address,
and we're not obligated to optimize into the MUBUF offset-only
addressing mode. The DAG should probably have an equivalent pseudo.

This should fix some correctness issues, and folding this into
addressing modes will be a future optimization patch.

2 years ago[clangd] NFC, emit source ranges in selection debug messages.
Haojian Wu [Wed, 19 Jan 2022 14:06:34 +0000 (15:06 +0100)]
[clangd] NFC, emit source ranges in selection debug messages.

It will make the output more versbose, but I found that these are useful
information when debugging selection tree.

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

2 years ago[MemCpyOpt] Test invalid noalias metadata after call slot opt (NFC)
Nikita Popov [Wed, 19 Jan 2022 14:50:32 +0000 (15:50 +0100)]
[MemCpyOpt] Test invalid noalias metadata after call slot opt (NFC)

2 years ago[MemCpyOpt] Add some debug output to call slot optimization (NFC)
Nikita Popov [Wed, 19 Jan 2022 14:41:16 +0000 (15:41 +0100)]
[MemCpyOpt] Add some debug output to call slot optimization (NFC)

2 years ago[LLDB] Adjust compiler-full-path.test for Windows/Arm64
TCWG [Tue, 9 Nov 2021 19:33:07 +0000 (19:33 +0000)]
[LLDB] Adjust compiler-full-path.test for Windows/Arm64

This patch updates compiler-full-path.test to make sure it passes on
Windows Arm64 platform with MSVC.

2 years ago[LoopFlatten] Move it from LPM2 to LPM1
Sjoerd Meijer [Wed, 19 Jan 2022 14:09:59 +0000 (14:09 +0000)]
[LoopFlatten] Move it from LPM2 to LPM1

In D110057 we moved LoopFlatten to a LoopPassManager. This caused a performance
regression for our 64-bit targets (the 32-bit were unaffected), the pass is no
longer triggering for a motivating example. The reason is that the IR is just
very different than expected; we try to match loop statements and particular
uses of induction variables. The easiest is to just move LoopFlatten to a place
in the pipeline where the IR is as expected, which is just before
IndVarSimplify. This means we move it from LPM2 to LPM1, so that it actually
runs just a bit earlier from where it was running before. IndVarSimplify is
responsible for significant rewrites that are difficult to "look through" in
LoopFlatten.

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

2 years agoRecommit "[LoopFlatten] Move it to a LoopPassManager"
Sjoerd Meijer [Wed, 19 Jan 2022 14:06:51 +0000 (14:06 +0000)]
Recommit "[LoopFlatten] Move it to a LoopPassManager"

This was reverted because of a performance regression, which is fixed by
D116612 that I will commit directly after this change.

This reverts commit e92d63b467e13227408f9726fbd66d07cc58811c.

2 years ago[LoopVectorize] Test in-loop reductions with tail folding for scalable vectors
Kerry McLaughlin [Wed, 19 Jan 2022 14:18:28 +0000 (14:18 +0000)]
[LoopVectorize] Test in-loop reductions with tail folding for scalable vectors

Adds `-prefer-inloop-reductions` to the RUN line of sve-tail-folding.ll & adds
a new test where in-loop reductions cannot be used (`@cond_xor_reduction`). NFC.

Reviewed By: david-arm

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

2 years ago[analyzer][NFC] Re-enable skipped SValTests by relaxing expectations
Balazs Benics [Wed, 19 Jan 2022 14:16:18 +0000 (15:16 +0100)]
[analyzer][NFC] Re-enable skipped SValTests by relaxing expectations

Some tests were skipped in D114454 to resolve test failures on some
platforms, where the pointers have different bitwidth than expected.
This patch re-enables these tests, by relaxing the requirements on the
types of the SVal.

The issue:
There is no way to reconstruct the type of the `SVal` perfectly
accurately, since there could be multiple types having the required
bitwidth and signedness.
Consider platforms where `int` and `long` have the same bitwidth.
Additionally, we need to be careful about casting a pointer to an
integral representation, because we don't know what smallest integral
type can represent that.

To workaround these issues, I propose enforcing a type that has the
same signedness and bitwidth as the expected type, instead of perfect
equality.

In the `GetLocAsIntType` test, in case of pointer-to-integral casts
I'm using the widest standard integral type (long long) to make sure
that the pointer can be represented by the type without losing
precision. This won't affect the test in any meaningful way, since the
type of the `lvalue` remained the same.

In one case, I had to replace `getUIntPtrType()` with `UnsignedLongTy`
because on some platforms `getUIntPtrType()` is different then `long
int`.

In this patch, I also enforce that the tests must compile without
errors, to prevent narrowing conversions in the future.

Reviewed By: stevewan

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

2 years ago[JITLink] Add RISCV label subtraction and addition relocations
luxufan [Fri, 7 Jan 2022 07:49:03 +0000 (15:49 +0800)]
[JITLink] Add RISCV label subtraction and addition relocations

This patch add RISCV label subtraction and addition relocations in JITLink

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

2 years ago[AArch64][SVE][VLS] Move extends into arguments of comparisons
David Truby [Tue, 16 Nov 2021 11:33:12 +0000 (11:33 +0000)]
[AArch64][SVE][VLS] Move extends into arguments of comparisons

When a comparison is extended and it would be free to extend the
arguments to that comparison, we can propagate the extend into those arguments.
This prevents extra instructions being generated to extend the result of the
comparison, which is not free to extend.

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

2 years ago[flang][NFC] Fix indentation
Valentin Clement [Wed, 19 Jan 2022 14:08:40 +0000 (15:08 +0100)]
[flang][NFC] Fix indentation

2 years ago[flang][NFC] Remove number of inlined elements
Valentin Clement [Wed, 19 Jan 2022 13:51:07 +0000 (14:51 +0100)]
[flang][NFC] Remove number of inlined elements

Following the recommendation just remove the specified number of
inlined elements since it is not well-motivated choice here.

2 years ago[flang][NFC] Fix includes order
Valentin Clement [Wed, 19 Jan 2022 13:32:48 +0000 (14:32 +0100)]
[flang][NFC] Fix includes order

2 years ago[mlir][linalg][bufferize][NFC] Move analysis-related code to Comprehensive Bufferize
Matthias Springer [Wed, 19 Jan 2022 13:19:31 +0000 (22:19 +0900)]
[mlir][linalg][bufferize][NFC] Move analysis-related code to Comprehensive Bufferize

The code in `BufferizableOpInterface`'s header/source no longer contains any analysis code. This makes it easier to run the bufferization with a different analysis or without any analysis.

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

2 years ago[clang-format] [docs] Fix link to avoid redirection. NFC.
Marek Kurdej [Wed, 19 Jan 2022 13:16:14 +0000 (14:16 +0100)]
[clang-format] [docs] Fix link to avoid redirection. NFC.

2 years ago[AVR] Do not clear r0 at interrupt entry
Ayke van Laethem [Thu, 6 Jan 2022 17:22:06 +0000 (18:22 +0100)]
[AVR] Do not clear r0 at interrupt entry

There is no reason to do this: it's a scratch register and can therefore
hold any arbitrary value. And because it is in an interrupt, this code
is performance critical so it should be as short as possible.

I believe r0 was cleared because of the following:

 1. There used to be a bug that the cleared register was r0, not r1 as
    it should have been.
 2. This was fixed in https://reviews.llvm.org/D99467, but left the code
    to clear r0.

This patch completes D99467 by removing the `clr r0` instruction.

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