platform/upstream/llvm.git
2 years agoAtomicExpand: Add some more overaligned atomic tests
Matt Arsenault [Tue, 20 Sep 2022 21:57:40 +0000 (17:57 -0400)]
AtomicExpand: Add some more overaligned atomic tests

2 years agoAtomicExpand: Use llvm.ptrmask instead of ptrtoint
Matt Arsenault [Tue, 20 Sep 2022 19:29:47 +0000 (15:29 -0400)]
AtomicExpand: Use llvm.ptrmask instead of ptrtoint

This removes the ptrtoint from the load's pointer operand, although we
can't entirely eliminate these to get the LSB shift. In a future
patch, this will avoid ptrtoint in the case where the atomic is
overaligned to the word size.

2 years ago[C++2a] P0634r3: Down with typename!
Nicolas Lesser [Wed, 7 Sep 2022 00:33:54 +0000 (20:33 -0400)]
[C++2a] P0634r3: Down with typename!

This patch implements P0634r3 that removes the need for 'typename' in certain contexts.

For example,

```
template <typename T>
using foo = T::type; // ok
```

This is also allowed in previous language versions as an extension, because I think it's pretty useful. :)

Reviewed By: #clang-language-wg, erichkeane

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

2 years agoAdd missing `struct` keyword to the test p2-2.cpp
Alan Zhao [Sat, 24 Sep 2022 00:09:30 +0000 (17:09 -0700)]
Add missing `struct` keyword to the test p2-2.cpp

While working on D53847, I noticed that this test would fail once we
started recognizing the types in the modified `export` statement [0].
The tests would fail because Clang would emit a "declaration does not
declare anything" diagnostic instead of the expected namespace scope
diagnostic.

I believe that the test is currently incorrectly passing because Clang
doesn't parse the type and therefore doesn't treat the statement as a
declaration. My understanding is that the intention of this test case is
that it wants to export a `struct` type, which I believe requires a
`struct` keyword, even for types with template parameters. With this
change, the only error with these two statements should be the
namespace scope issue.

[0]: https://reviews.llvm.org/D53847?id=462032#inline-1297053

Reviewed By: erichkeane

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

2 years agoMoving some C papers around on the status page; NFC
Aaron Ballman [Wed, 28 Sep 2022 16:37:12 +0000 (12:37 -0400)]
Moving some C papers around on the status page; NFC

These three are basically related to the TS 18661 integration, so now
they're grouped there.

2 years ago[clang][msan] Turn on -fsanitize-memory-param-retval by default
Arthur Eubanks [Tue, 27 Sep 2022 00:41:37 +0000 (17:41 -0700)]
[clang][msan] Turn on -fsanitize-memory-param-retval by default

This eagerly reports use of undef values when passed to noundef
parameters or returned from noundef functions.

This also decreases binary sizes under msan.

To go back to the previous behavior, pass `-fno-sanitize-memory-param-retval`.

Reviewed By: vitalybuka, MaskRay

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

2 years ago[AggressiveInstCombine] Combine consecutive loads which are being merged to form...
bipmis [Wed, 28 Sep 2022 16:32:47 +0000 (17:32 +0100)]
[AggressiveInstCombine] Combine consecutive loads which are being merged to form a wider load.

The patch simplifies some of the patterns as below

1. (ZExt(L1) << shift1) | (ZExt(L2) << shift2) -> ZExt(L3) << shift1
2. (ZExt(L1) << shift1) | ZExt(L2) -> ZExt(L3)

The pattern is indicative of the fact that the loads are being merged to a wider load and the only use of this pattern is with a wider load. In this case for a non-atomic/non-volatile loads reduce the pattern to a combined load which would improve the cost of inlining, unrolling, vectorization etc.

Fix the error reported on reverse load merge.

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

2 years ago[flang] Add co_broadcast to the list of intrinsics
Katherine Rasmussen [Thu, 25 Aug 2022 21:33:59 +0000 (14:33 -0700)]
[flang] Add co_broadcast to the list of intrinsics

Add the collective subroutine, co_broadcast, to the list
of intrinsic subroutines. Add co_broadcast to the check
for coindexed objects for the first, third, and fourth dummy
arguments. Update the co_broadcast semantics test.

Reviewed By: jeanPerier

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

2 years ago[RISCV][CodeGen][NFC] Add fixed vector type test cases for llvm.round.*
eopXD [Wed, 28 Sep 2022 10:04:29 +0000 (03:04 -0700)]
[RISCV][CodeGen][NFC] Add fixed vector type test cases for llvm.round.*

Reviewed By: reames

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

2 years agoremove LE,BE labels inserted incorrectly
bipmis [Wed, 28 Sep 2022 16:07:17 +0000 (17:07 +0100)]
remove LE,BE labels inserted incorrectly

2 years ago[InstCombine] fold select shuffles with shared operand together
Sanjay Patel [Wed, 28 Sep 2022 15:22:52 +0000 (11:22 -0400)]
[InstCombine] fold select shuffles with shared operand together

We don't combine generic shuffles together in IR, but select
shuffles are a special-case because a select shuffle of a
select shuffle is just another select shuffle; codegen is
expected to efficiently lower those (select shuffles are also
the canonical form of a vector select with constant condition).

2 years ago[InstCombine] add tests for shuffle-of-shuffle; NFC
Sanjay Patel [Tue, 27 Sep 2022 22:00:59 +0000 (18:00 -0400)]
[InstCombine] add tests for shuffle-of-shuffle; NFC

2 years agoAdd reverse load tests to test load combine patch
bipmis [Wed, 28 Sep 2022 15:50:51 +0000 (16:50 +0100)]
Add reverse load tests to test load combine patch

