platform/upstream/llvm.git
2 years ago[InstCombine] add tests for select with frozen condition; NFC
Sanjay Patel [Mon, 18 Apr 2022 18:45:18 +0000 (14:45 -0400)]
[InstCombine] add tests for select with frozen condition; NFC

2 years agoRevert "[SLP] Support internal users of splat loads"
Vasileios Porpodas [Mon, 18 Apr 2022 19:12:34 +0000 (12:12 -0700)]
Revert "[SLP] Support internal users of splat loads"

This reverts commit f8e1337115623cb879f734940fd9dfeb29a611e7.

2 years ago[Clang][Docs] Update information on the new driver now that it's default
Joseph Huber [Mon, 18 Apr 2022 19:01:55 +0000 (15:01 -0400)]
[Clang][Docs] Update information on the new driver now that it's default

Summary:
This patch updates some of the documentation on the new driver now that
it's the default. Also the ABI for embedding these images changed.

2 years ago[OpenMP] Make the new offloading driver the default
Joseph Huber [Thu, 31 Mar 2022 15:42:13 +0000 (11:42 -0400)]
[OpenMP] Make the new offloading driver the default

Previously an opt-in flag `-fopenmp-new-driver` was used to enable the
new offloading driver. After passing tests for a few months it should be
sufficiently mature to flip the switch and make it the default. The new
offloading driver is now enabled if there is OpenMP and OpenMP
offloading present and the new `-fno-openmp-new-driver` is not present.

The new offloading driver has three main benefits over the old method:
- Static library support
- Device-side LTO
- Unified clang driver stages

Depends on D122683

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

2 years ago[OpenMP] Refactor OMPScheduleType enum.
Michael Kruse [Mon, 18 Apr 2022 15:58:53 +0000 (10:58 -0500)]
[OpenMP] Refactor OMPScheduleType enum.

The OMPScheduleType enum stores the constants from libomp's internal sched_type in kmp.h and are used by several kmp API functions. The enum values have an internal structure, namely each scheduling algorithm (e.g.) exists in four variants: unordered, orderend, normerge unordered, and nomerge ordered.

This patch (basically a followup to D114940) splits the "ordered" and "nomerge" bits into separate flags, as was already done for the "monotonic" and "nonmonotonic", so we can apply bit flags operations on them. It also now contains all possible combinations according to kmp's sched_type. Deriving of the OMPScheduleType enum from clause parameters has been moved form MLIR's OpenMPToLLVMIRTranslation.cpp to OpenMPIRBuilder to make available for clang as well. Since the primary purpose of the flag is the binary interface to libomp, it has been made more private to LLVMFrontend. The primary interface for generating worksharing-loop using OpenMPIRBuilder code becomes `applyWorkshareLoop` which derives the OMPScheduleType automatically and calls the appropriate emitter function.

While this is mostly a NFC refactor, it still applies the following functional changes:
 * The logic from OpenMPToLLVMIRTranslation to derive the OMPScheduleType also applies to clang. Most notably, it now applies the nonmonotonic flag for non-static schedules by default.
 * In OpenMPToLLVMIRTranslation, the nonmonotonic default flag was previously not applied if the simd modifier was used. I assume this was a bug, since the effect was due to `loop.schedule_modifier()` returning `mlir::omp::ScheduleModifier::none` instead of `llvm::Optional::None`.
 * In OpenMPToLLVMIRTranslation, the nonmonotonic default flag was set even if ordered was specified, in breach to what the comment before citing the OpenMP specification says. I assume this was an oversight.

The ordered flag with parameter was not considered in this patch. Changes will need to be made (e.g. adding/modifying function parameters) when support for it is added. The lengthy names of the enum values can be discussed, for the moment this is avoiding reusing previously existing enum value names such as `StaticChunked` to avoid confusion.

Reviewed By: peixin

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

2 years ago[mlir:NFC] Remove the forward declaration of FuncOp in the mlir namespace
River Riddle [Mon, 18 Apr 2022 18:53:47 +0000 (11:53 -0700)]
[mlir:NFC] Remove the forward declaration of FuncOp in the mlir namespace

FuncOp has been moved to the `func` namespace for a little over a month, the
using directive can be dropped now.

2 years ago[SLP] Support internal users of splat loads
Vasileios Porpodas [Mon, 18 Apr 2022 14:49:26 +0000 (07:49 -0700)]
[SLP] Support internal users of splat loads

Until now we would only accept a broadcast load pattern if it is only used
by a single vector of instructions.

This patch relaxes this, and allows for the broadcast to have more than one
user vector, as long as all of its uses are internal to the SLP graph and
vectorized.

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

2 years ago[Arch64][SelectionDAG] Add target-specific implementation of srem
chenglin.bi [Mon, 18 Apr 2022 03:19:06 +0000 (11:19 +0800)]
[Arch64][SelectionDAG] Add target-specific implementation of srem

1. X%C to the equivalent of X-X/C*C is not always fastest path if there is no SDIV pair exist. So check target have faster for srem only first.
2. Add AArch64 faster path for SREM only pow2 case.

Fix https://github.com/llvm/llvm-project/issues/54649

Reviewed By: efriedma

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

2 years agoImprove terminator doc in MLIR LangRef
Mehdi Amini [Mon, 18 Apr 2022 18:43:25 +0000 (18:43 +0000)]
Improve terminator doc in MLIR LangRef

Reviewed By: rriddle, bondhugula

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

2 years ago[NFC][PowerPC] Style and ordering changes for PPCInstrP10.td
Stefan Pintilie [Mon, 18 Apr 2022 18:09:21 +0000 (13:09 -0500)]
[NFC][PowerPC] Style and ordering changes for PPCInstrP10.td

Renamed the two classes 8LS_DForm_R_SI34_RTA5 and 8LS_DForm_R_SI34_XT6_RA5 to
8LS_DForm_R_SI34_RTA5_MEM and 8LS_DForm_R_SI34_XT6_RA5_MEM because the
instructions that use the classes use memory reads/writes.

