platform/upstream/llvm.git
3 years ago[NFC intended] Refactor the code for printChanged for reuse and to facilitate subsequ...
Jamie Schmeiser [Fri, 20 Nov 2020 14:43:06 +0000 (09:43 -0500)]
[NFC intended] Refactor the code for printChanged for reuse and to facilitate subsequent reporters of changes to the IR in the new pass manager.

Summary:
[NFC intended] Refactor the code for printChanged for reuse and to facilitate
subsequent reporters of changes to the IR in the new pass manager.

Create abstract template base classes for common functionality and give
classes more appropriate names.  The base classes handle all of the
determination of when a function or pass is "interesting" and should be
reported or filtered out. They have pure virtual functions which are called
when a change by a pass has been recognized so the derived class need only
provide the overrides to present the information about the changing IR.
There are at least 2 more change reporters to come (which were presented
in my tutorial at the 2020 llvm developer's meeting) that derive from
these classes.

Respond to review comments:  move function out of line, remove inline keyword,
remove unneeded qualifiers, simplify comparison.

Author: Jamie Schmeiser <schmeise@ca.ibm.com>
Reviewed By: aeubanks (Arthur Eubanks), madhur13490 (Madhur Amilkanthwar)
Differential Revision: https://reviews.llvm.org/D87000

3 years ago[clang] Do not crash on pointer wchar_t pointer assignment.
Adam Czachorowski [Tue, 17 Nov 2020 13:24:00 +0000 (14:24 +0100)]
[clang] Do not crash on pointer wchar_t pointer assignment.

wchar_t can be signed (thus hasSignedIntegerRepresentation() returns
true), but it doesn't have an unsigned type, which would lead to a crash
when trying to get it.

With this fix, we special-case WideChar types in the pointer assignment
code.

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

3 years ago[AArch64] Enable post RA scheduler for Cortex-R82
Sjoerd Meijer [Fri, 20 Nov 2020 14:04:26 +0000 (14:04 +0000)]
[AArch64] Enable post RA scheduler for Cortex-R82

Just something I forgot when I added the R82. Need to have a look
at crypto and fusing, but will do that as a follow up.

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

3 years agoAdd a call super attribute plugin example
Yafei Liu [Fri, 20 Nov 2020 13:50:39 +0000 (08:50 -0500)]
Add a call super attribute plugin example

If a virtual method is marked as call_super, the
override method must call it, simpler feature like @CallSuper
in Android Java.

3 years agoAdd documentation illustrating use of IgnoreUnlessSpelledInSource
Stephen Kelly [Tue, 17 Nov 2020 16:50:53 +0000 (16:50 +0000)]
Add documentation illustrating use of IgnoreUnlessSpelledInSource

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

3 years ago[ARM] Disable WLSTP loops
David Green [Fri, 20 Nov 2020 13:30:44 +0000 (13:30 +0000)]
[ARM] Disable WLSTP loops

This checks to see if the loop will likely become a tail predicated loop
and disables wls loop generation if so, as the likelihood for reverting
is currently too high. These should be fairly rare situations anyway due
to the way iterations and element counts are used during lowering. Just
not trying can alter how SCEV's are materialized however, leading to
different codegen.

It also adds a option to disable all while low overhead loops, for
debugging.

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

3 years ago[AArch64] Out-of-line atomics (-moutline-atomics) implementation.
Pavel Iliin [Thu, 19 Nov 2020 19:52:46 +0000 (19:52 +0000)]
[AArch64] Out-of-line atomics (-moutline-atomics) implementation.

This patch implements out of line atomics for LSE deployment
mechanism. Details how it works can be found in llvm/docs/Atomics.rst
Options -moutline-atomics and -mno-outline-atomics to enable and disable it
were added to clang driver. This is clang and llvm part of out-of-line atomics
interface, library part is already supported by libgcc. Compiler-rt
support is provided in separate patch.

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

3 years ago[CostModel] add tests for math library calls; NFC
Sanjay Patel [Fri, 13 Nov 2020 23:01:39 +0000 (18:01 -0500)]
[CostModel] add tests for math library calls; NFC

This is a partial un-revert of 32dd5870ee31 (originally df09f82599 ).

I'm adding back the baseline tests first, so we don't have
to back-track as much in case there are still problems.

3 years ago[LoopUnroll] add test for full unroll that is sensitive to cost-model; NFC
Sanjay Patel [Fri, 20 Nov 2020 13:03:33 +0000 (08:03 -0500)]
[LoopUnroll] add test for full unroll that is sensitive to cost-model; NFC

See discussion in D90554.

This is a partial un-revert of 32dd5870ee31. I'm adding
back the baseline tests first, so we don't have to
back-track as much in case there are still problems.

3 years ago[sanitizers][test] Test sanitizer_common and ubsan_minimal on Solaris
Rainer Orth [Fri, 20 Nov 2020 13:06:25 +0000 (14:06 +0100)]
[sanitizers][test] Test sanitizer_common and ubsan_minimal on Solaris

During the initial Solaris sanitizer port, I missed to enable the
`sanitizer_common` and `ubsan_minimal` testsuites.  This patch fixes this,
correcting a few unportabilities:

- `Posix/getpass.cpp` failed to link since Solaris lacks `libutil`.
  Omitting the library lets the test `PASS`, but I thought adding `%libutil`
  along the lines of `%librt` to be overkill.
- One subtest of `Posix/getpw_getgr.cpp` is disabled because Solaris
  `getpwent_r` has a different signature than expected.
- `/dev/null` is a symlink on Solaris.
- XPG7 specifies that `uname` returns a non-negative value on success.

Tested on `amd64-pc-solaris2.11` and `sparcv9-sun-solaris2.11`.

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

3 years ago[mlir][std] Canonicalize a dim(memref_reshape) into a load from the shape operand
Stephan Herhut [Fri, 20 Nov 2020 10:21:27 +0000 (11:21 +0100)]
[mlir][std] Canonicalize a dim(memref_reshape) into a load from the shape operand

This canonicalization helps propagate shape information through the program.

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

3 years ago[InstCombine] add test comments for negative tests; NFC
Sanjay Patel [Fri, 20 Nov 2020 11:40:28 +0000 (06:40 -0500)]
[InstCombine] add test comments for negative tests; NFC

3 years ago[mlir][std] Fold load(tensor_to_memref) into extract_element
Stephan Herhut [Fri, 20 Nov 2020 10:32:42 +0000 (11:32 +0100)]
[mlir][std] Fold load(tensor_to_memref) into extract_element

This canonicalization is useful to resolve loads into scalar values when
doing partial bufferization.

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

3 years agoPartially revert '[MachO] Update embedded part of ObjectFileMachO for Mangled API...
Raphael Isemann [Fri, 20 Nov 2020 12:01:01 +0000 (13:01 +0100)]
Partially revert '[MachO] Update embedded part of ObjectFileMachO for Mangled API change'

Commit f3aa9e36d91b7b0f4f24f7a3b13cf80c11356e5e fixed the embedded OS
build by removing all passed args for `GetName`/`GetDemangledName`. The motivation
for this was that these arguments were apparently removed in
commit 22b044877d239c40c9a932d1ea47d489c507000f. However, only `GetName`'s language
argument was removed but the mangling preference argument was *not* removed
(and unfortunately had a default argument). So when that commit removed all
the args it didn't just fix the build but it also changed all the mangling
preferences to 'demangled' for all `GetName` calls.

Also some `GetName` calls were outside the TARGET_OS_EMBEDDED ifdef, so
this change ended up breaking the following tests on macOS:

  lldb-api :: lang/objc/objc-static-method-stripped/TestObjCStaticMethodStripped.py
  lldb-api :: lang/objc/objc-super/TestObjCSuper.py

From what I can see f3aa9e36d91b7 removed 12 ePreferMangled args and this patch
re-adds 12 args with roughly the same line numbers, so this *should* restore the
old behaviour and also keep the embedded build working. On the other hand,
ObjectFileMachO::ParseSymtab is a very successful attempt at writing
the longest possible function within LLVM, so this fix is partly based
on the engineering principle known as "hoping for the best".

3 years ago[VE] Change threshold for jump table generation
Kazushi (Jam) Marukawa [Thu, 19 Nov 2020 12:31:21 +0000 (21:31 +0900)]
[VE] Change threshold for jump table generation

Implement getMinimumJumpTableEntries() to specify threshold for jump
table genaration.  We use 8 for the case of PIC mode to relieve the
impact of PIC calculation required to implement PIC mode jump table.
Update jump table regression test also.

Reviewed By: simoll

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

3 years ago[mlir][std] Fold comparisons when the operands are equal
Stephan Herhut [Fri, 20 Nov 2020 10:46:22 +0000 (11:46 +0100)]
[mlir][std] Fold comparisons when the operands are equal

For equal operands, comparisons can be decided statically.

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

3 years agoRevert "[mlir][Linalg] Fuse sequence of Linalg operation (on buffers)"
Mikhail Goncharov [Fri, 20 Nov 2020 12:09:28 +0000 (13:09 +0100)]
Revert "[mlir][Linalg] Fuse sequence of Linalg operation (on buffers)"

This reverts commit f8284d21a8e294d58a0acd4b8b2e906d7a9f110c.

Revert "[mlir][Linalg] NFC: Expose some utility functions used for promotion."

This reverts commit 0c59f51592ef5c014352994369f5216c6376fae1.

Revert "Remove unused isZero function"

This reverts commit 0f9f0a4046e11c2b4c130640f343e3b2b5db08c1.

Change f8284d21 led to multiple failures in IREE compilation.

3 years ago[clang][CodeGen] Move WebAssembly specific tests to WebAssembly subtarget folder
Simon Pilgrim [Fri, 20 Nov 2020 12:02:57 +0000 (12:02 +0000)]
[clang][CodeGen] Move WebAssembly specific tests to WebAssembly subtarget folder

Minor cleanup to move more target specific tests out of the root codegen test folder

3 years ago[clang][CodeGen] Move riscv specific tests to RISCV subtarget folder
Simon Pilgrim [Fri, 20 Nov 2020 11:47:27 +0000 (11:47 +0000)]
[clang][CodeGen] Move riscv specific tests to RISCV subtarget folder

Minor cleanup to move more target specific tests out of the root codegen test folder

3 years ago[sanitizer_common][test] Disable CombinedAllocator32Compact etc. on Solaris/sparcv9
Rainer Orth [Fri, 20 Nov 2020 12:02:15 +0000 (13:02 +0100)]
[sanitizer_common][test] Disable CombinedAllocator32Compact etc. on Solaris/sparcv9

As reported in PR 48202, two allocator tests `FAIL` on Solaris/sparcv9,
presumably because Solaris uses the full 64-bit address space and the
allocator cannot deal with that:

  SanitizerCommon-Unit :: ./Sanitizer-sparcv9-Test/SanitizerCommon.CombinedAllocator32Compact
  SanitizerCommon-Unit :: ./Sanitizer-sparcv9-Test/SanitizerCommon.SizeClassAllocator32Iteration

This patch disables the tests.

Tested on `sparcv9-sun-solaris2.11`.

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

3 years ago[sanitizer_common][test] Disable FastUnwindTest.* on SPARC
Rainer Orth [Fri, 20 Nov 2020 11:52:18 +0000 (12:52 +0100)]
[sanitizer_common][test] Disable FastUnwindTest.* on SPARC

Many of the `FastUnwindTest.*` tests `FAIL` on SPARC, both Solaris and
Linux.  The issue is that the fake stacks used in those tests don't match
the requirements of the SPARC unwinder in `sanitizer_stacktrace_sparc.cpp`
which has to look at the register window save area.

I'm disabling the failing tests.

Tested on `sparcv9-sun-solaris2.11`.
Differential Revision: https://reviews.llvm.org/D91618

3 years agoFix MSVC "not all control paths return a value" warnings. NFCI.
Simon Pilgrim [Fri, 20 Nov 2020 11:40:59 +0000 (11:40 +0000)]
Fix MSVC "not all control paths return a value" warnings. NFCI.

3 years ago[lldb][AArch64/Linux] Show memory tagged memory regions
David Spickett [Mon, 17 Aug 2020 14:02:04 +0000 (15:02 +0100)]
[lldb][AArch64/Linux] Show memory tagged memory regions

This extends the "memory region" command to
show tagged regions on AArch64 Linux when the MTE
extension is enabled.

(lldb) memory region the_page
[0x0000fffff7ff8000-0x0000fffff7ff9000) rw-
memory tagging: enabled

This is done by adding an optional "flags" field to
the qMemoryRegion packet. The only supported flag is
"mt" but this can be extended.

This "mt" flag is read from /proc/{pid}/smaps on Linux,
other platforms will leave out the "flags" field.

Where this "mt" flag is received "memory region" will
show that it is enabled. If it is not or the target
doesn't support memory tagging, the line is not shown.
(since majority of the time tagging will not be enabled)

Testing is added for the existing /proc/{pid}/maps
parsing and the new smaps parsing.
Minidump parsing has been updated where needed,
though it only uses maps not smaps.

Target specific tests can be run with QEMU and I have
added MTE flags to the existing helper scripts.

Reviewed By: labath

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

3 years ago[mlir] Automatic reference counting for Async values + runtime support for ref counte...
Eugene Zhulenev [Fri, 20 Nov 2020 10:42:28 +0000 (02:42 -0800)]
[mlir] Automatic reference counting for Async values + runtime support for ref counted objects

Depends On D89963

**Automatic reference counting algorithm outline:**

1. `ReturnLike` operations forward the reference counted values without
    modifying the reference count.
2. Use liveness analysis to find blocks in the CFG where the lifetime of
   reference counted values ends, and insert `drop_ref` operations after
   the last use of the value.
3. Insert `add_ref` before the `async.execute` operation capturing the
   value, and pairing `drop_ref` before the async body region terminator,
   to release the captured reference counted value when execution
   completes.
4. If the reference counted value is passed only to some of the block
   successors, insert `drop_ref` operations in the beginning of the blocks
   that do not have reference coutned value uses.

Reviewed By: silvas

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

3 years ago[AMDGPU] Implement flat scratch init for pal
Sebastian Neubauer [Thu, 15 Oct 2020 11:26:44 +0000 (13:26 +0200)]
[AMDGPU] Implement flat scratch init for pal

Extract the scratch offset from the scratch buffer descriptor that is
stored in the global table.

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

3 years ago[NFC][Test] Update test for IEEE Long Double
QingShan Zhang [Fri, 20 Nov 2020 09:56:53 +0000 (09:56 +0000)]
[NFC][Test] Update test for IEEE Long Double

3 years ago[Test] Auto-update checks in a test
Max Kazantsev [Fri, 20 Nov 2020 09:52:50 +0000 (16:52 +0700)]
[Test] Auto-update checks in a test

3 years ago[llvm-readelf/obj] - Improve error reporting when dumping group sections.
Georgii Rymar [Thu, 19 Nov 2020 15:23:27 +0000 (18:23 +0300)]
[llvm-readelf/obj] - Improve error reporting when dumping group sections.

Our code that dumps groups has 3 noticeable issues:
1) It uses `unwrapOrError` in many places.
2) It doesn't allow reporting unique warnings, because the `getGroups` helper is not
   a member of `DumpStyle<ELFT>`.
