platform/upstream/llvm.git
4 years ago[clang][Driver] Default to /usr/bin/ld on Solaris
Rainer Orth [Thu, 13 Aug 2020 20:42:58 +0000 (22:42 +0200)]
[clang][Driver] Default to /usr/bin/ld on Solaris

`clang` currently requires the native linker on Solaris:

  - It passes `-C` to `ld` which GNU `ld` doesn't understand.

  - To use `gld`, one needs to pass the correct `-m EMU` option to select
    the right emulation.  Solaris `ld` cannot handle that option.

So far I've worked around this by passing `-DCLANG_DEFAULT_LINKER=/usr/bin/ld`
to `cmake`.  However, if someone forgets this, it depends on the user's
`PATH` whether or not `clang` finds the correct linker, which doesn't make
for a good user experience.

While it would be nice to detect the linker flavor at runtime, this is more
involved.  Instead, this patch defaults to `/usr/bin/ld` on Solaris.  This
doesn't work on its own, however: a link fails with

  clang-12: error: unable to execute command: Executable "x86_64-pc-solaris2.11-/usr/bin/ld" doesn't exist!

I avoid this by leaving absolute paths alone in `ToolChain::GetLinkerPath`.

Tested on `amd64-pc-solaris2.11`, `sparcv9-sun-solaris2.11`, and
`x86_64-pc-linux-gnu`.

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

4 years ago[Tests] Update strncpy tests
Dávid Bolvanský [Thu, 13 Aug 2020 20:37:24 +0000 (22:37 +0200)]
[Tests] Update strncpy tests

4 years agoRe-apply "[llvm-jitlink] Don't demote unreferenced definitions in -harness mode"
Lang Hames [Thu, 13 Aug 2020 19:25:05 +0000 (12:25 -0700)]
Re-apply "[llvm-jitlink] Don't demote unreferenced definitions in -harness mode"

This reapplies commit e137b550587a85b0d9c9c539edc79de0122b6946 with
fixes for the broken test case: Non-global symbols should only be
skipped after checking that they're not referenced by the harness.

4 years ago[SLC] Optimize strncpy(a, a, C) to memcpy(a, a000, C)
Dávid Bolvanský [Thu, 13 Aug 2020 20:22:33 +0000 (22:22 +0200)]
[SLC] Optimize strncpy(a, a, C) to memcpy(a, a000, C)
Solves PR47154

4 years ago[InstSimplify] Add tests for assume with min/max intrinsic (NFC)
Nikita Popov [Thu, 13 Aug 2020 20:08:40 +0000 (22:08 +0200)]
[InstSimplify] Add tests for assume with min/max intrinsic (NFC)

If we assume one of the operands is smaller/greater, then min/max
may be simplified.

4 years agosanitizer_common: Introduce internal_madvise and start using it.
Peter Collingbourne [Thu, 13 Aug 2020 02:32:15 +0000 (19:32 -0700)]
sanitizer_common: Introduce internal_madvise and start using it.

A recent change to sanitizer_common caused us to issue the syscall
madvise(MADV_HUGEPAGE) during HWASAN initialization. This may lead to a
problem if madvise is instrumented (e.g. because libc is instrumented
or the user intercepted it). For example, on Android the syscall may
fail if the kernel does not support transparent hugepages, which leads
to an attempt to set errno in a HWASAN instrumented function. Avoid
this problem by introducing a syscall wrapper and using it to issue
this syscall.

Tested only on Linux; includes untested updates for the other
platforms.

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

4 years agoAdd "status" to the list of absl libraries.
Vy Nguyen [Wed, 12 Aug 2020 16:23:37 +0000 (12:23 -0400)]
Add "status" to the list of absl libraries.

The Abseil-NoInternalDependenciesCheck currently mistakenly triggers on any usage of internal helpers even if it is within absl/status.

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

4 years ago[SystemZ][z/OS] enable trigraphs by default on z/OS
Abhina Sreeskantharajan [Thu, 13 Aug 2020 18:33:04 +0000 (14:33 -0400)]
[SystemZ][z/OS] enable trigraphs by default on z/OS

This patch enables trigraphs on z/OS.

Reviewed By: hubert.reinterpretcast, fanbo-meng

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

4 years ago[tsan] Respect no_huge_pages_for_shadow.
Chris Kennelly [Wed, 12 Aug 2020 16:13:32 +0000 (12:13 -0400)]
[tsan] Respect no_huge_pages_for_shadow.

Disable huge pages in the TSan shadow regions when no_huge_pages_for_shadow == true (default).

Reviewed By: eugenis

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

4 years ago[libc] Add strtok_r implementation.
parallels [Thu, 13 Aug 2020 19:51:16 +0000 (15:51 -0400)]
[libc] Add strtok_r implementation.

Reviewed By: sivachandra

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

4 years ago[SVE] Lower fixed length vector integer UMIN/UMAX
Cameron McInally [Thu, 13 Aug 2020 19:47:34 +0000 (14:47 -0500)]
[SVE] Lower fixed length vector integer UMIN/UMAX

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

4 years ago[gn build] (manually) port d650cbc349ccc4 better
Nico Weber [Thu, 13 Aug 2020 19:48:03 +0000 (15:48 -0400)]
[gn build] (manually) port d650cbc349ccc4 better

4 years ago[gn build] (manually) port d650cbc349ccc4
Nico Weber [Thu, 13 Aug 2020 19:43:43 +0000 (15:43 -0400)]
[gn build] (manually) port d650cbc349ccc4

4 years ago[ORC][NFC] Fix typo in comment
Stefan Gränitz [Tue, 11 Aug 2020 11:39:54 +0000 (13:39 +0200)]
[ORC][NFC] Fix typo in comment

