platform/upstream/llvm.git
2 years ago[lldb/Plugins] Replace platform-specific macro with LLVM_PRETTY_FUNCTION (NFC)
Med Ismail Bennani [Fri, 8 Oct 2021 18:48:02 +0000 (18:48 +0000)]
[lldb/Plugins] Replace platform-specific macro with LLVM_PRETTY_FUNCTION (NFC)

This patch refactors Scripted Process and Scripted Thread related
classes to use LLVM_PRETTY_FUNCTION instead of the compiler macro.

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2 years ago[clang] Set max allowed alignment to 2^32
Arthur Eubanks [Wed, 6 Oct 2021 18:20:44 +0000 (11:20 -0700)]
[clang] Set max allowed alignment to 2^32

Followup to D110451 which set LLVM's max allowed alignment to 2^32.

Reviewed By: hans

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

2 years agoAdd missing include after dfd74db9
Arthur Eubanks [Fri, 8 Oct 2021 18:41:53 +0000 (11:41 -0700)]
Add missing include after dfd74db9

2 years ago[NFC] Make some includes explicit
Nikita Popov [Thu, 7 Oct 2021 21:26:45 +0000 (23:26 +0200)]
[NFC] Make some includes explicit

Avoid relying on a number of indirect includes that currently
happen through the Hashing.h header in DenseMapInfo.h.

2 years ago[ORC] Move SimpleRemoteEPCServer::Dispatcher into OrcShared.
Lang Hames [Fri, 8 Oct 2021 05:04:48 +0000 (22:04 -0700)]
[ORC] Move SimpleRemoteEPCServer::Dispatcher into OrcShared.

Renames SimpleRemoteEPCServer::Dispatcher to SimpleRemoteEPCDispatcher and
moves it into OrcShared. SimpleRemoteEPCServer::ThreadDispatcher is similarly
moved and renamed to DynamicThreadPoolSimpleRemoteEPCDispatcher.

This will allow these classes to be reused by SimpleRemoteEPC on the controller
side of the connection.

2 years ago[clang] Option control afn flag
Masoud Ataei [Fri, 8 Oct 2021 18:26:14 +0000 (14:26 -0400)]
[clang] Option control afn flag

Clang option to set/unset afn fast-math flag.

 Differential: https://reviews.llvm.org/D106191
 Reviewd with: aaron.ballman, erichkeane, and others

2 years ago[GlobalISel] Improve G_UMHULH -> LSHR combine to accept non-uniform constant vectors.
Amara Emerson [Fri, 8 Oct 2021 18:05:09 +0000 (11:05 -0700)]
[GlobalISel] Improve G_UMHULH -> LSHR combine to accept non-uniform constant vectors.

2 years ago[libc++][doc] Update paper status.
Mark de Wever [Tue, 5 Oct 2021 16:18:16 +0000 (18:18 +0200)]
[libc++][doc] Update paper status.

Update the status with the approved papers and LWG-issues in the October 2021 plenary.

Reviewed By: #libc, ldionne

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

2 years ago[DFSan] Remove -dfsan-args-abi support in favor of TLS.
Andrew Browne [Mon, 4 Oct 2021 20:31:18 +0000 (13:31 -0700)]
[DFSan] Remove -dfsan-args-abi support in favor of TLS.

ArgsABI was originally added in https://reviews.llvm.org/D965

Current benchmarking does not show a significant difference.
There is no need to maintain both ABIs.

Reviewed By: pcc

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

2 years ago[RegisterScavenging] Use a Twine in a call to report_fatal_error instead of going...
Craig Topper [Fri, 8 Oct 2021 17:56:23 +0000 (10:56 -0700)]
[RegisterScavenging] Use a Twine in a call to report_fatal_error instead of going from std::string to c_str. NFC

The std::string was built on the line above. Might as well just
build it as a Twine in the call.

2 years agoRevert "[IR] Remove arg_operands and getNumArgOperands (NFC)"
Kazu Hirata [Fri, 8 Oct 2021 18:01:56 +0000 (11:01 -0700)]
Revert "[IR] Remove arg_operands and getNumArgOperands (NFC)"

This reverts commit b2ee408dde374d6a27a34746fd7c7b5bab97ea89.

2 years ago[IPT] Add a statistic to track instructions scanned to answer queries
Philip Reames [Fri, 8 Oct 2021 17:49:54 +0000 (10:49 -0700)]
[IPT] Add a statistic to track instructions scanned to answer queries

I'm planning some changes to the invalidation mechanism here, and having a concrete mechanism to track progress is key.

2 years agoAdd a statistic to track number of times we rebuild instruction ordering
Philip Reames [Fri, 8 Oct 2021 17:45:01 +0000 (10:45 -0700)]
Add a statistic to track number of times we rebuild instruction ordering

The goal here is to assist some future tuning work both on instruction ordering invalidation, and on some client code which uses it.

2 years agoRevert "Recommit "[LoopPeel] Peel loops with deoptimizing exits""
Arthur Eubanks [Fri, 8 Oct 2021 17:50:06 +0000 (10:50 -0700)]
Revert "Recommit "[LoopPeel] Peel loops with deoptimizing exits""

This reverts commit d68b59f3ebb253ee7119a25a71c51cf19b73e030.

This is causing crashes, see D110922 for details.

2 years ago[test] Use host platform specific error message substitution
Abhina Sreeskantharajan [Fri, 8 Oct 2021 17:52:13 +0000 (13:52 -0400)]
[test] Use host platform specific error message substitution

This patch modifies the testcase to use error substitution so it will pass on all platforms.

Reviewed By: fanbo-meng, muiez

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

