platform/upstream/llvm.git
19 months ago[mlir][sparse] introduce sparse_tensor::StorageSpecifierToLLVM pass
Peiming Liu [Thu, 15 Dec 2022 18:28:30 +0000 (18:28 +0000)]
[mlir][sparse] introduce sparse_tensor::StorageSpecifierToLLVM pass

Reviewed By: aartbik

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

19 months ago[LowerExpectIntrinsic] Propagate branch weights through phi values when ExpectedValue...
Zhi Zhuang [Thu, 22 Dec 2022 00:14:11 +0000 (19:14 -0500)]
[LowerExpectIntrinsic] Propagate branch weights through phi values when ExpectedValue is unlikely in LowerExpectIntrinsic

Update handlePhiDef to consider the probability argument in an expect.with.probability intrinsic when annotating BranchInsts.
In addition, we also disallow non-constant probability arguments in this intrinsic.

Differential Revsion: https://reviews.llvm.org/D140337

19 months ago[libc][NFC] Use operator delete to cleanup a File object.
Siva Chandra Reddy [Thu, 22 Dec 2022 08:13:19 +0000 (08:13 +0000)]
[libc][NFC] Use operator delete to cleanup a File object.

The File API has been refactored to allow cleanup using operator delete.

Reviewed By: lntue

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

19 months agoRevert "Emit unwind information in the .debug_frame section when the .cfi_sections...
Shubham Sandeep Rastogi [Thu, 22 Dec 2022 22:23:34 +0000 (14:23 -0800)]
Revert "Emit unwind information in the .debug_frame section when the .cfi_sections .debug_frame directive is used."

This reverts commit d2cbdb6bef31bdc3254daf57148225ea4b34520c.

This is because we are seeing linker crashes in the internal apple bots.

19 months ago[RISCV] Add pass to remove W suffix from ADDIW and SLLIW to improve compressibility
Nitin John Raj [Thu, 22 Dec 2022 19:28:53 +0000 (11:28 -0800)]
[RISCV] Add pass to remove W suffix from ADDIW and SLLIW to improve compressibility

SLLI and ADD are more compressible than SLLIW and ADDW. SLLI/ADD both have a 5-bit register encoding. SLLIW/ADDW have a 3-bit register encoding. They both require the dest to also be one of the sources.

We aggressively form ADDW/SLLIW as it helps hasAllWBitUsers in RISCVISelDAGToDAG to not require recursion. So we need a pass to remove excessive -w suffixes.

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

19 months ago[libc++] Granularize <type_traits> includes in <utility>
Nikolas Klauser [Tue, 20 Dec 2022 18:47:35 +0000 (19:47 +0100)]
[libc++] Granularize <type_traits> includes in <utility>

Reviewed By: Mordante, #libc

Spies: libcxx-commits

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

19 months agoSCCP: Add failing testcase with llvm.ssa.copy
Matt Arsenault [Tue, 20 Dec 2022 16:34:06 +0000 (11:34 -0500)]
SCCP: Add failing testcase with llvm.ssa.copy

19 months agoSCCP: Don't assert on constantexpr casts of function uses
Matt Arsenault [Tue, 20 Dec 2022 13:18:50 +0000 (08:18 -0500)]
SCCP: Don't assert on constantexpr casts of function uses

This includes 2 different, related fixes:

1. Fix asserting on direct assume-like intrinsic uses of a function
   address

2. Fix asserting on constant expression casts used by assume-like
   intrinsics.

By default hasAddressTaken permits assume-like intrinsic uses, which
ignores assume-like calls and pointer casts of the address used by
assume-like calls.

Fixes #59602, but there are additional issues I encountered when
debugging this. For instance, the original failing bitcast expression
was really unused. Clang tentatively created it for the function type,
but was unnecessary after applyGlobalValReplacements. That did not
clean up the now dead ConstantExpr which hung around oun the user
list, so this assert only reproduced when running clang from the
original testcase, and didn't just running opt -passes=ipsccp. I don't
know who is responsible for cleaning up unused ConstantExprs, but I've
run into similar issues several times recently.

Additionally, I found a few assertions with llvm.ssa.copy with
functions and casts of functions as the argument.

Another issue theoretically exists if hasAddressTaken chooses to
respect nocapture when passed function addresses. The search here
would need to do additional work to look at the users of the constant
cast to see if any call sites need returned to be stripped.

19 months ago[CSKY] Fix MachineFunctionInfo initialization after 69e75ae695d9ef1360a2a1fbefd6e0e04...
Fangrui Song [Thu, 22 Dec 2022 22:02:12 +0000 (14:02 -0800)]
[CSKY] Fix MachineFunctionInfo initialization after 69e75ae695d9ef1360a2a1fbefd6e0e0456c3f7b

19 months ago[clang] Remove redundant initialization of std::optional (NFC)
Kazu Hirata [Thu, 22 Dec 2022 21:46:26 +0000 (13:46 -0800)]
[clang] Remove redundant initialization of std::optional (NFC)

19 months ago[mlir][GPU] Add known_block_size and known_grid_size to gpu.func
Krzysztof Drewniak [Fri, 2 Dec 2022 20:38:39 +0000 (20:38 +0000)]
[mlir][GPU] Add known_block_size and known_grid_size to gpu.func

In many cases, the the number of workgroups (the grid size) and the
number of workitems within each group (the block size) that a GPU
kernel will be launched with are known. For example, if gpu.launch is
called with constant block and grid sizes, we know that those are the
only possible sizes that will be used to launch that kernel. In other
cases, a custom code-generation pipeline that eventually produces GPU
kernels may know the launch dimensions of those kernels, or at least
may be able to provide an upper bound on them.

