platform/upstream/llvm.git
2 years ago[RISCV] Fix misleading formatting and remove a dead getNode call. NFC
Craig Topper [Tue, 28 Jun 2022 01:49:31 +0000 (18:49 -0700)]
[RISCV] Fix misleading formatting and remove a dead getNode call. NFC

2 years agoAdd missing (void) for function declarations in C
David Blaikie [Tue, 28 Jun 2022 00:45:17 +0000 (00:45 +0000)]
Add missing (void) for function declarations in C

2 years agollvm-reduce: Handle reducing FP values to nan
Matt Arsenault [Thu, 9 Jun 2022 15:07:31 +0000 (11:07 -0400)]
llvm-reduce: Handle reducing FP values to nan

Prefer 0/1 over NaN, but it may make more sense to invert this as FP
operations with nan inputs can universally be folded into something
else.

2 years ago[docs] Remove outdated status update for FreeBSD
Brad Smith [Mon, 27 Jun 2022 23:37:59 +0000 (19:37 -0400)]
[docs] Remove outdated status update for FreeBSD

Reviewed By: emaste, MaskRay

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

2 years ago[test] Add -fsanitize=array-bounds test for pseudo flexible array member
Fangrui Song [Mon, 27 Jun 2022 23:40:52 +0000 (16:40 -0700)]
[test] Add -fsanitize=array-bounds test for pseudo flexible array member

This behavior (from commit 539e4a77bbabbc19f22b2bd24e04af2e432e599d in 2013) was untested.
The test can help detect regression introduced by 886715af962de2c92fac4bd37104450345711e4a

2 years ago[lldb] Use assertState in TestIgnoredExceptions
Jonas Devlieghere [Mon, 27 Jun 2022 23:30:32 +0000 (16:30 -0700)]
[lldb] Use assertState in TestIgnoredExceptions

2 years agoReland [Metadata] Add a resize capability to MDNodes and add a push_back interface...
Wolfgang Pieb [Mon, 16 May 2022 18:22:46 +0000 (11:22 -0700)]
Reland [Metadata] Add a resize capability to MDNodes and add a push_back interface to MDNode

Fixed a bug with double destruction of operands and corrected a test issue.

Note that this patch leads to a slight increase in compile time (I measured
about .3%) and a slight increase in memory usage. The increased memory usage
should be offset once resizing is used to a larger extent.

Reviewed By: dexonsmith

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

2 years ago[lit][test] relaxed GTEST_TOTAL_SHARDS checking for some googletests
Yuanfang Chen [Mon, 27 Jun 2022 23:12:45 +0000 (16:12 -0700)]
[lit][test] relaxed GTEST_TOTAL_SHARDS checking for some googletests

For machines with a small number of cores, GTEST_TOTAL_SHARDS may be
lower than 6.

2 years agoMark ASan global-location-nodebug test as unspported on win.
Mitch Phillips [Mon, 27 Jun 2022 23:03:32 +0000 (16:03 -0700)]
Mark ASan global-location-nodebug test as unspported on win.

Windows linkers don't have the easy reachable `-Wl,-S` option to strip
the binary. Disable the test for now.

2 years ago[mlir][ods] Add convertFromStorage field to parameters
Mogball [Thu, 23 Jun 2022 20:48:30 +0000 (20:48 +0000)]
[mlir][ods] Add convertFromStorage field to parameters

This patch adds a `convertFromStorage` field to attribute or type parameters that can implement more complex logic for converting from the parameter's C++ storage type (e.g. `Optional<SmallVector<T>>`) to its C++ type (e.g. `Optional<ArrayRef<T>>`).

Reviewed By: rriddle

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

2 years agoFix-forward ASan on Windows.
Mitch Phillips [Mon, 27 Jun 2022 22:51:14 +0000 (15:51 -0700)]
Fix-forward ASan on Windows.

D127911 deleted llvm.asan.globals. This had a side effect that we no
longer generated the `name` field for the `__asan_global` descriptor
from clang's decscription of the name, but the demangled name from the
LLVM IR. On Linux, this is the same as the clang-provided name. On
Windows, this includes the type, as the name in the IR is the mangled
name.

Attempt #1 to fix-forward the Windows bots by making the tests glob both
sides of the global name, thereby allowing types in the descriptor name.

2 years ago[lld][WebAssembly] Don't apply data relocations at static constructor time
Sam Clegg [Fri, 24 Jun 2022 10:04:58 +0000 (03:04 -0700)]
[lld][WebAssembly] Don't apply data relocations at static constructor time

Instead, export `__wasm_apply_data_relocs` and `__wasm_call_ctors`
separately.

This is required since user code in a shared library (such as static
constructors) should not be run until relocations have been applied to
all loaded libraries.

See: https://github.com/emscripten-core/emscripten/issues/17295

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

2 years ago[Clang][OpenMP] Don't overload "extension" in status doc
Joel E. Denny [Mon, 27 Jun 2022 22:41:17 +0000 (18:41 -0400)]
[Clang][OpenMP] Don't overload "extension" in status doc

In Clang's OpenMPSupport.rst, "extension" is currently overloaded to
describe both:

1. Standard OpenMP features that appear only in recent versions of the
   OpenMP spec.
2. Non-standard features supported by Clang.  This usage appears in
   the final table on the page.

Last fall, we discussed this issue in the OpenMP in LLVM call and
agreed it should be corrected.  This patch takes the simple approach
of dropping the word "extension" for all occurrences of the first
usage.  The result seems to read well.

Reviewed By: ABataev

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

2 years ago[libc] add printf oct conversion
Michael Jones [Tue, 14 Jun 2022 22:54:37 +0000 (15:54 -0700)]
[libc] add printf oct conversion

The oct converter handles the %o conversion.

Reviewed By: lntue

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