2 years agoUpdate polly for removal of CallInst::arg_operands/getNumArgOperands
Reid Kleckner [Fri, 8 Oct 2021 17:45:30 +0000 (10:45 -0700)]
Update polly for removal of CallInst::arg_operands/getNumArgOperands

Fixes polly build

2 years ago[AST Matchers] Update dump_ast_matchers.py to query only class index page.
James King [Fri, 8 Oct 2021 17:44:55 +0000 (17:44 +0000)]
[AST Matchers] Update dump_ast_matchers.py to query only class index page.

It may be possible to avoid relying on accessing many individual class pages,
by instead scanning the class index page at
https://clang.llvm.org/doxygen/classes.html. This updates the script to do so,
and includes updates to `LibASTMatchersReference.html` generated by the
modified script.

Reviewed By: aaron.ballman, sammccall

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

2 years agoAdd `TypeLoc`-related matchers.
James King [Fri, 8 Oct 2021 17:42:06 +0000 (17:42 +0000)]
Add `TypeLoc`-related matchers.

Contributes several matchers that involve `TypeLoc`s. These matchers are (in alphabetical order):

- elaboratedTypeLoc
- hasAnyTemplateArgumentLoc
- hasNamedTypeLoc
- hasPointeeLoc
- hasReferentLoc
- hasReturnTypeLoc
- hasTemplateArgumentLoc
- hasUnqualifiedLoc
- pointerTypeLoc
- qualifiedTypeLoc
- referenceTypeLoc
- templateSpecializationTypeLoc

Reviewed By: ymandel, aaron.ballman

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

2 years agoRevert "[clang] Fix absolute file paths with -fdebug-prefix-map"
Keith Smiley [Fri, 8 Oct 2021 17:38:13 +0000 (10:38 -0700)]
Revert "[clang] Fix absolute file paths with -fdebug-prefix-map"

This reverts commit a23a5967932292b82e9a7e4b37817d1b3f5be5ec.

This broke a windows test https://buildkite.com/llvm-project/premerge-checks/builds/59492#7dad207c-6cbe-40ad-95e4-c48b47fe2527

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

2 years ago[libcxx] Fix a missed case needing "system header" markings for init_priority(100)
Martin Storsjö [Thu, 7 Oct 2021 07:00:46 +0000 (10:00 +0300)]
[libcxx] Fix a missed case needing "system header" markings for init_priority(100)

This was missed in D95972 / 7c49052b170f76f19be64a5572d31ad8f5df4e61,
as this codepath isn't exercised by CI yet.

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

2 years ago[clang] Fix absolute file paths with -fdebug-prefix-map
Keith Smiley [Thu, 7 Oct 2021 20:25:21 +0000 (13:25 -0700)]
[clang] Fix absolute file paths with -fdebug-prefix-map

Previously if you passed an absolute path to clang, where only part of
the path to the file was remapped, it would result in the file's DIFile
being stored with a duplicate path, for example:

```
!DIFile(filename: "./ios/Sources/bar.c", directory: "./ios/Sources")
```

This change handles absolute paths, specifically in the case they are
remapped to something relative, and uses the dirname for the directory,
and basename for the filename.

This also adds a test verifying this behavior for more standard uses as
well.

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

2 years ago[IPT] Narrow scope of removeInstruction invalidation [NFC]
Philip Reames [Fri, 8 Oct 2021 17:32:36 +0000 (10:32 -0700)]
[IPT] Narrow scope of removeInstruction invalidation [NFC]

We only need to invalidate if the instruction being removed is the cached "first special instruction".  If the instruction is before that one, it can't (by assumption) be special.  If it is after that one, it wasn't the first.

2 years ago[sanitizer] Use one #if instead of 3 nested #if after D111185
Fangrui Song [Fri, 8 Oct 2021 17:31:57 +0000 (10:31 -0700)]
[sanitizer] Use one #if instead of 3 nested #if after D111185

2 years ago[clang-format-diff] Fix missing formatting for zero length git diff lines
Zequan Wu [Wed, 6 Oct 2021 21:18:12 +0000 (14:18 -0700)]
[clang-format-diff] Fix missing formatting for zero length git diff lines

If we only delete lines that are outer block statements (if, while, etc),
clang-format-diff.py can't format the statements inside the block statements.

An example to repro:
1. Delete the if statment at line 118 in llvm/lib/CodeGen/Analysis.cpp.
2. Run `git diff -U0 --no-color HEAD^ | clang/tools/clang-format/clang-format-diff.py -i -p1`

It fails to format the statement after if.

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

2 years agoReland [sanitizer] Support Intel CET
H.J. Lu [Fri, 10 Sep 2021 13:24:36 +0000 (06:24 -0700)]
Reland [sanitizer] Support Intel CET

1. Include <cet.h> in sanitizer_common/sanitizer_asm.h, if it exists, to
mark Intel CET support when Intel CET is enabled.
2. Define _CET_ENDBR as empty if it isn't defined.
3. Add _CET_ENDBR to function entries in assembly codes so that ENDBR
instruction will be generated when Intel CET is enabled.

Reviewed By: MaskRay

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

2 years ago[Support] Define sys::getHostCPUName for RISC-V
Andreas Schwab [Fri, 8 Oct 2021 17:08:39 +0000 (10:08 -0700)]
[Support] Define sys::getHostCPUName for RISC-V

The RISCV target doesn't define a "generic" cpu, only "generic-rv32" and
"generic-rv64".  Define sys::getHostCPUName for RISC-V that returns the
correct cpu for the host.

Reviewed By: craig.topper, MaskRay

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

