platform/upstream/llvm.git
23 months ago[TypeSwitch] Use perfect forwarding in the cast functions
River Riddle [Fri, 2 Dec 2022 08:19:28 +0000 (00:19 -0800)]
[TypeSwitch] Use perfect forwarding in the cast functions

This allows for properly supporting TypeSwitch on reference
types which do not support copying/do not want copying.

23 months ago[mlir] Allow access to the underlying diagnostic
River Riddle [Fri, 2 Dec 2022 07:22:22 +0000 (23:22 -0800)]
[mlir] Allow access to the underlying diagnostic

This allows for more interesting manipulation of an
inflight diagnostic.

23 months ago[libc] Make libc memory functions weak by default for bazel
Guillaume Chatelet [Wed, 30 Nov 2022 11:42:47 +0000 (11:42 +0000)]
[libc] Make libc memory functions weak by default for bazel

This helps override llvm libc functions for experiment purposes.

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

23 months ago[LoongArch] Extract out and reuse getValueType(). NFC.
gonglingqin [Fri, 2 Dec 2022 08:30:56 +0000 (16:30 +0800)]
[LoongArch] Extract out and reuse getValueType(). NFC.

23 months ago[flang] Lower evaluate::Extremum
Jean Perier [Fri, 2 Dec 2022 08:28:15 +0000 (09:28 +0100)]
[flang] Lower evaluate::Extremum

Update BinaryOp<T>::gen so that const T& is threaded and some
operation knowledge that is not encoded by the type T or the arguments
can be used. For Extremum, it is the order (Greater or Lesser) that is
required, but this will also be required for evaluate::Relational.

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

23 months ago[AMDGPU] Speedup GCNDownwardRPTracker::advanceBeforeNext
Valery Pykhtin [Wed, 19 Oct 2022 16:07:19 +0000 (18:07 +0200)]
[AMDGPU] Speedup GCNDownwardRPTracker::advanceBeforeNext

The function makes liveness tests for the entire live register set for every instruction it passes by.
This becomes very slow on high RP regions such as ASAN enabled code.

Instead only uses of last tracked instruction should be tested and this greatly improves compilation time.

This patch revealed few bugs in SIFormMemoryClauses and PreRARematStage::sinkTriviallyRematInsts which should
be fixed first.

Reviewed By: arsenm

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

23 months agoSupport: Convert some Optional to std::optional
Fangrui Song [Fri, 2 Dec 2022 08:02:19 +0000 (08:02 +0000)]
Support: Convert some Optional to std::optional

23 months ago[Windows SEH]: HARDWARE EXCEPTION HANDLING (MSVC -EHa) - Part 2
tentzen [Fri, 2 Dec 2022 06:45:46 +0000 (22:45 -0800)]
[Windows SEH]: HARDWARE EXCEPTION HANDLING (MSVC -EHa) - Part 2

This patch is the Part-2 (BE LLVM) implementation of HW Exception handling.
Part-1 (FE Clang) was committed in 797ad701522988e212495285dade8efac41a24d4.

This new feature adds the support of Hardware Exception for Microsoft Windows
SEH (Structured Exception Handling).

Compiler options:
  For clang-cl.exe, the option is -EHa, the same as MSVC.
  For clang.exe, the extra option is -fasync-exceptions,
  plus -triple x86_64-windows -fexceptions and -fcxx-exceptions as usual.

NOTE:: Without the -EHa or -fasync-exceptions, this patch is a NO-DIFF change.

The rules for C code:
For C-code, one way (MSVC approach) to achieve SEH -EHa semantic is to follow three rules:
  First, no exception can move in or out of _try region., i.e., no "potential faulty
    instruction can be moved across _try boundary.
  Second, the order of exceptions for instructions 'directly' under a _try must be preserved
    (not applied to those in callees).
  Finally, global states (local/global/heap variables) that can be read outside of _try region
    must be updated in memory (not just in register) before the subsequent exception occurs.

The impact to C++ code:
  Although SEH is a feature for C code, -EHa does have a profound effect on C++
  side. When a C++ function (in the same compilation unit with option -EHa ) is
  called by a SEH C function, a hardware exception occurs in C++ code can also
  be handled properly by an upstream SEH _try-handler or a C++ catch(...).
  As such, when that happens in the middle of an object's life scope, the dtor
  must be invoked the same way as C++ Synchronous Exception during unwinding process.

Design:
A natural way to achieve the rules above in LLVM today is to allow an EH edge
added on memory/computation instruction (previous iload/istore idea) so that
exception path is modeled in Flow graph preciously. However, tracking every
single memory instruction and potential faulty instruction can create many
Invokes, complicate flow graph and possibly result in negative performance
impact for downstream optimization and code generation. Making all
optimizations be aware of the new semantic is also substantial.

This design does not intend to model exception path at instruction level.
Instead, the proposed design tracks and reports EH state at BLOCK-level to
reduce the complexity of flow graph and minimize the performance-impact on CPP
code under -EHa option.
One key element of this design is the ability to compute State number at
block-level. Our algorithm is based on the following rationales:

A _try scope is always a SEME (Single Entry Multiple Exits) region as jumping
into a _try is not allowed. The single entry must start with a seh_try_begin()
invoke with a correct State number that is the initial state of the SEME.
Through control-flow, state number is propagated into all blocks. Side exits
marked by seh_try_end() will unwind to parent state based on existing SEHUnwindMap[].
Note side exits can ONLY jump into parent scopes (lower state number).
Thus, when a block succeeds various states from its predecessors, the lowest
State triumphs others.  If some exits flow to unreachable, propagation on those
paths terminate, not affecting remaining blocks.
For CPP code, object lifetime region is usually a SEME as SEH _try.
However there is one rare exception: jumping into a lifetime that has Dtor but
has no Ctor is warned, but allowed:

