platform/upstream/llvm.git
3 years agoEmit metadata when instr. profiles hash mismatch occurs.
Sriraman Tallam [Fri, 29 Jan 2021 20:52:59 +0000 (12:52 -0800)]
Emit metadata when instr. profiles hash mismatch occurs.

This patch emits "instr_prof_hash_mismatch" function annotation metadata if
there is a hash mismatch while applying instrumented profiles.

During the PGO optimized build using instrumented profiles, if the CFG of
the function has changed since generating the profile, a hash mismatch is
encountered. This patch emits this information as annotation metadata. We
plan to use this with Propeller which is done at the machine IR level.
Propeller is usually applied on top of PGO and a hash mismatch during
PGO could be used to detect source drift.

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

3 years ago[clang-tidy] Fix linking tests to LLVMTestingSupport
Michał Górny [Fri, 29 Jan 2021 01:14:47 +0000 (02:14 +0100)]
[clang-tidy] Fix linking tests to LLVMTestingSupport

LLVMTestingSupport is not part of libLLVM, and therefore can not
be linked to via LLVM_LINK_COMPONENTS.  Instead, it needs to be
specified explicitly to ensure that it is linked explicitly
even if LLVM_LINK_LLVM_DYLIB is used.  This is consistent with handling
in clangd.

Fixes PR#48931

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

3 years ago[mlir] Preserve lexicographic order after loop collapsing.
Alexander Belyaev [Fri, 29 Jan 2021 20:26:57 +0000 (21:26 +0100)]
[mlir] Preserve lexicographic order after loop collapsing.

Currently, for a scf.parallel (i,j,k) after the loop collapsing to 1D is done, the
IVs would be traversed as for an scf.parallel(k,j,i).

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

3 years agoRevert "[CMake] Actually require python 3.6 or greater"
Christopher Tetreault [Fri, 29 Jan 2021 20:03:32 +0000 (12:03 -0800)]
Revert "[CMake] Actually require python 3.6 or greater"

There are builders that do not have python 3.6. Revert until this situation can be rectified

This reverts commit 0703b0753c40dad30f1683403f6600bd2cb42055.

3 years ago[CMake] Actually require python 3.6 or greater
Christopher Tetreault [Fri, 29 Jan 2021 17:11:38 +0000 (09:11 -0800)]
[CMake] Actually require python 3.6 or greater

Previously, CMake would find any version of Python3. However, the project
claims to require 3.6 or greater, and 3.6 features are being used.

Reviewed By: yln

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

3 years ago[GlobalISel] Remove hint instructions in generic InstructionSelect code.
Jessica Paquette [Thu, 28 Jan 2021 20:27:30 +0000 (12:27 -0800)]
[GlobalISel] Remove hint instructions in generic InstructionSelect code.

I think every target will want to remove these in the same way. Rather than
making them all implement the same code, let's just put this in
InstructionSelect.

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

3 years ago[VE] Add include for formatted_raw_ostream after 046cfb856517c6140d5e1c0989232e26d00b05b2
Fangrui Song [Fri, 29 Jan 2021 19:18:30 +0000 (11:18 -0800)]
[VE] Add include for formatted_raw_ostream after 046cfb856517c6140d5e1c0989232e26d00b05b2

3 years ago[AIX] Actually push back "-mabi=vec-extabi" when option is on.
Zarko Todorovski [Fri, 29 Jan 2021 19:05:17 +0000 (14:05 -0500)]
[AIX] Actually push back "-mabi=vec-extabi" when option is on.

Accidentaly ommitted the portion of pushing back the option in
https://reviews.llvm.org/D94986

3 years ago[libcxx][test] Silence MSVC narrowing warning
Casey Carter [Fri, 29 Jan 2021 19:05:52 +0000 (11:05 -0800)]
[libcxx][test] Silence MSVC narrowing warning

3 years ago[OpenMP] Add environment variable to force monotonic dynamic scheduling
Jonathan Peyton [Fri, 22 Jan 2021 20:45:45 +0000 (14:45 -0600)]
[OpenMP] Add environment variable to force monotonic dynamic scheduling

This patch introduces a new environment variable to force monotonic
behavior for users that absolutely need it.  This is in anticipation
of 5.0 change that uses non-monotonic behavior for dynamic scheduling
by default. Fixes for that and the actual switch are coming soon.

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

3 years ago[OpenMP][NFC] Added release note for new `deviceRTLs` and hidden helper task
Shilei Tian [Fri, 29 Jan 2021 18:12:47 +0000 (13:12 -0500)]
[OpenMP][NFC] Added release note for new `deviceRTLs` and hidden helper task

Added release note for new `deviceRTLs` and hidden helper task for LLVM
12.

Reviewed By: jdoerfert

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

3 years ago[libcxx][test] Silence false positive MSVC /analyze warning
Casey Carter [Fri, 29 Jan 2021 18:05:14 +0000 (10:05 -0800)]
[libcxx][test] Silence false positive MSVC /analyze warning

3 years ago[libcxx][test] explicitly discard bitset::test's return
Casey Carter [Fri, 29 Jan 2021 18:01:37 +0000 (10:01 -0800)]
[libcxx][test] explicitly discard bitset::test's return

... just in case some implementation annotates it `[[nodiscard]]`.

3 years agoMake the profile-filter.c test compatible with 32-bit systems
Petr Hosek [Fri, 29 Jan 2021 03:01:41 +0000 (19:01 -0800)]
Make the profile-filter.c test compatible with 32-bit systems

This addresses PR48930.

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

3 years ago[AArch64][Clang][Linux] Enable out-of-line atomics by default.
Pavel Iliin [Thu, 17 Dec 2020 20:07:35 +0000 (20:07 +0000)]
[AArch64][Clang][Linux] Enable out-of-line atomics by default.

Generate outline atomics if compiling for armv8-a non-LSE AArch64 Linux
(including Android) targets to use LSE instructions, if they are available,
at runtime. Library support is checked by clang driver which doesn't enable
outline atomics if no proper libraries (libgcc >= 9.3.1 or compiler-rt) found.

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