2 years ago[clang][DR2621] using enum NAME lookup fix
Nathan Sidwell [Wed, 14 Sep 2022 17:42:34 +0000 (10:42 -0700)]
[clang][DR2621] using enum NAME lookup fix

Although using-enum's grammar is 'using elaborated-enum-specifier',
the lookup for the enum is ordinary lookup (and not the tagged-type
lookup that normally occurs wth an tagged-type specifier).  Thus (a)
we can find typedefs and (b) do not find enum tags hidden by a non-tag
name (the struct stat thing).

This reimplements that part of using-enum handling, to address DR2621,
where clang's behaviour does not match std intent (and other
compilers).

Reviewed By: aaron.ballman

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

2 years ago[mlir] Add macro for enabling all generated pass declarations
rkayaith [Tue, 27 Sep 2022 21:23:59 +0000 (17:23 -0400)]
[mlir] Add macro for enabling all generated pass declarations

Currently the generated pass declarations have to be enabled per-pass
using multiple `GEN_PASS_DECL_{PASSNAME}` defines. This adds
`GEN_PASS_DECL`, which enables the declarations for all passes in the
group with a single macro. This is convenient for cases where a single
header is used for all passes in the group.

Reviewed By: mehdi_amini, mscuttari

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

2 years ago[amdgpu] Error, instead of miscompile, anonymous kernels using lds
Jon Chesterfield [Wed, 28 Sep 2022 15:30:01 +0000 (16:30 +0100)]
[amdgpu] Error, instead of miscompile, anonymous kernels using lds

The association between kernel and struct is done by symbol name.
This doesn't work robustly for anonymous kernels as shown by the modified
test case.

An alternative association between function and struct can be constructed
if necessary, probably though metadata, but on the basis that we currently
miscompile anonymous kernels and that they are difficult to construct from
application code and difficult to call from the runtime, this patch makes
it a fatal error for now.

Reviewed By: arsenm

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

2 years ago[AAPointerInfo] OffsetInfo: Unassigned is distinct from Unknown
Sameer Sahasrabuddhe [Tue, 27 Sep 2022 05:19:56 +0000 (10:49 +0530)]
[AAPointerInfo] OffsetInfo: Unassigned is distinct from Unknown

A User like the PHINode may be visited multiple times for the same pointer along
different def-use edges. The uninitialized state of OffsetInfo at the first
visit needs to be distinct from the Unknown value that may be assigned after
processing the PHINode. Without that, a PHINode with all inputs Unknown is never
followed to its uses. This results in incorrect optimization because some
interfering accessess are missed.

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

2 years agoRevert "[FunctionAttrs] Infer precise FMRB"
Benjamin Kramer [Wed, 28 Sep 2022 14:53:45 +0000 (16:53 +0200)]
Revert "[FunctionAttrs] Infer precise FMRB"

This reverts commit 97dfa536260c434e68913129d79d863b26c1c179.

It can make DSE crash. Reduced test case at
https://reviews.llvm.org/P8291

2 years ago[lld-macho] Don't create entries in isecPriorities during sorting (NFC)
Daniel Bertalan [Wed, 28 Sep 2022 14:23:18 +0000 (16:23 +0200)]
[lld-macho] Don't create entries in isecPriorities during sorting (NFC)

If a value for a given key is not present, `DenseMap::operator[]`
default-constructs one, which is wasteful when we don't do anything with
it afterwards. Fix it by calling `lookup()` instead which only returns
the default value, but does not modify the map.

