platform/upstream/llvm.git
2 years agoProperly diagnose constant evaluation issues at TU scope
Aaron Ballman [Tue, 8 Mar 2022 15:09:16 +0000 (10:09 -0500)]
Properly diagnose constant evaluation issues at TU scope

We were not creating an evaluation context for the TU scope, so we
never popped an evaluation context for it. Popping the evaluation
context triggers a number of diagnostics, including warnings about
immediate invocations that we were previously missing.

Note: I think we have an additional issue that we should solve, but not
as part of this patch. I don't think Clang is properly modeling static
initialization as happening before constant expression evaluation. I
think structure members members are zero initialized per
http://eel.is/c++draft/basic.start.static#1,
https://eel.is/c++draft/basic.start.static#2.sentence-2, and
http://eel.is/c++draft/dcl.init#general-6.2 and the new test case
actually should be accepted. However, it's also worth noting that other
compilers behave the way this patch makes Clang behave:
https://godbolt.org/z/T7noqhdPr

2 years ago[clang][driver] Fix float128 diagnostics with glibc >= 2.32
Timm Bäder [Tue, 8 Mar 2022 13:21:37 +0000 (14:21 +0100)]
[clang][driver] Fix float128 diagnostics with glibc >= 2.32

Fix checking for an unsupported stdlib++.

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

2 years ago[InstCombine] add tests for fcmp (fpext X), C; NFC
Sanjay Patel [Mon, 7 Mar 2022 22:02:05 +0000 (17:02 -0500)]
[InstCombine] add tests for fcmp (fpext X), C; NFC

2 years ago[clang][ABI] New C++20 module mangling scheme
Nathan Sidwell [Tue, 18 Jan 2022 15:14:08 +0000 (07:14 -0800)]
[clang][ABI] New C++20 module mangling scheme

The existing module symbol mangling scheme turns out to be
undemangleable.  It is also desirable to switch to the
strong-ownership model as the hoped-for C++17 compatibility turns out
to be fragile, and we also now have a better way of controlling that.

The issue is captured on the ABI list at:
  https://github.com/itanium-cxx-abi/cxx-abi/issues/134

A document describing the issues and new mangling is at:
  https://drive.google.com/file/d/1qQjqptzOFT_lfXH8L6-iD9nCRi34wjft/view

This patch is the code-generation part.  I have a demangler too, but
that patch is based on some to-be-landed refactoring of the demangler.

The old mangling is unceremoniously dropped.  No backwards
compatibility, no deprectated old-mangling flag.  It was always
labelled experimental.  (Old and new manglings cannot be confused.)

Reviewed By: ChuanqiXu

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

2 years ago[lld-macho] Deduplicate the `__objc_classrefs` section contents
Jez Ng [Tue, 8 Mar 2022 13:25:59 +0000 (08:25 -0500)]
[lld-macho] Deduplicate the `__objc_classrefs` section contents

ld64 breaks down `__objc_classrefs` on a per-word level and deduplicates
them. This greatly reduces the number of bind entries emitted (and
therefore the amount of work `dyld` has to do at runtime). For
chromium_framework, this change to LLD cuts the number of (non-lazy)
binds from 912 to 190, getting us to parity with ld64 in this aspect.

Reviewed By: #lld-macho, thakis

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

2 years ago[lld-macho] Deduplicate CFStrings during ICF
Jez Ng [Tue, 8 Mar 2022 13:25:56 +0000 (08:25 -0500)]
[lld-macho] Deduplicate CFStrings during ICF

`__cfstring` has embedded addends that foil ICF's hashing / equality
checks. (We can ignore embedded addends when doing ICF because the same
information gets recorded in our Reloc structs.) Therefore, in order to
properly dedup CFStrings, we create a mutable copy of the CFString and
zero out the embedded addends before performing any hashing / equality
checks.

(We did in fact have a partial implementation of CFString deduplication
already. However, it only worked when the cstrings they point to are at
identical offsets in their object files.)

I anticipate this approach can be extended to other similar
statically-allocated struct sections in the future.

In addition, we previously treated all references with differing addends
as unequal. This is not true when the references are to literals:
different addends may point to the same literal in the output binary. In
particular, `__cfstring` has such references to `__cstring`. I've
adjusted ICF's `equalsConstant` logic accordingly, and I've added a few
more tests to make sure the addend-comparison code path is adequately
covered.

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

Reviewed By: #lld-macho, Roger

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

2 years ago[X86] convertIntLogicToFPLogic - pull out condcodes. NFCI.
Simon Pilgrim [Tue, 8 Mar 2022 13:31:17 +0000 (13:31 +0000)]
[X86] convertIntLogicToFPLogic - pull out condcodes. NFCI.

2 years ago[libc++] Enable more clang-tidy checks and list potential candidates
Nikolas Klauser [Thu, 3 Mar 2022 19:07:09 +0000 (20:07 +0100)]
[libc++] Enable more clang-tidy checks and list potential candidates

These are some checks that make sense in libc++ IMO. The checks after `#TODO: investigate these checks` are candidates, but they can't be enabled without some cleanup.

Reviewed By: ldionne, #libc

Spies: aheejin, libcxx-commits

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

2 years ago[Sparc] Add tail call support
Daniel Cederman [Tue, 8 Mar 2022 11:20:33 +0000 (12:20 +0100)]
[Sparc] Add tail call support

This patch adds tail call support to the 32-bit Sparc backend.

Two new instructions are defined, TAIL_CALL and TAIL_CALLri. They are
encoded the same as CALL and BINDri, but are marked with isReturn so
that the epilogue gets emitted. In contrast to CALL, TAIL_CALL is not
marked with isCall. This makes it possible to use the leaf function
optimization when the only call a function makes is a tail call.

