platform/upstream/llvm.git
2 years ago[OpenMP] Add variant extension that applies to declarations
Joseph Huber [Wed, 29 Jun 2022 18:53:45 +0000 (14:53 -0400)]
[OpenMP] Add variant extension that applies to declarations

This patch adds a new extension to the `omp begin / end declare variant`
support that causes it to apply to function declarations as well. This
is explicitly not done in the standard, but can be useful in some
situations so we should provide it as an extension. This will allow us
to uniquely bind and overload existing definitions with a simple
declaration using variants.

Reviewed By: jdoerfert

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

2 years agoAMDGPU: Add gfx11 feature to force initializing 16 input SGPRs
Matt Arsenault [Mon, 24 Jan 2022 16:35:34 +0000 (11:35 -0500)]
AMDGPU: Add gfx11 feature to force initializing 16 input SGPRs

The total user+system SGPR count needs to be padded out to 16 if fewer
inputs are enabled.

2 years ago[LinkerWrapper] Change wrapping to include jumps for other variables
Joseph Huber [Wed, 29 Jun 2022 18:39:42 +0000 (14:39 -0400)]
[LinkerWrapper] Change wrapping to include jumps for other variables

Summary:
We don't currently support other variable types, like managed or
surface. This patch simply adds code that checks the flags and does
nothing. This prevents us from registering a surface as a variable as we
do now. In the future, registering these will require adding the flags
to the entry struct.

2 years ago[flang][runtime] Emit "0.0E+0" for (1PG0.0) editing of 0.0
Peter Klausler [Mon, 27 Jun 2022 21:22:31 +0000 (14:22 -0700)]
[flang][runtime] Emit "0.0E+0" for (1PG0.0) editing of 0.0

When a scale factor is in effect, respect it for G0.0 output editing.

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

2 years ago[Clang][Preprocessor] Fix inconsistent `FLT_EVAL_METHOD` when compiling vs preprocessing
Egor Zhdan [Wed, 29 Jun 2022 12:35:54 +0000 (13:35 +0100)]
[Clang][Preprocessor] Fix inconsistent `FLT_EVAL_METHOD` when compiling vs preprocessing

When running `clang -E -Ofast` on macOS, the `__FLT_EVAL_METHOD__` macro is `0`, which causes the following typedef to be emitted into the preprocessed source: `typedef float float_t`.

However, when running `clang -c -Ofast`, `__FLT_EVAL_METHOD__` is `-1`, and `typedef long double float_t` is emitted.

This causes build errors for certain projects, which are not reproducible when compiling from preprocessed source.

The issue is that `__FLT_EVAL_METHOD__` is configured in `Sema::Sema` which is not executed when running in `-E` mode.

This change moves that logic into the preprocessor initialization method, which is invoked correctly in `-E` mode.

rdar://96134605
rdar://92748429

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

2 years ago[flang] Better error recovery for bad submodules
Peter Klausler [Thu, 23 Jun 2022 00:42:57 +0000 (17:42 -0700)]
[flang] Better error recovery for bad submodules

When a submodule appears in a source file and the compiler can't find the
named ancestor module (and submodule, if one appears), crashes may occur
later due to the absence of a scope.  For better resilience, a dummy
ancestral scope should be generated within which the submodule scope
can be created.

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

2 years ago[flang] Fix lowering issue with character temp
Valentin Clement [Wed, 29 Jun 2022 18:06:11 +0000 (20:06 +0200)]
[flang] Fix lowering issue with character temp

- Add verifiers that determine if an Op requires type parameters or
  not and checks that the correct number of parameters is specified.

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

Reviewed By: PeteSteinfeld

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

Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2 years agoFix CombineContractBroadcast folding reduction iterators.
Benoit Jacob [Tue, 28 Jun 2022 16:50:39 +0000 (16:50 +0000)]
Fix CombineContractBroadcast folding reduction iterators.

Fix CombineContractBroadcast folding reduction iterators.

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

2 years ago[lldb] Attempt to fix TestStepThroughTrampoline on windows
Pavel Labath [Wed, 29 Jun 2022 17:59:24 +0000 (19:59 +0200)]
[lldb] Attempt to fix TestStepThroughTrampoline on windows

2 years ago[llvm-objcopy] Remove support for legacy .zdebug sections
Fangrui Song [Wed, 29 Jun 2022 17:42:54 +0000 (10:42 -0700)]
[llvm-objcopy] Remove support for legacy .zdebug sections

clang 14 removed -gz=zlib-gnu support and ld.lld removed linker input support
for zlib-gnu in D126793. Now let's remove zlib-gnu from llvm-objcopy.

* .zdebug* sections are no longer recognized as debug sections. --strip* don't remove them.
  They are copied like other opaque sections
* --decompress-debug-sections does not uncompress .zdebug* sections
* --compress-debug-sections=zlib-gnu is not supported

It is very rare but in case a user has object files using .zdebug . They can use
llvm-objcopy<15 or GNU objcopy for uncompression.
--compress-debug-sections=zlib-gnu is unlikely ever used by anyone, so I do not
add a custom diagnostic.

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

2 years agoRevert "[RISCV] Avoid changing etype for splat of 0 or -1"
Philip Reames [Wed, 29 Jun 2022 17:24:38 +0000 (10:24 -0700)]
Revert "[RISCV] Avoid changing etype for splat of 0 or -1"