Moved the instruction defs up closer to the classes.
Removed unnecessary whitespace.

2 years agoApply clang-tidy fixes for readability-identifier-naming in GPUDialect.cpp (NFC)
Mehdi Amini [Sat, 16 Apr 2022 07:27:24 +0000 (07:27 +0000)]
Apply clang-tidy fixes for readability-identifier-naming in GPUDialect.cpp (NFC)

2 years agoApply clang-tidy fixes for readability-simplify-boolean-expr in TypeConverter.cpp...
Mehdi Amini [Sat, 16 Apr 2022 07:05:42 +0000 (07:05 +0000)]
Apply clang-tidy fixes for readability-simplify-boolean-expr in TypeConverter.cpp (NFC)

2 years agoDon't treat 'T &forward(T&&)' as builtin.
Richard Smith [Mon, 18 Apr 2022 18:07:10 +0000 (11:07 -0700)]
Don't treat 'T &forward(T&&)' as builtin.

This allows the standard library to diagnose it properly. Suppress
warning in libc++ testsuite for unused result of call to std::forward.

2 years ago[flang] Fix regression with recent work on intrinsic/generic interactions
Peter Klausler [Sat, 16 Apr 2022 03:59:13 +0000 (20:59 -0700)]
[flang] Fix regression with recent work on intrinsic/generic interactions

When resolving a procedure reference, do not allow a successful
intrinsic procedure probe result to override an existing
symbol.

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

2 years ago[Libomptarget] Fix LIBOMPTARGET_INFO test
Joseph Huber [Mon, 18 Apr 2022 18:08:16 +0000 (14:08 -0400)]
[Libomptarget] Fix LIBOMPTARGET_INFO test

Summary:
A patch added a new line to one of the info outputs without updating
this test. This patch adds the new text to the existing test.

2 years agoFix llvm-profgen breakage
Wenlei He [Mon, 18 Apr 2022 18:01:49 +0000 (11:01 -0700)]
Fix llvm-profgen breakage

2 years ago[ocaml bindings] Remove LTO bindings
Arthur Eubanks [Mon, 18 Apr 2022 17:22:26 +0000 (10:22 -0700)]
[ocaml bindings] Remove LTO bindings

Followup to D123882.

2 years ago[LegacyPM] Remove ThinLTO/LTO pipelines
Arthur Eubanks [Fri, 15 Apr 2022 23:03:48 +0000 (16:03 -0700)]
[LegacyPM] Remove ThinLTO/LTO pipelines

Using the legacy PM for the optimization pipeline was deprecated in 13.0.0.
Following recent changes to remove non-core features of the legacy
PM/optimization pipeline, remove the (Thin)LTO pipelines.

Reviewed By: MaskRay

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

2 years ago[CallPrinter] Port CallPrinter passes to new pass manager
Arthur Eubanks [Mon, 18 Apr 2022 16:58:11 +0000 (09:58 -0700)]
[CallPrinter] Port CallPrinter passes to new pass manager

Port the legacy CallGraphViewer and CallGraphDOTPrinter to work with the new pass manager.

Addresses issue https://github.com/llvm/llvm-project/issues/54323
Adds back related tests that were removed in commits d53a4e7b4a87 and 9e9d9aba1475

Reviewed By: aeubanks

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

2 years ago[llvm-profgen] Add process filter for perf reader
Wenlei He [Fri, 15 Apr 2022 19:27:46 +0000 (12:27 -0700)]
[llvm-profgen] Add process filter for perf reader

For profile generation, we need to filter raw perf samples for binary of interest. Sometimes binary name along isn't enough as we can have binary of the same name running in the system. This change adds a process id filter to allow users to further disambiguiate the input raw samples.

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

2 years ago[mlir] Fix two AttributeParser aborts
Jacques Pienaar [Mon, 18 Apr 2022 16:30:35 +0000 (09:30 -0700)]
[mlir] Fix two AttributeParser aborts

Reproducers that resulted in triggering the following asserts

mlir::NamedAttribute::NamedAttribute(mlir::StringAttr, mlir::Attribute)
mlir/lib/IR/Attributes.cpp:29:3
consumeToken
mlir/lib/Parser/Parser.h:126

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

2 years agoFormat fix in recent change. Removed whitespace. [NFC]
Blue Gaston [Mon, 18 Apr 2022 16:23:01 +0000 (09:23 -0700)]
Format fix in recent change. Removed whitespace. [NFC]

2 years ago[llvm][IPO] Inclusive language: Rename mergefunc-sanity to mergefunc-verify and remov...
Zarko Todorovski [Mon, 18 Apr 2022 15:49:54 +0000 (11:49 -0400)]
[llvm][IPO] Inclusive language: Rename mergefunc-sanity to mergefunc-verify and remove other instances of sanity in MergeFunctions.cpp

This patch renames the mergefunc-sanity to mergefunc-verify and renames the related functions to use more
inclusive language

Reviewed By: cebowleratibm

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

2 years agoForce GHashCell to be 8-byte-aligned.
Eli Friedman [Fri, 15 Apr 2022 20:03:39 +0000 (13:03 -0700)]
Force GHashCell to be 8-byte-aligned.

Otherwise, with recent versions of libstdc++, clang can't tell that the
atomic operations are properly aligned, and generates calls to
libatomic.  (Actually, because of the use of reinterpret_cast, it wasn't
guaranteed to be aligned, but I think it ended up being aligned in
practice.)

Fixes https://github.com/llvm/llvm-project/issues/54790 , the part where
LLVM failed to build.

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

2 years ago[Clang] Use of decltype(capture) in parameter-declaration-clause
Corentin Jabot [Sun, 17 Apr 2022 12:29:22 +0000 (14:29 +0200)]
[Clang] Use of decltype(capture) in parameter-declaration-clause