TAIL_CALL modifies the return address in %o7, so for leaf functions
the value in %o7 needs to be restored after the call. For normal
functions which uses the restore instruction this is not necessary.

Reviewed By: koakuma

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

2 years ago[clangd] NFC: Cleanup IncludeCleaner API
Kirill Bobyrev [Tue, 8 Mar 2022 12:42:50 +0000 (13:42 +0100)]
[clangd] NFC: Cleanup IncludeCleaner API

Make a further improvement to decrease verbosity of the API: ASTContext
provides SourceManager access.

Reviewed By: sammccall

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

2 years ago[clang-format] Correctly detect `!` as TT_NonNullAssertion after `default`.
Marek Kurdej [Mon, 7 Mar 2022 17:48:24 +0000 (18:48 +0100)]
[clang-format] Correctly detect `!` as TT_NonNullAssertion after `default`.

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

Depends on D121132.

Reviewed By: HazardyKnusperkeks, owenpan

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

2 years ago[clang-format] Handle C# 9 `init` accessor specifier.
Marek Kurdej [Mon, 7 Mar 2022 17:28:32 +0000 (18:28 +0100)]
[clang-format] Handle C# 9 `init` accessor specifier.

Before, the code:
```
int Value { get; } = 0;
int Value { init; } = 0;
```
was formatted incoherently:
```
int Value { get; } = 0;
int Value { init; }
= 0;
```
because `init` was not recognised as an accessor specifier.

Reviewed By: MyDeveloperDay, HazardyKnusperkeks

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

2 years agoUpdate more `parseSourceString()` call sites.
Christian Sigg [Tue, 8 Mar 2022 11:59:42 +0000 (12:59 +0100)]
Update more `parseSourceString()` call sites.

Change to non-deprecated function template (see D121075).

Reviewed By: rriddle

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

2 years ago[MLIR][Presburger] Silence warnings in GCC (NFC)
Lorenzo Chelini [Tue, 8 Mar 2022 11:16:00 +0000 (12:16 +0100)]
[MLIR][Presburger] Silence warnings in GCC (NFC)

Reviewed By: arjunp

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

2 years ago[X86] Add add / mul identity select tests for D119654
Simon Pilgrim [Tue, 8 Mar 2022 11:20:44 +0000 (11:20 +0000)]
[X86] Add add / mul identity select tests for D119654

2 years ago[clang] Fix reference to file that was moved.
Adrian Kuegel [Tue, 8 Mar 2022 11:26:02 +0000 (12:26 +0100)]
[clang] Fix reference to file that was moved.

2 years ago[AArch64] Add test for D120481 with multiple uses.
Florian Hahn [Tue, 8 Mar 2022 11:11:03 +0000 (11:11 +0000)]
[AArch64] Add test for D120481 with multiple uses.

2 years ago[AST] Fix typo in assert messages
Krystian Kuzniarek [Tue, 8 Mar 2022 11:06:18 +0000 (11:06 +0000)]
[AST] Fix typo in assert messages

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

2 years ago[mlir][bufferize][NFC] Better error messages if analysis fails
Matthias Springer [Tue, 8 Mar 2022 10:39:18 +0000 (19:39 +0900)]
[mlir][bufferize][NFC] Better error messages if analysis fails

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

2 years ago[X86] Update avx512vbmi2 intrinsic tests to avoid adds
Luo, Yuanke [Tue, 8 Mar 2022 09:46:54 +0000 (17:46 +0800)]
[X86] Update avx512vbmi2 intrinsic tests to avoid adds

As noticed in D119654, by adding the masked intrinsics results together
we can end up with the selects being canonicalized away from the
intrinsic - this isn't what we want to test here so replace with a
insertvalue chain into a aggregate instead to retain all the results.

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

2 years agotsan: fix false positive during fd close
Dmitry Vyukov [Mon, 7 Mar 2022 19:30:38 +0000 (20:30 +0100)]
tsan: fix false positive during fd close

FdClose is a subjet to the same atomicity problem as MemoryRangeFreed
(memory state is not "monotoic" wrt race detection).
So we need to lock the thread slot in FdClose the same way we do
in MemoryRangeFreed.
This fixes the modified stress.cpp test.

Reviewed By: vitalybuka, melver

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

2 years ago[LLDB] Skip TestIOHandlerProcessSTDIO.py for Arm/AArch64 Linux
Muhammad Omair Javaid [Tue, 8 Mar 2022 09:13:25 +0000 (14:13 +0500)]
[LLDB] Skip TestIOHandlerProcessSTDIO.py for Arm/AArch64 Linux

This patch disables TestIOHandlerProcessSTDIO.py for Arm/AArch64 Linux
to silence random test failures on buildbots. IO handler tests are known
to randomly fail on arm/aarch64 linux buildbots due to pexpect timeouts.

2 years ago[mlir][Vector] Use create_mask in transfer mask materializations
Javier Setoain [Thu, 24 Feb 2022 14:50:26 +0000 (14:50 +0000)]
[mlir][Vector] Use create_mask in transfer mask materializations

Currently, the transfer mask is materialized by generating the vector
comparison: [offset + 0, .., offset + length - 1] < [dim, .., dim]

A better alternative is to materialize the transfer mask by using the
operation: `vector.create_mask (dim - offset)`, which will generate
simpler code and compose better with scalable vectors.

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

2 years ago[Sema] Mark the referenced destructor during transformation of a `CXXBindTemporaryExpr`
Argyrios Kyrtzidis [Wed, 23 Feb 2022 19:59:27 +0000 (11:59 -0800)]
[Sema] Mark the referenced destructor during transformation of a `CXXBindTemporaryExpr`

Otherwise we will fail to generate the definition of a defaulted destructor,
if the only reference was in a templated temporary.