This reverts commit 755c84c62cda80b0acf51ccc5653fc6d64536f7e.  A bug was reported on the original review thread (https://reviews.llvm.org/D128006), and on inspection this patch is simply wrong.  It needs to be checking for VLInBytes, not MaxVL.  These happen to be the same when using AVL=VLMAX (which is quite common), but this does not fold when AVL != VLMAX.

2 years ago[UnrollRuntime] Invalidate SCEVs for modified phis in ConnectEpilog.
Florian Hahn [Wed, 29 Jun 2022 17:26:00 +0000 (18:26 +0100)]
[UnrollRuntime] Invalidate SCEVs for modified phis in ConnectEpilog.

ConnectEpilog adds new incoming values to exit phi nodes which can
change the SCEV for the phi after 20d798bd47ec51.

Fix is analog to cfc741bc0e029.

Fixes #56282.

2 years ago[flang] Fix folding of LEN(f(...))
Peter Klausler [Thu, 16 Jun 2022 18:41:09 +0000 (11:41 -0700)]
[flang] Fix folding of LEN(f(...))

LEN(f(...)), where "f" is a non-intrinsic function, should not be folded
to anything else unless the result is a known constant value.  While there
are conceivable cases in which we could do better (e.g., an internal function
whose length is a host-associated INTENT(IN) dummy argument), there are
other cases that we're getting wrong.

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

2 years ago[clang-format] Fix incorrect isspace input (NFC)
Kevin Cadieux [Wed, 29 Jun 2022 16:06:46 +0000 (09:06 -0700)]
[clang-format] Fix incorrect isspace input (NFC)

This change fixes a clang-format unit test failure introduced by [D124748](https://reviews.llvm.org/D124748). The `countLeadingWhitespace` function was calling `isspace` with values that could fall outside the valid input range. The valid input range for `isspace` is unsigned 0-255. Values outside this range produce undefined behavior, which on Windows manifests as an assertion being raised in the debug runtime libraries. `countLeadingWhitespace` was calling `isspace` with a signed char that could produce a negative value if the underlying byte's value was 128 or above, which can happen for non-ASCII encodings. The fix is to use `StringRef`'s `bytes_begin` and `bytes_end` iterators to read the values as unsigned chars instead.

This bug can be reproduced by building the `check-clang-unit` target with a DEBUG configuration under Windows. This change is already covered by existing unit tests.

Reviewed By: MyDeveloperDay

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

2 years ago[llvm-ar] Add --output to specify output directory
Fangrui Song [Wed, 29 Jun 2022 17:00:42 +0000 (10:00 -0700)]
[llvm-ar] Add --output to specify output directory

From binutils 2.34 onwards, ar supports --output to specify a directory
where archive members should be extracted to. Port this feature.

Reviewed By: jhenderson

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

2 years ago[InstCombine] Relax test to avoid Darwin failure.
Martin Sebor [Wed, 29 Jun 2022 16:46:43 +0000 (10:46 -0600)]
[InstCombine] Relax test to avoid Darwin failure.

Avoid testing folding of atoi calls with out-of-bounds pointers.

2 years ago[InstCombine] add fold for (ShiftC >> X) >u C
Sanjay Patel [Wed, 29 Jun 2022 15:38:48 +0000 (11:38 -0400)]
[InstCombine] add fold for (ShiftC >> X) >u C

This is the 'ugt' sibling to:
0399473de886595d

Decrement the input compare constant (and implicitly
decrement the new compare constant):
https://alive2.llvm.org/ce/z/iELmct

2 years ago[InstCombine] add tests for (pow2 >> X) <u C; NFC
Sanjay Patel [Wed, 29 Jun 2022 14:43:55 +0000 (10:43 -0400)]
[InstCombine] add tests for (pow2 >> X) <u C; NFC

Adapted from af5e64df728f498ea9c6

2 years ago[Clang] Rename StringLiteral::isAscii() => isOrdinary() [NFC]
Corentin Jabot [Tue, 28 Jun 2022 21:48:48 +0000 (23:48 +0200)]
[Clang] Rename StringLiteral::isAscii() => isOrdinary() [NFC]

"Ascii" StringLiteral instances are actually narrow strings
that are UTF-8 encoded and do not have an encoding prefix.
(UTF8 StringLiteral are also UTF-8 encoded strings, but with
the u8 prefix.

To avoid possible confusion both with actuall ASCII strings,
and with future works extending the set of literal encodings
supported by clang, this rename StringLiteral::isAscii() to
isOrdinary(), matching C++ standard terminology.

Reviewed By: aaron.ballman

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

2 years ago[trace] Make events first class items in the trace cursor and rework errors
Walter Erquinigo [Fri, 24 Jun 2022 21:02:47 +0000 (14:02 -0700)]
[trace] Make events first class items in the trace cursor and rework errors

We want to include events with metadata, like context switches, and this
requires the API to handle events with payloads (e.g. information about
such context switches). Besides this, we want to support multiple
similar events between two consecutive instructions, like multiple
context switches. However, the current implementation is not good for this because
we are defining events as bitmask enums associated with specific
instructions. Thus, we need to decouple instructions from events and
make events actual items in the trace, just like instructions and
errors.

- Add accessors in the TraceCursor to know if an item is an event or not
- Modify from the TraceDumper all the way to DecodedThread to support
- Renamed the paused event to disabled.
- Improved the tsc handling logic. I was using an API for getting the tsc from libipt, but that was an overkill that should be used when not processing events manually, but as we are already processing events, we can more easily get the tscs.
event items. Fortunately this simplified many things
- As part of this refactor, I also fixed and long stating issue, which is that some non decoding errors were being inserted in the decoded thread. I changed this so that TraceIntelPT::Decode returns an error if the decoder couldn't be set up proplerly. Then, errors within a trace are actual anomalies found in between instrutions.

All test pass

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

2 years ago[RISCV] Select (srl (and X, C2) as (slli (srliw X, C3), C3-C).
Craig Topper [Wed, 29 Jun 2022 15:51:10 +0000 (08:51 -0700)]
[RISCV] Select (srl (and X, C2) as (slli (srliw X, C3), C3-C).

If C2 has 32 leading zeros and C3 trailing zeros.

2 years agoAMDGPU: Make packed 32-bit instructions rematerializable
Matt Arsenault [Sat, 25 Jun 2022 14:25:11 +0000 (10:25 -0400)]
AMDGPU: Make packed 32-bit instructions rematerializable

2 years agoAMDGPU: Make 16-bit pk instructions rematerializable
Matt Arsenault [Sat, 25 Jun 2022 17:24:31 +0000 (13:24 -0400)]
AMDGPU: Make 16-bit pk instructions rematerializable

2 years agoAMDGPU: Add rematerialize tests for 16-bit pk instructions
Matt Arsenault [Sat, 25 Jun 2022 16:56:51 +0000 (12:56 -0400)]
AMDGPU: Add rematerialize tests for 16-bit pk instructions

2 years ago[lldb] [test] Avoid relying on signos in other fork tests
Michał Górny [Wed, 29 Jun 2022 15:47:53 +0000 (17:47 +0200)]
[lldb] [test] Avoid relying on signos in other fork tests

Sponsored by: The FreeBSD Foundation

2 years ago[LV] Add test case showing dead recipe blocking region merging.
Florian Hahn [Wed, 29 Jun 2022 15:34:11 +0000 (16:34 +0100)]
[LV] Add test case showing dead recipe blocking region merging.

2 years agoAMDGPU: Mark more instructions as rematerializable
Matt Arsenault [Sat, 25 Jun 2022 15:39:59 +0000 (11:39 -0400)]
AMDGPU: Mark more instructions as rematerializable

D106023 excluded 16-bit instructions from rematerialization, with the
justification that we can't rematerialize instructions that preserve
the high bits (plus the instructions which do are a confusing mess
between different subtargets). This doesn't make sense to me as a
problem since cases where we would rely on the high bit behavior would
still need to be represented as a register value constraint with a
tied operand. It's not a hidden side effect and should still be
rematerializable.

2 years agoAMDGPU: Add more rematerialization tests for 16-bit instructions
Matt Arsenault [Sat, 25 Jun 2022 13:53:31 +0000 (09:53 -0400)]
AMDGPU: Add more rematerialization tests for 16-bit instructions

2 years ago[VectorCombine] Avoid ConstantExpr::get() (NFC)
Nikita Popov [Wed, 29 Jun 2022 15:17:20 +0000 (17:17 +0200)]
[VectorCombine] Avoid ConstantExpr::get() (NFC)

Use IRBuilder APIs instead, which will still constant fold.

2 years agoRevert "[libc][test] Remove dependency on sstream in algorithm_test.cpp"
Guillaume Chatelet [Wed, 29 Jun 2022 15:12:24 +0000 (15:12 +0000)]
Revert "[libc][test] Remove dependency on sstream in algorithm_test.cpp"

This reverts commit 292b281caf8c3750cc0796b971af2ca24236a926.

2 years ago[libc][test] Remove dependency on sstream in algorithm_test.cpp
Guillaume Chatelet [Wed, 29 Jun 2022 12:28:00 +0000 (12:28 +0000)]
[libc][test] Remove dependency on sstream in algorithm_test.cpp

Bots have been failing in full build mode because ´#include <sstream>´ would pull pthread which is not possible when code is compiled with ´-freestanding´.

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

2 years ago[mlir][Tensor] Improve documentation of verification behavior of InsertSliceOp.
Nicolas Vasilache [Wed, 29 Jun 2022 14:51:41 +0000 (07:51 -0700)]
[mlir][Tensor] Improve documentation of verification behavior of InsertSliceOp.

2 years ago[JumpThreading] Avoid ConstantExpr::get() (NFCI)
Nikita Popov [Wed, 29 Jun 2022 14:41:38 +0000 (16:41 +0200)]
[JumpThreading] Avoid ConstantExpr::get() (NFCI)

This code requires the result to be an UndefValue/ConstantInt
anyway (checked by getKnownConstant), so we are only interested
in the case where this folds.

2 years ago[mlir][Tensor][NFC] Better document rank-reducing behavior of ExtractSliceOp and...
Nicolas Vasilache [Wed, 29 Jun 2022 11:16:49 +0000 (04:16 -0700)]
[mlir][Tensor][NFC] Better document rank-reducing behavior of ExtractSliceOp and cleanup

2 years ago[PowerPC] Fix signatures for vec_replace_unaligned builtin
Lei Huang [Tue, 21 Jun 2022 16:54:40 +0000 (11:54 -0500)]
[PowerPC] Fix signatures for vec_replace_unaligned builtin

``vec_replace_unaligned`` is meant to return vuc to emphasize that elements
are being inserted on unnatural boundaries.

Reviewed By: amyk, quinnp

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

2 years agoAMDGPU: Use isMeta flags on pseudoinstructions
Matt Arsenault [Mon, 6 Jun 2022 21:19:03 +0000 (17:19 -0400)]
AMDGPU: Use isMeta flags on pseudoinstructions

2 years ago[InstCombine] Avoid some calls to ConstantExpr::get() (NFCI)
Nikita Popov [Wed, 29 Jun 2022 14:06:49 +0000 (16:06 +0200)]
[InstCombine] Avoid some calls to ConstantExpr::get() (NFCI)

Replace some calls to ConstantExpr::get() with IRBuilder APIs
(which will also constant fold if possible).

2 years ago[lldb] [test] Un-XFAIL fork tests on arm as well
Michał Górny [Wed, 29 Jun 2022 14:04:50 +0000 (16:04 +0200)]
[lldb] [test] Un-XFAIL fork tests on arm as well

Sponsored by: The FreeBSD Foundation

2 years ago[clang-cl] Handle some pragma alloc_text corner cases handled by MSVC
Stephen Long [Tue, 28 Jun 2022 13:45:18 +0000 (06:45 -0700)]
[clang-cl] Handle some pragma alloc_text corner cases handled by MSVC

MSVC's pragma alloc_text accepts a function that was redeclared in
a non extern-C context if the previous declaration was in an extern-C
context. i.e.

```
extern "C" { static void f(); }
static void f();
```

MSVC's pragma alloc_text also rejects non-functions.

Reviewed By: hans

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

2 years ago[AMDGPU] Remove FIXMEs that were resolved by D30134
Jay Foad [Wed, 29 Jun 2022 13:43:01 +0000 (14:43 +0100)]
[AMDGPU] Remove FIXMEs that were resolved by D30134

2 years ago[lldb] [test] Use raise(SIGSTOP) instead of trap in fork tests
Michał Górny [Wed, 29 Jun 2022 05:18:54 +0000 (07:18 +0200)]
[lldb] [test] Use raise(SIGSTOP) instead of trap in fork tests

Replace the use of "trap" with a new "stop" command in fork tests,
that maps to `raise(SIGSTOP)`.  Since traps do not increment PC on some
architectures (notably ARM), using traps would require special logic
to increment it while testing.  Using SIGSTOP avoids the problem
and is probably more logical, given that the purpose of the "trap"s
was to simply stop the inferior at a synchronization point.  This fixes
tests on AArch64 (and possibly ARM, I'll update XFAILs when it is
confirmed by the buildbot).

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

2 years ago[CUDA] Stop adding CUDA features twice
Joseph Huber [Tue, 28 Jun 2022 19:21:03 +0000 (15:21 -0400)]
[CUDA] Stop adding CUDA features twice

We currently call the `addNVPTXFeatures` function in two places, inside
of the CUDA Toolchain and inside of Clang in the standard entry point.
We normally add features to the job in Clang, so the call inside of the
CUDA toolchain is redundant and results in `+ptx` features being added.
Since we remove this call, we no longer will have a cached CUDA
installation so we will usually create it twice.

Reviewed By: tra

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

2 years ago[pseudo] Update the cxx.bnf path in comments to reflect the new
Haojian Wu [Wed, 29 Jun 2022 13:10:39 +0000 (15:10 +0200)]
[pseudo] Update the cxx.bnf path in comments to reflect the new
location, NFC

2 years agoImprove handling of static assert messages.
Corentin Jabot [Fri, 20 Aug 2021 15:52:28 +0000 (17:52 +0200)]
Improve handling of static assert messages.

Instead of dumping the string literal (which
quotes it and escape every non-ascii symbol),
we can use the content of the string when it is a
8 byte string.

Wide, UTF-8/UTF-16/32 strings are still completely
escaped, until we clarify how these entities should
behave (cf https://wg21.link/p2361).

`FormatDiagnostic` is modified to escape
non printable characters and invalid UTF-8.

This ensures that unicode characters, spaces and new
lines are properly rendered in static messages.
This make clang more consistent with other implementation
and fixes this tweet
https://twitter.com/jfbastien/status/1298307325443231744 :)

Of note, `PaddingChecker` did print out new lines that were
later removed by the diagnostic printing code.
To be consistent with its tests, the new lines are removed
from the diagnostic.

Unicode tables updated to both use the Unicode definitions
and the Unicode 14.0 data.

U+00AD SOFT HYPHEN is still considered a print character
to match existing practices in terminals, in addition of
being considered a formatting character as per Unicode.

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

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

2 years ago[Flang] fix some types in error message
Valentin Clement [Wed, 29 Jun 2022 12:46:19 +0000 (05:46 -0700)]
[Flang] fix some types in error message

2 years ago[lldb] Replace linux/uio.h with sys/uio.h in NativeRegisterContextLinux_s390x
Pavel Labath [Wed, 29 Jun 2022 12:48:54 +0000 (14:48 +0200)]
[lldb] Replace linux/uio.h with sys/uio.h in NativeRegisterContextLinux_s390x

Fixes PR56280.

2 years ago[Test] Add XFAIL test for PR56243
Max Kazantsev [Wed, 29 Jun 2022 12:30:52 +0000 (19:30 +0700)]
[Test] Add XFAIL test for PR56243

This test demonstrates how sinking down gc.relocate may lead to breach
of LCSSA form by tokens and, consecutively, end up with SSA breach by
LoopSimplifyCFG which creates fake edges and is unable to update missing
LCSSA phis for tokens used outside of the loop.

2 years ago[Bitcode] Restore bitcast expression auto-upgrade
Nikita Popov [Wed, 29 Jun 2022 12:16:30 +0000 (14:16 +0200)]
[Bitcode] Restore bitcast expression auto-upgrade

Restore the autoupgrade from bitcast to ptrtoint+inttoptr, which
was lost as part of D127729.

This fixes the backwards compatibility issue noted in:
https://reviews.llvm.org/D127729#inline-1236519

2 years ago[SCEV] Don't create udiv constant expression (NFC)
Nikita Popov [Wed, 29 Jun 2022 12:34:02 +0000 (14:34 +0200)]
[SCEV] Don't create udiv constant expression (NFC)

Work on APInts to make it clear that this will not create a
constant expression.

This code path is not reached if the RHS is zero.

2 years ago[flang][NFC] Cosmetic changes to make the file more homogenous
Valentin Clement [Wed, 29 Jun 2022 12:21:00 +0000 (14:21 +0200)]
[flang][NFC] Cosmetic changes to make the file more homogenous

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

Reviewed By: jeanPerier

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

2 years ago[flang] Switch attr name to bindc_name
Valentin Clement [Wed, 29 Jun 2022 12:19:56 +0000 (14:19 +0200)]
[flang] Switch attr name to bindc_name

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

Reviewed By: jeanPerier

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

Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2 years agoApply clang-tidy fixes for readability-simplify-boolean-expr in ViewLikeInterface...
Mehdi Amini [Sun, 12 Jun 2022 18:12:26 +0000 (18:12 +0000)]
Apply clang-tidy fixes for readability-simplify-boolean-expr in ViewLikeInterface.cpp (NFC)

2 years agoApply clang-tidy fixes for readability-identifier-naming in Float16bits.cpp (NFC)
Mehdi Amini [Sun, 12 Jun 2022 18:08:50 +0000 (18:08 +0000)]
Apply clang-tidy fixes for readability-identifier-naming in Float16bits.cpp (NFC)

2 years ago[AArch64][SVE] Match (add x (urshr/srshr y c)) -> ursra/srsra x y c
Bradley Smith [Fri, 17 Jun 2022 10:45:27 +0000 (10:45 +0000)]
[AArch64][SVE] Match (add x (urshr/srshr y c)) -> ursra/srsra x y c

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

2 years ago[Flang][OpenMP] Remove TODO for shared and two values of default clause
Kiran Chandramohan [Wed, 29 Jun 2022 11:59:52 +0000 (11:59 +0000)]
[Flang][OpenMP] Remove TODO for shared and two values of default clause

Shared is the default behaviour in the IR, so no handling is required.
Default clause with shared or none do not require any handling since
Shared is the default behaviour in the IR and None is only required
for semantic checks.

This patch is carved out from D123930 to remove couple of false TODOs.

Reviewed By: peixin, shraiysh

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

Co-authored-by: Nimish Mishra <neelam.nimish@gmail.com>
2 years ago[MLIR][Preburger] fix typo covertVarKind -> convertVarKind
Arjun P [Wed, 29 Jun 2022 12:02:52 +0000 (13:02 +0100)]
[MLIR][Preburger] fix typo covertVarKind -> convertVarKind

Also update parameter names in the implementation file to match the header.

2 years ago[clangd] Support multiline semantic tokens
Kadir Cetinkaya [Wed, 15 Jun 2022 13:44:09 +0000 (15:44 +0200)]
[clangd] Support multiline semantic tokens

Per LSP, multiline tokens should be handled as if they end at the end
of the line starting the token (there's also a capability to enable them, but
that's an adventure for a different day).

Fixes https://github.com/clangd/clangd/issues/1145

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

2 years ago[lldb] [test] Fix variable overwrite in non-stop fork tests
Michał Górny [Wed, 29 Jun 2022 11:33:43 +0000 (13:33 +0200)]
[lldb] [test] Fix variable overwrite in non-stop fork tests

Thanks to Pavel Labath for noticing the mistake in:
https://reviews.llvm.org/D128638#3618039

Sponsored by: The FreeBSD Foundation

2 years agoRevert clang-tidy fixes for readability-simplify-boolean-expr and add NOLINT
Arjun P [Wed, 29 Jun 2022 11:21:48 +0000 (12:21 +0100)]
Revert clang-tidy fixes for readability-simplify-boolean-expr and add NOLINT

The original code is more readable because the goal is to check if the given
value does *not* lie in the range. It is harder to understand this by
reading the rewritten code.

Reviewed By: mehdi_amini

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

2 years ago[IRBuilder] Migrate div/rem to use fold infrastructure
Nikita Popov [Wed, 29 Jun 2022 11:04:15 +0000 (13:04 +0200)]
[IRBuilder] Migrate div/rem to use fold infrastructure

Migrate udiv, sdiv, urem, and srem to use the FoldXYZ rather than
the CreateXYZ infrastructure.

2 years ago[analyzer] Fix BindingDecl evaluation for reference types
isuckatcs [Wed, 29 Jun 2022 10:50:24 +0000 (12:50 +0200)]
[analyzer] Fix BindingDecl evaluation for reference types

The case when the bound variable is reference type in a
BindingDecl wasn't handled, which lead to false positives.

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

2 years ago[AMDGPU] Remove FIXME that was resolved by D30212
Jay Foad [Tue, 28 Jun 2022 16:05:21 +0000 (17:05 +0100)]
[AMDGPU] Remove FIXME that was resolved by D30212

2 years ago[Presburger] Cheat around old versions of clang not doing NRVO when there's a derived...
Benjamin Kramer [Wed, 29 Jun 2022 10:32:32 +0000 (12:32 +0200)]
[Presburger] Cheat around old versions of clang not doing NRVO when there's a derived-to-base cast in the way

Should be NFC. We can just do the base conversion manually and avoid
warnings about it. Clang before Clang 13 didn't implement P1825 and
complains:

mlir/lib/Analysis/Presburger/IntegerRelation.cpp:226:10: warning: local variable 'result' will be copied
      despite being returned by name [-Wreturn-std-move]
  return result;
         ^~~~~~
mlir/lib/Analysis/Presburger/IntegerRelation.cpp:226:10: note: call 'std::move' explicitly to avoid copying
  return result;
         ^~~~~~
         std::move(result)

2 years ago[flang][NFC] Fix some typos
Valentin Clement [Wed, 29 Jun 2022 10:21:26 +0000 (03:21 -0700)]
[flang][NFC] Fix some typos

2 years ago[AMDGPU][GFX90a][DOC][NFC] Update assembler syntax description
Dmitry Preobrazhensky [Mon, 27 Jun 2022 15:55:53 +0000 (18:55 +0300)]
[AMDGPU][GFX90a][DOC][NFC] Update assembler syntax description

Summary of changes:
- Update MUBUF lds syntax (see https://reviews.llvm.org/D124485).
- Update SMEM syntax (see https://reviews.llvm.org/D127314).
- Enable src0=literal for v_madak*, v_madmk* (see https://reviews.llvm.org/D111067).
- Correct src0 operands of v_accvgpr_write_b32.
- Correct description of s_getreg/s_setreg (add TBA/TMA).
- Remove SYSMSG_OP_HOST_TRAP_ACK message.
- Minor bug fixing and improvements.

2 years ago[SCEV] Construct SCEV iteratively.
Florian Hahn [Wed, 29 Jun 2022 10:29:31 +0000 (11:29 +0100)]
[SCEV] Construct SCEV iteratively.

This patch updates SCEV construction to work iteratively instead of recursively
in most cases. It resolves stack overflow issues when trying to construct SCEVs
for certain inputs, e.g. PR45201.

The basic approach is to to use a worklist to queue operands of V which
need to be created before V. To do so, the current patch adds a
getOperandsToCreate function which collects the operands SCEV
construction depends on for a given value. This is a slight duplication
with createSCEV.

At the moment, SCEVs for phis are still created recursively.

Fixes #32078, #42594, #44546, #49293, #49599,  #55333, #55511

Reviewed By: nikic

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

2 years ago[test][RISCV][Driver] Precommit tests for D128625
Anton Afanasyev [Sat, 25 Jun 2022 11:02:32 +0000 (14:02 +0300)]
[test][RISCV][Driver] Precommit tests for D128625

2 years ago[BasicAA] Add test coverage from D76194.
Florian Hahn [Wed, 29 Jun 2022 10:25:19 +0000 (11:25 +0100)]
[BasicAA] Add test coverage from D76194.

2 years ago[BasicAA] Convert test to use opaque pointers.
Florian Hahn [Wed, 29 Jun 2022 10:25:13 +0000 (11:25 +0100)]
[BasicAA] Convert test to use opaque pointers.

Using opaque pointers simplifies the tests quite a bit.

2 years agoRevert "Add default copy and move c'tor/assignment to PresburgerRelation."
Christian Sigg [Wed, 29 Jun 2022 10:24:28 +0000 (12:24 +0200)]
Revert "Add default copy and move c'tor/assignment to PresburgerRelation."

This reverts commit 2cd468ef1561e9f4c888e5dde821f86e427a75a1.

2 years agoStandardInstrumentation: print verifier output to errs
Nicolai Hähnle [Tue, 28 Jun 2022 17:14:09 +0000 (19:14 +0200)]
StandardInstrumentation: print verifier output to errs

Enabling the verifiers is not very helpful if their output is
suppressed beyond the fatal error.

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

2 years agoAdd default copy and move c'tor/assignment to PresburgerRelation.
Christian Sigg [Wed, 29 Jun 2022 08:40:34 +0000 (10:40 +0200)]
Add default copy and move c'tor/assignment to PresburgerRelation.

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

2 years ago[NFC] Switch FloatModeKind enum class to use bitmask enums
Jolanta Jensen [Wed, 15 Jun 2022 16:11:28 +0000 (17:11 +0100)]
[NFC] Switch FloatModeKind enum class to use bitmask enums

Using bitmask enums simplifies and clarifies the code.

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

2 years ago[SROA] Don't create constant expressions (NFC)
Nikita Popov [Wed, 29 Jun 2022 09:51:22 +0000 (11:51 +0200)]
[SROA] Don't create constant expressions (NFC)

Use IRBuilder instead, which will fold these. Just to clarify
that this does not actually create any udiv expression.

2 years ago[SCCP] Regenerate test checks (NFC)
Nikita Popov [Wed, 29 Jun 2022 09:24:16 +0000 (11:24 +0200)]
[SCCP] Regenerate test checks (NFC)

2 years ago[mlir][complex] Canonicalization for consecutive complex.neg
lewuathe [Wed, 29 Jun 2022 08:32:23 +0000 (10:32 +0200)]
[mlir][complex] Canonicalization for consecutive complex.neg

Consecutive complex.neg are redundant so that we can canonicalize them to the original operands.

Reviewed By: pifon2a

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

2 years ago[lldb] fix stepping through POSIX trampolines
Michael Daniels [Wed, 29 Jun 2022 09:00:45 +0000 (11:00 +0200)]
[lldb] fix stepping through POSIX trampolines

The DynamicLoaderPOSIXDYLD::GetStepThroughTrampolinePlan() function was
doing the symbol lookup using the demangled name. This stopped working
with https://reviews.llvm.org/D118814. To get things working again, just
use the mangled name for the lookup instead.

Reviewed By: labath

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

2 years ago[LLDB] Add PDB/calling-conventions.test for Arm/Windows
Muhammad Omair Javaid [Wed, 29 Jun 2022 08:56:00 +0000 (12:56 +0400)]
[LLDB] Add PDB/calling-conventions.test for Arm/Windows

This patch renames PDB/calling-conventions.test to calling-conventions-x86.test.
Also restrict it to run only for target-x86*.
This patch also adds a arm specific test PDB/calling-conventions-arm.test which
tests that x86 specifc calling convention decorators are ignored by Arm compiler.

Reviewed By: labath

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

2 years ago[LLDB] Add Arm64 CodeView to LLDB regnum mapping
Muhammad Omair Javaid [Wed, 29 Jun 2022 08:50:41 +0000 (12:50 +0400)]
[LLDB] Add Arm64 CodeView to LLDB regnum mapping

This patch writes a mapping structure for converting  CodeView Arm64 register numbers to LLDB Arm64 regnums.

This fixes various symbols and variable location test failures on AArch64/Windows.

Reviewed By: DavidSpickett

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

2 years ago[LLDB] Fix PDB/pointers.test for 32bit Arm/Windows
Muhammad Omair Javaid [Wed, 29 Jun 2022 08:34:56 +0000 (12:34 +0400)]
[LLDB] Fix PDB/pointers.test for 32bit Arm/Windows

PDB/pointers.test was orignally written for 32bit x86 keeping in mind
__cdecl and __stdcall calling conventions which does name mangling for
example like adding "_" underscore before function name.
This is only x86 specific but purpose of pointers.test is NOT to test
calling convention.
I am have made a few minor changes to this test which will make it pass
when run on Windows/Arm platform.

Reviewed By: mstorsjo

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

2 years ago[ConstExpr] Remove more leftovers of extractvalue expression (NFC)
Nikita Popov [Wed, 29 Jun 2022 08:42:46 +0000 (10:42 +0200)]
[ConstExpr] Remove more leftovers of extractvalue expression (NFC)

Remove some leftover bits of extractvalue handling after the
removal in D125795.

2 years ago[flang][test] Remove RUN COMMANDS/EXPECTED OUTPUT/INPUT markers from test/Driver
Fangrui Song [Wed, 29 Jun 2022 08:06:01 +0000 (01:06 -0700)]
[flang][test] Remove RUN COMMANDS/EXPECTED OUTPUT/INPUT markers from test/Driver

Uses of these markers are contrary to all other llvm-project subprojects
and carry no information for people who know the basics of a lit test.

I understand that there is an argument "this makes beginners get started
quickly" but I am unsure whether this is strong enough to deviate from
all other projects. https://llvm.org/docs/TestingGuide.html covers the
basics. Actually, some contributors were confused by the markers.

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

2 years ago[AsmPrinter] Further restrict expressions supported in global initializers
Nikita Popov [Thu, 16 Jun 2022 14:39:54 +0000 (16:39 +0200)]
[AsmPrinter] Further restrict expressions supported in global initializers

lowerConstant() currently accepts a number of constant expressions
which have corresponding MC expressions, but which cannot be
evaluated as a relocatable expression (unless the operands are
constant, in which case we'll just fold the expression to a constant).

The motivation here is to clarify which constant expressions are
really needed for https://discourse.llvm.org/t/rfc-remove-most-constant-expressions/63179,
and in particular clarify that we do not need to support any
division expressions, which are particularly problematic.

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

2 years ago[TableGen] Add a knob for MCOperandInfo expansion in gen-instr-info
Amir Ayupov [Wed, 29 Jun 2022 07:59:01 +0000 (00:59 -0700)]
[TableGen] Add a knob for MCOperandInfo expansion in gen-instr-info

Control the MCOperandInfo expansion with `-instr-info-expand-mi-operand-info`.
For X86, this would make it possible to see memory operand type e.g.:
```
    /* MOV8rm */
    GR8, i8mem,
    /* MOV8rm_NOREX */
    GR8_NOREX, i8mem_NOREX,
```

The intended use is a follow-up diff D126116 (`getMemOperandSize`).

Reviewed By: skan

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

2 years ago[clang][flang] Disable defaulting to `-fpie` for LLVM Flang
Andrzej Warzynski [Wed, 22 Jun 2022 10:29:57 +0000 (10:29 +0000)]
[clang][flang] Disable defaulting to `-fpie` for LLVM Flang

In, https://reviews.llvm.org/D120305, CLANG_DEFAULT_PIE_ON_LINUX was set
to `On` by default. However, neither `-fpie` nor `-fpic` are currently
supported in LLVM Flang. Hence, in this patch the behaviour controlled
with CLANG_DEFAULT_PIE_ON_LINUX is refined not to apply to Flang.

Another way to look at this is that CLANG_DEFAULT_PIE_ON_LINUX is
currently affecting both Clang and Flang. IIUC, the intention for this
CMake variable has always been to only affect Clang. This patch makes
sure that that's the case.

Without this change, you might see errors like this on X86_64:
```
/usr/bin/ld: main.o: relocation R_X86_64_32 against `.bss' can not be used when making a PIE object; recompile with -fPIC
```
I've not experienced any issues on AArch64. That's probably because on
AArch64 some object files happen to be position independent without
needing -fpie or -fpic.

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

2 years ago[ArgPromotion] Remove all the getters and ReplaceCallSite (NFC)
Pavel Samolysov [Tue, 28 Jun 2022 13:25:54 +0000 (16:25 +0300)]
[ArgPromotion] Remove all the getters and ReplaceCallSite (NFC)

AARGetter is an abstraction over a source of the `AAResults` introduced
to support the legacy pass manager as well as the modern one. Since the
Argument Promotion pass doesn't support the legacy pass manager anymore,
the abstraction is not required and `AAResults` may be used directly.

The instance of the `FunctionAnalysisManager` is passed through the
functions to get all the required analyses just wherever they are
required and do not use the awkward getter callbacks.

The `ReplaceCallSite` parameter was required for the legacy pass manager
only and isn't used anymore, so the parameter has been eliminated.

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

2 years ago[ArgPromotion] Move isDenselyPacked static member (NFC)
Pavel Samolysov [Wed, 18 May 2022 08:26:35 +0000 (11:26 +0300)]
[ArgPromotion] Move isDenselyPacked static member (NFC)

The `isDenselyPacked` static member of the `ArgumentPromotionPass` class
is not used in the class itself anymore. The single known user of the
function is in the `AttributorAttributes.cpp` file, so the function has
been moved into the file.

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

2 years agoRevert "[mlir][Presburger] Fix warning Wreturn-std-move (NFC)"
Adrian Kuegel [Wed, 29 Jun 2022 07:22:36 +0000 (09:22 +0200)]
Revert "[mlir][Presburger] Fix warning Wreturn-std-move (NFC)"

This reverts commit a4070a5e77283912eb29e79efd4fb872fdb9ec90.
It introduced another warning instead.

2 years ago[clang-format] Fix misplacement of `*` in declaration of pointer to struct
Huang Zhen-Hong [Wed, 29 Jun 2022 07:09:05 +0000 (15:09 +0800)]
[clang-format] Fix misplacement of `*` in declaration of pointer to struct

Fixes #55810

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

2 years ago[OpenMP] Implementing omp_get_device_num()
Jose M Monsalve Diaz [Wed, 22 Jun 2022 15:05:34 +0000 (10:05 -0500)]
[OpenMP] Implementing omp_get_device_num()

This patch implements omp_get_device_num() in the host and the device.

It uses the already existing getDeviceNum in the device config for the device.
And in the host it uses the omp_get_num_devices().

Two simple tests added

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

2 years ago[llvm-readobj][RISCV] Support dumping PT_RISCV_ATTRIBUTES
luxufan [Fri, 24 Jun 2022 05:18:19 +0000 (13:18 +0800)]
[llvm-readobj][RISCV] Support dumping PT_RISCV_ATTRIBUTES

This patch drops the prefix `PT_RISCV_` when dumping `PT_RISCV_ATTRIBUTES`.

GNU readelf dumps it as `RISCV_ATTRIBUT`. Because GNU readelf uses
something like `%-14.14s` so only the first 14 bytes are printed.

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

2 years ago[mlir][Presburger] Fix warning Wreturn-std-move (NFC)
Adrian Kuegel [Wed, 29 Jun 2022 07:10:20 +0000 (09:10 +0200)]
[mlir][Presburger] Fix warning Wreturn-std-move (NFC)

2 years ago[GuardWidening] Add tests showing incorrect behavior of GW.
Serguei Katkov [Wed, 29 Jun 2022 04:06:34 +0000 (11:06 +0700)]
[GuardWidening] Add tests showing incorrect behavior of GW.

The first test shows that combineRangeChecks may choose to keep only two poison conditions.
And we cannot do simple arithmetic or logical and in guard.
The second test shows that keeping two poison conditions in the widened guard may allow
execution of side-effect instruction even if just freeze these conditions.
The third test shows that even in simple test we can hoist a poison and even logical and does not help here.

Reviewed By: mkazantsev
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D128779

2 years ago[libc++][format] Improve pointer formatters.
Mark de Wever [Tue, 28 Dec 2021 17:48:04 +0000 (18:48 +0100)]
[libc++][format] Improve pointer formatters.

This changes the implementation of the formatter. Instead of inheriting
from a specialized parser all formatters will use the same generic
parser. This reduces the binary size.

The new parser contains some additional fields only used in the chrono
formatting. Since this doesn't change the size of the parser the fields
are in the generic parser. The parser is designed to fit in 128-bit,
making it cheap to pass by value.

The new format function is a const member function. This isn't required
by the Standard yet, but it will be after LWG-3636 is accepted.
Additionally P2286 adds a formattable concept which requires the member
function to be const qualified in C++23. This paper is likely to be
accepted in the 2022 July plenary.

This is based on D125606. That commit did the groundwork and did similar
changes for the string formatters.

Depends on D128139.

Reviewed By: #libc, ldionne

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

2 years ago[MLIR][Math] Improve docs for round op (NFC)
lorenzo chelini [Mon, 27 Jun 2022 16:16:39 +0000 (18:16 +0200)]
[MLIR][Math] Improve docs for round op (NFC)

Reviewed By: antiagainst

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

2 years agoPass code-model through Module IR to [llc].
esmeyi [Wed, 29 Jun 2022 06:30:13 +0000 (02:30 -0400)]
Pass code-model through Module IR to [llc].

Currently, the code-model specified in IR can't be captured by [llc].
This patch fixes that.

Reviewed By: shchenz, MaskRay

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

2 years ago[libc++][format] Improve integral formatters.
Mark de Wever [Tue, 28 Dec 2021 17:48:04 +0000 (18:48 +0100)]
[libc++][format] Improve integral formatters.

This changes the implementation of the formatter. Instead of inheriting
from a specialized parser all formatters will use the same generic
parser. This reduces the binary size.

The new parser contains some additional fields only used in the chrono
formatting. Since this doesn't change the size of the parser the fields
are in the generic parser. The parser is designed to fit in 128-bit,
making it cheap to pass by value.

The new format function is a const member function. This isn't required
by the Standard yet, but it will be after LWG-3636 is accepted.
Additionally P2286 adds a formattable concept which requires the member
function to be const qualified in C++23. This paper is likely to be
accepted in the 2022 July plenary.

This is based on D125606. That commit did the groundwork and did similar
changes for the string formatters.

Depends on D125606

Reviewed By: #libc, ldionne

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

2 years ago[lldb] [test] Split TestGdbRemoteFork in two
Michał Górny [Wed, 29 Jun 2022 04:56:32 +0000 (06:56 +0200)]
[lldb] [test] Split TestGdbRemoteFork in two

Split the test that's gotten very long in two, in hope that it will
resolve the arm/aarch64 buildbot failures.  Even if it does not, it
could help pinpointing where the problem lies.

Sponsored by: The FreeBSD Foundation

2 years ago[C++20] [Module] Support reachable definition initially/partially
Chuanqi Xu [Wed, 29 Jun 2022 04:48:48 +0000 (12:48 +0800)]
[C++20] [Module] Support reachable definition initially/partially

This patch introduces a new kind of ModuleOwnershipKind as
ReachableWhenImported. This intended the status for reachable described
at: https://eel.is/c++draft/module.reach#3.

Note that this patch is not intended to support all semantics about
reachable semantics. For example, this patch didn't implement discarded
declarations in GMF. (https://eel.is/c++draft/module.global.frag#3).

This fixes: https://bugs.llvm.org/show_bug.cgi?id=52281 and
https://godbolt.org/z/81f3ocjfW.

Reviewed By: rsmith, iains

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

2 years agoRevert "[C++20] [Modules] Implement Reachable initiallly"
Chuanqi Xu [Wed, 29 Jun 2022 04:43:26 +0000 (12:43 +0800)]
Revert "[C++20] [Modules] Implement Reachable initiallly"

This reverts commit a223ba0a697c1598b434cf2495c9cd9ec5640fc7.

The previous commit don't contain additional information, which is bad.