3) It might just crash. See the comment for `StrTableOrErr->data() + Sym.st_name` line.

In this patch I am starting addressing these points.
For start I've converted one of `unwrapOrError` calls to a unique warning.

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

3 years ago[clangd] NFC: Reorder headers in tests accordig to Clang-Tidy
Kirill Bobyrev [Fri, 20 Nov 2020 09:38:41 +0000 (10:38 +0100)]
[clangd] NFC: Reorder headers in tests accordig to Clang-Tidy

3 years ago[llvm-readobj] - Introduce `forEachRelocationDo` helper.
Georgii Rymar [Thu, 12 Nov 2020 09:46:59 +0000 (12:46 +0300)]
[llvm-readobj] - Introduce `forEachRelocationDo` helper.

Our `printStackSize` implementation currently uses
API like `RelocationRef`, `object::symbol_iterator`.
It is not ideal as it doesn't allow
to handle possible error conditions properly.

Some time ago I started rewriting it and this NFC patch is
a one more step toward to it. Here I am introducing the
`forEachRelocationDo` helper. With it it is possible to iterate
over all kinds of relocations, what is helpful for improving
the code in `printStackSize` and around.

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

3 years agoRevert "[OpenMP] Add support for Intel's umonitor/umwait"
AndreyChurbanov [Fri, 20 Nov 2020 09:15:00 +0000 (12:15 +0300)]
Revert "[OpenMP] Add support for Intel's umonitor/umwait"

