platform/upstream/llvm.git
4 years ago[SveEmitter] Add builtins for svmov_b and svnot_b.
Sander de Smalen [Wed, 29 Apr 2020 10:59:57 +0000 (11:59 +0100)]
[SveEmitter] Add builtins for svmov_b and svnot_b.

These are custom expanded in CGBuiltin:

  svmov_b_z(pg, op) <=> svand_b_z(pg, op, op)
  svnot_b_z(pg, op) <=> sveor_b_z(pg, op, pg)

Reviewers: SjoerdMeijer, efriedma, ctetreau, rengolin

Reviewed By: efriedma

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

4 years ago[analyzer] Fix build error. NFC.
Valeriy Savchenko [Wed, 29 Apr 2020 12:20:57 +0000 (15:20 +0300)]
[analyzer] Fix build error. NFC.

Move DenseMapInfo specialization to llvm namespace

4 years ago[NFC][ARM] Modify cost model test
Sam Parker [Wed, 29 Apr 2020 11:42:47 +0000 (12:42 +0100)]
[NFC][ARM] Modify cost model test

4 years ago[NFC][ARM] Add two cost model tests
Sam Parker [Wed, 29 Apr 2020 11:36:05 +0000 (12:36 +0100)]
[NFC][ARM] Add two cost model tests

4 years agoFix Wparentheses gcc warning. NFC.
Simon Pilgrim [Wed, 29 Apr 2020 11:21:05 +0000 (12:21 +0100)]
Fix Wparentheses gcc warning. NFC.

It should be either a float(32) or an int(32).

4 years ago[TTI] Add DemandedElts to getScalarizationOverhead
Simon Pilgrim [Wed, 29 Apr 2020 10:39:13 +0000 (11:39 +0100)]
[TTI] Add DemandedElts to getScalarizationOverhead

The improvements to the x86 vector insert/extract element costs in D74976 resulted in the estimated costs for vector initialization and scalarization increasing higher than should be expected. This is particularly noticeable on pre-SSE4 targets where the available of legal INSERT_VECTOR_ELT ops is more limited.

This patch does 2 things:
1 - it implements X86TTIImpl::getScalarizationOverhead to more accurately represent the typical costs of a ISD::BUILD_VECTOR pattern.
2 - it adds a DemandedElts mask to getScalarizationOverhead to permit the SLP's BoUpSLP::getGatherCost to be rewritten to use it directly instead of accumulating raw vector insertion costs.

