platform/upstream/llvm.git
2 years ago[ConstantFolding] Use ICmpInst::Predicate instead of plain integer
Serge Pavlov [Wed, 29 Dec 2021 04:40:03 +0000 (11:40 +0700)]
[ConstantFolding] Use ICmpInst::Predicate instead of plain integer

The function `ConstantFoldCompareInstruction` uses `unsigned short` to
represent compare predicate, although all usesrs of the respective
include file use definition of CmpInst also. This change replaces
predicate argument type in this function to `ICmpInst::Predicate`,
which allows to make code a bit clearer and simpler.

No functional changes.

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

2 years ago[cmake] Tweak warning in `extend_path` helper function
John Ericson [Thu, 30 Dec 2021 07:00:50 +0000 (07:00 +0000)]
[cmake] Tweak warning in `extend_path` helper function

There was one more reference the word "install" I forgot to remove.

Follow-up to bde561c4813952847112600e5efe72d9015556f7 /
https://reviews.llvm.org/D115746

2 years ago[compiler-rt][cmake] Factor out extend_install_path function
John Ericson [Tue, 14 Dec 2021 19:52:02 +0000 (14:52 -0500)]
[compiler-rt][cmake] Factor out extend_install_path function

It is likely to become used again, if other projects want their own per-project
install directory variables. `install` is removed from the name since it is not inherently about installing.

Reviewed By: stephenneuendorffer

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