4 years ago[darwin][driver] fix isMacosxVersionLT minimum supported OS version check
Alex Lorenz [Thu, 13 Aug 2020 19:05:57 +0000 (12:05 -0700)]
[darwin][driver] fix isMacosxVersionLT minimum supported OS version check

The previous Driver's triple check only worked for -target, but not for -arch -mmacosx-version-min invocations

4 years ago[mlir][docs] Update/Add documentation for MLIRs Pattern Rewrite infrastructure
River Riddle [Thu, 13 Aug 2020 19:05:04 +0000 (12:05 -0700)]
[mlir][docs] Update/Add documentation for MLIRs Pattern Rewrite infrastructure

This infrastructure has evolved a lot over the course of MLIRs lifetime, and has never truly been documented outside of rationale or proposals. This revision aims to document the infrastructure and user facing API, with the rationale specific portions moved to the Rationale folder and updated.

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

4 years ago[mlir][DialectConversion] Update the documentation for dialect conversion
River Riddle [Thu, 13 Aug 2020 19:04:57 +0000 (12:04 -0700)]
[mlir][DialectConversion] Update the documentation for dialect conversion

This revision updates the documentation for dialect conversion, as many concepts have changed/evolved over time.

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

4 years ago[ORC] cloneToNewContext() can work with a const-ref to ThreadSafeModule
Stefan Gränitz [Sun, 2 Aug 2020 12:37:33 +0000 (14:37 +0200)]
[ORC] cloneToNewContext() can work with a const-ref to ThreadSafeModule

4 years ago[ORC] Fix SymbolLookupSet::containsDuplicates()
Stefan Gränitz [Sun, 2 Aug 2020 12:36:02 +0000 (14:36 +0200)]
[ORC] Fix SymbolLookupSet::containsDuplicates()

4 years ago[LLDB] Fix how ValueObjectChild handles bit-fields stored in a Scalar in UpdateValue()
shafik [Thu, 13 Aug 2020 17:49:40 +0000 (10:49 -0700)]
[LLDB] Fix how ValueObjectChild handles bit-fields stored in a Scalar in UpdateValue()

When bit-field data was stored in a Scalar in ValueObjectChild during UpdateValue()
it was extracting the bit-field value. Later on in lldb_private::DumpDataExtractor(…)
we were again attempting to extract the bit-field. Which would then not obtain the
correct value. This will remove the extra extraction in UpdateValue().
We hit this specific case when values are passed in registers, which we could only
reproduce in an optimized build.

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

4 years ago[elfabi] Move llvm-elfabi related code to InterfaceStub library
Haowei Wu [Tue, 11 Aug 2020 18:44:22 +0000 (11:44 -0700)]
[elfabi] Move llvm-elfabi related code to InterfaceStub library

This change moves elfabi related code to llvm/InterfaceStub library
so it can be shared by multiple llvm tools without causing cyclic
dependencies.

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

4 years agoRevert "[llvm-jitlink] Don't demote unreferenced definitions in -harness mode."
Lang Hames [Thu, 13 Aug 2020 18:44:42 +0000 (11:44 -0700)]
Revert "[llvm-jitlink] Don't demote unreferenced definitions in -harness mode."

This reverts commit e137b550587a85b0d9c9c539edc79de0122b6946.

This commit broke a test case. Reverting while I investigate.

4 years ago[AMDGPU] Inhibit SDWA if target instruction has FI
Stanislav Mekhanoshin [Thu, 13 Aug 2020 18:15:44 +0000 (11:15 -0700)]
[AMDGPU] Inhibit SDWA if target instruction has FI

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

4 years ago[AMDGPU] Fix misleading SDWA verifier error. NFC.
Stanislav Mekhanoshin [Thu, 13 Aug 2020 18:22:01 +0000 (11:22 -0700)]
[AMDGPU] Fix misleading SDWA verifier error. NFC.

The old error from GFX9 shall be updated to GFX9+.

4 years agoFix PR45442: Bail out when MemorySSA information is not available
Aditya Kumar [Thu, 13 Aug 2020 07:06:22 +0000 (00:06 -0700)]
Fix PR45442: Bail out when MemorySSA information is not available

Reviewers: sebpop, uabelho, fhahn
Reviewed by: fhahn

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

4 years ago[Tests] Removed debug copy command
Dávid Bolvanský [Thu, 13 Aug 2020 18:21:19 +0000 (20:21 +0200)]
[Tests] Removed debug copy command

4 years ago[Diagnostics] Skip var decl of structs for -Wstring-concatenation
Dávid Bolvanský [Thu, 13 Aug 2020 18:19:21 +0000 (20:19 +0200)]
[Diagnostics] Skip var decl of structs for -Wstring-concatenation

4 years ago[llvm-jitlink] Don't demote unreferenced definitions in -harness mode.
Lang Hames [Thu, 13 Aug 2020 03:44:05 +0000 (20:44 -0700)]
[llvm-jitlink] Don't demote unreferenced definitions in -harness mode.

Demoting unreferenced externals is unsafe if multiple interdependent test
objects are used, including objects loaded from archives.

4 years ago[JITLink][MachO] Return an error when MachO TLV relocations are encountered.
Lang Hames [Thu, 13 Aug 2020 00:43:28 +0000 (17:43 -0700)]
[JITLink][MachO] Return an error when MachO TLV relocations are encountered.

MachO TLV relocations aren't supported yet. Error out rather than falling
through to llvm_unreachable.

4 years ago[llvm-libtool-darwin] Add support for -arch_only
Sameer Arora [Tue, 28 Jul 2020 16:50:51 +0000 (09:50 -0700)]
[llvm-libtool-darwin] Add support for -arch_only

