platform/upstream/llvm.git
2 years ago[LoongArch] Include missing header files after D119244
Weining Lu [Fri, 11 Feb 2022 08:14:59 +0000 (00:14 -0800)]
[LoongArch] Include missing header files after D119244

Reviewed By: MaskRay

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

2 years agoRemove spurious includes and dependencies from Bazel files (NFC)
Mehdi Amini [Fri, 11 Feb 2022 07:14:40 +0000 (07:14 +0000)]
Remove spurious includes and dependencies from Bazel files (NFC)

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

2 years ago[X86] Zero out the 32-bit GPRs explicitly
Bill Wendling [Fri, 11 Feb 2022 07:08:11 +0000 (23:08 -0800)]
[X86] Zero out the 32-bit GPRs explicitly

This should ensure that only the 32-bit xors are emitted, and not the
64-bit xors.

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

2 years ago[NFC] Sort textual headers by alphabetical order
Shubham Rastogi [Fri, 11 Feb 2022 06:34:37 +0000 (22:34 -0800)]
[NFC] Sort textual headers by alphabetical order

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

2 years ago[MLIR] Add result status for normalizeAffineFor
Uday Bondhugula [Thu, 10 Feb 2022 08:40:58 +0000 (14:10 +0530)]
[MLIR] Add result status for normalizeAffineFor

Add result status for normalizeAffineFor utility.

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

2 years ago[libc++][ranges][NFC] Fix a typo in links on the Ranges status page.
Konstantin Varlamov [Fri, 11 Feb 2022 04:55:27 +0000 (20:55 -0800)]
[libc++][ranges][NFC] Fix a typo in links on the Ranges status page.

2 years ago[Object] Include llvm/Support/MemoryBuffer.h after D119457
Fangrui Song [Fri, 11 Feb 2022 04:23:22 +0000 (20:23 -0800)]
[Object] Include llvm/Support/MemoryBuffer.h after D119457

libc++ -DLLVM_ENABLE_MODULES=on build needs the complete type. This fixes

error: invalid application of 'sizeof' to an incomplete type 'llvm::MemoryBuffer'

2 years ago[RISCV] Fix -Wunused-variable in -DLLVM_ENABLE_ASSERTIONS=off builds
Fangrui Song [Fri, 11 Feb 2022 04:10:12 +0000 (20:10 -0800)]
[RISCV] Fix -Wunused-variable in -DLLVM_ENABLE_ASSERTIONS=off builds

2 years ago[C++20] [Modules] Check if modulemap exists to avoid crash in implicit used C++ module
ZezhengLi [Fri, 11 Feb 2022 03:22:04 +0000 (11:22 +0800)]
[C++20] [Modules] Check if modulemap exists to avoid crash in implicit used C++ module

An impilt used of C++ module without prebuild path may cause crash.

For example:

```
// ./dir1/C.cppm
export module C;
// ./dir2/B.cppm
export module B;
import C;
// ./A.cpp
import B;
import C;
```

When we compile A.cpp without the prebuild path of C.pcm, the compiler
will crash.

```
clang++ -std=c++20 --precompile -c ./dir1/C.cppm -o ./dir1/C.pcm
clang++ -std=c++20 --precompile -fprebuilt-module-path=./dir2  -c
./dir2/B.cppm -o ./dir2/B.pcm
clang++ -std=c++20 -fprebuilt-module-path=./dir2 A.cpp

```

The prebuilt path of module C is cached when import module B, and in the
function HeaderSearch::getCachedModuleFileName, the compiler try to get
the filename by modulemap without check if modulemap exists, and there
is no modulemap in C++ module.

Reviewed By: ChuanqiXu

Differential review: https://reviews.llvm.org/D119426

2 years ago[Analyzer] Re-enables trustnonnullchecker_test.m
Rashmi Mudduluru [Fri, 11 Feb 2022 02:49:34 +0000 (18:49 -0800)]
[Analyzer] Re-enables trustnonnullchecker_test.m

Differential review: https://reviews.llvm.org/D119270

2 years ago[libc++][ranges][NFC] Update the status of predefined iterators.
Konstantin Varlamov [Fri, 11 Feb 2022 02:43:43 +0000 (18:43 -0800)]
[libc++][ranges][NFC] Update the status of predefined iterators.

`{back,front}_insert_iterator` and `ostream{,buf}_iterator` effectively
fully implement the One Ranges Proposal already, so mark them as done:
- the change to `difference_type` was made by D103273;
- default constructors and the associated default member initializers
  were removed by wg21.link/P2325 (implemented by D102468).

Also fix a stale template signature in the `<iterator>` synopsis.

2 years ago[NFC] Make file offsets a regex to handle CRLF
Chris Bieneman [Wed, 19 Jan 2022 23:55:20 +0000 (17:55 -0600)]
[NFC] Make file offsets a regex to handle CRLF

None of these tests are really intended to test the file offset as much
as to test the structure. Making the regex allows this test to work
even if the file is checked out with CRLF line endings.

Reviewed By: aaron.ballman

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

2 years ago[clang][OpaquePtr] Use proper Address constructor in AtomicInfo::getAtomicAddress()
Arthur Eubanks [Fri, 11 Feb 2022 02:28:45 +0000 (18:28 -0800)]
[clang][OpaquePtr] Use proper Address constructor in AtomicInfo::getAtomicAddress()

2 years ago[AVR] Fix a potential assert failure
Ben Shi [Thu, 10 Feb 2022 09:29:05 +0000 (09:29 +0000)]
[AVR] Fix a potential assert failure

Reviewed By: MaskRay

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

2 years ago[llvm] Remove unused file MaximumSpanningTree.h
Nico Weber [Fri, 11 Feb 2022 01:59:28 +0000 (20:59 -0500)]
[llvm] Remove unused file MaximumSpanningTree.h

The last use of this file was removed in late 2013 in ea564946251e.
The last use was in PathProfiling.cpp, which had an overview comment
of the overall approach.

Similar functionality lives in the slight more cryptically named
CFGMST.h in this same directory. A similar overview comment is
in PGOInstrumentation.cpp.