3 years ago[mlir][docs] Fix typo: even -> event
Jordan Rupprecht [Fri, 29 Jan 2021 17:16:35 +0000 (09:16 -0800)]
[mlir][docs] Fix typo: even -> event

3 years ago[flang][docs] Add New Flang Driver Biweekly call
Andrzej Warzynski [Fri, 29 Jan 2021 16:56:53 +0000 (16:56 +0000)]
[flang][docs] Add New Flang Driver Biweekly call

3 years ago[GlobalISel] Fix modifying a G_OR without notifying the observer
Jay Foad [Fri, 29 Jan 2021 14:41:58 +0000 (14:41 +0000)]
[GlobalISel] Fix modifying a G_OR without notifying the observer

Remove the call to setFlags in favour of creating the instruction with
the correct flags in the first place, so we don't have to explicitly
notify the observer.

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

3 years agoRevert "Disable rosegment for old Android versions."
Nico Weber [Fri, 29 Jan 2021 16:20:04 +0000 (11:20 -0500)]
Revert "Disable rosegment for old Android versions."

This reverts commit fae16fc0eed7cf60207901818cfe040116f2ef00.
Breaks building compiler-rt android runtimes with trunk clang
but older NDK, see discussion on https://reviews.llvm.org/D95166

3 years ago[AMDGPU] Test all register names known to AMDGPUPALMetadata
Jay Foad [Thu, 28 Jan 2021 14:19:31 +0000 (14:19 +0000)]
[AMDGPU] Test all register names known to AMDGPUPALMetadata

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

3 years ago[flang] Fix problems with constant arrays with lower bounds that are not 1
Peter Steinfeld [Tue, 26 Jan 2021 16:20:57 +0000 (08:20 -0800)]
[flang] Fix problems with constant arrays with lower bounds that are not 1

There were two problems with constant arrays whose lower bound is not 1.
First, when folding the arrays, we were creating the folded array to have lower
bounds of 1 but, we were not re-adjusting their lower bounds to the
declared values.  Second, we were not calculating the extents correctly.
Both of these problems led to bogus error messages.

I fixed the first problem by adjusting the lower bounds in
NonPointerInitializationExpr() in Evaluate/check-expression.cpp.  I wrote the
class ArrayConstantBoundChanger, which is similar to the existing class
ScalarConstantExpander.  In the process of implementing and testing it, I found
a bug that I fixed in ScalarConstantExpander which caused it to infinitely
recurse on parenthesized expressions.  I also removed the unrelated class
ScalarExpansionVisitor, which was not used.

I fixed the second problem by changing the formula that calculates upper bounds
in in the function ComputeUpperBound() in Evaluate/shape.cpp.

I added tests that trigger the bogus error messages mentioned above along with
a constant folding tests that uses array operands with shapes that conform but
have different bounds.

In the process of adding tests, I discovered that tests in
Evaluate/folding09.f90 and folding16.f90 were written incorrectly, and I
fixed them.  This also revealed a bug in contant folding of the
intrinsic "lbounds" which I plan to fix in a later change.

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

3 years ago[TableGen] Fix instantiating multiclass in foreach
J-Y You [Fri, 29 Jan 2021 15:24:30 +0000 (10:24 -0500)]
[TableGen] Fix instantiating multiclass in foreach

If multiclass argument comes from loop varaible and argument is record type,
it will not recognize the type. This patch ensures that loop variables are
resolved correctly.

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

3 years agoclang-cl: Accept /std:c11, /std:c17 flags
Nico Weber [Wed, 27 Jan 2021 23:59:39 +0000 (18:59 -0500)]
clang-cl: Accept /std:c11, /std:c17 flags

clang-cl already defaults to C17 for .c files, but no harm
in accepting these flags. Fixes PR48185.

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

3 years agoclang-cl: Invent a /winsysroot concept
Nico Weber [Wed, 27 Jan 2021 16:01:59 +0000 (11:01 -0500)]
clang-cl: Invent a /winsysroot concept

On non-Windows platforms, --sysroot can be used to make the compiler use
a single, hermetic directory for all header and library files.

This is useful, but difficult to do on Windows. After D95472 it's
possible to achieve this with two flags:

    out/gn/bin/clang-cl win.c -fuse-ld=lld \
        /vctoolsdir path/to/VC/Tools/MSVC/14.26.28801 \
        /winsdkdir path/to/win_sdk

But that's still cumbersome: It requires two flags instead of one, and
it requires writing down the (changing) VC/Tools/MSVC version.

This adds a new `/winsysroot <dir>` flag that's effectively an alias to
these two flags. With this, building against a hermetic Windows
toolchain only needs:

    out/gn/bin/clang-cl win.c -fuse-ld=lld /winsysroot path

`/winsysroot <dir>` is the same as adding

    /vctoolsdir <dir>/VC/Tools/MSVC/<vctoolsver>
    /winsdkdir <dir>/Windows Kits/<winsdkmajorversion>

`<vctoolsver>` is taken from `/vctoolsversion` if passed, or else it's
the name of the directory in `<dir>/VC/Tools/MSVC` that's the highest
numeric tuple.

`<winsdkmajorversion>` is the major version in /winsdkversion if passed,
else it's the name of the directory in `<dir>/Windows Kits` that's the
highest number.

So `/winsysroot <path>` requires this subfolder structure:

  path/
    VC/
      Tools/
        MSVC/
          14.26.28801  (or another number)
            include/
            ...
    Windows Kits/
      10/
        Include/
          10.0.19041.0/ (or another number)
            um/
            ...
        Lib/
          10.0.19041.0/ (or another number)
            um/
              x64/
              ...
            ...

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

3 years ago[X86][SSE] combineExtractWithShuffle - support zero-extending to allow extracting...
Simon Pilgrim [Fri, 29 Jan 2021 14:21:55 +0000 (14:21 +0000)]
[X86][SSE] combineExtractWithShuffle - support zero-extending to allow extracting from narrow shuffle masks