rdar://89366678

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

2 years ago[MLIR][Presburger] Move PresburgerLocalSpace::isEqual from protected to public
Groverkss [Tue, 8 Mar 2022 08:50:52 +0000 (14:20 +0530)]
[MLIR][Presburger] Move PresburgerLocalSpace::isEqual from protected to public

This change is done to match the interface of PresburgerSpace, which has
PresburgerSpace::isEqual as public.

2 years ago[X86] Update avx512vbmi2 intrinsic tests to avoid adds
Luo, Yuanke [Tue, 8 Mar 2022 08:35:15 +0000 (16:35 +0800)]
[X86] Update avx512vbmi2 intrinsic tests to avoid adds

As noticed in D119654, by adding the masked intrinsics results together
we can end up with the selects being canonicalized away from the
intrinsic - this isn't what we want to test here so replace with a
insertvalue chain into a aggregate instead to retain all the results.

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

2 years ago[mlir][NFC] Properly include PassDetail.h for FoldSubViewOpsPass
River Riddle [Tue, 8 Mar 2022 08:03:27 +0000 (00:03 -0800)]
[mlir][NFC] Properly include PassDetail.h for FoldSubViewOpsPass

2 years ago[mlir][NFC] Remove dead forward declaration of FuncOp
River Riddle [Tue, 8 Mar 2022 08:01:41 +0000 (00:01 -0800)]
[mlir][NFC] Remove dead forward declaration of FuncOp

2 years ago[mlir][Bazel] Adjust regarding StandardToLLVM -> FuncToLLVM rename.
Adrian Kuegel [Tue, 8 Mar 2022 07:55:55 +0000 (08:55 +0100)]
[mlir][Bazel] Adjust regarding StandardToLLVM -> FuncToLLVM rename.

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

2 years agoRevert "[CMake][compiler-rt] Make CRT separately buildable"
Petr Hosek [Tue, 8 Mar 2022 07:59:29 +0000 (23:59 -0800)]
Revert "[CMake][compiler-rt] Make CRT separately buildable"

This reverts commit ed28461e2716fda004f4f55654ef33bc8c78f203 since
it broke the VE bot.

2 years ago[NewPM][Inliner] Make inlined calls to functions in same SCC as callee exponentially...
Arthur Eubanks [Mon, 7 Mar 2022 18:17:09 +0000 (10:17 -0800)]
[NewPM][Inliner] Make inlined calls to functions in same SCC as callee exponentially expensive

Introduce a new attribute "function-inline-cost-multiplier" which
multiplies the inline cost of a call site (or all calls to a callee) by
the multiplier.

When processing the list of calls created by inlining, check each call
to see if the new call's callee is in the same SCC as the original
callee. If so, set the "function-inline-cost-multiplier" attribute of
the new call site to double the original call site's attribute value.
This does not happen when the original call site is intra-SCC.

This is an alternative to D120584, which marks the call sites as
noinline.

Hopefully fixes PR45253.

Reviewed By: davidxl

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

2 years ago[MLIR][OpDSL] Silence warning (NFC)
Lorenzo Chelini [Tue, 8 Mar 2022 07:30:20 +0000 (08:30 +0100)]
[MLIR][OpDSL] Silence warning (NFC)

2 years ago[AMDGPU] Set noclobber metadata on loads instead of cast to constant
Stanislav Mekhanoshin [Mon, 7 Mar 2022 23:53:16 +0000 (15:53 -0800)]
[AMDGPU] Set noclobber metadata on loads instead of cast to constant

A load via pointer cast to constant will return true from
pointsToConstantMemory which is not necessarily so.

Fixes: SWDEV-326463

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

2 years ago[CMake][compiler-rt] Make CRT separately buildable
Petr Hosek [Mon, 28 Feb 2022 20:21:11 +0000 (12:21 -0800)]
[CMake][compiler-rt] Make CRT separately buildable

This is useful when building a complete toolchain to ensure that CRT
is built after builtins but before the rest of the compiler-rt.

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

2 years ago[CSKY] Enable TargetAsmStreamer/ELFStreamer and support asm directive of csky_attribute
Zi Xuan Wu [Mon, 7 Mar 2022 10:28:13 +0000 (18:28 +0800)]
[CSKY] Enable TargetAsmStreamer/ELFStreamer and support asm directive of csky_attribute

Add support of parsing .csky_attribute directive and emit related target attributes in .csky.attribute section.
It does not emit attribute directive in assembly code, so only emit target attributes in ELF streamer.
In ELF streamer, it handles the header EFlag and the csky_attribute section which contains some attribute items.
The EFlag and attribute items are calculated from feature bits based on Subtarget.

2 years agoReland "[clang][debug] port clang-cl /JMC flag to ELF"
Yuanfang Chen [Mon, 7 Mar 2022 20:42:09 +0000 (12:42 -0800)]
Reland "[clang][debug] port clang-cl /JMC flag to ELF"

This relands commit 731347431976509823e38329a96fcbc69fe98cd2.

It failed on Windows/Mac because `-fjmc` is only checked for ELF targets.
Check the flag unconditionally instead and issue a warning for non-ELF targets.

2 years ago[flang] Remove unused variable in Allocatable.cpp
Valentin Clement [Tue, 8 Mar 2022 05:51:10 +0000 (06:51 +0100)]
[flang] Remove unused variable in Allocatable.cpp

Fix for buildbot failure: https://lab.llvm.org/buildbot/#/builders/180/builds/3532

2 years ago[OpenMP][FIX] Ensure flag to disable de-globalization works properly
Johannes Doerfert [Fri, 25 Feb 2022 00:50:37 +0000 (18:50 -0600)]
[OpenMP][FIX] Ensure flag to disable de-globalization works properly