2 years ago[OpenMP] Add missing `tt_hidden_helper_task_encountered` along with `tt_found_proxy_t...
Shilei Tian [Thu, 30 Dec 2021 04:22:37 +0000 (23:22 -0500)]
[OpenMP] Add missing `tt_hidden_helper_task_encountered` along with `tt_found_proxy_tasks`

In most cases, hidden helper task behave similar as detached tasks. That means,
for example, if we have to wait for detached tasks, we have to do the same thing
for hidden helper tasks as well. This patch adds the missing condition for hidden
helper task accordingly along with detached task.

Reviewed By: AndreyChurbanov

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

2 years ago[RISCV] Use vmv.s.x instead of vfmv.s.f when the floating point scalar is 0.
jacquesguan [Wed, 29 Dec 2021 07:29:40 +0000 (15:29 +0800)]
[RISCV] Use vmv.s.x instead of vfmv.s.f when the floating point scalar is 0.

Use integer vector scalar move instruction when move 0 to avoid add a integer-float move instruction.

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

2 years ago[NFC] Specify targets for clang stack-protector-guard.c
Qiu Chaofan [Thu, 30 Dec 2021 02:13:41 +0000 (10:13 +0800)]
[NFC] Specify targets for clang stack-protector-guard.c

The run line of stack-protector-guard.c doesn't specify the triple,
which means it depends on the platform running the test. This makes
some failure hidden.

Reviewed By: nickdesaulniers

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

2 years ago[RISCV] Refactor immediate comparison instructions patterns
Chenbing.Zheng [Thu, 30 Dec 2021 01:31:01 +0000 (09:31 +0800)]
[RISCV] Refactor immediate comparison instructions patterns

The patterns of the immediate comparison instruction is rewrite here, and put similar code to a class.
Do not change any function of the original code, making the code more concise.

Reviewed By: craig.topper

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

2 years agoCouple of post-commit tweaks on 4d58d1d5af31 based on maskray's feedback
David Blaikie [Thu, 30 Dec 2021 00:45:00 +0000 (16:45 -0800)]
Couple of post-commit tweaks on 4d58d1d5af31 based on maskray's feedback

2 years agoFix build of llvm-prettyprinters/gdb/mlir-support.cpp test
Mehdi Amini [Wed, 29 Dec 2021 23:08:37 +0000 (23:08 +0000)]
Fix build of llvm-prettyprinters/gdb/mlir-support.cpp test

This is just fixing the build itself, the test won't pass right now.

2 years agoDWARFVerifier: fix remaining tests and compact/rephrase the output
David Blaikie [Wed, 29 Dec 2021 22:47:43 +0000 (14:47 -0800)]
DWARFVerifier: fix remaining tests and compact/rephrase the output

2 years agoDWARFDie: don't try to compute a full template name for a template parameter packs
David Blaikie [Wed, 29 Dec 2021 22:04:38 +0000 (14:04 -0800)]
DWARFDie: don't try to compute a full template name for a template parameter packs

Otherwise these look a lot like actual templates (they have a name and
they have template parameters) but they don't participate in naming
(this doesn't come up in practice because a template parameter pack DIE
is never referenced from another DIE (so we don't do full name
rebuilding for it) or the subject of simplified template name rebuilding
(never has the _STN prefix)) - it could be tested with some hand crafted
DWARF but doesn't seem important/useful to do so.

This change is just for performance - to avoid trying to parse more
DIEs, etc, when it's not needed when computing the name in the DWARF
verifier.

2 years agoDWARFVerifier: Print the CU name and CU count to help visualize progress
David Blaikie [Wed, 29 Dec 2021 22:00:40 +0000 (14:00 -0800)]
DWARFVerifier: Print the CU name and CU count to help visualize progress

2 years ago[libc++] [NFC] Remove an unused parameter from `__sift_down`.
Arthur O'Dwyer [Wed, 29 Dec 2021 19:17:26 +0000 (14:17 -0500)]
[libc++] [NFC] Remove an unused parameter from `__sift_down`.

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

2 years agoDWARFVerifier: Delay loading nested types in type dumping to improve performance
David Blaikie [Wed, 29 Dec 2021 21:11:16 +0000 (13:11 -0800)]
DWARFVerifier: Delay loading nested types in type dumping to improve performance

Avoid trying to resolve nested types that may not be needed because the name is
already provided by the outer DIE.

2 years ago[InstCombine] add more folds for unsigned overflow checks
Sanjay Patel [Wed, 29 Dec 2021 20:53:56 +0000 (15:53 -0500)]
[InstCombine] add more folds for unsigned overflow checks

 ((Op1 + C) & C) u<  Op1 --> Op1 != 0
 ((Op1 + C) & C) u>= Op1 --> Op1 == 0
 Op0 u>  ((Op0 + C) & C) --> Op0 != 0
 Op0 u<= ((Op0 + C) & C) --> Op0 == 0

https://alive2.llvm.org/ce/z/iUfXJN
https://alive2.llvm.org/ce/z/caAtjj

  define i1 @src(i8 %x, i8 %y) {
    ; the add/mask must be with a low-bit mask (0x01ff...)
    %y1 = add i8 %y, 1
    %pop = call i8 @llvm.ctpop.i8(i8 %y1)
    %ismask = icmp eq i8 %pop, 1
    call void @llvm.assume(i1 %ismask)

    %a = add i8 %x, %y
    %m = and i8 %a, %y
    %r = icmp ult i8 %m, %x
    ret i1 %r
  }

  define i1 @tgt(i8 %x, i8 %y) {
    %r = icmp ne i8 %x, 0
    ret i1 %r
  }

I suspect this can be generalized in some way, but this
is the pattern I'm seeing in a motivating test based on
issue #52851.

2 years ago[InstCombine] add tests for unsigned overflow of bitmask offset; NFC
Sanjay Patel [Wed, 29 Dec 2021 20:16:11 +0000 (15:16 -0500)]
[InstCombine] add tests for unsigned overflow of bitmask offset; NFC

2 years ago[InstCombine] add tests for lshr(add(shl())); NFC
Sanjay Patel [Tue, 28 Dec 2021 21:59:53 +0000 (16:59 -0500)]
[InstCombine] add tests for lshr(add(shl())); NFC

2 years ago[mlir][MemRef] Deprecate unspecified trailing offset, size, and strides semantics...
MaheshRavishankar [Wed, 29 Dec 2021 18:48:02 +0000 (10:48 -0800)]
[mlir][MemRef] Deprecate unspecified trailing offset, size, and strides semantics of `OffsetSizeAndStrideOpInterface`.

The semantics of the ops that implement the
`OffsetSizeAndStrideOpInterface` is that if the number of offsets,
sizes or strides are less than the rank of the source, then some
default values are filled along the trailing dimensions (0 for offset,
source dimension of sizes, and 1 for strides). This is confusing,
especially with rank-reducing semantics. Immediate issue here is that
the methods of `OffsetSizeAndStridesOpInterface` assumes that the
number of values is same as the source rank. This cause out-of-bounds
errors.

So simplifying the specification of `OffsetSizeAndStridesOpInterface`
to make it invalid to specify number of offsets/sizes/strides not
equal to the source rank.

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

2 years ago[Hexagon] Don't build two halves of HVX vector in parallel
Krzysztof Parzyszek [Wed, 29 Dec 2021 19:00:01 +0000 (11:00 -0800)]
[Hexagon] Don't build two halves of HVX vector in parallel

There can only be one permute operations per packet, so this actually
pessimizes the code (due to the extra "or").

2 years ago[Hexagon] Improve BUILD_VECTOR codegen
Joshua Herrera [Wed, 29 Dec 2021 18:18:21 +0000 (10:18 -0800)]
[Hexagon] Improve BUILD_VECTOR codegen

For vectors with repeating values, old codegen would rotate and insert
every duplicate element. This patch replaces that behavior with a splat
of the most common element, vinsert/vror only occur when needed.

2 years ago[MLIR][LLVM] Expose powi intrinsic to MLIR
William S. Moses [Wed, 29 Dec 2021 08:08:01 +0000 (03:08 -0500)]
[MLIR][LLVM] Expose powi intrinsic to MLIR

Expose the powi intrinsic to the LLVM dialect within MLIR

Reviewed By: mehdi_amini

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

2 years ago[LV] Replace redundant tail-fold check with assert (NFC).
Florian Hahn [Wed, 29 Dec 2021 18:00:41 +0000 (19:00 +0100)]
[LV] Replace redundant tail-fold check with assert (NFC).

The code path can only be reached when folding the tail, so turn the
check into an assertion.

2 years ago[RISCV] Add a few more instructions to hasAllNBitUsers.
Craig Topper [Wed, 29 Dec 2021 17:14:32 +0000 (09:14 -0800)]
[RISCV] Add a few more instructions to hasAllNBitUsers.

2 years ago[Hexagon] Calling conventions for floating point vectors
Krzysztof Parzyszek [Wed, 29 Dec 2021 16:46:26 +0000 (08:46 -0800)]
[Hexagon] Calling conventions for floating point vectors

They are the same as for the other HVX vectors, but types need to be
listed explicitly. Also, add a detailed codegen testcase.

Co-authored-by: Abhikrant Sharma <quic_abhikran@quicinc.com>
2 years ago[Basic] Drop unnecessary const from return types (NFC)
Kazu Hirata [Wed, 29 Dec 2021 16:55:37 +0000 (08:55 -0800)]
[Basic] Drop unnecessary const from return types (NFC)

Identified with readability-const-return-type.

2 years ago[clang] Use nullptr instead of 0 or NULL (NFC)
Kazu Hirata [Wed, 29 Dec 2021 16:34:20 +0000 (08:34 -0800)]
[clang] Use nullptr instead of 0 or NULL (NFC)

Identified with modernize-use-nullptr.

2 years ago[clang] Remove unused "using" (NFC)
Kazu Hirata [Wed, 29 Dec 2021 16:27:29 +0000 (08:27 -0800)]
[clang] Remove unused "using" (NFC)

2 years ago[NewGVN] Use poison instead of undef to represent unreachable values
Nuno Lopes [Wed, 29 Dec 2021 15:48:30 +0000 (15:48 +0000)]
[NewGVN] Use poison instead of undef to represent unreachable values
This enables more simplifications and gets us closer to removing undef.
ping @alinas

2 years ago[Hexagon] Handle floating point splats
Krzysztof Parzyszek [Wed, 29 Dec 2021 14:52:24 +0000 (06:52 -0800)]
[Hexagon] Handle floating point splats

Co-authored-by: Anirudh Sundar Subramaniam <quic_sanirudh@quicinc.com>
2 years ago[Hexagon] Handle floating point vector loads/stores
Krzysztof Parzyszek [Wed, 29 Dec 2021 13:45:43 +0000 (05:45 -0800)]
[Hexagon] Handle floating point vector loads/stores

2 years ago[NewGVN] Prefer poison to undef when ranking operands
Nuno Lopes [Wed, 29 Dec 2021 12:38:14 +0000 (12:38 +0000)]
[NewGVN] Prefer poison to undef when ranking operands
ping @alinas

2 years ago[SYCL] Diagnose uses of zero length arrays
Mariya Podchishchaeva [Wed, 29 Dec 2021 10:46:15 +0000 (13:46 +0300)]
[SYCL] Diagnose uses of zero length arrays

Adds diagnosing on attempt to use zero length arrays, pointers, refs, arrays
of them and structs/classes containing all of it.
In case a struct/class with zero length array is used this emits a set
of notes pointing out how zero length array got into used struct, like
this:
```
struct ContainsArr {
  int A[0]; // note: field of illegal type declared here
};
struct Wrapper {
  ContainsArr F; // note: within field of type ContainsArr declared here
  // ...
}