Add support for -arch_only option for llvm-libtool-darwin. This diff
also adds support for accepting universal files as input and flattening
them to create the required static library. Supports input universal
files contaning both Mach-O object files or archives.

Differences from cctools' libtool:
- `-arch_only` can be specified multiple times
- archives containing universal files are considered invalid (libtool
allows such archives)

Reviewed by jhenderson, smeenai

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

4 years ago[flang][openacc] Handle optional end directive in combined construct
Valentin Clement [Thu, 13 Aug 2020 18:04:43 +0000 (14:04 -0400)]
[flang][openacc] Handle optional end directive in combined construct

OpenACC combined construct can have an optional end directive. This patch handle this
case in the parsing/unparsing with a canonicalization step. Unlike OmpEndLoopDirective,
this doesn't need a special treatment in the pre-fir tree as there is no clause attached to
a AccEndCombinedDirective.

Reviewed By: klausler

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

4 years ago[llvm-libtool-darwin] Refactor ArchiveWriter
Sameer Arora [Wed, 29 Jul 2020 14:40:11 +0000 (07:40 -0700)]
[llvm-libtool-darwin] Refactor ArchiveWriter

Refactoring function `writeArchive` in ArchiveWriter. Added a new
function `writeArchiveBuffer` that returns the archive in a memory
buffer instead of writing it out to the disk. This refactor is necessary
so as to allow `llvm-libtool-darwin` to write universal files containing
archives.

Reviewed by jhenderson, MaskRay, smeenai

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

4 years ago[BPI] Improve static heuristics for integer comparisons
Dávid Bolvanský [Thu, 13 Aug 2020 10:45:14 +0000 (12:45 +0200)]
[BPI] Improve static heuristics for integer comparisons

Similarly as for pointers, even for integers a == b is usually false.

GCC also uses this heuristic.

Reviewed By: ebrevnov

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

4 years ago[llvm-install-name-tool] Add more documentation
Sameer Arora [Mon, 10 Aug 2020 01:58:02 +0000 (18:58 -0700)]
[llvm-install-name-tool] Add more documentation

Add documentation for the remaining options of
`llvm-install-name-tool`.

Reviewed by jhenderson, smeenai

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

4 years ago[flang] Descriptor-based I/O using wrong size for contiguous unformatted I/O
peter klausler [Wed, 12 Aug 2020 23:25:26 +0000 (16:25 -0700)]
[flang] Descriptor-based I/O using wrong size for contiguous unformatted I/O

The descriptor-based I/O routine was using the size of the descriptor
rather than the size of the described data for the transfer.  Fix,
and add a comment to the relevant API.

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

4 years ago[X86][SSE] Add HADD combine regression case from rG9bd97d036398
Simon Pilgrim [Thu, 13 Aug 2020 15:56:08 +0000 (16:56 +0100)]
[X86][SSE] Add HADD combine regression case from rG9bd97d036398

rG9bd97d036398 caused a miscompile of this internal test case

4 years ago[lldb] Set the launch flags to GetLaunchInfo().GetLaunchFlags()
Jonas Devlieghere [Thu, 13 Aug 2020 17:23:52 +0000 (10:23 -0700)]
[lldb] Set the launch flags to GetLaunchInfo().GetLaunchFlags()

Instead of clearing the launch flags, always pass the target's current
launch flags.

4 years ago[mlir] Test CallOp STD->LLVM conversion.
Alexander Belyaev [Thu, 13 Aug 2020 16:53:07 +0000 (18:53 +0200)]
[mlir] Test CallOp STD->LLVM conversion.

This exercises the corner case that was fixed in
https://reviews.llvm.org/rG8979a9cdf226066196f1710903d13492e6929563.

The bug can be reproduced when there is a @callee with a custom type argument and @caller has a producer of this argument passed to the @callee.

Example:
func @callee(!test.test_type) -> i32
func @caller() -> i32 {
  %arg = "test.type_producer"() : () -> !test.test_type
  %out = call @callee(%arg) : (!test.test_type) -> i32
  return %out : i32
}

Even though there is a type conversion for !test.test_type, the output IR (before the fix) contained a DialectCastOp:

module {
  llvm.func @callee(!llvm.ptr<i8>) -> !llvm.i32
  llvm.func @caller() -> !llvm.i32 {
    %0 = llvm.mlir.null : !llvm.ptr<i8>
    %1 = llvm.mlir.cast %0 : !llvm.ptr<i8> to !test.test_type
    %2 = llvm.call @callee(%1) : (!test.test_type) -> !llvm.i32
    llvm.return %2 : !llvm.i32
  }
}

instead of

module {
  llvm.func @callee(!llvm.ptr<i8>) -> !llvm.i32
  llvm.func @caller() -> !llvm.i32 {
    %0 = llvm.mlir.null : !llvm.ptr<i8>
    %1 = llvm.call @callee(%0) : (!llvm.ptr<i8>) -> !llvm.i32
    llvm.return %1 : !llvm.i32
  }
}

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

4 years ago[ARM] Mark VMINNMA/VMAXNMA as commutative
David Green [Thu, 13 Aug 2020 17:01:11 +0000 (18:01 +0100)]
[ARM] Mark VMINNMA/VMAXNMA as commutative

These operations take Qda and Rn register operands, which are
commutative so long as the instruction is not predicated.

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

4 years ago[flang] Implement shape analysis of TRANSFER intrinsic function result
peter klausler [Wed, 12 Aug 2020 23:38:28 +0000 (16:38 -0700)]
[flang] Implement shape analysis of TRANSFER intrinsic function result

The shape (esp. the size) of the result of a call to TRANSFER
is implemented according to the definition in the standard.

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