Other GPU programming systems, such as OpenCL, allow capturing such
information to enable compiler optimizations - see
reqd_work_group_size, but MLIR currently has no mechanism for doing so.

This set of attributes is the first step in enabling optimizations
based on the known launch dimensions of kernels. It extends the kernel
outline pass to set these bounds on kernels with constant launch
dimensions and extends integer range inference for GPU index
operations to account for the bounds when they are known.

Subsequent revisions will use this data when lowering GPU operations
to the ROCDL dialect.

Reviewed By: antiagainst

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

19 months ago[gn build] Port 17ed8f29287b
LLVM GN Syncbot [Thu, 22 Dec 2022 21:20:59 +0000 (21:20 +0000)]
[gn build] Port 17ed8f29287b

19 months ago[BOLT][AArch64] Handle adrp+ld64 linker relaxations
Vladislav Khmelevsky [Wed, 16 Nov 2022 07:57:35 +0000 (11:57 +0400)]
[BOLT][AArch64] Handle adrp+ld64 linker relaxations

Linker might relax adrp + ldr got address loading to adrp + add for
local non-preemptible symbols (e.g. hidden/protected symbols in
executable). As usually linker doesn't change relocations properly after
relaxation, so we have to handle such cases by ourselves. To do that
during relocations reading we change LD64 reloc to ADD if instruction
mismatch found and introduce FixRelaxationPass that searches for ADRP+ADD
pairs and after performing some checks we're replacing ADRP target symbol
to already fixed ADDs one.

Vladislav Khmelevsky,
Advanced Software Technology Lab, Huawei

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

19 months ago[lld-macho] Fix assert when splitting section
Keith Smiley [Thu, 22 Dec 2022 00:02:38 +0000 (16:02 -0800)]
[lld-macho] Fix assert when splitting section

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

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

19 months ago[mlir][sparse] make loop emitter API more concise.
Peiming Liu [Thu, 22 Dec 2022 18:56:44 +0000 (18:56 +0000)]
[mlir][sparse] make loop emitter API more concise.

Reviewed By: aartbik

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

19 months ago[LangRef] Add description for nocallback attribute
Gulfem Savrun Yeniceri [Wed, 10 Aug 2022 22:40:23 +0000 (22:40 +0000)]
[LangRef] Add description for nocallback attribute

This patch adds the description for nocallback attribute
that is implemented in https://reviews.llvm.org/D90275.

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

19 months ago[Linker] Remove nocallback attribute while linking
Gulfem Savrun Yeniceri [Thu, 3 Nov 2022 21:16:06 +0000 (21:16 +0000)]
[Linker] Remove nocallback attribute while linking

GCC's leaf attribute is lowered to LLVM IR nocallback attribute.
Clang conservatively treats this function attribute as a hint on the
module level, and removes it while linking modules. More context can
be found in: https://reviews.llvm.org/D131628.

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

19 months ago[DAGCombine][X86] Pull one-use `freeze` out of `extract_vector_elt` vector operand
Roman Lebedev [Thu, 22 Dec 2022 19:18:11 +0000 (22:18 +0300)]
[DAGCombine][X86] Pull one-use `freeze` out of `extract_vector_elt` vector operand

This may allow us to further simplify the vector,
and freezing the extracted result is still fine:
```
----------------------------------------
define i8 @src(<2 x i8> %src, i64 %idx) {
%0:
  %i1 = freeze <2 x i8> %src
  %i2 = extractelement <2 x i8> %i1, i64 %idx
  ret i8 %i2
}
=>
define i8 @tgt(<2 x i8> %src, i64 %idx) {
%0:
  %i1 = extractelement <2 x i8> %src, i64 %idx
  %i2 = freeze i8 %i1
  ret i8 %i2
}
Transformation seems to be correct!
```

BUT, there must not be other uses of that freeze,
see `@freeze_extractelement_extra_use`.

Also, looks like we are missing some ISEL-level handling for freeze.

19 months ago[NFC][Codegen][X86] Add tests where we could improve `freeze` handling
Roman Lebedev [Thu, 22 Dec 2022 18:26:40 +0000 (21:26 +0300)]
[NFC][Codegen][X86] Add tests where we could improve `freeze` handling

19 months ago[Driver] Revert D139717 and add -Xparser/-Xcompiler instead
Fangrui Song [Thu, 22 Dec 2022 20:51:20 +0000 (12:51 -0800)]
[Driver] Revert D139717 and add -Xparser/-Xcompiler instead

Some macOS projects use -Xparser even if it leads to a
-Wunused-command-line-argument warning. It doesn't justify adding a broad Joined
`-X` (IgnoredGCCCompat) as GCC doesn't really support these arbitrary `-X`
options.

Note: `-Xcompiler foo` is a GNU libtool option, not a driver option.
It is misused by some ChromeOS packages (but not by Gentoo).
Keep it for a while.

It seems that GCC < 4.6 reports g++: unrecognized option '-Xfoo' but exit with 0.
GCC >= 4.6 reports g++: error: unrecognized option '-Xfoo' and exits with 1.
It never supports -Xcompiler or -Xparser, so `IgnoredGCCCompat` is not justified.

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

19 months ago[mlir][sparse] move loop boundary method to codegenenv
Aart Bik [Thu, 22 Dec 2022 20:10:03 +0000 (12:10 -0800)]
[mlir][sparse] move loop boundary method to codegenenv