// Device code
Wrapper W;
W.use(); // error: zero-length arrays are not permitted

```
Total deep check of each used declaration may result in double
diagnosing at the same location.

Reviewed By: aaron.ballman

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

2 years agoFix lit feature name in 9dc4af327b12d
Sam McCall [Wed, 29 Dec 2021 12:18:11 +0000 (13:18 +0100)]
Fix lit feature name in 9dc4af327b12d

2 years agoRe-land "[clang] Add early exit when checking for const init of arrays."
Sam McCall [Wed, 29 Dec 2021 11:07:42 +0000 (12:07 +0100)]
Re-land "[clang] Add early exit when checking for const init of arrays."

This reverts commit 6d09aaecdfe51e13fc64d539aa7c9a790de341d7.

The test uses ulimit and ran into problems on some bots. Run on linux only.
There's nothing platform-specific about the code we're testing, so this
should be enough to ensure correctness.

2 years ago[AArch64] Remove outdated FIXME in test arm64-csel.ll. NFC.
Sjoerd Meijer [Thu, 23 Dec 2021 15:22:46 +0000 (15:22 +0000)]
[AArch64] Remove outdated FIXME in test arm64-csel.ll. NFC.

2 years ago[lldb/linux] Fix a bug in wait status handling
Pavel Labath [Wed, 29 Dec 2021 09:54:46 +0000 (10:54 +0100)]
[lldb/linux] Fix a bug in wait status handling

The MonitorCallback function was assuming that the "exited" argument is
set whenever a thread exits, but the caller was only setting that flag
for the main thread.

This patch deletes the argument altogether, and lets MonitorCallback
compute what it needs itself.

This is almost NFC, since previously we would end up in the
"GetSignalInfo failed for unknown reasons" branch, which was doing the
same thing -- forgetting about the thread.

2 years ago[lldb] Fix PR52702 by fixing bool conversion of Mangled
PoYao Chang [Mon, 27 Dec 2021 04:34:23 +0000 (12:34 +0800)]
[lldb] Fix PR52702 by fixing bool conversion of Mangled

Remove the Mangled::operator! and Mangled::operator void* where the
comments in header and implementation files disagree and replace them
with operator bool.

This fix PR52702 as https://reviews.llvm.org/D106837 used the buggy
Mangled::operator! in Symbol::SynthesizeNameIfNeeded. For example,
consider the symbol "puts" in a hello world C program:

// Inside Symbol::SynthesizeNameIfNeeded
(lldb) p m_mangled
(lldb_private::Mangled) $0 = (m_mangled = None, m_demangled = "puts")
(lldb) p !m_mangled
(bool) $1 = true          # should be false!!
This leads to Symbol::SynthesizeNameIfNeeded overwriting m_demangled
part of Mangled (in this case "puts").

In conclusion, this patch turns
callq  0x401030                  ; symbol stub for: ___lldb_unnamed_symbol36
back into
callq  0x401030                  ; symbol stub for: puts .

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

2 years ago[lldb] Adjust TestModuleCacheSimple for D115951
Pavel Labath [Wed, 29 Dec 2021 09:00:00 +0000 (10:00 +0100)]
[lldb] Adjust TestModuleCacheSimple for D115951

Now that we are caching the dwarf index as well, we will always have
more than one cache file (when not using accelerator tables). I have
adjusted the test to check for the presence of one _symtab_ index.

2 years ago[lldb] Make ProcessLauncherPosixFork (mostly) async-signal-safe
Pavel Labath [Tue, 21 Dec 2021 12:59:14 +0000 (13:59 +0100)]
[lldb] Make ProcessLauncherPosixFork (mostly) async-signal-safe

Multithreaded applications using fork(2) need to be extra careful about
what they do in the fork child. Without any special precautions (which
only really work if you can fully control all threads) they can only
safely call async-signal-safe functions. This is because the forked
child will contain snapshot of the parents memory at a random moment in
the execution of all of the non-forking threads (this is where the
similarity with signals comes in).

For example, the other threads could have been holding locks that can
now never be released in the child process and any attempt to obtain
them would block. This is what sometimes happen when using tcmalloc --
our fork child ends up hanging in the memory allocation routine. It is
also what happened with our logging code, which is why we added a
pthread_atfork hackaround.

This patch implements a proper fix to the problem, by which is to make
the child code async-signal-safe. The ProcessLaunchInfo structure is
transformed into a simpler ForkLaunchInfo representation, one which can
be read without allocating memory and invoking complex library
functions.

Strictly speaking this implementation is not async-signal-safe, as it
still invokes library functions outside of the posix-blessed set of
entry points. Strictly adhering to the spec would mean reimplementing a
lot of the functionality in pure C, so instead I rely on the fact that
any reasonable implementation of some functions (e.g.,
basic_string::c_str()) will not start allocating memory or doing other
unsafe things.

The new child code does not call into our logging infrastructure, which
enables us to remove the pthread_atfork call from there.

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

2 years ago[clang] Fix crash in bug52905
Chuanqi Xu [Wed, 29 Dec 2021 08:22:26 +0000 (16:22 +0800)]
[clang] Fix crash in bug52905

The root cause for the crash is the incorrect use of `cast`.
The actual type and cast-to type is different. This patch fixes the
crash by converting the `cast` to `dyn_cast`.

2 years ago[clang] Fix header guards (NFC)
Kazu Hirata [Wed, 29 Dec 2021 08:16:40 +0000 (00:16 -0800)]
[clang] Fix header guards (NFC)

Identified with llvm-header-guard.

2 years ago[Hexagon] Use range-based for loops (NFC)
Kazu Hirata [Wed, 29 Dec 2021 07:47:25 +0000 (23:47 -0800)]
[Hexagon] Use range-based for loops (NFC)

2 years ago[OpenMP][OpenACC] Update test after encoding change in D113126
Johannes Doerfert [Wed, 29 Dec 2021 07:29:07 +0000 (01:29 -0600)]
[OpenMP][OpenACC] Update test after encoding change in D113126

2 years agoReapply "[OpenMP][NFCI] Embed the source location string size in the ident_t"
Johannes Doerfert [Wed, 29 Dec 2021 07:07:53 +0000 (01:07 -0600)]
Reapply "[OpenMP][NFCI] Embed the source location string size in the ident_t"

This reverts commit 73ece231ee0cf048d56841f47915beb1db6afc26 and
reapplies 7bfcdbcbf368cea14a5236080af975d5878a46eb with mlir changes.
Also reverts commit 423ba12971bac8397c87fcf975ba6a4b7530ed28 and
includes the unit test changes of
16da2140045808b2aea1d28366ca7d326eb3c809.

2 years agoRevert "[OpenMP][FIX] Also update unit test after API change"
Mehdi Amini [Wed, 29 Dec 2021 07:08:58 +0000 (07:08 +0000)]
Revert "[OpenMP][FIX] Also update unit test after API change"

This reverts commit 16da2140045808b2aea1d28366ca7d326eb3c809.

Revert unit-test API update after previous revert of the API change.

2 years agoRevert "[OpenMP][NFCI] Embed the source location string size in the ident_t"
Mehdi Amini [Wed, 29 Dec 2021 06:57:36 +0000 (06:57 +0000)]
Revert "[OpenMP][NFCI] Embed the source location string size in the ident_t"

This reverts commit 7bfcdbcbf368cea14a5236080af975d5878a46eb.
Broke MLIR build

2 years ago[AST] Fix a warning
Kazu Hirata [Wed, 29 Dec 2021 06:52:56 +0000 (22:52 -0800)]
[AST] Fix a warning

This patch fixes:

  mlir/include/mlir/Tools/PDLL/AST/Types.h:54:3: error: definition of
  implicit copy assignment operator for 'Type' is deprecated because
  it has a user-declared copy constructor [-Werror,-Wdeprecated-copy]

2 years ago[Attributor] Look through allocated heap memory
Johannes Doerfert [Wed, 29 Dec 2021 05:59:35 +0000 (23:59 -0600)]
[Attributor] Look through allocated heap memory

AAPointerInfo, and thereby other places, can look already through
internal global and stack memory. This patch enables them to look
through heap memory returned by functions with a `noalias` return.

In the future we can look through `noalias` arguments as well but that
will require AAIsDead to learn that such memory can be inspected by the
caller later on. We also need teach AAPointerInfo about dominance to
actually deal with memory that might not be `null` or `undef`
initialized. D106397 is a first step in that direction already.

Reviewed By: kuter

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

2 years ago[OpenMP] Simplify all stores in the device code
Johannes Doerfert [Wed, 29 Dec 2021 05:55:32 +0000 (23:55 -0600)]
[OpenMP] Simplify all stores in the device code

Similar to loads, we want to be aggressive when it comes to store
simplification. Not everything in LLVM handles dead stores well when
address space casts are involved, we can simply ask the Attributor to do
it for us though.

Reviewed By: tianshilei1992

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

2 years ago[OpenMP][FIX] Also update unit test after API change
Johannes Doerfert [Wed, 29 Dec 2021 06:16:56 +0000 (00:16 -0600)]
[OpenMP][FIX] Also update unit test after API change

2 years ago[OpenMP][NFC] Extract assumption helpers into own header file
Johannes Doerfert [Thu, 4 Nov 2021 13:48:19 +0000 (08:48 -0500)]
[OpenMP][NFC] Extract assumption helpers into own header file

2 years ago[OpenMP][NFCI] Embed the source location string size in the ident_t
Johannes Doerfert [Wed, 3 Nov 2021 17:28:11 +0000 (12:28 -0500)]
[OpenMP][NFCI] Embed the source location string size in the ident_t

One of the unused ident_t fields now holds the size of the string
(=const char *) field so we have an easier time dealing with those
in the future.

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

2 years ago[Attributor][FIX] Ensure store uses are correlated with reloads
Johannes Doerfert [Sat, 11 Sep 2021 23:15:53 +0000 (18:15 -0500)]
[Attributor][FIX] Ensure store uses are correlated with reloads

While we skipped uses in stores if we can find all copies of the value
when the memory is loaded, we did not correlate the use in the store
with the use in the load. So far this lead to less precise results in the
offset calculations which prevented deductions. With the new
EquivalentUseCB callback argument the user of checkForAllUses can be
informed of the correlation and act on it appropriately.

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

2 years ago[OpenMP][FIX] Make AAExecutionDomain deterministic
Johannes Doerfert [Tue, 28 Dec 2021 22:03:16 +0000 (16:03 -0600)]
[OpenMP][FIX] Make AAExecutionDomain deterministic

2 years ago[OpenMP][FIX] Make heap2shared deterministic
Johannes Doerfert [Sun, 26 Dec 2021 20:33:37 +0000 (14:33 -0600)]
[OpenMP][FIX] Make heap2shared deterministic

Issue #52875 reported non-determinism, this is the first step to avoid
it. We iterate over MallocCalls so we should keep the order stable.

2 years ago[OpenMP][NFC] Move address space enum into OMPConstants header
Johannes Doerfert [Wed, 3 Nov 2021 17:57:43 +0000 (12:57 -0500)]
[OpenMP][NFC] Move address space enum into OMPConstants header

2 years ago[OpenMP][NFC] Move headers into include folder
Johannes Doerfert [Wed, 3 Nov 2021 16:58:05 +0000 (11:58 -0500)]
[OpenMP][NFC] Move headers into include folder

2 years ago[MLIR] Expose atomicrmw and/or
William S. Moses [Tue, 28 Dec 2021 23:40:54 +0000 (18:40 -0500)]
[MLIR] Expose atomicrmw and/or

LLVM (dialect and IR) have atomics for and/or. This patch enables atomic_rmw ops in the standard dialect for and/or that lower to these (in addition to the existing atomics such as addi, etc).

Reviewed By: mehdi_amini

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

2 years ago[MLIR] Add constant folder for fptosi and friends
William S. Moses [Mon, 27 Dec 2021 21:07:11 +0000 (16:07 -0500)]
[MLIR] Add constant folder for fptosi and friends

This patch adds constant folds for FPToSI/FPToUI/SIToFP/UIToFP

Reviewed By: mehdi_amini, bondhugula

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

2 years ago[libcxx][test] Remove redundant semiregular checks for CPOs
Joe Loser [Wed, 22 Dec 2021 17:30:09 +0000 (12:30 -0500)]
[libcxx][test] Remove redundant semiregular checks for CPOs

Some individual test files verify the CPO under test satisfies
`semiregular` concept.  This is redundant since it is already part of the test
in verifying whether the entity is indeed a CPO in
`libcxx/test/std/library/description/conventions/customization.point.object/cpo.compile.pass.cpp`.

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

2 years ago[RISCV] Add more div by constant test cases.
Craig Topper [Wed, 29 Dec 2021 02:28:23 +0000 (18:28 -0800)]
[RISCV] Add more div by constant test cases.

Some constants require more instructions than others. This adds
additional test for each variation. UDIV has 2 variations, SDIV has
4 variations.

Some of these sequence may have gotten worse on RV32 when we started
doing the div by constant optimization before type legalization. We
materialized a smaller constant, but we require more instructions
to emulate 8 or 16 bit right shifts. This was hidden by the lack
of test coverage.

I've also added Zba and Zbb test cases to show the affect of sext.b,
sext.h, zext.h, and zext.w on some of the shifts. In some cases
we end up generating more code after the multiply because we use
a zext.h+srli and sext.h+srai where without Zbb we share a slli
between a srli and srai.

2 years ago[llvm-profdata][docs] Use `` instead of `
Fangrui Song [Wed, 29 Dec 2021 02:03:28 +0000 (18:03 -0800)]
[llvm-profdata][docs] Use `` instead of `

2 years ago[llvm-profdata] Make -debug-info visible
Kyungwoo Lee [Wed, 29 Dec 2021 01:31:36 +0000 (17:31 -0800)]
[llvm-profdata] Make -debug-info visible

Add the option comment in .rst.

Reviewed By: ellis

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

2 years ago[ELF] --gc-sections: Work around SHT_PROGBITS .init_array.N for Rust
Fangrui Song [Wed, 29 Dec 2021 00:40:51 +0000 (16:40 -0800)]
[ELF] --gc-sections: Work around SHT_PROGBITS .init_array.N for Rust

See https://github.com/rust-lang/rust/issues/92181

2 years ago[lld-macho] Fix alignment of TLV data sections
Mike Hommey [Wed, 29 Dec 2021 00:01:01 +0000 (19:01 -0500)]
[lld-macho] Fix alignment of TLV data sections

References from thread-local variable sections are treated as offsets
relative to the start of the thread-local data memory area, which is
initialized via copying all the TLV data sections (which are all
contiguous). If later data sections require a greater alignment than
earlier ones, the offsets of data within those sections won't be
guaranteed to aligned unless we normalize alignments. We therefore use
the largest alignment for all TLV data sections.

Reviewed By: #lld-macho, int3

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

2 years ago[CodeView] Clamp Frontend version
modimo [Tue, 28 Dec 2021 22:48:15 +0000 (14:48 -0800)]
[CodeView] Clamp Frontend version

D43002 introduced a test debug-info-objname.cpp that outputted the current compiler version into CodeView. Internally we appended a date to the patch version and overflowed the 16-bits allocated to that space. This change clamps the Frontend version outputted values to 16-bits like rGd1185fc081ead71a8bf239ff1814f5ff73084c15 did for the Backend version.

Testing:
ninja check-all
newly added tests correctly clamps and no longer asserts when trying to output the field

Reviewed By: aganea

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

2 years ago[Hexagon] Support BUILD_VECTOR of floating point HVX vectors
Krzysztof Parzyszek [Tue, 28 Dec 2021 21:47:42 +0000 (13:47 -0800)]
[Hexagon] Support BUILD_VECTOR of floating point HVX vectors

Co-authored-by: Anirudh Sundar Subramaniam <quic_sanirudh@quicinc.com>
Co-authored-by: Ankit Aggarwal <aankit@quicinc.com>
2 years ago[OpenMP][CUDA] Add resource pool for CUevent
Shilei Tian [Tue, 28 Dec 2021 22:42:31 +0000 (17:42 -0500)]
[OpenMP][CUDA] Add resource pool for CUevent

Following D111954, this patch adds the resource pool for CUevent.

Reviewed By: ye-luo

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

2 years ago[InstrProf] Prevent duplicate functions in correlated data
Ellis Hoag [Tue, 28 Dec 2021 21:34:36 +0000 (13:34 -0800)]
[InstrProf] Prevent duplicate functions in correlated data

When using debug info for profile correlation, avoid adding duplicate
functions in the synthetic Data section.

Before this patch, n duplicate function entries in the Data section would
cause counter values to be a factor of n larger. I built instrumented
clang with and without debug info correlation and got these summaries.

```
# With Debug Info Correlate
$ llvm-profdata show default.profdata
Instrumentation level: IR  entry_first = 0
Total functions: 182530
Maximum function count: 52034
Maximum internal block count: 5763