If the shuffle mask can't be widened to match the original extracted element width, see if the upper bits are zeroable - which allows us to extract+zero-extend the smaller extraction.

3 years ago[mlir] Remove mlir_c_runner_utils_static.
Christian Sigg [Thu, 28 Jan 2021 14:03:25 +0000 (15:03 +0100)]
[mlir] Remove mlir_c_runner_utils_static.

The library is not actually static when BUILD_SHARED_LIBS is on, and tests need to explicitly load it already. Also, the shared objects it was linked to did not use any symbols from it and it was therefore never linked to it.

Reviewed By: ftynse

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

3 years agoRevert "[clangd] Extract symbol-scope logic out of Quality, add tests. NFC"
Sam McCall [Fri, 29 Jan 2021 13:59:16 +0000 (14:59 +0100)]
Revert "[clangd] Extract symbol-scope logic out of Quality, add tests. NFC"

On second thought, this can't properly be reused for highlighting.

Consider this example, which Quality wants to consider function-scope,
but highlighting must consider class-scope:

void foo() {
  class X {
    int ^y;
  };
}

3 years ago[clangd] Extract symbol-scope logic out of Quality, add tests. NFC
Sam McCall [Fri, 29 Jan 2021 13:38:43 +0000 (14:38 +0100)]
[clangd] Extract symbol-scope logic out of Quality, add tests. NFC

This prepares for reuse from the semantic highlighting code.

There's a bit of yak-shaving here:
 - when the enum is moved into the clangd namespace, promote it to a
   scoped enum. This means teaching the decision forest infrastructure
   to deal with scoped enums.
 - AccessibleScope isn't quite the right name: e.g. public class members
   are treated as accessible, but still have class scope. So rename to
   SymbolScope.
 - Rename some QualitySignals members to avoid name conflicts.
   (the string) SymbolScope -> Scope
   (the enum) Scope -> ScopeKind

3 years ago[MachineLICM] Fix wrong and confusing comment. NFC.
Sjoerd Meijer [Fri, 29 Jan 2021 13:32:56 +0000 (13:32 +0000)]
[MachineLICM] Fix wrong and confusing comment. NFC.

3 years ago[gn build] port e90e455d2a0cc
Nico Weber [Fri, 29 Jan 2021 13:36:19 +0000 (08:36 -0500)]
[gn build] port e90e455d2a0cc

3 years ago[Syntax] Add syntax-tree-dump in clang-check.
Haojian Wu [Fri, 29 Jan 2021 08:08:02 +0000 (09:08 +0100)]
[Syntax] Add syntax-tree-dump in clang-check.

This is useful to experiment/develop syntax trees.

Reviewed By: sammccall

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

3 years ago[test] Use host platform specific error message substitution in lit tests
Abhina Sreeskantharajan [Fri, 29 Jan 2021 12:15:50 +0000 (07:15 -0500)]
[test] Use host platform specific error message substitution in lit tests

On z/OS, the following error message is not matched correctly in lit tests.

```
EDC5129I No such file or directory.
```

This patch uses a lit config substitution to check for platform specific error messages.

Reviewed By: muiez, jhenderson

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

3 years ago[MemCpyOpt] Add test for incorrect optimization across lifetime (NFC)
Nikita Popov [Fri, 29 Jan 2021 11:56:23 +0000 (12:56 +0100)]
[MemCpyOpt] Add test for incorrect optimization across lifetime (NFC)

This only affects the MemorySSA-based implementation.

3 years ago[LTO] Update splitCodeGen to take a reference to the module. (NFC)
Florian Hahn [Fri, 29 Jan 2021 10:20:54 +0000 (10:20 +0000)]
[LTO] Update splitCodeGen to take a reference to the module. (NFC)

splitCodeGen does not need to take ownership of the module, as it
currently clones the original module for each split operation.

There is an ~4 year old fixme to change that, but until this is
addressed, the function can just take a reference to the module.

This makes the transition of LTOCodeGenerator to use LTOBackend a bit
easier, because under some circumstances, LTOCodeGenerator needs to
write the original module back after codegen.

Reviewed By: tejohnson

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

3 years ago[gn build] (semi-manually) port 2ff8662b5d16
Nico Weber [Fri, 29 Jan 2021 11:48:17 +0000 (06:48 -0500)]
[gn build] (semi-manually) port 2ff8662b5d16

3 years ago[libcxx] Sanitize paths before creating symlinks on windows
Martin Storsjö [Mon, 9 Nov 2020 13:20:18 +0000 (15:20 +0200)]
[libcxx] Sanitize paths before creating symlinks on windows

The MS STL does even more cleanup (corresponding to lexically_normal
I think), but this seems to be the very minimum needed for making the
symlinks work when the target path contains non-native paths.

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

3 years ago[libcxx] Hook up a number of operation functions to their windows counterparts
Martin Storsjö [Fri, 6 Nov 2020 09:16:30 +0000 (11:16 +0200)]
[libcxx] Hook up a number of operation functions to their windows counterparts

Use the corresponding wchar functions, named "_wfunc" instead of "func",
where feasible, or reimplement functions with native windows APIs.

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

3 years ago[libcxx] Implement _FilesystemClock::now() and __last_write_time for windows
Martin Storsjö [Wed, 4 Nov 2020 20:56:03 +0000 (22:56 +0200)]
[libcxx] Implement _FilesystemClock::now() and __last_write_time for windows

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

3 years ago[libcxx] Implement the stat function family on top of native windows APIs
Martin Storsjö [Wed, 4 Nov 2020 14:59:07 +0000 (16:59 +0200)]
[libcxx] Implement the stat function family on top of native windows APIs

While the windows CRTs (the modern UCRT, and the legacy msvcrt.dll
that mingw still often defaults to) do provide stat functions, they're
a bit lacking - they only provide second precision on the modification
time, lack support for symlinks and a few other details.