Partially implement the proposed resolution to CWG2569.

D119136 broke some libstdc++ code, as P2036R3, implemented as a DR to
C++11 made ill-formed some previously valid and innocuous code.

We resolve this issue to allow decltype(x) - but not decltype((x)
to appear in the parameter list of a lambda that capture x by copy.

Unlike CWG2569, we do not extend that special treatment to
sizeof/noexcept yet, as the resolution has not been approved yet
and keeping the review small allows a quicker fix of impacted code.

Reviewed By: aaron.ballman

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

2 years agoSilence a "not all control paths return a value" warning; NFC
Aaron Ballman [Mon, 18 Apr 2022 12:54:08 +0000 (08:54 -0400)]
Silence a "not all control paths return a value" warning; NFC

2 years ago[InstCombine] Add additional test coverage for D123374
Simon Pilgrim [Mon, 18 Apr 2022 12:13:35 +0000 (13:13 +0100)]
[InstCombine] Add additional test coverage for D123374

More basic test coverage for the fold: (A & 2^C1) + A => A & (2^C1 - 1) iff bit C1 in A is a sign bit

2 years ago[PowerPC] Fix sanitizers build on FreeBSD
Piotr Kubaj [Mon, 18 Apr 2022 09:53:01 +0000 (04:53 -0500)]
[PowerPC] Fix sanitizers build on FreeBSD

1. Add correct pc, sp and bp for FreeBSD.
2. Since there's no personality.h header on FreeBSD, move SANITIZER_PPC64V2
   case below FREEBSD case.
3. __ppc_get_timebase_freq() is glibc-specific. Add a shim for FreeBSD that
   does the same.

2 years ago[AArch64] Async unwind - Adjust unwind info in AArch64LoadStoreOptimizer
Momchil Velikov [Mon, 18 Apr 2022 10:15:46 +0000 (11:15 +0100)]
[AArch64] Async unwind - Adjust unwind info in AArch64LoadStoreOptimizer

[Re-commit after fixing a dereference of "end" iterator]

The AArch64LoadStoreOptimnizer pass may merge a register
increment/decrement with a following memory operation. In doing so, it
may break CFI by moving a stack pointer adjustment past the CFI
instruction that described *that* adjustment.

This patch fixes this issue by moving said CFI instruction after the
merged instruction, where the SP increment/decrement actually takes
place.

Reviewed By: efriedma

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

2 years ago[Test] Add more tests showing duplicate PHIs generated by RS4GC (NFC)
Dmitry Makogon [Mon, 18 Apr 2022 06:41:14 +0000 (13:41 +0700)]
[Test] Add more tests showing duplicate PHIs generated by RS4GC (NFC)

2 years ago[libc][docs] Remove the description of a "www" directory.
Siva Chandra Reddy [Mon, 18 Apr 2022 07:14:33 +0000 (07:14 +0000)]
[libc][docs] Remove the description of a "www" directory.

We plan to use the "docs" directory as the home for our "www" pages,
similar to how it is for the libcxx project.

2 years ago[libc] Add a doc describing the current status of libc runtimes build.
Siva Chandra Reddy [Thu, 14 Apr 2022 06:52:23 +0000 (06:52 +0000)]
[libc] Add a doc describing the current status of libc runtimes build.

A section briefly mentioning the planned future enhancements has also
been included.

Reviewed By: lntue

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

2 years ago[PowerPC] Mark side effects of Power9 darn instruction
Qiu Chaofan [Mon, 18 Apr 2022 05:21:40 +0000 (13:21 +0800)]
[PowerPC] Mark side effects of Power9 darn instruction

This fixes CVE-2019-15847, preventing random number generation from
being merged.

Reviewed By: lkail

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

2 years ago[MLIR][Presburger] Make IntegerRelation::mergeLocalIds not delete duplicates
Groverkss [Mon, 18 Apr 2022 04:45:17 +0000 (10:15 +0530)]
[MLIR][Presburger] Make IntegerRelation::mergeLocalIds not delete duplicates

This patch modifies mergeLocalIds to not delete duplicate local ids in
`this` relation. This allows the ordering of the final local ids for `this`
to be determined more easily, which is generally required when other objects
refer to these local ids.

Reviewed By: arjunp

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

2 years ago[RISCV] Pass -mno-relax to assembler when -fno-integrated-as specified
luxufan [Tue, 8 Mar 2022 11:28:10 +0000 (19:28 +0800)]
[RISCV] Pass -mno-relax to assembler when -fno-integrated-as specified

In the past, `clang --target=riscv64-unknown-linux-gnu -mno-relax -c hello.s` will assemble hello.s without relaxation, but `clang --target=riscv64-unknown-linux-gnu -mno-relax -fno-integrated-as -c hello.s` doesn't pass the `-mno-relax` option to assembler, and assemble with relaxation
This patch pass the -mno-relax option to assembler when -fno-integrated-as is specified.

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

2 years ago[mlir][Vector] Fold transpose splat to splat with transposed type.
jacquesguan [Thu, 14 Apr 2022 08:32:02 +0000 (08:32 +0000)]
[mlir][Vector] Fold transpose splat to splat with transposed type.

This revision folds transpose splat to a new splat with the transposed vector type. For a splat, there is no need to actually do transpose for it, it would be more effective to just build a new splat as the result.

Reviewed By: ThomasRaoux

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

2 years agoSpecify -fno-builtin when testing to make sure that certain stdlib
Richard Smith [Mon, 18 Apr 2022 02:39:55 +0000 (19:39 -0700)]
Specify -fno-builtin when testing to make sure that certain stdlib
functions are not treated as [[nodiscard]].

The compiler might choose to treat them as [[nodiscard]] without the
involvement of libc++ if we allow it to recognize them as builtins.

2 years agoRevert "[Arch64][SelectionDAG] Add target-specific implementation of srem"
chenglin.bi [Mon, 18 Apr 2022 02:35:09 +0000 (10:35 +0800)]
Revert "[Arch64][SelectionDAG] Add target-specific implementation of srem"

This reverts commit 9d9eddd3dde46751a5c415b7e5e475b4feb76600.

2 years agoFix wrong signature for std::move and std::swap in test.
Richard Smith [Mon, 18 Apr 2022 02:24:46 +0000 (19:24 -0700)]
Fix wrong signature for std::move and std::swap in test.

2 years ago[LogicalResult.h] Move ParseResult to the bottom of file and fix comment, NFC.
Chris Lattner [Sun, 17 Apr 2022 22:34:26 +0000 (15:34 -0700)]
[LogicalResult.h] Move ParseResult to the bottom of file and fix comment, NFC.

This was review feedback that I missed in the phab review:
https://reviews.llvm.org/D123760

2 years ago[Support] Move ParseResult from OpDefinition.h to LogicalResult.h
Chris Lattner [Thu, 14 Apr 2022 05:01:15 +0000 (22:01 -0700)]
[Support] Move ParseResult from OpDefinition.h to LogicalResult.h

This class is a helper for 'parser-like' use cases of LogicalResult
where the implicit conversion to bool is tolerable.  It is used by the
operation asmparsers, but is more generic functionality that is closely
aligned with LogicalResult.  Hoist it up to LogicalResult.h to make it
more accessible.  This is part of Issue #54884

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

2 years agoTreat `std::move`, `forward`, etc. as builtins.
Richard Smith [Sun, 17 Apr 2022 20:09:42 +0000 (13:09 -0700)]
Treat `std::move`, `forward`, etc. as builtins.

This is extended to all `std::` functions that take a reference to a
value and return a reference (or pointer) to that same value: `move`,
`forward`, `move_if_noexcept`, `as_const`, `addressof`, and the
libstdc++-specific function `__addressof`.

We still require these functions to be declared before they can be used,
but don't instantiate their definitions unless their addresses are
taken. Instead, code generation, constant evaluation, and static
analysis are given direct knowledge of their effect.

This change aims to reduce various costs associated with these functions
-- per-instantiation memory costs, compile time and memory costs due to
creating out-of-line copies and inlining them, code size at -O0, and so
on -- so that they are not substantially more expensive than a cast.
Most of these improvements are very small, but I measured a 3% decrease
in -O0 object file size for a simple C++ source file using the standard
library after this change.

We now automatically infer the `const` and `nothrow` attributes on these
now-builtin functions, in particular meaning that we get a warning for
an unused call to one of these functions.

In C++20 onwards, we disallow taking the addresses of these functions,
per the C++20 "addressable function" rule. In earlier language modes, a
compatibility warning is produced but the address can still be taken.

The same infrastructure is extended to the existing MSVC builtin
`__GetExceptionInfo`, which is now only recognized in namespace `std`
like it always should have been.

This is a re-commit of
  fc3090109643af8d2da9822d0f99c84742b9c877,
  a571f82a50416b767fd3cce0fb5027bb5dfec58c, and
  64c045e25b8471bbb572bd29159c294a82a86a25
which were reverted in
  e75d8b70370435b0ad10388afba0df45fcf9bfcc
due to a crasher bug where CodeGen would emit a builtin glvalue as an
rvalue if it constant-folds.

Reviewed By: aaron.ballman

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

2 years ago[ORC] Report paths in errors when creating StaticLibrarySearchGenerators.
Lang Hames [Sun, 17 Apr 2022 18:42:42 +0000 (11:42 -0700)]
[ORC] Report paths in errors when creating StaticLibrarySearchGenerators.

2 years ago[llvm-jitlink] Add paths to file-not-found errors.
Lang Hames [Sun, 17 Apr 2022 18:34:13 +0000 (11:34 -0700)]
[llvm-jitlink] Add paths to file-not-found errors.

2 years ago[llvm-jitlink] Don't show FailedToMaterialize errors by default.
Lang Hames [Sun, 17 Apr 2022 16:32:02 +0000 (09:32 -0700)]
[llvm-jitlink] Don't show FailedToMaterialize errors by default.

This patch makes printing of FailedToMaterialize errors in llvm-jitlink
conditional on the -show-err-failed-to-materialize option, which defaults to
false.

FailedToMaterialize errors are not root-cause errors: they're generated when a
symbol is requested but cannot be provided because of a failure that was
reported on some other error path. They typically don't convey actionable
information, and tend to flood error logs making root cause errors harder to
spot. Hiding FailedToMaterialize errors by default addresses these issues.

2 years agoRevert "[MLIR] Provide a way to print ops in custom form on pass failure"
Mehdi Amini [Sun, 17 Apr 2022 18:55:09 +0000 (18:55 +0000)]
Revert "[MLIR] Provide a way to print ops in custom form on pass failure"

This reverts commit daabcf5f04bbd13ac53f76ca3cc43b0d1ef64f5a.

This patch still had on-going discussion that should be closed before
committing.

2 years ago[Attributor] CGSCC pass should not recompute results outside the SCC (reapply)
Johannes Doerfert [Tue, 12 Apr 2022 21:24:37 +0000 (16:24 -0500)]
[Attributor] CGSCC pass should not recompute results outside the SCC (reapply)

When we run the CGSCC pass we should only invest time on the SCC. We can
initialize AAs with information from the module slice but we should not
update those AAs. We make an exception for are call site of the SCC as
they are helpful providing information for the SCC.

Minor modifications to pointer privatization allow us to perform it even
in the CGSCC pass, similar to ArgumentPromotion.

2 years ago[NVPTX] Use opaque pointers in param space vectorization tests
Daniil Kovalev [Sun, 17 Apr 2022 16:08:31 +0000 (19:08 +0300)]
[NVPTX] Use opaque pointers in param space vectorization tests

Opaque pointers are enabled by default since D123300, so test IR should be
regenerated correspondingly.

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

2 years ago[JITLink] Suppress "symbols not found" errors for testcase.
Lang Hames [Sun, 17 Apr 2022 15:34:22 +0000 (08:34 -0700)]
[JITLink] Suppress "symbols not found" errors for testcase.

On some platforms _ZTIi may not be present (see discussion at
https://reviews.llvm.org/rG43acef48d38e). We don't need this symbol for the
test to work, so just add -phony-externals to the testcase to suppress the
error.

2 years ago[NVPTX] Disable parens for identifiers starting with '$'
Andrew Savonichev [Mon, 11 Apr 2022 18:33:04 +0000 (21:33 +0300)]
[NVPTX] Disable parens for identifiers starting with '$'

ptxas fails to parse such syntax:

    mov.u64 %rd1, ($str);
    fatal   : Parsing error near '$str': syntax error

A new MCAsmInfo option was added because InParens parameter of
MCExpr::print is not sufficient to disable parens
completely. MCExpr::print resets it to false for a recursive call in
case of unary or binary expressions.

Targets that require parens around identifiers that start with '$'
should always pass MCAsmInfo to MCExpr::print.
Therefore 'operator<<(raw_ostream &, MCExpr&)' should be avoided
because it calls MCExpr::print with nullptr MAI.

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

2 years ago[MLIR] Provide a way to print ops in custom form on pass failure
Uday Bondhugula [Sat, 16 Apr 2022 03:54:20 +0000 (09:24 +0530)]
[MLIR] Provide a way to print ops in custom form on pass failure

The generic form of the op is too verbose and in some cases not
readable. On pass failure, ops have been so far printed in generic form
to provide a (stronger) guarantee that the IR print succeeds. However,
in a large number of pass failure cases, the IR is still valid and
the custom printers for the ops will succeed. In fact, readability is
highly desirable post pass failure. This revision provides an option to
print ops in their custom/pretty-printed form on IR failure -- this
option is unsafe and there is no guarantee it will succeed. It's
disabled by default and can be turned on only if needed.

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

2 years ago[AMDGPU][SIFrameLowering] Refactor custom SGPR spills (NFC).
Christudasan Devadasan [Wed, 13 Apr 2022 11:39:45 +0000 (17:09 +0530)]
[AMDGPU][SIFrameLowering] Refactor custom SGPR spills (NFC).

Reviewed By: arsenm

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

2 years ago[randstruct] Enforce using a designated init for a randomized struct
Bill Wendling [Sun, 17 Apr 2022 06:24:48 +0000 (23:24 -0700)]
[randstruct] Enforce using a designated init for a randomized struct

A randomized structure needs to use a designated or default initializer.
Using a non-designated initializer will result in values being assigned
to the wrong fields.

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

2 years ago[AMDGPU] Pre-checkin updated lit tests for D123525.
hsmahesha [Sun, 17 Apr 2022 05:14:40 +0000 (10:44 +0530)]
[AMDGPU] Pre-checkin updated lit tests for D123525.

Fix indentation within the lit test - agpr-copy-no-free-registers.ll.

Reviewed By: rampitec

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

2 years ago[mlir][docs] Add missing directory separator
Jacques Pienaar [Sun, 17 Apr 2022 04:59:18 +0000 (21:59 -0700)]
[mlir][docs] Add missing directory separator

2 years ago[JITLink] Error instead of asserting on unrecognized edge kinds.
Lang Hames [Sun, 17 Apr 2022 01:49:47 +0000 (18:49 -0700)]
[JITLink] Error instead of asserting on unrecognized edge kinds.

It's idiomatic to require that plugins (especially platform plugins) be
installed to handle special edge kinds. If the plugins are not installed and an
object is loaded that uses one of the special edge kinds then we want to error
out rather than asserting.

2 years agoWindows: correct iteration of additional search paths
Saleem Abdulrasool [Sun, 17 Apr 2022 00:57:00 +0000 (17:57 -0700)]
Windows: correct iteration of additional search paths

This adjusts the path iteration - `paths` is a null-terminated sequence
of C strings, creating an array from a single contiguous buffer.  We
would previously continue to iterate indefinitely as we did not check if
we had encountered the terminator.

Found by inspection.

2 years ago[libcxx] [test] Use LIBCPP_ASSERT for libc++-specific checks
Jonathan Wakely [Sat, 16 Apr 2022 21:01:05 +0000 (23:01 +0200)]
[libcxx] [test] Use LIBCPP_ASSERT for libc++-specific checks

This makes it a little easier to reuse the libc++ tests for another
std::lib (specifically libstdc++).

The regex_error::what() strings are different in other
implementations, so should be tested with LIBCPP_ASSERT so that those
checks are skipped for other implementations.

The value of ECMAScript constant is non-zero in other implementations,
and conditionally for libc++, so adjust the preprocessor condition for
that too.

Reviewed By: ldionne, #libc, philnik, Mordante

Spies: Mordante, philnik, libcxx-commits

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

2 years ago[flang] Add & use a better visit() (take 2)
Peter Klausler [Wed, 23 Mar 2022 21:05:50 +0000 (14:05 -0700)]
[flang] Add & use a better visit() (take 2)

Adds flang/include/flang/Common/log2-visit.h, which defines
a Fortran::common::visit() template function that is a drop-in
replacement for std::visit().  Modifies most use sites in
the front-end and runtime to use common::visit().

The C++ standard mandates that std::visit() have O(1) execution
time, which forces implementations to build dispatch tables.
This new common::visit() is O(log2 N) in the number of alternatives
in a variant<>, but that N tends to be small and so this change
produces a fairly significant improvement in compiler build
memory requirements, a 5-10% improvement in compiler build time,
and a small improvement in compiler execution time.

Building with -DFLANG_USE_STD_VISIT causes common::visit()
to be an alias for std::visit().

Calls to common::visit() with multiple variant arguments
are referred to std::visit(), pending further work.

This change is enabled only for GCC builds with GCC >= 9;
an earlier attempt (D122441) ran into bugs in some versions of
clang and was reverted rather than simply disabled; and it is
not well tested with MSVC. In non-GCC and older GCC builds,
common::visit() is simply an alias for std::visit().

2 years ago[X86] Move some hasOneUse checks after checking what the opcode is.
Craig Topper [Sat, 16 Apr 2022 21:08:04 +0000 (14:08 -0700)]
[X86] Move some hasOneUse checks after checking what the opcode is.

Calling hasOneUse can be expensive on nodes with multiple results.
Especially when some results are Chains. By checking the opcode first,
we can avoid walking the uses if it isn't an interesting node,
and thus avoid calling hasOneUse on a node that might have many uses.

Found by profiling the IR given in D123857.

Reviewed By: RKSimon

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

2 years ago[ORC] Make IRSpeculationLayer::BaseLayer an IRLayer.
Lang Hames [Sat, 16 Apr 2022 21:06:27 +0000 (14:06 -0700)]
[ORC] Make IRSpeculationLayer::BaseLayer an IRLayer.

BaseLayer was originally written as an IRCompileLayer, but there was no need for
this restriction. Using IRLayer gives clients more flexibility in choosing the
underlying layer.

2 years ago[IROutliner] Ensure that phi values that are passed in as arguments are remapped...
Andrew Litteken [Mon, 21 Mar 2022 20:56:50 +0000 (15:56 -0500)]
[IROutliner] Ensure that phi values that are passed in as arguments are remapped as arguments

Issue: https://github.com/llvm/llvm-project/issues/54430

For incoming values of phi nodes added to an outlined function to accommodate different exit paths in the function, when a value is a constant that is passed into the outlined function as an argument, we find the corresponding value in the first extracted function used to fill the overall outlined function. When this value is an argument, the corresponding value used will be the old value, prior to outlining. This patch maintains a mapping from these values to arguments, and uses this mapping to update the added phi node accordingly.

Reviewers: paquette

Recommit of d6eb480afbc038871570fa053d772c913cd77a61

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

2 years ago[LSR] Update outdated comment
eop Chen [Sat, 16 Apr 2022 19:10:58 +0000 (12:10 -0700)]
[LSR] Update outdated comment

2 years ago[mlir][CSE] Add ability to remove commutative operations
Valentin Clement [Sat, 16 Apr 2022 19:08:16 +0000 (21:08 +0200)]
[mlir][CSE] Add ability to remove commutative operations

This patch takes advantage of the Commutative trait on operation
to remove identical commutative operations where the operands are swapped.

The second operation below can be removed since `arith.addi` is commutative.
```
%1 = arith.addi %a, %b : i32
%2 = arith.addi %b, %a : i32
```

Reviewed By: rriddle

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

2 years ago[gn build] (manually) port f2526c1a5c6f
Nico Weber [Sat, 16 Apr 2022 16:58:04 +0000 (12:58 -0400)]
[gn build] (manually) port f2526c1a5c6f

2 years agoRevert "[randstruct] Enforce using a designated init for a randomized struct"
Aaron Ballman [Sat, 16 Apr 2022 15:11:32 +0000 (11:11 -0400)]
Revert "[randstruct] Enforce using a designated init for a randomized struct"

This reverts commit aed923b1246ac38335b222b89594516fcf0d6385.

It causes some buildbot test failures.

2 years agoRevert "[randstruct] Force errors for all platforms"
Aaron Ballman [Sat, 16 Apr 2022 15:10:57 +0000 (11:10 -0400)]
Revert "[randstruct] Force errors for all platforms"

This reverts commit 2a404cdfd8bc75de593ce0e15fff0a7a0a18ec1c.

It didn't address the built bot failures.

https://lab.llvm.org/buildbot/#/builders/171/builds/13231
https://lab.llvm.org/buildbot/#/builders/186/builds/5520

2 years ago[clang-tidy] Add a Standalone diagnostics mode to clang-tidy
Nathan James [Sat, 16 Apr 2022 08:53:32 +0000 (09:53 +0100)]
[clang-tidy] Add a Standalone diagnostics mode to clang-tidy

Adds a flag to `ClangTidyContext` that is used to indicate to checks that fixes will only be applied one at a time.
This is to indicate to checks that each fix emitted should not depend on any other fixes emitted across the translation unit.
I've currently implemented the `IncludeInserter`, `LoopConvertCheck` and `PreferMemberInitializerCheck` to use these support these modes.

Reasoning behind this is in use cases like `clangd` it's only possible to apply one fix at a time.
For include inserter checks, the include is only added once for the first diagnostic that requires it, this will result in subsequent fixes not having the included needed.

A similar issue is seen in the `PreferMemberInitializerCheck` where the `:` will only be added for the first member that needs fixing.

Fixes emitted in `StandaloneDiagsMode` will likely result in malformed code if they are applied all together, conversely fixes currently emitted may result in malformed code if they are applied one at a time.
For this reason invoking `clang-tidy` from the binary will always with `StandaloneDiagsMode` disabled, However using it as a library its possible to select the mode you wish to use, `clangd` always selects `StandaloneDiagsMode`.

This is an example of the current behaviour failing
```lang=c++
struct Foo {
  int A, B;
  Foo(int D, int E) {
    A = D;
    B = E; // Fix Here
  }
};
```
Incorrectly transformed to:
```lang=c++
struct Foo {
  int A, B;
  Foo(int D, int E), B(E) {
    A = D;
     // Fix Here
  }
};
```
In `StandaloneDiagsMode`, it gets transformed to:
```lang=c++
struct Foo {
  int A, B;
  Foo(int D, int E) : B(E) {
    A = D;
     // Fix Here
  }
};
```

Reviewed By: sammccall

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

2 years agoRevert "Treat `std::move`, `forward`, and `move_if_noexcept` as builtins."
Vitaly Buka [Sat, 16 Apr 2022 07:18:48 +0000 (00:18 -0700)]
Revert "Treat `std::move`, `forward`, and `move_if_noexcept` as builtins."
Revert "Extend support for std::move etc to also cover std::as_const and"
Revert "Update test to handle opaque pointers flag flip."

It crashes on libcxx tests https://lab.llvm.org/buildbot/#/builders/85/builds/8174

This reverts commit fc3090109643af8d2da9822d0f99c84742b9c877.
This reverts commit a571f82a50416b767fd3cce0fb5027bb5dfec58c.
This reverts commit 64c045e25b8471bbb572bd29159c294a82a86a25.

2 years agoApply clang-tidy fixes for readability-identifier-naming in OpFormatGen.cpp (NFC)
Mehdi Amini [Mon, 4 Apr 2022 00:32:38 +0000 (00:32 +0000)]
Apply clang-tidy fixes for readability-identifier-naming in OpFormatGen.cpp (NFC)

2 years agoApply clang-tidy fixes for llvm-qualified-auto in OpFormatGen.cpp (NFC)
Mehdi Amini [Mon, 4 Apr 2022 00:31:56 +0000 (00:31 +0000)]
Apply clang-tidy fixes for llvm-qualified-auto in OpFormatGen.cpp (NFC)

2 years ago[mlir] Add asserts when changing various MLIRContext configurations
River Riddle [Wed, 19 Jan 2022 00:16:54 +0000 (16:16 -0800)]
[mlir] Add asserts when changing various MLIRContext configurations

This helps to prevent tsan failures when users inadvertantly mutate the
context in a non-safe way.

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

2 years ago[Arch64][SelectionDAG] Add target-specific implementation of srem
chenglin.bi [Sat, 16 Apr 2022 04:29:11 +0000 (12:29 +0800)]
[Arch64][SelectionDAG] Add target-specific implementation of srem

X%C to the equivalent of X-X/C*C is not always fastest path if there is no SDIV pair exist. So check target have faster for srem only first. Add AArch64 faster path for SREM only pow2 case.

Fix https://github.com/llvm/llvm-project/issues/54649

Reviewed By: efriedma

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

2 years ago[msan][test] Remove legacy PM style opt -foo tests
Fangrui Song [Sat, 16 Apr 2022 04:07:50 +0000 (21:07 -0700)]
[msan][test] Remove legacy PM style opt -foo tests

2 years ago[flang][runtime] Don't emit empty lines for bad writes
Peter Klausler [Tue, 12 Apr 2022 22:15:46 +0000 (15:15 -0700)]
[flang][runtime] Don't emit empty lines for bad writes

When an error occurs in a formatted sequential output statement
and no output was ever emitted, don't emit a blank record.
This matches the error case behavior of other Fortran compilers.

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

2 years agoAdd some helpers to better check Scope's kind. NFC
Jun Zhang [Sat, 16 Apr 2022 03:27:18 +0000 (11:27 +0800)]
Add some helpers to better check Scope's kind. NFC

Signed-off-by: Jun Zhang <jun@junz.org>
2 years ago[flang] Accept %KIND type parameter inquiries on %RE,%IM, &c.
Peter Klausler [Tue, 12 Apr 2022 21:08:04 +0000 (14:08 -0700)]
[flang] Accept %KIND type parameter inquiries on %RE,%IM, &c.

The x%KIND inquiry needs to be supported when 'x' is itself
a complex part reference or a type parameter inquiry.

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

2 years ago[flang] Allow POINTER attribute statement on procedure interfaces
Peter Klausler [Tue, 12 Apr 2022 01:57:59 +0000 (18:57 -0700)]
[flang] Allow POINTER attribute statement on procedure interfaces

A POINTER attribute statement is allowed to add the POINTER attribute
to a procedure entity that has already been declared, e.g. with an
INTERFACE block.

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

2 years ago[test] Test -Werror=foo -Wfoo & -Werror -Wno-error=foo -Wfoo
Fangrui Song [Sat, 16 Apr 2022 03:14:07 +0000 (20:14 -0700)]
[test] Test -Werror=foo -Wfoo & -Werror -Wno-error=foo -Wfoo

Clang now matches GCC in the two cases.

D109981 fixed the second case though it did not call out the effect.

2 years ago[flang] Upgrade short actual character arguments to errors
Peter Klausler [Tue, 12 Apr 2022 01:39:02 +0000 (18:39 -0700)]
[flang] Upgrade short actual character arguments to errors

f18 was emitting a warning about short character actual arguments to
subprograms and statement functions; every other compiler considers this
case to be an error.

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

2 years ago[asan][test] Remove legacy PM style opt -foo tests
Fangrui Song [Sat, 16 Apr 2022 03:00:56 +0000 (20:00 -0700)]
[asan][test] Remove legacy PM style opt -foo tests

2 years ago[LoongArch] Fix typo that SP should be R3 but not R2
Weining Lu [Sat, 9 Apr 2022 08:52:24 +0000 (16:52 +0800)]
[LoongArch] Fix typo that SP should be R3 but not R2

2 years ago[flang][runtime] Fix ENDFILE for formatted stream output
Peter Klausler [Tue, 12 Apr 2022 00:12:39 +0000 (17:12 -0700)]
[flang][runtime] Fix ENDFILE for formatted stream output

A predicate expression made ENDFILE statements significant
only for sequential files, but it's applicable to formatted
stream output as well.

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

2 years ago[Clang][OpenMP] Use bitfields for flags in `OMPAtomicDirective`
Shilei Tian [Sat, 16 Apr 2022 01:34:19 +0000 (21:34 -0400)]
[Clang][OpenMP] Use bitfields for flags in `OMPAtomicDirective`

As suggested in D120290.

Reviewed By: ABataev

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

2 years ago[OpenMP] Fix linting diagnostics in the linker wrapper
Joseph Huber [Sat, 16 Apr 2022 01:18:56 +0000 (21:18 -0400)]
[OpenMP] Fix linting diagnostics in the linker wrapper

Summary:
A previous patch had some linter warnings that should've been addressed.

2 years agoBlind stab in the dark to fix a bot failure
Chris Bieneman [Sat, 16 Apr 2022 01:12:52 +0000 (20:12 -0500)]
Blind stab in the dark to fix a bot failure

*fingers crossed*

2 years ago[NFC] fix cmake build
Mogball [Sat, 16 Apr 2022 00:56:38 +0000 (00:56 +0000)]
[NFC] fix cmake build

2 years agoApply clang-tidy fixes for readability-identifier-naming in mlir-parser-fuzzer.cpp...
Mehdi Amini [Mon, 4 Apr 2022 00:28:26 +0000 (00:28 +0000)]
Apply clang-tidy fixes for readability-identifier-naming in mlir-parser-fuzzer.cpp (NFC)

2 years agoApply clang-tidy fixes for readability-identifier-naming in DummyParserFuzzer.cpp...
Mehdi Amini [Mon, 4 Apr 2022 00:27:44 +0000 (00:27 +0000)]
Apply clang-tidy fixes for readability-identifier-naming in DummyParserFuzzer.cpp (NFC)

2 years ago[IR] Allow constant folding (insertelement <vscale x 2 x i32> zeroinitializer, i32...
Craig Topper [Sat, 16 Apr 2022 00:32:42 +0000 (17:32 -0700)]
[IR] Allow constant folding (insertelement <vscale x 2 x i32> zeroinitializer, i32 0, i32 i32 0.

Most of insertelement constant folding is blocked if the vector type
is scalable. I believe we can make an exception for inserting null
into an all zeros vector.

Reviewed By: nikic

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

2 years ago[mlir] Refactor LICM into a utility
Mogball [Sat, 16 Apr 2022 00:36:22 +0000 (00:36 +0000)]
[mlir] Refactor LICM into a utility

LICM is refactored into a utility that is application on any region. The implementation is moved to Transform/Utils.

2 years ago[OpenMP] Use new offloading binary when embedding offloading images
Joseph Huber [Fri, 25 Mar 2022 15:03:02 +0000 (11:03 -0400)]
[OpenMP] Use new offloading binary when embedding offloading images

The previous patch introduced the offloading binary format so we can
store some metada along with the binary image. This patch introduces
using this inside the linker wrapper and Clang instead of the previous
method that embedded the metadata in the section name.

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

2 years ago[OpenMP] Don't manually strip sections in the linker wrapper
Joseph Huber [Wed, 13 Apr 2022 17:43:47 +0000 (13:43 -0400)]
[OpenMP] Don't manually strip sections in the linker wrapper

Summary:
The changes in D122987 ensures that the offloading sections always have
the SHF_EXCLUDE flag. This means that we do not need to manually strip
these sections for ELF or COFF targets.

2 years agollvm-reduce: Clone some of the easy function properties
Matt Arsenault [Thu, 14 Apr 2022 14:59:37 +0000 (10:59 -0400)]
llvm-reduce: Clone some of the easy function properties

Error on some of these other fields, since tracking down test cases
for all of these at once is exhausting.

2 years agoMIR: Serialize a few bool function fields
Matt Arsenault [Thu, 14 Apr 2022 20:16:08 +0000 (16:16 -0400)]
MIR: Serialize a few bool function fields

2 years ago[X86] Move hasOneUse check after opcode check. NFC
Craig Topper [Sat, 16 Apr 2022 00:19:07 +0000 (17:19 -0700)]
[X86] Move hasOneUse check after opcode check. NFC

Checking opcode is cheap. hasOneUse might not be if the node has
multiple results. By checking the opcode we can rule out nodes
with multiple results we aren't interested in.

2 years agoRevert "[mlir] Refactor LICM into a utility"
Stella Stamenova [Sat, 16 Apr 2022 00:09:05 +0000 (17:09 -0700)]
Revert "[mlir] Refactor LICM into a utility"

This reverts commit 3131f808243abe3746280e016ab9459c14d9e53b.

This commit broke the Windows mlir bot:
https://lab.llvm.org/buildbot/#/builders/13/builds/19745

2 years ago[DAGCombiner] Move call to hasOneUse after opcode checks. NFC
Craig Topper [Sat, 16 Apr 2022 00:01:40 +0000 (17:01 -0700)]
[DAGCombiner] Move call to hasOneUse after opcode checks. NFC

Checking the opcode is cheap, counting the number of uses is not.

2 years agoAdd DXIL Bitcode Writer and DXIL testing
Chris Bieneman [Thu, 14 Apr 2022 18:37:44 +0000 (13:37 -0500)]
Add DXIL Bitcode Writer and DXIL testing

This change is a big blob of code that isn't easy to break up. It
either comes in all together as a blob, works and has tests, or it
doesn't do anything.

Logically you can think of this patch as three things:
(1) Adding virtual interfaces so the bitcode writer can be overridden
(2) Adding a new bitcode writer implementation for DXIL
(3) Adding some (optional) crazy CMake goop to build the
DirectXShaderCompiler's llvm-dis as dxil-dis for testing

Reviewed By: nikic

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

2 years ago[DAGCombiner] Move or/xor/and opcode check in ReduceLoadOpStoreWidth before hasOneUse...
Craig Topper [Fri, 15 Apr 2022 23:33:12 +0000 (16:33 -0700)]
[DAGCombiner] Move or/xor/and opcode check in ReduceLoadOpStoreWidth before hasOneUse check.

hasOneUse is not cheap on nodes with chain results that might have
many uses. By checking the opcode first, we can avoid a costly walk
of the use list on nodes we aren't interested in.

Found by investigating calls to hasNUsesOfValue from the example
provided in D123857.