No behavior change.

2 years ago[llvm] add missing word in a comment
Nico Weber [Fri, 11 Feb 2022 01:57:03 +0000 (20:57 -0500)]
[llvm] add missing word in a comment

2 years ago[runtimes] rewrap a comment to 80 columns
Nico Weber [Fri, 11 Feb 2022 01:56:36 +0000 (20:56 -0500)]
[runtimes] rewrap a comment to 80 columns

2 years ago[lld-macho][nfc] Centralize usages of ld64.lld in tests
Vincent Lee [Thu, 10 Feb 2022 01:05:18 +0000 (17:05 -0800)]
[lld-macho][nfc] Centralize usages of ld64.lld in tests

We have a mix of substituted lld (`%lld`) and hard-coded lld (`ld64.lld`) commands.
When testing with different versions of LLD, this would require going into every place
where lld is hard-coded and changing that. If we centralize it, this'll only  require us
to modify it in only one place and will make it easy to run the same test suite. Plus,
this will make it be consistent with how we write other tests.

Reviewed By: #lld-macho, int3, oontvoo

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

2 years ago[mlir][gpu] Add device side async copy operations
Thomas Raoux [Tue, 8 Feb 2022 04:41:05 +0000 (20:41 -0800)]
[mlir][gpu] Add device side async copy operations

Add new operations to the gpu dialect to represent device side
asynchronous copies. This also add the lowering of those operations to
nvvm dialect.
Those ops are meant to be low level and map directly to llvm dialects
like nvvm or rocdl.

We can further add higher level of abstraction by building on top of
those operations.
This has been discuss here:
https://discourse.llvm.org/t/modeling-gpu-async-copy-ampere-feature/4924

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

2 years ago[PDLL] Attempt to fix the gcc5 build by adding this-> to auto lambda
River Riddle [Fri, 11 Feb 2022 00:59:03 +0000 (16:59 -0800)]
[PDLL] Attempt to fix the gcc5 build by adding this-> to auto lambda

2 years ago[PSE] Remove assumption that top level predicate is union from public interface ...
Philip Reames [Thu, 10 Feb 2022 23:52:13 +0000 (15:52 -0800)]
[PSE] Remove assumption that top level predicate is union from public interface [NFC*]

Note that this doesn't actually cause the top level predicate to become a non-union just yet.

The * above comes from a case in the LoopVectorizer where a predicate which is later proven no longer blocks vectorization due to a change from checking if predicates exists to whether the predicate is possibly false.

2 years ago[clang][WebAssemmbly] Call TargetInfo::adjust in derived method.
Sam Clegg [Sun, 30 Jan 2022 19:10:59 +0000 (11:10 -0800)]
[clang][WebAssemmbly] Call TargetInfo::adjust in derived method.

The superclass method handles a bunch of useful things. For example
it applies flags such as `-fnew-alignment` which doesn't work without
this patch.

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

2 years agoDebugInfo: Don't simplify names referencing local enums
David Blaikie [Thu, 10 Feb 2022 23:48:48 +0000 (15:48 -0800)]
DebugInfo: Don't simplify names referencing local enums

Due to the way type units work, this would lead to a declaration in a
type unit of a local type in a CU - which is ambiguous. Rather than
trying to resolve that relative to the CU that references the type unit,
let's just not try to simplify these names.

Longer term this should be fixed by not putting the template
instantiation in a type unit to begin with - since it references an
internal linkage type, it can't legitimately be duplicated/in more than
one translation unit, so skip the type unit overhead. (but the right fix
for that is to move type unit management into a DICompositeType flag
(dropping the "identifier" field is not a perfect solution since it
breaks LLVM IR linking decl/def merging during IR linking))

2 years ago[SCEVPredicateRewriter] Remove assumption top level predicate is a union [NFC]
Philip Reames [Thu, 10 Feb 2022 23:50:50 +0000 (15:50 -0800)]
[SCEVPredicateRewriter] Remove assumption top level predicate is a union [NFC]

2 years ago[docs] Replace `opt -analyze` with better alternatives.
Arthur Eubanks [Thu, 10 Feb 2022 22:24:04 +0000 (14:24 -0800)]
[docs] Replace `opt -analyze` with better alternatives.

`opt -analyze` is legacy PM-specific. Show better ways of doing the same
thing, generally with some sort of `-passes=print<foo>`.

Reviewed By: asbirlea

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

2 years agoRevert "Add -fmodules-local-submodule-visibility to MANDATORY_MODULE_BUILD_CFLAGS"
Adrian Prantl [Thu, 10 Feb 2022 23:37:01 +0000 (15:37 -0800)]
Revert "Add -fmodules-local-submodule-visibility to MANDATORY_MODULE_BUILD_CFLAGS"

This reverts commit 547a667ceeb60dca5447e5bc09165a52b22925eb.

2 years ago[gn build] Port f92702141069
LLVM GN Syncbot [Thu, 10 Feb 2022 23:27:43 +0000 (23:27 +0000)]
[gn build] Port f92702141069

2 years agoFix Windows build that fails if a class has a member with the same naem
David Blaikie [Thu, 10 Feb 2022 23:27:14 +0000 (15:27 -0800)]
Fix Windows build that fails if a class has a member with the same naem

2 years ago[OpenMP][Offloading] Change the way to compare floating point values in bug49334.cpp
Shilei Tian [Thu, 10 Feb 2022 23:20:29 +0000 (18:20 -0500)]
[OpenMP][Offloading] Change the way to compare floating point values in bug49334.cpp

`bug49334.cpp` directly uses `!=` to compare two floating point values,
which is almost wrong.

Reviewed By: jhuber6

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

2 years agoReland "[clang-cl] Support the /JMC flag"
Yuanfang Chen [Thu, 10 Feb 2022 23:10:48 +0000 (15:10 -0800)]
Reland "[clang-cl] Support the /JMC flag"

This relands commit b380a31de084a540cfa38b72e609b25ea0569bb7.

Restrict the tests to Windows only since the flag symbol hash depends on
system-dependent path normalization.