2 years agoAdd iterator range variants of isGuaranteedToTransferExecutionToSuccessor [mostly...
Philip Reames [Fri, 8 Oct 2021 15:58:03 +0000 (08:58 -0700)]
Add iterator range variants of isGuaranteedToTransferExecutionToSuccessor [mostly-nfc]

This factors out utilities for scanning a bounded block of instructions since we have this code repeated in a bunch of places.  The change to InlineFunction isn't strictly NFC as the limit mechanism there didn't handle debug instructions correctly.

2 years ago[Dexter] Add option to pass a Visual Studio solution instead of a binary
Stephen Tozer [Fri, 8 Oct 2021 16:39:51 +0000 (17:39 +0100)]
[Dexter] Add option to pass a Visual Studio solution instead of a binary

This patch allows a visual studio solution file to be passed directly
into Dexter, instead of using a pre-built binary and a small internal
solution file with template arguments. This is primarily to allow
launching an application that has specific launch configuration
requirements, without needing all the details of this configuration to
be built directly into Dexter or adding a config file that simply
duplicates existing settings in the VS solution.

Reviewed By: Orlando

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

2 years ago[lldb] Fix windows build failure due to undefined macro
Med Ismail Bennani [Fri, 8 Oct 2021 16:24:41 +0000 (18:24 +0200)]
[lldb] Fix windows build failure due to undefined macro

This should fix a build failure on Windows caused by the macro
__PRETTY_FUNCTION__ not being defined.

https://lab.llvm.org/buildbot/#/builders/83/builds/10836

https://reviews.llvm.org/D107585

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2 years ago[AIX] Disable tests failing due to missing DWARF sections
Jake Egan [Fri, 8 Oct 2021 16:06:25 +0000 (12:06 -0400)]
[AIX] Disable tests failing due to missing DWARF sections

The following tests are failing due to missing DWARF sections. This patch sets these tests as XFAIL/DISABLED on AIX until a more permanent solution is implemented.

Reviewed By: shchenz

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

2 years ago[AIX] Disable tests failing due to lack of .loc and .file directive support
Jake Egan [Fri, 8 Oct 2021 15:54:33 +0000 (11:54 -0400)]
[AIX] Disable tests failing due to lack of .loc and .file directive support

The following tests explicitly check for .loc and .file directives, which is not currently supported. Disable these tests on AIX for now.

Reviewed By: shchenz

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

2 years agoFix parsing of hex-format index dense tensor attributes.
Stella Laurenzo [Fri, 8 Oct 2021 15:39:28 +0000 (15:39 +0000)]
Fix parsing of hex-format index dense tensor attributes.

TensorLiteralParser::getHexAttr does a isIntOrIndexOrFloat check and properly handles index elements, but TensorLiteralParser::getAttr that calls into it has a mismatched check. This just makes the checks match so that index element attrs can parse when of type tensor.

Reviewed By: rriddle

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

2 years ago[libc++] Improve atomic_fetch_(add|sub).*.
Mark de Wever [Wed, 9 Jun 2021 18:26:34 +0000 (20:26 +0200)]
[libc++] Improve atomic_fetch_(add|sub).*.

While looking at the review comments in D103765 there was an oddity in
the tests for the following functions:
- atomic_fetch_add
- atomic_fetch_add_explicit
- atomic_fetch_sub
- atomic_fetch_sub_explicit

Libc++ allows usage of
`atomic_fetch_add<int>(atomic<int*>*, atomic<int*>::difference_type);`
MSVC and GCC reject this code: https://godbolt.org/z/9d8WzohbE

This makes the atomic `fetch(add|sub).*` Standard conforming and removes the non-conforming extensions.

Fixes PR47908

Reviewed By: ldionne, #libc

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

2 years ago[IR] Remove arg_operands and getNumArgOperands (NFC)
Kazu Hirata [Fri, 8 Oct 2021 15:26:22 +0000 (08:26 -0700)]
[IR] Remove arg_operands and getNumArgOperands (NFC)

The last uses were removed on Oct 7, 2021 in commit
80e39366ee403ac420f2087883550398e5fbf968.

This is a relanding of c72722f45ef1aa6d78e1e6fee07ab6bd86980da8.

2 years ago[InstCombine] add shift of bool test with extra use; NFC
Sanjay Patel [Fri, 8 Oct 2021 15:19:01 +0000 (11:19 -0400)]
[InstCombine] add shift of bool test with extra use; NFC

2 years ago[InstCombine] add tests for (i32 X s>> 31) & Y; NFC
Sanjay Patel [Fri, 8 Oct 2021 13:34:15 +0000 (09:34 -0400)]
[InstCombine] add tests for (i32 X s>> 31) & Y; NFC

Also regenerate some check lines to more accurately show
current transforms via name changes.

2 years ago[OpenMP][NVPTX] Fix an error in configuring #teams and #threads
Shilei Tian [Fri, 8 Oct 2021 15:07:31 +0000 (11:07 -0400)]
[OpenMP][NVPTX] Fix an error in configuring #teams and #threads

It must be a copy mistake.

Reviewed By: ye-luo

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

2 years ago[libc++] Remove the ad-hoc "unified standalone" build
Louis Dionne [Thu, 7 Oct 2021 20:07:59 +0000 (16:07 -0400)]
[libc++] Remove the ad-hoc "unified standalone" build

It is not used anywhere anymore since we're using the new runtimes build
in <monorepo>/runtimes now, so we can remove all traces of this build.

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

2 years agoRevert "[SelectionDAG] Remove PromoteIntOp_EXTRACT_SUBVECTOR."
Bradley Smith [Fri, 8 Oct 2021 14:38:35 +0000 (14:38 +0000)]
Revert "[SelectionDAG] Remove PromoteIntOp_EXTRACT_SUBVECTOR."

This reverts commit 3e8d2008f74245e9e1ca60bc97e4e619b0d42c6c.

The code removed in this commit is actually required for extracting
fixed types from illegal scalable types, hence this commit causes
assertion failures in such extracts.

2 years ago[flang][driver] Fix erroneous `&`
Andrzej Warzynski [Fri, 8 Oct 2021 09:41:02 +0000 (09:41 +0000)]
[flang][driver] Fix erroneous `&`

As pointed out by Valentin Clement in PR [1], we should be using `&&`
instead of `&`.

[1] https://github.com/flang-compiler/f18-llvm-project/pull/1113#discussion_r724321121

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

2 years ago[libc] Add rep;movsb as an accelerator under x86
Guillaume Chatelet [Fri, 8 Oct 2021 14:31:55 +0000 (14:31 +0000)]
[libc] Add rep;movsb as an accelerator under x86

2 years ago[libc] ifdef guard element architecture implementations
Guillaume Chatelet [Fri, 8 Oct 2021 14:25:08 +0000 (14:25 +0000)]
[libc] ifdef guard element architecture implementations

2 years ago[NFC] Use CHECK-NEXT instead of CHECK-SAME in target-invalid-cpu-note.c
Freddy Ye [Fri, 8 Oct 2021 13:54:18 +0000 (21:54 +0800)]
[NFC] Use CHECK-NEXT instead of CHECK-SAME in target-invalid-cpu-note.c

Reviewed By: DavidSpickett

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

2 years ago[AIX][ZOS] Excluding merge-objc-interface.m from Tests
Qiongsi Wu [Fri, 8 Oct 2021 13:58:32 +0000 (13:58 +0000)]
[AIX][ZOS] Excluding merge-objc-interface.m from Tests

Objective C is not supported on AIX or ZOS. This patch excludes the newly added `clang/test/Modules/merge-objc-interface.m` (added by https://reviews.llvm.org/D110280) from AIX and ZOS testing.

Many existing tests are already disabled by https://reviews.llvm.org/D109060.

Reviewed By: jsji

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

2 years agoRevert "[libc] Add rep;movsb as an accelerator under x86"
Guillaume Chatelet [Fri, 8 Oct 2021 13:44:37 +0000 (13:44 +0000)]
Revert "[libc] Add rep;movsb as an accelerator under x86"

This reverts commit 1c7160300db124468ef4a26ec55ad3d6e6527a69.

2 years ago[libc] Add rep;movsb as an accelerator under x86
Guillaume Chatelet [Fri, 8 Oct 2021 13:34:02 +0000 (13:34 +0000)]
[libc] Add rep;movsb as an accelerator under x86

2 years ago[AMDGPU] Set number vgprs used in PS shaders based on input registers actually used
David Stuttard [Thu, 15 Apr 2021 20:00:22 +0000 (21:00 +0100)]
[AMDGPU] Set number vgprs used in PS shaders based on input registers actually used

For PS shaders we can use the input SPI_PS_INPUT_ENA and SPI_PS_INPUT_ADDR
registers

Calculate the number of VGPR registers used as input VGPRs based on these
registers rather than the arguments passed in (this conservatively always
allocates the maximum).

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

Change-Id: Idf7c060cbbd5f7e3300102c55ecee3c07f209de6

2 years ago[lldb/test] Disable TestScriptedProcess.py unless Darwin
Med Ismail Bennani [Fri, 8 Oct 2021 13:19:54 +0000 (15:19 +0200)]
[lldb/test] Disable TestScriptedProcess.py unless Darwin

This patch disables TestScriptedProcess.py on Linux and Windows while I
investigate the OS specific failure:

http://lab.llvm.org:8011/#/builders/68/builds/19793

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2 years ago[lldb/Plugins] Add memory region support in ScriptedProcess
Med Ismail Bennani [Fri, 8 Oct 2021 12:25:04 +0000 (12:25 +0000)]
[lldb/Plugins] Add memory region support in ScriptedProcess

This patch adds support for memory regions in Scripted Processes.
This is necessary to read the stack memory region in order to
reconstruct each stackframe of the program.

In order to do so, this patch makes some changes to the SBAPI, namely:
- Add a new constructor for `SBMemoryRegionInfo` that takes arguments
  such as the memory region name, address range, permissions ...
  This is used when reading memory at some address to compute the offset
  in the binary blob provided by the user.
- Add a `GetMemoryRegionContainingAddress` method to `SBMemoryRegionInfoList`
  to simplify the access to a specific memory region.

With these changes, lldb is now able to unwind the stack and reconstruct
each frame. On top of that, reloading the target module at offset 0 allows
lldb to symbolicate the `ScriptedProcess` using debug info, similarly to an
ordinary Process.

To test this, I wrote a simple program with multiple function calls, ran it in
lldb, stopped at a leaf function and read the registers values and copied
the stack memory into a binary file. These are then used in the python script.

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2 years ago[lldb/Plugins] Add support for ScriptedThread in ScriptedProcess
Med Ismail Bennani [Wed, 6 Oct 2021 00:09:20 +0000 (00:09 +0000)]
[lldb/Plugins] Add support for ScriptedThread in ScriptedProcess

This patch introduces the `ScriptedThread` class with its python
interface.

When used with `ScriptedProcess`, `ScriptedThreaad` can provide various
information such as the thread state, stop reason or even its register
context.

This can be used to reconstruct the program stack frames using lldb's unwinder.

rdar://74503836

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2 years ago[clangd] IncludeCleaner: Stop crashing when included file is not found
Kirill Bobyrev [Fri, 8 Oct 2021 12:50:27 +0000 (14:50 +0200)]
[clangd] IncludeCleaner: Stop crashing when included file is not found

2 years ago[lldb] [test] Use secondary pty end for testing Terminal
Michał Górny [Fri, 8 Oct 2021 11:49:02 +0000 (13:49 +0200)]
[lldb] [test] Use secondary pty end for testing Terminal

Open and use the secondary end of a pty for testing Terminal properties
in order to fix the tests on Darwin.  While at it, streamline getting
the fd and Terminal class.

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

2 years ago[GlobalISel] Combine for eliminating redundant operand negations
Mirko Brkusanin [Fri, 8 Oct 2021 12:21:10 +0000 (14:21 +0200)]
[GlobalISel] Combine for eliminating redundant operand negations

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

2 years ago[mlir][linalg][bufferize] Rewrite "write into non-writable memory" detection
Matthias Springer [Fri, 8 Oct 2021 12:19:13 +0000 (21:19 +0900)]
[mlir][linalg][bufferize] Rewrite "write into non-writable memory" detection

The purpose of this revision is to make "write into non-writable memory" conflict detection easier to understand.

The main idea is that there is a conflict in the case of inplace bufferization if:

1. Someone writes to (an alias of) opOperand, opResult or the to-be-bufferized op writes itself.
2. And, opOperand or opResult aliases a non-writable buffer.

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

2 years ago[mlir][linalg] Constant fold linalg.generic that are transposes
Lei Zhang [Fri, 8 Oct 2021 12:06:31 +0000 (08:06 -0400)]
[mlir][linalg] Constant fold linalg.generic that are transposes

This commit adds a pattern to perform constant folding on linalg
generic ops which are essentially transposes. We see real cases
where model importers may generate such patterns.

Reviewed By: mravishankar

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

2 years ago[fir] Add affine demotion pass
Rajan Walia [Fri, 8 Oct 2021 12:02:02 +0000 (14:02 +0200)]
[fir] Add affine demotion pass

Add affine demotion pass.
Affine dialect's default lowering for loads and stores is different from
fir as it uses the `memref` type. The `memref` type is not compatible with
the Fortran runtime. Therefore, conversion of memory operations back to
`fir.load` and `fir.store` with `!fir.ref<?>` types is required.

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

Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: V Donaldson <vdonaldson@nvidia.com>
Co-authored-by: Rajan Walia <walrajan@gmail.com>
Co-authored-by: Sourabh Singh Tomar <SourabhSingh.Tomar@amd.com>
Co-authored-by: Valentin Clement <clementval@gmail.com>
Reviewed By: schweitz

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

2 years ago[CostModel][TTI] Replace BAD_ICMP_PREDICATE with ICMP_SGT/UGT for generic abs/min...
Simon Pilgrim [Fri, 8 Oct 2021 11:19:46 +0000 (12:19 +0100)]
[CostModel][TTI] Replace BAD_ICMP_PREDICATE with ICMP_SGT/UGT for generic abs/min/max cost expansion

Split off ABS cost handling from MIN/MAX and use explicit predicates for each

Our generic expansion of ABS doesn't use NEG+CMP+SELECT any more (its now ASHR+ADD+XOR) so this needs to be updated.

2 years ago[gn build] Port 30caca39f401
LLVM GN Syncbot [Fri, 8 Oct 2021 11:24:14 +0000 (11:24 +0000)]
[gn build] Port 30caca39f401

2 years agoReland "[gn build] (manually) port 6fe2beba7d2a (ExceptionTests)"
Nico Weber [Fri, 8 Oct 2021 11:17:04 +0000 (07:17 -0400)]
Reland "[gn build] (manually) port 6fe2beba7d2a (ExceptionTests)"

This reverts commit 98d0f8f2ff98ee02d79930a5aaa56c1cf5b14653.
6fe2beba7d2a relanded in 1dba6b37bdc7.

2 years agoExtend init-statement to allow alias-declaration
Corentin Jabot [Fri, 8 Oct 2021 11:12:46 +0000 (07:12 -0400)]
Extend init-statement to allow alias-declaration

Implement P2360R0 in C++23 mode and as an extension in older
languages mode.

2 years agoRecommit "[LoopPeel] Peel loops with deoptimizing exits"
Max Kazantsev [Fri, 8 Oct 2021 10:54:27 +0000 (17:54 +0700)]
Recommit "[LoopPeel] Peel loops with deoptimizing exits"

Removed obsolete DT verification that should not be there because the
strategy of DT updates has changed.

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

2 years agoThird Recommit "[AArch64] Split bitmask immediate of bitwise AND operation"
Jingu Kang [Thu, 7 Oct 2021 18:54:40 +0000 (19:54 +0100)]
Third Recommit "[AArch64] Split bitmask immediate of bitwise AND operation"

This reverts the revert commit fc36fb4d23a5e419cf33002c87c0082f682cb77b with
bug fixes.

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

2 years ago[mlir] Add alignment option to constant tensor bufferization pass
Eugene Zhulenev [Thu, 7 Oct 2021 22:52:17 +0000 (15:52 -0700)]
[mlir] Add alignment option to constant tensor bufferization pass

Reviewed By: bkramer

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

2 years ago[lldb] [ConnectionFileDescriptorPosix] Refactor scheme matching
Michał Górny [Thu, 7 Oct 2021 15:58:06 +0000 (17:58 +0200)]
[lldb] [ConnectionFileDescriptorPosix] Refactor scheme matching

Move the POSIX-specific fd:// and file:// scheme handling into
separate methods.  Replace the custom GetURLAddress() matching with
splitting into scheme and path, and matching scheme via
llvm::StringSwitch.  Use early returns.

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

2 years ago[fir] Add affine promotion pass
Jean Perier [Fri, 8 Oct 2021 09:38:44 +0000 (11:38 +0200)]
[fir] Add affine promotion pass

Convert fir operations which satisfy affine constraints to the affine
dialect.

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

Co-authored-by: V Donaldson <vdonaldson@nvidia.com>
Co-authored-by: Rajan Walia <walrajan@gmail.com>
Co-authored-by: Sourabh Singh Tomar <SourabhSingh.Tomar@amd.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: Valentin Clement <clementval@gmail.com>
Reviewed By: schweitz, awarzynski

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

2 years agoFix a variety of bugs with nil-receiver checks when targeting
John McCall [Fri, 8 Oct 2021 09:20:45 +0000 (05:20 -0400)]
Fix a variety of bugs with nil-receiver checks when targeting
non-Darwin ObjC runtimes:

- Use the same logic the Darwin runtime does for inferring that a
  receiver is non-null and therefore doesn't require null checks.
  Previously we weren't skipping these for non-super dispatch.

- Emit a null check when there's a consumed parameter so that we can
  destroy the argument if the call doesn't happen.  This mostly
  involves extracting some common logic from the Darwin-runtime code.

- Generate a zero aggregate by zeroing the same memory that was used
  in the method call instead of zeroing separate memory and then
  merging them with a phi.  This uses less memory and avoids unnecessary
  copies.

- Emit zero initialization, and generate zero values in phis, using
  the proper zero-value routines instead of assuming that the zero
  value of the result type has a bitwise-zero representation.

2 years ago[Clang][OpenMP] Add partial support for Static Device Libraries
Saiyedul Islam [Fri, 8 Oct 2021 09:19:15 +0000 (09:19 +0000)]
[Clang][OpenMP] Add partial support for Static Device Libraries

An archive containing device code object files can be passed to
clang command line for linking. For each given offload target
it creates a device specific archives which is either passed to llvm-link
if the target is amdgpu, or to clang-nvlink-wrapper if the target is
nvptx. -L/-l flags are used to specify these fat archives on the command
line. E.g.
  clang++ -fopenmp -fopenmp-targets=nvptx64 main.cpp -L. -lmylib

It currently doesn't support linking an archive directly, like:
  clang++ -fopenmp -fopenmp-targets=nvptx64 main.cpp libmylib.a

Linking with x86 offload also does not work.

Reviewed By: ye-luo

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

2 years ago[lldb] [ConnectionFileDescriptorPosix] Use a single NativeFile
Michał Górny [Thu, 7 Oct 2021 14:28:53 +0000 (16:28 +0200)]
[lldb] [ConnectionFileDescriptorPosix] Use a single NativeFile

Replace separate read and write NativeFile instances with a single
instance shared for reading and writing.  There is no clear indication
why two instances were used in the first place, and replacing them
with just one does not seem to cause any regressions in tests or manual
'process connect file://...'.

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

2 years ago[LoopPeel] Add tests where peeling turns invar accesses dereferenceable.
Florian Hahn [Fri, 8 Oct 2021 09:09:13 +0000 (10:09 +0100)]
[LoopPeel] Add tests where peeling turns invar accesses dereferenceable.

Precommit test cases for D108114.

2 years ago[Driver][NetBSD] Use ToolChain reference instead of getToolChain().
Frederic Cambus [Fri, 8 Oct 2021 09:07:50 +0000 (11:07 +0200)]
[Driver][NetBSD] Use ToolChain reference instead of getToolChain().

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

2 years ago[X86] Check if struct is blank before getting the inner types
Wang, Pengfei [Fri, 8 Oct 2021 08:01:45 +0000 (16:01 +0800)]
[X86] Check if struct is blank before getting the inner types

This fixes pr52011.

Reviewed By: LuoYuanke

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

2 years agoRevert "[LoopPeel] Peel loops with deoptimizing exits"
Max Kazantsev [Fri, 8 Oct 2021 09:07:59 +0000 (16:07 +0700)]
Revert "[LoopPeel] Peel loops with deoptimizing exits"

This reverts commit 8a959625c433f311233682afa7bfe1c76367700d.

Reported failures with LLVM_ENABLE_EXPENSIVE_CHECKS, need to investigate.

2 years ago[compiler-rt][fuzzer] Re-enable flags test on AArch64 Linux
David Spickett [Fri, 8 Oct 2021 08:54:23 +0000 (08:54 +0000)]
[compiler-rt][fuzzer] Re-enable flags test on AArch64 Linux

This is now passing after bots were upgraded to Ubuntu Focal,
which comes with ld 2.34.

2 years ago[lldb/gdb-remote] Refactor ReadExtFeature
Pavel Labath [Thu, 7 Oct 2021 12:23:26 +0000 (14:23 +0200)]
[lldb/gdb-remote] Refactor ReadExtFeature

replace stl and lldb apis with standard llvm ones.

2 years ago[lldb] Remove shared_ptr from some global Properties objects
Pavel Labath [Thu, 7 Oct 2021 13:44:47 +0000 (15:44 +0200)]
[lldb] Remove shared_ptr from some global Properties objects

they're unnecessary, make the code longer, and their removal actually
ensures proper initialization in multithreaded scenarios.

2 years ago[clangd] Revert unwanted change from D108194
Kirill Bobyrev [Fri, 8 Oct 2021 08:40:40 +0000 (10:40 +0200)]
[clangd] Revert unwanted change from D108194

Left-overs from the review process were not deleted.

2 years ago[LoopBoundSplit] Handle the case in which exiting block is loop header
Jingu Kang [Mon, 4 Oct 2021 09:23:54 +0000 (10:23 +0100)]
[LoopBoundSplit] Handle the case in which exiting block is loop header

Update the incoming value of phi nodes in header of post-loop correctly.

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

2 years ago[LoopIdiom] Transform loop containing memcpy to memmove
Dawid Jurczak [Tue, 5 Oct 2021 15:31:08 +0000 (17:31 +0200)]
[LoopIdiom] Transform loop containing memcpy to memmove

The purpose of patch is to learn Loop Idiom Recognize pass how to recognize simple memmove patterns
in similar way like GCC does: https://godbolt.org/z/dKjGvTGff
It's follow-up of following change: https://reviews.llvm.org/D104464

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

2 years ago[NFC] [Clang] Remove pre-computed complex float types
Qiu Chaofan [Fri, 8 Oct 2021 07:48:01 +0000 (15:48 +0800)]
[NFC] [Clang] Remove pre-computed complex float types

As discussed in D109948, pre-computing all complex float types is not
necessary and brings extra overhead. This patch removes these defined
types, and construct them in-place when needed.

Reviewed By: teemperor

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

2 years ago[mlir][python] support taking ops instead of values in op constructors
Alex Zinenko [Thu, 7 Oct 2021 16:29:03 +0000 (18:29 +0200)]
[mlir][python] support taking ops instead of values in op constructors

Introduce support for accepting ops instead of values when constructing ops. A
single-result op can be used instead of a value, including in lists of values,
and any op can be used instead of a list of values. This is similar to, but
more powerful, than the C++ API that allows for implicitly casting an OpType to
Value if it is statically known to have a single result - the cast in Python is
based on the op dynamically having a single result, and also handles the
multi-result case. This allows to build IR in a more concise way:

    op = dialect.produce_multiple_results()
    other = dialect.produce_single_result()
    dialect.consume_multiple_results(other, op)

instead of having to access the results manually

    op = dialect.produce.multiple_results()
    other = dialect.produce_single_result()
    dialect.consume_multiple_results(other.result, op.operation.results)

The dispatch is implemented directly in Python and is triggered automatically
for autogenerated OpView subclasses. Extension OpView classes should use the
functions provided in ods_common.py if they want to implement this behavior.
An alternative could be to implement the dispatch in the C++ bindings code, but
it would require to forward opaque types through all Python functions down to a
binding call, which makes it hard to inspect them in Python, e.g., to obtain
the types of values.

Reviewed By: gysit

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

2 years ago[Polly] Completely remove -polly-opt-fusion.
Michael Kruse [Wed, 6 Oct 2021 17:34:45 +0000 (12:34 -0500)]
[Polly] Completely remove -polly-opt-fusion.

This was missing from 07e7cb9433daa80e7a8b418cb334c663abe68202.
The switch did nothing since then.

2 years ago[mlir][linalg] Retire Linalg ConvOp.
Tobias Gysi [Fri, 8 Oct 2021 06:50:52 +0000 (06:50 +0000)]
[mlir][linalg] Retire Linalg ConvOp.

The convolution op is one of the remaining hard coded Linalg operations that have no region attached. It got obsolete due to the OpDSL convolution operations. Removing it allows us to delete specialized code and tests that are not needed for the OpDSL counterparts that rely on the standard code paths.

Test needed due to specialized implementations are removed. Tiling and fusion tests are replaced by variants using linalg.conv_2d.

Reviewed By: nicolasvasilache

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

2 years ago[GlobalISel][IRTranslator] Fix a use-after-free bug when translating trap-func-name...
Amara Emerson [Fri, 8 Oct 2021 06:26:35 +0000 (23:26 -0700)]
[GlobalISel][IRTranslator] Fix a use-after-free bug when translating trap-func-name traps.

This was using MachineFunction::createExternalSymbolName() before, which seems
reasonable, but in fact this is freed before the asm emitter which tries to access
the function name string. Switching it to use the string returned by the attribute
seems to fix the problem.

2 years ago[GlobalISel] Combine G_UMULH x, (1 << c)) -> x >> (bitwidth - c)
Amara Emerson [Mon, 4 Oct 2021 05:26:26 +0000 (22:26 -0700)]
[GlobalISel] Combine G_UMULH x, (1 << c)) -> x >> (bitwidth - c)