Warning: jump bypasses variable with a non-trivial destructor

In that case, the region is actually a MEME (multiple entry multiple exits).
Our solution is to inject a eha_scope_begin() invoke in the side entry block to
ensure a correct State.
Implementation:
Part-1: Clang implementation (already in):
Please see commit 797ad701522988e212495285dade8efac41a24d4).

Part-2 : LLVM implementation described below.

For both C++ & C-code, the state of each block is computed at the same place in
BE (WinEHPreparing pass) where all other EH tables/maps are calculated.
In addition to _scope_begin & _scope_end, the computation of block state also
rely on the existing State tracking code (UnwindMap and InvokeStateMap).

For both C++ & C-code, the state of each block with potential trap instruction
is marked and reported in DAG Instruction Selection pass, the same place where
the state for -EHsc (synchronous exceptions) is done.
If the first instruction in a reported block scope can trap, a Nop is injected
before this instruction. This nop is needed to accommodate LLVM Windows EH
implementation, in which the address in IPToState table is offset by +1.
(note the purpose of that is to ensure the return address of a call is in the
same scope as the call address.

The handler for catch(...) for -EHa must handle HW exception. So it is
'adjective' flag is reset (it cannot be IsStdDotDot (0x40) that only catches
C++ exceptions).
Suppress push/popTerminate() scope (from noexcept/noTHrow) so that HW
exceptions can be passed through.

Original llvm-dev [RFC] discussions can be found in these two threads below:
https://lists.llvm.org/pipermail/llvm-dev/2020-March/140541.html
https://lists.llvm.org/pipermail/llvm-dev/2020-April/141338.html

Differential Revision: https://reviews.llvm.org/D102817/new/

23 months agoAttributeParser: Convert Optional to std::optional
Fangrui Song [Fri, 2 Dec 2022 07:43:18 +0000 (07:43 +0000)]
AttributeParser: Convert Optional to std::optional

23 months agoRevert "[OpenMP] [OMPT] [3/8] Implemented callback registration in libomptarget"
Dhruva Chakrabarti [Fri, 2 Dec 2022 06:01:54 +0000 (22:01 -0800)]
Revert "[OpenMP] [OMPT] [3/8] Implemented callback registration in libomptarget"

This reverts commit 2b234ce3f07caea605df730ca0b33f22c419582f.

23 months ago[LoongArch] Remove dead code. NFC
wanglei [Fri, 2 Dec 2022 05:48:02 +0000 (13:48 +0800)]
[LoongArch] Remove dead code. NFC

23 months agoRevert "[clang][modules][deps] Parent module maps are affecting"
Jan Svoboda [Fri, 2 Dec 2022 05:31:30 +0000 (21:31 -0800)]
Revert "[clang][modules][deps] Parent module maps are affecting"

This reverts commit f99e5a9106f08ad92a22c3b114d2052e5c502924.

23 months agoRevert "[clang][modules][deps] Including module maps are affecting"
Jan Svoboda [Fri, 2 Dec 2022 05:31:29 +0000 (21:31 -0800)]
Revert "[clang][modules][deps] Including module maps are affecting"

This reverts commit 83973cf157f7850eb133a4bbfa0f8b7958bad215.

23 months ago[PowerPC] move ctrloop pass before tail duplication
Chen Zheng [Fri, 2 Dec 2022 03:58:03 +0000 (22:58 -0500)]
[PowerPC] move ctrloop pass before tail duplication

Tail duplication may modify the loop to a "non-canonical" form
that CTR Loop pass can not recognize. We fixed one issue in D135846.
And we found in some other case, the loop is changed to irreducible form.
It is hard to fix this case in CTR loop pass, instead we reorder the
CTR loop pass before tail duplication pass and just after finalize-isel
pass to avoid any unexpected change to the loop form.

Reviewed By: lkail

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

23 months agoRevert "[PowerPC] handle more than two predecessors loop header in ctrloop pass"
Chen Zheng [Fri, 2 Dec 2022 03:51:24 +0000 (22:51 -0500)]
Revert "[PowerPC] handle more than two predecessors loop header in ctrloop pass"

This reverts commit df9d60af1f9fa44f411b656bbc691d950c6fc087.

The CTRLoops pass is reordered to front of tail duplication pass in D138265.

23 months ago[clang][deps] Convert file dependency paths to the native style
Jan Svoboda [Fri, 2 Dec 2022 05:07:56 +0000 (21:07 -0800)]
[clang][deps] Convert file dependency paths to the native style

This is an attempt to fix a Windows bot failure. In the test introduced in 83973cf1, file dependencies were printed out-of-order (after replacing backslashes with slashes). This might've been caused by styles of some paths being different.

23 months ago[clang][modules][deps] Including module maps are affecting
Jan Svoboda [Fri, 2 Dec 2022 04:09:03 +0000 (20:09 -0800)]
[clang][modules][deps] Including module maps are affecting

With this patch, we mark module maps that include an affecting `extern` module map as also affecting. This is a generalization of D137197: now we don't require the importing module map to describe parent of the extern module.

Depends on D137198.

Reviewed By: Bigcheese

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

23 months ago[clang][modules][deps] Parent module maps are affecting
Jan Svoboda [Fri, 2 Dec 2022 04:08:51 +0000 (20:08 -0800)]
[clang][modules][deps] Parent module maps are affecting

Currently, the algorithm for gathering affecting module maps includes only those defining modules that include some headers. This is not entirely correct, though. Some module maps might be "importing" module maps for `extern` submodules. Such parent module maps are affecting - they do change semantics of the compilation. This patch adds parent module maps into the set of affecting module maps.

Depends on D137197.

Reviewed By: Bigcheese

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

23 months ago[clang][modules][deps] Transitive module maps are not affecting
Jan Svoboda [Fri, 2 Dec 2022 04:08:30 +0000 (20:08 -0800)]
[clang][modules][deps] Transitive module maps are not affecting

Currently, the algorithm for gathering affecting module maps includes those defining transitive dependencies. This seems like an over-approximation, since those don't change the semantics of current module build.

(With this patch, `ModulesToProcess` only ever holds modules whose headers will be serialized into the current PCM.)

Reviewed By: Bigcheese

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

23 months agoInstCombine: Convert some tests to opaque pointers
Matt Arsenault [Fri, 2 Dec 2022 02:59:52 +0000 (21:59 -0500)]
InstCombine: Convert some tests to opaque pointers

Needed manual fixes:
  2008-01-06-VoidCast.ll
  alias.ll @0 type lost
  pr27703.ll totally confused
  pr44242.ll phi and update_test_checks
  pr44245.ll phi and update_test_checks

Needed re-running update_test_checks:
  2009-01-08-AlignAlloca.ll
  2009-02-20-InstCombine-SROA.ll
  addrspacecast.ll
  alloca-cast-debuginfo.ll
  alloca-in-non-alloca-as.ll
  alloca.ll
  icmp-gep.ll
  icmp-custom-dl.ll
  lifetime-no-null-opt.ll
  non-integral-pointers.ll
  pr33689_same_bitwidth.ll
  pr39908.ll
  scalable-cast-of-alloc.ll
  select-cmp-br.ll
  unpack-fca.ll

Converted to generated checks:
  2012-6-7-vselect-bitcast.ll

23 months agoInstCombine: Don't use anonymous values in tests
Matt Arsenault [Fri, 2 Dec 2022 03:26:30 +0000 (22:26 -0500)]
InstCombine: Don't use anonymous values in tests

These interfered with opaquification

23 months agoInstCombine: Stop using grep in some tests
Matt Arsenault [Fri, 2 Dec 2022 03:12:28 +0000 (22:12 -0500)]
InstCombine: Stop using grep in some tests

Switch to FileCheck and generated checks.

23 months ago[clang][serialization] NFCI: Avoid re-reading input file info
Jan Svoboda [Fri, 2 Dec 2022 04:00:56 +0000 (20:00 -0800)]
[clang][serialization] NFCI: Avoid re-reading input file info

This patch resolves a FIXME that points out an inefficiency in first deserializing the input file info and the whole input file, which redundantly deserializes the input file info again.

Reviewed By: Bigcheese

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

23 months ago[clang][deps][lex] Avoid canonicalization of remapped framework directories
Jan Svoboda [Fri, 2 Dec 2022 03:09:09 +0000 (19:09 -0800)]
[clang][deps][lex] Avoid canonicalization of remapped framework directories

In D134923, the scanner introduced canonicalization of framework directories when reporting module map paths in order to increase module sharing. However, if we canonicalize framework directory that plays a role in a VFS remapping, and later try to use that module map to build the module, header lookup can fail. This happens when the module headers are remapped using the original framework path.

This patch fixes that. The implementation relies on the fact that the chain of directories in VFS remapping are assigned `DirectoryEntry` objects distinct from their on-disk counterparts. If we detect that case, we avoid the canonicalization.

Reviewed By: benlangmuir

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

23 months ago[libc++][NFC] Avoid most-vexing parse
Louis Dionne [Fri, 2 Dec 2022 03:26:01 +0000 (19:26 -0800)]
[libc++][NFC] Avoid most-vexing parse

23 months ago[PowerPC] [NFC] add test for O0 pipeline
Chen Zheng [Fri, 2 Dec 2022 01:52:14 +0000 (20:52 -0500)]
[PowerPC] [NFC] add test for O0 pipeline

This is to address comments https://reviews.llvm.org/D138265#3950197

This should be helpful for detecting optimization passes added to O0
pipeline by mistake.

Reviewed By: lkail

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

23 months ago[AArch64] Precommit test for D138904; NFC
chenglin.bi [Fri, 2 Dec 2022 02:58:44 +0000 (10:58 +0800)]
[AArch64] Precommit test for D138904; NFC
shift + and -> shift + shift to select more shfited registers.

23 months agoInstCombine: Convert target tests to opaque pointers
Matt Arsenault [Fri, 2 Dec 2022 02:46:59 +0000 (21:46 -0500)]
InstCombine: Convert target tests to opaque pointers

The opaquify script deleted a few declarations for some reason which
were manually deleted.

23 months agoInstCombine: Don't use anonymous values in test
Matt Arsenault [Fri, 2 Dec 2022 02:51:13 +0000 (21:51 -0500)]
InstCombine: Don't use anonymous values in test

Also don't use grep because it's not 2002.

23 months agoAMDGPU: Convert some assorted tests to opaque pointers
Matt Arsenault [Fri, 2 Dec 2022 02:33:26 +0000 (21:33 -0500)]
AMDGPU: Convert some assorted tests to opaque pointers

23 months agoReplacing `is` with `==` for the dtype check.
Prashant Kumar [Thu, 1 Dec 2022 16:27:33 +0000 (16:27 +0000)]
Replacing `is` with `==` for the dtype check.

>>> a = np.ndarray([1,1]).astype(np.half)
>>> a
array([[0.007812]], dtype=float16)
>>> a.dtype
dtype('float16')
>>> a.dtype == np.half
True
>>> a.dtype == np.float16
True
>>> a.dtype is np.float16
False

Checking with `is` leads to inconsistency in checking.

Reviewed By: silvas

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

23 months agoAMDGPU: Fix broken attribute usage in test
Matt Arsenault [Thu, 1 Dec 2022 23:07:47 +0000 (18:07 -0500)]
AMDGPU: Fix broken attribute usage in test

23 months agoAMDGPU: Convert some stack tests to opaque pointers
Matt Arsenault [Fri, 2 Dec 2022 02:14:49 +0000 (21:14 -0500)]
AMDGPU: Convert some stack tests to opaque pointers

23 months ago[mlir][nvgpu] Fix affine maps computing indices for LdMatrixOp srcMemref
Manish Gupta [Wed, 30 Nov 2022 04:36:40 +0000 (20:36 -0800)]
[mlir][nvgpu] Fix affine maps computing indices for LdMatrixOp srcMemref

This patch fixes and simplifies the ldmatrix affine map arithmetic by
abstracting the affine expressions in terms of pitch-linear layout
(strided and contiguous dimensions). Then it applies the maps for
strided and contiguous dimensions in row-major and col-major.

LdMatrixOp collaboratively (32 threads in a warp) load tiles
(8 row x 128b col) of data. It can load either x1, x2, x4 tiles.
Additionally, it can transpose at 16-bit granularity when moving
data from the Shared Memory to registers.

This patch fixes affine map:
(laneid -> coordinate index a thread points in a tile).

- Loading x4 tiles needs all 32 lanes T0-31 point to a contiguous
  chunk of 128b. The issue was exposed when running this case.
- Loading x2 tiles and x1 needs T0-15 threads and T0-7 threads points
  to contiguous chunk of 128b. The patch is NFC for these cases.

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

23 months agoAdd void cast for preprocessor-conditionall-unused loop variable
David Blaikie [Fri, 2 Dec 2022 02:08:36 +0000 (02:08 +0000)]
Add void cast for preprocessor-conditionall-unused loop variable

Fixing -Wunused -Werror build on Android.

23 months ago[NFC] Cleanup: Replaces BB->getInstList().erase() with BB->erase().
Vasileios Porpodas [Mon, 28 Nov 2022 22:50:32 +0000 (14:50 -0800)]
[NFC] Cleanup: Replaces BB->getInstList().erase() with BB->erase().

This is part of a series of cleanup patches towards making BasicBlock::getInstList() private.

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

23 months agoAMDGPU: Update some wait tests to opaque pointers
Matt Arsenault [Fri, 2 Dec 2022 02:01:58 +0000 (21:01 -0500)]
AMDGPU: Update some wait tests to opaque pointers

The script mangled the constantexprs in waitcnt-looptest.ll, so fixed
those manually.

23 months ago[IR][NFC] Adds BasicBlock::erase().
Vasileios Porpodas [Mon, 28 Nov 2022 22:49:34 +0000 (14:49 -0800)]
[IR][NFC] Adds BasicBlock::erase().

Currently the only way to do this is to work with the instruction list directly.
This is part of a series of cleanup patches towards making BasicBlock::getInstList() private.

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

23 months ago[NFC][PowerPC] More descriptive debug messages for rr to ri conversion
Nemanja Ivanovic [Fri, 2 Dec 2022 01:32:31 +0000 (19:32 -0600)]
[NFC][PowerPC] More descriptive debug messages for rr to ri conversion

23 months agoImprove error logging when xcrun fails to execute successfully
Adrian Prantl [Fri, 2 Dec 2022 00:20:26 +0000 (16:20 -0800)]
Improve error logging when xcrun fails to execute successfully

Because Host::RunShellCommand runs commands through $SHELL there is an
opportunity for this to fail spectacularly on systems that use custom
shells with odd behaviors. This patch makes these situations easier to
debug by at least logging the result of the failed xcrun invocation.

It also doesn't run xcrun through a shell any more.

rdar://102389438

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

23 months agoTargetLowering: convert Optional to std::optional
Krzysztof Parzyszek [Fri, 2 Dec 2022 00:18:32 +0000 (16:18 -0800)]
TargetLowering: convert Optional to std::optional

23 months ago[clang-format] Don't move comments if AlignTrailingComments: Leave
Maíra Canal [Thu, 1 Dec 2022 23:55:58 +0000 (15:55 -0800)]
[clang-format] Don't move comments if AlignTrailingComments: Leave

For comments that start after a new line, currently, the comments are
being indented. This happens because the OriginalWhitespaceRange
considers newlines on the range. Therefore, when AlignTrailingComments:
Kind: Leave, deduct the number of newlines before the token to calculate
the number of spaces for trailing comments.

Fixes #59203.

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

23 months ago[OpenMP] [OMPT] [3/8] Implemented callback registration in libomptarget
Dhruva Chakrabarti [Thu, 1 Dec 2022 19:06:58 +0000 (11:06 -0800)]
[OpenMP] [OMPT] [3/8] Implemented callback registration in libomptarget

The purpose of this patch is to have tool-provided callbacks registered
in libomptarget. The overall design document is in
https://rice.app.box.com/s/pf3gix2hs4d4o1aatwir1set05xmjljc

Defined a class OmptDeviceCallbacksTy that will be used by libomptarget
and a plugin for callbacks registered by a tool. Once the callbacks are
registered in libomp, a lookup function is passed to libomptarget that is
used to retrieve the callbacks and register them in libomptarget.

Patch from John Mellor-Crummey <johnmc@rice.edu>
(With contributions from Dhruva Chakrabarti <Dhruva.Chakrabarti@amd.com>)

Reviewed By: jplehr

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

23 months ago[mlgo][nfc] Virtualize Logger implementation
Mircea Trofin [Thu, 1 Dec 2022 00:42:09 +0000 (16:42 -0800)]
[mlgo][nfc] Virtualize Logger implementation

This is in preparation for dropping the dependency on protobuf. This
first step allows us to subsequently introduce the non-protobuf
implementation behind a flag. After that we can update the training side
to ingest the new format, after which we can drop the protobuf
implementation and de-virtualize everything.

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

23 months agoThreading: Convert Optional to std::optional
Fangrui Song [Thu, 1 Dec 2022 22:36:05 +0000 (22:36 +0000)]
Threading: Convert Optional to std::optional

dthorn: Relanding after fix-forward.

23 months ago[BOLT] Fix a build error
Kazu Hirata [Thu, 1 Dec 2022 23:48:03 +0000 (15:48 -0800)]
[BOLT] Fix a build error

This patch fixes:

  bolt/lib/Profile/DataAggregator.cpp:264:66: error: no viable
  conversion from 'Optional<llvm::StringRef>[3]' to
  'ArrayRef<std::optional<StringRef>>'

23 months agoRevert "Threading: Convert Optional to std::optional"
Daniel Thornburgh [Thu, 1 Dec 2022 23:42:25 +0000 (15:42 -0800)]
Revert "Threading: Convert Optional to std::optional"

This reverts commit 5e50b8089aee249d77542ea858d956568ec6581f.

This commit breaks the build for BOLT:
  bolt/lib/Profile/DataAggregator.cpp:264:66: error: no viable
  conversion from 'Optional<StringRef>[3]' to
  'ArrayRef<std::optional<StringRef>>'

23 months ago[libc][Obvious] Fix the build after e748db0f7f0971dc258c6631ae1fb0a38cfdf9dd.
Siva Chandra Reddy [Thu, 1 Dec 2022 23:34:41 +0000 (23:34 +0000)]
[libc][Obvious] Fix the build after e748db0f7f0971dc258c6631ae1fb0a38cfdf9dd.

That changed some parts of the Support API to use std::optional instead
of llvm::Optional. This patch updates the libc uses to the new API.

23 months ago[NFC] Cleanup: Replaces BB->getInstList().splice() with BB->splice().
Vasileios Porpodas [Mon, 28 Nov 2022 22:45:59 +0000 (14:45 -0800)]
[NFC] Cleanup: Replaces BB->getInstList().splice() with BB->splice().

This is part of a series of cleanup patches towards making BasicBlock::getInstList() private.

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

23 months agoMemoryLocation: convert Optional to std::optional
Krzysztof Parzyszek [Thu, 1 Dec 2022 23:23:53 +0000 (15:23 -0800)]
MemoryLocation: convert Optional to std::optional

23 months ago[DomTree] Add docstring for `dominates(const Instruction*, const BasicBlock*)`. NFC
Michael Maitland [Thu, 1 Dec 2022 23:12:33 +0000 (15:12 -0800)]
[DomTree] Add docstring for `dominates(const Instruction*, const BasicBlock*)`. NFC

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

23 months ago[NFC] Fix dbgs() statement in ControlHeightReduction
Mircea Trofin [Thu, 1 Dec 2022 23:02:24 +0000 (15:02 -0800)]
[NFC] Fix dbgs() statement in ControlHeightReduction

23 months agoclangd: Try to fix build with std::optional
Matt Arsenault [Thu, 1 Dec 2022 22:58:38 +0000 (17:58 -0500)]
clangd: Try to fix build with std::optional

Should have been in e748db0f7f0971dc258c6631ae1fb0a38cfdf9dd, but the
build option is well hidden.

23 months ago[libc++] Fix 64-bit file creation for Bionic and Windows
Ryan Prichard [Thu, 1 Dec 2022 22:48:20 +0000 (14:48 -0800)]
[libc++] Fix 64-bit file creation for Bionic and Windows

Bionic didn't add fopen64 until API 24, but there's no meaningful
distinction between them with Bionic, so just use fopen instead.

On Windows, use _chsize_s instead of _chsize. _chsize uses a 32-bit
`long` size argument, while _chsize_s uses __int64 instead.

Factor out utils::{off64_t, fopen64, ftruncate64} for use within the
create_file function.

Reviewed By: ldionne, #libc, mstorsjo

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

23 months agoThreading: Convert Optional to std::optional
Fangrui Song [Thu, 1 Dec 2022 22:36:05 +0000 (22:36 +0000)]
Threading: Convert Optional to std::optional

23 months agoInitLLVM: Remove unused include after 88e41b42f8d0abab4488b08f9d88d8e014d7f537
Fangrui Song [Thu, 1 Dec 2022 22:26:33 +0000 (22:26 +0000)]
InitLLVM: Remove unused include after 88e41b42f8d0abab4488b08f9d88d8e014d7f537

23 months ago[clangd] Fix build after e748db0f7f0971dc258c6631ae1fb0a38cfdf9dd
Fangrui Song [Thu, 1 Dec 2022 22:18:34 +0000 (22:18 +0000)]
[clangd] Fix build after e748db0f7f0971dc258c6631ae1fb0a38cfdf9dd

23 months ago[X86][MC] Remove "in directive" from diagnostics
Fangrui Song [Thu, 1 Dec 2022 22:15:41 +0000 (22:15 +0000)]
[X86][MC] Remove "in directive" from diagnostics

23 months ago[LoongArch] Fix tests after comment change
Fangrui Song [Thu, 1 Dec 2022 22:08:21 +0000 (22:08 +0000)]
[LoongArch] Fix tests after comment change

23 months ago[MC][AsmParser] Remove "in directive" from diagnostics
Fangrui Song [Thu, 1 Dec 2022 22:04:27 +0000 (22:04 +0000)]
[MC][AsmParser] Remove "in directive" from diagnostics

This part is not useful (all the custom parsing deals with directives) and does
not appear in the majority of diagnostics.

While updating diagnostics, change "unexpected token" to more useful
diagnostics, e.g. "expected comma", "expected end of directive".

23 months ago[mlir][sparse] add getPointerType/getIndexType to SparseTensorEncodingAttr.
Peiming Liu [Thu, 1 Dec 2022 21:23:52 +0000 (21:23 +0000)]
[mlir][sparse] add getPointerType/getIndexType to SparseTensorEncodingAttr.

add new interfaces to SparseTensorEncodingAttr to construct the pointer/index types based on pointer/index bitwidth.

Reviewed By: aartbik, wrengr

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

23 months agoSupport: Convert Program APIs to std::optional
Matt Arsenault [Thu, 1 Dec 2022 19:47:29 +0000 (14:47 -0500)]
Support: Convert Program APIs to std::optional

23 months ago[IR][NFC] Adds BasicBlock::splice().
Vasileios Porpodas [Mon, 28 Nov 2022 22:44:51 +0000 (14:44 -0800)]
[IR][NFC] Adds BasicBlock::splice().

Currently the only way to do this is to work with the instruction list directly.
This is part of a series of cleanup patches towards making BasicBlock::getInstList() private.

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

23 months ago[AArch64] Remove following .inst/after directive from AsmParser diagnostics
Fangrui Song [Thu, 1 Dec 2022 21:44:03 +0000 (21:44 +0000)]
[AArch64] Remove following .inst/after directive from AsmParser diagnostics

The part of the diagnostic is not useful because the instruction line is
printed. The new style follows generic code.

23 months ago[AVR] Convert test to check 'target=avr.*'
Paul Robinson [Thu, 1 Dec 2022 21:41:10 +0000 (13:41 -0800)]
[AVR] Convert test to check 'target=avr.*'

Part of the project to eliminate special handling for triples in lit
expressions.

23 months ago[AVR] Test XPASSes, remove the XFAIL
Paul Robinson [Thu, 1 Dec 2022 21:39:48 +0000 (13:39 -0800)]
[AVR] Test XPASSes, remove the XFAIL

I built llvm with default triple avr-- and this test XPASSed
so it seems safe enough.

23 months agoRemove some trailing WS from the release notes
Erich Keane [Thu, 1 Dec 2022 21:37:19 +0000 (13:37 -0800)]
Remove some trailing WS from the release notes

23 months ago[compiler-rt] support armv4t
Ties Stuij [Thu, 1 Dec 2022 20:52:18 +0000 (20:52 +0000)]
[compiler-rt] support armv4t

The main thing that needed changing was excluding functionality that
isn't supported on armv4t. So excluding Arm specific builtin assembly files.

In the process some files were renamed and the source was annotated where
appropriate, so it's a bit easier to follow what group of files are meant for
what purpose.

Reviewed By: peter.smith, nickdesaulniers

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

23 months ago[mlir][sparse] Put the implementation for the insertion operation to subroutines.
bixia1 [Wed, 30 Nov 2022 16:50:36 +0000 (08:50 -0800)]
[mlir][sparse] Put the implementation for the insertion operation to subroutines.

Previously, we generated inlined implementation for insert operation and
observed MLIR compile time increase due to the size of the main routine. We now
put the insert operation implementation in subroutines and leave the inlining
decision to the MLIR compiler.

Reviewed By: aartbik

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

23 months ago[lldb] Enable use of dummy target from dwim-print
Dave Lee [Wed, 30 Nov 2022 00:35:36 +0000 (16:35 -0800)]
[lldb] Enable use of dummy target from dwim-print

Allow `dwim-print` to evaluate expressions using the dummy target if no real
target exists.

This adds some parity to `expression`. With this, both of the following work:

```
lldb -o 'expr 1+2'
lldb -o 'dwim-print 1+2'
```

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

23 months ago[PowerPC] Implement xscmpeqqp, xscmpgeqp, xscmpgtqp instructions
Maryam Moghadas [Wed, 23 Nov 2022 18:37:15 +0000 (12:37 -0600)]
[PowerPC] Implement xscmpeqqp, xscmpgeqp, xscmpgtqp instructions

This patch adds 3 Power10 VSX Scalar compare for quad precision
instructions including xscmpeqqp, xscmpgeqp, xscmpgtqp

Reviewed By: amyk

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

23 months ago[clang] Avoid duplicating ProgramAddressSpace in TargetInfo. NFCI
Alex Richardson [Thu, 1 Dec 2022 19:37:56 +0000 (19:37 +0000)]
[clang] Avoid duplicating ProgramAddressSpace in TargetInfo. NFCI

This value was added to clang/Basic in D111566, but is only used during
codegen, where we can use the LLVM IR DataLayout instead. I noticed this
because the downstream CHERI targets would have to also set this value
for AArch64/RISC-V/MIPS. Instead of duplicating more information between
LLVM IR and Clang, this patch moves getTargetAddressSpace(QualType T) to
CodeGenTypes, where we can consult the DataLayout.

Reviewed By: rjmccall

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

23 months ago[test] Switch to use -passes syntax in various test cases
Bjorn Pettersson [Thu, 1 Dec 2022 20:00:24 +0000 (21:00 +0100)]
[test] Switch to use -passes syntax in various test cases

23 months ago[Support][MathExtras] Add variadic SaturatingAdd
Alexander Shaposhnikov [Thu, 1 Dec 2022 20:22:06 +0000 (20:22 +0000)]
[Support][MathExtras] Add variadic SaturatingAdd

Add variadic SaturatingAdd.

Test plan: ninja check-llvm-unit check-all

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

23 months ago[XCore] Convert tests to check 'target=xcore.*'
Paul Robinson [Thu, 1 Dec 2022 20:18:31 +0000 (12:18 -0800)]
[XCore] Convert tests to check 'target=xcore.*'

Part of the project to eliminate special handling for triples in lit
expressions.

23 months ago[NFC][SROA] A few more tests for D138238
Roman Lebedev [Thu, 1 Dec 2022 20:16:52 +0000 (23:16 +0300)]
[NFC][SROA] A few more tests for D138238

23 months ago[AArch64] Make opcode switch in tryARM64PackedUnwind comprehensive.
Eli Friedman [Thu, 1 Dec 2022 20:06:31 +0000 (12:06 -0800)]
[AArch64] Make opcode switch in tryARM64PackedUnwind comprehensive.

I don't think compiler-generated code could actually be affected by
this, but better to be thorough.

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

23 months ago[InstCombine] canonicalize trunc + insert as bitcast + shuffle, part 2
Sanjay Patel [Thu, 1 Dec 2022 19:17:07 +0000 (14:17 -0500)]
[InstCombine] canonicalize trunc + insert as bitcast + shuffle, part 2

This enhances the base fold from part 1 to allow mapping a
right-shift to an insert index.

Example of translating a middle chunk of the scalar to vector
for either endian:
https://alive2.llvm.org/ce/z/fRXCOZ

This only allows creating an identity shuffle (with optional
shortening/lengthening) because that is considered the safe
baseline for any target (can be inverted if needed). If we
tried this fold with target-specific costs/legality, then we
could do the transform more generally.

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

23 months ago[InstCombine] improve efficiency of bool logic; NFC
Sanjay Patel [Thu, 1 Dec 2022 12:59:48 +0000 (07:59 -0500)]
[InstCombine] improve efficiency of bool logic; NFC

As noted in issue #59266, the logic reduction could be
beyond the capabilities of an optimizing compiler, and
the code with ternary op is easier to read either way.

23 months ago[Hexagon] Check if vector is empty before calling back()
Krzysztof Parzyszek [Thu, 1 Dec 2022 19:21:53 +0000 (11:21 -0800)]
[Hexagon] Check if vector is empty before calling back()

23 months ago[Sparc] Convert tests to check 'target=sparc.*'
Paul Robinson [Thu, 1 Dec 2022 19:40:53 +0000 (11:40 -0800)]
[Sparc] Convert tests to check 'target=sparc.*'

Part of the project to eliminate special handling for triples in lit
expressions.

23 months agoIntrinsics: Make is_fpclass and arithmetic_fence speculatable
Matt Arsenault [Wed, 30 Nov 2022 03:17:14 +0000 (22:17 -0500)]
Intrinsics: Make is_fpclass and arithmetic_fence speculatable

23 months agollvm-reduce: Fix tsan failures
Matt Arsenault [Tue, 29 Nov 2022 14:06:39 +0000 (09:06 -0500)]
llvm-reduce: Fix tsan failures

There's a data race on the UninterestingChunks set. The code seems to
be operating on the assumption that all the tasks completed, so ensure
the unused results do complete. This started showing up about 50% of
the time when running operands-skip-parallel.ll after the recent
switch to use DenseSet; previously it failed much less frequently with
std::set.

We should introduce a mechanism to early terminate unused
results. Alternatively, I've been thinking about ways to to make the
reduction order smarter. I frequently have tests that take multiple
minutes to compile and hit the failure. It may be helpful to see which
chunks took the least time and prefer those over just taking the first
result.

23 months ago[Sparc] Remove an XFAIL
Paul Robinson [Thu, 1 Dec 2022 19:36:33 +0000 (11:36 -0800)]
[Sparc] Remove an XFAIL

I built llvm with default triple sparc-sun-solaris2 and this test
XPASSed so it seems safe enough.

23 months ago[RISCV] Add ADDW/AND/OR/XOR/SUB/SUBW to getRegAllocHints.
Craig Topper [Thu, 1 Dec 2022 19:09:38 +0000 (11:09 -0800)]
[RISCV] Add ADDW/AND/OR/XOR/SUB/SUBW to getRegAllocHints.

These instructions requires both register operands to be compressible
so I've only applied the hint if we already have a GPRC physical register
assigned for the other register operand.

Reviewed By: reames

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

23 months ago[mlir][NFC] Generalize `getPermutedPosition`
Diego Caballero [Thu, 1 Dec 2022 18:43:18 +0000 (18:43 +0000)]
[mlir][NFC] Generalize `getPermutedPosition`

Small change to support projected permutations in the
`getPermutedPosition` utility. Renamed to `getResultPosition`.

Reviewed By: nicolasvasilache

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

23 months agoAdd assembler plumbing for sanitize_memtag
Mitch Phillips [Thu, 1 Dec 2022 18:50:28 +0000 (10:50 -0800)]
Add assembler plumbing for sanitize_memtag

Extends the Asm reader/writer to support reading and writing the
'.memtag' directive (including allowing it on internal global
variables). Also add some extra tooling support, including objdump and
yaml2obj/obj2yaml.

Test that the sanitize_memtag IR attribute produces the expected asm
directive.

Uses the new Aarch64 MemtagABI specification
(https://github.com/ARM-software/abi-aa/blob/main/memtagabielf64/memtagabielf64.rst)
to identify symbols as tagged in object files. This is done using a
R_AARCH64_NONE relocation that identifies each tagged symbol, and these
relocations are tagged in a special SHT_AARCH64_MEMTAG_GLOBALS_STATIC
section. This signals to the linker that the global variable should be
tagged.

Reviewed By: fmayer, MaskRay, peter.smith

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

23 months ago[AMDGPU] Convert test to check 'target=r600.*'
Paul Robinson [Thu, 1 Dec 2022 18:49:23 +0000 (10:49 -0800)]
[AMDGPU] Convert test to check 'target=r600.*'

Part of the project to eliminate special handling for triples in lit
expressions.

23 months ago[RISCV] Incorporate LMUL into costs for arithmetic and shuffles
Philip Reames [Thu, 1 Dec 2022 18:37:44 +0000 (10:37 -0800)]
[RISCV] Incorporate LMUL into costs for arithmetic and shuffles

This reuses the routine implemented in 0e6f0b7 to implement several existing TODOs. Many of the operations scale linearly with LMUL; this change represents that in the cost model.

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

23 months ago[CodeGen] Fix restore blocks' BasicBlock information in branch relaxation
ZHU Zijia [Thu, 1 Dec 2022 18:41:04 +0000 (02:41 +0800)]
[CodeGen] Fix restore blocks' BasicBlock information in branch relaxation

In branch relaxation pass, restore blocks are created and placed before
the jump destination if indirect branches are required. For example:

        foo
        sd      s11, 0(sp)
        jump    .restore, s11
        bar
        bar
        bar
        j       .dest
.restore:
        ld      s11, 0(sp)
.dest:
        baz

The BasicBlock information of the restore MachineBasicBlock should be
identical to the dest MachineBasicBlock.

Reviewed By: arsenm

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

23 months ago[CodeGen][test] Pre-commit test for D131863
ZHU Zijia [Thu, 1 Dec 2022 18:39:14 +0000 (02:39 +0800)]
[CodeGen][test] Pre-commit test for D131863

Reviewed By: arsenm

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

23 months ago[Hexagon] Punt on GEPs with different base types in vector alignment
Krzysztof Parzyszek [Thu, 1 Dec 2022 16:00:11 +0000 (08:00 -0800)]
[Hexagon] Punt on GEPs with different base types in vector alignment

23 months agoRevert "[flang] Use proper attributes for runtime calls with 'i1' arguments/returns."
Slava Zakharin [Thu, 1 Dec 2022 17:35:59 +0000 (09:35 -0800)]
Revert "[flang] Use proper attributes for runtime calls with 'i1' arguments/returns."

This reverts commit d5b0de35bdd9a3f4d4a093e7938b06add34678eb.

23 months agoRevert "[CodeGen] Add new pass for late cleanup of redundant definitions."
Jonas Paulsson [Thu, 1 Dec 2022 18:29:24 +0000 (13:29 -0500)]
Revert "[CodeGen] Add new pass for late cleanup of redundant definitions."

Temporarily revert and fix buildbot failure.

This reverts commit 6d12599fd4134c1da63198c74a25490d28c733f6.

23 months ago[CodeGen] Add new pass for late cleanup of redundant definitions.
Jonas Paulsson [Wed, 6 Apr 2022 15:47:00 +0000 (17:47 +0200)]
[CodeGen] Add new pass for late cleanup of redundant definitions.

A new pass MachineLateInstrsCleanup is added to be run after PEI.

This is a simple pass that removes redundant and identical instructions
whenever found by scanning the MF once while keeping track of register
definitions in a map. These instructions are typically immediate loads
resulting from rematerialization, and address loads emitted by target in
eliminateFrameInde().

This is enabled by default, but a target could easily disable it by means of
'disablePass(&MachineLateInstrsCleanupID);'.

This late cleanup is naturally not "optimal" in removing instructions as it
is done by looking at phys-regs, but still quite effective. It would be
desirable to improve other parts of CodeGen and avoid these redundant
instructions in the first place, but there are no ideas for this yet.

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

Reviewed By: RKSimon, foad, craig.topper, arsenm, asb

23 months ago[NFC] Port an assortment of tests that invoke SROA to new pass manager
Roman Lebedev [Thu, 1 Dec 2022 18:12:31 +0000 (21:12 +0300)]
[NFC] Port an assortment of tests that invoke SROA to new pass manager

23 months ago[clang] Add test for CWG36
Vlad Serebrennikov [Thu, 1 Dec 2022 18:10:28 +0000 (21:10 +0300)]
[clang] Add test for CWG36

Reviewed By: #clang-language-wg, aaron.ballman, erichkeane

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

23 months ago[lldb] Remove timer from Module::GetNumCompileUnits
Dave Lee [Tue, 29 Nov 2022 00:15:41 +0000 (16:15 -0800)]
[lldb] Remove timer from Module::GetNumCompileUnits

`GetNumCompileUnits` has fast execution, and is high firing. Fast and frequent functions are not good candidates for timers. In a recent profile, `GetNumCompileUnits` was called >>10k times with an average duration of 1 microsecond.

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

23 months ago[Clang] Adjust assert from Sema::BuildCXXTypeConstructExpr
Shafik Yaghmour [Thu, 1 Dec 2022 17:38:13 +0000 (09:38 -0800)]
[Clang] Adjust assert from Sema::BuildCXXTypeConstructExpr

Currently Sema::BuildCXXTypeConstructExpr asserts that list initialization must
mean we have an InitListExpr as well. We have several cases of valid code the
result in CXXTemporaryObjectExpr in the AST instead for list initialization.
Commit 1ae689c seems to indicate that this is not unexpected, although may be a
design issue

This fixes:

  https://github.com/llvm/llvm-project/issues/58302
  https://github.com/llvm/llvm-project/issues/58753
  https://github.com/llvm/llvm-project/issues/59100

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

23 months ago[NVPTX] Convert tests to check 'target=nvptx.*'
Paul Robinson [Thu, 1 Dec 2022 17:00:04 +0000 (09:00 -0800)]
[NVPTX] Convert tests to check 'target=nvptx.*'

Part of the project to eliminate special handling for triples in lit
expressions.