2 years ago[OpenMP][CUDA] Remove the hard team limit
Shilei Tian [Thu, 10 Feb 2022 23:07:39 +0000 (18:07 -0500)]
[OpenMP][CUDA] Remove the hard team limit

Currently we have a hard team limit, which is set to 65536. It says no matter whether the device can support more teams, or users set more teams, as long as it is larger than that hard limit, the final number to launch the kernel will always be that hard limit. It is way less than the actual hardware limit. For example, my workstation has GTX2080, and the hardware limit of grid size is 2147483647, which is exactly the largest number a `int32_t` can represent. There is no limitation mentioned in the spec. This patch simply removes it.

Reviewed By: jdoerfert

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

2 years agoReverting an entire stack of changes causing build failures
YASHASVI KHATAVKAR [Thu, 10 Feb 2022 22:58:03 +0000 (17:58 -0500)]
Reverting  an entire stack of changes causing build failures

2 years agoDebugInfo: Don't simplify any template referencing a lambda
David Blaikie [Thu, 10 Feb 2022 22:40:25 +0000 (14:40 -0800)]
DebugInfo: Don't simplify any template referencing a lambda

Lambda names aren't entirely canonical (as demonstrated by the
cross-project-test added here) at the moment (we should fix that for a
bunch of reasons) - even if the template referencing them is
non-simplified, other names referencing /that/ template can't be
simplified either because type units might cause a different template to
be picked up that would conflict with the expected name.

(other than for roundtripping precision, it'd be OK to simplify types
that reference types that reference lambdas - but best be consistent
between the roundtrip/verify mode and the actual simplified template
names mode)

2 years ago[gn build] Port 290e5722e83e
LLVM GN Syncbot [Thu, 10 Feb 2022 22:52:25 +0000 (22:52 +0000)]
[gn build] Port 290e5722e83e

2 years ago[AMDGPU] Improve clobbering checks in the kernel argument promotion
Stanislav Mekhanoshin [Thu, 10 Feb 2022 21:02:23 +0000 (13:02 -0800)]
[AMDGPU] Improve clobbering checks in the kernel argument promotion

Use same MSSA clobbering checks as in the AMDGPUAnnotateUniformValues.
Kernel argument promotion needs exactly the same information so factor
out utility function isClobberedInFunction.

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

2 years ago[gn build] Port b380a31de084
LLVM GN Syncbot [Thu, 10 Feb 2022 22:24:30 +0000 (22:24 +0000)]
[gn build] Port b380a31de084

2 years ago[NFC][SCEV] `createNodeForSelectOrPHIViaUMinSeq()`: use sub instead of add
Roman Lebedev [Thu, 10 Feb 2022 18:16:19 +0000 (21:16 +0300)]
[NFC][SCEV] `createNodeForSelectOrPHIViaUMinSeq()`: use sub instead of add

For booleans, xor/add/sub are interchangeable:
https://alive2.llvm.org/ce/z/ziav3d

But for larger bitwidths, we'll need sub, so change it now.

2 years ago[NFC][LSR] Harden lsr-expand-quadratic.ll against smarter SCEV
Roman Lebedev [Thu, 10 Feb 2022 20:58:59 +0000 (23:58 +0300)]
[NFC][LSR] Harden lsr-expand-quadratic.ll against smarter SCEV

We can analyse that `select`, and after that
the test no longer does what it's supposed to.

2 years ago[NFC][CodeGen][X86] Autogenerate checklines in a test to simplify further updates
Roman Lebedev [Thu, 10 Feb 2022 21:25:51 +0000 (00:25 +0300)]
[NFC][CodeGen][X86] Autogenerate checklines in a test to simplify further updates

2 years ago[NFC][CodeGen][PPC] Autogenerate checklines in a test to simplify further updates
Roman Lebedev [Thu, 10 Feb 2022 20:34:13 +0000 (23:34 +0300)]
[NFC][CodeGen][PPC] Autogenerate checklines in a test to simplify further updates

2 years ago[NFC][LSR] Autogenerate checklines in a test to simplify further updates
Roman Lebedev [Thu, 10 Feb 2022 20:33:57 +0000 (23:33 +0300)]
[NFC][LSR] Autogenerate checklines in a test to simplify further updates

2 years ago[NFC][SCEV] Autogenerate checklines in a test to simplify further updates
Roman Lebedev [Thu, 10 Feb 2022 20:33:50 +0000 (23:33 +0300)]
[NFC][SCEV] Autogenerate checklines in a test to simplify further updates

2 years ago[libc++] Add LWG-issues from february 2022 plenary meeting
Nikolas Klauser [Thu, 10 Feb 2022 17:08:36 +0000 (18:08 +0100)]
[libc++] Add LWG-issues from february 2022 plenary meeting

Reviewed By: ldionne, Quuxplusone, Mordante, #libc

Spies: libcxx-commits

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

2 years agoRevert "[clang-cl] Support the /JMC flag"
Yuanfang Chen [Thu, 10 Feb 2022 22:17:37 +0000 (14:17 -0800)]
Revert "[clang-cl] Support the /JMC flag"

This reverts commit bd3a1de683f80d174ea9c97000db3ec3276bc022.

Break bots:
https://luci-milo.appspot.com/ui/p/fuchsia/builders/toolchain.ci/clang-windows-x64/b8822587673277278177/overview

2 years ago[Libomptarget][AMDGCN] add gfx90c target
Ye Luo [Thu, 10 Feb 2022 21:54:13 +0000 (15:54 -0600)]
[Libomptarget][AMDGCN] add gfx90c target

Reviewed By: JonChesterfield

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

2 years ago[CodeView] Avoid integer overflow while parsing long version strings
Reid Kleckner [Thu, 10 Feb 2022 21:40:28 +0000 (13:40 -0800)]
[CodeView] Avoid integer overflow while parsing long version strings

This came up on a funny vendor-provided version string that didn't have
a standard dotted quad of numbers.