This reverts commit 9cfad5f9c5bfd985f1bc8b0954f58013c5236e58.

3 years ago[Test] Add tests demonstrating a bug in SCEV, PR48225
Max Kazantsev [Fri, 20 Nov 2020 08:57:44 +0000 (15:57 +0700)]
[Test] Add tests demonstrating a bug in SCEV, PR48225

Slightly simplified version of original test reported by Congzhe Cao.

3 years ago[lldb] [test/Register] XFAIL x86-fp-write on Darwin
Michał Górny [Fri, 20 Nov 2020 08:43:08 +0000 (09:43 +0100)]
[lldb] [test/Register] XFAIL x86-fp-write on Darwin

3 years agoRevert "[LLDB] Fixing lldb/test/Shell/Register/x86-fp-write.test"
Michał Górny [Fri, 20 Nov 2020 08:42:13 +0000 (09:42 +0100)]
Revert "[LLDB] Fixing lldb/test/Shell/Register/x86-fp-write.test"

The problem is not specific to arch but to the whole Darwin platform.

Reverts: 0fd04337a17138174adf9e6d408cf9c885dea086

3 years ago[X86] Add support for vex, vex2, vex3, and evex for MASM
Liu, Chen3 [Fri, 30 Oct 2020 03:11:35 +0000 (11:11 +0800)]
[X86] Add support for vex, vex2, vex3, and evex for MASM