This speeds up linking a fair bit when only a small portion of all
sections are specified in the order file, like in the case of Chromium
Framework:

      N           Min           Max        Median           Avg        Stddev
  x  25      3.727684     3.8808699      3.753552     3.7702461     0.0397282
  +  25     3.6469049     3.7523289     3.6764321     3.6841622   0.025525047
  Difference at 95.0% confidence
   -0.0860839 +/- 0.0189924
   -2.28324% +/- 0.503745%
   (Student's t, pooled s = 0.0333906)

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

2 years agoAMDGPU: Make various vector undefs legal
Matt Arsenault [Tue, 27 Sep 2022 03:07:49 +0000 (23:07 -0400)]
AMDGPU: Make various vector undefs legal

Surprisingly these were getting legalized to something
zero initialized.

This fixes an infinite loop when combining some vector types.
Also fixes zero initializing some undef values.

SimplifyDemandedVectorElts / SimplifyDemandedBits are not checking
for the legality of the output undefs they are replacing unused
operations with. This resulted in turning vectors into undefs
that were later re-legalized back into zero vectors.

2 years ago[AArch64][SVE] Expand gather index to 32 bits instead of 64 bits
Matt Devereau [Thu, 28 Jul 2022 09:18:18 +0000 (09:18 +0000)]
[AArch64][SVE] Expand gather index to 32 bits instead of 64 bits

For gathers which load in 8 and 16 bit data then use that data
as an index, the index can be extended to 32 bits instead of
64 bits

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

2 years ago[mlir] Use hip's config mode to find libraries
Krzysztof Drewniak [Tue, 27 Sep 2022 15:41:09 +0000 (15:41 +0000)]
[mlir] Use hip's config mode to find libraries

Instead of using find_package(HIP) to find FindHIP.cmake, which
doesn't seem to be the preferred way to find HIP anymore, use
find_package(hip CONFIG) to find the HIP configuration. Give
preference to ${ROCM_PATH} over ${ROCM_PATH}/hip in order to handle
the fact that newer ROCm versions prefer the include path to use
${ROCM_PATH}/include/hip over ${ROCM_PATH}/hip/innclude/hip (the
latter throws up a bunch of deprecation warnings)

Then, instead of trying to manually find the host-side headers and
runtime library by hand, use the hip::host and hip::amdhip64 libraries
that the config module defines.

This makes the CMake config much less error-prone and brings it in
line with the recommended approach to finding HIP.

Reviewed By: mehdi_amini

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

2 years agoRevert "[AARCH64][CostModel] Modified the cost of mask vector load/store"
Florian Hahn [Wed, 28 Sep 2022 14:35:12 +0000 (15:35 +0100)]
Revert "[AARCH64][CostModel] Modified the cost of mask vector load/store"

This reverts commit 1c62af3e23cab41074f7ce0ba86a93bea82b99b9.

The commit causes the test below to fail. Revert for now to get the bots
back to green.

Failing test:
lvm/test/Transforms/LoopVectorize/AArch64/masked-op-cost.ll

2 years ago[cmake] Export GetHostTriple.cmake
Nikita Popov [Tue, 27 Sep 2022 10:55:35 +0000 (12:55 +0200)]
[cmake] Export GetHostTriple.cmake

GetHostTriple is used by the runtimes build, so this cmake file
must be exported. Otherwise it is not possible to build runtimes
against a previously built LLVM.

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

2 years ago[AArch64] break non-temporal loads over 256 into 256-loads and a smaller load
Florian Hahn [Wed, 28 Sep 2022 14:20:25 +0000 (15:20 +0100)]
[AArch64] break non-temporal loads over 256 into 256-loads and a smaller load

Currently over 256 non-temporal loads are broken inefficently. For example, `v17i32` gets broken into 2 128-bit loads. It is better if we can use
256-bit loads instead.

Reviewed By: fhahn

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

2 years ago[amdgpu][nfc] Allocate kernel-specific LDS struct deterministically
Jon Chesterfield [Wed, 28 Sep 2022 13:55:14 +0000 (14:55 +0100)]
[amdgpu][nfc] Allocate kernel-specific LDS struct deterministically

A kernel may have an associated struct for laying out LDS variables.
This patch puts that instance, if present, at a deterministic address by
allocating it at the same time as the module scope instance.

This is relatively likely to be where the instance was allocated anyway (~NFC)
but will allow later patches to calculate where a given field can be found,
which means a function which is only reachable from a single kernel will be
able to access a LDS variable with zero overhead. That will be particularly
helpful for applications that instantiate a function template containing LDS
variables once per kernel.

Reviewed By: arsenm

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

2 years ago[AArch64] Correct v9.x-a Features
Archibald Elliott [Mon, 26 Sep 2022 15:26:30 +0000 (16:26 +0100)]
[AArch64] Correct v9.x-a Features

A change to D109517 during review stated it was disabling the crypto
extensions by default in armv9a, but it also ended up removing two other
non-crypto features: i8mm and bf16. This error was also made in D116158.

This patch re-adds those two extensions to the feature bitmaps for the
affected armv9a versions in the target parser.

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

2 years ago[ARM] Support fp16/bf16 using t constraint
Archibald Elliott [Fri, 23 Sep 2022 17:41:58 +0000 (18:41 +0100)]
[ARM] Support fp16/bf16 using t constraint

fp16 and bf16 values can be used in GCC's inline assembly using the "t"
constraint, which means "VFP floating-point registers s0-s31" - fp16 and
bf16 values are stored in S registers too.

This change ensures that LLVM is compatible with GCC for programs that
use fp16 and the 't' constraint.

Fixes #57753

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

2 years ago[flang] Use libm over pgmath for complex number intrinsics
David Truby [Mon, 26 Sep 2022 13:30:20 +0000 (13:30 +0000)]
[flang] Use libm over pgmath for complex number intrinsics

This patch changes the handling of complex number intrinsics that
have C libm equivalents to call into those instead of calling the
external pgmath library.

Currently complex numbers to integer powers are excluded as libm
has no powi equivalent function.

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

2 years ago[llvm-jitlink] Remove JITLinkSlabAllocator class
Anubhab Ghosh [Wed, 28 Sep 2022 01:51:42 +0000 (07:21 +0530)]
[llvm-jitlink] Remove JITLinkSlabAllocator class

This class was used for testing JITLink with -noexec option and
also included slab allocation support. Its functionality has been
replaced with InProcessDeltaMapper and MapperJITLinkMemoryManager.

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

2 years ago[LLDB] Remove the bool + RegisterInfo& version of GetRegisterInfo
David Spickett [Fri, 23 Sep 2022 14:55:14 +0000 (14:55 +0000)]
[LLDB] Remove the bool + RegisterInfo& version of GetRegisterInfo

All callers have been converted to the optional version.

Depends on D134540

Reviewed By: clayborg

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

2 years ago[LLDB][AArch64] Move instruction emulation to optional GetRegisterInfo
David Spickett [Fri, 23 Sep 2022 14:47:06 +0000 (14:47 +0000)]
[LLDB][AArch64] Move instruction emulation to optional GetRegisterInfo

Depends on D134539

Reviewed By: clayborg

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

2 years ago[libc++] Remove MSVC tests checked into the libc++ test suite
Louis Dionne [Mon, 19 Sep 2022 18:56:19 +0000 (14:56 -0400)]
[libc++] Remove MSVC tests checked into the libc++ test suite

We should strive to have our own tests, except when there is overwhelming
value in using another standard library's existing tests. The reason is
that it ensures that implementations don't all start relying on the same
interpretation of the Standard.

The unique_ptr tests did not add any test coverage AFAICT, and the
forward_like tests were moved to the style used everywhere in the
libc++ test suite.

Note that I got to this because this actually broke a downstream
configuration where we use -ffreestanding. The signature of main()
was not consistent with the signature we (need to) use everywhere
in the test suite.

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

2 years ago[AARCH64][CostModel] Modified the cost of mask vector load/store
liqinweng [Wed, 28 Sep 2022 11:12:06 +0000 (19:12 +0800)]
[AARCH64][CostModel] Modified the cost of mask vector load/store

Reviewed By: david-arm

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

2 years ago[SCEVExpander] Remove dead Root argument from expandCodeForImpl (NFC).
Florian Hahn [Wed, 28 Sep 2022 11:08:20 +0000 (12:08 +0100)]
[SCEVExpander] Remove dead Root argument from expandCodeForImpl (NFC).

The argument is unused and can be removed.

2 years ago[AMDGPU] Add MIMG NSA threshold configuration attribute
Carl Ritson [Wed, 28 Sep 2022 10:46:46 +0000 (19:46 +0900)]
[AMDGPU] Add MIMG NSA threshold configuration attribute

Make MIMG NSA minimum addresses threshold an attribute that can
be set on a function or configured via command line.
This enables frontend tuning which allows increased NSA usage
where beneficial.

Reviewed By: foad

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

2 years ago[LLDB][MIPS] Move instruction emulation to optional GetRegisterInfo
David Spickett [Fri, 23 Sep 2022 14:46:17 +0000 (14:46 +0000)]
[LLDB][MIPS] Move instruction emulation to optional GetRegisterInfo

Depends on D134538

Reviewed By: clayborg

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

2 years ago[LLDB][ARM] Move instruction emulation to optional GetRegisterInfo
David Spickett [Fri, 23 Sep 2022 14:45:37 +0000 (14:45 +0000)]
[LLDB][ARM] Move instruction emulation to optional GetRegisterInfo

Depends on D134537

Reviewed By: clayborg

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

2 years ago[RISCV] Add and update reverse mask tests, NFC
liqinweng [Wed, 28 Sep 2022 09:18:33 +0000 (17:18 +0800)]
[RISCV] Add and update reverse mask tests, NFC

Reviewed By: Jimerlife

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

2 years ago[LLDB] Move MIPS64/PPC64 and misc. to optional GetRegisterInfo
David Spickett [Fri, 23 Sep 2022 14:42:25 +0000 (14:42 +0000)]
[LLDB] Move MIPS64/PPC64 and misc. to optional GetRegisterInfo

Depends on D134536

Reviewed By: clayborg

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

2 years ago[LoopDeletion] Forget block and loop dispositions after deleting loop.
Florian Hahn [Wed, 28 Sep 2022 10:33:42 +0000 (11:33 +0100)]
[LoopDeletion] Forget block and loop dispositions after deleting loop.

After deleting a loop, the block and loop dispositions need to be
cleared. As we don't know which SCEVs in the loop/blocks may be
impacted, completely clear the cache. This should also fix some cases
where deleted loops remained in the LoopDispositions cache.

This fixes a verification failure surfaced by D134531.

Reviewed By: mkazantsev

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

2 years ago[libc++] implement "pair" section of P2321R2 `zip`
Hui Xie [Tue, 9 Aug 2022 13:56:30 +0000 (14:56 +0100)]
[libc++] implement "pair" section of P2321R2 `zip`

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

2 years ago[SLP] ScalarizationOverheadBuilder - demand all elements for scalarization if the...
Simon Pilgrim [Wed, 28 Sep 2022 10:03:29 +0000 (11:03 +0100)]
[SLP] ScalarizationOverheadBuilder - demand all elements for scalarization if the extraction index is unknown / out of bounds

Workaround for a chromium bug reported on D134605 - test case will be added later

2 years agoDocument use of Co-author-by git tag.
Kristof Beyls [Tue, 27 Sep 2022 14:40:49 +0000 (16:40 +0200)]
Document use of Co-author-by git tag.

We are already using the Co-author-by git tag, but don't have documentation in
our developer policy about it. Fix that.

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

2 years ago[lldb][COFF] Map symbols without base+complex type as 'Data' type
Alvin Wong [Wed, 28 Sep 2022 09:46:27 +0000 (12:46 +0300)]
[lldb][COFF] Map symbols without base+complex type as 'Data' type

Both LLD and GNU ld write global/static variables to the COFF symbol
table with `IMAGE_SYM_TYPE_NULL` and `IMAGE_SYM_DTYPE_NULL` type. Map
these symbols as 'Data' type in the symtab to allow these symbols to be
used in expressions and printable.

Reviewed By: labath, DavidSpickett

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

2 years ago[lldb][COFF] Add note to forwarder export symbols in symtab
Alvin Wong [Wed, 28 Sep 2022 09:45:38 +0000 (12:45 +0300)]
[lldb][COFF] Add note to forwarder export symbols in symtab

Forwarder exports do not point to a real function or variable. Instead
they point to a string describing which DLL and symbol to forward to.
Any imports which uses them will be redirected by the loader
transparently. These symbols do not have much use in LLDB, but keep them
just in case someone find it useful. Also set a synthesized name with
the forwarder string for informational purpose.

Reviewed By: labath

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

2 years ago[lldb][COFF] Load absolute symbols from COFF symbol table
Alvin Wong [Wed, 28 Sep 2022 09:45:23 +0000 (12:45 +0300)]
[lldb][COFF] Load absolute symbols from COFF symbol table

Reviewed By: labath

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

2 years ago[lldb][COFF] Match symbols from COFF symbol table to export symbols
Alvin Wong [Wed, 28 Sep 2022 09:44:03 +0000 (12:44 +0300)]
[lldb][COFF] Match symbols from COFF symbol table to export symbols

If a symbol is the same as an export symbol, mark it as 'Additional' to
prevent the duplicated symbol from being repeated in some commands (e.g.
`disas -n func`). If the RVA is the same but exported with a different
name, only synchronize the symbol types.

Reviewed By: labath

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

2 years ago[lldb][COFF] Improve info of symbols from export table
Alvin Wong [Wed, 28 Sep 2022 09:43:14 +0000 (12:43 +0300)]
[lldb][COFF] Improve info of symbols from export table

- Skip dummy/invalid export symbols.
- Make the export ordinal of export symbols visible when dumping the
  symtab.
- Stop setting the 'Debug' flag and set the 'External' flag instead to
  better match the meaning of export symbols.
- Try to guess the type (code vs data) of the symbol from section flags.

Reviewed By: labath

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

2 years ago[lldb][COFF] Rewrite ParseSymtab to list both export and symbol tables
Alvin Wong [Wed, 28 Sep 2022 09:40:37 +0000 (12:40 +0300)]
[lldb][COFF] Rewrite ParseSymtab to list both export and symbol tables

This reimplements `ObjectFilePECOFF::ParseSymtab` to replace the manual
data extraction with what `COFFObjectFile` already provides. Also use
`SymTab::AddSymbol` instead of resizing the SymTab then assigning each
elements afterwards.

Previously, ParseSymTab loads symbols from both the COFF symbol table
and the export table, but if there are any entries in the export table,
it overwrites all the symbols already loaded from the COFF symbol table.
Due to the change to use AddSymbols, this no longer happens, and so the
SymTab now contains all symbols from both tables as expected.

The export symbols are now ordered by ordinal, instead of by the name
table order.

In its current state, it is possible for symbols in the COFF symbol
table to be duplicated by those in the export table. This behaviour will
be modified in a separate change.

Reviewed By: labath

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

2 years agoFix MSVC "not all control paths return a value" warning. NFCI.
Simon Pilgrim [Wed, 28 Sep 2022 09:55:16 +0000 (10:55 +0100)]
Fix MSVC "not all control paths return a value" warning. NFCI.

2 years ago[LoongArch] Specify registers used in DWARF exception handling
wanglei [Wed, 28 Sep 2022 09:31:44 +0000 (17:31 +0800)]
[LoongArch] Specify registers used in DWARF exception handling

Defines LoongArch registers for getExceptionPointerRegister() and
getExceptionSelectorRegister().

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

2 years ago[vscode-mlir] Bump to version 0.0.11
River Riddle [Wed, 28 Sep 2022 09:50:06 +0000 (02:50 -0700)]
[vscode-mlir] Bump to version 0.0.11

Since version 0.10 we've:

* Added support for viewing/editing bytecode files

2 years ago[LLVM] Fix GetErrcMessages.cmake module for WoA
Muhammad Omair Javaid [Mon, 12 Sep 2022 11:46:04 +0000 (16:46 +0500)]
[LLVM] Fix GetErrcMessages.cmake module for WoA

GetErrcMessages.cmake module makes use of cmake's try_run which by
default builds its sources in debug mode unless configured with
CMAKE_TRY_COMPILE_CONFIGURATION. Debug builds on Windows sometimes fail
when appropraite DLLs are not included in path. Also on Windows on Arm
machines debug builds sometimes fail to link the correct debug DLLs.

To fix this I am setting CMAKE_TRY_COMPILE_CONFIGURATION to active build
configuration of currently configured LLVM project. This makes sure we
select same build type for try_run/try_compile cmake modules as
currently configured LLVM project.

Reviewed By: zero9178

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

2 years ago[LoopVectorize][Fix] Crash when invariant store address is calculated inside loop
Igor Kirillov [Fri, 9 Sep 2022 08:17:07 +0000 (09:17 +0100)]
[LoopVectorize][Fix] Crash when invariant store address is calculated inside loop

Fixes #57572

Generally LICM pass is responsible for sinking out code that calculates
invariant address inside loop as it only needed to be calculated once.
But in rare case it does not happen we will not be vectorizing the
loop.

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

2 years ago[LegalizeTypes] Use getVectorElementCount to avoid crash of scalable vector.
jacquesguan [Tue, 27 Sep 2022 08:37:25 +0000 (16:37 +0800)]
[LegalizeTypes] Use getVectorElementCount to avoid crash of scalable vector.

Reviewed By: RKSimon

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

2 years ago[AArch64][SVE] Remove redundant ptest after match/nmatch
Cullen Rhodes [Wed, 28 Sep 2022 08:01:58 +0000 (08:01 +0000)]
[AArch64][SVE] Remove redundant ptest after match/nmatch

These instructions are flag setting so the ptest is redundant, the
TableGen class wasn't setting the element size for the predicate causing
the checks in AArch64InstrInfo::optimizePTestInstr to fail.

2 years ago[AArch64][SVE] Precommit tests for redundant ptest after match/nmatch
Cullen Rhodes [Wed, 28 Sep 2022 07:45:27 +0000 (07:45 +0000)]
[AArch64][SVE] Precommit tests for redundant ptest after match/nmatch

2 years ago[MLIR] Fix after 4b27825.
Christian Sigg [Wed, 28 Sep 2022 08:15:41 +0000 (10:15 +0200)]
[MLIR] Fix after 4b27825.

The 'RUN' command was missing the input file argument.

2 years ago[TableGen] Only track reference locations if asked
River Riddle [Wed, 28 Sep 2022 07:47:48 +0000 (00:47 -0700)]
[TableGen] Only track reference locations if asked

Normal compilation doesn't care about tracking references,
and shouldn't pay the compilation time cost.

2 years ago[InstCombine] Add one more test for shl_trunc_icmp. nfc
Chenbing Zheng [Wed, 28 Sep 2022 07:39:52 +0000 (15:39 +0800)]
[InstCombine] Add one more test for shl_trunc_icmp. nfc

2 years ago[RISCV] Rename vp.ceil test functions
Fraser Cormack [Wed, 28 Sep 2022 05:45:47 +0000 (06:45 +0100)]
[RISCV] Rename vp.ceil test functions

These look like they were copy/pasted from vfabs-vp.ll

Reviewed By: eopXD

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

2 years ago[test][StackLifetime] Add simple cycle test
Vitaly Buka [Wed, 28 Sep 2022 07:08:33 +0000 (00:08 -0700)]
[test][StackLifetime] Add simple cycle test

2 years agoRevert "[ELF] --pack-dyn-relocs=android: scan relocation serially after D133003"
Fangrui Song [Wed, 28 Sep 2022 07:06:49 +0000 (07:06 +0000)]
Revert "[ELF] --pack-dyn-relocs=android: scan relocation serially after D133003"

This reverts commit bce6416775ea1577f0a7f82cc012cf0c1b9d9ce5.

The workaround is unneeded after 7dac9f4e481c9119a2205e869e07a643828f53db.

2 years ago[ELF] Make --pack-dyn-relocs=android compatible with parallel relocation scanning
Fangrui Song [Wed, 28 Sep 2022 06:58:58 +0000 (06:58 +0000)]
[ELF] Make --pack-dyn-relocs=android compatible with parallel relocation scanning

2 years ago[mlir:LSP] Add bullet for tablegen hover in the vscode section
River Riddle [Wed, 28 Sep 2022 06:56:51 +0000 (23:56 -0700)]
[mlir:LSP] Add bullet for tablegen hover in the vscode section

This allows hover documentation to show up in the vscode extension.

2 years ago[libc] Add implementation of pthread_once.
Siva Chandra Reddy [Tue, 27 Sep 2022 08:13:16 +0000 (08:13 +0000)]
[libc] Add implementation of pthread_once.

The existing thrd_once function has been refactored so that the
implementation can be shared between thrd_once and pthread_once
functions.

Reviewed By: michaelrj

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

2 years ago[mlir:LSP] Add a doc blurb for bytecode editing support
River Riddle [Wed, 28 Sep 2022 06:20:13 +0000 (23:20 -0700)]
[mlir:LSP] Add a doc blurb for bytecode editing support

This was missed when bytecode support was originally added.

2 years ago[TableGen:LSP] Resolve "go-to-def" on a let field to the base definition
River Riddle [Tue, 20 Sep 2022 08:45:17 +0000 (01:45 -0700)]
[TableGen:LSP] Resolve "go-to-def" on a let field to the base definition

This allows for go-to-def on the a `let` field to resolve to the definition
of the base class. This is kind of like how C++ works with go-to-def
from use->def->decl, with the decl in this case being the base definition
of the field.

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

2 years ago[TableGen:LSP] Add hover support for records and recordvals
River Riddle [Tue, 20 Sep 2022 08:11:09 +0000 (01:11 -0700)]
[TableGen:LSP] Add hover support for records and recordvals

This provides hover information for classes, defs, fields, and template
arguments. Like PDLL, this pulls documentation from the source code
when hovering over fields and records.

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

2 years ago[TableGen] Track reference locations of Records/RecordVals
River Riddle [Fri, 16 Sep 2022 22:06:51 +0000 (15:06 -0700)]
[TableGen] Track reference locations of Records/RecordVals

This is extremely useful for language tooling as it allows
for providing go-to-def/find-references/etc. for many
more situations than what is currently possible.

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

2 years ago[RISCV][NFC] Add test for extractelt of vector types that should be split.
jacquesguan [Tue, 27 Sep 2022 08:49:31 +0000 (16:49 +0800)]
[RISCV][NFC] Add test for extractelt of vector types that should be split.

Reviewed By: reames

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

2 years ago[Release] Add bump-version script.
Tobias Hieta [Thu, 15 Sep 2022 08:30:38 +0000 (10:30 +0200)]
[Release] Add bump-version script.

There are many files that needs to be updated when you
bump the version of LLVM. This script tries to automate
that in order to make the release managers job easier.

Reviewed By: kwk, hans, ldionne

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

2 years ago[flang] Move main variables static promotion from lowering into IsSaved
Jean Perier [Wed, 28 Sep 2022 06:35:08 +0000 (08:35 +0200)]
[flang] Move main variables static promotion from lowering into IsSaved

Currently, lowering is promoting main program array and character
variables that are not saved into static memory.

This causes issues with equivalence initial value images because
semantics is relying on IsSaved to build the initial value of variables
in static memory. It seems more robust to have IsSaved be the place
deciding if a variable needs to be in static memory (except for common
block members).

Move the logic to decide if a main program variable must be in static
memory into evaluate::IsSaved and add two options to semantics to
replace the llvm options that were used in lowering:
 - SaveMainProgram (off by default): save all main program variables.
 - SaveBigMainProgramVariables (on by default): save all main program
   variables that are bigger than 32 bytes.

The first options is required to run a few old programs that expect all
main program variables to be in bss (and therefore zero initialized).

The second option is added to allow performance testing: placing big
arrays in static memory seems a sane default to avoid blowing up the
stack with old programs that define big local arrays in the main
program, but since it is easier to prove that an alloca does not
escape/is not modified by calls, keeping big arrays on the stack could
yield improvements.

The logic of SaveBigMainProgramVariables is slightly changed compared to what
it was doing in lowering. The old code was placing all arrays and all
explicit length characters in static memory.
The new code is placing everything bigger than 32 bytes in static
memory. This has the advantages of being a simpler logic, and covering
the cases of scalar derived type with big array components or many
components. Small strings and arrays are now left on the stack (after
all, a character(1) can fit in register).

Note: I think it could have been nicer to add a single "integer" option
to set a threshold to place main program variables in static memory so
that this can be fine tuned by the drivers (SaveMainProgram would be
implemented by setting it to zero). But the language feature options are
not meant to carry integer options. Extending it for this seems an
overkill precedent, and placing it in SemanticsContext is weird (it is
a too low level option to be a bare member of SemanticsContext in my
opinion). So I just rolled my own dices and picked 32 for the sake of
simplicity.

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

2 years agoRevert "[Support] Class for response file expansion (NFC)"
Serge Pavlov [Wed, 28 Sep 2022 06:32:20 +0000 (13:32 +0700)]
Revert "[Support] Class for response file expansion (NFC)"

This reverts commit 6e491c48d6b9cadcc5b77f730dd83a1448197329.
There are missed changes in flang.

2 years ago[Bazel] NFC: Move ParseUtilities.h from 'hdrs' to 'srcs'.
Christian Sigg [Wed, 28 Sep 2022 06:29:00 +0000 (08:29 +0200)]
[Bazel] NFC: Move ParseUtilities.h from 'hdrs' to 'srcs'.

This is slightly cleaner.

2 years ago[NFC][StackLifetime] Rename local variable
Vitaly Buka [Wed, 28 Sep 2022 06:24:09 +0000 (23:24 -0700)]
[NFC][StackLifetime] Rename local variable

The next patch will require more generic name.

2 years ago[Bazel] Fix after 4b27825ba36d55779561c0a2c3c2f89f52d81303.
Christian Sigg [Wed, 28 Sep 2022 06:17:04 +0000 (08:17 +0200)]
[Bazel] Fix after 4b27825ba36d55779561c0a2c3c2f89f52d81303.

2 years ago[test][StackLifetime] Add new test created debugging an issue
Vitaly Buka [Wed, 28 Sep 2022 06:13:43 +0000 (23:13 -0700)]
[test][StackLifetime] Add new test created debugging an issue

The issue is not confirmened, but tests can stay.

2 years ago[NFC][StackLifetime] Remove local variable
Vitaly Buka [Wed, 28 Sep 2022 06:06:15 +0000 (23:06 -0700)]
[NFC][StackLifetime] Remove local variable

2 years ago[Support] Class for response file expansion (NFC)
Serge Pavlov [Sun, 21 Aug 2022 17:30:28 +0000 (00:30 +0700)]
[Support] Class for response file expansion (NFC)

Functions that implement expansion of response and config files depend
on many options, which are passes as arguments. Extending the expansion
requires new options, it in turn causes changing calls in various places
making them even more bulky.

This change introduces a class ExpansionContext, which represents set of
options that control the expansion. Its methods implements expansion of
responce files including config files. It makes extending the expansion
easier.

No functional changes.

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

2 years ago[Clang] Don't warn if deferencing void pointers in unevaluated context
Jun Zhang [Wed, 28 Sep 2022 04:30:02 +0000 (12:30 +0800)]
[Clang] Don't warn if deferencing void pointers in unevaluated context

After https://reviews.llvm.org/D134461, Clang will diagnose a warning if
trying to deference void pointers in C mode. However, this causes a lot
of noises when compiling a 5.19.11 Linux kernel.

This patch reduces the warning by marking deferencing void pointers in
unevaluated context OK, like `sizeof(*void_ptr)`, `typeof(*void_ptr)`
and etc.

Fixes https://github.com/ClangBuiltLinux/linux/issues/1720

Signed-off-by: Jun Zhang <jun@junz.org>
Differential Revision: https://reviews.llvm.org/D134702

2 years ago[LangRef][Doc] Fix warning for too short title underline
eopXD [Wed, 28 Sep 2022 02:53:28 +0000 (19:53 -0700)]
[LangRef][Doc] Fix warning for too short title underline

2 years ago[VP][RISCV] Add vp.floor, vp.round, vp.roundeven and their RISC-V support
eopXD [Tue, 27 Sep 2022 20:03:25 +0000 (13:03 -0700)]
[VP][RISCV] Add vp.floor, vp.round, vp.roundeven and their RISC-V support

Reviewed By: craig.topper

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

2 years ago[LoongArch] Expand FSIN/FCOS/FSINCOS/FPOW/FREM
gonglingqin [Wed, 28 Sep 2022 01:25:32 +0000 (09:25 +0800)]
[LoongArch] Expand FSIN/FCOS/FSINCOS/FPOW/FREM

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

2 years ago[mlir][sparse] Support sparse2sparse collapse for dynamic sizes
Anlun Xu [Tue, 27 Sep 2022 23:25:20 +0000 (16:25 -0700)]
[mlir][sparse] Support sparse2sparse collapse for dynamic sizes

This patch implements sparse2sparse collapse for operands with dynamic shape.

Reviewed By: aartbik

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

2 years agoRevert "[clang-doc] Add typedef/using information."
Haowei Wu [Wed, 28 Sep 2022 01:35:34 +0000 (18:35 -0700)]
Revert "[clang-doc] Add typedef/using information."

This reverts commit eed22583fd78d4d657fb70b99e62fbdc1f83b8f9, which
breaks clang build with -Werror.

2 years ago[HWASan] [NFC] use auto* over auto& for pointers
Florian Mayer [Wed, 28 Sep 2022 01:19:25 +0000 (18:19 -0700)]
[HWASan] [NFC] use auto* over auto& for pointers

2 years ago[mlir-opt] Support parsing operations other than 'builtin.module' as top-level
rkayaith [Wed, 28 Sep 2022 01:09:34 +0000 (21:09 -0400)]
[mlir-opt] Support parsing operations other than 'builtin.module' as top-level

This adds a `--no-implicit-module` option, which disables the insertion
of a top-level `builtin.module` during parsing. In this mode any op may
be top-level, however it's required that there be exactly one top-level
op in the source.

`parseSource{File,String}` now support `Operation *` as the container op
type, which disables the top-level-op-insertion behaviour.

Following patches will add the same option to the other tools as well.

Depends on D133644

Reviewed By: rriddle

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

2 years ago[mlir-opt] Delay pass manager creation until after parsing
rkayaith [Fri, 9 Sep 2022 01:39:55 +0000 (21:39 -0400)]
[mlir-opt] Delay pass manager creation until after parsing

Currently the pass manager is created before parsing, which requires an
assumption that the top-level operation will be `builtin.module`.
Delaying the creation allows for using the parsed top-level operation as
the PassManager operation instead.

A followup change will allow for parsing top-level operations other than
`builtin.module`.

Reviewed By: rriddle

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

2 years ago[RISCV] Lower BUILD_VECTOR to RISCVISD::VID_VL if it is floating-point type.
Han-Kuan Chen [Tue, 27 Sep 2022 05:48:52 +0000 (22:48 -0700)]
[RISCV] Lower BUILD_VECTOR to RISCVISD::VID_VL if it is floating-point type.

Reviewed By: craig.topper

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

2 years ago[gn build] re-add hlsl.h after e432108bf254
Nico Weber [Wed, 28 Sep 2022 00:16:56 +0000 (20:16 -0400)]
[gn build] re-add hlsl.h after e432108bf254

2 years ago[PowerPC][NFC] Pre-commit test case for an upcoming atomics patch
Nemanja Ivanovic [Tue, 27 Sep 2022 23:50:56 +0000 (18:50 -0500)]
[PowerPC][NFC] Pre-commit test case for an upcoming atomics patch

Just a new test case with auto generated checks.

2 years ago[llvm-jitlink] Remove stray global.
Lang Hames [Tue, 27 Sep 2022 23:32:19 +0000 (16:32 -0700)]
[llvm-jitlink] Remove stray global.

This was accidentally introduced in an earlier commit.

2 years agoFix the test added in 55cd5bc50964449627f6f1
Yuanfang Chen [Tue, 27 Sep 2022 23:42:55 +0000 (16:42 -0700)]
Fix the test added in 55cd5bc50964449627f6f1

It is hard to test the functionality for multiple platforms. Just test it
on Linux as similar patches did in the past.

2 years ago[mlir][sparse] change memref argument to proper SSA components
Aart Bik [Thu, 22 Sep 2022 00:40:50 +0000 (17:40 -0700)]
[mlir][sparse] change memref argument to proper SSA components

The indices for insert/compress were previously provided as
a memref<?xindex> with proper rank, since that matched the
argument for the runtime support libary better. However, with
proper codegen coming, providing the indices as SSA values
is much cleaner. This also brings the sparse_tensor.insert
closer to unification with tensor.insert, planned in the
longer run.

Reviewed By: Peiming

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

2 years ago[clang-doc] Add typedef/using information.
Brett Wilson [Tue, 27 Sep 2022 23:33:29 +0000 (23:33 +0000)]
[clang-doc] Add typedef/using information.

Read typedef and "using" type alias declarations and serialize into the internal structures. Emit this information in the YAML output. The HTML and MD generators are unchanged.

Separate out the logic to create the parent namespace or record object and insert the newly created child into it. This logic was previously duplicated for every "info" type and is now shared.

To help this, a struct containing the child vectors was separated out so children can be added generically and without having too many templates.

A small change was made to populateParentNamespaces() to allow using types that aren't themselves DeclContexts (typedefs are the first example of this).

Reviewed By: paulkirth, haowei

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

2 years ago[clang-doc] Clean up *Info constructors.
Brett Wilson [Tue, 27 Sep 2022 23:29:04 +0000 (23:29 +0000)]
[clang-doc] Clean up *Info constructors.

The *Info object (for the copy of the AST") constructors had many duplicated variants. Many of the variants seemed to be in an attempt to avoid default arguments. But default arguments are not prohibited and using them allows most of the variants to be removed which improves readability.

Remove the IsInGlobalNamespace flag on a Reference. This is set when the path is empty, and only read once in the HTML generator with the identical condition. The constructor cleanup exposed a problem where this was set to false when the constructor with no path was used, but true when the path was set to empty.

There should be no observable change with the exception that IsInGlobalNamespace is no longer emitted in YAML.

Reviewed By: paulkirth, haowei

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

2 years agoClear old section-to-addr entry when loading Section at new addr
Jason Molenda [Tue, 27 Sep 2022 23:17:22 +0000 (16:17 -0700)]
Clear old section-to-addr entry when loading Section at new addr

SectionLoadList has a section-to-address map (m_sect_to_addr) and
an address-to-section map (m_addr_to_sect).  When the load address
of a section is updated, the old entry from m_addr_to_sect would
never be cleared, resulting in incorrect address-to-section address
lookups from that point forward.

Differential Revision: https://reviews.llvm.org/D130534
rdar://97308773

2 years ago[flang] Add co_min and co_max to the list of intrinsics
Katherine Rasmussen [Thu, 25 Aug 2022 17:09:47 +0000 (10:09 -0700)]
[flang] Add co_min and co_max to the list of intrinsics

Add the collective subroutines, co_min and co_max, to the list
of intrinsic subroutines. Add those two subroutines to the check
for coindexed objects for the first, third, and fourth dummy
arguments. Update the co_min and co_max semantics tests.

Reviewed By: klausler

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