Instead reimplement them using a couple windows native functions,
getting exactly the info we need. (Technically, the implementation
within the CRT calls these functions anyway.)

If we only need a few fields, we could also do with fewer calls, as a
later optimization.

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

3 years agoFix macos target assumption in test
Thomas Preud'homme [Wed, 6 Jan 2021 23:22:12 +0000 (23:22 +0000)]
Fix macos target assumption in test

Clang test Driver/macos-apple-silicon-slice-link-libs-darwin-only.cpp
assumes the target is darwin when the host is darwin which is not
necessarily the case, causing the test to fail when it is not. This
commit adds a -triple argument to the clang invocation to ensure the
target is darwin.

Reviewed By: hans

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

3 years ago[OpenMP] libomp: fix build by cl with vs2019
AndreyChurbanov [Fri, 29 Jan 2021 10:16:41 +0000 (13:16 +0300)]
[OpenMP] libomp: fix build by cl with vs2019

Replace VLA with dynamic allocation using alloca().
This fixes https://bugs.llvm.org/show_bug.cgi?id=48919.

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

3 years agoAdapt lldb-instr to d47ee525f9e92898 APi change
serge-sans-paille [Fri, 29 Jan 2021 09:57:45 +0000 (10:57 +0100)]
Adapt lldb-instr to d47ee525f9e92898 APi change

3 years ago[mlir] Prevent segfault in Tensor canonicalization
Tres Popp [Wed, 27 Jan 2021 16:28:14 +0000 (17:28 +0100)]
[mlir] Prevent segfault in Tensor canonicalization

This segfault could occur from out of bounds accesses when simplifying
tensor.extract with a constant index and a tensor created by
tensor.from_elements.

This IR is not necesarilly invalid as it might conditionally be
never executed.

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

3 years ago[libc][Obvious] Fix typo
Cheng Wang [Fri, 29 Jan 2021 09:41:25 +0000 (17:41 +0800)]
[libc][Obvious] Fix typo

3 years ago[clang-tooling] Prevent llvm::fatal_error on invalid CLI option
serge-sans-paille [Mon, 11 Jan 2021 15:19:35 +0000 (16:19 +0100)]
[clang-tooling] Prevent llvm::fatal_error on invalid CLI option

Fail gracefully instead. Prevent further misuse by enforcing the factory builder
instead of the constructor.

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

3 years ago[llvm-jitlink] Replace use of deprecated gethostbyname by getaddrinfo.
Rafik Zurob [Fri, 22 Jan 2021 12:51:19 +0000 (06:51 -0600)]
[llvm-jitlink] Replace use of deprecated gethostbyname by getaddrinfo.

This patch replaces use of deprecated gethostbyname by getaddrinfo.

Author: Rafik Zurob

Reviewed By: lhames

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

3 years ago[libc][Obvious] Remove DEPS for unistd.h in CMake file of memmove.
Cheng Wang [Fri, 29 Jan 2021 08:43:44 +0000 (16:43 +0800)]
[libc][Obvious] Remove DEPS for unistd.h in CMake file of memmove.

3 years ago[llvm-readobj/elf] - Report "bitcode files are not supported" warning for bitcode...
Georgii Rymar [Thu, 28 Jan 2021 10:28:55 +0000 (13:28 +0300)]
[llvm-readobj/elf] - Report "bitcode files are not supported" warning for bitcode files.

Fixes https://bugs.llvm.org/show_bug.cgi?id=43543

Currently we report "The file was not recognized as a valid object file" for BC files.
Also, we terminate dumping.

Instead we could report a better warning and try to continue dumping other files.
This is what this patch implements.

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

3 years agoRevert "[clang-format] Add option to control the spaces in a line comment"
Björn Schäpers [Fri, 29 Jan 2021 08:28:03 +0000 (09:28 +0100)]
Revert "[clang-format] Add option to control the spaces in a line comment"

This reverts commit 078f30e04d1fcb5a05d8e340f3178f3478075541.

3 years ago[clangd] Add include-fixer fixit for field_incomplete_or_sizeless diagnostic.
Haojian Wu [Tue, 26 Jan 2021 10:50:33 +0000 (11:50 +0100)]
[clangd] Add include-fixer fixit for field_incomplete_or_sizeless diagnostic.

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

3 years ago[NFC][ScalarizeMaskedMemIntrin] Fix unused variable warning
Yang Fan [Fri, 29 Jan 2021 07:13:04 +0000 (15:13 +0800)]
[NFC][ScalarizeMaskedMemIntrin] Fix unused variable warning

GCC warning:
```
/llvm-project/llvm/lib/Transforms/Scalar/ScalarizeMaskedMemIntrin.cpp: In function ‘void scalarizeMaskedStore(llvm::CallInst*, llvm::DomTreeUpdater*, bool&)’:
/llvm-project/llvm/lib/Transforms/Scalar/ScalarizeMaskedMemIntrin.cpp:295:15: warning: variable ‘IfBlock’ set but not used [-Wunused-but-set-variable]
  295 |   BasicBlock *IfBlock = CI->getParent();
      |               ^~~~~~~
/llvm-project/llvm/lib/Transforms/Scalar/ScalarizeMaskedMemIntrin.cpp: In function ‘void scalarizeMaskedScatter(llvm::CallInst*, llvm::DomTreeUpdater*, bool&)’:
/llvm-project/llvm/lib/Transforms/Scalar/ScalarizeMaskedMemIntrin.cpp:555:15: warning: variable ‘IfBlock’ set but not used [-Wunused-but-set-variable]
  555 |   BasicBlock *IfBlock = CI->getParent();
      |               ^~~~~~~
```

3 years ago[clang-tidy] bugprone-assert-side-effect: Warn on NSAssert by default.
Artem Dergachev [Fri, 29 Jan 2021 05:41:57 +0000 (21:41 -0800)]
[clang-tidy] bugprone-assert-side-effect: Warn on NSAssert by default.

NSAssert and NSCAssert are Objective-C Foundation's standard assert macros.

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