2 years ago[pseudo] Check follow-sets instead of tying reduce actions to lookahead tokens.
Sam McCall [Thu, 23 Jun 2022 21:55:41 +0000 (23:55 +0200)]
[pseudo] Check follow-sets instead of tying reduce actions to lookahead tokens.

Previously, the action table stores a reduce action for each lookahead
token it should allow. These tokens are the followSet(action.rule.target).

In practice, the follow sets are large, so we spend a bunch of time binary
searching around all these essentially-duplicates to check whether our lookahead
token is there.
However the number of reduces for a given state is very small, so we're
much better off linear scanning over them and performing a fast check for each.

D128318 was an attempt at this, storing a bitmap for each reduce.
However it's even more compact just to use the follow sets directly, as
there are fewer nonterminals than (state, rule) pairs. It's also faster.

This specialized approach means unbundling Reduce from other actions in
LRTable, so it's no longer useful to support it in Action. I suspect
Action will soon go away, as we store each kind of action separately.

This improves glrParse speed by 42% (3.30 -> 4.69 MB/s).
It also reduces LR table size by 59% (343 -> 142kB).

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

2 years agoHave CommandObjectParsed check for "commands that take no arguments".
Jim Ingham [Thu, 23 Jun 2022 16:33:40 +0000 (09:33 -0700)]
Have CommandObjectParsed check for "commands that take no arguments".

This is currently being done in an ad hoc way, and so for some
commands it isn't being checked.  We have the info to make this check,
since commands are supposed to add their arguments to the m_arguments
field of the CommandObject.  This change uses that info to check whether
the command received arguments in error.

A handful of commands weren't defining their argument types, I also had
to fix them.  And a bunch of commands were checking for arguments by
hand, so I removed those checks in favor of the CommandObject one.  That
also meant I had to change some tests that were checking for the ad hoc
error outputs.

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

2 years ago[asan] Add missing dependency on Demangle
Vitaly Buka [Mon, 27 Jun 2022 22:10:02 +0000 (15:10 -0700)]
[asan] Add missing dependency on Demangle

Follow up to D127911.

2 years agoDelete 'llvm.asan.globals' for global metadata.
Mitch Phillips [Mon, 27 Jun 2022 21:40:03 +0000 (14:40 -0700)]
Delete 'llvm.asan.globals' for global metadata.

Now that we have the sanitizer metadata that is actually on the global
variable, and now that we use debuginfo in order to do symbolization of
globals, we can delete the 'llvm.asan.globals' IR synthesis.

This patch deletes the 'location' part of the __asan_global that's
embedded in the binary as well, because it's unnecessary. This saves
about ~1.7% of the optimised non-debug with-asserts clang binary.

Reviewed By: vitalybuka

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

2 years ago[docs] Restore missing blank line
Vitaly Buka [Mon, 27 Jun 2022 21:19:51 +0000 (14:19 -0700)]
[docs] Restore missing blank line

Lost in resolving conflicts for cdfa15da94f06289dcf86173d18b6627f92ac403.

2 years ago[Sanitizer][Darwin] Mark test UNSUPPORTED instead of XFAIL
Julian Lettner [Mon, 27 Jun 2022 21:16:43 +0000 (14:16 -0700)]
[Sanitizer][Darwin] Mark test UNSUPPORTED instead of XFAIL

This is test is failing/passing depending on the host OS version.  Need
to investigate/fix before re-enabling.

rdar://95982696

2 years agoRevert "[clang] Introduce -fstrict-flex-arrays=<n> for stricter handling of flexible...
Vitaly Buka [Mon, 27 Jun 2022 20:56:11 +0000 (13:56 -0700)]
Revert "[clang] Introduce -fstrict-flex-arrays=<n> for stricter handling of flexible arrays"

This reverts D126864 and related fixes.

This reverts commit 572b08790a69f955ae0cbb1b4a7d4a215f15dad9.
This reverts commit 886715af962de2c92fac4bd37104450345711e4a.

2 years ago[Sanitizer][Darwin] atos does not show line numbers for globals
Julian Lettner [Mon, 27 Jun 2022 20:58:12 +0000 (13:58 -0700)]
[Sanitizer][Darwin] atos does not show line numbers for globals

atos does not show line numbers for globals and will probably not
support this anytime soon.  Mark test UNSUPPORTED instead of XFAIL.

2 years ago[RISCV] Remove repeated calls to getSExtValue. NFC
Craig Topper [Mon, 27 Jun 2022 17:12:41 +0000 (10:12 -0700)]
[RISCV] Remove repeated calls to getSExtValue. NFC

2 years ago[RISCV] Add tests for (load (add X, [2048,4094])). NFC
Craig Topper [Mon, 27 Jun 2022 18:02:37 +0000 (11:02 -0700)]
[RISCV] Add tests for (load (add X, [2048,4094])). NFC

Offsets in the range [-4095,-2049] or [2048, 4094] are split into
two ADDIs. One of the ADDIs will be folded into the load/store
immediate through an post-isel peephole.

2 years ago[LV] Allow scalable vectorization with vscale = 1
Philip Reames [Mon, 27 Jun 2022 19:53:57 +0000 (12:53 -0700)]
[LV] Allow scalable vectorization with vscale = 1

This change is a bit subtle. If we have a type like <vscale x 1 x i64>, the vectorizer will currently reject vectorization. The reason is that a type like <1 x i64> is likely to get simply rescalarized, and the vectorizer doesn't want to be in the game of simple unrolling.