For MASM syntax, the prefixes are not enclosed in braces.
The assembly code should like:
  "evex vcvtps2pd xmm0, xmm1"

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

3 years ago[lib/Object] - Generalize the RelocationResolver API.
Georgii Rymar [Thu, 12 Nov 2020 12:16:57 +0000 (15:16 +0300)]
[lib/Object] - Generalize the RelocationResolver API.

This allows to reuse the RelocationResolver from the code
that doesn't want to deal with `RelocationRef` class.

I am going to use it in llvm-readobj. See the description
of D91530 for more details.

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

3 years ago[NFC] Pre-commit test for flt_rounds on PowerPC
Qiu Chaofan [Fri, 20 Nov 2020 07:04:57 +0000 (15:04 +0800)]
[NFC] Pre-commit test for flt_rounds on PowerPC

3 years ago[PGO] Make -disable-preinline work with NPM
Arthur Eubanks [Thu, 19 Nov 2020 22:40:33 +0000 (14:40 -0800)]
[PGO] Make -disable-preinline work with NPM

Fixes cspgo_profile_summary.ll under NPM.

Reviewed By: xur

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

3 years agoTemporarily Revert "[CostModel] remove cost-kind predicate for intrinsics in basic...
Eric Christopher [Fri, 20 Nov 2020 05:59:16 +0000 (21:59 -0800)]
Temporarily Revert "[CostModel] remove cost-kind predicate for intrinsics in basic TTI implementation"
as it's causing crashes in the optimizer. A reduced testcase has been posted as a follow-up.

This reverts commit f7eac51b9b3f780c96ca41913293851c5acb465b.

Temporarily Revert "[CostModel] make default size cost for libcalls small (again)" as it depends upon the primary revert.

This reverts commit 8ec7ea3ddce7379e13e8dfb4a5260a6d2004aa1c.

Temporarily Revert "[CostModel] add tests for math library calls; NFC" as it depends upon the primary revert.

This reverts commit df09f825995b10da03f148133c119f52c94fd6e4.

Temporarily Revert "[LoopUnroll] add test for full unroll that is sensitive to cost-model; NFC" as it depends upon the primary revert.

This reverts commit 618d555e8d926a83161774df2035519c387269db.

3 years ago[CodeGen] Use llvm::is_contained (NFC)
Kazu Hirata [Fri, 20 Nov 2020 06:07:55 +0000 (22:07 -0800)]
[CodeGen] Use llvm::is_contained (NFC)

3 years ago[mlir] Support big-endian systems in DenseElementsAttr (multiple word)
Haruki Imai [Fri, 20 Nov 2020 05:07:31 +0000 (05:07 +0000)]
[mlir] Support big-endian systems in DenseElementsAttr (multiple word)

 D78076 supports big endian in DenseElementsAttr, but does not work when
APInt has multiple words(the number of bits > 64). This patch updates
D78076 to support it.
This patch removed the fix in D78076 and re-implemented to support multiple words.

Reviewed By: rriddle

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

3 years agoRemove unused isZero function
Geoffrey Martin-Noble [Fri, 20 Nov 2020 03:35:13 +0000 (19:35 -0800)]
Remove unused isZero function

Unused since https://reviews.llvm.org/D91503 and triggering
-Wunused-function

Reviewed By: rriddle

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

3 years ago[mlir][Linalg] NFC: Expose some utility functions used for promotion.
MaheshRavishankar [Fri, 20 Nov 2020 03:04:57 +0000 (19:04 -0800)]
[mlir][Linalg] NFC: Expose some utility functions used for promotion.

Exposing some utility functions from Linalg to allow for promotion of
fused views outside of the core tile+fuse logic.
This is an alternative to patch D91322 which adds the promotion logic
to the tileAndFuse method. Downside with that approach is that it is
not easily customizable based on needs.

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

3 years ago[mlir][Linalg] Fuse sequence of Linalg operation (on buffers)
MaheshRavishankar [Fri, 20 Nov 2020 03:02:31 +0000 (19:02 -0800)]
[mlir][Linalg] Fuse sequence of Linalg operation (on buffers)

Enhance the tile+fuse logic to allow fusing a sequence of operations.

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

3 years ago[mlir][Linalg] Add utility function that return static loop bounds of Linalg ops
MaheshRavishankar [Fri, 20 Nov 2020 02:59:48 +0000 (18:59 -0800)]
[mlir][Linalg] Add utility function that return static loop bounds of Linalg ops

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

3 years ago[PowerPC] Allow a '%' prefix for registers in CFI directives
Bill Wendling [Wed, 18 Nov 2020 12:06:09 +0000 (04:06 -0800)]
[PowerPC] Allow a '%' prefix for registers in CFI directives

Clang generates a '%' prefix for some registers in CFI directives. E.g.
".cfi_register lr, r12" becomes ".cfi_register lr, %r12" after
processing.

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

3 years ago[test] Fix multiply-minimal.ll
Arthur Eubanks [Fri, 20 Nov 2020 02:13:22 +0000 (18:13 -0800)]
[test] Fix multiply-minimal.ll

3 years agoADT: Split out isSafeToReferenceAfterResize helper to use early returns, NFC
Duncan P. N. Exon Smith [Thu, 19 Nov 2020 02:57:50 +0000 (18:57 -0800)]
ADT: Split out isSafeToReferenceAfterResize helper to use early returns, NFC

The assertion logic in SmallVector::assertSafeToReferenceAfterResize is
hard to follow; split out SmallVector::isSafeToReferenceAfterResize and
add early returns and comments. No functionality change here.

3 years agoPort -lower-matrix-intrinsics-minimal to NPM
Arthur Eubanks [Wed, 18 Nov 2020 07:09:20 +0000 (23:09 -0800)]
Port -lower-matrix-intrinsics-minimal to NPM