3 years ago[clang-tidy] bugprone-assert-side-effect: Improve warning message.
Artem Dergachev [Fri, 29 Jan 2021 05:40:48 +0000 (21:40 -0800)]
[clang-tidy] bugprone-assert-side-effect: Improve warning message.

Drop redundant "found", specify what exactly is wrong with side effects
in assert conditions.

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

3 years ago[MustExecute] Use ListSeparator (NFC)
Kazu Hirata [Fri, 29 Jan 2021 06:21:16 +0000 (22:21 -0800)]
[MustExecute] Use ListSeparator (NFC)

3 years ago[llvm] Populate SmallVector at construction time (NFC)
Kazu Hirata [Fri, 29 Jan 2021 06:21:14 +0000 (22:21 -0800)]
[llvm] Populate SmallVector at construction time (NFC)

3 years ago[llvm] Forward-declare formatted_raw_ostream (NFC)
Kazu Hirata [Fri, 29 Jan 2021 06:21:12 +0000 (22:21 -0800)]
[llvm] Forward-declare formatted_raw_ostream (NFC)

Various *TargetStreamer.h need formatted_raw_ostream but rely on a
forward declaration of formatted_raw_ostream in MCStreamer.h.  This
patch adds forward declarations right in *TargetStreamer.h.

While we are at it, this patch removes the one in MCStreamer.h, where
it is unnecessary.

3 years ago[clang-format] Add option to control the spaces in a line comment
Björn Schäpers [Sat, 26 Dec 2020 21:04:30 +0000 (22:04 +0100)]
[clang-format] Add option to control the spaces in a line comment

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

3 years ago[LiveDebugVariables] Add cache for SkipPHIsLabelsAndDebug to prevent
Wei Mi [Sat, 16 Jan 2021 18:11:18 +0000 (10:11 -0800)]
[LiveDebugVariables] Add cache for SkipPHIsLabelsAndDebug to prevent
iterating the same PHI/LABEL/Debug instructions repeatedly.

We run into a compiling timeout problem when building a target after its
SampleFDO profile is updated. It is because some very large blocks with
a bunch of PHIs at the beginning. LiveDebugVariables::emitDebugValues
called during VirtRegRewriter phase searchs the insertion point for those
large BBs repeatedly in SkipPHIsLabelsAndDebug, and each time
SkipPHIsLabelsAndDebug needs to go through the same set of PHIs before it
can find the first non PHI/Label/Debug instruction. This patch adds a cache
to save the last position for the sequence which has been checked in the
previous call of SkipPHIsLabelsAndDebug.

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

3 years ago[SCEV] Do not cache comparison result upon reached max depth as "equivalence". PR48725
Max Kazantsev [Fri, 29 Jan 2021 05:08:34 +0000 (12:08 +0700)]
[SCEV] Do not cache comparison result upon reached max depth as "equivalence". PR48725

We use `EquivalenceClasses` to cache the notion that two SCEVs are equivalent,
so save time in situation when `A` is equivalent to `B` and `B` is equivalent to `C`,
making check "if `A` is equivalent to `C`?" cheaper.

We also return `0` in the comparator when we reach max analysis depth to save
compile time. After doing this, we also cache them as being equivalent.

Now, imagine the following situation:
- `A` is proved equivalent to `B`;
- `C` is proved equivalent to `D`;
- Comparison of `A` against `D` is proved non-zero;
- Comparison of `B` against `C` reaches max depth (and gets cached as equivalence).