If the user disables de-globalization we did not seed the AAHeapToShared
and AAHeapToStack but we still could end up with them through in-flight
lookups. With this patch we disable AAHeapToShared completely if the
user disabled de-globalization. Heap-2-stack is still run though.

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

2 years ago[OpenMP][CUDA] Use one event pool per device
Johannes Doerfert [Fri, 18 Feb 2022 17:49:00 +0000 (11:49 -0600)]
[OpenMP][CUDA] Use one event pool per device

An event pool, similar to the stream pool, needs to be kept per device.
For one, events are associated with cuda contexts which means we cannot
destroy the former after the latter. Also, CUDA documentation states
streams and events need to be associated with the same context, which
we did not ensure at all.

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

2 years ago[OpenMP] Allow to explicitly deinitialize device resources
Johannes Doerfert [Thu, 17 Feb 2022 22:04:12 +0000 (16:04 -0600)]
[OpenMP] Allow to explicitly deinitialize device resources

There are two problems this patch tries to address:
1) We currently free resources in a random order wrt. plugin and
   libomptarget destruction. This patch should ensure the CUDA plugin
   is less fragile if something during the deinitialization goes wrong.
2) We need to support (hard) pause runtime calls eventually. This patch
   allows us to free all associated resources, though we cannot
   reinitialize the device yet.

Follow up patch will associate one event pool per device/context.

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

2 years ago[OpenMP][NFCI] Use RAII lock guards in libomptarget where possible
Johannes Doerfert [Wed, 2 Mar 2022 19:34:24 +0000 (13:34 -0600)]
[OpenMP][NFCI] Use RAII lock guards in libomptarget where possible

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

2 years agoNFC. Improve isInnermostAffineForOp - drop unnecessary check
Uday Bondhugula [Mon, 7 Mar 2022 23:42:54 +0000 (05:12 +0530)]
NFC. Improve isInnermostAffineForOp - drop unnecessary check

Rewrite isInnermostAffineForOp utility to make it more direct/efficient.
Drop unnecessary check. NFC.

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

2 years ago[RISCV] Share PatFprFpr classes for F, D, and Zfh
Shao-Ce SUN [Tue, 8 Mar 2022 04:43:33 +0000 (12:43 +0800)]
[RISCV] Share PatFprFpr classes for F, D, and Zfh

Inspired by D115469

Reviewed By: craig.topper

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

2 years ago[ORC][JITLink] Fix MachO absolute symbol handling, add test case.
Lang Hames [Tue, 8 Mar 2022 04:37:33 +0000 (20:37 -0800)]
[ORC][JITLink] Fix MachO absolute symbol handling, add test case.

This patch removes the unintended resolution of locally scoped absolute symbols
(which was causing unexpected definition errors).

It stops using the JITSymbolFlags::Absolute flag (it isn't set or used elsewhere,
and causes mismatch-flags asserts), and adds JITSymbolFlags::Exported to default
scoped absolute symbols.

Finally, we now set the scope of absolute symbols correctly in
MachOLinkGraphBuilder.

2 years agoAMDGPU: Skip folding REG_SEQUENCE if found unknown regclasses for its users
Christudasan Devadasan [Wed, 2 Mar 2022 06:46:29 +0000 (12:16 +0530)]
AMDGPU: Skip folding REG_SEQUENCE if found unknown regclasses for its users

Use TII::getRegClass to return a valid regclass or a nullptr
if the RC is unknown for a given OpIdx. This fixes a potential
crash occurred while getting the RC from a variadic instruction.

Reviewed By: arsenm

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

2 years ago[X86] Add helper enum for ternary intrinsics
Phoebe Wang [Tue, 8 Mar 2022 03:18:41 +0000 (11:18 +0800)]
[X86] Add helper enum for ternary intrinsics

Reviewed By: RKSimon, LuoYuanke

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

2 years ago[SLP] Extract a helper for buildvector [nfc]
Philip Reames [Tue, 8 Mar 2022 03:11:32 +0000 (19:11 -0800)]
[SLP] Extract a helper for buildvector [nfc]

2 years ago[clang][dataflow] Fix nullptr dereferencing error.
Yitzhak Mandelbaum [Mon, 7 Mar 2022 21:16:28 +0000 (21:16 +0000)]
[clang][dataflow] Fix nullptr dereferencing error.

When pre-initializing fields in the environment, the code assumed that all
fields of a struct would be initialized. However, given limits on value
construction, that assumption is incorrect. This patch changes the code to drop
that assumption and thereby avoid dereferencing a nullptr.

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

2 years ago[RISCV] Add patterns for vector widening floating-point reduction instructions.
jacquesguan [Wed, 23 Feb 2022 07:30:10 +0000 (15:30 +0800)]
[RISCV] Add patterns for vector widening floating-point reduction instructions.

Add patterns for vector widening floating-point reduction instructions.

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

2 years ago[SLP] Fix spelling in a lambda name [NFC]
Philip Reames [Tue, 8 Mar 2022 02:52:51 +0000 (18:52 -0800)]
[SLP] Fix spelling in a lambda name [NFC]

2 years ago[BOLT][CMAKE] Remove CMake 3.13.4 incompatible parameter
Amir Ayupov [Tue, 8 Mar 2022 02:41:12 +0000 (18:41 -0800)]
[BOLT][CMAKE] Remove CMake 3.13.4 incompatible parameter

Remove `TYPE BIN` parameter that is introduced in CMake 3.14 and revert back to
the equivalent compatible form `DESTINATION ${CMAKE_INSTALL_BINDIR}`.

Addresses https://github.com/llvm/llvm-project/issues/54099

Reviewed By: rafauler

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