4 years ago[lldb] Skip TestStepScripted with reproducers
Jonas Devlieghere [Thu, 13 Aug 2020 16:41:52 +0000 (09:41 -0700)]
[lldb] Skip TestStepScripted with reproducers

Some of the test methods were already skipped because of an unexpected
packet. The test started failing after it was expanded. Skip the whole
test with reproducers so we don't have to add the decorator for every
method.

4 years ago[SVE] Lower fixed length vector integer SMIN/SMAX
Cameron McInally [Thu, 13 Aug 2020 16:00:37 +0000 (11:00 -0500)]
[SVE] Lower fixed length vector integer SMIN/SMAX

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

4 years ago[clangd] Move clang-tidy check modifications into ClangdServer
Kadir Cetinkaya [Mon, 6 Jul 2020 13:44:16 +0000 (15:44 +0200)]
[clangd] Move clang-tidy check modifications into ClangdServer

Summary:
This enables sharing the logic between standalone clangd and embedders
of it. The new approach should be same performance-wise, as it is only called
once per addDocument call.

This patch also introduces a blacklisting code path for disabling crashy or
high-noise tests, until we figure out a way to make them work with clangd-setup.

The biggest difference is the way we make use of preambles, hence those checks
can't see directives coming from the preamble section of the file. The second
thing is the fact that code might-not be compiling while clangd is trying to
build an AST, hence some checks might choke on those incomplete ASTs.

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, aaron.ballman, cfe-commits

Tags: #clang

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

4 years ago[clangd] Send EOF before resetting diagnostics consumer
Kadir Cetinkaya [Sun, 5 Jul 2020 19:12:11 +0000 (21:12 +0200)]
[clangd] Send EOF before resetting diagnostics consumer

Summary:
Some clang-tidy checkers, e.g. llvm-include-order can emit diagnostics
at this callback (as mentioned in the comments).

Clangd was resetting diag consumer to IgnoreDiags before sending EOF, hence we
were unable to emit diagnostics for such checkers.

This patch changes the order of that reset and preprocosser event to make sure
we emit that diag.

Fixes https://github.com/clangd/clangd/issues/314.

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

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

4 years agoFix PR45442: Bail out when MemorySSA information is not available
Aditya Kumar [Thu, 13 Aug 2020 07:06:22 +0000 (00:06 -0700)]
Fix PR45442: Bail out when MemorySSA information is not available

4 years agoAdd cold attribute to one time construction APIs
Aditya Kumar [Thu, 13 Aug 2020 05:11:50 +0000 (22:11 -0700)]
Add cold attribute to one time construction APIs

_cxa_guard_acquire is used for only one purpose,
namely guarding local static variable initialization,
and since that purpose is definitionally cold,
it should be attributed as cold

Reviewed By: ldionne

Reviewers: mclow.lists, ldionne, jfb, yfeldblum

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

4 years ago[VectorCombine] Fix for non-zero addrspace when creating vector load from scalar...
Bjorn Pettersson [Thu, 13 Aug 2020 15:43:12 +0000 (17:43 +0200)]
[VectorCombine] Fix for non-zero addrspace when creating vector load from scalar load

This is a fixup to commit 43bdac290663f4424f9fb, to make sure the
address space from the original load pointer is retained in the
vector pointer.