2 years agoAdd support to dsymutil for dumping out new swift5 reflection sections
Shubham Sandeep Rastogi [Wed, 9 Feb 2022 05:26:40 +0000 (21:26 -0800)]
Add support to dsymutil for dumping out new swift5 reflection sections

This change adds support for dsymutil to be able to dump out the new swift5 reflection sections called swift5_proto and swift5_protos. The test is also updated to check for this.

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

2 years agoMake shtest-format.py CHECK lines more flexible
Douglas Yung [Thu, 10 Feb 2022 21:47:04 +0000 (13:47 -0800)]
Make shtest-format.py CHECK lines more flexible

The test sometimes fails on Windows due to a warning emitted by bash about not
being able to find the /tmp directory causing this test to randomly fail. This
update makes the test more flexible to account for this possibility and should
hopefully make it more reliable.

Reviewed By: probinson

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

2 years agoFix the build errors when enabling -DLLVM_ENABLE_MODULES=On and change e53e6ec6ef74
Shubham Sandeep Rastogi [Thu, 10 Feb 2022 20:37:59 +0000 (12:37 -0800)]
Fix the build errors when enabling -DLLVM_ENABLE_MODULES=On and change e53e6ec6ef74

Build Failure: https://green.lab.llvm.org/green/job/lldb-cmake/41267/

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

2 years ago[mlir][sparse][pytaco] add SDDMM test with two different ways of defining kernel
Aart Bik [Thu, 10 Feb 2022 19:33:38 +0000 (11:33 -0800)]
[mlir][sparse][pytaco] add SDDMM test with two different ways of defining kernel

Reviewed By: bixia

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

2 years ago[ThinLTO][WPD] LICM set lookup (NFC)
Teresa Johnson [Thu, 10 Feb 2022 20:41:00 +0000 (12:41 -0800)]
[ThinLTO][WPD] LICM set lookup (NFC)

Minor efficiency fix. There is no reason to perform the same set lookup
repeatedly in the inner loop as it is invariant there.

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

2 years agoUse functions with prototypes when appropriate; NFC
Aaron Ballman [Thu, 10 Feb 2022 21:04:13 +0000 (16:04 -0500)]
Use functions with prototypes when appropriate; NFC

A significant number of our tests in C accidentally use functions
without prototypes. This patch converts the function signatures to have
a prototype for the situations where the test is not specific to K&R C
declarations. e.g.,

  void func();

becomes

  void func(void);

This is the seventh batch of tests being updated (there are a
significant number of other tests left to be updated).

2 years ago[AArch64] Add extra fptoint_sat tests for larger than legal types. NFC
David Green [Thu, 10 Feb 2022 21:04:41 +0000 (21:04 +0000)]
[AArch64] Add extra fptoint_sat tests for larger than legal types. NFC

2 years ago[FileCheck] Fix initialized but never used static analyzer warning. NFC.
Simon Pilgrim [Thu, 10 Feb 2022 21:03:45 +0000 (21:03 +0000)]
[FileCheck] Fix initialized but never used static analyzer warning. NFC.

Remove superfluous variable initialization, the variable is assigned by both paths immediately afterward.

2 years ago[PDLL] Add support for user defined constraint and rewrite functions
River Riddle [Sun, 2 Jan 2022 03:41:08 +0000 (03:41 +0000)]
[PDLL] Add support for user defined constraint and rewrite functions

These functions allow for defining pattern fragments usable within the `match` and `rewrite` sections of a pattern. The main structure of Constraints and Rewrites functions are the same, and are similar to functions in other languages; they contain a signature (i.e. name, argument list, result list) and a body:

```pdll
// Constraint that takes a value as an input, and produces a value:
Constraint Cst(arg: Value) -> Value { ... }

// Constraint that returns multiple values:
Constraint Cst() -> (result1: Value, result2: ValueRange);
```

When returning multiple results, each result can be optionally be named (the result of a Constraint/Rewrite in the case of multiple results is a tuple).

These body of a Constraint/Rewrite functions can be specified in several ways:

* Externally
In this case we are importing an external function (registered by the user outside of PDLL):

```pdll
Constraint Foo(op: Op);
Rewrite Bar();
```

* In PDLL (using PDLL constructs)
In this case, the body is defined using PDLL constructs:

```pdll
Rewrite BuildFooOp() {
  // The result type of the Rewrite is inferred from the return.
  return op<my_dialect.foo>;
}
// Constraints/Rewrites can also implement a lambda/expression
// body for simple one line bodies.
Rewrite BuildFooOp() => op<my_dialect.foo>;
```

* In PDLL (using a native/C++ code block)
In this case the body is specified using a C++(or potentially other language at some point) code block. When building PDLL in AOT mode this will generate a native constraint/rewrite and register it with the PDL bytecode.

```pdll
Rewrite BuildFooOp() -> Op<my_dialect.foo> [{
  return rewriter.create<my_dialect::FooOp>(...);
}];
```

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

2 years ago[PDLL] Add support for single line lambda-like patterns
River Riddle [Sun, 2 Jan 2022 03:40:45 +0000 (03:40 +0000)]
[PDLL] Add support for single line lambda-like patterns

This allows for defining simple patterns in a single line. The lambda
body of a Pattern expects a single operation rewrite statement:

```
Pattern => replace op<my_dialect.foo>(operands: ValueRange) with operands;
```

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

2 years ago[libcxx] Silence -Wformat-nonliteral warnings in the Windows support code
Martin Storsjö [Mon, 7 Feb 2022 14:24:16 +0000 (16:24 +0200)]
[libcxx] Silence -Wformat-nonliteral warnings in the Windows support code

This brings the mingw build back to zero build warnings as it was
at some earlier time.

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

2 years ago[llvm-libtool-darwin] Use cast<> instead of dyn_cast<> to avoid dereference of nullptr
Simon Pilgrim [Thu, 10 Feb 2022 20:44:19 +0000 (20:44 +0000)]
[llvm-libtool-darwin] Use cast<> instead of dyn_cast<> to avoid dereference of nullptr

The pointer is dereferenced immediately, so assert the cast is correct instead of returning nullptr