2 years agoChange "target.save-jit-objects" to "target.save-jit-objects-dir".
Jim Ingham [Tue, 8 Mar 2022 00:38:52 +0000 (16:38 -0800)]
Change "target.save-jit-objects" to "target.save-jit-objects-dir".
The old command wrote to CWD, which doesn't always work, and if it
didn't, there was no workaround (and it crashed on failure).  This
patch changed the setting to provide a directory to save the objects
to.

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

2 years ago[libcxx][AIX] Remove `LIBCXX-AIX-FIXME` in isalwayslockfree check after 86478c7ad8a7
Kai Luo [Tue, 8 Mar 2022 01:23:23 +0000 (01:23 +0000)]
[libcxx][AIX] Remove `LIBCXX-AIX-FIXME` in isalwayslockfree check after 86478c7ad8a7

The workaround has been removed via https://reviews.llvm.org/D119931, checks passed on AIX-32.

Reviewed By: ldionne, daltenty, jsji, #libc

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

2 years ago[flang] Fix module file missing USE for shadowed derived type
Peter Klausler [Fri, 25 Feb 2022 21:54:44 +0000 (13:54 -0800)]
[flang] Fix module file missing USE for shadowed derived type

When a module uses a derived type that is shadowed by a generic
interface, the module file was missing a USE statement for the
name.  Detect and handle this situation.

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

2 years ago[clang] Fix OpenMP critical hint parameter check
Peixin-Qiao [Tue, 8 Mar 2022 01:04:31 +0000 (09:04 +0800)]
[clang] Fix OpenMP critical hint parameter check

The paramemter of hint clause in OpenMP critical hint should be
non-negative. The omp_lock_hint_none is 0 in omp.h.

Reviewed By: Alexey Bataev

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

2 years ago[mlir][sparse][taco] Split the evaluate method into compile and compute.
Bixia Zheng [Mon, 7 Mar 2022 03:34:40 +0000 (19:34 -0800)]
[mlir][sparse][taco] Split the evaluate method into compile and compute.

This is to align with the PyTACO API better.

Modify an existing unit test to test the new routines.

Reviewed By: aartbik

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

2 years agoAdd JSON output option to llvm-remark-size-diff
Jessica Paquette [Mon, 7 Mar 2022 23:33:12 +0000 (15:33 -0800)]
Add JSON output option to llvm-remark-size-diff

This adds JSON output to llvm-remark-size-diff.

The goal here is to make it easy for external tools to consume output from
llvm-remark-size-diff. These tools could be used for automated size analysis.
(E.g. in CI).

To specify JSON output, use `--report_style=json`. JSON output can be
pretty-printed via `--pretty`.

With automation in mind, the schema looks like this:

```
"Files": {
  "A": <filename_a>
  "B": <filename_b>
},

"InBoth": [
   {
    "FunctionName": <function name>,
    "InstCount": [
       <count_in_a>,
       <count_in_b>
     ],
    "StackSize": [
       <count_in_a>,
       <count_in_b>
     ]
   },
   ...
]

"OnlyInA": [
   {
    "FunctionName": <function name>,
    "InstCount": [
       <count_in_a>,
       0
     ],
    "StackSize": [
       <count_in_a>,
       0
     ]
   },
   ...
]

"OnlyInB": [
    {
    "FunctionName": <function name>,
    "InstCount": [
       0,
       <count_in_b>
     ],
    "StackSize": [
       0,
       <count_in_b>
     ]
   },
   ...
]
```

A few notes:

- Filenames are included, because tools may want to combine many outputs
  together in some way (a big JSON file, a big CSV, or something.)

- Counts are represented as [a, b] so that a diff can be calculated via b - a.
  The original counts may be useful for size analysis (e.g. was this function
  extremely large before?) and so both are preserved.

- `OnlyInA` and `OnlyInB` have a 0 for one of the counts always. This is to
  make it easier for tools to share code between `OnlyInA`, `OnlyInB`, and
  `InBoth`.

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

2 years ago[WebAssembly] Add new target feature in support of 'extended-const' proposal
Sam Clegg [Mon, 7 Mar 2022 20:52:23 +0000 (12:52 -0800)]
[WebAssembly] Add new target feature in support of 'extended-const' proposal

We don't yet do anything when this feature is enabled, this change
just lays the ground work by accepting that there is such a feature.

See https://github.com/WebAssembly/extended-const

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

2 years ago[flang] Make uninitialized allocatable components explicitly NULL() in structure...
Peter Klausler [Mon, 28 Feb 2022 18:24:58 +0000 (10:24 -0800)]
[flang] Make uninitialized allocatable components explicitly NULL() in structure constructors

When a structure constructor does not initialize an allocatable component,
ensure that the typed expression representation contains an explicit
NULL() for the component.  Expression semantics already copies default
initialized expressions for nonallocatable components into structure
constructors.  This change is expected to simplify lowering.

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

2 years ago[NFC] Cleanup StandardInstrumentations
Arthur Eubanks [Tue, 8 Mar 2022 00:24:36 +0000 (16:24 -0800)]
[NFC] Cleanup StandardInstrumentations

2 years agoRevert "[libc++] Remove extension to support allocator<const T>"
Louis Dionne [Mon, 7 Mar 2022 22:34:17 +0000 (17:34 -0500)]
Revert "[libc++] Remove extension to support allocator<const T>"

This reverts commit bed3240bf7d196a17cc31f1c5b59b4721017e638.

I will need to add more tests for std::shared_ptr<T const> before
re-landing this.

2 years ago[AMDGPU] Add gfx10 assembler directive to specify shared VGPR count
Jacob Lambert [Fri, 7 Jan 2022 21:29:15 +0000 (13:29 -0800)]
[AMDGPU] Add gfx10 assembler directive to specify shared VGPR count