Resolves problem with
  Assertion `castIsValid(op, S, Ty) && "Invalid cast!"' failed.
due to address space mismatch.

Reviewed By: spatel

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

4 years ago[InstCombine] Handle gc.relocate(null) in one iteration
Serguei Katkov [Wed, 12 Aug 2020 07:25:18 +0000 (14:25 +0700)]
[InstCombine] Handle gc.relocate(null) in one iteration

InstCombine adds users of transformed instruction to working list to
process on the same iteration. However gc.relocate may have a hidden
user (next gc.relocate) which is connected through gc.statepoint intrinsic and
there is no direct def-use chain between them.

In this case if the next gc.relocation is already processed it will not be added
to worklist and will not be able to be processed on the same iteration.
Let's we have the following case:
A = gc.relocate(null)
B = statepoint(A)
C = gc.relocate(B, hidden(A))
If C is already considered then after replacement of A with null, statepoint B
instruction will be added to the queue but not C.
C can be processed only on the next iteration.

If the chain of relocation is pretty long the many iteration may be required.
This change is to reduce the number of iteration to meet the latest changes
related to reducing infinite loop threshold.

This is a quick (not best) fix. In the follow up patches I plan to move gc relocation
handling into statepoint handler. This should also help to remove unused gc live
entries in statepoint bundle.

Reviewers: reames, dantrushin
Reviewed By: reames
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D75598

4 years ago[clangd] Extract BackgroundIndex::Options struct. NFC
Sam McCall [Thu, 13 Aug 2020 16:01:47 +0000 (18:01 +0200)]
[clangd] Extract BackgroundIndex::Options struct. NFC

I've dropped the background context parameter, since we in practice just pass the
current context there, and we now have a different way to specify context too.
While here, clean up a couple of comments.

Reviewed By: kadircet

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

4 years ago[ELF] --gdb-index: skip SHF_GROUP .debug_info
Fangrui Song [Thu, 13 Aug 2020 03:50:59 +0000 (20:50 -0700)]
[ELF] --gdb-index: skip SHF_GROUP .debug_info

-gdwarf-5 -fdebug-types-section may produce multiple .debug_info sections.  All
except one are type units (.debug_types before DWARF v5). When constructing
.gdb_index, we should ignore these type units. We use a simple heuristic: the
compile unit does not have the SHF_GROUP flag. (This needs to be revisited if
people place compile unit .debug_info in COMDAT groups.)

This issue manifests as a data race: because an object file may have multiple
.debug_info sections, we may concurrently construct `LLDDwarfObj` for the same
file in multiple threads. The threads may access `InputSectionBase::data()`
concurrently on the same input section. `InputSectionBase::data()` does a lazy
uncompress() and rewrites the member variable `rawData`. A thread running zlib
`inflate()` (transitively called by uncompress()) on a buffer with `rawData`
tampered by another thread may fail with `uncompress failed: zlib error: Z_DATA_ERROR`.

Even if no data race occurred in an optimistic run, if there are N .debug_info,
one CU entry and its address ranges will be replicated N times. The result
.gdb_index can be much larger than a correct one.

The new test gdb-index-dwarf5-type-unit.s actually has two compile units. This
cannot be produced with regular approaches (it can be produced with -r
--unique). This is used to demonstrate that the .gdb_index construction code
only considers the last non-SHF_GROUP .debug_info

Reviewed By: grimar

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

4 years ago[flang] Fix assert on character literal substrings as arguments
Peter Steinfeld [Thu, 13 Aug 2020 15:07:58 +0000 (08:07 -0700)]
[flang] Fix assert on character literal substrings as arguments

Character literal substrings used as arguments were causing asserts.  This
happened when the code was trying to get the DynamicType of the substring.  We
were only recording the DynamicType of the Designator on which the substring
was based.  For character literal substrings, the Designator was a character
literal, and we weren't handling getting its type.

I fixed this by changing the `GetType()` method for `DynamicType` to check to
see if we were getting the type of a `Substring` and calculating the type of
the substring by getting the number of bytes in an element of the string.

I also changed the test `resolve49.f90` with some tests, one of which causes
the original crash.

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

4 years ago[flang] Correct manipulation of mixed complex expressions
peter klausler [Wed, 12 Aug 2020 23:35:26 +0000 (16:35 -0700)]
[flang] Correct manipulation of mixed complex expressions

Ensure that mixed complex expressions (one operand complex,
the other not) are properly manipulated; add test.

4 years ago[flang] Ensure Preprocessor::Define saves macro names correctly
peter klausler [Wed, 12 Aug 2020 23:20:20 +0000 (16:20 -0700)]
[flang] Ensure Preprocessor::Define saves macro names correctly

This fixes problems with macros defined with -D on the command line
and predefined macros defined in the throwaway driver program.

4 years ago[flang] Correct the default value for PAD= to PAD='YES'.
peter klausler [Wed, 12 Aug 2020 23:09:51 +0000 (16:09 -0700)]
[flang] Correct the default value for PAD= to PAD='YES'.

4 years ago[clangd] Clean up old test fixture/names a little. NFC
Sam McCall [Thu, 13 Aug 2020 15:42:58 +0000 (17:42 +0200)]
[clangd] Clean up old test fixture/names a little. NFC

4 years ago[AArch64][x86] add tests for x/sqrt(x); NFC
Sanjay Patel [Thu, 13 Aug 2020 14:52:38 +0000 (10:52 -0400)]
[AArch64][x86] add tests for x/sqrt(x); NFC

4 years ago[ELF] -r: allow SHT_X86_64_UNWIND to be merged into SHT_PROGBITS
Fangrui Song [Thu, 13 Aug 2020 03:14:00 +0000 (20:14 -0700)]
[ELF] -r: allow SHT_X86_64_UNWIND to be merged into SHT_PROGBITS

* For .cfi_*, GCC/GNU as emits SHT_PROGBITS type .eh_frame sections.
* Since rL252300, clang emits SHT_X86_64_UNWIND type .eh_frame sections
  (originated from Solaris, documented in the x86-64 psABI).
* Some assembly use `.section .eh_frame,"a",@unwind` to generate
  SHT_X86_64_UNWIND .eh_frame sections.

In a non-relocatable link, input .eh_frame are combined and there is
only one SyntheticSection .eh_frame in the output section, so the
"section type mismatch" diagnostic does not fire.

In a relocatable link, there is no SyntheticSection .eh_frame. .eh_frame of
mixed types can trigger the diagnostic. This patch fixes it by adding another
special case 0x70000001 (= SHT_X86_64_UNWIND) to canMergeToProgbits().

    ld.lld -r gcc.o clang.o => error: section type mismatch for .eh_frame

There was a discussion "RFC: Usefulness of SHT_X86_64_UNWIND" on the x86-64-abi
mailing list. Folks are not wild about making the psABI value 0x70000001 into
gABI, but a few think defining 0x70000001 for .eh_frame may be a good idea for a
new architecture.

Reviewed By: grimar

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

4 years ago[llvm-objdump] Change symbol name/PLT decoding errors to warnings
Fangrui Song [Thu, 13 Aug 2020 15:13:26 +0000 (08:13 -0700)]
[llvm-objdump] Change symbol name/PLT decoding errors to warnings

If the referenced symbol of a J[U]MP_SLOT is invalid (e.g. symbol index 0), llvm-objdump -d will bail out:

```
error: 'a': st_name (0x326600) is past the end of the string table of size 0x7
```

where 0x326600 is the st_name field of the first entry past the end of .symtab

Change it to a warning to continue dumping.
`X86/plt.test` uses a prebuilt executable, so I pick `ELF/AArch64/plt.test`
which has a YAML input and can be easily modified.

Reviewed By: jhenderson

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

4 years ago[libc++] Ensure the CI scripts can find Ninja
Louis Dionne [Thu, 13 Aug 2020 15:10:13 +0000 (11:10 -0400)]
[libc++] Ensure the CI scripts can find Ninja

Ninja isn't necessarily installed on macOS out of the box, so make sure
we use the SDK Ninja instead of relying on one being available on the
system.

4 years ago[clangd] Revert "[clangd] Fix crash-bug in preamble indexing when using modules."
Adam Czachorowski [Thu, 13 Aug 2020 14:59:34 +0000 (16:59 +0200)]
[clangd] Revert "[clangd] Fix crash-bug in preamble indexing when using modules."

This reverts commit 4061d9e42cff621462931ac7df9666806c77a237.
Tests are failing in some configuration, likely due to not cleaning up
module cache path before running the test.

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

4 years ago[analyzer] Fix crash with pointer to members values
Valeriy Savchenko [Wed, 12 Aug 2020 08:04:56 +0000 (11:04 +0300)]
[analyzer] Fix crash with pointer to members values

This fix unifies all of the different ways we handled pointer to
members into one.  The crash was caused by the fact that the type
of pointer-to-member values was `void *`, and while this works
for the vast majority of cases it breaks when we actually need
to explain the path for the report.

rdar://problem/64202361

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

4 years agoFix unused variable warning. NFC.
Simon Pilgrim [Thu, 13 Aug 2020 14:43:20 +0000 (15:43 +0100)]
Fix unused variable warning. NFC.

Reduce the dyn_cast<> to a isa<> as that's all non-assert builds require, and move the cast<> inside the assert.

4 years agorG9bd97d0363987b582 - Revert "[X86][SSE] Fold HOP(SHUFFLE(X),SHUFFLE(Y)) --> SHUFFLE...
Simon Pilgrim [Thu, 13 Aug 2020 13:48:51 +0000 (14:48 +0100)]
rG9bd97d0363987b582 - Revert "[X86][SSE] Fold HOP(SHUFFLE(X),SHUFFLE(Y)) --> SHUFFLE(HOP(X,Y))"

This reverts commit 9bd97d0363987b582e4a92b354b02e86ac068407.

Seeing some codegen issues in internal testing.

4 years agoclang: Fix minor grammar-o in diag added in c354b2e3b
Nico Weber [Thu, 13 Aug 2020 14:06:27 +0000 (10:06 -0400)]
clang: Fix minor grammar-o in diag added in c354b2e3b

4 years ago[mlir][openacc] Introduce OpenACC dialect with parallel, data, loop operations
Valentin Clement [Wed, 12 Aug 2020 15:48:24 +0000 (11:48 -0400)]
[mlir][openacc] Introduce OpenACC dialect with parallel, data, loop operations

This patch introduces the OpenACC dialect with three operation defined
parallel, data and loop operations with custom parsing and printing.

OpenACC dialect RFC can be find here: https://llvm.discourse.group/t/rfc-openacc-dialect/546/2

Reviewed By: rriddle, kiranchandramohan

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

4 years ago[libc++][test] Fix another -Wstring-concatenation warning
Louis Dionne [Thu, 13 Aug 2020 13:51:20 +0000 (09:51 -0400)]
[libc++][test] Fix another -Wstring-concatenation warning

4 years ago[MLIR] Support for ReturnOps in memref map layout normalization
avarmapml [Thu, 13 Aug 2020 13:39:22 +0000 (19:09 +0530)]
[MLIR] Support for ReturnOps in memref map layout normalization

-- This commit handles the returnOp in memref map layout normalization.
-- An initial filter is applied on FuncOps which helps us know which functions can be
   a suitable candidate for memref normalization which doesn't lead to invalid IR.
-- Handles memref map normalization for external function assuming the external function
   is normalizable.

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

4 years ago[gn build] Port d17437d2bd8
LLVM GN Syncbot [Thu, 13 Aug 2020 13:35:44 +0000 (13:35 +0000)]
[gn build] Port d17437d2bd8

4 years agoDAG: Don't pass 0 alignment value to allowsMisalignedMemoryAccesses
Matt Arsenault [Thu, 13 Aug 2020 00:02:05 +0000 (20:02 -0400)]
DAG: Don't pass 0 alignment value to allowsMisalignedMemoryAccesses

I think not unconditionally passing getDstAlign is broken, but leave
that for another change.

4 years ago[SyntaxTree] Clean `#includes` in `TreeTestBase.h`
Eduardo Caldas [Thu, 13 Aug 2020 12:27:02 +0000 (12:27 +0000)]
[SyntaxTree] Clean `#includes` in `TreeTestBase.h`

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