2 years ago[LoopVectorize] getStepVector - reduce scope of local variable. NFC.
Simon Pilgrim [Thu, 10 Feb 2022 20:42:14 +0000 (20:42 +0000)]
[LoopVectorize] getStepVector - reduce scope of local variable. NFC.

2 years ago[libc++] Prepare string.modifiers tests for constexpr
Nikolas Klauser [Thu, 10 Feb 2022 15:51:04 +0000 (16:51 +0100)]
[libc++] Prepare string.modifiers tests for constexpr

Reviewed By: ldionne, #libc

Spies: libcxx-commits

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

2 years ago[SCEV] Constify some uses of SCEVUnionPredicate* [NFC]
Philip Reames [Thu, 10 Feb 2022 20:25:45 +0000 (12:25 -0800)]
[SCEV] Constify some uses of SCEVUnionPredicate* [NFC]

This exploits the immutability introduced in d334fec.

2 years ago[NFC] Simplify pairwise store test mir to drop stack accesses.
Huihui Zhang [Thu, 10 Feb 2022 20:00:23 +0000 (12:00 -0800)]
[NFC] Simplify pairwise store test mir to drop stack accesses.

Test simplified:
 test/CodeGen/AArch64/stp-opt-with-renaming-undef-assert.mir

2 years agoModified SourceLevelDebugging.rst to include information about memory location exp
YASHASVI KHATAVKAR [Mon, 7 Feb 2022 15:02:22 +0000 (10:02 -0500)]
Modified SourceLevelDebugging.rst to include information about memory location exp

2 years agoupdated local branch to incorporate latest changes
YASHASVI KHATAVKAR [Wed, 2 Feb 2022 20:31:49 +0000 (15:31 -0500)]
updated local branch to incorporate latest changes

2 years agoworked on review comments
YASHASVI KHATAVKAR [Tue, 1 Feb 2022 20:44:00 +0000 (15:44 -0500)]
worked on review comments

2 years agoUpdated the test to include proper string get functions
YASHASVI KHATAVKAR [Tue, 1 Feb 2022 14:59:10 +0000 (09:59 -0500)]
Updated the test to include proper string get functions

2 years agoUpdated the test to include addtional details
YASHASVI KHATAVKAR [Mon, 31 Jan 2022 16:42:35 +0000 (11:42 -0500)]
Updated the test to include addtional details

2 years agoAdded StringLocationExp to the new apis
YASHASVI KHATAVKAR [Thu, 27 Jan 2022 19:19:10 +0000 (14:19 -0500)]
Added  StringLocationExp to the new apis

2 years agoAddressed review comments
YASHASVI KHATAVKAR [Thu, 27 Jan 2022 14:50:52 +0000 (09:50 -0500)]
Addressed review comments

2 years agoAdding DIBuilder interface for assumed length string
YASHASVI KHATAVKAR [Wed, 26 Jan 2022 19:49:37 +0000 (14:49 -0500)]
Adding DIBuilder interface for assumed length string

2 years agoCleanup LLVMObject headers
serge-sans-paille [Thu, 10 Feb 2022 17:39:06 +0000 (18:39 +0100)]
Cleanup LLVMObject headers

Most notably,

llvm/Object/Binary.h no longer includes llvm/Support/MemoryBuffer.h
llvm/Object/MachOUniversal*.h no longer include llvm/Object/Archive.h
llvm/Object/TapiUniversal.h no longer includes llvm/Object/TapiFile.h

llvm-project preprocessed size:
before: 1068185081
after:  1068324320

Discourse thread: https://discourse.llvm.org/t/include-what-you-use-include-cleanup
Differential Revision: https://reviews.llvm.org/D119457

2 years agoUpdate all LLVM documentation mentioning runtimes in LLVM_ENABLE_PROJECTS
Louis Dionne [Wed, 9 Feb 2022 17:08:44 +0000 (12:08 -0500)]
Update all LLVM documentation mentioning runtimes in LLVM_ENABLE_PROJECTS

We are moving away from building the runtimes with LLVM_ENABLE_PROJECTS,
however the documentation was largely outdated. This commit updates all
the documentation I could find to use LLVM_ENABLE_RUNTIMES instead of
LLVM_ENABLE_PROJECTS for building runtimes.

Note that in the near future, libcxx, libcxxabi and libunwind will stop
supporting being built with LLVM_ENABLE_PROJECTS altogether. I don't know
what the plans are for other runtimes like libc, openmp and compiler-rt,
so I didn't make any changes to the documentation that would imply
something for those projects.

Once this lands, I will also cherry-pick this on the release/14.x branch
to make sure that LLVM's documentation is up-to-date and reflects what
we intend to support in the future.

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

2 years agoSign-extend addresses in CompactRingBuffer.
Evgenii Stepanov [Thu, 10 Feb 2022 19:31:43 +0000 (11:31 -0800)]
Sign-extend addresses in CompactRingBuffer.

Summary:
This is neccessary to support solaris/sparc9 where some userspace
addresses have all top bits set, as well as, potentially, kernel memory
on aarch64.

This change does not update the compiler side (HWASan IR pass) which
needs to be done separately for the affected targets.

Reviewers: ro, vitalybuka

Subscribers: llvm-commits

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

2 years ago[Attributor][NFC] Expose new API in AAPointerInfo
Johannes Doerfert [Tue, 8 Feb 2022 15:42:15 +0000 (09:42 -0600)]
[Attributor][NFC] Expose new API in AAPointerInfo

New users might want to check bins without a load or store instruction
at hand. Since we use those instructions only to find the offset and
size of the access anyway, we can expose an offset and size interface
to the outside world as well.

This commit mainly moves code around and exposes a class (OffsetAndSize)
as well as a method forallInterferingAccesses in AAPointerInfo.

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

2 years ago[Attributor][FIX] Reachability needs to account for readonly callees
Johannes Doerfert [Tue, 8 Feb 2022 05:37:02 +0000 (23:37 -0600)]
[Attributor][FIX] Reachability needs to account for readonly callees