This fixes PR45418 where a v4i8 (zext'd to v4i32) was no longer vectorizing.

A future patch should extend X86TTIImpl::getScalarizationOverhead to tweak the EXTRACT_VECTOR_ELT scalarization costs as well.

Reviewed By: @craig.topper

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

4 years ago[SveEmitter] Add builtins for gather prefetches
Sander de Smalen [Wed, 29 Apr 2020 10:36:41 +0000 (11:36 +0100)]
[SveEmitter] Add builtins for gather prefetches

Patch by Andrzej Warzynski

Reviewed By: efriedma

Tags: #clang

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

4 years agoRecommit "[VPlan] Add & use VPValue operands for VPWidenRecipe (NFC)."
Florian Hahn [Wed, 29 Apr 2020 09:22:30 +0000 (10:22 +0100)]
Recommit "[VPlan] Add & use VPValue operands for VPWidenRecipe (NFC)."

The crash that caused the original revert has been fixed in
a3c964a278b4. I also added a reduced version of the crash reproducer.

This reverts the revert commit 2107af9ccfdfe67a90ea9ed4f3bfd7c72c4e29ac.

4 years ago[MLIR] Introduce op trait PolyhedralScope (revised)
Uday Bondhugula [Wed, 29 Apr 2020 00:08:23 +0000 (05:38 +0530)]
[MLIR] Introduce op trait PolyhedralScope (revised)

(A previous version of this, dd2c639c3cd397dfef941186fb85c82e4e918425, was
reverted.)

Introduce op trait PolyhedralScope for ops to define a new scope for
polyhedral optimization / affine dialect purposes, thus generalizing
such scopes beyond FuncOp. Ops to which this trait is attached will
define a new scope for the consideration of SSA values as valid symbols
for the purposes of polyhedral analysis and optimization. Update methods
that check for dim/symbol validity to work based on this trait.

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

4 years ago[analyzer] Track runtime types represented by Obj-C Class objects
Valeriy Savchenko [Wed, 22 Apr 2020 15:15:03 +0000 (18:15 +0300)]
[analyzer] Track runtime types represented by Obj-C Class objects

Summary:
Objective-C Class objects can be used to do a dynamic dispatch on
class methods. The analyzer had a few places where we tried to overcome
the dynamic nature of it and still guess the actual function that
is being called. That was done mostly using some simple heuristics
covering the most widespread cases (e.g. [[self class] classmethod]).
This solution introduces a way to track types represented by Class
objects and work with that instead of direct AST matching.

rdar://problem/50739539

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

4 years ago[DSE,MSSA] Add multi-path tests with readnone throwing calls.
Florian Hahn [Wed, 29 Apr 2020 09:30:05 +0000 (10:30 +0100)]
[DSE,MSSA] Add multi-path tests with readnone throwing calls.

4 years agoRevert "[lldb/Platform] Return a std::string from GetSDKPath"
Jonas Devlieghere [Wed, 29 Apr 2020 08:23:49 +0000 (01:23 -0700)]
Revert "[lldb/Platform] Return a std::string from GetSDKPath"

This reverts commit b14c37a29a5455853419f5fe0605f6023c51de89.

4 years ago[AMDGPU] Remove some redundant variables. NFC.
Jay Foad [Mon, 27 Apr 2020 16:15:33 +0000 (17:15 +0100)]
[AMDGPU] Remove some redundant variables. NFC.

4 years agoFixed a -Wunused-variable warning in no-assert builds
Dmitri Gribenko [Wed, 29 Apr 2020 07:12:47 +0000 (09:12 +0200)]
Fixed a -Wunused-variable warning in no-assert builds

4 years agoRevert "[tsan] Relax stack trace check"
Vitaly Buka [Wed, 29 Apr 2020 06:56:07 +0000 (23:56 -0700)]
Revert "[tsan] Relax stack trace check"

Edited hwasan by mistake.

This reverts commit a3b942edc8074dce139bac0643b568f840d7a6a0.

4 years ago[tsan] Relax stack trace check
Vitaly Buka [Wed, 29 Apr 2020 06:51:03 +0000 (23:51 -0700)]
[tsan] Relax stack trace check

With GCC 8 stack is different.

4 years agoMake -fno-char8_t disable the char8_t keyword, even in C++20.
Richard Smith [Wed, 29 Apr 2020 06:41:11 +0000 (23:41 -0700)]
Make -fno-char8_t disable the char8_t keyword, even in C++20.

This fixes a regression introduced in r354736, and makes our behavior
compatible with that of Clang 8 and GCC.

4 years agoFix up clangd after clang commit llvmorg-11-init-13375-g0a088ead85f.
Richard Smith [Wed, 29 Apr 2020 06:22:53 +0000 (23:22 -0700)]
Fix up clangd after clang commit llvmorg-11-init-13375-g0a088ead85f.

It's not clear whether clangd should really consider #import to mark a
header as self-contained or not, but this change preserves the old (and
unit-tested) behavior.

4 years ago[X86] Add initialize function for X86FixupSetCC so that it will show up in print...
Craig Topper [Wed, 29 Apr 2020 06:31:28 +0000 (23:31 -0700)]
[X86] Add initialize function for X86FixupSetCC so that it will show up in print-after-all.

4 years agoRemove DeleteContainer* functions, now that all uses have been ported to unique_ptr
David Blaikie [Wed, 29 Apr 2020 05:39:30 +0000 (22:39 -0700)]
Remove DeleteContainer* functions, now that all uses have been ported to unique_ptr

4 years ago[mlir] NFC: fix trivial typo
Kazuaki Ishizaki [Wed, 29 Apr 2020 05:47:35 +0000 (14:47 +0900)]
[mlir] NFC: fix trivial typo

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

4 years agoSymbolManager::SymbolDependencies: Use unique_ptr to simplify memory management
David Blaikie [Wed, 29 Apr 2020 04:03:57 +0000 (21:03 -0700)]
SymbolManager::SymbolDependencies: Use unique_ptr to simplify memory management

4 years agoAnalysisDeclContext::ManagedAnalyses: Use unique_ptr to simplify memory management
David Blaikie [Wed, 29 Apr 2020 03:54:57 +0000 (20:54 -0700)]
AnalysisDeclContext::ManagedAnalyses: Use unique_ptr to simplify memory management

4 years agoCodeGenTypes::CGRecordLayouts: Use unique_ptr to simplify memory management
David Blaikie [Wed, 29 Apr 2020 03:40:31 +0000 (20:40 -0700)]
CodeGenTypes::CGRecordLayouts: Use unique_ptr to simplify memory management

4 years agoASTContext::OMPTraitInfoVector: Use unique_ptr to simplify memory management
David Blaikie [Wed, 29 Apr 2020 03:18:01 +0000 (20:18 -0700)]
ASTContext::OMPTraitInfoVector: Use unique_ptr to simplify memory management

4 years agoBugReporter::StrBugTypes: Use unique_ptr to simplify memory management
David Blaikie [Wed, 29 Apr 2020 02:14:58 +0000 (19:14 -0700)]
BugReporter::StrBugTypes: Use unique_ptr to simplify memory management

4 years agoPragmaNamespace::Handlers: Use unique_ptr to simplify memory management
David Blaikie [Wed, 29 Apr 2020 01:59:40 +0000 (18:59 -0700)]
PragmaNamespace::Handlers: Use unique_ptr to simplify memory management

The API actually passes and returns ownership too, but the usage uis
complicated enough that I'm not going to unique_ptr-ify those add/remove
calls.

4 years ago[PowerPC-QPX] add more test for QPX madd/msub operands order - NFC
Chen Zheng [Wed, 29 Apr 2020 04:48:49 +0000 (00:48 -0400)]
[PowerPC-QPX] add more test for QPX madd/msub operands order - NFC

4 years ago[mlir][EDSC] Retire OperationHandle
Nicolas Vasilache [Wed, 29 Apr 2020 04:30:31 +0000 (00:30 -0400)]
[mlir][EDSC] Retire OperationHandle

OperationHandle mostly existed to mirror the behavior of ValueHandle.
This has become unnecessary and can be retired.

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

4 years agoFix LLDB elf core dump register access for ARM/AArch64
Muhammad Omair Javaid [Mon, 6 Apr 2020 11:28:01 +0000 (11:28 +0000)]
Fix LLDB elf core dump register access for ARM/AArch64

Summary:
This patch adds support to access AArch64 FP SIMD core dump registers and adds a test case to verify registers.

This patches fixes a bug where doing "register read --all" causes lldb to crash.

Reviewers: labath

Reviewed By: labath

Subscribers: kristof.beyls, danielkiss, lldb-commits

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

4 years agolldb: use the newer `find_package` if available
Saleem Abdulrasool [Wed, 29 Apr 2020 03:49:51 +0000 (03:49 +0000)]
lldb: use the newer `find_package` if available

Now that the rest of LLVM prefers python3 over python2, the LLDB path
should follow suite.  Add a fallback path to python2 for non-Windows
targets.

4 years agoExtend max register size to accommodate AArch64 SVE vector regs
Muhammad Omair Javaid [Wed, 29 Apr 2020 02:48:45 +0000 (07:48 +0500)]
Extend max register size to accommodate AArch64 SVE vector regs

Summary: This patch increases maximum register size to 256 bytes to accommodate AArch64 SVE registers maximum possible size of 256 bytes.

Reviewers: labath, jankratochvil, rengolin

Reviewed By: labath

Subscribers: tschuett, kristof.beyls, danielkiss, lldb-commits

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

4 years ago[lldb/Host] Pass a StringRef to the FileSpec ctor
Jonas Devlieghere [Wed, 29 Apr 2020 02:21:27 +0000 (19:21 -0700)]
[lldb/Host] Pass a StringRef to the FileSpec ctor

The FileSpec constructor takes a StringRef so there's no point in going
through a C string.

4 years ago[lldb/Platform] Synchronize access to SDK String Map.
Jonas Devlieghere [Wed, 29 Apr 2020 02:20:06 +0000 (19:20 -0700)]
[lldb/Platform] Synchronize access to SDK String Map.

The SwiftASTContext queries this function in parallel and requires
synchronization.

4 years ago[lldb/Platform] Return a std::string from GetSDKPath
Jonas Devlieghere [Wed, 29 Apr 2020 02:05:51 +0000 (19:05 -0700)]
[lldb/Platform] Return a std::string from GetSDKPath

Nothing guarantees that the objects in the StringMap remains at the same
address when the StringMap grows. Therefore we shouldn't return a
reference into the StringMap but return a copy of the string instead.

4 years ago[dsymutil] Fix short options displayed in the help message.
Xing GUO [Wed, 29 Apr 2020 02:16:06 +0000 (10:16 +0800)]
[dsymutil] Fix short options displayed in the help message.

This patch helps make the short options displayed in the help message be consistant with the description in https://llvm.org/docs/CommandGuide/dsymutil.html

Reviewed By: JDevlieghere, aprantl

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

4 years ago[DAGCombine] Checking the cost directly to improve the code readability
QingShan Zhang [Wed, 29 Apr 2020 01:35:30 +0000 (01:35 +0000)]
[DAGCombine] Checking the cost directly to improve the code readability

Call getNegatedExpression(Cost) and check the Cost to make the code more clear.

Reviewed By: RKSimon

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

4 years agoReland "[gn build] (manually) merge c4c3883"
Nico Weber [Wed, 29 Apr 2020 01:43:38 +0000 (21:43 -0400)]
Reland "[gn build] (manually) merge c4c3883"

The Python3 change relanded yet again, so merge it yet again.

This reverts commit f0019cdc47f59e94b9bc3291b83a9b4cec1bf62b.
This reverts commit 854a7db46c0a9750d9d9f932d5d49c3d64a85153.

4 years agoImprove diagnostics for missing import / #include of module.
Richard Smith [Wed, 29 Apr 2020 01:22:34 +0000 (18:22 -0700)]
Improve diagnostics for missing import / #include of module.

Fix a few bugs where we would fail to properly determine header to
module correspondence when determining whether to suggest a #include or
import, and suggest a #include more often in language modes where there
is no import syntax. Generally, if the target is in a header with
include guards or #pragma once, we should suggest either #including or
importing that header, and not importing a module that happens to
textually include it.

In passing, improve the notes we attach to the corresponding
diagnostics: calling an entity that we couldn't see "previous" is
confusing.

4 years agoRevert "Temporarily revert "build: use `find_package(Python3)` if available""
Saleem Abdulrasool [Wed, 29 Apr 2020 01:37:28 +0000 (01:37 +0000)]
Revert "Temporarily revert "build: use `find_package(Python3)` if available""

This reverts commit 35edd704e0fda09e8e634515c0b451d4a8b6b914.

Revert the revert and extend the patch further to account for the use of
the `PYTHONINTERP_FOUND`.

4 years agoASTWriter::FileDeclIDs: Use unique_ptr to simplify memory management
David Blaikie [Wed, 29 Apr 2020 01:05:28 +0000 (18:05 -0700)]
ASTWriter::FileDeclIDs: Use unique_ptr to simplify memory management

4 years agoASTUnit::FileDecls: Use unique_ptr to simplify memory management
David Blaikie [Wed, 29 Apr 2020 00:58:53 +0000 (17:58 -0700)]
ASTUnit::FileDecls: Use unique_ptr to simplify memory management

4 years ago[gn build] Port 8683f5de535
LLVM GN Syncbot [Wed, 29 Apr 2020 00:53:06 +0000 (00:53 +0000)]
[gn build] Port 8683f5de535

4 years ago[gn build] fix typo
Nico Weber [Wed, 29 Apr 2020 00:52:51 +0000 (20:52 -0400)]
[gn build] fix typo

4 years agoRevert "[gn build] (manually) merge c4c3883"
Nico Weber [Wed, 29 Apr 2020 00:47:26 +0000 (20:47 -0400)]
Revert "[gn build] (manually) merge c4c3883"

This reverts commit cbaa74a0981833537e88a8eeac9c9df0f528833c.
The Py3 change got (mostly, except compiler-rt) reverted again.

4 years agoAllocatedCXCodeCompleteResults::DiagnosticWrappers: use unique_ptr to simplify memory...
David Blaikie [Wed, 29 Apr 2020 00:45:07 +0000 (17:45 -0700)]
AllocatedCXCodeCompleteResults::DiagnosticWrappers: use unique_ptr to simplify memory management

4 years agoWebAssemblyExceptionInfo::Exceptions: Use unique_ptr to simplify memory management
David Blaikie [Tue, 28 Apr 2020 21:31:43 +0000 (14:31 -0700)]
WebAssemblyExceptionInfo::Exceptions: Use unique_ptr to simplify memory management

4 years agoInstrCOPYReplacer::Converters: Use unique_ptr to own values to simplify memory management
David Blaikie [Tue, 28 Apr 2020 19:47:06 +0000 (12:47 -0700)]
InstrCOPYReplacer::Converters: Use unique_ptr to own values to simplify memory management

4 years ago[clang-tidy] Add check callee-namespace.
Paula Toth [Wed, 29 Apr 2020 00:22:16 +0000 (17:22 -0700)]
[clang-tidy] Add check callee-namespace.

Summary:
This check will ensure that all calls to functions resolve to one inside the `__llvm_libc` namespace.

This is done to ensure that if we include a public header then we don't accidentally call into the a function within the global namespace.

Reviewers: aaron.ballman, njames93

Reviewed By: aaron.ballman

Subscribers: Eugene.Zelenko, mgorny, xazax.hun, cfe-commits, sivachandra

Tags: #clang-tools-extra, #libc-project, #clang

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

4 years ago[lld-macho][reland] Add support for emitting dylibs with a single symbol
Jez Ng [Tue, 28 Apr 2020 23:58:22 +0000 (16:58 -0700)]
[lld-macho][reland] Add support for emitting dylibs with a single symbol

This got reverted due to UBSAN errors in a diff lower in the stack,
which is being fixed in https://reviews.llvm.org/D79050. This diff is
otherwise identical to the original https://reviews.llvm.org/D76908
(which was committed in 9598778bd191 and reverted in b52bc2653bbc).

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

4 years ago[lld-macho][reland] Add basic symbol table output
Jez Ng [Tue, 28 Apr 2020 23:58:19 +0000 (16:58 -0700)]
[lld-macho][reland] Add basic symbol table output

This diff implements basic support for writing a symbol table.

Attributes are loosely supported for extern symbols and not at all for
other types.

Initial version by Kellie Medlin <kelliem@fb.com>

Originally committed in a3d95a50ee33 and reverted in fbae153ca583 due to
UBSAN erroring over unaligned writes. That has been fixed in the
current diff with the following changes:

```
diff --git a/lld/MachO/SyntheticSections.cpp b/lld/MachO/SyntheticSections.cpp
--- a/lld/MachO/SyntheticSections.cpp
+++ b/lld/MachO/SyntheticSections.cpp
@@ -133,6 +133,9 @@ SymtabSection::SymtabSection(StringTableSection &stringTableSection)
     : stringTableSection(stringTableSection) {
   segname = segment_names::linkEdit;
   name = section_names::symbolTable;
+  // TODO: When we introduce the SyntheticSections superclass, we should make
+  // all synthetic sections aligned to WordSize by default.
+  align = WordSize;
 }

 size_t SymtabSection::getSize() const {
diff --git a/lld/MachO/Writer.cpp b/lld/MachO/Writer.cpp
--- a/lld/MachO/Writer.cpp
+++ b/lld/MachO/Writer.cpp
@@ -371,6 +371,7 @@ void Writer::assignAddresses(OutputSegment *seg) {
     ArrayRef<InputSection *> sections = p.second;
     for (InputSection *isec : sections) {
       addr = alignTo(addr, isec->align);
+      // We must align the file offsets too to avoid misaligned writes of
+      // structs.
+      fileOff = alignTo(fileOff, isec->align);
       isec->addr = addr;
       addr += isec->getSize();
       fileOff += isec->getFileSize();
@@ -396,6 +397,7 @@ void Writer::writeSections() {
     uint64_t fileOff = seg->fileOff;
     for (auto &sect : seg->getSections()) {
       for (InputSection *isec : sect.second) {
+        fileOff = alignTo(fileOff, isec->align);
         isec->writeTo(buf + fileOff);
         fileOff += isec->getFileSize();
       }
```

I don't think it's easy to write a test for alignment (that doesn't
involve brittly hard-coding file offsets), so there isn't one... but
UBSAN builds pass now.

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

4 years agoMake getCompileUnitForAddress public.
Sterling Augustine [Tue, 28 Apr 2020 22:19:58 +0000 (15:19 -0700)]
Make getCompileUnitForAddress public.

Summary:
Certain dwarf information (like the compilation directory), are only
accessible from the compile unit. Make it available for use.

Subscribers: aprantl, llvm-commits

Tags: #llvm

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

4 years agoTemporarily revert "build: use `find_package(Python3)` if available"
Eric Christopher [Tue, 28 Apr 2020 23:41:22 +0000 (16:41 -0700)]
Temporarily revert "build: use `find_package(Python3)` if available"
as it seems to be causing multiple people problems with running tests
and building.

This reverts commit c4c3883b00d3a6aa657a5e3e515c90c9ea1f81c6.

4 years ago[AMDGPU] Adapt GCNRegBankReassign for 16 bit subregs
Stanislav Mekhanoshin [Thu, 23 Apr 2020 22:10:25 +0000 (15:10 -0700)]
[AMDGPU] Adapt GCNRegBankReassign for 16 bit subregs

It allows it not to crash and analyze 16 bit subregs if those
appear in the instructions. At the same time it does not attempt
to reassign these. It still can correctly identify register
banks to let larger registers to be reassigned.

More work will be needed here when real instructions will use
these registers and more tests as well.

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

4 years ago[libc] Add strlen to library entrypoints.
Paula Toth [Tue, 28 Apr 2020 23:14:37 +0000 (16:14 -0700)]
[libc] Add strlen to library entrypoints.

Reviewers: sivachandra, abrachet

Reviewed By: abrachet

Subscribers: mgorny, tschuett, libc-commits

Tags: #libc-project

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

4 years agoReland "Add a facility to get system cache directory and use it in clangd"
Sam McCall [Tue, 28 Apr 2020 22:55:13 +0000 (00:55 +0200)]
Reland "Add a facility to get system cache directory and use it in clangd"

This reverts commit faf2dce1dd6ae25aa75d2685ac7bb27ec31e2ced.

4 years agoTemporarily revert "Add a facility to get system cache directory and use it in clangd"
Eric Christopher [Tue, 28 Apr 2020 22:48:56 +0000 (15:48 -0700)]
Temporarily revert "Add a facility to get system cache directory and use it in clangd"

This reverts commit ad38f4b371bdca214e3a3cda9a76ec2213215c68.

As it broke building the unittests:

.../sources/llvm-project/llvm/unittests/Support/Path.cpp:334:5: error: use of undeclared identifier 'set'
    set(Value);
    ^
1 error generated.

4 years ago[AST] Use PrintingPolicy for format string diagnosis
Jessica Clarke [Tue, 28 Apr 2020 22:43:48 +0000 (23:43 +0100)]
[AST] Use PrintingPolicy for format string diagnosis

Summary:
This is a small improvement for OpenCL diagnostics, but is also useful
for our CHERI fork, as our __capability qualifier is suppressed from
diagnostics when all pointers are capabilities, only being used when pointers
need to be explicitly opted-in to being capabilities.

Reviewers: rsmith, Anastasia, aaron.ballman

Reviewed By: Anastasia, aaron.ballman

Subscribers: aaron.ballman, arichardson, cfe-commits

Tags: #clang

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

4 years ago[AMDGPU] Define AGPR subregs
Stanislav Mekhanoshin [Tue, 28 Apr 2020 22:30:27 +0000 (15:30 -0700)]
[AMDGPU] Define AGPR subregs

These are only needed as VGPR counterpart.

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

4 years agoFix buildbot after 9f31446c
Jessica Paquette [Tue, 28 Apr 2020 22:19:17 +0000 (15:19 -0700)]
Fix buildbot after 9f31446c

Add missing ifndef to make release builds happy.

Example failure: http://lab.llvm.org:8011/builders/fuchsia-x86_64-linux/builds/4006/steps/ninja-build/logs/stdio

4 years ago[X86] Add PACK instructions to hasUndefRegUpdate so the BreakFalseDeps pass will...
Craig Topper [Tue, 28 Apr 2020 22:10:51 +0000 (15:10 -0700)]
[X86] Add PACK instructions to hasUndefRegUpdate so the BreakFalseDeps pass will reassign an undef second source to match the first source

We generate PACK instructions with an undef second source when we are truncating from a 128-bit vector to something narrower and we don't care about the upper bits of the vector register. The register allocation process will always assign untied undef uses to xmm0. This creates a false dependency on xmm0.

By adding these instructions to hasUndefRegUpdate, we can get the BreakFalseDeps pass to reassign the source to match the other input. Normally this interface is used for instructions that might need an xor inserted to break the dependency. But the pass also has a heuristic that tries to use the same register as other sources. That should always be possible for these instructions so we'll never trigger the xor dependency break.

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

4 years ago[AMDGPU] Define special SGPR subregs
Stanislav Mekhanoshin [Tue, 28 Apr 2020 20:54:14 +0000 (13:54 -0700)]
[AMDGPU] Define special SGPR subregs

These are used in SReg_32 and when we start to use SGPR_LO16
there will be compaints that not all registers in RC support
all subreg indexes. For now it is NFC.

Unused regunits are reserved so that verifier does not complain
about missing phys reg live-ins.

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

4 years ago[AArch64][GlobalISel] Generalize logic for promoting copies
Jessica Paquette [Tue, 28 Apr 2020 21:45:05 +0000 (14:45 -0700)]
[AArch64][GlobalISel] Generalize logic for promoting copies

Generalize the 16-bit FPR to 32-bit GPR logic to work for all cases where
destination size is bigger than source size.

Also fixed CheckCopy() always returning true instead of the result of
isValidCopy().

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

Patch by tambre (Raul Tambre)

4 years ago[NFC] Correct spelling of "ambiguous"
Casey Carter [Tue, 28 Apr 2020 21:50:52 +0000 (14:50 -0700)]
[NFC] Correct spelling of "ambiguous"

4 years ago[libc] Fix benchmarks build.
Siva Chandra Reddy [Tue, 28 Apr 2020 21:00:12 +0000 (14:00 -0700)]
[libc] Fix benchmarks build.

Reviewers: gchatelet, echristo

Subscribers: mgorny, tschuett, libc-commits

Tags: #libc-project

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

4 years agoAdd a facility to get system cache directory and use it in clangd
Vojtěch Štěpančík [Tue, 28 Apr 2020 20:03:30 +0000 (22:03 +0200)]
Add a facility to get system cache directory and use it in clangd

Summary:
This patch adds a function that is similar to `llvm::sys::path::home_directory`, but provides access to the system cache directory.

For Windows, that is %LOCALAPPDATA%, and applications should put their files under %LOCALAPPDATA%\Organization\Product\.

For *nixes, it adheres to the XDG Base Directory Specification, so it first looks at the XDG_CACHE_HOME environment variable and falls back to ~/.cache/.

Subsequently, the Clangd Index storage leverages this new API to put index files somewhere else than the users home directory.

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

Reviewers: sammccall, chandlerc, Bigcheese

Reviewed By: sammccall

Subscribers: hiraditya, ilya-biryukov, MaskRay, jkorous, dexonsmith, arphaman, kadircet, ormris, usaxena95, cfe-commits, llvm-commits

Tags: #clang-tools-extra, #clang, #llvm

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

4 years ago[libc++] Make sure temporary config files are closed
Louis Dionne [Tue, 28 Apr 2020 21:12:18 +0000 (17:12 -0400)]
[libc++] Make sure temporary config files are closed

Otherwise, trying to remove the file triggers an error on Windows.

4 years ago[GlobalISel] Assign the correct debug location when combining G_ANYEXT/G_ZEXT
Davide Italiano [Tue, 28 Apr 2020 20:09:28 +0000 (13:09 -0700)]
[GlobalISel] Assign the correct debug location when combining G_ANYEXT/G_ZEXT

<rdar://problem/62535712>

4 years ago[tsan] Relax stack trace check
Vitaly Buka [Tue, 28 Apr 2020 21:04:55 +0000 (14:04 -0700)]
[tsan] Relax stack trace check

With GCC 8 stack is different.

4 years agoMake ops with StructAttr's actually verify `isa<TheStruct>`.
Sean Silva [Tue, 28 Apr 2020 00:52:59 +0000 (17:52 -0700)]
Make ops with StructAttr's actually verify `isa<TheStruct>`.

Previously, they would only only verify `isa<DictionaryAttr>` on such attrs
which resulted in crashes down the line from code assuming that the
verifier was doing the more thorough check introduced in this patch.
The key change here is for StructAttr to use
`CPred<"$_self.isa<" # name # ">()">` instead of `isa<DictionaryAttr>`.

To test this, introduce struct attrs to the test dialect. Previously,
StructAttr was only being tested by unittests/, which didn't verify how
StructAttr interacted with ODS.

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

4 years ago[InstCombine] Add PR45715 test case
Simon Pilgrim [Tue, 28 Apr 2020 20:25:21 +0000 (21:25 +0100)]
[InstCombine] Add PR45715 test case

4 years agoRevert "[AMDGPU] Define special SGPR subregs"
Stanislav Mekhanoshin [Tue, 28 Apr 2020 20:50:36 +0000 (13:50 -0700)]
Revert "[AMDGPU] Define special SGPR subregs"

This reverts commit 1baaa080e0481fa2a7cfafc7303c264d0a305c58.

4 years ago[LAA] Move CheckingPtrGroup/PointerCheck outside class (NFC).
Florian Hahn [Tue, 28 Apr 2020 20:35:02 +0000 (21:35 +0100)]
[LAA] Move CheckingPtrGroup/PointerCheck outside class (NFC).

This allows forward declarations of PointerCheck, which in turn reduce
the number of times LoopAccessAnalysis needs to be included.

Ultimately this helps with moving runtime check generation to
Transforms/Utils/LoopUtils.h, without having to include it there.

Reviewers: anemet, Ayal

Reviewed By: Ayal

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

4 years ago[AMDGPU] Define special SGPR subregs
Stanislav Mekhanoshin [Mon, 20 Apr 2020 23:45:25 +0000 (16:45 -0700)]
[AMDGPU] Define special SGPR subregs

These are used in SReg_32 and when we start to use SGPR_LO16
there will be compaints that not all registers in RC support
all subreg indexes. For now it is NFC.

Unused regunits are reserved so that verifier does not complain
about missing phys reg live-ins.

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

4 years ago[llvm][NFC] Refactor APIs operating on CallBase
Mircea Trofin [Tue, 28 Apr 2020 17:25:13 +0000 (10:25 -0700)]
[llvm][NFC] Refactor APIs operating on CallBase

Summary:
Refactored the parameter and return type where they are too generally
typed as Instruction.

Reviewers: dblaikie, wmi, craig.topper

Subscribers: hiraditya, llvm-commits

Tags: #llvm

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

4 years agoAdd StringRef include to libc benchmark.
Eric Christopher [Tue, 28 Apr 2020 20:11:54 +0000 (13:11 -0700)]
Add StringRef include to libc benchmark.

4 years agobuild: update libc++ as there are some bots with integrated build
Saleem Abdulrasool [Tue, 28 Apr 2020 19:50:12 +0000 (19:50 +0000)]
build: update libc++ as there are some bots with integrated build

Some of the builders are building with C++ in the unified build.  Merge
this without review to try to restore the builder.

4 years ago[lldb-vscode] Add an option for loading core files
Walter Erquinigo [Fri, 24 Apr 2020 23:35:57 +0000 (16:35 -0700)]
[lldb-vscode] Add an option for loading core files

Summary:
Currently loading core files on lldb-vscode is broken because there's a check in the attach workflow that asserts that the PID is valid, which of course fails for this case.
Hence, I'm adding a "coreFile" argument for the attach request, which does the work correctly.

I don't know how to test it effectively so that it runs on the buildbots and the debugger can in fact makes sense of it. Anyway, the change has been relatively simple.

Reviewers: labath, clayborg

Subscribers: lldb-commits

Tags: #lldb

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

4 years ago[SVE] Remove invalid usage of VectorType::getNumElements in Function
Christopher Tetreault [Tue, 28 Apr 2020 19:39:59 +0000 (12:39 -0700)]
[SVE] Remove invalid usage of VectorType::getNumElements in Function

Summary:
Removes usage of VectorType::getNumElements identified by test located
at CodeGen/aarch64-sve-intrinsics/acle_sve_dot.c. This code explicitly
converts a potentially fixed length vector to scalable vector by
constructing the ElementCount = {getNumElements(), true}

Reviewers: rengolin, efriedma, kmclaughlin, c-rhodes, sdesmalen

Reviewed By: efriedma

Subscribers: tschuett, kristof.beyls, hiraditya, rkruppe, psnobl, llvm-commits

Tags: #llvm

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

4 years agoOpenMPOpt::RuntimeFunctionInfo::UsesMap: Use unique_ptr for values to simplify memory...
David Blaikie [Tue, 28 Apr 2020 19:26:09 +0000 (12:26 -0700)]
OpenMPOpt::RuntimeFunctionInfo::UsesMap: Use unique_ptr for values to simplify memory management

4 years agoMustBeExecutedContextExplorer::InstructionIteratorMap: use unique_ptr for values...
David Blaikie [Tue, 28 Apr 2020 19:17:36 +0000 (12:17 -0700)]
MustBeExecutedContextExplorer::InstructionIteratorMap: use unique_ptr for values in this map to simplify memory management

4 years agoAttributor::ArgumentReplacementMap: Use unique_ptr to simplify memory management
David Blaikie [Tue, 28 Apr 2020 19:06:48 +0000 (12:06 -0700)]
Attributor::ArgumentReplacementMap: Use unique_ptr to simplify memory management

4 years ago[Support] Simplify and optimize ThreadPool
Fangrui Song [Sat, 25 Apr 2020 03:50:06 +0000 (20:50 -0700)]
[Support] Simplify and optimize ThreadPool

* Merge QueueLock and CompletionLock.
* Avoid spurious CompletionCondition.notify_all() when ActiveThreads is greater than 0.
* Use default member initializers.

Reviewed By: mehdi_amini

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

4 years ago[ELF][PPC64] Don't perform toc-indirect to toc-relative relaxation for R_PPC64_TOC16_...
Fangrui Song [Sat, 18 Apr 2020 06:08:11 +0000 (23:08 -0700)]
[ELF][PPC64] Don't perform toc-indirect to toc-relative relaxation for R_PPC64_TOC16_HA not followed by R_PPC64_TOC16_LO_DS

The current implementation assumes that R_PPC64_TOC16_HA is always followed
by R_PPC64_TOC16_LO_DS. This can break with:

// Load the address of the TOC entry, instead of the value stored at that address
  addis 3, 2, .LC0@tloc@ha  # R_PPC64_TOC16_HA
  addi  3, 3, .LC0@tloc@l   # R_PPC64_TOC16_LO
  blr

which is used by boringssl's util/fipstools/delocate/delocate.go
https://github.com/google/boringssl/blob/master/crypto/fipsmodule/FIPS.md has some documentation.
In short, this tool converts an assembly file to avoid any potential relocations.
The distance to an input .toc is not a constant after linking, so the assembly cannot use an `addis;ld` pair.
Instead, delocate changes the code to jump to a stub (`addis;addi`) which loads the TOC entry address.

Reviewed By: sfertile

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

4 years ago[PowerPC][AIX] Pass ByVal formal args that span registers and stack.
Sean Fertile [Wed, 15 Apr 2020 13:58:22 +0000 (09:58 -0400)]
[PowerPC][AIX] Pass ByVal formal args that span registers and stack.

Implement passing of ByVal formal arguments when the argument is passed
partly in the argument registers, with the remainder of the argument
passed on the stack.

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

4 years ago[Windows] Autolink with basenames and add libdir to libpath
Reid Kleckner [Wed, 31 Jul 2019 21:52:00 +0000 (14:52 -0700)]
[Windows] Autolink with basenames and add libdir to libpath

Prior to this change, for a few compiler-rt libraries such as ubsan and
the profile library, Clang would embed "-defaultlib:path/to/rt-arch.lib"
into the .drective section of every object compiled with
-finstr-profile-generate or -fsanitize=ubsan as appropriate.

These paths assume that the link step will run from the same working
directory as the compile step. There is also evidence that sometimes the
paths become absolute, such as when clang is run from a different drive
letter from the current working directory. This is fragile, and I'd like
to get away from having paths embedded in the object if possible. Long
ago it was suggested that we use this for ASan, and apparently I felt
the same way back then:
https://reviews.llvm.org/D4428#56536

This is also consistent with how all other autolinking usage works for
PS4, Mac, and Windows: they all use basenames, not paths.

To keep things working for people using the standard GCC driver
workflow, the driver now adds the resource directory to the linker
library search path when it calls the linker. This is enough to make
check-ubsan pass, and seems like a generally good thing.

Users that invoke the linker directly (most clang-cl users) will have to
add clang's resource library directory to their linker search path in
their build system. I'm not sure where I can document this. Ideally I'd
also do it in the MSBuild files, but I can't figure out where they go.
I'd like to start with this for now.

Reviewed By: hans

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

4 years ago[X86] Update costs for truncates from less than 128-bit vectors to vXi1 on pre-avx512...
Craig Topper [Tue, 28 Apr 2020 17:50:59 +0000 (10:50 -0700)]
[X86] Update costs for truncates from less than 128-bit vectors to vXi1 on pre-avx512 targets

vXi1 types are legalized by promoting, but the narrow vectors
are legalized by widening. This results in some truncates turning
into any_extends.

4 years ago[AArch64][GlobalISel] Select immediate forms of compares by wiggling constants
Jessica Paquette [Wed, 22 Apr 2020 23:43:31 +0000 (16:43 -0700)]
[AArch64][GlobalISel] Select immediate forms of compares by wiggling constants

Similar to code in `getAArch64Cmp` in AArch64ISelLowering.

When we get a compare against a constant, sometimes, that constant isn't valid
for selecting an immediate form.

However, sometimes, you can get a valid constant by adding 1 or subtracting 1,
and updating the condition code.

This implements the following transformations when valid:

- x slt c => x sle c - 1
- x sge c => x sgt c - 1
- x ult c => x ule c - 1
- x uge c => x ugt c - 1

- x sle c => x slt c + 1
- x sgt c => s sge c + 1
- x ule c => x ult c + 1
- x ugt c => s uge c + 1

Valid meaning the constant doesn't wrap around when we fudge it, and the result
gives us a compare which can be selected into an immediate form.

This also moves `getImmedFromMO` higher up in the file so we can use it.

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

4 years agoRevert "[lld-macho] Add basic symbol table output"
Shoaib Meenai [Tue, 28 Apr 2020 18:31:39 +0000 (11:31 -0700)]
Revert "[lld-macho] Add basic symbol table output"

This reverts commit a3d95a50ee3397c89327fce6983624446cd8e9d7.

Reverting due to UBSan failures:
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/40817/steps/check-lld%20ubsan/logs/stdio

4 years agoRevert "[lld-macho] Add support for emitting dylibs with a single symbol"
Shoaib Meenai [Tue, 28 Apr 2020 18:30:57 +0000 (11:30 -0700)]
Revert "[lld-macho] Add support for emitting dylibs with a single symbol"

This reverts commit 9598778bd1910e77ccd399f2c9e979c8ecf98e55.

Reverting due to UBSan failures:
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/40817/steps/check-lld%20ubsan/logs/stdio

4 years ago[MachO] Fix UB in memcpy
Shoaib Meenai [Tue, 28 Apr 2020 18:29:30 +0000 (11:29 -0700)]
[MachO] Fix UB in memcpy

UBSan complains about a memcpy with a null pointer, so just skip the
memcpy call if the data is empty.

4 years agoMustBeExecutedContextPrinter::runOnModule: Use unique_ptr to simplify/clarify ownership
David Blaikie [Tue, 28 Apr 2020 18:30:22 +0000 (11:30 -0700)]
MustBeExecutedContextPrinter::runOnModule: Use unique_ptr to simplify/clarify ownership

4 years agoRevert "Recommit [libc++] Move abs and div into stdlib.h to fix header cycle."
Raphael Isemann [Tue, 28 Apr 2020 18:23:01 +0000 (20:23 +0200)]
Revert "Recommit [libc++] Move abs and div into stdlib.h to fix header cycle."

It seems that D74892 still hasn't fixed the issue on the bot. Currently
investigating the bot breakage and meanwhile (again) reverting this...

4 years ago[SVE] Update EmitSVEPredicateCast to take a ScalableVectorType
Christopher Tetreault [Tue, 28 Apr 2020 17:32:55 +0000 (10:32 -0700)]
[SVE] Update EmitSVEPredicateCast to take a ScalableVectorType

Summary:
Removes usage of VectorType::getNumElements identified by test located
at CodeGen/aarch64-sve-intrinsics/acle_sve_abs.c. Since the type is an
SVE predicate vector, it makes sense to specialize the code for scalable
vectors only.

Reviewers: rengolin, efriedma

Reviewed By: efriedma

Subscribers: tschuett, kristof.beyls, rkruppe, psnobl, cfe-commits

Tags: #clang

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

4 years ago[FileCollector] Lock Mutex in copyFiles
Jan Korous [Tue, 28 Apr 2020 17:43:17 +0000 (10:43 -0700)]
[FileCollector] Lock Mutex in copyFiles

We should synchronize reading of VFSWriter's data with the rest of the methods.

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

4 years ago[X86] Handle more cases in combineAddOrSubToADCOrSBB.
Craig Topper [Tue, 28 Apr 2020 17:24:44 +0000 (10:24 -0700)]
[X86] Handle more cases in combineAddOrSubToADCOrSBB.

This adds support for

X + SETAE --> sbb X, -1
X - SETAE --> adc X, -1

Fixes PR45700

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

4 years ago[X86] Pre-commit tests for D78984. NFC
Craig Topper [Tue, 28 Apr 2020 17:08:49 +0000 (10:08 -0700)]
[X86] Pre-commit tests for D78984. NFC

These tests show some missed opportunities to use sbb/adc.

4 years ago[X86][CostModel] Correct the costs for truncate to a mask register with avx512
Craig Topper [Tue, 28 Apr 2020 17:06:29 +0000 (10:06 -0700)]
[X86][CostModel] Correct the costs for truncate to a mask register with avx512

I've modified isTruncateFree to get an accurate cost for types that need to be split. I'm planning to look into fixing it for all vectors, but need more cost cleanups first.

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

4 years ago[COFF] Add a fastpath for /INCLUDE: in .drective sections
Reid Kleckner [Sat, 25 Apr 2020 00:26:17 +0000 (17:26 -0700)]
[COFF] Add a fastpath for /INCLUDE: in .drective sections

This speeds up linking chrome.dll with PGO instrumentation by 13%
(154271ms -> 134033ms).

LLVM's Option library is very slow. In particular, it allocates at least
one large-ish heap object (Arg) for every argument. When PGO
instrumentation is enabled, all the __profd_* symbols are added to the
@llvm.used list, which compiles down to these /INCLUDE: directives. This
means we have O(#symbols) directives to parse in the section, so we end
up allocating an Arg for every function symbol in the object file. This
is unnecessary.

To address the issue and speed up the link, extend the fast path that we
already have for /EXPORT:, which has similar scaling issues.

I promise that I took a hard look at optimizing the Option library, but
its data structures are very general and would need a lot of cleanup. We
have accumulated lots of optional features (option groups, aliases,
multiple values) over the years, and these are now properties of every
parsed argument, when the vast majority of arguments do not use these
features.

Reviewed By: thakis

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

4 years ago[libc++] Avoid using distutils.util in the DSL
Louis Dionne [Tue, 28 Apr 2020 17:32:05 +0000 (13:32 -0400)]
[libc++] Avoid using distutils.util in the DSL

Some bots apparently don't have that package.