4 years ago[SyntaxTree] Split `TreeTest.cpp`
Eduardo Caldas [Thu, 13 Aug 2020 10:13:59 +0000 (10:13 +0000)]
[SyntaxTree] Split `TreeTest.cpp`

We extract the test infrastructure into `TreeTestBase.h` and split the
tests into `MutationsTest.cpp` and `BuildTreeTest.cpp`

4 years ago[NFC] Add test case showing the miscompile being fixed by D83507
Roman Lebedev [Thu, 13 Aug 2020 13:04:34 +0000 (16:04 +0300)]
[NFC] Add test case showing the miscompile being fixed by D83507

See https://reviews.llvm.org/D83507

4 years ago[InstCombine] Fix incorrect Modified status
David Stenberg [Thu, 13 Aug 2020 06:55:39 +0000 (08:55 +0200)]
[InstCombine] Fix incorrect Modified status

When removing instructions from unreachable blocks, and only debug info
intrinsics were removed, InstCombine could incorrectly return a false
Modified status.

This is fixed by making removeAllNonTerminatorAndEHPadInstructions()
also return how many debug info intrinsics that were removed, and take
that into account.

This was caught using the check introduced by D80916.

Reviewed By: majnemer

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

4 years agoIntroduce ns_error_domain attribute.
Michael Forster [Thu, 13 Aug 2020 12:54:02 +0000 (14:54 +0200)]
Introduce ns_error_domain attribute.