The oversight caused us to ignore call sites that are effectively dead
when we computed reachability (or more precise the call edges of a
function). The problem is that loads in the readonly callee might depend
on stores prior to the callee. If we do not track the call edge we
mistakenly assumed the store before the call cannot reach the load.
The problem is nicely visible in:
  `llvm/test/Transforms/Attributor/ArgumentPromotion/basictest.ll`

Caused by D118673.

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

2 years ago[Attributor][FIX] Honor alloca address space in AAPrivatizablePtr
Johannes Doerfert [Tue, 8 Feb 2022 04:40:13 +0000 (22:40 -0600)]
[Attributor][FIX] Honor alloca address space in AAPrivatizablePtr

When we privatize a pointer (~argument promotion) we introduce new
private allocas as replacement. These need to be placed in the alloca
address space as later passes cannot properly deal with them otherwise.

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

2 years ago[sanitizer] Try to enable test on Android
Vitaly Buka [Thu, 10 Feb 2022 19:51:29 +0000 (11:51 -0800)]
[sanitizer] Try to enable test on Android

#53721 suggests that it should work after https://reviews.llvm.org/D119461

2 years ago[MLIR][GPU][lld] Use LLD bundled in ROCm, removing workaround
Krzysztof Drewniak [Thu, 10 Feb 2022 18:32:42 +0000 (18:32 +0000)]
[MLIR][GPU][lld] Use LLD bundled in ROCm, removing workaround

Having clarified that executing the SerializeToHsaco pass can
depend on a ROCm installation, switch from calling lld as a library to
using the copy of lld guaranteed to be included in a ROCm install.

This removes the workaround introduced in D119277

Reviewed By: whchung

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

2 years ago[flang] Refine pointer/target test for ASSOCIATED intrinsic
Peter Klausler [Mon, 7 Feb 2022 16:45:11 +0000 (08:45 -0800)]
[flang] Refine pointer/target test for ASSOCIATED intrinsic

The second argument to the ASSOCIATED intrinsic must be a valid pointer
or target. The test for this property only checked the last symbol
in a data-reference, but any symbol in the reference with the
POINTER or TARGET attribute will do.

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

2 years ago[clang-tidy] Add early exit for defaulted FunctionDecls
Kirill Bobyrev [Thu, 10 Feb 2022 19:09:46 +0000 (20:09 +0100)]
[clang-tidy] Add early exit for defaulted FunctionDecls

This prevents matching of defaulted comparison operators.

Resolves: https://github.com/llvm/llvm-project/issues/53355

Author: Febbe (Fabian Keßler)

2 years ago[libc++][P2321R2] Add vector<bool>::reference::operator=(bool) const
Nikolas Klauser [Wed, 2 Feb 2022 21:48:42 +0000 (22:48 +0100)]
[libc++][P2321R2] Add vector<bool>::reference::operator=(bool) const

Add vector<bool>::reference::operator(bool) const

Reviewed By: Quuxplusone, ldionne, #libc

Spies: BRevzin, libcxx-commits

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

2 years ago[libc][obvious] only include vector with malloc
Michael Jones [Thu, 10 Feb 2022 19:10:20 +0000 (11:10 -0800)]
[libc][obvious] only include vector with malloc

the vector class, due to being dynamically resized, needs malloc. This
fixes the build so that it only includes it when malloc should be
available.

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

2 years ago[compiler-rt] Fix endianness in get_sock_peer_name test
Michał Górny [Thu, 10 Feb 2022 18:40:28 +0000 (19:40 +0100)]
[compiler-rt] Fix endianness in get_sock_peer_name test

Fix passing the port and IP address with the wrong endianness
in get_sock_peer_name() that causes the connect() to fail inside
without an outgoing network interface (it's trying to connect
to 1.0.0.127 instead of 127.0.0.1).

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

2 years ago[OpenMP][CUDA] Refine the logic to determine grid size
Shilei Tian [Thu, 10 Feb 2022 19:13:18 +0000 (14:13 -0500)]
[OpenMP][CUDA] Refine the logic to determine grid size

This patch refines the logic to determine grid size as previous method
can escape the check of whether `CudaBlocksPerGrid` could be greater than the actual
hardware limit.

Reviewed By: jdoerfert

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

2 years agoAdd -fmodules-local-submodule-visibility to MANDATORY_MODULE_BUILD_CFLAGS
Adrian Prantl [Thu, 10 Feb 2022 19:09:40 +0000 (11:09 -0800)]
Add -fmodules-local-submodule-visibility to MANDATORY_MODULE_BUILD_CFLAGS

to work around build failure introduced in https://reviews.llvm.org/D119036

2 years ago[libc] add a vector internal class
Michael Jones [Fri, 4 Feb 2022 00:00:10 +0000 (16:00 -0800)]
[libc] add a vector internal class

Add a basic implementation of the vector class for use internally to
LLVM-libc.

Reviewed By: sivachandra

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

2 years ago[TTI][X86] Pull out repeated getSizeInBits() calls. NFC.
Simon Pilgrim [Thu, 10 Feb 2022 18:58:22 +0000 (18:58 +0000)]
[TTI][X86] Pull out repeated getSizeInBits() calls. NFC.

2 years agoFix a double debug info size counting in top level stats for "statistics dump".
Greg Clayton [Thu, 10 Feb 2022 02:48:17 +0000 (18:48 -0800)]
Fix a double debug info size counting in top level stats for "statistics dump".

This mainly affects Darwin targets (macOS, iOS, tvOS and watchOS) when these targets don't use dSYM files and the debug info was in the .o files. All modules, including the .o files that are loaded by the debug maps, were in the global module list. This was great because it allows us to see each .o file and how much it contributes. There were virtual functions on the SymbolFile class to fetch the symtab/debug info parse and index times, and also the total debug info size. So the main executable would add all of the .o file's stats together and report them as its own data. Then the "totalDebugInfoSize" and many other "totalXXX" top level totals were all being added together. This stems from the fact that my original patch only emitted the modules for a target at the start of the patch, but as comments from the reviews came in, we switched to emitting all of the modules from the global module list.