In order to not generate an unnecessary G_CTLZ, I extended the constant folder
in the CSEMIRBuilder to handle G_CTLZ. I also added some extra handing of
vector constants too. It seems we don't have any support for doing constant
folding of vector constants, so the tests show some other useless G_SUB
instructions too.

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

2 years ago[mlir][linalg] Add loop interchange to CodegenStrategy.
Tobias Gysi [Fri, 8 Oct 2021 06:39:22 +0000 (06:39 +0000)]
[mlir][linalg] Add loop interchange to CodegenStrategy.

Add a loop interchange pass and integrate it with CodegenStrategy.

This patch depends on https://reviews.llvm.org/D110728 and https://reviews.llvm.org/D110746.

Reviewed By: nicolasvasilache

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

2 years ago[TargetPassConfig] Remove an obsolete FIXME comment
Jay Foad [Fri, 8 Oct 2021 06:32:44 +0000 (07:32 +0100)]
[TargetPassConfig] Remove an obsolete FIXME comment

The "coloring with register" functionality it refers to was removed ten
years ago in svn r144481 "Remove the -color-ss-with-regs option".

2 years ago[mlir][linalg] Add generalization to CodegenStrategy.
Tobias Gysi [Fri, 8 Oct 2021 06:06:12 +0000 (06:06 +0000)]
[mlir][linalg] Add generalization to CodegenStrategy.