This reuses the existing lower-matrix-intrinsics pass rather than going
the legacy pass route of creating a new pass.

Use this new variant in the NPM -O0 pipeline.

Reviewed By: asbirlea

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

3 years agoADT: Use early returns in SmallVector::resize, NFC
Duncan P. N. Exon Smith [Fri, 20 Nov 2020 01:21:40 +0000 (17:21 -0800)]
ADT: Use early returns in SmallVector::resize, NFC

Just a simple cleanup, no functionality change here.

3 years agoADT: Weaken SmallVector::resize assertion from 5abf76fbe37380874a88cc9aa02164800e4e10f3
Duncan P. N. Exon Smith [Fri, 20 Nov 2020 01:15:34 +0000 (17:15 -0800)]
ADT: Weaken SmallVector::resize assertion from 5abf76fbe37380874a88cc9aa02164800e4e10f3

There's no need to check for reference invalidation when
`SmallVector::resize` is shrinking; the parameter isn't accessed.

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

3 years ago[lld][WebAssembly] Convert more tests to asm format. NFC.
Sam Clegg [Wed, 18 Nov 2020 05:52:45 +0000 (21:52 -0800)]
[lld][WebAssembly] Convert more tests to asm format. NFC.

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

3 years ago[LLDB] Fixing lldb/test/Shell/Register/x86-fp-write.test
shafik [Fri, 20 Nov 2020 00:29:28 +0000 (16:29 -0800)]
[LLDB] Fixing lldb/test/Shell/Register/x86-fp-write.test

D91497 changed lldb/test/Shell/Register/x86-fp-write.test and added target-x86_64 to the REQUIRES clause.
It looks this test does not pass on this platform so removing it since it one of tests failing on the
green dragon build bot.

3 years ago[gn build] Port 8adc4d1ec76
LLVM GN Syncbot [Fri, 20 Nov 2020 00:15:31 +0000 (00:15 +0000)]
[gn build] Port 8adc4d1ec76

3 years ago[clangd] Add textDocument/ast extension method to dump the AST
Sam McCall [Fri, 16 Oct 2020 18:03:48 +0000 (20:03 +0200)]
[clangd] Add textDocument/ast extension method to dump the AST

This is a mass-market version of the "dump AST" tweak we have behind
-hidden-features.
I think in this friendlier form it'll be useful for people outside clang
developers, which would justify making it a real feature.
It could be useful as a step towards lightweight clang-AST tooling in clangd
itself (like matcher-based search).

Advantages over the tweak:
 - simplified information makes it more accessible, likely somewhat useful
   without learning too much clang internals
 - can be shown in a tree view
 - structured information gives some options for presentation (e.g.
   icon + two text colors + tooltip in vscode)
 - clickable nodes jump to the corresponding code
Disadvantages:
 - a bunch of code to handle different node types
 - likely missing some important info vs dump-ast due to brevity/oversight
 - may end up chasing/maintaining support for the long tail of nodes

Demo with VSCode support: https://imgur.com/a/6gKfyIV

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

3 years ago[test] Fix split-vfunc.ll under NPM
Arthur Eubanks [Thu, 19 Nov 2020 22:58:24 +0000 (14:58 -0800)]
[test] Fix split-vfunc.ll under NPM

We need an AA pipeline under NPM.
This is a no-op if we are still using the legacy PM.

3 years ago[ConstraintElimination] Decompose GEP with arbitrary offsets.
Florian Hahn [Wed, 18 Nov 2020 11:45:26 +0000 (11:45 +0000)]
[ConstraintElimination] Decompose GEP with arbitrary offsets.

This patch decomposes `GEP %x, %offset` as  0 + 1 * %x + 1 * %off.

3 years ago[test] Fix globalaa-retained.ll under NPM
Arthur Eubanks [Thu, 19 Nov 2020 22:24:46 +0000 (14:24 -0800)]
[test] Fix globalaa-retained.ll under NPM

Just '-O2' didn't run the full AA pipeline under NPM.

3 years ago[test] Fix pr39282.ll under NPM
Arthur Eubanks [Thu, 19 Nov 2020 22:19:48 +0000 (14:19 -0800)]
[test] Fix pr39282.ll under NPM

Already has a NPM RUN line

3 years ago[mlir] Add missing const * updates in StandardAttributes
Tres Popp [Thu, 19 Nov 2020 21:48:03 +0000 (22:48 +0100)]
[mlir] Add missing const * updates in StandardAttributes

This add missing updates to the header file that caused linking issues.
Original change at https://reviews.llvm.org/D91740

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

3 years agoRemove unused private fields
Geoffrey Martin-Noble [Thu, 19 Nov 2020 21:34:40 +0000 (13:34 -0800)]
Remove unused private fields

Unused since https://reviews.llvm.org/D91762 and triggering
-Wunused-private-field

```
llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp:365:13: error: private field 'GetArgTLS' is not used [-Werror,-Wunused-private-field]
  Constant *GetArgTLS;
            ^
llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp:366:13: error: private field 'GetRetvalTLS' is not used [-Werror,-Wunused-private-field]
  Constant *GetRetvalTLS;
```

Reviewed By: stephan.yichao.zhao

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

3 years ago[InstCombine] Fold `and(shl(zext(x), width(SIGNMASK) - width(%x)), SIGNMASK)` to...
Roman Lebedev [Thu, 19 Nov 2020 21:07:48 +0000 (00:07 +0300)]
[InstCombine] Fold `and(shl(zext(x), width(SIGNMASK) - width(%x)), SIGNMASK)` to `and(sext(%x), SIGNMASK)`

One less instruction and reducing use count of zext.
As alive2 confirms, we're fine with all the weird combinations of
undef elts in constants, but unless the shift amount was undef
for a lane, we must sanitize undef mask to zero, since sign bits
are no longer zeros.