Reviewed By: Peiming

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

19 months agoRemove incorrectly implemented -mibt-seal
Fangrui Song [Thu, 22 Dec 2022 20:32:59 +0000 (12:32 -0800)]
Remove incorrectly implemented -mibt-seal

The option from D116070 does not work as intended and will not be needed when
hidden visibility is used. A function needs ENDBR if it may be reached
indirectly. If we make ThinLTO combine the address-taken property (close to
`!GV.use_empty() && !GV.hasAtLeastLocalUnnamedAddr()`), then the condition can
be expressed with:

`AddressTaken || (!F.hasLocalLinkage() && (VisibleToRegularObj || !F.hasHiddenVisibility()))`

The current `F.hasAddressTaken()` condition does not take into acount of
address-significance in another bitcode file or ELF relocatable file.

For the Linux kernel, it uses relocatable linking. lld/ELF uses a
conservative approach by setting all `VisibleToRegularObj` to true.
Using the non-relocatable semantics may under-estimate
`VisibleToRegularObj`. As @pcc mentioned on
https://github.com/ClangBuiltLinux/linux/issues/1737#issuecomment-1343414686
, we probably need a symbol list to supply additional
`VisibleToRegularObj` symbols (not part of the relocatable LTO link).

Reviewed By: samitolvanen

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

19 months ago[DAGCombiner] `visitFREEZE()`: allow, and update, other uses of maybe-poison operand
Roman Lebedev [Thu, 22 Dec 2022 19:55:28 +0000 (22:55 +0300)]
[DAGCombiner] `visitFREEZE()`: allow, and update, other uses of maybe-poison operand

19 months ago[NFC][Codegen][X86] Add test for freeze with other uses of maybe-poison operand
Roman Lebedev [Thu, 22 Dec 2022 19:57:01 +0000 (22:57 +0300)]
[NFC][Codegen][X86] Add test for freeze with other uses of maybe-poison operand

19 months ago[libc][obvious] fix errno for 32 bit long test
Michael Jones [Thu, 22 Dec 2022 20:01:21 +0000 (12:01 -0800)]
[libc][obvious] fix errno for 32 bit long test

one of the tests in StrtolTest.h is intended to detect that 32 bit longs
are handled correctly, but it wasn't using the correct value for errno
causing failures.

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

19 months ago[lldb] Fix a warning
Kazu Hirata [Thu, 22 Dec 2022 20:01:35 +0000 (12:01 -0800)]
[lldb] Fix a warning

This patch fixes:

  lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp:1378:16:
  warning: control reaches end of non-void function [-Wreturn-type]

19 months agoRevert D138179 "MIPS: fix build from IR files, nan2008 and FpAbi"
Fangrui Song [Thu, 22 Dec 2022 19:48:55 +0000 (11:48 -0800)]
Revert D138179 "MIPS: fix build from IR files, nan2008 and FpAbi"

This reverts commit 9739bb81aed490bfcbcbbac6970da8fb7232fd34.
It causes `.module is not permitted after generating code`
for Linux kernel's `ARCH=mips 32r1_defconfig` clang+GNU as build.
It's confirmed as a defect, but the proper fix needs time to sort out.

19 months agoFix indentation in LangRef.rst
Jessica Paquette [Thu, 22 Dec 2022 19:44:13 +0000 (11:44 -0800)]
Fix indentation in LangRef.rst

Sphinx build was broken.

19 months agoSupport: Fix broken C++ marker
Matt Arsenault [Tue, 29 Nov 2022 19:12:56 +0000 (14:12 -0500)]
Support: Fix broken C++ marker

19 months ago[mlir] Fix a warning
Kazu Hirata [Thu, 22 Dec 2022 19:40:19 +0000 (11:40 -0800)]
[mlir] Fix a warning

This patch fixes:

  mlir/lib/Analysis/DataFlow/SparseAnalysis.cpp:321:19: warning:
  unused variable ‘block’ [-Wunused-variable]

19 months ago[libc] Handle allocation failures gracefully in FILE related API.
Siva Chandra Reddy [Thu, 22 Dec 2022 00:36:59 +0000 (00:36 +0000)]
[libc] Handle allocation failures gracefully in FILE related API.

Few uses of free have not yet been replaced by the custom operator
delete yet. They will be done in a follow up patch.

Reviewed By: lntue, michaelrj

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

19 months ago[mlir] Fix warnings
Kazu Hirata [Thu, 22 Dec 2022 19:10:47 +0000 (11:10 -0800)]
[mlir] Fix warnings

This patch fixes:

  third-party/unittest/googletest/include/gtest/gtest.h:1526:11:
  error: comparison of integers of different signs: 'const unsigned
  long' and 'const int' [-Werror,-Wsign-compare]

19 months agoProperly support LLVM_ENABLE_LLD on Windows
serge-sans-paille [Thu, 22 Dec 2022 09:48:37 +0000 (10:48 +0100)]
Properly support LLVM_ENABLE_LLD on Windows

Currently, setting -DLLVM_ENABLE_LLD=ON on windows also requires setting
-DCMAKE_LINKER=lld-link.exe. This is both misleading and redundant.

Fix this by trying to find llvm-link.exe when -DLLVM_ENABLE_LLD=ON is
set and CMAKE_LINKER is not, and aborting otherwise.

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

19 months ago[VPlan] Add support for tracking UFs applicable to VPlan (NFC).
Florian Hahn [Thu, 22 Dec 2022 18:58:22 +0000 (18:58 +0000)]
[VPlan] Add support for tracking UFs applicable to VPlan (NFC).