Add a generalization pass and integrate it with CodegenStrategy.

This patch depends on https://reviews.llvm.org/D110728.

Reviewed By: nicolasvasilache

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

2 years ago[VE][Test] Make Scalar/va_arg test generic
Simon Moll [Fri, 8 Oct 2021 06:07:51 +0000 (08:07 +0200)]
[VE][Test] Make Scalar/va_arg test generic

Make match patterns more permissive to be invariant to register
allocation choices.

Reviewed By: kaz7

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

2 years agoReland "[clang-repl] Re-implement clang-interpreter as a test case."
Vassil Vassilev [Tue, 5 Oct 2021 14:31:30 +0000 (14:31 +0000)]
Reland "[clang-repl] Re-implement clang-interpreter as a test case."

  Original commit message: "
    Original commit message: "
        Original commit message:"
          The current infrastructure in lib/Interpreter has a tool, clang-repl, very
          similar to clang-interpreter which also allows incremental compilation.

          This patch moves clang-interpreter as a test case and drops it as conditionally
          built example as we already have clang-repl in place.

          Differential revision: https://reviews.llvm.org/D107049
        "

        This patch also ignores ppc due to missing weak symbol for __gxx_personality_v0
        which may be a feature request for the jit infrastructure. Also, adds a missing
        build system dependency to the orc jit.
    "

    Additionally, this patch defines a custom exception type and thus avoids the
    requirement to include header <exception>, making it easier to deploy across
    systems without standard location of the c++ headers.
  "

  This patch also works around PR49692 and finds a way to use llvm::consumeError
  in rtti mode.

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