https://rise4fun.com/Alive/d7r
```
----------------------------------------
Optimization: zz
Precondition: ((C1 == (width(%r) - width(%x))) && isSignBit(C2))
  %o0 = zext %x
  %o1 = shl %o0, C1
  %r = and %o1, C2
=>
  %n0 = sext %x
  %r = and %n0, C2

Done: 2016
Optimization is correct!
```

3 years ago[NFC][InstCombine] Add test coverage for `and (sext %x), SIGNMASK`-like pattern
Roman Lebedev [Thu, 19 Nov 2020 21:04:48 +0000 (00:04 +0300)]
[NFC][InstCombine] Add test coverage for `and (sext %x), SIGNMASK`-like pattern

3 years ago[MemLoc] Use hasValue() method more (NFC)
Nikita Popov [Thu, 19 Nov 2020 21:28:39 +0000 (22:28 +0100)]
[MemLoc] Use hasValue() method more (NFC)

Followup to 7de7c40898a8f815d661781c92757f93fa4c6e5b. I previously
removed a number of == comparisons to LocationSize::unknown(), but
missed these != comparisons.

3 years ago[mlir] Add an assertion on creating an Operation with null result types
Alex Zinenko [Thu, 19 Nov 2020 18:35:35 +0000 (19:35 +0100)]
[mlir] Add an assertion on creating an Operation with null result types

Null types are commonly used as an error marker. Catch them in the constructor
of Operation if they are present in the result type list, as otherwise this
could lead to further surprising behavior when querying op result types.

Fix AsyncToLLVM and StandardToLLVM that were using null types when constructing
operations.

Reviewed By: rriddle

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

3 years agoRemove deadcode from DFSanFunction::get*TLS*()
Jianzhou Zhao [Thu, 19 Nov 2020 05:27:13 +0000 (05:27 +0000)]
Remove deadcode from DFSanFunction::get*TLS*()

clean more deadcode after D84704

Reviewed-by: morehouse
Differential Revision: https://reviews.llvm.org/D91762

3 years ago[mlir] Split BufferUtils.h out of Bufferize.h
Sean Silva [Mon, 16 Nov 2020 21:10:20 +0000 (13:10 -0800)]
[mlir] Split BufferUtils.h out of Bufferize.h

These utilities are more closely associated with the buffer
optimizations and buffer deallocation than with the dialect conversion
stuff in Bufferize.h. So move them out.

This makes Bufferize.h very easy to understand and completely focused on
dialect conversion.

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

3 years ago[MemLoc] Use hasValue() method (NFC)
Nikita Popov [Thu, 19 Nov 2020 20:53:20 +0000 (21:53 +0100)]
[MemLoc] Use hasValue() method (NFC)

Instead of comparing to LocationSize::unknown(), prefer calling
the hasValue() method instead, which is less reliant on
implementation details.

3 years ago[MemLoc] Specify LocationSize in unit test
Nikita Popov [Thu, 19 Nov 2020 20:50:44 +0000 (21:50 +0100)]
[MemLoc] Specify LocationSize in unit test

Followup to 393b9e9db31a3f83bc8b813ee24b56bc8ed93a49,
where I missed updating one MemoryLocation use inside a unit test.

3 years ago[MemLoc] Require LocationSize argument (NFC)
Nikita Popov [Thu, 19 Nov 2020 20:41:51 +0000 (21:41 +0100)]
[MemLoc] Require LocationSize argument (NFC)

When constructing a MemoryLocation by hand, require that a
LocationSize is explicitly specified. D91649 will split up
LocationSize::unknown() into two different states, and callers
should make an explicit choice regarding the kind of MemoryLocation
they want to have.

3 years agoFix rollback of first block erasure in a region.
Tres Popp [Thu, 19 Nov 2020 13:27:58 +0000 (14:27 +0100)]
Fix rollback of first block erasure in a region.

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

3 years agoReplace the equivalent code by UnionTableAddr
Jianzhou Zhao [Thu, 19 Nov 2020 04:39:25 +0000 (04:39 +0000)]
Replace the equivalent code by UnionTableAddr

UnionTableAddr is always inlined.

Reviewed-by: morehouse
Differential Revision: https://reviews.llvm.org/DD91758

3 years ago[BasicAA] Deoptimize intrinsics don't modify memory
Artur Pilipenko [Tue, 17 Nov 2020 20:16:24 +0000 (12:16 -0800)]
[BasicAA] Deoptimize intrinsics don't modify memory

Similarly to assumes and guards deoptimize intrinsics are
marked as writing to ensure proper control dependencies
but they never modify any particular memory location.

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

3 years agoMake array pointers in the CAPI const
George [Thu, 19 Nov 2020 18:45:43 +0000 (10:45 -0800)]
Make array pointers in the CAPI const

These pointers do not need to be mutable. This has an affect that generated function signatures in the Swift bindings now use `UnsafePointer` instead of `UnsafeMutablePointer`.

Reviewed By: ftynse, mehdi_amini

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

3 years ago[Lint] Use MemoryLocation
Nikita Popov [Thu, 19 Nov 2020 19:53:27 +0000 (20:53 +0100)]
[Lint] Use MemoryLocation

Instead of separately passing pointer and size, make use of
MemoryLocation. This allows us to also reuse all the existing
logic for determining the MemoryLocation correponding to an
instruction or call argument.

Not quite NFC because used locations may be more precise in some
cases.

3 years ago[libc++] Add documentation for setting up new CI jobs
Louis Dionne [Thu, 19 Nov 2020 19:22:28 +0000 (14:22 -0500)]
[libc++] Add documentation for setting up new CI jobs

3 years ago[Polly] Use LocationSize::unknown() (NFC)
Nikita Popov [Thu, 19 Nov 2020 19:25:30 +0000 (20:25 +0100)]
[Polly] Use LocationSize::unknown() (NFC)

Avoid MemoryLocation::UnknownSize when we're initializing a
LocationSize.

3 years ago[gn build] (manually) merge 1fb91fcf9cfe849
Nico Weber [Thu, 19 Nov 2020 19:24:27 +0000 (14:24 -0500)]
[gn build] (manually) merge 1fb91fcf9cfe849