Explicitly track the UFs supported in a VPlan. This is needed to
allow transformations to restrict the UFs which are supported.

Discussed as separate improvement in D135017.

19 months ago[SPARC] Fix SELECT_REG emission for f128s
Koakuma [Thu, 22 Dec 2022 18:50:11 +0000 (13:50 -0500)]
[SPARC] Fix SELECT_REG emission for f128s

In LowerSELECT_CC, SELECT_REG between two f128s should only be emitted if we
have hardware quadfloat enabled.

This should fix issue #59646

Reviewed By: arsenm

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

19 months ago[libc++][CI] Improves buildbot runner.
Mark de Wever [Thu, 22 Dec 2022 18:47:54 +0000 (19:47 +0100)]
[libc++][CI] Improves buildbot runner.

Adds documentation and shows a help message when running the script
without arguments.

Lands parts of D139545.

19 months ago[gn build] Port eb6e13cb3280
LLVM GN Syncbot [Thu, 22 Dec 2022 18:42:31 +0000 (18:42 +0000)]
[gn build] Port eb6e13cb3280

19 months ago[libc] change str to int tests to be templated
Michael Jones [Tue, 20 Dec 2022 23:37:17 +0000 (15:37 -0800)]
[libc] change str to int tests to be templated

Previously the tests were copy/pasted into several files, this changes
them to be instead templated and sharing one file.

Reviewed By: lntue

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

19 months ago[libc++][format] Removes test redundancy.
Mark de Wever [Thu, 15 Dec 2022 17:07:41 +0000 (18:07 +0100)]
[libc++][format] Removes test redundancy.

The format function test serve two purposes:
- Test whether all format functions work in general.
- Test whether all formatting rules are implemented correctly.

At the moment the *pass.cpp tests do both. These tests are quite slow,
while testing all rules for all functions doesn't add much coverage.

There are two execution modi of the format functions:
- run-time validation in the vformat functions.
- compile-time validation in the other function.

So instead of running all tests for all functions, they are only used for
format.pass.cpp and vformat.pass.cpp still do all tests.

The other tests do a smaller set of test, just to make sure they work in the
basics.

Running the format tests using one thread:
- before 00:04:16
- after  00:02:14

The slow tests were also reported in
https::llvm.org/PR58141

Also split a generic part of the test to a generic support header. This
allows these parts to be reused in the range-based formatter tests.

Reviewed By: #libc, ldionne

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

19 months ago[libc++][format] Adds formatter for tuple and pair
Mark de Wever [Thu, 5 May 2022 16:57:32 +0000 (18:57 +0200)]
[libc++][format] Adds formatter for tuple and pair

Implements parts of
- P2286R8 Formatting Ranges

Reviewed By: ldionne, #libc

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

19 months ago[mlir][sparse] completed codegen environment privatization
Aart Bik [Thu, 22 Dec 2022 01:10:12 +0000 (17:10 -0800)]
[mlir][sparse] completed codegen environment privatization

All members are now private and access is through delegate
or convenience methods only (except the loop emitter, which
is still under refactoring).

Reviewed By: Peiming

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

19 months ago[VPlan] Add unittest for printing plans with VFs and UFs (NFC).
Florian Hahn [Thu, 22 Dec 2022 18:29:39 +0000 (18:29 +0000)]
[VPlan] Add unittest for printing plans with VFs and UFs (NFC).

19 months ago[mlir][spirv] Add StreamingInterfaceINTEL to SPIRVBase.td
Mark Mendell [Thu, 22 Dec 2022 18:14:10 +0000 (10:14 -0800)]
[mlir][spirv] Add StreamingInterfaceINTEL to SPIRVBase.td

StreamingInterfaceINTEL has been recently added to the SPIR-V headers:
https://github.com/KhronosGroup/SPIRV-Headers/commit/70ff9d939cd7fd0c758756ac57ab0c7c6d6c64d6

Reviewed By: antiagainst

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

19 months ago[Sanitizer] Fix page alignment for mmap calls
Blue Gaston [Mon, 19 Dec 2022 21:50:07 +0000 (16:50 -0500)]
[Sanitizer] Fix page alignment for mmap calls

We are in the process of enabling sanitizer_common unit tests on arm64 for apple devices. rdar://101436019

The test `CompactRingBuffer.int64` is failing on arm64 with the error:

```==17265==ERROR: SanitizerTool failed to deallocate 0xfffffffffffff000 (-4096) bytes at address 0x000105c30000
SanitizerTool: CHECK failed: sanitizer_posix.cpp:63 "(("unable to unmap" && 0)) != (0)" (0x0, 0x0) (tid=157296)```

If page size is sufficiently larger than alignment then this code:
   UnmapOrDie((void*)end, map_end - end);
end is will be greater than map_end causing the value passed to UnmapOrDie to be negative.

This is caused when GetPageSizeCached returns 16k and alignment is 8k.
map_size and what is mapped by mmap uses size and alignment which is smaller than what is calculated by end using the actual page size.
Therefore, map_end ends up being less than end.
The call to mmap is allocating sufficent page-aligned memory, because it calls RoundUp within MmapOrDieOnFatalError.
But this size is not being captured by map_size.

We can address this by rounding up map_size here to be page-aligned. This ensures that map_end will be greater than or equal to end and that it will match mmaps use of page-aligned value, and the
subsequent call to munmap will also be page-aligned.

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