Now, before the invocation of compare(`B`, `C`), `A` and `D` belonged
to different equivalence classes, and their comparison returned non-zero.
After the the invocation of compare(`B`, `C`), equivalence classes get merged
and `A`, `B`, `C` and `D` all fall into the same equivalence class. So the comparator
will change its behavior for couple `A` and `D`, with weird consequences following it.
This comparator is finally used in `std::stable_sort`, and this behavior change
makes it crash (looks like it's causing a memory corruption).

Solution: this patch changes `CompareSCEVComplexity` to return `None`
when the max depth is reached. So in this case, we do not cache these SCEVs
(and their parents in the tree) as being equivalent.

Differential Revision: https://reviews.llvm.org/D94654
Reviewed By: lebedev.ri

3 years agoSupport a list of CostPerUse values
Christudasan Devadasan [Wed, 23 Dec 2020 05:21:13 +0000 (10:51 +0530)]
Support a list of CostPerUse values

This patch allows targets to define multiple cost
values for each register so that the cost model
can be more flexible and better used during the
register allocation as per the target requirements.

For AMDGPU the VGPR allocation will be more efficient
if the register cost can be associated dynamically
based on the calling convention.

Reviewed By: qcolombet

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

3 years ago[lldb] Use `foo is None` instead of `not foo` in darwin.py
Jonas Devlieghere [Fri, 29 Jan 2021 03:56:16 +0000 (19:56 -0800)]
[lldb] Use `foo is None` instead of `not foo` in darwin.py

Explicitly compare to None when checking the triple's components so we
don't bail out when one of them is the empty string.

3 years ago[NFC][DebugInfo] Fix Wreturn-type gcc warning
Yang Fan [Fri, 29 Jan 2021 02:44:44 +0000 (10:44 +0800)]
[NFC][DebugInfo] Fix Wreturn-type gcc warning

GCC warning:
```
/llvm-project/llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp: In member function ‘llvm::Expected<long unsigned int> llvm::dwarf::CFIProgram::Instruction::getOperandAsUnsigned(const llvm::dwarf::CFIProgram&, uint32_t) const’:
/llvm-project/llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp:425:1: warning: control reaches end of non-void function [-Wreturn-type]
  425 | }
      | ^
/llvm-project/llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp: In member function ‘llvm::Expected<long int> llvm::dwarf::CFIProgram::Instruction::getOperandAsSigned(const llvm::dwarf::CFIProgram&, uint32_t) const’:
/llvm-project/llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp:477:1: warning: control reaches end of non-void function [-Wreturn-type]
  477 | }
      | ^
```

3 years ago[NFC][llvm-nm] Fix unused variable warning
Yang Fan [Fri, 29 Jan 2021 02:27:43 +0000 (10:27 +0800)]
[NFC][llvm-nm] Fix unused variable warning

3 years agoFix typo in "[DebugInfo][CodeView] Use <lambda_n> as the display name for lambdas."
Amy Huang [Fri, 29 Jan 2021 03:02:51 +0000 (19:02 -0800)]
Fix typo in "[DebugInfo][CodeView] Use <lambda_n> as the display name for lambdas."
(Commited in d5f5deee9ee996f078fb40ee20795539409523e4)

3 years agoReland "[DebugInfo][CodeView] Use <lambda_n> as the display name for lambdas"
Amy Huang [Fri, 29 Jan 2021 00:46:26 +0000 (16:46 -0800)]
Reland "[DebugInfo][CodeView] Use <lambda_n> as the display name for lambdas"
with fix to test case and stringrefs.

Currently (for codeview) lambdas have a string like `<lambda_0>` in
their mangled name, and don't have any display name. This change uses the
`<lambda_0>` as the display name, which helps distinguish between lambdas
in -gline-tables-only, since there are no linkage names there.
It also changes how we display lambda names; previously we used
`<unnamed-tag>`; now it will show `<lambda_0>`.

I added a function to the mangling context code to create this string;
for Itanium it just returns an empty string.

Bug: https://bugs.llvm.org/show_bug.cgi?id=48432

Reviewed By: rnk

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

This reverts 9b21d4b9434d2d4796b0d60d64f6ded9bac95441

3 years ago[libcxx][test] move libc++-specific tests into the libcxx tree
Casey Carter [Fri, 29 Jan 2021 02:01:48 +0000 (18:01 -0800)]
[libcxx][test] move libc++-specific tests into the libcxx tree

...and rename from `version.pass.cpp` to `version.compile.pass.cpp` to follow the new convention.

3 years ago[libc][NFC] Add a few casts to suppress loss of precision warnings
Michael Jones [Thu, 28 Jan 2021 23:53:27 +0000 (23:53 +0000)]
[libc][NFC] Add a few casts to suppress loss of precision warnings

Reviewed By: sivachandra

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

3 years ago[libcxx][test] MoveOnly's comparisons are non-member
Casey Carter [Thu, 28 Jan 2021 22:24:31 +0000 (14:24 -0800)]
[libcxx][test] MoveOnly's comparisons are non-member

... so that comparisons with an `int` LHS and `MoveOnly` RHS are valid, as is necessary for the `partial_sort_copy` test to pass with an implementation that doesn't force a conversion to the type of the RHS as libc++ does.

3 years ago[AMDGPU] Fix WMM Entry SCC preservation
Carl Ritson [Wed, 27 Jan 2021 03:48:19 +0000 (12:48 +0900)]
[AMDGPU] Fix WMM Entry SCC preservation

SCC was not correctly preserved when entering WWM.
Current lit test was unable to detect this as entry block is
handled differently.
Additionally fix an issue where SCC was unnecessarily preserved
when exiting from WWM to Exact mode.

Reviewed By: foad

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

3 years ago[GlobalISel] Implement regbankselect for G_ASSERT_ZEXT
Jessica Paquette [Thu, 28 Jan 2021 18:16:44 +0000 (10:16 -0800)]
[GlobalISel] Implement regbankselect for G_ASSERT_ZEXT

This adds generic regbankselect support for G_ASSERT_ZEXT.

It inherits whatever register bank the source was given, always, on all targets.

I think that at the point where we run into these, the source register bank
should be decided.

This also adds some AArch64-specific code which makes sure we can handle
G_ASSERT_ZEXT when deciding on register banks for G_STORE, G_PHI, ... etc.

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

3 years agoEnsure that we traverse non-op() method bodys of lambdas
Stephen Kelly [Thu, 28 Jan 2021 23:40:16 +0000 (23:40 +0000)]
Ensure that we traverse non-op() method bodys of lambdas

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

3 years ago[AMDGPU] Mark V_SET_INACTIVE as defining SCC
Carl Ritson [Wed, 27 Jan 2021 04:55:33 +0000 (13:55 +0900)]
[AMDGPU] Mark V_SET_INACTIVE as defining SCC

V_SET_INACTIVE is implemented with S_NOT which clobbers SCC.
Mark sure it is marked appropriately.

Reviewed By: piotr

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

3 years agoRevert "[DebugInfo][CodeView] Use <lambda_n> as the display name for lambdas."
Amy Huang [Fri, 29 Jan 2021 00:41:26 +0000 (16:41 -0800)]
Revert "[DebugInfo][CodeView] Use <lambda_n> as the display name for lambdas."
for test failures.

This reverts commit d73564c510036b2d4f5858effdcd23fe54fc1063.

3 years ago[AArch64][GlobalISel] Enable CSE for the prelegalizer combiner.
Amara Emerson [Fri, 29 Jan 2021 00:08:47 +0000 (16:08 -0800)]
[AArch64][GlobalISel] Enable CSE for the prelegalizer combiner.

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

3 years ago[GlobalISel] Implement computeKnownBits for G_ASSERT_ZEXT
Jessica Paquette [Wed, 27 Jan 2021 22:01:38 +0000 (14:01 -0800)]
[GlobalISel] Implement computeKnownBits for G_ASSERT_ZEXT

It's the same as the ZEXT/TRUNC case, except SrcBitWidth is given by the
immediate operand.

Update KnownBitsTest.cpp and a MIR test for a concrete example.

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

3 years ago[DebugInfo][CodeView] Use <lambda_n> as the display name for lambdas.
Amy Huang [Thu, 28 Jan 2021 23:28:16 +0000 (15:28 -0800)]
[DebugInfo][CodeView] Use <lambda_n> as the display name for lambdas.

Currently (for codeview) lambdas have a string like `<lambda_0>` in
their mangled name, and don't have any display name. This change uses the
`<lambda_0>` as the display name, which helps distinguish between lambdas
in -gline-tables-only, since there are no linkage names there.
It also changes how we display lambda names; previously we used
`<unnamed-tag>`; now it will show `<lambda_0>`.

I added a function to the mangling context code to create this string;
for Itanium it just returns an empty string.

Bug: https://bugs.llvm.org/show_bug.cgi?id=48432

Reviewed By: rnk

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

3 years ago[AArch64][GlobalISel] Add a combine to fold away truncate in: G_ICMP EQ/NE (G_TRUNC...
Amara Emerson [Wed, 27 Jan 2021 07:39:56 +0000 (23:39 -0800)]
[AArch64][GlobalISel] Add a combine to fold away truncate in: G_ICMP EQ/NE (G_TRUNC(v), 0)

We try to do this optimization if we can determine that testing for the
truncated bits with an eq/ne predicate results in the same thing as testing
the lower bits.

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

3 years agoIntroduce a new DialectIdentifier structure, extending Identifier with a Dialect...
Mehdi Amini [Fri, 29 Jan 2021 00:05:26 +0000 (00:05 +0000)]
Introduce a new DialectIdentifier structure, extending Identifier with a Dialect information

This class is looking up a dialect prefix on the identifier on initialization
and keeping a pointer to the Dialect when found.

The NamedAttribute key is now a DialectIdentifier.

Reviewed By: rriddle, jpienaar

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

3 years ago[clang-tidy] Applied clang-tidy fixes. NFC
Alexander Kornienko [Thu, 28 Jan 2021 23:49:53 +0000 (00:49 +0100)]
[clang-tidy] Applied clang-tidy fixes. NFC

Applied fixes enabled by the LLVM's .clang-tidy configs. Reverted files where
fixes introduced compile errors:
  clang-tools-extra/clang-tidy/hicpp/NoAssemblerCheck.cpp
  clang-tools-extra/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp

$ clang-tools-extra/clang-tidy/tool/run-clang-tidy.py -fix clang-tools-extra/clang-tidy/
Enabled checks:
    llvm-else-after-return
    llvm-header-guard
    llvm-include-order
    llvm-namespace-comment
    llvm-prefer-isa-or-dyn-cast-in-conditionals
    llvm-prefer-register-over-unsigned
    llvm-qualified-auto
    llvm-twine-local
    misc-definitions-in-headers
    misc-misplaced-const
    misc-new-delete-overloads
    misc-no-recursion
    misc-non-copyable-objects
    misc-redundant-expression
    misc-static-assert
    misc-throw-by-value-catch-by-reference
    misc-unconventional-assign-operator
    misc-uniqueptr-reset-release
    misc-unused-alias-decls
    misc-unused-using-decls
    readability-identifier-naming

Reviewed By: aaron.ballman

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

3 years agoFix windows buildbot build errors from D89845.
Greg Clayton [Thu, 28 Jan 2021 23:23:22 +0000 (15:23 -0800)]
Fix windows buildbot build errors from D89845.

3 years ago[mlir][Linalg] Fix SFINAE check to actually check the value.
Richard Smith [Thu, 28 Jan 2021 23:12:03 +0000 (15:12 -0800)]
[mlir][Linalg] Fix SFINAE check to actually check the value.

No internal functionality change intended, but this fixes out-of-tree
uses.

3 years agoADT: Fix typo in static assert message from 17c584551d573f1693990773e29fbe6b4b6fa4f4
Duncan P. N. Exon Smith [Thu, 28 Jan 2021 23:14:46 +0000 (15:14 -0800)]
ADT: Fix typo in static assert message from 17c584551d573f1693990773e29fbe6b4b6fa4f4

3 years agoADT: Add SFINAE to the generic IntrusiveRefCntPtr constructors
Duncan P. N. Exon Smith [Wed, 27 Jan 2021 03:51:22 +0000 (19:51 -0800)]
ADT: Add SFINAE to the generic IntrusiveRefCntPtr constructors

Add an `enable_if` to the generic `IntrusiveRefCntPtr` constructors so
that std::is_convertible gives an honest answer when the underlying
pointers cannot be converted. Added `static_assert`s to the test suite
to verify.

Also combine generic constructors from `IntrusiveRefCntPtr<X>&&` and
`const IntrusiveRefCntPtr<X>&`. At first glance this appears to be an
infinite loop, but the real copy/move constructors are spelled out
separately above. Added a unit test to verify.

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

3 years ago[sanitizer] Fix msan test build on FreeBSD after 7afdc89c2054
Dimitry Andric [Thu, 28 Jan 2021 22:53:45 +0000 (23:53 +0100)]
[sanitizer] Fix msan test build on FreeBSD after 7afdc89c2054

This commit accidentally enabled fgetgrent_r() in the msan tests under
FreeBSD, but this function is not supported. Also remove FreeBSD from
the SANITIZER_INTERCEPT_FGETGRENT_R macro.

3 years agoRecommit "[GlobalISel] Walk through hints in getDefIgnoringCopies et al"
Jessica Paquette [Thu, 28 Jan 2021 22:39:42 +0000 (14:39 -0800)]
Recommit "[GlobalISel] Walk through hints in getDefIgnoringCopies et al"

Recommit of 4580acf6752ea3cc884657b5aa3e174bed86fc8c

`Opc = DefMI->getOpcode()` was in the wrong place.

3 years agoRevert "[GlobalISel] Walk through hints in getDefIgnoringCopies et al"
Jessica Paquette [Thu, 28 Jan 2021 22:37:57 +0000 (14:37 -0800)]
Revert "[GlobalISel] Walk through hints in getDefIgnoringCopies et al"

This reverts commit 4580acf6752ea3cc884657b5aa3e174bed86fc8c.

Reverting while looking into some test failures.

3 years ago[GlobalISel] Walk through hints in getDefIgnoringCopies et al
Jessica Paquette [Thu, 28 Jan 2021 00:06:19 +0000 (16:06 -0800)]
[GlobalISel] Walk through hints in getDefIgnoringCopies et al

Treat hint instructions like G_ASSERT_ZEXT like COPY instructions in helpers
which walk through copies.

This ensures that instructions like G_ASSERT_ZEXT won't impact any optimizations
that rely on these helpers.

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

3 years ago[NFC][AMDGPU] Correct name of DWARF CFA extensions
Tony Tye [Thu, 28 Jan 2021 22:09:29 +0000 (22:09 +0000)]
[NFC][AMDGPU] Correct name of DWARF CFA extensions

Add LLVM to the DW_CFA_LLVM_def_aspace_cfa and
DW_CFA_LLVM_def_aspace_cfa_sf DWARF extensions.

Reviewed By: scott.linder

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

3 years ago[mlir][Linalg] Enable TileAndFusePattern to work with tensors.
MaheshRavishankar [Thu, 28 Jan 2021 18:51:01 +0000 (10:51 -0800)]
[mlir][Linalg] Enable TileAndFusePattern to work with tensors.

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

3 years ago[ScalarizeMaskedMemIntrin] Preserve Dominator Tree, if avaliable
Roman Lebedev [Thu, 28 Jan 2021 15:13:17 +0000 (18:13 +0300)]
[ScalarizeMaskedMemIntrin] Preserve Dominator Tree, if avaliable

This de-pessimizes the arguably more usual case of no masked mem intrinsics,
and gets rid of one more Dominator Tree recalculation.

As per llvm/test/CodeGen/X86/opt-pipeline.ll,
there's one more Dominator Tree recalculation left, we could get rid of.

3 years ago[PartiallyInlineLibCalls] Preserve Dominator Tree, if avaliable
Roman Lebedev [Thu, 28 Jan 2021 13:49:08 +0000 (16:49 +0300)]
[PartiallyInlineLibCalls] Preserve Dominator Tree, if avaliable

This doesn't get rid of any Dominator Tree recalculations just yet,
there is one more pass to update..

3 years ago[NFC][ScalarizeMaskedMemIntrin] scalarizeMaskedCompressStore(): port to SplitBlockAnd...
Roman Lebedev [Thu, 28 Jan 2021 19:59:15 +0000 (22:59 +0300)]
[NFC][ScalarizeMaskedMemIntrin] scalarizeMaskedCompressStore(): port to SplitBlockAndInsertIfThen()

Makes Dominator Tree preservation in a followup patch somewhat easier.

3 years ago[NFC][ScalarizeMaskedMemIntrin] scalarizeMaskedExpandLoad(): port to SplitBlockAndIns...
Roman Lebedev [Thu, 28 Jan 2021 19:39:19 +0000 (22:39 +0300)]
[NFC][ScalarizeMaskedMemIntrin] scalarizeMaskedExpandLoad(): port to SplitBlockAndInsertIfThen()

Makes Dominator Tree preservation in a followup patch somewhat easier.

3 years ago[NFC][ScalarizeMaskedMemIntrin] scalarizeMaskedScatter(): port to SplitBlockAndInsert...
Roman Lebedev [Thu, 28 Jan 2021 19:15:34 +0000 (22:15 +0300)]
[NFC][ScalarizeMaskedMemIntrin] scalarizeMaskedScatter(): port to SplitBlockAndInsertIfThen()

Makes Dominator Tree preservation in a followup patch somewhat easier.

3 years ago[NFC][ScalarizeMaskedMemIntrin] scalarizeMaskedGather(): port to SplitBlockAndInsertI...
Roman Lebedev [Thu, 28 Jan 2021 18:58:29 +0000 (21:58 +0300)]
[NFC][ScalarizeMaskedMemIntrin] scalarizeMaskedGather(): port to SplitBlockAndInsertIfThen()

Makes Dominator Tree preservation in a followup patch somewhat easier.

3 years ago[NFC][ScalarizeMaskedMemIntrin] scalarizeMaskedStore(): port to SplitBlockAndInsertIf...
Roman Lebedev [Thu, 28 Jan 2021 18:39:28 +0000 (21:39 +0300)]
[NFC][ScalarizeMaskedMemIntrin] scalarizeMaskedStore(): port to SplitBlockAndInsertIfThen()

Makes Dominator Tree preservation in a followup patch somewhat easier.

3 years ago[NFC][ScalarizeMaskedMemIntrin] scalarizeMaskedLoad(): port to SplitBlockAndInsertIfT...
Roman Lebedev [Thu, 28 Jan 2021 18:28:36 +0000 (21:28 +0300)]
[NFC][ScalarizeMaskedMemIntrin] scalarizeMaskedLoad(): port to SplitBlockAndInsertIfThen()

Makes Dominator Tree preservation in a followup patch somewhat easier.

3 years ago[NFC][PartiallyInlineLibCalls] Port to SplitBlockAndInsertIfThen()
Roman Lebedev [Thu, 28 Jan 2021 13:01:41 +0000 (16:01 +0300)]
[NFC][PartiallyInlineLibCalls] Port to SplitBlockAndInsertIfThen()

This makes follow-up patch for Dominator Tree preservation
somewhat more straight-forward.

3 years ago[NFC][EntryExitInstrumenter] Mark Dominator Tree as preserved in legacy-PM too
Roman Lebedev [Thu, 28 Jan 2021 21:45:04 +0000 (00:45 +0300)]
[NFC][EntryExitInstrumenter] Mark Dominator Tree as preserved in legacy-PM too

This is correctly handled in new-PM wrappers, but not in old-PM.

3 years ago[GlobalISel] Implement widenScalar for carry-in add/sub
Cassie Jones [Thu, 28 Jan 2021 18:20:35 +0000 (13:20 -0500)]
[GlobalISel] Implement widenScalar for carry-in add/sub

These are widened to a wider UADDE/USUBE, with the overflow value
unused, and with the same synthesis of a new overflow value as for the
O operations.

Reviewed By: paquette

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