2 years ago[NFC][ScalarEvolution] Fix typo in getRangeForAffineAR and getRangeViaFactoring
Jimmy Zhongduo Lin [Fri, 8 Oct 2021 05:58:42 +0000 (11:28 +0530)]
[NFC][ScalarEvolution] Fix typo in getRangeForAffineAR and getRangeViaFactoring

2 years ago[mlir][linalg][bufferize][NFC] API change of aliasesNonWritableBuffer
Matthias Springer [Fri, 8 Oct 2021 05:46:45 +0000 (14:46 +0900)]
[mlir][linalg][bufferize][NFC] API change of aliasesNonWritableBuffer

The function now takes a Value instead of an OpOperand.

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

2 years ago[mlir][linalg][bufferize] Fix/add missing case to getAliasingOpOperand
Matthias Springer [Fri, 8 Oct 2021 05:36:43 +0000 (14:36 +0900)]
[mlir][linalg][bufferize] Fix/add missing case to getAliasingOpOperand

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

2 years ago[mlir][linalg][bufferize] Add bufferRelation to op interface
Matthias Springer [Fri, 8 Oct 2021 03:14:05 +0000 (12:14 +0900)]
[mlir][linalg][bufferize] Add bufferRelation to op interface

Currently supported are: BufferRelation::None, BufferRelation::Equivalent.

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