19 months ago[IR/MachineOutliner] Add a "nooutline" function attr and respect it
Jessica Paquette [Tue, 20 Dec 2022 23:16:18 +0000 (15:16 -0800)]
[IR/MachineOutliner] Add a "nooutline" function attr and respect it

Add `nooutline` + update LangRef to say it exists.

This makes it possible to say "don't outline from this function ever."

We want to be able to toggle whether or not a function should be in the search
set regardless of default behaviour.

Add testcases for the IR Outliner + Machine Outliner.

Also remove an unnecessary check for an empty function in the Machine Outliner.

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

19 months ago[libc] add exponent format to printf
Michael Jones [Thu, 1 Dec 2022 23:29:15 +0000 (15:29 -0800)]
[libc] add exponent format to printf

Add support for the %e/E conversion in printf, as well as unit tests. It
does not yet support long doubles.

Reviewed By: sivachandra

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

19 months ago[lldb] Add LTO dependency to lldb test suite
Augusto Noronha [Wed, 14 Dec 2022 21:21:57 +0000 (13:21 -0800)]
[lldb] Add LTO dependency to lldb test suite

Make the lldb test target depend on LTO, since TestFullLtoStepping
needs it (prior to this patch, running "ninja check-lldb" would not
build libLTO).

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

19 months agoAMDGPU: Modernize sqrt f64 test
Matt Arsenault [Mon, 21 Nov 2022 15:54:50 +0000 (10:54 -0500)]
AMDGPU: Modernize sqrt f64 test

Use the readfirstlane hack for the scalar cases as a hack to
combine globalisel and sdag tests. gfx6 stores are a bit broken
in globalisel, and scalar returns are totally broken in sdag.

19 months agoAdd aligned_alloc to symbolizer symbols list.
Mitch Phillips [Thu, 22 Dec 2022 17:52:40 +0000 (09:52 -0800)]
Add aligned_alloc to symbolizer symbols list.

New symbol used by libcxx as of https://reviews.llvm.org/D138196, needs
to be added to the symbol deps list.

19 months agoSupport: Add polling option to sys::Wait
Matt Arsenault [Tue, 29 Nov 2022 19:09:08 +0000 (14:09 -0500)]
Support: Add polling option to sys::Wait

Currently the process is terminated after the timeout. Add an option
to let the process resume after the timeout instead.

https://reviews.llvm.org/D138952

19 months agoAMDGPU: Update constant address spaces used in printf test
Matt Arsenault [Thu, 22 Dec 2022 15:22:11 +0000 (10:22 -0500)]
AMDGPU: Update constant address spaces used in printf test

This was never updated for the address space number shuffle.

19 months agoAMDGPU: Use early continue to reduce indentation
Matt Arsenault [Thu, 22 Dec 2022 15:20:33 +0000 (10:20 -0500)]
AMDGPU: Use early continue to reduce indentation

19 months ago[mlir] Allow specifying benefit for C func ptr style patterns.
Chenguang Wang [Thu, 22 Dec 2022 17:10:15 +0000 (09:10 -0800)]
[mlir] Allow specifying benefit for C func ptr style patterns.

Reviewed By: rriddle

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

19 months ago[AArch64] Add RSHRN and RSHRN2 patterns
David Green [Thu, 22 Dec 2022 16:49:19 +0000 (16:49 +0000)]
[AArch64] Add RSHRN and RSHRN2 patterns

This adds some tablegen patterns for RSHRN, which performs a rounding
shift with narrow. This is similar to the existing SHRN patterns with an
extra addition to perform the rounding, that adds 1<<(shift-1) before
the right shift. Because the round immediate and the shift amount are
tied, it goes via a ComplexPattern that uses a SelectRoundingVLShr
method to perform the selection checks.

aarch64_neon_rshrn are expanded into the sequence of equivalent
instructions (trunc(shr(add(x, 1<<(sht-1)), sht))) so that they can be
converted back into RSHRN. Which also allows us to match raddhn through
the adjusted patterns that previously used aarch64_neon_rshrn.

DIfferential Revision: https://reviews.llvm.org/D140297

19 months agoSmall fixes to creduce-clang-crash.py script.
Amy Huang [Wed, 21 Dec 2022 23:02:43 +0000 (23:02 +0000)]
Small fixes to creduce-clang-crash.py script.

Specify python3, and replace / with // to do integer division.

19 months agomlir/tblgen test: add a test for EnumAttr customAssemblyFormat
Ramkumar Ramachandra [Wed, 14 Dec 2022 17:55:07 +0000 (18:55 +0100)]
mlir/tblgen test: add a test for EnumAttr customAssemblyFormat

attr-or-type-format.td contains tests for various attributes and types,
but nowhere in the testsuite is the customAssemblyFormat for an EnumAttr
(enum class in C++) exercised. Fix this by adding a test.

Signed-off-by: Ramkumar Ramachandra <r@artagnon.com>
Differential Revision: https://reviews.llvm.org/D140034

19 months ago[GlobalISel][Legalizer] add minScalarIf action
Ties Stuij [Thu, 22 Dec 2022 15:32:34 +0000 (15:32 +0000)]
[GlobalISel][Legalizer] add minScalarIf action

Ensure scalar is at least as wide as type, but only if the specified condition
is met.

Reviewed By: paquette

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

19 months ago[AVR] Do not emit instructions invalid for attiny10
Ayke van Laethem [Wed, 23 Nov 2022 18:14:01 +0000 (19:14 +0100)]
[AVR] Do not emit instructions invalid for attiny10