So this patch fixes it so when we have a SymbolFileDWARFDebugMap that loads .o files, the main executable will have no debug info size or symtab/debug info parse/index times, but each .o file will have its own data as a separate module. Also, to be able to tell when/if we have a dSYM file I have added a "symbolFilePath" if the SymbolFile for the main modules path doesn't match that of the main executable. We also include a "symbolFileModuleIdentifiers" key in each module if the module does have multiple lldb_private::Module objects that contain debug info so that you can track down the information for a module and add up the contributions of all of the .o files.

Tests were added that are labeled with @skipUnlessDarwin and @no_debug_info_test that test all of this functionality so it doesn't regress.

For a module with a dSYM file, we can see the "symbolFilePath" is included:
```
  "modules": [
    {
      "debugInfoByteSize": 1070,
      "debugInfoIndexLoadedFromCache": false,
      "debugInfoIndexSavedToCache": false,
      "debugInfoIndexTime": 0,
      "debugInfoParseTime": 0,
      "identifier": 4873280600,
      "path": "/Users/gclayton/Documents/src/lldb/main/Debug/lldb-test-build.noindex/commands/statistics/basic/TestStats.test_dsym_binary_has_symfile_in_stats/a.out",
      "symbolFilePath": "/Users/gclayton/Documents/src/lldb/main/Debug/lldb-test-build.noindex/commands/statistics/basic/TestStats.test_dsym_binary_has_symfile_in_stats/a.out.dSYM/Contents/Resources/DWARF/a.out",
      "symbolTableIndexTime": 7.9999999999999996e-06,
      "symbolTableLoadedFromCache": false,
      "symbolTableParseTime": 7.8999999999999996e-05,
      "symbolTableSavedToCache": false,
      "triple": "arm64-apple-macosx12.0.0",
      "uuid": "E1F7D85B-3A42-321E-BF0D-29B103F5F2E3"
    },
```
And for the DWARF in .o file case we can see the "symbolFileModuleIdentifiers" in the executable's module stats:
```
  "modules": [
    {
      "debugInfoByteSize": 0,
      "debugInfoIndexLoadedFromCache": false,
      "debugInfoIndexSavedToCache": false,
      "debugInfoIndexTime": 0,
      "debugInfoParseTime": 0,
      "identifier": 4603526968,
      "path": "/Users/gclayton/Documents/src/lldb/main/Debug/lldb-test-build.noindex/commands/statistics/basic/TestStats.test_no_dsym_binary_has_symfile_identifiers_in_stats/a.out",
      "symbolFileModuleIdentifiers": [
        4604429832
      ],
      "symbolTableIndexTime": 7.9999999999999996e-06,
      "symbolTableLoadedFromCache": false,
      "symbolTableParseTime": 0.000112,
      "symbolTableSavedToCache": false,
      "triple": "arm64-apple-macosx12.0.0",
      "uuid": "57008BF5-A726-3DE9-B1BF-3A9AD3EE8569"
    },
```
And the .o file for 4604429832 looks like:
```
    {
      "debugInfoByteSize": 1028,
      "debugInfoIndexLoadedFromCache": false,
      "debugInfoIndexSavedToCache": false,
      "debugInfoIndexTime": 0,
      "debugInfoParseTime": 6.0999999999999999e-05,
      "identifier": 4604429832,
      "path": "/Users/gclayton/Documents/src/lldb/main/Debug/lldb-test-build.noindex/commands/statistics/basic/TestStats.test_no_dsym_binary_has_symfile_identifiers_in_stats/main.o",
      "symbolTableIndexTime": 0,
      "symbolTableLoadedFromCache": false,
      "symbolTableParseTime": 0,
      "symbolTableSavedToCache": false,
      "triple": "arm64-apple-macosx"
    }
```

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

2 years agoWild guess to fix LLDB bot
Renato Golin [Thu, 10 Feb 2022 18:51:29 +0000 (18:51 +0000)]
Wild guess to fix LLDB bot

2 years ago[gn build] Port bd3a1de683f8
LLVM GN Syncbot [Thu, 10 Feb 2022 18:38:23 +0000 (18:38 +0000)]
[gn build] Port bd3a1de683f8

2 years ago[MLIR][GPU] Add now-required include to SerializeToHsaco
Krzysztof Drewniak [Thu, 10 Feb 2022 17:46:02 +0000 (17:46 +0000)]
[MLIR][GPU] Add now-required include to SerializeToHsaco

Reviewed By: whchung

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

2 years ago[flang] Handle "type(foo) function f" when foo is defined in f
Peter Klausler [Sat, 5 Feb 2022 02:04:58 +0000 (18:04 -0800)]
[flang] Handle "type(foo) function f" when foo is defined in f

Fortran allows forward references to derived types, including
function results that are typed in a prefix of a FUNCTION statement.
If a type is defined in the body of the function, a reference to
that type from a prefix on the FUNCTION statement must resolve to
the local symbol, even and especially when that type shadows one
from the host scope.

The solution is to defer the processing of that type until the
end of the function's specification part.  But the language doesn't
allow for forward references to other names in the prefix, so defer
the processing of the type only when it is not an intrinsic type.
The data structures in name resolution that track this information
for functions needed to become a stack in order to make this work,
since functions can contain interfaces that are functions.

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

2 years ago[clang-cl] Support the /JMC flag
Yuanfang Chen [Thu, 10 Feb 2022 17:40:05 +0000 (09:40 -0800)]
[clang-cl] Support the /JMC flag

The introduction and some examples are on this page:
https://devblogs.microsoft.com/cppblog/announcing-jmc-stepping-in-visual-studio/

The `/JMC` flag enables these instrumentations:
- Insert at the beginning of every function immediately after the prologue with
  a call to `void __fastcall __CheckForDebuggerJustMyCode(unsigned char *JMC_flag)`.
  The argument for `__CheckForDebuggerJustMyCode` is the address of a boolean
  global variable (the global variable is initialized to 1) with the name
  convention `__<hash>_<filename>`. All such global variables are placed in
  the `.msvcjmc` section.