# Without
$ llvm-profdata show default.profdata
Instrumentation level: IR  entry_first = 0
Total functions: 183212
Maximum function count: 52034
Maximum internal block count: 5766
```

The slight difference in counts seem to be mostly from FileSystem and
Map functions and the difference in the number of instrumented functions
seems to come from missing debug info like destructors without source.

Reviewed By: kyulee

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

2 years ago[TargetLowering] Remove workaround for old behavior of getShiftAmountTy. NFC
Craig Topper [Tue, 28 Dec 2021 22:05:40 +0000 (14:05 -0800)]
[TargetLowering] Remove workaround for old behavior of getShiftAmountTy. NFC

getShiftAmountTy used to directly return the shift amount type from
the target which could be too small for large illegal types. For
example, X86 always returns i8.

The code here detected this and used i32 instead if it won't fit. This
behavior was added to getShiftAmountTy in D112469 so we no longer need
this workaround.

2 years ago[clang][ARM] re-use arm::isHardTPSupported for hardware TLS check
Nick Desaulniers [Tue, 28 Dec 2021 20:48:30 +0000 (12:48 -0800)]
[clang][ARM] re-use arm::isHardTPSupported for hardware TLS check

This conditional check for -mstack-protector-guard=tls got out of sync
with the conditional check for -mtp=cp15 by me in D114116, because I
forgot about the similar check added in D113026.

Re-use the code in arm::isHardTPSupported so that these aren't out of
sync.

Interestingly, our CI reported this when testing
-mstack-protector-guard=tls; it was only reproducible with Debian's LLVM
and not upstream LLVM due to this out of tree patch:
https://salsa.debian.org/pkg-llvm-team/llvm-toolchain/-/blob/snapshot/debian/patches/930008-arm.diff

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

Reviewed By: ardb

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

2 years ago[OpenMP][Plugin] Minor adjustments to ResourcePool
Shilei Tian [Tue, 28 Dec 2021 21:10:49 +0000 (16:10 -0500)]
[OpenMP][Plugin] Minor adjustments to ResourcePool

This patch makes some minor adjustments to `ResourcePool`:
- Don't initialize the resources if `Size` is 0 which can avoid assertion.
- Add a new interface function `clear` to release all hold resources.
- If initial size is 0, resize to 1 when the first request is encountered.

Reviewed By: jdoerfert

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

2 years agoDocumentation for the process of adding new targets
Renato Golin [Tue, 28 Dec 2021 11:59:54 +0000 (11:59 +0000)]
Documentation for the process of adding new targets

Plenty of new targets nowadays and I found myself repeating the same
thing over and over, so this is more or less what we said over the last
few years, but condensed in an ordered fashion and easy to digest.

This does not change any of the recommendations, only documents what we
have been saying for years.

2 years ago[Hexagon] Delete unused declaration of LowerHvxMul, NFC
Krzysztof Parzyszek [Tue, 28 Dec 2021 19:36:07 +0000 (11:36 -0800)]
[Hexagon] Delete unused declaration of LowerHvxMul, NFC

2 years ago[Hexagon] Add testcase for arch flags
Brian Cain [Tue, 28 Dec 2021 19:23:50 +0000 (11:23 -0800)]
[Hexagon] Add testcase for arch flags

2 years ago[mlir][tosa] Resubmit split tosa-to-linalg named ops out of pass
Rob Suderman [Fri, 24 Dec 2021 00:25:53 +0000 (16:25 -0800)]
[mlir][tosa] Resubmit split tosa-to-linalg named ops out of pass

Includes dependency fix that resulted in canonicalizer pass not linking in.

Linalg named ops lowering are moved to a separate pass. This allows TOSA
canonicalizers to run between named-ops lowerings and the general TOSA
lowerings. This allows the TOSA canonicalizers to run between lowerings.

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

2 years ago[Hexagon] Move testcase accidentally committed to wrong directory
Krzysztof Parzyszek [Tue, 28 Dec 2021 19:20:03 +0000 (11:20 -0800)]
[Hexagon] Move testcase accidentally committed to wrong directory

llvm/test/DebugInfo/Hexagon/zreg-post-inc.s -> llvm/test/MC/Hexagon/zreg-post-inc.s

2 years ago[clang] Fix AttrDocs.td formatting.
Michael Benfield [Tue, 28 Dec 2021 19:10:27 +0000 (19:10 +0000)]
[clang] Fix AttrDocs.td formatting.

This should fix the builder clang-sphinx-docs.

2 years ago[AArch64] Minor AArch64MIPeepholeOpt cleanup. NFC
David Green [Tue, 28 Dec 2021 19:10:01 +0000 (19:10 +0000)]
[AArch64] Minor AArch64MIPeepholeOpt cleanup. NFC

We should always be in SSA form when running the pass, so turn a check
into an assert.

2 years ago[BitcodeReader] propagateAttributeTypes(): fix opaque pointer handling
Roman Lebedev [Tue, 28 Dec 2021 18:58:31 +0000 (21:58 +0300)]
[BitcodeReader] propagateAttributeTypes(): fix opaque pointer handling

Can't get the pointee type of an opaque pointer,
but in that case said attributes must already be typed,
so just don't try to rewrite them if they already are.

2 years agoFix "settings set -g" so it works again.
Greg Clayton [Tue, 28 Dec 2021 19:02:50 +0000 (11:02 -0800)]
Fix "settings set -g" so it works again.

When we switched options over to use the Options.td file, a bug was introduced that caused the "-g" option for "settings set" to require a filename arguemnt. This patch fixes this issue and adds a test so this doesn't regress.

Reviewed By: JDevlieghere

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

2 years agoCache the manual DWARF index out to the LLDB cache directory when the LLDB index...
Greg Clayton [Tue, 28 Dec 2021 18:49:59 +0000 (10:49 -0800)]
Cache the manual DWARF index out to the LLDB cache directory when the LLDB index cache is enabled.

This patch add the ability to cache the manual DWARF indexing results to disk for faster subsequent debug sessions. Manual DWARF indexing is time consuming and causes all DWARF to be fully parsed and indexed each time you debug a binary that doesn't have an acceptable accelerator table. Acceptable accelerator tables include .debug_names in DWARF5 or Apple accelerator tables.

This patch breaks up testing by testing all of the encoding and decoding of required C++ objects in a gtest unit test, and then has a test to verify the debug info cache is generated correctly.

This patch also adds the ability to track when a symbol table or DWARF index is loaded or saved to the cache in the "statistics dump" command. This is essential to know in statistics as it can help explain why a debug session was slower or faster than expected.

Reviewed By: labath, wallace

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

2 years ago[CMake] Remove unneeded CLANG_DEFAULT_PIE_ON_LINUX canonicalization after D115751
Fangrui Song [Tue, 28 Dec 2021 18:49:52 +0000 (10:49 -0800)]
[CMake] Remove unneeded CLANG_DEFAULT_PIE_ON_LINUX canonicalization after D115751

2 years agoDrop unnecessary const from return types (NFC)
Kazu Hirata [Tue, 28 Dec 2021 18:01:39 +0000 (10:01 -0800)]
Drop unnecessary const from return types (NFC)

Identified with readability-const-return-type.

2 years ago[Hexagon] Add HexagonMCInstrInfo::IsABranchingInst, NFC
Brian Cain [Tue, 28 Dec 2021 17:51:27 +0000 (09:51 -0800)]
[Hexagon] Add HexagonMCInstrInfo::IsABranchingInst, NFC

2 years ago[Hexagon] Fix for producer operands search w/z-reg
Brian Cain [Thu, 6 Sep 2018 16:53:00 +0000 (11:53 -0500)]
[Hexagon] Fix for producer operands search w/z-reg

Z-register does not show up in defs, so checks searching
for the def operand must look for a different def index
than they would normally.

2 years ago[AMDGPU][NFC] Update to DWARF extension for heterogeneous debugging
Tony Tye [Sat, 25 Dec 2021 00:49:23 +0000 (00:49 +0000)]
[AMDGPU][NFC] Update to DWARF extension for heterogeneous debugging

- Update documentation on the DWARF extension for heterogeneous
  debugging to better reference the DWARF Version 5 standard.
- Numerous other corrections.

Reviewed By: kzhuravl

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

2 years ago[AMDGPU][NFC] Update DWARF extension allowing locations on stack
Tony Tye [Fri, 24 Dec 2021 08:30:06 +0000 (08:30 +0000)]
[AMDGPU][NFC] Update DWARF extension allowing locations on stack

Add changes to the DWARF Version 5 standard to the DWARF extension to
allow locations on the evaluation stack documentation.

Reviewed By: kzhuravl

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

2 years ago[llvm] Use nullptr instead of 0 (NFC)
Kazu Hirata [Tue, 28 Dec 2021 16:52:25 +0000 (08:52 -0800)]
[llvm] Use nullptr instead of 0 (NFC)

Identified with modernize-use-nullptr.

2 years ago[VPlan] Add prepareToExecute to set up live-ins (NFC).
Florian Hahn [Tue, 28 Dec 2021 16:49:46 +0000 (17:49 +0100)]
[VPlan] Add prepareToExecute to set up live-ins (NFC).

This patch adds a new prepareToExecute helper to set up live-ins, so
VPTransformState doesn't need to hold values like TripCount.

This also requires making the trip count operand for ActiveLaneMask
explicit in VPlan.

Reviewed By: Ayal

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

2 years ago[Hexagon] Remove isPredicateRegister in favor of isPredReg, NFC
Krzysztof Parzyszek [Tue, 28 Dec 2021 16:37:08 +0000 (08:37 -0800)]
[Hexagon] Remove isPredicateRegister in favor of isPredReg, NFC

HexagonMCChecker has its own function isPredicateRegister, which does
the same thing as HexagonMCInstrInfo::isPredReg.

2 years ago[Analysis] allow caller to choose signed/unsigned when computing constant range
Sanjay Patel [Tue, 28 Dec 2021 14:25:16 +0000 (09:25 -0500)]
[Analysis] allow caller to choose signed/unsigned when computing constant range

We should not lose analysis precision if an 'add' has both no-wrap
flags (nsw and nuw) compared to just one or the other.

This patch is modeled on a similar construct that was added with
D59386.

I don't think it is possible to expose a problem with an unsigned
compare because of the way this was coded (nuw is handled first).

InstCombine has an assert that fires with the example from:
https://github.com/llvm/llvm-project/issues/52884
...because it was expecting InstSimplify to handle this kind of
pattern with an smax.

Fixes #52884

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

2 years ago[InstSimplify] add tests for icmp with no-wrap add operand; NFC
Sanjay Patel [Mon, 27 Dec 2021 20:44:59 +0000 (15:44 -0500)]
[InstSimplify] add tests for icmp with no-wrap add operand; NFC

2 years ago[VPlan] Add abstract base class for header phi recipes (NFC).
Florian Hahn [Tue, 28 Dec 2021 14:37:28 +0000 (15:37 +0100)]
[VPlan] Add abstract base class for header phi recipes (NFC).

Not all header phis widen the phi, e.g. like the new
VPCanonicalIVPHIRecipe in D113223. To let those recipes also inherit
from a phi-like base class, add a more generic VPHeaderPHIRecipe
abstract base class.

Reviewed By: Ayal

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

2 years ago[InstCombine] Skip some GEP folds under opaque pointers
Nikita Popov [Tue, 28 Dec 2021 14:30:01 +0000 (15:30 +0100)]
[InstCombine] Skip some GEP folds under opaque pointers

In their current form, these folds are fundamentally incompatible
with opaque pointers. We should add a separate set of folds for
the canonicalization of the GEP source type. For now, skip these
folds.

2 years ago[InstCombine] Use GEP type instead of pointee type
Nikita Popov [Tue, 28 Dec 2021 13:57:43 +0000 (14:57 +0100)]
[InstCombine] Use GEP type instead of pointee type

The GEP source type is independent of whether it is a scalar or
vector GEP, as such we can simply preserve it.

2 years ago[ConstFold] Add another icmp of gep of global test (NFC)
Nikita Popov [Tue, 28 Dec 2021 13:28:28 +0000 (14:28 +0100)]
[ConstFold] Add another icmp of gep of global test (NFC)

This time with some complex arithmetic involving bitcasts.

2 years ago[Assembler] Regenerate test checks (NFC)
Nikita Popov [Tue, 28 Dec 2021 13:20:29 +0000 (14:20 +0100)]
[Assembler] Regenerate test checks (NFC)

Switch this Assembler test to use utc by adding a dummy function
and opt run line.

2 years ago[ConstFold] Don't fold signed comparison of gep of global
Nikita Popov [Tue, 28 Dec 2021 13:09:34 +0000 (14:09 +0100)]
[ConstFold] Don't fold signed comparison of gep of global

An inbounds GEP may still cross the sign boundary, so signed icmps
cannot be folded (https://alive2.llvm.org/ce/z/XSgi4D). This was
previously fixed for other folds in this function, but this one
was missed.

2 years ago[ConstFold] Add additional icmp of gep of global tests (NFC)
Nikita Popov [Tue, 28 Dec 2021 13:06:07 +0000 (14:06 +0100)]
[ConstFold] Add additional icmp of gep of global tests (NFC)

The fold is incorrect for the sgt case, as gep inbounds is allowed
to cross the sign boundary.