2 years agoevert "[mlir] Limit Python dependency to Development.Module when possible."
Mehdi Amini [Fri, 8 Oct 2021 05:18:44 +0000 (05:18 +0000)]
evert "[mlir] Limit Python dependency to Development.Module when possible."

This reverts commit 7aebdfc4fcc4a2667f5d5c30ffbdc146f9b014d2.

The build is broken with errors like:

GPUPasses.cpp:(.text.pybind11_object_init[pybind11_object_init]+0x118): undefined reference to `PyExc_TypeError'

2 years ago[mlir] Limit Python dependency to Development.Module when possible.
Mike Urbach [Fri, 8 Oct 2021 04:08:15 +0000 (22:08 -0600)]
[mlir] Limit Python dependency to Development.Module when possible.

After CMake 3.18, we are able to limit the scope of the
find_package(Python3 ...) search to just Development.Module. Searching
for Development will fail in manylinux builds, and isn't necessary
since we are not embedding the Python interpreter. For more information, see:
https://pybind11.readthedocs.io/en/stable/compiling.html#findpython-mode

Reviewed By: stellaraccident

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

2 years agoFix test-rsqrt.mlir to accept AMD's approximation of rsqrt as well
Mehdi Amini [Fri, 8 Oct 2021 01:21:24 +0000 (01:21 +0000)]
Fix test-rsqrt.mlir to accept AMD's approximation of rsqrt as well

These kind of function can behave differently on these X86 chips, there
isn't really "one true answer" so we'll accept both.

Also remove spurious passes and use mattr="avx" to match the instruction
used here.

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

2 years agoRevert "[sanitizer] Support Intel CET"
Arthur Eubanks [Fri, 8 Oct 2021 03:53:43 +0000 (20:53 -0700)]
Revert "[sanitizer] Support Intel CET"

This reverts commit fdf4c035225de52f596899931b1f6100e5e3e928.

Breaks macOS bots, e.g. https://crbug.com/1257863.
Still figuring out if this is actually supported on macOS. Other places
that include <cet.h> only do so on Linux.

2 years ago[RISCV] Remove experimental-b extension that includes all Zb* extensions
Craig Topper [Thu, 7 Oct 2021 19:02:35 +0000 (12:02 -0700)]
[RISCV] Remove experimental-b extension that includes all Zb* extensions

At this point it looks like a B extension will never exist. Instead
Zba, Zbb, Zbc, and Zbs are individual extensions being ratified
together as a package. Unknown at this time when or if the other
Zb* extensions will be ratified.

This patch removes references to the B extension. I've updated and
split tests accordingly.

This has been split from D110669 to make review a little easier.

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

2 years agouse right separator for windows.
Chen Zheng [Fri, 8 Oct 2021 03:44:12 +0000 (03:44 +0000)]
use right separator for windows.

2 years ago[LoopPeel] Peel loops with deoptimizing exits
Max Kazantsev [Fri, 8 Oct 2021 02:09:22 +0000 (09:09 +0700)]
[LoopPeel] Peel loops with deoptimizing exits

Added support for peeling loops with "deoptimizing" exits -
such exits that it or any of its children (or any of their
children, etc) either has a @llvm.experimental.deoptimize call
prior to the terminating return instruction of this basic block
or is terminated with unreachable. All blocks in the the
sequence must have a single successor, maybe except for the last
one.

Previously we only checked the exit block for being deoptimizing.
Now we check if the last reachable block from the exit is deoptimizing.

Patch by Dmitry Makogon!

Differential Revision: https://reviews.llvm.org/D110922
Reviewed By: mkazantsev