3 years ago[NPM] Move more O0 pass building into PassBuilder
Arthur Eubanks [Mon, 16 Nov 2020 20:48:42 +0000 (12:48 -0800)]
[NPM] Move more O0 pass building into PassBuilder

This moves handling of alwaysinline, coroutines, matrix lowering, PGO,
and LTO-required passes into PassBuilder. Much of this is replicated
between Clang and opt. Other out-of-tree users also replicate some of
this, such as Rust [1] replicating the alwaysinline, LTO, and PGO
passes.

The LTO passes are also now run in
build(Thin)LTOPreLinkDefaultPipeline() since they are semantically
required for (Thin)LTO.

[1]: https://github.com/rust-lang/rust/blob/f5230fbf76bafd86ee4376a0e26e551df8d17fec/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp#L896

Reviewed By: tejohnson

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

3 years agoFix crash after looking up dwo_id=0 in CU index.
Jorge Gorbe Moya [Thu, 19 Nov 2020 18:59:08 +0000 (10:59 -0800)]
Fix crash after looking up dwo_id=0 in CU index.

In the current state, if getFromHash(0) is called and there's no CU with
dwo_id=0, the lookup will stop at an empty slot, then the check
`Rows[H].getSignature() != S` won't cause the lookup to fail and return
a nullptr (as it should), because the empty slot has a 0 in the
signature field, and a pointer to the empty slot will be incorrectly
returned.

This patch fixes this by using the index field in the hash entry to
check for empty slots: signature = 0 can match a valid hash but
according to the spec the index for an occupied slot will always be
non-zero.

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

3 years ago[clangd] Express ASAN interactions of tests more clearly. NFC
Sam McCall [Thu, 19 Nov 2020 19:14:40 +0000 (20:14 +0100)]
[clangd] Express ASAN interactions of tests more clearly. NFC

3 years ago[mlir][BuiltinDialect] Resolve comments from D91571
River Riddle [Thu, 19 Nov 2020 18:43:12 +0000 (10:43 -0800)]
[mlir][BuiltinDialect] Resolve comments from D91571

* Move ops to a BuiltinOps.h
* Add file comments

3 years ago[clangd] Also detect corrupt stri table size.
Sam McCall [Wed, 11 Nov 2020 21:34:46 +0000 (22:34 +0100)]
[clangd] Also detect corrupt stri table size.

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

3 years ago[OpenMP] Add support for Intel's umonitor/umwait
AndreyChurbanov [Thu, 19 Nov 2020 19:04:21 +0000 (22:04 +0300)]
[OpenMP] Add support for Intel's umonitor/umwait

Patch by tlwilmar (Terry Wilmarth)

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

3 years ago[RISCV] Add test cases for missed grevi/greviw opportunities. NFC
Fraser Cormack [Thu, 19 Nov 2020 18:39:35 +0000 (18:39 +0000)]
[RISCV] Add test cases for missed grevi/greviw opportunities. NFC

3 years ago[libc++] Mark a few tests as unsupported on older Clangs to fix bots
Louis Dionne [Thu, 19 Nov 2020 18:36:48 +0000 (13:36 -0500)]
[libc++] Mark a few tests as unsupported on older Clangs to fix bots

3 years ago[CUDA] Unbreak CUDA compilation with -std=c++20
Artem Belevich [Thu, 19 Nov 2020 18:06:57 +0000 (10:06 -0800)]
[CUDA] Unbreak CUDA compilation with -std=c++20

Standard libc++ headers in stdc++ mode include <new> which picks up
cuda_wrappers/new before any of the CUDA macros have been defined.

We can not include CUDA headers that early, so the work-around is to define
__device__ in the wrapper header itself.

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

3 years ago[mlir] Add a missing dependency to LinalgToLLVM
Stella Stamenova [Thu, 19 Nov 2020 18:30:40 +0000 (10:30 -0800)]
[mlir] Add a missing dependency to LinalgToLLVM

Generate passes.h before trying to use it

Reviewed By: mehdi_amini

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

3 years ago[llvm][IR] Add dso_local_equivalent Constant
Leonard Chan [Wed, 1 Apr 2020 22:25:04 +0000 (15:25 -0700)]
[llvm][IR] Add dso_local_equivalent Constant

The `dso_local_equivalent` constant is a wrapper for functions that represents a
value which is functionally equivalent to the global passed to this. That is, if
this accepts a function, calling this constant should have the same effects as
calling the function directly. This could be a direct reference to the function,
the `@plt` modifier on X86/AArch64, a thunk, or anything that's equivalent to the
resolved function as a call target.

When lowered, the returned address must have a constant offset at link time from
some other symbol defined within the same binary. The address of this value is
also insignificant. The name is leveraged from `dso_local` where use of a function
or variable is resolved to a symbol in the same linkage unit.

In this patch:
- Addition of `dso_local_equivalent` and handling it
- Update Constant::needsRelocation() to strip constant inbound GEPs and take
  advantage of `dso_local_equivalent` for relative references