The attiny4/attiny5/attiny9/attiny10 have a slightly modified
instruction set that drops a number of useful instructions. This patch
makes sure to not emit them on these "reduced tiny" cores.

The affected instructions are:

  * lds and sts (load/store directly from data)
  * ldd and std (load/store with displacement)
  * adiw and sbiw (add/sub register pairs)
  * various other instructions that were emitted without checking
    whether the chip actually supports them (movw, adiw, etc)

There is a variant on lds and sts on these chips, but it can only
address a limited portion of the address space and is mainly useful to
load/store I/O registers (as an extension to the in and out
instructions). I have not implemented it here, implementing it can be
done in a separate patch.

This patch is not optimal. I'm sure it can be improved a lot. For
example, we could teach the instruction selector to not select lddw/stdw
instructions so that the weird pointer adjustments are not necessary.
But for now I've focused just on correctness, not on code quality.

Updates: https://github.com/llvm/llvm-project/issues/53459

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

19 months ago[AMDGPU] Remove permlane discard vdst_in optimization from isel
Jay Foad [Thu, 22 Dec 2022 12:02:11 +0000 (12:02 +0000)]
[AMDGPU] Remove permlane discard vdst_in optimization from isel

D72845 implemented the equivalent IR optimization in InstCombine so it
seems that there's no advantage to doing it during isel too.

This partially reverts D72844.

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

19 months agoApply clang-tidy fixes for llvm-else-after-return in TensorOps.cpp (NFC)
Mehdi Amini [Sat, 10 Dec 2022 12:22:49 +0000 (12:22 +0000)]
Apply clang-tidy fixes for llvm-else-after-return in TensorOps.cpp (NFC)

19 months agoApply clang-tidy fixes for llvm-else-after-return in SparseVectorization.cpp (NFC)
Mehdi Amini [Sat, 10 Dec 2022 12:01:27 +0000 (12:01 +0000)]
Apply clang-tidy fixes for llvm-else-after-return in SparseVectorization.cpp (NFC)

19 months ago[SampleProfile] Regenerate test checks (NFC)
Nikita Popov [Thu, 22 Dec 2022 15:24:03 +0000 (16:24 +0100)]
[SampleProfile] Regenerate test checks (NFC)

19 months ago[Util] Regenerate test checks (NFC)
Nikita Popov [Thu, 22 Dec 2022 15:20:55 +0000 (16:20 +0100)]
[Util] Regenerate test checks (NFC)

19 months ago[InstCombine] Regenerate test checks (NFC)
Nikita Popov [Thu, 22 Dec 2022 15:13:36 +0000 (16:13 +0100)]
[InstCombine] Regenerate test checks (NFC)

19 months ago[mlir][linalg] Reuploading: add a shortened printing/parsing form for linalg.map...
Aliia Khasanova [Thu, 22 Dec 2022 10:14:24 +0000 (11:14 +0100)]
[mlir][linalg] Reuploading: add a shortened printing/parsing form for linalg.map and linalg.reduce.

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

19 months ago[libc++] Use aligned_alloc instead of posix_memalign for C++17
Alex Richardson [Thu, 17 Nov 2022 10:19:28 +0000 (10:19 +0000)]
[libc++] Use aligned_alloc instead of posix_memalign for C++17

C++17 defines the C11 `aligned_alloc`, so we can use that instead of
posix_memalign. This change allows building against picolibc without
defining _DEFAULT_SOURCE/_GNU_SOURCE.
The C11 `aligned_alloc` function should be available on all supported
non-Windows platforms except for macOS where we need version 10.15.

There is one caveat: aligned_alloc() requires that __size is a multiple of
__alignment, but [new.delete.general] only states "if the value of an
alignment argument passed to any of these functions is not a valid
alignment value, the behavior is undefined".
To handle calls such as ::operator new(1, std::align_val_t(128)), we
round up __size to __alignment (and check for wrap-around).
This is required at least for macOS where aligned_alloc(128, 1) returns
an error instead of allocating memory (glibc ignores the specification).

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

19 months ago[SystemZ] Convert test to opaque pointers (NFC)
Nikita Popov [Thu, 22 Dec 2022 14:58:18 +0000 (15:58 +0100)]
[SystemZ] Convert test to opaque pointers (NFC)

19 months ago[RISCV] Convert test to opaque pointers (NFC)
Nikita Popov [Thu, 22 Dec 2022 14:55:38 +0000 (15:55 +0100)]
[RISCV] Convert test to opaque pointers (NFC)

There is a minor change in operand order (of a commutative
instruction).

19 months ago[RISCV] Convert some tests to opaque pointers (NFC)
Nikita Popov [Thu, 22 Dec 2022 14:47:32 +0000 (15:47 +0100)]
[RISCV] Convert some tests to opaque pointers (NFC)

The asm test has minor differences in instruction scheduling only.

19 months ago[clang][dataflow] Fix bug in handling of `return` statements.
Yitzhak Mandelbaum [Tue, 20 Dec 2022 19:41:19 +0000 (19:41 +0000)]
[clang][dataflow] Fix bug in handling of `return` statements.

The handling of return statements, added in support of context-sensitive
analysis, has a bug relating to functions that return reference
types. Specifically, interpretation of such functions can result in a crash from
a bad cast. This patch fixes the bug and guards all of that code with the
context-sensitive option, since there's no reason to execute at all when
context-sensitive analysis is off.

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

19 months agoInstSimplify: Split isKnownNeverInfinity tests into separate file
Matt Arsenault [Thu, 22 Dec 2022 13:51:07 +0000 (08:51 -0500)]
InstSimplify: Split isKnownNeverInfinity tests into separate file