Reviewed By: rampitec

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

2 years agoRe-land [lld-macho][nfc] Don't use `stubsHelperIndex` in ICF hash
Jez Ng [Mon, 7 Mar 2022 21:34:02 +0000 (16:34 -0500)]
Re-land [lld-macho][nfc] Don't use `stubsHelperIndex` in ICF hash

Previous attempt was commit 112135e77444e8c8106efa77416af09f4b9a5012 and
reverted in d86d431814c836ec5579fc0b981e86c7fb81f2f2.

2 years ago[flang] Runtime validation of SPREAD(DIM=dim) argument
Peter Klausler [Wed, 23 Feb 2022 22:16:10 +0000 (14:16 -0800)]
[flang] Runtime validation of SPREAD(DIM=dim) argument

Crash when DIM= is not a valid dimension in the result.

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

2 years ago[MLIR][Presburger][NFC] Cleanup PresburgerSet
Groverkss [Mon, 7 Mar 2022 21:31:24 +0000 (03:01 +0530)]
[MLIR][Presburger][NFC] Cleanup PresburgerSet

This patch cleans up the interface to PresburgerSet. At a high level it does
the following changes:

  - Move member functions around to have constructors at top and print/dump
    at end.
  - Move a private function to be a static function instead.
  - Change member functions of type "getAllIntegerPolyhedron" to "getAllPolys"
    instead.
  - Improve documentation for PresburgerSet.

Reviewed By: arjunp

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

2 years ago[flang] Use faster path for default formatted character input
Peter Klausler [Wed, 23 Feb 2022 19:45:21 +0000 (11:45 -0800)]
[flang] Use faster path for default formatted character input