This is useful for the [Relative VTables C++ ABI](https://reviews.llvm.org/D72959)
which makes vtables readonly. This works by replacing the dynamic relocations for
function pointers in them with static relocations that represent the offset between
the vtable and virtual functions. If a function is externally defined,
`dso_local_equivalent` can be used as a generic wrapper for the function to still
allow for this static offset calculation to be done.

See [RFC](http://lists.llvm.org/pipermail/llvm-dev/2020-August/144469.html) for more details.

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

3 years ago[MLIR][SPIRV] Rename `spv._module_end` to `spv.mlir.endmodule`
ergawy [Thu, 19 Nov 2020 18:22:37 +0000 (13:22 -0500)]
[MLIR][SPIRV] Rename `spv._module_end` to `spv.mlir.endmodule`

This commit does the renaming mentioned in the title in order to bring
'spv' dialect closer to the MLIR naming conventions.

Reviewed By: antiagainst

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

3 years ago[lldb] Fix another Python2/3 string<->bytes type error in patch-crashlog.py
Raphael Isemann [Thu, 19 Nov 2020 18:24:40 +0000 (19:24 +0100)]
[lldb] Fix another Python2/3 string<->bytes type error in patch-crashlog.py

3 years ago[MemProf] Add interface to dump profile
Teresa Johnson [Thu, 19 Nov 2020 07:14:48 +0000 (23:14 -0800)]
[MemProf] Add interface to dump profile

Add an interface so that the profile can be dumped on demand.

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

3 years ago[clang-tidy] ElseAfterReturn check wont suggest fixes if preprocessor branches are...
Nathan James [Thu, 19 Nov 2020 18:20:31 +0000 (18:20 +0000)]
[clang-tidy] ElseAfterReturn check wont suggest fixes if preprocessor branches are involved

Consider this code:
```
if (Cond) {
#ifdef X_SUPPORTED
  X();
#else
  return;
#endif
} else {
  Y();
}
Z();```

In this example, if `X_SUPPORTED` is not defined, currently we'll get a warning from the else-after-return check. However If we apply that fix, and then the code is recompiled with `X_SUPPORTED` defined, we have inadvertently changed the behaviour of the if statement due to the else being removed. Code flow when `Cond` is `true` will be:
```
X();
Y();
Z();```
 where as before the fix it was:
 ```
 X();
 Z();```

 This patch adds checks that guard against `#endif` directives appearing between the control flow interrupter and the else and not applying the fix if they are detected.

Reviewed By: aaron.ballman

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

3 years ago[RISCV] Lower GREVI and GORCI as custom nodes
Fraser Cormack [Wed, 11 Nov 2020 13:41:55 +0000 (13:41 +0000)]
[RISCV] Lower GREVI and GORCI as custom nodes

This moves the recognition of GREVI and GORCI from TableGen patterns
into a DAGCombine. This is done primarily to match "deeper" patterns in
the future, like (grevi (grevi x, 1) 2) -> (grevi x, 3).

TableGen is not best suited to matching patterns such as these as the compile
time of the DAG matchers quickly gets out of hand due to the expansion of
commutative permutations.

Reviewed By: craig.topper

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

3 years agoRevert "Reorder linalg.conv indexing_maps loop order"
Lei Zhang [Thu, 19 Nov 2020 18:13:41 +0000 (13:13 -0500)]
Revert "Reorder linalg.conv indexing_maps loop order"

This reverts commit 9b47525824df9be5ae23c39e7ce0d220d12f85e5
and falls back to the original parallel-iterators-as-leading-
dimensions convention. We can control the loop order by first
converting the named op into linalg.generic and then performing
interchange.

Reviewed By: nicolasvasilache, asaadaldien

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

3 years ago[compiler-rt] [builtins] Use _Float16 on extendhfsf2, truncdfhf2 __truncsfhf2 if...
Adhemerval Zanella [Wed, 18 Nov 2020 19:08:43 +0000 (19:08 +0000)]
[compiler-rt] [builtins] Use _Float16 on extendhfsf2, truncdfhf2 __truncsfhf2 if available

On AArch64 it allows use the native FP16 ABI (although libcalls are
not emitted for fptrunc/fpext lowering), while on other architectures
the expected current semantic is preserved (arm for instance).

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

3 years ago[compiler-rt] [builtins] Support conversion between fp16 and fp128
Adhemerval Zanella [Wed, 18 Nov 2020 17:24:04 +0000 (17:24 +0000)]
[compiler-rt] [builtins] Support conversion between fp16 and fp128

This patch adds both extendhftf2 and trunctfhf2 to support
conversion between half-precision and quad-precision floating-point
values. They are enabled iff the compiler supports _Float16.

Some notes on ARM plaforms: while __fp16 is supported on all
architectures, _Float16 is supported only for 32-bit ARM, 64-bit ARM,
and SPIR (as indicated by clang/docs/LanguageExtensions.rst).  Also,
__fp16 is a storage format and promoted to 'float' for argument passing
and 64-bit ARM supports floating-point convert precision to half as
base armv8-a instruction.

It means that although extendhfsf2, truncdfhf2 __truncsfhf2 will be
built for 64-bit ARM, they will be never used in practice (compiler
won't emit libcall to them). This patch does not change the ABI for
32-bit ARM, it will continue to pass _Float16 as uint16.

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

3 years ago[AArch64] Lower fptrunc/fpext from/to FP128t to/from FP16
Adhemerval Zanella [Wed, 18 Nov 2020 17:21:46 +0000 (17:21 +0000)]
[AArch64] Lower fptrunc/fpext from/to FP128t to/from FP16

The compiler-rt part which adds the emitted symbols is handled in
a subsequent patch.

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

3 years ago[lldb] Fix incorrect error handling in GDBRemoteCommunicationClient::SendGetSupporte...
Raphael Isemann [Thu, 19 Nov 2020 18:13:39 +0000 (19:13 +0100)]
[lldb] Fix incorrect error handling in  GDBRemoteCommunicationClient::SendGetSupportedTraceType

GDBRemoteCommunicationClient::SendGetSupportedTraceType is checking whether the
response is `!response.IsNormalResponse()` and infers from that that it is an error response.
However, it could be either "unsupported" or "error". If we get an unsupported response,
the code then tries to generate an llvm::Expected from the non-error response which then asserts.

Debugserver doesn't implement `jLLDBTraceSupportedType`, so we get an unsupported response
whenever this function is called on macOS.

This fixes the TestAproposWithProcess on macOS (where the `apropos` command will query
the CommandObjectTraceStart which then sends the trace type query package).

Reviewed By: wallace, shafik

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

3 years ago[LoopVectorize] NFC: Fix unused variable warning for MaxSafeDepDist
Sander de Smalen [Thu, 19 Nov 2020 17:02:43 +0000 (17:02 +0000)]
[LoopVectorize] NFC: Fix unused variable warning for MaxSafeDepDist

rGf571fe6df585127d8b045f8e8f5b4e59da9bbb73 led to a warning of an unused
variable for MaxSafeDepDist (written but not used). It seems this
variable and assignment can be safely removed.