This fixes an annoying assymmetry in the test organization. We have
known-never-nan.ll for dedicated isKnownNeverNaN handling tests, but
the isKnownNeverInfinity were in floating-point-compare.ll. Move the
more targeted tests into a separate file to match.

19 months agoValueTracking: Add test for isKnownNeverInfinity for fptrunc
Matt Arsenault [Sun, 4 Dec 2022 14:09:41 +0000 (09:09 -0500)]
ValueTracking: Add test for isKnownNeverInfinity for fptrunc

19 months agoValueTracking: Add test for fneg isKnownNeverNaN handling
Matt Arsenault [Thu, 17 Nov 2022 16:02:14 +0000 (08:02 -0800)]
ValueTracking: Add test for fneg isKnownNeverNaN handling

This didn't have a negative test.

19 months ago[clang][dataflow] Account for global variables in constructor initializers.
Yitzhak Mandelbaum [Wed, 21 Dec 2022 22:05:09 +0000 (22:05 +0000)]
[clang][dataflow] Account for global variables in constructor initializers.

Previously, the analysis modeled global variables appearing in the _body_ of
any function (including constructors). But, that misses those appearing in
constructor _initializers_. This patch adds the initializers to the set of
expressions used to determine which globals to model.

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

19 months ago[clang][dataflow] Simplify handling of nullopt-optionals.
Yitzhak Mandelbaum [Wed, 21 Dec 2022 22:48:04 +0000 (22:48 +0000)]
[clang][dataflow] Simplify handling of nullopt-optionals.

Previously, in the case of an optional constructed from `nullopt`, we relied on
the value constructed for the `nullopt`. This complicates the implementation and
exposes it to bugs (indeed, one such was found), yet doesn't improve the
engine. Instead, this patch constructs a fresh optional representation, rather
than relying on the underlying nullopt representation.

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

19 months agoMIR: Fix test error message
Matt Arsenault [Thu, 22 Dec 2022 13:57:16 +0000 (08:57 -0500)]
MIR: Fix test error message

19 months ago[mlir][vector] Add additional scalar vector transfer foldings
Matthias Springer [Thu, 22 Dec 2022 13:05:51 +0000 (14:05 +0100)]
[mlir][vector] Add additional scalar vector transfer foldings

* Rewrite vector.transfer_write of vectors with 1 element to
  memref.store
* Rewrite vector.extract(vector.transfer_read) to memref.load

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

19 months agoclang/HIP: Fix missing test for __frsqrt_rn
Matt Arsenault [Tue, 22 Nov 2022 16:21:18 +0000 (11:21 -0500)]
clang/HIP: Fix missing test for __frsqrt_rn

19 months ago[RISCV] Name instructions in tests (NFC)
Nikita Popov [Thu, 22 Dec 2022 13:30:38 +0000 (14:30 +0100)]
[RISCV] Name instructions in tests (NFC)

19 months ago[test][lldb-vscode] Relax assertion to allow multiple compile units returned.
Jordan Rupprecht [Thu, 22 Dec 2022 13:19:29 +0000 (05:19 -0800)]
[test][lldb-vscode] Relax assertion to allow multiple compile units returned.

I don't think the intent of this test is to make sure we only have one compile unit; it's to make sure request_compileUnits returns something sensible. Relax the test case to just make sure that the main source file is one of the compile units returned, even if there are others.

Fixes llvm.org/pr49418.

Reviewed By: labath

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

19 months agoMIR: Don't assert if a virtual register uses a non-allocatable class
Matt Arsenault [Thu, 22 Dec 2022 12:31:05 +0000 (07:31 -0500)]
MIR: Don't assert if a virtual register uses a non-allocatable class

19 months ago[VPlan] Move VF and UF string generation to getName() (NFC).
Florian Hahn [Thu, 22 Dec 2022 13:15:01 +0000 (13:15 +0000)]
[VPlan] Move VF and UF string generation to getName() (NFC).

The VFs and UFs may be more constrained as the plans are transformed
(e.g. see D135017 for an example).

To make sure the VFs/UFs included in the VPlan dump are accurate,
generate them when accessing a plan's name, rather than include them in
the name string set after initial construction.

19 months ago[mlir][Tosa] Apply ClangTidy performance findings (NFC)
Adrian Kuegel [Thu, 22 Dec 2022 13:13:30 +0000 (14:13 +0100)]
[mlir][Tosa] Apply ClangTidy performance findings (NFC)

19 months ago[NVPTX] Convert test to opaque pointers (NFC)
Nikita Popov [Thu, 22 Dec 2022 13:01:56 +0000 (14:01 +0100)]
[NVPTX] Convert test to opaque pointers (NFC)

19 months ago[MIR] Convert tests to opaque pointers (NFC)
Nikita Popov [Thu, 22 Dec 2022 12:58:29 +0000 (13:58 +0100)]
[MIR] Convert tests to opaque pointers (NFC)

19 months ago[CodeGen] Convert test to opaque pointers (NFC)
Nikita Popov [Thu, 22 Dec 2022 12:57:14 +0000 (13:57 +0100)]
[CodeGen] Convert test to opaque pointers (NFC)

19 months agoclang/HIP: Fix broken implementations of __make_mantissa* functions
Matt Arsenault [Mon, 21 Nov 2022 03:30:09 +0000 (19:30 -0800)]
clang/HIP: Fix broken implementations of __make_mantissa* functions