Rather than reading default character variables in formatted
input one byte at a time via NextInField(), skip and read
them via blocks of available buffer data.  This eliminates
a bottleneck that affected reads of large character values.
(It also exposed a problem with sequential reads with RECL=
set on the OPEN statement, so that's fixed too.)

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

2 years ago[OpenMP][libomp] Fix register constraint for tpause and umwait
Jonathan Peyton [Mon, 7 Mar 2022 20:54:07 +0000 (14:54 -0600)]
[OpenMP][libomp] Fix register constraint for tpause and umwait

Register constraint switched to "=q" which means very specifically (from
https://gcc.gnu.org/onlinedocs/gcc/Machine-Constraints.html#Machine-Constraints)

> Any register accessible as rl. In 32-bit mode, a, b, c, and d; in 64-bit
mode, any integer register.

Older gcc versions (8.x and below) were trying to use esi or edi for the
8 bit flag variable, but it wound up displaying this error in the end:

kmp_lock.cpp: In function ‘void __kmp_spin_backoff(kmp_backoff_t*)’:
kmp_lock.cpp:2684:1: error: unsupported size for integer register
Hence the correct restriction is "=q" instead of "=r".

Fixes: https://github.com/llvm/llvm-project/issues/53309
Differential Revision: https://reviews.llvm.org/D120519

2 years ago[mlir][Vector] Add patterns to reorder elementwise ops and broadcast/transpose ops.
Hanhan Wang [Mon, 7 Mar 2022 20:52:03 +0000 (12:52 -0800)]
[mlir][Vector] Add patterns to reorder elementwise ops and broadcast/transpose ops.

In quantized comutation, there are casting ops around computation ops.
Reorder the ops to make reduce-to-contract actually work.

Reviewed By: ThomasRaoux

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

2 years ago[flang] Lower allocate and deallocate statements
Valentin Clement [Mon, 7 Mar 2022 20:22:28 +0000 (21:22 +0100)]
[flang] Lower allocate and deallocate statements

This patch add the lowering for the allocate
and the deallocate statements.

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

Reviewed By: PeteSteinfeld

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

Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: V Donaldson <vdonaldson@nvidia.com>
2 years ago[libc++] Make common_iterator's proxy types into aggregates.
Arthur O'Dwyer [Mon, 7 Mar 2022 16:46:06 +0000 (11:46 -0500)]
[libc++] Make common_iterator's proxy types into aggregates.

Saves one move in each case, which is basically nothing perf-wise;
this is more about simplifying the code.

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

2 years ago[sancov] Don't instrument calls to bitcast funcs: they're not indirect.
Ahmed Bougacha [Mon, 7 Mar 2022 20:43:37 +0000 (12:43 -0800)]
[sancov] Don't instrument calls to bitcast funcs: they're not indirect.

Currently, when instrumenting indirect calls, this uses
CallBase::getCalledFunction to determine whether a given callsite is
eligible.

However, that returns null if:
  this is an indirect function invocation or the function signature
  does not match the call signature.

So, we end up instrumenting direct calls where the callee is a bitcast
ConstantExpr, even though we presumably don't need to.

Use isIndirectCall to ignore those funky direct calls.

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

2 years agoRevert "[clang][debug] port clang-cl /JMC flag to ELF"
Yuanfang Chen [Mon, 7 Mar 2022 20:40:15 +0000 (12:40 -0800)]
Revert "[clang][debug] port clang-cl /JMC flag to ELF"

This reverts commit 731347431976509823e38329a96fcbc69fe98cd2.

Break bots:
http://45.33.8.238/win/54551/step_7.txt
http://45.33.8.238/macm1/29590/step_7.txt

2 years ago[libcxxabi] Fix cmake order dependency wrt dllexporting
Martin Storsjö [Mon, 7 Mar 2022 18:32:52 +0000 (13:32 -0500)]
[libcxxabi] Fix cmake order dependency wrt dllexporting

If LIBCXX_ENABLE_SHARED isn't explicitly set on the cmake command
line, isn't set in the cache, and the libcxxabi project is configured
before libcxx, then LIBCXX_ENABLE_SHARED isn't defined yet. Once
the libcxx cmake project has been parsed, LIBCXX_ENABLE_SHARED would
have been set to its default value of ON.

This makes sure that the symbols are properly dllexported in such
a configuration scenario.

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

2 years ago[libc++] Remove extension to support allocator<const T>
Louis Dionne [Fri, 4 Mar 2022 14:54:29 +0000 (09:54 -0500)]
[libc++] Remove extension to support allocator<const T>

This extension is a portability trap for users, since no other standard
library supports it. Furthermore, the Standard explicitly allows
implementations to reject std::allocator<cv T>, so allowing it is
really going against the current.

This was discovered in D120684: this extension required `const_cast`ing
in `__construct_range_forward`, a fishy bit of code that can be removed
if we don't support the extension anymore.

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

2 years ago[AMDGPU] new gfx940 fp atomics
Stanislav Mekhanoshin [Thu, 3 Mar 2022 21:14:42 +0000 (13:14 -0800)]
[AMDGPU] new gfx940 fp atomics

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

2 years ago[flang] Make per-argument intrinsic error messages more localized
Peter Klausler [Wed, 23 Feb 2022 00:59:48 +0000 (16:59 -0800)]
[flang] Make per-argument intrinsic error messages more localized

A recent patch made it possible to emit more localized error messages
pertaining to actual arguments in non-intrinsic procedure references.
Use these new powers for good and make intrinsic error messages more
precise, too.

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

2 years ago[x86] reduce code duplication for select of X86ISD::CMP; NFC
Sanjay Patel [Mon, 7 Mar 2022 19:42:39 +0000 (14:42 -0500)]
[x86] reduce code duplication for select of X86ISD::CMP; NFC

2 years ago[x86] add tests for mask+cmp; NFC
Sanjay Patel [Mon, 7 Mar 2022 18:39:09 +0000 (13:39 -0500)]
[x86] add tests for mask+cmp; NFC

2 years ago[x86] remove unnecessary decorations in test file; NFC
Sanjay Patel [Mon, 7 Mar 2022 17:26:16 +0000 (12:26 -0500)]
[x86] remove unnecessary decorations in test file; NFC

2 years ago[lldb] Format g_color_tokens as a table (NFC)
Jonas Devlieghere [Mon, 7 Mar 2022 20:12:49 +0000 (12:12 -0800)]
[lldb] Format g_color_tokens as a table (NFC)

This makes editing the table easier and mistakes more obvious.

2 years ago[lldb] Support "bright" ANSI colors
Jonas Devlieghere [Mon, 7 Mar 2022 20:09:22 +0000 (12:09 -0800)]
[lldb] Support "bright" ANSI colors

Support ANSI escape codes for bright colors variants. Most modern
terminals support them. LLDB is not using them in any of its defaults,
but they're useful for people who want to modify their preferred ANSI
prefix/suffix.

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

2 years ago[AMDGPU] Add v_mov_b64 gfx940 opcode
Stanislav Mekhanoshin [Fri, 4 Mar 2022 19:49:34 +0000 (11:49 -0800)]
[AMDGPU] Add v_mov_b64 gfx940 opcode

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

2 years ago[IVDescriptors] Bail out instead of asserting that order is expected.
Florian Hahn [Mon, 7 Mar 2022 19:57:26 +0000 (19:57 +0000)]
[IVDescriptors] Bail out instead of asserting that order is expected.

When dealing with multiple phis that depend on each other, the order
might have been changed and may not match the expectation. If that
happens, bail out, rather than asserting.

Fixes https://github.com/llvm/llvm-project/issues/54218
Fixes https://github.com/llvm/llvm-project/issues/54233
Fixes https://github.com/llvm/llvm-project/issues/54254

2 years ago[Hexagon] Handle v2f16 in build_vector in isel
Krzysztof Parzyszek [Mon, 7 Mar 2022 19:27:41 +0000 (11:27 -0800)]
[Hexagon] Handle v2f16 in build_vector in isel

2 years ago[AMDGPU] gfx940 uses new names for coherency bits
Stanislav Mekhanoshin [Wed, 2 Mar 2022 23:27:25 +0000 (15:27 -0800)]
[AMDGPU] gfx940 uses new names for coherency bits

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

2 years agoFix buildbots after https://reviews.llvm.org/D120755.
Greg Clayton [Mon, 7 Mar 2022 19:31:21 +0000 (11:31 -0800)]
Fix buildbots after https://reviews.llvm.org/D120755.

This improves this test a lot because before when using the "attachCommands" to run the following commands:

(lldb) target create -d /path/to/a.out
(lldb) process launch

This was racy as it wasn't stopping the program at the entry point, and the process might run to completion before we can even debug it. With the recent changes to the "attachCommands" we were waiting for the process to stop, but the process might be exited already, and that _should_ have caused the attach to fail since there was no process to attach to. By adding "--stop-at-entry" to the process launch, we ensure this should be less racy and give us a valid process to attach to.

2 years ago[libc] Align the stack pointer in the start function.
Siva Chandra Reddy [Mon, 7 Mar 2022 09:00:14 +0000 (09:00 +0000)]
[libc] Align the stack pointer in the start function.

The loader TLS test for x86_64, which now passes, has been enabled.
A future change should enable the test for aarch64 as well.

Reviewed By: jeffbailey

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

2 years ago[flang] Avoid crash case in provenance mapping
Peter Klausler [Fri, 18 Feb 2022 19:15:08 +0000 (11:15 -0800)]
[flang] Avoid crash case in provenance mapping

When a contiguous range of a cooked character stream is being
mapped to a range of source provenance, the code was assuming
that the "end()" position of the input range -- being the character
immediately after the range -- would also follow the range's
source provenance.  This isn't always the case.

Modify the code to work with the true last character of the
input range (at end()-1) and to also cope with cases when that
last position truly maps to an earlier provenance, which can happen
when the prescanner has inserted a space into the cooked character
stream.

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

2 years ago[AMDGPU] Fix uninitialized value after 8d0c34fd4f
Austin Kerbow [Mon, 7 Mar 2022 19:31:12 +0000 (11:31 -0800)]
[AMDGPU] Fix uninitialized value after 8d0c34fd4f

2 years ago[AMDGPU] gfx940: support V_FMAMK_F32 and V_FMAAK_F32
Stanislav Mekhanoshin [Tue, 1 Mar 2022 21:39:57 +0000 (13:39 -0800)]
[AMDGPU] gfx940: support V_FMAMK_F32 and V_FMAAK_F32

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

2 years ago[MTE] Add NT_ANDROID_TYPE_MEMTAG
Mitch Phillips [Thu, 3 Mar 2022 18:48:05 +0000 (10:48 -0800)]
[MTE] Add NT_ANDROID_TYPE_MEMTAG

This ELF note is aarch64 and Android-specific. It specifies to the
dynamic loader that specific work should be scheduled to enable MTE
protection of stack and heap regions.

Current synthesis of the ".note.android.memtag" ELF note is done in the
Android build system. We'd like to move that to the compiler, and this
is the first step.

Reviewed By: MaskRay, jhenderson

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

2 years ago[RISCV] Rename 'SplatOperand' to 'ScalarOperand'. NFC
Craig Topper [Mon, 7 Mar 2022 19:12:17 +0000 (11:12 -0800)]
[RISCV] Rename 'SplatOperand' to 'ScalarOperand'. NFC

vslide1up/down have this flag set, but the value isn't a splat.
Rename for clarity.

Reviewed By: khchen

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

2 years ago[LegalizeTypes][ARM][X86] Change ExpandIntRes_ABS to use sra+xor+sub.
Craig Topper [Sat, 5 Mar 2022 02:53:54 +0000 (18:53 -0800)]
[LegalizeTypes][ARM][X86] Change ExpandIntRes_ABS to use sra+xor+sub.

Previously we used sra+add+xor if ADDCARRY is supported. This changes
to sra+xor+sub is SUBCARRY is available.

This is consistent with the recent change to the default expansion
in LegalizeDAG.

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

2 years ago[mlir][NFC] Remove FuncOp overload of NestedPattern::match
River Riddle [Sat, 5 Mar 2022 03:45:00 +0000 (19:45 -0800)]
[mlir][NFC] Remove FuncOp overload of NestedPattern::match

This method is redundant with the Operation* overload, and is an artifact of when
FuncOp wasn't an operation.

2 years ago[mlir][NFC] Drop a few dead forward declarations of FuncOp
River Riddle [Sat, 5 Mar 2022 03:41:15 +0000 (19:41 -0800)]
[mlir][NFC] Drop a few dead forward declarations of FuncOp

2 years ago[mlir][NFC] Rename StandardToLLVM to FuncToLLVM
River Riddle [Tue, 1 Mar 2022 22:53:41 +0000 (14:53 -0800)]
[mlir][NFC] Rename StandardToLLVM to FuncToLLVM

The current StandardToLLVM conversion patterns only really handle
the Func dialect. The pass itself adds patterns for Arithmetic/CFToLLVM, but
those should be/will be split out in a followup. This commit focuses solely
on being an NFC rename.

Aside from the directory change, the pattern and pass creation API have been renamed:
 * populateStdToLLVMFuncOpConversionPattern -> populateFuncToLLVMFuncOpConversionPattern
 * populateStdToLLVMConversionPatterns -> populateFuncToLLVMConversionPatterns
 * createLowerToLLVMPass -> createConvertFuncToLLVMPass

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

2 years ago[pseudo] Strip comments for TokenStream.
Haojian Wu [Mon, 7 Mar 2022 09:47:38 +0000 (10:47 +0100)]
[pseudo] Strip comments for TokenStream.

Add a utility function to strip comments from a "raw" tokenstream. The
derived stream will be fed to the GLR parser (for early testing).

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

2 years ago[OpenMP] libomp: implemented task priorities.
AndreyChurbanov [Mon, 7 Mar 2022 19:24:18 +0000 (22:24 +0300)]
[OpenMP] libomp: implemented task priorities.

Before this patch task priorities were ignored, that was a valid implementation
as the task priority is a hint according to OpenMP specification.

Implemented shared list of sorted (high -> low) task deques one per task
priority value. Tasks execution changed to first check if priority tasks ready
for execution exist, and these tasks executed before others;
otherwise usual tasks execution mechanics work.

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

2 years ago[libc++][AIX][test] Enable put_double/long_double locale tests
Jinsong Ji [Mon, 7 Mar 2022 19:08:57 +0000 (14:08 -0500)]
[libc++][AIX][test] Enable put_double/long_double locale tests

AIX print -0.0 , inf, nan differently, which are causing the test
failures. We are OK for most other tests.

This patch remove the tests related these limitations conditionally on AIX,
so that we can enable the other tests to avoid losing test coverage.

The general direction is:

```
if strings don't differ between environments, keep the string literal "INF" and the padding, instead of folding them into variables.
```

Reviewed By: ldionne, #libc, Mordante

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

2 years ago[pseudo] empty parameter-declaration should be allowed in lambda declarator.
Haojian Wu [Mon, 7 Mar 2022 09:13:12 +0000 (10:13 +0100)]
[pseudo] empty parameter-declaration should be allowed in lambda declarator.

This was an oversight, as we did a avoild-nullable modication to
parameter-declaration-clause.

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