ns_error_domain can be used by, e.g. NS_ERROR_ENUM, in order to
identify a global declaration representing the domain constant.

Introduces the attribute, Sema handling, diagnostics, and test case.

This is cherry-picked from https://github.com/llvm/llvm-project-staging/commit/a14779f504b02ad0e4dbc39d6d10cadc7ed4cfd0
and adapted to updated Clang APIs.

Reviewed By: gribozavr2, aaron.ballman

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

4 years ago[AMDGPU] Fix missed SI_RETURN_TO_EPILOG in pre-emit peephole
Carl Ritson [Thu, 13 Aug 2020 11:56:32 +0000 (20:56 +0900)]
[AMDGPU] Fix missed SI_RETURN_TO_EPILOG in pre-emit peephole

SIPreEmitPeephole does not process all terminators, which means
it can fail to handle SI_RETURN_TO_EPILOG if immediately preceeded
by a branch to the early exit block.

Reviewed By: rampitec

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

4 years ago[libc++][test] Fix -Wstring-concatenation warnings
Louis Dionne [Thu, 13 Aug 2020 12:48:12 +0000 (08:48 -0400)]
[libc++][test] Fix -Wstring-concatenation warnings

4 years agoSupport the standards-based dates for __has_c_attribute
Aaron Ballman [Thu, 13 Aug 2020 12:47:40 +0000 (08:47 -0400)]
Support the standards-based dates for __has_c_attribute

WG14 N2481 was adopted with minor modifications at the latest WG14 meetings.
The only modification to the paper was to correct the date for the deprecated
attribute to be 201904L (the corrected date value will be present in WG14
N2553 when it gets published).

4 years ago[libc++] Use CMake interface targets to setup benchmark flags
Louis Dionne [Wed, 12 Aug 2020 21:56:16 +0000 (17:56 -0400)]
[libc++] Use CMake interface targets to setup benchmark flags

This also fixes an issue where the benchmarks were being built with C++14
instead of C++17, as they should be.

4 years agoRevert "[BPI] Improve static heuristics for integer comparisons"
Dávid Bolvanský [Thu, 13 Aug 2020 12:37:07 +0000 (14:37 +0200)]
Revert "[BPI] Improve static heuristics for integer comparisons"

This reverts commit 44587e2f7e732604cd6340061d40ac21e7e188e5. Sanitizer tests need to be updated.

4 years ago[clangd] Express dumpAST in tests as a customAction()
Sam McCall [Thu, 13 Aug 2020 12:27:15 +0000 (14:27 +0200)]
[clangd] Express dumpAST in tests as a customAction()

4 years ago[BPI] Improve static heuristics for integer comparisons
Dávid Bolvanský [Thu, 13 Aug 2020 10:45:14 +0000 (12:45 +0200)]
[BPI] Improve static heuristics for integer comparisons

Similarly as for pointers, even for integers a == b is usually false.

GCC also uses this heuristic.

Reviewed By: ebrevnov

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

4 years ago[lldb][NFC] Use llvm::is_contained instead of std::find in a few places
Raphael Isemann [Thu, 13 Aug 2020 11:44:25 +0000 (13:44 +0200)]
[lldb][NFC] Use llvm::is_contained instead of std::find in a few places

4 years ago[X86][SSE] IsElementEquivalent - add HOP(X,X) support
Simon Pilgrim [Thu, 13 Aug 2020 11:42:43 +0000 (12:42 +0100)]
[X86][SSE] IsElementEquivalent - add HOP(X,X) support

For HADD/HSUB/PACKS ops with repeated operands the lower/upper half element of each lane are known to be equivalent

4 years ago[SVE] Lower fixed length vector integer shifts.
Paul Walker [Mon, 10 Aug 2020 18:02:02 +0000 (19:02 +0100)]
[SVE] Lower fixed length vector integer shifts.

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

4 years ago[SVE][CodeGen] Legalisation of EXTRACT_VECTOR_ELT for scalable vectors
Kerry McLaughlin [Thu, 13 Aug 2020 10:25:43 +0000 (11:25 +0100)]
[SVE][CodeGen] Legalisation of EXTRACT_VECTOR_ELT for scalable vectors

This patch changes SplitVecOp_EXTRACT_VECTOR_ELT to work correctly
for scalable vectors and also fixes an a bug in DAGCombiner where
the scalable property is dropped in visitTRUNCATE when attempting
to fold an extract + a truncate.

Reviewed By: efriedma

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

4 years ago[ARM][MVE] Fix for tail predication for loops containing MVE gather/scatters
Anna Welker [Thu, 13 Aug 2020 11:22:43 +0000 (12:22 +0100)]
[ARM][MVE] Fix for tail predication for loops containing MVE gather/scatters