The optimizer was folding the entire function to return 0. This
meant to be checking the character content of the pointer is the
string terminator, not null.

Also just make null inputs undefined. My docs for nanf say the
behavior of the argument is unspecified and segfaults on my system.

19 months ago[BPF] Convert test to opaque pointers (NFC)
Nikita Popov [Thu, 22 Dec 2022 11:56:50 +0000 (12:56 +0100)]
[BPF] Convert test to opaque pointers (NFC)

19 months ago[AMDGPU] Simplify simplifyAMDGCNMemoryIntrinsicDemanded. NFC.
Jay Foad [Thu, 22 Dec 2022 11:21:11 +0000 (11:21 +0000)]
[AMDGPU] Simplify simplifyAMDGCNMemoryIntrinsicDemanded. NFC.

19 months ago[Clang][LoongArch] Add intrinsic for rdtime_d, rdtimeh_w and rdtimel_w
gonglingqin [Thu, 22 Dec 2022 11:18:22 +0000 (19:18 +0800)]
[Clang][LoongArch] Add intrinsic for rdtime_d, rdtimeh_w and rdtimel_w

Add these intrinsics to keep consistent with GCC [1].

[1]: https://github.com/gcc-mirror/gcc/blob/master/gcc/config/loongarch/larchintrin.h#L33

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

19 months ago[Clang][LoongArch] Add intrinsic for asrtle, asrtgt, lddir, ldpte and cpucfg
gonglingqin [Thu, 22 Dec 2022 08:59:56 +0000 (16:59 +0800)]
[Clang][LoongArch] Add intrinsic for asrtle, asrtgt, lddir, ldpte and cpucfg

`__cpucfg` is required by Linux [1].

[1]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/loongarch/include/asm/loongarch.h#n59

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

19 months ago[clang-format] Add InsertBraces to operator== in Format.h
Owen Pan [Thu, 22 Dec 2022 10:24:01 +0000 (02:24 -0800)]
[clang-format] Add InsertBraces to operator== in Format.h

19 months ago[AArch64][SVE] Remove dso_local and local_unnamed_addr from muladdsub.ll
Matt Devereau [Thu, 22 Dec 2022 10:00:57 +0000 (10:00 +0000)]
[AArch64][SVE] Remove dso_local and local_unnamed_addr from muladdsub.ll

19 months ago[clang-format] Add 'friend' to QualifierOrder
Micah Weston [Thu, 22 Dec 2022 09:54:04 +0000 (01:54 -0800)]
[clang-format] Add 'friend' to QualifierOrder

For cases of defining friend functions, qualifier ordering can
allow multiple positions for the 'friend' token.

Closes #59450.

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

19 months ago[AArch64][InstCombine] Fuse ADD+MUL and SUB+MUL AArch64 instrinsics
Matt Devereau [Thu, 15 Dec 2022 16:09:13 +0000 (16:09 +0000)]
[AArch64][InstCombine] Fuse ADD+MUL and SUB+MUL AArch64 instrinsics

Fold (ADD p c (MUL p a b)) into (MAD p a b c)
Fold (FADD p c (FMUL p a b)) into (FMAD p a b c)
Fold (FSUB p c (FMUL p a b)) into (FNMSB p a b c)

Fold (ADD p (MUL p a b) c) into (MLA p c a b)
Fold (FADD p (FMUL p a b) c) into (FMLA p c a b)
Fold (SUB p (MUL p a b) C) into (MLS p c a b)
Fold (FSUB p (FMUL p a b) c) into (FMLS p c a b)

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

19 months ago[mlir][vector] Fold vector.extractelement(vector.broadcast)
Matthias Springer [Thu, 22 Dec 2022 09:22:37 +0000 (10:22 +0100)]
[mlir][vector] Fold vector.extractelement(vector.broadcast)

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

19 months ago[X86] Support ANDNP combine through vector_shuffle
Evgenii Kudriashov [Wed, 21 Dec 2022 12:45:41 +0000 (20:45 +0800)]
[X86] Support ANDNP combine through vector_shuffle

Combine
```
   and (vector_shuffle<Z,...,Z>
            (insert_vector_elt undef, (xor X, -1), Z), undef), Y
   ->
   andnp (vector_shuffle<Z,...,Z>
              (insert_vector_elt undef, X, Z), undef), Y
```

Reviewed By: RKSimon, pengfei

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

19 months agoRevert "Revert "[DebugInfo] Correctly recognize bitfields when emitting dwarf""
Juan Manuel MARTINEZ CAAMAÑO [Thu, 22 Dec 2022 08:31:36 +0000 (03:31 -0500)]
Revert "Revert "[DebugInfo] Correctly recognize bitfields when emitting dwarf""

https://reviews.llvm.org/D140195 should have fixed the fail in
green-dragon that was reported in https://reviews.llvm.org/D96334 and
resulted in the revert.

This reverts commit 920de9c94caff0b3ac21bf637487b07cb9aea98a.

19 months ago[bazel] Fix some --features=layering_check issues
Fangrui Song [Thu, 22 Dec 2022 08:12:58 +0000 (00:12 -0800)]
[bazel] Fix some --features=layering_check issues

19 months ago[mlir][llvm] Cleanup LLVM IR control flow import test (NFC).
Tobias Gysi [Thu, 22 Dec 2022 07:49:00 +0000 (08:49 +0100)]
[mlir][llvm] Cleanup LLVM IR control flow import test (NFC).

Use a FileCheck variable to match the switch op argument
instead of hardcoding the argument name.

Reviewed By: ftynse, Dinistro

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