(I've given the example in terms of 1 x types which use a single register, but the same issue exists for any N x types which use N registers. e.g. RISCV LMULs.)

This change distinguishes scalable types from fixed types under the reasoning that converting to a scalable type isn't unrolling. Because the actual vscale isn't known until runtime, using a vscale type is potentially very profitable.

This makes an important, but unchecked, assumption. Specifically, the scalable type is assumed to only be legal per the cost model if there's actually a scalable register class which is distinct from the scalar domain. This is, to my knowledge, true for all targets which return non-invalid costs for scalable vector ops today, but in theory, we could have a target decide to lower scalable to fixed length vector or even scalar registers. If that ever happens, we'd need to revisit this code.

In practice, this patch unblocks scalable vectorization for ELEN types on RISCV.

Let me sketch one alternate implementation I considered. We could have restricted this to when we know a minimum value for vscale. Specifically, for the default +v extension for RISCV, we actually know that vscale >= 2 for ELEN types. However, doing it this way means we can't generate scalable vectors when using the various embedded vector extensions which have a minimum vscale of 1.

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

2 years agoAdd wait for child processe(s) to exit. (amended+clang-formatted)
Roy Sundahl [Fri, 24 Jun 2022 23:25:09 +0000 (16:25 -0700)]
Add wait for child processe(s) to exit. (amended+clang-formatted)

It was possible for the parent process to exit before the
forked child process had finished. In some shells, this
causes the pipe to close and FileCheck misses some output
from the child. Waiting for the child process to exit before
exiting the parent, assures that all output from stdout and
stderr is combined and forwarded through the pipe to FileCheck.

rdar://95241490

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

2 years ago[libc++][lit][AIX] Port tests for getting time to AIX
Xing Xue [Mon, 27 Jun 2022 20:07:27 +0000 (16:07 -0400)]
[libc++][lit][AIX] Port tests for getting time to AIX

Summary:
This patch ports libc++ LIT test cases for getting time in various locales to AIX.

Reviewed by: philnik, Mordante, libc++

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

2 years ago[libc++][lit][AIX] Port tests for money format to AIX
Xing Xue [Mon, 27 Jun 2022 19:57:54 +0000 (15:57 -0400)]
[libc++][lit][AIX] Port tests for money format to AIX

Summary:
This patch ports libc++ LIT test cases for money formats to AIX. On AIX, the money format of locale zh_CN.UTF-8 is the similar to that of en_US.UTF-8, i.e., sign, symbol, none, value.

Reviewed by: Mordante, DiggerLin, libc++

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

2 years ago[RISCV] Remove a use of getMinVLen in favor of getRealMinVLen
Philip Reames [Mon, 27 Jun 2022 19:46:09 +0000 (12:46 -0700)]
[RISCV] Remove a use of getMinVLen in favor of getRealMinVLen

The later is possibly greater than the former, and thus the assert was overly strong when a wider VLEN was set at the command line.

2 years ago[RISCV] Cost model for scalable reductions
Philip Reames [Sun, 26 Jun 2022 19:50:57 +0000 (12:50 -0700)]
[RISCV] Cost model for scalable reductions

This extends the existing cost model for reductions for scalable vectors.

The existing cost model assumes that reductions are roughly logarithmic in cost for unordered variants and linear for ordered ones. This change keeps that same basic model, and extends it out to the maximum number of elements a scalable vector could possibly have.

This results in costs which aren't terribly high for unordered reductions, but are for ordered ones. This seems about right; we want to strongly bias away from using scalable ordered reductions if the cost might be linear in VL.

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

2 years agoRevert "[X86] Support `_Float16` on SSE2 and up"
Vitaly Buka [Mon, 27 Jun 2022 19:42:08 +0000 (12:42 -0700)]
Revert "[X86] Support `_Float16` on SSE2 and up"

Breaks buildbot
https://lab.llvm.org/buildbot/#/builders/37/builds/14334

This reverts commit f5d781d6273cc56dd8b44ee9e4cfb2ae5579bb04.

2 years ago[mlir][bufferize] Improve to_tensor/to_memref folding
Matthias Springer [Mon, 27 Jun 2022 19:34:09 +0000 (21:34 +0200)]
[mlir][bufferize] Improve to_tensor/to_memref folding

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

2 years ago[test] Add workaround for flaky error we see on Windows bots
Vitaly Buka [Mon, 27 Jun 2022 19:36:33 +0000 (12:36 -0700)]
[test] Add workaround for flaky error we see on Windows bots

2 years ago[NFC][lldb] Correct Module::FindFunctions documentation
Alex Langford [Mon, 27 Jun 2022 19:32:18 +0000 (12:32 -0700)]
[NFC][lldb] Correct Module::FindFunctions documentation

Looks like a copy/paste from ModuleList::FindCompileUnits.

2 years agoFix sphinx docs build
Yuanfang Chen [Mon, 27 Jun 2022 19:22:02 +0000 (12:22 -0700)]
Fix sphinx docs build

Fix "Title underline too short."

2 years ago[Coroutine] Remove the '!func_sanitize' metadata for split functions
Yuanfang Chen [Mon, 27 Jun 2022 18:36:32 +0000 (11:36 -0700)]
[Coroutine] Remove the '!func_sanitize' metadata for split functions

There is no proper RTTI for these split functions. So just delete the
metadata.

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

Reviewed By: rjmccall

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

2 years ago[ubsan] Using metadata instead of prologue data for function sanitizer
Yuanfang Chen [Mon, 27 Jun 2022 18:33:45 +0000 (11:33 -0700)]
[ubsan] Using metadata instead of prologue data for function sanitizer

Information in the function `Prologue Data` is intentionally opaque.
When a function with `Prologue Data` is duplicated. The self (global
value) references inside `Prologue Data` is still pointing to the
original function. This may cause errors like `fatal error: error in backend: Cannot represent a difference across sections`.

This patch detaches the information from function `Prologue Data`
and attaches it to a function metadata node.

This and D116130 fix https://github.com/llvm/llvm-project/issues/49689.

Reviewed By: pcc

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

2 years ago[clang][dataflow] Add `buildAndSubstituteFlowCondition` to `DataflowEnvironment`
Wei Yi Tee [Mon, 27 Jun 2022 19:05:36 +0000 (21:05 +0200)]
[clang][dataflow] Add `buildAndSubstituteFlowCondition` to `DataflowEnvironment`

Depends On D128658

Reviewed By: gribozavr2, xazax.hun

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

2 years ago[clang][dataflow] Do not allow substitution of true/false boolean literals in `buildA...
Wei Yi Tee [Mon, 27 Jun 2022 18:53:07 +0000 (20:53 +0200)]
[clang][dataflow] Do not allow substitution of true/false boolean literals in `buildAndSubstituteFlowCondition`

Reviewed By: gribozavr2, xazax.hun

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

2 years ago[mlir][sparse] remove redundant whitespace
Aart Bik [Mon, 27 Jun 2022 18:36:35 +0000 (11:36 -0700)]
[mlir][sparse] remove redundant whitespace

Reviewed By: Peiming

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

2 years ago[MLIR][Parser] Fix AffineParser colliding bare identifiers with primitive types
Groverkss [Mon, 27 Jun 2022 18:35:20 +0000 (19:35 +0100)]
[MLIR][Parser] Fix AffineParser colliding bare identifiers with primitive types

The parser currently can't parse bare identifiers like 'i0' in affine
maps and sets, and similarly ids like f16/f32. But these bare ids are
part of the grammar - although they are primitive types.

```
error: expected bare identifier
set = affine_set<(i0, i1) : ()>
                   ^
```

This patch allows the parser for AffineMap/IntegerSet to parse bare
identifiers as defined by the grammer.

Reviewed By: bondhugula, rriddle

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

2 years ago[mlir][sparse]more integration test cases for sparse_tensor.BinaryOp
Peiming Liu [Mon, 27 Jun 2022 17:59:46 +0000 (10:59 -0700)]
[mlir][sparse]more integration test cases for sparse_tensor.BinaryOp

Adding more test cases for sparse_tensor.BinaryOp, including different cases when overlap/left/right region is implemented/empty/identity

Reviewed By: aartbik

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

2 years ago[Symbolize] Fix MarkupFilter tests for Windows.
Daniel Thornburgh [Mon, 27 Jun 2022 18:13:52 +0000 (11:13 -0700)]
[Symbolize] Fix MarkupFilter tests for Windows.

The tests use in-band ANSI color codes, while the Windows cmd console
uses an out-of-band interface for color.

2 years ago[Symbolize] Fix llvm-symbolizer --filter-markup test on Windows.
Daniel Thornburgh [Mon, 27 Jun 2022 18:13:52 +0000 (11:13 -0700)]
[Symbolize] Fix llvm-symbolizer --filter-markup test on Windows.

The tests use in-band ANSI color codes, while the Windows cmd console
uses an out-of-band interface for color.

2 years ago[BOLT] Restrict icp-inline to callsites
Amir Ayupov [Mon, 27 Jun 2022 17:30:30 +0000 (10:30 -0700)]
[BOLT] Restrict icp-inline to callsites

ICP peel for inline mode only makes sense for calls, not jump tables.
Plus, add a check that the Target BinaryFunction is found.

Reviewed By: rafauler

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

2 years ago[mlir][sparse]Add more integration tests for sparse_tensor.unary
Peiming Liu [Mon, 27 Jun 2022 17:17:58 +0000 (10:17 -0700)]
[mlir][sparse]Add more integration tests for sparse_tensor.unary

Previously, the sparse_tensor.unary integration test does not contain cases with the use of `linalg.index` (previoulsy unsupported), this commit adds test cases that use `linalg.index` operators.

Reviewed By: aartbik

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

2 years ago[gn build] Port eb5af0acf054
LLVM GN Syncbot [Mon, 27 Jun 2022 17:44:48 +0000 (17:44 +0000)]
[gn build] Port eb5af0acf054

2 years ago[Symbolize] Add log markup --filter to llvm-symbolizer.
Daniel Thornburgh [Wed, 4 May 2022 22:47:42 +0000 (22:47 +0000)]
[Symbolize] Add log markup --filter to llvm-symbolizer.

This adds a --filter option to llvm-symbolizer. This takes log-bearing
symbolizer markup from stdin and writes a human-readable version to
stdout.

For now, this only implements the "symbol" markup tag; all others are
passed through unaltered. This is a proof-of-concept bit of
functionalty; implement the various tags is more-or-less just a matter
of hooking up various parts of the Symbolize library to the architecture
established here.

Reviewed By: peter.smith

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

2 years ago[Docs] Update clang & llvm release notes for HLSL
Chris Bieneman [Thu, 16 Jun 2022 19:34:57 +0000 (14:34 -0500)]
[Docs] Update clang & llvm release notes for HLSL

Adding release note entries for LLVM & Clang to introduce the HLSL &
DirectX support that is being added.

Reviewed By: aaron.ballman, MaskRay

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

2 years ago[OpenMP] Only strip runtime attributes if needed
Joseph Huber [Mon, 27 Jun 2022 17:23:25 +0000 (13:23 -0400)]
[OpenMP] Only strip runtime attributes if needed

Summary:
Currently in OpenMPOpt we strip `noinline` attributes from runtime
functions. This is here because the device bitcode library that we link
has problems with needed definitions getting prematurely optimized out.
This is only necessary for OpenMP offloading to GPUs so we should narrow
the scope for where we spend time doing this. In the future this
shouldn't be necessary as we move to using a linked library rather than
pulling in a bitcode library in Clang.

2 years ago[libc][docs] Added fmod performance results.
Kirill Okhotnikov [Mon, 27 Jun 2022 17:30:31 +0000 (19:30 +0200)]
[libc][docs] Added fmod performance results.

2 years ago[BOLT][NFC] Add aliases for ICP flags
Amir Ayupov [Mon, 27 Jun 2022 17:29:10 +0000 (10:29 -0700)]
[BOLT][NFC] Add aliases for ICP flags

- `indirect-call-promotion` -> `icp`
- `indirect-call-promotion-mispredict-threshold` -> `icp-mp-threshold`
- `indirect-call-promotion-use-mispredicts` -> `icp-use-mp`
- `indirect-call-promotion-topn` -> `icp-topn`
- `indirect-call-promotion-calls-topn` -> `icp-calls-topn`
- `indirect-call-promotion-jump-tables-topn` -> `icp-jt-topn`
- `icp-jump-table-targets` -> `icp-jt-targets`

This also fixes an inconsistency in ICP flag names that some start with
`indirect-call-promotion` while others start with `icp`.

Reviewed By: rafauler

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

2 years ago[BOLT][NFC] Use llvm::less_first
Amir Ayupov [Mon, 27 Jun 2022 17:26:55 +0000 (10:26 -0700)]
[BOLT][NFC] Use llvm::less_first

Follow the case of https://reviews.llvm.org/D126068 and simplify call sites
with `llvm::less_first`.

Reviewed By: rafauler

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

2 years ago[NFC][SVE] Add more tests of vector compares and selects taking an immediate operand.
Paul Walker [Wed, 22 Jun 2022 15:03:44 +0000 (16:03 +0100)]
[NFC][SVE] Add more tests of vector compares and selects taking an immediate operand.

Increases coverage of predicated compares (int and fp) along with
predicated zeroing of active floating point lanes.

2 years agollvm-reduce: Check shouldKeep before trying to reduce operands
Matt Arsenault [Thu, 9 Jun 2022 15:17:09 +0000 (11:17 -0400)]
llvm-reduce: Check shouldKeep before trying to reduce operands

No point doing the more complicated check first.

2 years ago[lldb] Add a log dump command
Jonas Devlieghere [Mon, 27 Jun 2022 17:00:05 +0000 (10:00 -0700)]
[lldb] Add a log dump command

Add a log dump command to dump logs to a file. This only works for
channels that have a log handler associated that supports dumping. For
now that's limited to the circular log handler, but more could be added
in the future.

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

2 years agoRound up zero-sized symbols to 1 byte in `.debug_aranges` (without breaking other...
Patrick Walton [Mon, 27 Jun 2022 17:00:43 +0000 (10:00 -0700)]
Round up zero-sized symbols to 1 byte in `.debug_aranges` (without breaking other logic).

This commit modifies the AsmPrinter to avoid emitting any zero-sized symbols to
the .debug_aranges table, by rounding their size up to 1. Entries with zero
length violate the DWARF 5 spec, which states:

> Each descriptor is a triple consisting of a segment selector, the beginning
> address within that segment of a range of text or data covered by some entry
> owned by the corresponding compilation unit, followed by the non-zero length
> of that range.

In practice, these zero-sized entries produce annoying warnings in lld and
cause GNU binutils to truncate the table when parsing it.

Other parts of LLVM, such as DWARFDebugARanges in the DebugInfo module
(specifically the appendRange method), already avoid emitting zero-sized
symbols to .debug_aranges, but not comprehensively in the AsmPrinter. In fact,
the AsmPrinter does try to avoid emitting such zero-sized symbols when labels
aren't involved, but doesn't when the symbol to emitted is a difference of two
labels; this patch extends that logic to handle the case in which the symbol is
defined via labels.

Furthermore, this patch fixes a bug in which `available_externally` symbols
would cause unpredictable values to be emitted into the `.debug_aranges` table
under certain circumstances. In practice I don't believe that this caused
issues up until now, but the root cause of this bug--an invalid DenseMap
lookup--triggered failures in Chromium when combined with an earlier version of
this patch. Therefore, this patch fixes that bug too.

This is a revised version of diff D126257, which was reverted due to breaking
tests. The now-reverted version of this patch didn't distinguish between
symbols that didn't have their size reported to the DwarfDebug handler and
those that had their size reported to be zero. This new version of the patch
instead restricts the special handling only to the symbols whose size is
definitively known to be zero.

Reviewed By: dblaikie

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

2 years ago[libc++] Add a few missing min/max macro push/pop
Louis Dionne [Mon, 27 Jun 2022 15:37:01 +0000 (11:37 -0400)]
[libc++] Add a few missing min/max macro push/pop

Also, improve the test for nasty macros to define min and max, so this
will be caught in the future.

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

2 years ago[mlir][LLVMIR] Memorize compatible LLVM types
Min-Yih Hsu [Tue, 24 May 2022 22:24:23 +0000 (15:24 -0700)]
[mlir][LLVMIR] Memorize compatible LLVM types

This patch memorize compatible LLVM types in `LLVM::isCompatibleType` in
order to avoid redundant works.

This is especially useful when the size of program is big and there are
multiple occurrences of some deeply nested LLVM struct types, in which
case we can gain quite some speedups with this patch.

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

2 years ago[mlir][LLVMIR] Add support for va_start/copy/end intrinsics
Min-Yih Hsu [Mon, 23 May 2022 20:52:38 +0000 (13:52 -0700)]
[mlir][LLVMIR] Add support for va_start/copy/end intrinsics

This patch adds three new LLVM intrinsic operations: llvm.intr.vastart/copy/end.
And its translation from LLVM IR.

This effectively removes a restriction, imposed by 0126dcf1f0a1, where
non-external functions in LLVM dialect cannot be variadic. At that time
it was not clear how LLVM intrinsics are going to be modeled, which
indirectly affects va_start/copy/end, the core intrinsics used in
variadic functions. But since we have LLVM intrinsics as normal
MLIR operations, it's not a problem anymore.

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

2 years ago[memprof] Return an error for unsupported symbolization.
Snehasish Kumar [Fri, 24 Jun 2022 23:34:18 +0000 (16:34 -0700)]
[memprof] Return an error for unsupported symbolization.

Add a check to detect that the profiled binary was build with position
independent code. Add a test with a pie binary to which can be reused
later when support is added. Also clean up the error messages with
trailing colons.

Reviewed By: tejohnson

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

2 years ago[lldb] [llgs] Skip new vCont test on Windows
Michał Górny [Mon, 27 Jun 2022 16:22:15 +0000 (18:22 +0200)]
[lldb] [llgs] Skip new vCont test on Windows

Sponsored by: The FreeBSD Foundation

2 years ago[llvm-ar] Fix MRI ADDLIB command when used with thin archives
gbreynoo [Mon, 27 Jun 2022 16:10:11 +0000 (17:10 +0100)]
[llvm-ar] Fix MRI ADDLIB command when used with thin archives

We did not properly handle using CREATETHIN in an MRI script and
attempting to use ADDLIB to add the contents of a regular archive. This
fix outputs a meaningful error message in this case and provides some
more testing.

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

2 years agoSilence an "illegal conversion" diagnostic
Aaron Ballman [Mon, 27 Jun 2022 16:02:34 +0000 (12:02 -0400)]
Silence an "illegal conversion" diagnostic

MSVC was issuing "illegal conversion; more than one user-defined
conversion has been implicitly applied" as a warning on this code.
Explicitly calling .str() causes a StringRef to be materialized so
that a second user-defined conversion is not required.

2 years ago[Clang][OpenMP] Claim nowait clause on taskwait
Chi Chun Chen [Mon, 27 Jun 2022 16:02:39 +0000 (11:02 -0500)]
[Clang][OpenMP] Claim nowait clause on taskwait

2 years agoSilence some format specifier warnings
Aaron Ballman [Mon, 27 Jun 2022 15:52:41 +0000 (11:52 -0400)]
Silence some format specifier warnings

This solves a format specifier warning for char32_t being converted to
an unsigned integer type, and multiple format specifier warnings for
size_t being converted to long.

2 years ago[libc++][doc] Fixes a broken table entry.
Mark de Wever [Mon, 27 Jun 2022 15:42:37 +0000 (17:42 +0200)]
[libc++][doc] Fixes a broken table entry.

2 years ago[AMDGPU] Cluster stores as well as loads for GFX11
Jay Foad [Fri, 24 Jun 2022 12:26:50 +0000 (13:26 +0100)]
[AMDGPU] Cluster stores as well as loads for GFX11

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

2 years ago[Driver][test] Add libclang_rt.profile{{.*}}.a tests for NetBSD
Frederic Cambus [Sun, 26 Jun 2022 22:26:22 +0000 (00:26 +0200)]
[Driver][test] Add libclang_rt.profile{{.*}}.a tests for NetBSD

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

2 years agoAdding support for target in_reduction
Ritanya B Bharadwaj [Mon, 27 Jun 2022 15:35:30 +0000 (10:35 -0500)]
Adding support for target in_reduction

Implementing target in_reduction by wrapping target task with host task with in_reduction and if clause. This is in compliance with OpenMP 5.0 section: 2.19.5.6.
So, this

```
  for (int i=0; i<N; i++) {
    res = res+i
  }
```

will become

```

   #pragma omp task in_reduction(+:res) if(0)
   #pragma omp target map(res)
   for (int i=0; i<N; i++) {
     res = res+i
   }
```

Reviewed By: ABataev

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

2 years ago[lldb] [llgs] Support "t" vCont action
Michał Górny [Fri, 3 Jun 2022 18:21:26 +0000 (20:21 +0200)]
[lldb] [llgs] Support "t" vCont action

Implement support for the "t" action that is used to stop a thread.
Normally this action is used only in non-stop mode.  However, there's
no technical reason why it couldn't be also used in all-stop mode,
e.g. to express "resume all threads except ..." (`t:...;c`).

While at it, add a more complete test for vCont correctly resuming
a subset of program's threads.

Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.llvm.org/D126983

2 years ago[flang][driver] Use `-O{0|1|2|3}` to define LLVM backend pass pipeline
Andrzej Warzynski [Fri, 17 Jun 2022 13:08:42 +0000 (13:08 +0000)]
[flang][driver] Use `-O{0|1|2|3}` to define LLVM backend pass pipeline

Support for optimisation flags in LLVM Flang was originally added in
https://reviews.llvm.org/D128043. That patch focused on LLVM
middle-end/optimisation pipelines. With this patch, Flang will
additionally configure LLVM backend pass pipelines accordingly. This
behavior is consistent with Clang.

New hook is added to translate compiler optimisation flags (e.g. `-O3`)
into backend optimisation level: `getCGOptLevel`. Identical hooks are
available in Clang and LLVM. In other words, the meaning of these
optimisation flags remains consistent with other sub-projects that use
LLVM backends.

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

2 years ago[mlir][SCF][bufferize] Small simplification and more comments
Matthias Springer [Mon, 27 Jun 2022 15:02:45 +0000 (17:02 +0200)]
[mlir][SCF][bufferize] Small simplification and more comments

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

2 years ago[GlobalOpt] Fix memset handling in global ctor evaluation (PR55859)
Nikita Popov [Fri, 24 Jun 2022 14:02:28 +0000 (16:02 +0200)]
[GlobalOpt] Fix memset handling in global ctor evaluation (PR55859)

The global ctor evaluator currently handles by checking whether the
memset memory is already zero, and skips it in that case. However,
it only actually checks the first byte of the memory being set.

This patch extends the code to check all bytes being set. This is
done byte-by-byte to avoid converting undef values to zeros in
larger reads. However, the handling is still not completely correct,
because there might still be padding bytes (though probably this
doesn't matter much in practice, as I'd expect global variable
padding to be zero-initialized in practice).

Mostly fixes https://github.com/llvm/llvm-project/issues/55859.

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

2 years ago[mlir][complex] complex.arg op to calculate the angle of complex number
Lewuathe [Mon, 27 Jun 2022 12:29:15 +0000 (14:29 +0200)]
[mlir][complex] complex.arg op to calculate the angle of complex number

Add complex.arg op which calculates the angle of complex number. The op name is inspired by the function carg in libm.

See: https://sourceware.org/newlib/libm.html#carg

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

2 years ago[GlobalOpt] Add tests for memset with non-zero value (NFC)
Nikita Popov [Mon, 27 Jun 2022 14:36:10 +0000 (16:36 +0200)]
[GlobalOpt] Add tests for memset with non-zero value (NFC)

2 years ago[mlir][bufferize] Infer memory space in all bufferization patterns
Matthias Springer [Mon, 27 Jun 2022 14:28:38 +0000 (16:28 +0200)]
[mlir][bufferize] Infer memory space in all bufferization patterns

This change updates all remaining bufferization patterns (except for scf.while) and the remaining bufferization infrastructure to infer the memory space whenever possible instead of falling back to "0". (If a default memory space is set in the bufferization options, we still fall back to that value if the memory space could not be inferred.)

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

2 years agotsan: add missing guard for DumpProcessMap call
Than McIntosh [Mon, 27 Jun 2022 13:28:18 +0000 (09:28 -0400)]
tsan: add missing guard for DumpProcessMap call

Add a missing "#if !SANITIZER_GO" guard for a call to DumpProcessMap
in the Finalize hook (needed to build an updated Go race detector syso
image).

Reviewed By: dvyukov

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

2 years ago[mlir][bufferize][NFC] Change signature of allocateTensorForShapedValue
Matthias Springer [Mon, 27 Jun 2022 13:59:00 +0000 (15:59 +0200)]
[mlir][bufferize][NFC] Change signature of allocateTensorForShapedValue

Add a failure return value and bufferization options argument. This is to keep a subsequent change smaller.

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

2 years ago[X86] Support `_Float16` on SSE2 and up
Phoebe Wang [Mon, 27 Jun 2022 13:02:57 +0000 (21:02 +0800)]
[X86] Support `_Float16` on SSE2 and up

This is split from D113107 to address #56204 and https://discourse.llvm.org/t/how-to-build-compiler-rt-for-new-x86-half-float-abi/63366

Reviewed By: zahiraam, rjmccall, bkramer

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

2 years ago[libc++][NFC] Remove trailing whitespace
Louis Dionne [Mon, 27 Jun 2022 13:36:52 +0000 (09:36 -0400)]
[libc++][NFC] Remove trailing whitespace

2 years ago[Clang] Remove unused function declaration after 77475ffd22418ca72.
Florian Hahn [Mon, 27 Jun 2022 13:17:53 +0000 (14:17 +0100)]
[Clang] Remove unused function declaration after 77475ffd22418ca72.

2 years ago[libc++] Remove dummy command in Dockerfile
Louis Dionne [Mon, 27 Jun 2022 13:15:28 +0000 (09:15 -0400)]
[libc++] Remove dummy command in Dockerfile

It turns out that the Docker images on CI instances are not updated
based on what's in this file, but instead when a new image is pushed
to ldionne/libcxx-builder on DockerHub. So this is effectively useless.

2 years ago[mlir][llvm] Add vector insert/extract intrinsics
Javier Setoain [Mon, 6 Jun 2022 10:55:04 +0000 (11:55 +0100)]
[mlir][llvm] Add vector insert/extract intrinsics

These intrinsics will be needed to convert between fixed-length vectors
and scalable vectors.

This operation will be needed for VLS (vector-length specific)
vectorization, when interfacing with vector functions or intrinsics that
take scalable vectors as operands in a context where the length of our
vectors is known or assumed at compile time, but we still want to
generate scalable vector instructions.

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

2 years ago[SPARC] Don't do leaf optimization on procedures with inline assembly
Koakuma [Mon, 27 Jun 2022 12:52:10 +0000 (14:52 +0200)]
[SPARC] Don't do leaf optimization on procedures with inline assembly

On SPARC, leaf function optimization omits the register window sliding (and the associated register name changes). This might result in miscompilation of procedures containing inline assembly, as some of the register constraints used may interfere with the register usage of optimized functions, so we disable leaf procedure optimization on those procedures to prevent it from happening.

This is a continuation of patch D102342 by @LemonBoy, the original comment is reproduced below:

> Leaf functions allow the compiler to omit the setup and teardown of a frame pointer, therefore avoiding the exchange of the in/out register. According to the SPARC architecture manual every reference to %i0-%i5 should be replaced with %o0-o5, if the target register is already in use a further remapping step to %g1-%g7 is required to free the output register.
>
> Add a simple check to make sure not to stomp on any output register that's already in use.

Reviewed By: dcederman

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

2 years ago[ARM][Thumb] Command-line option to ensure AAPCS compliant Frame Records
Lucas Prates [Fri, 6 May 2022 09:31:11 +0000 (10:31 +0100)]
[ARM][Thumb] Command-line option to ensure AAPCS compliant Frame Records

Currently the a AAPCS compliant frame record is not always created for
functions when it should. Although a consistent frame record might not
be required in some cases, there are still scenarios where applications
may want to make use of the call hierarchy made available trough it.

In order to enable the use of AAPCS compliant frame records whilst keep
backwards compatibility, this patch introduces a new command-line option
(`-mframe-chain=[none|aapcs|aapcs+leaf]`) for Aarch32 and Thumb backends.
The option allows users to explicitly select when to use it, and is also
useful to ensure the extra overhead introduced by the frame records is
only introduced when necessary, in particular for Thumb targets.

Reviewed By: efriedma

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

2 years ago[flang][NFC] Add IO lowering tests
Valentin Clement [Mon, 27 Jun 2022 13:00:07 +0000 (15:00 +0200)]
[flang][NFC] Add IO lowering tests

These tests were left behind or only partially upstreamed during
the lower code upstreaming.

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

Reviewed By: PeteSteinfeld

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

Co-authored-by: Kiran Chandramohan <kiran.chandramohan@arm.com>
Co-authored-by: Jean Perier <jperier@nvidia.com>
2 years agoARM: don't try to load function pointer before long call.
Tim Northover [Mon, 27 Jun 2022 12:59:35 +0000 (13:59 +0100)]
ARM: don't try to load function pointer before long call.

Deciding to load an arbitrary global based on whether the entire module is
being built for long calls is pretty clearly spurious, and in fact the existing
indirect logic is sufficient.

2 years ago[IndVars] Add test for PR56242 (NFC)
Nikita Popov [Mon, 27 Jun 2022 12:54:03 +0000 (14:54 +0200)]
[IndVars] Add test for PR56242 (NFC)

2 years agoMIR: Fix parse error on empty CustomRegMask
Matt Arsenault [Wed, 22 Jun 2022 23:04:07 +0000 (19:04 -0400)]
MIR: Fix parse error on empty CustomRegMask

2 years ago[gn build] Port 633d1d0df766
LLVM GN Syncbot [Mon, 27 Jun 2022 12:35:34 +0000 (12:35 +0000)]
[gn build] Port 633d1d0df766

2 years ago[libc++] Use bounded iterators in std::span when the debug mode is enabled
Louis Dionne [Mon, 6 Jun 2022 18:01:38 +0000 (14:01 -0400)]
[libc++] Use bounded iterators in std::span when the debug mode is enabled

Previously, we'd use raw pointers when the debug mode was enabled,
which means we wouldn't get out-of-range checking with std::span's
iterators.

This patch introduces a new class called __bounded_iter which can
be used to wrap iterators and make them carry around bounds-related
information. This allows iterators to assert when they are dereferenced
outside of their bounds.

As a fly-by change, this commit removes the _LIBCPP_ABI_SPAN_POINTER_ITERATORS
knob. Indeed, not using a raw pointer as the iterator type is useful to
avoid users depending on properties of raw pointers in their code.

This is an alternative to D127401.

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

2 years ago[libc++] Improve Lit's buildhost=XXXX feature on a few platforms
Louis Dionne [Thu, 23 Jun 2022 19:09:52 +0000 (15:09 -0400)]
[libc++] Improve Lit's buildhost=XXXX feature on a few platforms

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

2 years ago[flang][NFC] Add array lowering tests
Valentin Clement [Mon, 27 Jun 2022 12:19:23 +0000 (14:19 +0200)]
[flang][NFC] Add array lowering tests

These tests were left behind during the upstreaming of parts lowering.

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

Reviewed By: jeanPerier

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

Co-authored-by: V Donaldson <vdonaldson@nvidia.com>
Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2 years ago[clang][dataflow] Singleton pointer values for null pointers.
Wei Yi Tee [Mon, 27 Jun 2022 12:14:01 +0000 (14:14 +0200)]
[clang][dataflow] Singleton pointer values for null pointers.

When a `nullptr` is assigned to a pointer variable, it is wrapped in a `ImplicitCastExpr` with cast kind `CK_NullTo(Member)Pointer`. This patch assigns singleton pointer values representing null to these expressions.

For each pointee type, a singleton null `PointerValue` is created and stored in the `NullPointerVals` map of the `DataflowAnalysisContext` class. The pointee type is retrieved from the implicit cast expression, and used to initialise the `PointeeLoc` field of the `PointerValue`. The `PointeeLoc` created is not mapped to any `Value`, reflecting the absence of value indicated by null pointers.

Reviewed By: gribozavr2, sgatev, xazax.hun

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

2 years ago[SCF] Add thread_dim_mapping attribute to scf.foreach_thread
Nicolas Vasilache [Fri, 24 Jun 2022 09:26:22 +0000 (02:26 -0700)]
[SCF] Add thread_dim_mapping attribute to scf.foreach_thread

An optional thread_dim_mapping index array attribute specifies for each
virtual thread dimension, how it remaps 1-1 to a set of concrete processing
element resources (e.g. a CUDA grid dimension or a level of concrete nested
async parallelism). At this time, the specification is backend-dependent and
is not verified by the op, beyond being an index array attribute.
It is the reponsibility of the lowering to interpret the index array in the
context of the concrete target the op is lowered to, or to ignore it when
the specification is ill-formed or unsupported for a particular target.

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

2 years ago[mlir][bufferization][NFC] Add error handling to getBuffer
Matthias Springer [Mon, 27 Jun 2022 11:46:37 +0000 (13:46 +0200)]
[mlir][bufferization][NFC] Add error handling to getBuffer

This is in preparation of adding memory space support.

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

2 years ago[mlir][bufferization][NFC] Fix typo in AllocTensorOp builders
Matthias Springer [Mon, 27 Jun 2022 11:41:18 +0000 (13:41 +0200)]
[mlir][bufferization][NFC] Fix typo in AllocTensorOp builders

2 years ago[mlir][SCF][bufferize][NFC] Bufferize scf.for terminator separately
Matthias Springer [Mon, 27 Jun 2022 11:25:52 +0000 (13:25 +0200)]
[mlir][SCF][bufferize][NFC] Bufferize scf.for terminator separately

This allows for better type inference during bufferization and is in preparation of supporting memory spaces.

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

2 years ago[mlir][SCF][bufferize] Bufferize scf.if/execute_region terminators separately
Matthias Springer [Mon, 27 Jun 2022 11:17:45 +0000 (13:17 +0200)]
[mlir][SCF][bufferize] Bufferize scf.if/execute_region terminators separately

This allows for better type inference during bufferization and is in preparation of supporting memory spaces.

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