Fix to include non-predicated version of write-back gather in special case
treatment for deducting the instruction type.
(This is fixing https://reviews.llvm.org/D85138 for corner cases)

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

4 years agoBranchFolding.cpp - removes includes already included by BranchFolding.h. NFC.
Simon Pilgrim [Thu, 13 Aug 2020 11:14:18 +0000 (12:14 +0100)]
BranchFolding.cpp - removes includes already included by BranchFolding.h. NFC.

4 years ago[DSE,MSSA] Fix crash when using tryToMergePartialOverlappingStores.
Florian Hahn [Thu, 13 Aug 2020 10:56:40 +0000 (11:56 +0100)]
[DSE,MSSA] Fix crash when using tryToMergePartialOverlappingStores.

We are re-using tryToMergePartialOverlappingStores, which requires
earlier to domiante Later. In the long run,
tryToMergeParialOverlappingStores should be re-written using MemorySSA.

Fixes PR46513.

4 years ago[llvm-readobj/elf] - Cleanup helpers that are used to print segment types. NFCI.
Georgii Rymar [Wed, 12 Aug 2020 11:47:15 +0000 (14:47 +0300)]
[llvm-readobj/elf] - Cleanup helpers that are used to print segment types. NFCI.

`getElfSegmentType` and `getElfPtType` are methods that are used for printing
segment types for LLVM and GNU styles accordingly.

This patch does a cleanup and simplification that allows to avoid
the code duplication and to get rid of one macro.

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

4 years ago[SVE] Lower fixed length vector integer ISD::SETCC operations.
Paul Walker [Tue, 19 May 2020 19:14:17 +0000 (20:14 +0100)]
[SVE] Lower fixed length vector integer ISD::SETCC operations.

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

4 years agoRevert "[BPI] Improve static heuristics for integer comparisons"
Dávid Bolvanský [Thu, 13 Aug 2020 10:58:45 +0000 (12:58 +0200)]
Revert "[BPI] Improve static heuristics for integer comparisons"

This reverts commit 385c9d673f217e176b18e7bf6fe055154ac589c6.

4 years ago[SVE] Lower fixed length integer extend operations.
Paul Walker [Thu, 6 Aug 2020 17:14:40 +0000 (18:14 +0100)]
[SVE] Lower fixed length integer extend operations.

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

4 years ago[llvm-readobj/elf][test] - Refine --headers testing and the related code comment.
Georgii Rymar [Wed, 12 Aug 2020 12:49:37 +0000 (15:49 +0300)]
[llvm-readobj/elf][test] - Refine --headers testing and the related code comment.

Specifying --headers is equivalent to setting --file-headers,
--program-headers and --section-headers at the same time.

The existent test case uses a precompiled object and doesn't test the
output properly. This patch fixes it.

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

4 years ago[BPI] Improve static heuristics for integer comparisons
Dávid Bolvanský [Thu, 13 Aug 2020 10:45:14 +0000 (12:45 +0200)]
[BPI] Improve static heuristics for integer comparisons

Similarly as for pointers, even for integers a == b is usually false.

GCC also uses this heuristic.

Reviewed By: ebrevnov

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

4 years agoSplitKit.cpp - removes includes already included by SplitKit.h. NFC.
Simon Pilgrim [Thu, 13 Aug 2020 10:43:12 +0000 (11:43 +0100)]
SplitKit.cpp - removes includes already included by SplitKit.h. NFC.

Don't duplicate includes already provided by the module header.

4 years agoDwarfDebug.cpp - removes includes already included by DwarfDebug.h. NFC.
Simon Pilgrim [Thu, 13 Aug 2020 10:23:45 +0000 (11:23 +0100)]
DwarfDebug.cpp - removes includes already included by DwarfDebug.h. NFC.

Don't duplicate includes already provided by the module header.

4 years ago[DWARFYAML] Replace InitialLength with Format and Length. NFC.
Xing GUO [Thu, 13 Aug 2020 10:37:58 +0000 (18:37 +0800)]
[DWARFYAML] Replace InitialLength with Format and Length. NFC.

This change replaces the InitialLength of pub-tables with Format and
Length. All the InitialLength fields have been removed.

Reviewed By: jhenderson

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

4 years ago[lldb][NFC] Fix indentation in TCPSocket::CloseListenSockets
Raphael Isemann [Thu, 13 Aug 2020 10:28:51 +0000 (12:28 +0200)]
[lldb][NFC] Fix indentation in TCPSocket::CloseListenSockets

4 years ago[clangd] Add ClangdServer::customAction() extension point
Sam McCall [Thu, 13 Aug 2020 08:43:51 +0000 (10:43 +0200)]
[clangd] Add ClangdServer::customAction() extension point

This lets basic AST-consuming actions be defined outside clangdserver.
(it essentially exposes TUScheduler::runWithAST).

Two use cases for now:
 - replace ClangdServer::dumpAST, which doesn't really belong in the public
   interface (a followup patch will do this)
 - allow embedders to add/experiment with extra features
   (e.g. I know some who want to try crazy AST+ML code completion...)

Maybe in the future we should use this sort of mechanism to make ClangdServer
less of a monolith, but that's not in scope for now.
This would probably require a richer and more carefully-thought-out API.

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

4 years ago[SVE][CodeGen] Fix scalable vector issues in DAGTypeLegalizer::GenWidenVectorStores
David Sherwood [Fri, 31 Jul 2020 12:56:02 +0000 (13:56 +0100)]
[SVE][CodeGen] Fix scalable vector issues in DAGTypeLegalizer::GenWidenVectorStores

In DAGTypeLegalizer::GenWidenVectorStores the algorithm assumes it only
ever deals with fixed width types, hence the offsets for each individual
store never take 'vscale' into account. I've changed the main loop in
that function to use TypeSize instead of unsigned for tracking the
remaining store amount and offset increment. In addition, I've changed
the loop to use the new IncrementPointer helper function for updating
the addresses in each iteration, since this handles scalable vector
types.

Whilst fixing this function I also fixed a minor issue in
IncrementPointer whereby we were not adding the no-unsigned-wrap flag
for the add instruction in the same way as the fixed width case does.

Also, I've added a report_fatal_error in GenWidenVectorTruncStores,
since this code currently uses a sequence of element-by-element scalar
stores.

I've added new tests in

  CodeGen/AArch64/sve-intrinsics-stores.ll
  CodeGen/AArch64/sve-st1-addressing-mode-reg-imm.ll

for the changes in GenWidenVectorStores.

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