- The `<hash>` part of `__<hash>_<filename>` has a one-to-one mapping
  with a directory path. MSVC uses some unknown hashing function. Here I
  used DJB.
- Add a dummy/empty COMDAT function `__JustMyCode_Default`.
- Add `/alternatename:__CheckForDebuggerJustMyCode=__JustMyCode_Default` link
  option via ".drectve" section. This is to prevent failure in
  case `__CheckForDebuggerJustMyCode` is not provided during linking.

Implementation:
All the instrumentations are implemented in an IR codegen pass. The pass is placed immediately before CodeGenPrepare pass. This is to not interfere with mid-end optimizations and make the instrumentation target-independent (I'm still working on an ELF port in a separate patch).

Reviewed By: hans

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

2 years ago[AArch64][ARM] add -Wunaligned-access only for clang
Yuanfang Chen [Thu, 10 Feb 2022 17:33:49 +0000 (09:33 -0800)]
[AArch64][ARM] add -Wunaligned-access only for clang

Reviewed By: lenary

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

2 years ago [AArch64][LoadStoreOptimizer] Ignore undef registers when checking rename register...
Huihui Zhang [Thu, 10 Feb 2022 18:05:39 +0000 (10:05 -0800)]
 [AArch64][LoadStoreOptimizer] Ignore undef registers when checking rename register used between paired instructions.

The content of undef registers are not used in meaningful ways, when checking
if a rename register is used between paired instructions we should ignore
undef registers.

Reviewed By: efriedma

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

2 years ago[clang-format] Do not remove required spaces when aligning tokens.
Marek Kurdej [Thu, 10 Feb 2022 18:11:26 +0000 (19:11 +0100)]
[clang-format] Do not remove required spaces when aligning tokens.

Fixes https://github.com/llvm/llvm-project/issues/44292.
Fixes https://github.com/llvm/llvm-project/issues/45874.

Reviewed By: HazardyKnusperkeks, owenpan

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

2 years ago[mlir][vector] Add pattern to drop lead unit dim for Contraction Op
Nirvedh [Fri, 28 Jan 2022 05:25:27 +0000 (05:25 +0000)]
[mlir][vector] Add pattern to drop lead unit dim for Contraction Op

If the result operand has a unit leading dim it is removed from all operands.

Reviewed By: ThomasRaoux

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

2 years ago[X86] Add smulo and umulo with add+load test coverage
Simon Pilgrim [Thu, 10 Feb 2022 17:47:14 +0000 (17:47 +0000)]
[X86] Add smulo and umulo with add+load test coverage

2 years ago[clangd] Crash in __memcmp_avx2_movbe
Ivan Murashko [Thu, 10 Feb 2022 17:40:24 +0000 (09:40 -0800)]
[clangd] Crash in __memcmp_avx2_movbe

There is a clangd crash at `__memcmp_avx2_movbe`. Short problem description is below.

The method `HeaderIncludes::addExistingInclude` stores `Include` objects by reference at 2 places: `ExistingIncludes` (primary storage) and `IncludesByPriority` (pointer to the object's location at ExistingIncludes). `ExistingIncludes` is a map where value is a `SmallVector`. A new element is inserted by `push_back`. The operation might do resize. As result pointers stored at `IncludesByPriority` might become invalid.

Typical stack trace
```
    frame #0: 0x00007f11460dcd94 libc.so.6`__memcmp_avx2_movbe + 308
    frame #1: 0x00000000004782b8 clangd`llvm::StringRef::compareMemory(Lhs="
\"t2.h\"", Rhs="", Length=6) at StringRef.h:76:22
    frame #2: 0x0000000000701253 clangd`llvm::StringRef::compare(this=0x0000
7f10de7d8610, RHS=(Data = "", Length = 7166742329480737377)) const at String
Ref.h:206:34
  * frame #3: 0x00000000007603ab clangd`llvm::operator<(llvm::StringRef, llv
m::StringRef)(LHS=(Data = "\"t2.h\"", Length = 6), RHS=(Data = "", Length =
7166742329480737377)) at StringRef.h:907:23
    frame #4: 0x0000000002d0ad9f clangd`clang::tooling::HeaderIncludes::inse
rt(this=0x00007f10de7fb1a0, IncludeName=(Data = "t2.h\"", Length = 4), IsAng
led=false) const at HeaderIncludes.cpp:365:22
    frame #5: 0x00000000012ebfdd clangd`clang::clangd::IncludeInserter::inse
rt(this=0x00007f10de7fb148, VerbatimHeader=(Data = "\"t2.h\"", Length = 6))
const at Headers.cpp:262:70
```

A unit test test for the crash was created (`HeaderIncludesTest.RepeatedIncludes`). The proposed solution is to use std::list instead of llvm::SmallVector

Test Plan
```
./tools/clang/unittests/Tooling/ToolingTests --gtest_filter=HeaderIncludesTest.RepeatedIncludes
```

Reviewed By: sammccall

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

2 years ago[RISCV] Lower the shufflevector equivalent of vector.splice
Craig Topper [Thu, 10 Feb 2022 17:29:39 +0000 (09:29 -0800)]
[RISCV] Lower the shufflevector equivalent of vector.splice

We can lower a vector splice to a vslidedown and a vslideup.

The majority of the matching code here came from X86's code for matching
PALIGNR and VPALIGND/Q.

The slidedown and slideup lowering don't really require it to be concatenation,
but it happened to be an interesting pattern with existing analysis code I
could use.

This helps with cases where the scalar loop optimizer forwarded a load
result from a previous loop iteration. For example, this happens if the
loop uses x[i] and x[i+1] on the same iteration. The scalar optimizer
will forward x[i+1] load from the previous loop to satisfy x[i] on this
loop. When this get vectorized it results in one element of a vector
being forwarded from the previous loop to be concatenated with elements
loaded on this iteration.

Whether that's more efficient than doing a shifted loaded or reloading
the single scalar and using vslide1up is an interesting question.
But that's not something the backend can help with.

Reviewed By: khchen

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