platform/upstream/llvm.git
3 years ago[TableGen] Eliminate the 'code' type
Paul C. Anagnostopoulos [Tue, 24 Nov 2020 18:09:02 +0000 (13:09 -0500)]
[TableGen] Eliminate the 'code' type

Update the documentation.

Rework various backends that relied on the code type.

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

3 years ago[VE] Add vsll, vsrl, vsla, vsra, and vsfa intrinsic instructions
Kazushi (Jam) Marukawa [Thu, 3 Dec 2020 03:22:59 +0000 (12:22 +0900)]
[VE] Add vsll, vsrl, vsla, vsra, and vsfa intrinsic instructions

Add vsll, vsrl, vsla, vsra, and vsfa intrinsic instructions and
regression tests.

Reviewed By: simoll

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

3 years ago[mac/arm] Fix rtti codegen tests when running on an arm mac
Nico Weber [Thu, 3 Dec 2020 14:11:03 +0000 (09:11 -0500)]
[mac/arm] Fix rtti codegen tests when running on an arm mac

shouldRTTIBeUnique() returns false for iOS64CXXABI, which causes
RTTI objects to be emitted hidden. Update two tests that didn't
expect this to happen for the default triple.

Also rename iOS64CXXABI to AppleARM64CXXABI, since it's used for
arm64-apple-macos triples too.

Part of PR46644.

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

3 years ago[MLIR] Normalize the results of normalizable operations
Haruki Imai [Thu, 3 Dec 2020 13:52:00 +0000 (19:22 +0530)]
[MLIR] Normalize the results of normalizable operations

Memrefs with affine_map in the results of normalizable operation were
not normalized by `--normalize-memrefs` option. This patch normalizes
them.

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

3 years agoclang/darwin: Don't use response files with ld64
Nico Weber [Tue, 1 Dec 2020 01:10:30 +0000 (20:10 -0500)]
clang/darwin: Don't use response files with ld64

This morally reverts D82777 -- turns out that ld64 crashes with many
response files, so we must stop passing them to it until the crash is
fixed.

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

3 years ago[clangd] Relation slabs should not be accounted when computing backing storage size
Ilya Golovenko [Thu, 3 Dec 2020 13:55:11 +0000 (16:55 +0300)]
[clangd] Relation slabs should not be accounted when computing backing storage size

Reviewed By: sammccall

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

3 years ago[TableGen] Remove unused class RecordValResolver. NFC.
Jay Foad [Wed, 2 Dec 2020 12:32:35 +0000 (12:32 +0000)]
[TableGen] Remove unused class RecordValResolver. NFC.

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

3 years agoReland "[mac/lld] Implement -why_load".
Nico Weber [Wed, 2 Dec 2020 23:59:00 +0000 (18:59 -0500)]
Reland "[mac/lld] Implement -why_load".

The problem was that `sym` became replaced in the call
to make<ObjFile> and referring to it afer that read memory that now
stored a different kind of symbol (a Defined instead of a LazySymbol).
Since this happens only once per archive, just copy the symbol to the
stack before make<ObjFile> and read the copy instead.

Originally reviewed at https://reviews.llvm.org/D92496

3 years ago[compiler-rt] Fix building the aarch64 out-of-line atomics assembly for non-ELF platforms
Martin Storsjö [Thu, 3 Dec 2020 08:31:31 +0000 (10:31 +0200)]
[compiler-rt] Fix building the aarch64 out-of-line atomics assembly for non-ELF platforms

Move the two different definitions of FUNC_ALIGN out of the ELF
specific block. Add the missing CFI_END in
END_COMPILERRT_OUTLINE_FUNCTION, to go with the corresponding CFI_START
in DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED.

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

3 years ago[VE] Add standard include path and library path for C++
Kazushi (Jam) Marukawa [Mon, 30 Nov 2020 18:41:12 +0000 (03:41 +0900)]
[VE] Add standard include path and library path for C++

We have a plan to add libcxx and libcxxabi for VE.  In order to do so,
we need to compile cxx source code with bootstarapped header files.
This patch adds such expected path to make clang++ work, at least
not crash at the startup.  Add regression test for that, also.

Reviewed By: simoll

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

3 years ago[DAGCombine] Fix TypeSize warning in DAGCombine::visitLIFETIME_END
Joe Ellis [Wed, 2 Dec 2020 14:02:47 +0000 (14:02 +0000)]
[DAGCombine] Fix TypeSize warning in DAGCombine::visitLIFETIME_END

Bail out early if we encounter a scalable store.

Reviewed By: peterwaller-arm

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

3 years ago[NFC][Tests] Added one additional test case for NaryRessociation pass.
Evgeniy Brevnov [Thu, 3 Dec 2020 12:02:32 +0000 (19:02 +0700)]
[NFC][Tests] Added one additional test case for NaryRessociation pass.

New tes cases added. Change var names to avoid the following warning from  update_test_checks.py:

WARNING: Change IR value name 'tmp5' to prevent possible conflict with scripted FileCheck name.

Reviewed By: ebrevnov

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

3 years ago[clangd] Fix a nullptr-access crash in canonicalRenameDecl.
Haojian Wu [Thu, 3 Dec 2020 11:57:41 +0000 (12:57 +0100)]
[clangd] Fix a nullptr-access crash in canonicalRenameDecl.

3 years ago[NFC][Tests] Auto generate checks for llvm/test/Transforms/NaryReassociate/pr24301...
Evgeniy Brevnov [Thu, 3 Dec 2020 10:51:40 +0000 (17:51 +0700)]
[NFC][Tests] Auto generate checks for llvm/test/Transforms/NaryReassociate/pr24301.ll using update_test_checks.py

Generate checks with update_test_checks.py in order to simplify upcoming updates.

Reviewed By: mkazantsev

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

3 years ago[llvm-readelf/obj] - Report unique warnings in getSymbolForReloc() helper.
Georgii Rymar [Thu, 3 Dec 2020 09:16:58 +0000 (12:16 +0300)]
[llvm-readelf/obj] - Report unique warnings in getSymbolForReloc() helper.

Use `reportUniqueWarning` instead of `reportWarning` and refine the
interface of the helper.

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

3 years agoarm64: count Triple::aarch64_32 as an aarch64 target and enable leaf frame pointers
Tim Northover [Tue, 10 Nov 2020 11:15:08 +0000 (11:15 +0000)]
arm64: count Triple::aarch64_32 as an aarch64 target and enable leaf frame pointers

3 years ago[libomptarget][amdgpu] Address compiler warnings, drive by fixes
Jon Chesterfield [Thu, 3 Dec 2020 10:36:20 +0000 (10:36 +0000)]
[libomptarget][amdgpu] Address compiler warnings, drive by fixes

[libomptarget][amdgpu] Address compiler warnings, drive by fixes

Initialize some variables, remove unused ones.
Changes the debug printing condition to align with the aomp test suite.

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

3 years ago[llvm-readelf] - Report unique warnings when dumping hash symbols/histogram.
Georgii Rymar [Thu, 3 Dec 2020 08:42:17 +0000 (11:42 +0300)]
[llvm-readelf] - Report unique warnings when dumping hash symbols/histogram.

This converts 2 more places to use `reportUniqueWarning` and adds tests.

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

3 years agoRevert "[IndVars] ICmpInst should not prevent IV widening"
Max Kazantsev [Thu, 3 Dec 2020 10:08:35 +0000 (17:08 +0700)]
Revert "[IndVars] ICmpInst should not prevent IV widening"

This reverts commit 0c9c6ddf17bb01ae350a899b3395bb078aa0c62e.

We are seeing some failures with this patch locally. Not clear
if it's causing them or just triggering a problem in another
place. Reverting while investigating.

3 years ago[MLIR] Added support for dynamic shaped allocas to promote-buffers-to-stack pass.
Julian Gross [Mon, 23 Nov 2020 15:03:27 +0000 (16:03 +0100)]
[MLIR] Added support for dynamic shaped allocas to promote-buffers-to-stack pass.

Extended promote buffers to stack pass to support dynamically shaped allocas.
The conversion is limited by the rank of the underlying tensor.
An option is added to the pass to adjust the given rank.

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

3 years ago[Clang][Sema] Attempt to fix CTAD faulty copy of non-local typedefs
Gabor Marton [Wed, 25 Nov 2020 15:29:28 +0000 (16:29 +0100)]
[Clang][Sema] Attempt to fix CTAD faulty copy of non-local typedefs

http://lists.llvm.org/pipermail/cfe-dev/2020-November/067252.html

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

3 years ago[OpenCL] Add some more kernel argument tests
Sven van Haastregt [Thu, 3 Dec 2020 10:21:29 +0000 (10:21 +0000)]
[OpenCL] Add some more kernel argument tests

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

3 years ago[clang-format] De-duplicate includes with leading or trailing whitespace.
Marek Kurdej [Thu, 3 Dec 2020 09:38:37 +0000 (10:38 +0100)]
[clang-format] De-duplicate includes with leading or trailing whitespace.

This fixes PR46555 (https://bugs.llvm.org/show_bug.cgi?id=46555).

Reviewed By: MyDeveloperDay

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

3 years ago[c++2b] Add option -std=c++2b to enable support for potential C++2b features.
Marek Kurdej [Thu, 3 Dec 2020 09:27:09 +0000 (10:27 +0100)]
[c++2b] Add option -std=c++2b to enable support for potential C++2b features.

Reviewed By: rsmith

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

3 years agoFix forward for rGd9adde5ae216: adding missing dependency.
Christian Sigg [Thu, 3 Dec 2020 09:08:08 +0000 (10:08 +0100)]
Fix forward for rGd9adde5ae216: adding missing dependency.

Reviewed By: herhut

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

3 years ago[VE] Add veqv and vseq intrinsic instructions
Kazushi (Jam) Marukawa [Thu, 3 Dec 2020 01:18:10 +0000 (10:18 +0900)]
[VE] Add veqv and vseq intrinsic instructions

Add veqv and vseq intrinsic instructions and regression tests.

Reviewed By: simoll

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

3 years ago[libc++] [docs] Add C++2b (to be C++23) status page.
Marek Kurdej [Thu, 3 Dec 2020 08:17:14 +0000 (09:17 +0100)]
[libc++] [docs] Add C++2b (to be C++23) status page.

Also:
* Fix header line in all status tables.
* Use C++20 instead of C++2a.

Reviewed By: ldionne, #libc, miscco

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

3 years ago[mlir][gpu] Move gpu.wait ops from async.execute regions to its dependencies.
Christian Sigg [Wed, 2 Dec 2020 08:48:59 +0000 (09:48 +0100)]
[mlir][gpu] Move gpu.wait ops from async.execute regions to its dependencies.

This can prevent unnecessary host synchronization.

Reviewed By: herhut

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

3 years ago[NFC] Add proper triple for arc.ll test
Yuanfang Chen [Thu, 3 Dec 2020 07:31:06 +0000 (23:31 -0800)]
[NFC] Add proper triple for arc.ll test

3 years agoBPF: add a test for selectiondag alias analysis w.r.t. lifetime
Yonghong Song [Wed, 2 Dec 2020 03:26:39 +0000 (19:26 -0800)]
BPF: add a test for selectiondag alias analysis w.r.t. lifetime

This adds a test for the bug
  https://bugs.llvm.org/show_bug.cgi?id=47591

Previously, selection dag has a bug which may incorrectly
assume no alias when crossing a lifetime boundary and this
may generate incorrect code as demonstrated in the above bug.

It looks the bug is fixed by https://reviews.llvm.org/D91833.
Basically, when comparing two potential memory access dag nodes,
  a store and a lifetime.start,
with the same frame index.
Previously, it may be decided no alias. With the above fix,
these two will be considered aliasing which will prevent
incorrect code scheduling.

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

3 years ago[NFC] Fix typo
modimo [Thu, 3 Dec 2020 06:23:57 +0000 (22:23 -0800)]
[NFC] Fix typo

3 years agoSwitch from llvm::is_trivially_copyable to std::is_trivially_copyable
Fangrui Song [Thu, 3 Dec 2020 06:02:48 +0000 (22:02 -0800)]
Switch from llvm::is_trivially_copyable to std::is_trivially_copyable

GCC<5 did not support std::is_trivially_copyable. Now LLVM builds require 5.1
we can migrate to std::is_trivially_copyable.

The Optional.h change made MSVC choke
(https://buildkite.com/llvm-project/premerge-checks/builds/18587#cd1bb616-ffdc-4581-9795-b42c284196de)
so I leave it out for now.

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

3 years ago[dfsan] Rename ShadowTy/ZeroShadow with prefix Primitive
Jianzhou Zhao [Wed, 2 Dec 2020 05:58:09 +0000 (05:58 +0000)]
[dfsan] Rename ShadowTy/ZeroShadow with prefix Primitive

This is a child diff of D92261.

After supporting field/index-level shadow, the existing shadow with type
i16 works for only primitive types.

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

3 years ago[libomptarget][AMDGPU] Remove MaxParallelLevel
Pushpinder Singh [Wed, 2 Dec 2020 06:34:38 +0000 (01:34 -0500)]
[libomptarget][AMDGPU] Remove MaxParallelLevel

Removes MaxParallelLevel references from rtl.cpp and drops
resulting dead code.

Reviewed By: JonChesterfield

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

3 years ago[RISCV] Add additional half precision fnmadd/fnmsub tests with an fneg on the second...
Craig Topper [Thu, 3 Dec 2020 05:03:05 +0000 (21:03 -0800)]
[RISCV] Add additional half precision fnmadd/fnmsub tests with an fneg on the second operand instead of the first.

This matches the float/double tests added in defe11866a326491ee9767f84bb3f70cfc4f4bcb

3 years ago[RISCV] Add f16 to isFMAFasterThanFMulAndFAdd now that the Zfh extension is supported
Craig Topper [Thu, 3 Dec 2020 04:20:38 +0000 (20:20 -0800)]
[RISCV] Add f16 to isFMAFasterThanFMulAndFAdd now that the Zfh extension is supported

3 years ago[PowerPC] Add the hw sqrt test for vector type v4f32/v2f64
QingShan Zhang [Thu, 3 Dec 2020 03:09:25 +0000 (03:09 +0000)]
[PowerPC] Add the hw sqrt test for vector type v4f32/v2f64

PowerPC ISA support the input test for vector type v4f32 and v2f64.
Replace the software compare with hw test will improve the perf.

Reviewed By: ChenZheng

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

3 years ago[SelectionDAG] Use is_contained (NFC)
Kazu Hirata [Thu, 3 Dec 2020 03:09:45 +0000 (19:09 -0800)]
[SelectionDAG] Use is_contained (NFC)

3 years ago[NFC] [Clang] Move ppc64le f128 vaargs OpenMP test
Qiu Chaofan [Thu, 3 Dec 2020 02:50:42 +0000 (10:50 +0800)]
[NFC] [Clang] Move ppc64le f128 vaargs OpenMP test

This case for long-double semantics mismatch on OpenMP references
%clang, which should be located in Driver directory.

3 years ago[NFC][sanitizer] Another attempt to fix test on arm
Vitaly Buka [Thu, 3 Dec 2020 02:36:02 +0000 (18:36 -0800)]
[NFC][sanitizer] Another attempt to fix test on arm

3 years ago[RISCV] Initialize MergeBaseOffsetOptPass so it will work with print-before/after...
Craig Topper [Thu, 3 Dec 2020 01:28:20 +0000 (17:28 -0800)]
[RISCV] Initialize MergeBaseOffsetOptPass so it will work with print-before/after-all.

If its not in the PassRegistry it's not recognized as
a pass when we print before/after. Happened to notice while
I was working on a new pass.

3 years agoPR48339: Improve diagnostics for invalid dependent unqualified function calls.
Richard Smith [Thu, 3 Dec 2020 01:46:28 +0000 (17:46 -0800)]
PR48339: Improve diagnostics for invalid dependent unqualified function calls.

Fix bogus diagnostics that would get confused and think a "no viable
fuctions" case was an "undeclared identifiers" case, resulting in an
incorrect diagnostic preceding the correct one. Use overload resolution
to determine which function we should select when we can find call
candidates from a dependent base class. Make the diagnostics for a call
that could call a function from a dependent base class more specific,
and use a different diagnostic message for the case where the call
target is instead declared later in the same class. Plus some minor
diagnostic wording improvements.

3 years ago[MemorySSA] Remove unused declaration findDominatingDef (NFC)
Kazu Hirata [Thu, 3 Dec 2020 01:40:19 +0000 (17:40 -0800)]
[MemorySSA] Remove unused declaration findDominatingDef (NFC)

The function definition was removed on Feb 22, 2017 in commit
17e8d0eae24ffa41cf7641d984c05e00d59b93a4.  The declaration has
remained since.

3 years agoRevert "Frontend: Sink named pipe logic from CompilerInstance down to FileManager"
Duncan P. N. Exon Smith [Thu, 3 Dec 2020 01:34:38 +0000 (17:34 -0800)]
Revert "Frontend: Sink named pipe logic from CompilerInstance down to FileManager"

This reverts commit 3b18a594c7717a328c33b9c1eba675e9f4bd367c, since
apparently this doesn't work everywhere. E.g.,
clang-x86_64-debian-fast/3889
(http://lab.llvm.org:8011/#/builders/109/builds/3889) gives me:
```
+ : 'RUN: at line 8'
+ /b/1/clang-x86_64-debian-fast/llvm.obj/bin/clang -x c /dev/fd/0 -E
+ cat /b/1/clang-x86_64-debian-fast/llvm.src/clang/test/Misc/dev-fd-fs.c
fatal error: file '/dev/fd/0' modified since it was first processed
1 error generated.
```

3 years ago[llvm-link] use file magic when deciding if input should be loaded as archive
Sergey Dmitriev [Thu, 3 Dec 2020 00:19:31 +0000 (16:19 -0800)]
[llvm-link] use file magic when deciding if input should be loaded as archive

llvm-link should not rely on the '.a' file extension when deciding if input file
should be loaded as archive. Archives may have other extensions (f.e. .lib) or no
extensions at all. This patch changes llvm-link to use llvm::file_magic to check
if input file is an archive.

Reviewed By: RaviNarayanaswamy

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

3 years ago[RISCV] Handle zfh in the arch string.
Hsiangkai Wang [Thu, 12 Nov 2020 02:00:33 +0000 (10:00 +0800)]
[RISCV] Handle zfh in the arch string.

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

3 years ago[RISCV] Support Zfh half-precision floating-point extension.
Hsiangkai Wang [Fri, 3 Jul 2020 14:57:59 +0000 (22:57 +0800)]
[RISCV] Support Zfh half-precision floating-point extension.

Support "Zfh" extension according to
https://github.com/riscv/riscv-isa-manual/blob/zfh/src/zfh.tex

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

3 years agoFrontend: Sink named pipe logic from CompilerInstance down to FileManager
Duncan P. N. Exon Smith [Tue, 3 Nov 2020 13:33:06 +0000 (08:33 -0500)]
Frontend: Sink named pipe logic from CompilerInstance down to FileManager

Remove compilicated logic from CompilerInstance::InitializeSourceManager
to deal with named pipes, updating FileManager::getBufferForFile to
handle it in a more straightforward way. The existing test at
clang/test/Misc/dev-fd-fs.c covers the new behaviour (just like it did
the old behaviour).

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

3 years ago[lldb] Treat remote macOS debugging like any other remote darwin platform
Jonas Devlieghere [Thu, 3 Dec 2020 00:26:11 +0000 (16:26 -0800)]
[lldb] Treat remote macOS debugging like any other remote darwin platform

Extract remote debugging logic from PlatformMacOSX and move it into
PlatformRemoteMacOSX so it can benefit from all the logic necessary for
remote debugging.

Until now, remote macOS debugging was treated almost identical to local
macOS debugging. By moving in into its own class, we can have it inherit
from PlatformRemoteDarwinDevice and all the functionality it provides,
such as looking at the correct DeviceSupport directory.

rdar://68167374

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

3 years agoRevert "[llvm-link] use file magic when deciding if input should be loaded as archive"
Sergey Dmitriev [Thu, 3 Dec 2020 00:52:48 +0000 (16:52 -0800)]
Revert "[llvm-link] use file magic when deciding if input should be loaded as archive"

This reverts commit 55f8c2fdfbc5eda1be946e97ecffa2dea44a883e.

3 years agoSmall improvements to Intrinsic::getName
Xun Li [Thu, 3 Dec 2020 00:49:12 +0000 (16:49 -0800)]
Small improvements to Intrinsic::getName

While I was adding a new intrinsic instruction (not overloaded), I accidentally used CreateUnaryIntrinsic to create the intrinsics, which turns out to be passing the type list to getName, and ended up naming the intrinsics function with type suffix, which leads to wierd bugs latter on. It took me a long time to debug.
It seems a good idea to add an assertion in getName so that it fails if types are passed but it's not a overloaded function.
Also, the overloade version of getName is less efficient because it creates an std::string. We should avoid calling it if we know that there are no types provided.

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

3 years ago[llvm-link] use file magic when deciding if input should be loaded as archive
Sergey Dmitriev [Thu, 3 Dec 2020 00:19:31 +0000 (16:19 -0800)]
[llvm-link] use file magic when deciding if input should be loaded as archive

llvm-link should not rely on the '.a' file extension when deciding if input file
should be loaded as archive. Archives may have other extensions (f.e. .lib) or no
extensions at all. This patch changes llvm-link to use llvm::file_magic to check
if input file is an archive.

Reviewed By: RaviNarayanaswamy

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

3 years agoARCMigrate: Stop abusing PreprocessorOptions for passing back file remappings, NFC
Duncan P. N. Exon Smith [Wed, 4 Nov 2020 20:51:56 +0000 (15:51 -0500)]
ARCMigrate: Stop abusing PreprocessorOptions for passing back file remappings, NFC

As part of reducing use of PreprocessorOptions::RemappedFileBuffers,
stop abusing it to pass information around remapped files in
`ARCMigrate`.  This simplifies an eventual follow-up to switch to using
an `InMemoryFileSystem` for this.

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

3 years ago [scudo][standalone] Add missing va_end() in ScopedString::append
Kostya Kortchinsky [Wed, 2 Dec 2020 23:19:42 +0000 (15:19 -0800)]
 [scudo][standalone] Add missing va_end() in ScopedString::append

In ScopedString::append va_list ArgsCopy is created but never cleanuped
which can lead to undefined behaviour, like stack corruption.

Reviewed By: cryptoad

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

3 years agoFix assertion in tryEmitAsConstant
Yaxun (Sam) Liu [Wed, 2 Dec 2020 23:35:52 +0000 (18:35 -0500)]
Fix assertion in tryEmitAsConstant

due to cd95338ee3022bffd658e52cd3eb9419b4c218ca

Need to check if result is LValue before getLValueBase.

3 years ago[lldb] Return the original path when tilde expansion fails.
Jonas Devlieghere [Thu, 3 Dec 2020 00:00:21 +0000 (16:00 -0800)]
[lldb] Return the original path when tilde expansion fails.

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

3 years agoRevert "[mac/lld] Implement -why_load"
Nico Weber [Wed, 2 Dec 2020 23:57:46 +0000 (18:57 -0500)]
Revert "[mac/lld] Implement -why_load"

This reverts commit 542d3b609dbe99a30759942271398890fc7770dc.
Seems to break check-lld. Reverting while I take a look.

3 years agoADT: Rely on std::aligned_union_t for math in AlignedCharArrayUnion, NFC
Duncan P. N. Exon Smith [Wed, 2 Dec 2020 19:43:15 +0000 (11:43 -0800)]
ADT: Rely on std::aligned_union_t for math in AlignedCharArrayUnion, NFC

Instead of computing the alignment and size of the `char` buffer in
`AlignedCharArrayUnion`, rely on the math in `std::aligned_union_t`.
Because some users of this rely on the `buffer` field existing with a
type convertible to `char *`, we can't change the field type, but we can
still avoid duplicating the logic.

A potential follow up would be to delete `AlignedCharArrayUnion` after
updating its users to use `std::aligned_union_t` directly; or if we like
our template parameters better, could update users to stop peeking
inside and then replace the definition with:
```
template <class T, class... Ts>
using AlignedCharArrayUnion = std::aligned_union_t<1, T, Ts...>;
```

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

3 years ago[NFC][MC] TargetRegisterInfo::getSubReg is a MCRegister.
Mircea Trofin [Thu, 19 Nov 2020 15:43:56 +0000 (07:43 -0800)]
[NFC][MC] TargetRegisterInfo::getSubReg is a MCRegister.

Typing the API appropriately.

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

3 years ago[lldb] X-FAIL class template parameter pack tests on Windows
Raphael Isemann [Wed, 2 Dec 2020 23:37:19 +0000 (00:37 +0100)]
[lldb] X-FAIL class template parameter pack tests on Windows

Both seem to fail to read values from the non-running target.

3 years ago[mac/lld] Implement -why_load
Nico Weber [Wed, 2 Dec 2020 18:17:55 +0000 (13:17 -0500)]
[mac/lld] Implement -why_load

This is useful for debugging why lld loads .o files it shouldn't load.
It's also useful for users of lld -- I've used ld64's version of this a
few times.

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

3 years ago[flang] Fix bugs related to merging generics during USE
Tim Keith [Wed, 2 Dec 2020 23:13:49 +0000 (15:13 -0800)]
[flang] Fix bugs related to merging generics during USE

When the same generic name is use-associated from two modules, the
generics are merged into a single one in the current scope. This change
fixes some bugs in that process.

When a generic is merged, it can have two specific procedures with the
same name as the generic (c.f. module m7c in modfile07.f90). We were
disallowing that by checking for duplicate names in the generic rather
than duplicate symbols. Changing `namesSeen` to `symbolsSeen` in
`ResolveSpecificsInGeneric` fixes that.

We weren't including each USE of those generics in the .mod file so in
some cases they were incorrect. Extend GenericDetails to specify all
use-associated symbols that are merged into the generic. This is used to
write out .mod files correctly.

The distinguishability check for specific procedures of a generic
sometimes have to refer to procedures from a use-associated generic in
error messages. In that case we don't have the source location of the
procedure so adapt the message to say where is was use-associated from.
This requires passing the scope through the checks to make that
determination.

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

3 years ago[lldb][NFC] Make DeclOrigin::Valid() const
Raphael Isemann [Wed, 2 Dec 2020 23:08:19 +0000 (00:08 +0100)]
[lldb][NFC] Make DeclOrigin::Valid() const

3 years agoADT: Remove redundant `alignas` from IntervalMap, NFC
Duncan P. N. Exon Smith [Wed, 2 Dec 2020 21:48:40 +0000 (13:48 -0800)]
ADT: Remove redundant `alignas` from IntervalMap, NFC

`AlignedArrayCharUnion` is now using `alignas`, which is properly
supported now by all the host toolchains we support. As a result, the
extra `alignas` on `IntervalMap` isn't needed anymore.

This is effectively a revert of 379daa29744cd96b0a87ed0d4a010fa4bc47ce73.

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

3 years agoRevert "Use std::is_trivially_copyable", breaks MSVC build
Reid Kleckner [Wed, 2 Dec 2020 21:48:05 +0000 (13:48 -0800)]
Revert "Use std::is_trivially_copyable", breaks MSVC build

Revert "Delete llvm::is_trivially_copyable and CMake variable HAVE_STD_IS_TRIVIALLY_COPYABLE"

This reverts commit 4d4bd40b578d77b8c5bc349ded405fb58c333c78.

This reverts commit 557b00e0afb2dc1776f50948094ca8cc62d97be4.

3 years ago[ConstraintElimination] Make sure arguments of std:pow match.
Florian Hahn [Wed, 2 Dec 2020 22:22:17 +0000 (22:22 +0000)]
[ConstraintElimination] Make sure arguments of std:pow match.

This should fix a build failure on some systems, e.g. solaris11-sparcv9
http://lab.llvm.org:8014/#/builders/22

3 years ago[X86] Add TLS_(base_)addrX32 for X32 mode
Harald van Dijk [Wed, 2 Dec 2020 22:20:36 +0000 (22:20 +0000)]
[X86] Add TLS_(base_)addrX32 for X32 mode

LLVM has TLS_(base_)addr32 for 32-bit TLS addresses in 32-bit mode, and
TLS_(base_)addr64 for 64-bit TLS addresses in 64-bit mode. x32 mode wants 32-bit
TLS addresses in 64-bit mode, which were not yet handled. This adds
TLS_(base_)addrX32 as copies of TLS_(base_)addr64, except that they use
tls32(base)addr rather than tls64(base)addr, and then restricts
TLS_(base_)addr64 to 64-bit LP64 mode, TLS_(base_)addrX32 to 64-bit ILP32 mode.

Reviewed By: RKSimon

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

3 years agoUse PC-relative address for x32 TLS address
H.J. Lu [Tue, 3 Jun 2014 20:22:28 +0000 (13:22 -0700)]
Use PC-relative address for x32 TLS address

Since x32 supports PC-relative address, it shouldn't use EBX for TLS
address.  Instead of checking N.getValueType(), we should check
Subtarget->is32Bit().  This fixes PR 22676.

Reviewed By: RKSimon

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

3 years agoModule: Use FileEntryRef and DirectoryEntryRef in Umbrella, Header, and DirectoryName...
Duncan P. N. Exon Smith [Fri, 30 Oct 2020 20:10:10 +0000 (16:10 -0400)]
Module: Use FileEntryRef and DirectoryEntryRef in Umbrella, Header, and DirectoryName, NFC

Push `FileEntryRef` and `DirectoryEntryRef` further, using it them
`Module::Umbrella`, `Module::Header::Entry`, and
`Module::DirectoryName::Entry`.

- Add `DirectoryEntryRef::operator const DirectoryEntry *` and
  `OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr`, to get the
  same "degrades to `DirectoryEntry*` behaviour `FileEntryRef` enjoys
  (this avoids a bunch of churn in various clang tools).
- Fix the `DirectoryEntryRef` constructor from `MapEntry` to take it by
  `const&`.

Note that we cannot get rid of the `...AsWritten` names leveraging the
new classes, since these need to be as written in the `ModuleMap` file
and the module directory path is preprended for the lookup in the
`FileManager`.

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

3 years ago[gn build] Port 24d4291ca70
LLVM GN Syncbot [Wed, 2 Dec 2020 21:52:41 +0000 (21:52 +0000)]
[gn build] Port 24d4291ca70

3 years ago[libc++] Install missing packages to cross-compile to 32 bits during CI
Louis Dionne [Wed, 2 Dec 2020 21:35:08 +0000 (16:35 -0500)]
[libc++] Install missing packages to cross-compile to 32 bits during CI

3 years ago[CSSPGO] Pseudo probes for function calls.
Hongtao Yu [Wed, 2 Dec 2020 05:44:06 +0000 (21:44 -0800)]
[CSSPGO] Pseudo probes for function calls.

An indirect call site needs to be probed for its potential call targets. With CSSPGO a direct call also needs a probe so that a calling context can be represented by a stack of callsite probes. Unlike pseudo probes for basic blocks that are in form of standalone intrinsic call instructions, pseudo probes for callsites have to be attached to the call instruction, thus a separate instruction would not work.

One possible way of attaching a probe to a call instruction is to use a special metadata that carries information about the probe. The special metadata will have to make its way through the optimization pipeline down to object emission. This requires additional efforts to maintain the metadata in various places. Given that the `!dbg` metadata is a first-class metadata and has all essential support in place , leveraging the `!dbg` metadata as a channel to encode pseudo probe information is probably the easiest solution.

With the requirement of not inflating `!dbg` metadata that is allocated for almost every instruction, we found that the 32-bit DWARF discriminator field which mainly serves AutoFDO can be reused for pseudo probes. DWARF discriminators distinguish identical source locations between instructions and with pseudo probes such support is not required. In this change we are using the discriminator field to encode the ID and type of a callsite probe and the encoded value will be unpacked and consumed right before object emission. When a callsite is inlined, the callsite discriminator field will go with the inlined instructions. The `!dbg` metadata of an inlined instruction is in form of a scope stack. The top of the stack is the instruction's original `!dbg` metadata and the bottom of the stack is for the original callsite of the top-level inliner. Except for the top of the stack, all other elements of the stack actually refer to the nested inlined callsites whose discriminator field (which actually represents a calliste probe) can be used together to represent the inline context of an inlined PseudoProbeInst or CallInst.

To avoid collision with the baseline AutoFDO in various places that handles dwarf discriminators where a check against  the `-pseudo-probe-for-profiling` switch is not available, a special encoding scheme is used to tell apart a pseudo probe discriminator from a regular discriminator. For the regular discriminator, if all lowest 3 bits are non-zero, it means the discriminator is basically empty and all higher 29 bits can be reversed for pseudo probe use.

Callsite pseudo probes are inserted in `SampleProfileProbePass` and a target-independent MIR pass `PseudoProbeInserter` is added to unpack the probe ID/type from `!dbg`.

Note that with this work the switch -debug-info-for-profiling will not work with -pseudo-probe-for-profiling anymore. They cannot be used at the same time.

Reviewed By: wmi

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

3 years ago[dfsan] Rename CachedCombinedShadow to be CachedShadow
Jianzhou Zhao [Wed, 2 Dec 2020 05:48:16 +0000 (05:48 +0000)]
[dfsan] Rename CachedCombinedShadow to be CachedShadow

At D92261, this type will be used to cache both combined shadow and
converted shadow values.

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

3 years ago[dfsan] Test loading global ptrs
Jianzhou Zhao [Wed, 2 Dec 2020 06:03:12 +0000 (06:03 +0000)]
[dfsan] Test loading global ptrs

This covers a branch in the loadShadow method.

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

3 years ago[CUDA][HIP] Fix overloading resolution
Yaxun (Sam) Liu [Wed, 25 Nov 2020 15:33:18 +0000 (10:33 -0500)]
[CUDA][HIP] Fix overloading resolution

This patch implements correct hostness based overloading resolution
in isBetterOverloadCandidate.

Based on hostness, if one candidate is emittable whereas the other
candidate is not emittable, the emittable candidate is better.

If both candidates are emittable, or neither is emittable based on hostness, then
other rules should be used to determine which is better. This is because
hostness based overloading resolution is mostly for determining
viability of a function. If two functions are both viable, other factors
should take precedence in preference.

If other rules cannot determine which is better, CUDA preference will be
used again to determine which is better.

However, correct hostness based overloading resolution
requires overloading resolution diagnostics to be deferred,
which is not on by default. The rationale is that deferring
overloading resolution diagnostics may hide overloading reslolutions
issues in header files.

An option -fgpu-exclude-wrong-side-overloads is added, which is off by
default.

When -fgpu-exclude-wrong-side-overloads is off, keep the original behavior,
that is, exclude wrong side overloads only if there are same side overloads.
This may result in incorrect overloading resolution when there are no
same side candates, but is sufficient for most CUDA/HIP applications.

When -fgpu-exclude-wrong-side-overloads is on, enable deferring
overloading resolution diagnostics and enable correct hostness
based overloading resolution, i.e., always exclude wrong side overloads.

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

3 years ago[dfsan] Add a test case for phi
Jianzhou Zhao [Wed, 2 Dec 2020 06:08:59 +0000 (06:08 +0000)]
[dfsan] Add a test case for phi

3 years agoAdd a less ambiguous macro for Android version.
Dan Albert [Tue, 17 Nov 2020 23:17:17 +0000 (15:17 -0800)]
Add a less ambiguous macro for Android version.

Android has a handful of API levels relevant to developers described
here: https://developer.android.com/studio/build#module-level.
`__ANDROID_API__` is too vague and confuses a lot of people. Introduce
a new macro name that is explicit about which one it represents. Keep
the old name around because code has been using it for a decade.

3 years ago[dfsan] Add test cases for struct/pair
Jianzhou Zhao [Wed, 2 Dec 2020 05:44:03 +0000 (05:44 +0000)]
[dfsan] Add test cases for struct/pair

This is a child diff of D92261.

This locks down the behavior before the change.

3 years ago[ThinLTO][test] Fix X86/nossp.ll after D91816
Fangrui Song [Wed, 2 Dec 2020 21:13:58 +0000 (13:13 -0800)]
[ThinLTO][test] Fix X86/nossp.ll after D91816

3 years ago[MLIR][NFC] Fix mix up between dialect attribute values and names
Uday Bondhugula [Wed, 2 Dec 2020 20:42:01 +0000 (02:12 +0530)]
[MLIR][NFC] Fix mix up between dialect attribute values and names

Clear up documentation on dialect attribute values. Fix/improve
ModuleOp verifier error message on dialect prefixed attribute names.
Additional discussion is here:
https://llvm.discourse.group/t/moduleop-attributes/2325

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

3 years agoUpdate MS ABI mangling for union constants based on new information from
Richard Smith [Wed, 2 Dec 2020 19:36:11 +0000 (11:36 -0800)]
Update MS ABI mangling for union constants based on new information from
Jon Caves.

3 years ago[AArch64] Compiler-rt interface for out-of-line atomics.
Pavel Iliin [Fri, 20 Nov 2020 15:02:57 +0000 (15:02 +0000)]
[AArch64] Compiler-rt interface for out-of-line atomics.

Out-of-line helper functions to support LSE deployment added.
This is a port of libgcc implementation:
https://gcc.gnu.org/git/?p=gcc.git;h=33befddcb849235353dc263db1c7d07dc15c9faa

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

3 years ago[XCOFF][AIX] Alternative path in EHStreamer for platforms do not have uleb128 support
jasonliu [Wed, 2 Dec 2020 18:46:58 +0000 (18:46 +0000)]
[XCOFF][AIX] Alternative path in EHStreamer for platforms do not have uleb128 support

Summary:
Not all system assembler supports `.uleb128 label2 - label1` form.
When the target do not support this form, we have to take
alternative manual calculation to get the offsets from them.

Reviewed By: hubert.reinterpretcast

Diffierential Revision: https://reviews.llvm.org/D92058

3 years ago[CMake][Fuchsia] Install llvm-elfabi
Roland McGrath [Wed, 2 Dec 2020 02:41:56 +0000 (18:41 -0800)]
[CMake][Fuchsia] Install llvm-elfabi

The canonical Fuchsia toolchain configuration installs llvm-elfabi.

Reviewed By: haowei

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

3 years ago[lsan] Use final on Fuchsia ThreadContext declaration
Roland McGrath [Wed, 2 Dec 2020 02:28:10 +0000 (18:28 -0800)]
[lsan] Use final on Fuchsia ThreadContext declaration

This is consistent with other platforms' versions and
eliminates a compiler warning.

Reviewed By: leonardchan

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

3 years ago[libc] Fix couple of corner cases in remquo.
Siva Chandra Reddy [Thu, 19 Nov 2020 05:30:47 +0000 (21:30 -0800)]
[libc] Fix couple of corner cases in remquo.

These two cases are fixed:
1. If numerator is not zero and denominator is infinity, then the
numerator is returned as the remainder.
2. If numerator and denominator are equal in magnitude, then quotient
with the right sign is returned.

The differet tests of remquo, remquof and remquol have been unified
into a single file to avoid duplication.

Reviewed By: lntue

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

3 years ago[Inline] prevent inlining on stack protector mismatch
Nick Desaulniers [Wed, 2 Dec 2020 18:44:35 +0000 (10:44 -0800)]
[Inline] prevent inlining on stack protector mismatch

It's common for code that manipulates the stack via inline assembly or
that has to set up its own stack canary (such as the Linux kernel) would
like to avoid stack protectors in certain functions. In this case, we've
been bitten by numerous bugs where a callee with a stack protector is
inlined into an attribute((no_stack_protector)) caller, which
generally breaks the caller's assumptions about not having a stack
protector. LTO exacerbates the issue.

While developers can avoid this by putting all no_stack_protector
functions in one translation unit together and compiling those with
-fno-stack-protector, it's generally not very ergonomic or as
ergonomic as a function attribute, and still doesn't work for LTO. See also:
https://lore.kernel.org/linux-pm/20200915172658.1432732-1-rkir@google.com/
https://lore.kernel.org/lkml/20200918201436.2932360-30-samitolvanen@google.com/T/#u

SSP attributes can be ordered by strength. Weakest to strongest, they
are: ssp, sspstrong, sspreq.  Callees with differing SSP attributes may be
inlined into each other, and the strongest attribute will be applied to the
caller. (No change)

After this change:
* A callee with no SSP attributes will no longer be inlined into a
  caller with SSP attributes.
* The reverse is also true: a callee with an SSP attribute will not be
  inlined into a caller with no SSP attributes.
* The alwaysinline attribute overrides these rules.

Functions that get synthesized by the compiler may not get inlined as a
result if they are not created with the same stack protector function
attribute as their callers.

Alternative approach to https://reviews.llvm.org/D87956.

Fixes pr/47479.

Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Reviewed By: rnk, MaskRay

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

3 years ago[gn build] Port a65d8c5d720
LLVM GN Syncbot [Wed, 2 Dec 2020 18:50:30 +0000 (18:50 +0000)]
[gn build] Port a65d8c5d720

3 years ago[libc++] Add slice_array operator= valarray overload.
zoecarver [Wed, 2 Dec 2020 18:49:20 +0000 (10:49 -0800)]
[libc++] Add slice_array operator= valarray overload.

Add the slice_array::operator=(const std::valarray<T>& val_arr) overload.

Fixes https://llvm.org/PR40792.

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

3 years ago[mlir][PDL] Use explicit loop over llvm::find to fix MSVC breakage
River Riddle [Wed, 2 Dec 2020 18:42:40 +0000 (10:42 -0800)]
[mlir][PDL] Use explicit loop over llvm::find to fix MSVC breakage

3 years ago[XCOFF][AIX] Generate LSDA data and compact unwind section on AIX
jasonliu [Wed, 2 Dec 2020 14:48:52 +0000 (14:48 +0000)]
[XCOFF][AIX] Generate LSDA data and compact unwind section on AIX

Summary:
AIX uses the existing EH infrastructure in clang and llvm.
The major differences would be
1. AIX do not have CFI instructions.
2. AIX uses a new personality routine, named __xlcxx_personality_v1.
   It doesn't use the GCC personality rountine, because the
   interoperability is not there yet on AIX.
3. AIX do not use eh_frame sections. Instead, it would use a eh_info
section (compat unwind section) to store the information about
personality routine and LSDA data address.

Reviewed By: daltenty, hubert.reinterpretcast

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

3 years ago[JumpThreading][VectorUtils] avoid infinite loop on unreachable IR
Sanjay Patel [Wed, 2 Dec 2020 18:35:05 +0000 (13:35 -0500)]
[JumpThreading][VectorUtils] avoid infinite loop on unreachable IR

https://llvm.org/PR48362

It's possible that we could stub this out sooner somewhere
within JumpThreading, but I'm not sure how to do that, and
then we would still have potential danger in other callers.

I can't find a way to trigger this using 'instsimplify',
however, because that already has a bailout on unreachable
blocks.

3 years ago[flang][NFC] Add GetTopLevelUnitContaining functions
Tim Keith [Wed, 2 Dec 2020 18:28:48 +0000 (10:28 -0800)]
[flang][NFC] Add GetTopLevelUnitContaining functions

`GetTopLevelUnitContaining` returns the Scope nested in the global scope
that contains the given Scope or Symbol.

Use "Get" rather than "Find" in the name because "Find" implies it might
not be found, which can't happen. Following that logic, rename
`FindProgramUnitContaining` to `GetProgramUnitContaining` and have it
also return a reference rather that a pointer.

Note that the use of "ProgramUnit" is slightly confusing. In the Fortran
standard, "program-unit" refers to what is called a "TopLevelUnit" here.
What we are calling a "ProgramUnit" (here and in `ProgramTree`) includes
internal subprograms while "TopLevelUnit" does not.

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

3 years ago[lldb][NFC] Give class template pack test files unique class names
Raphael Isemann [Wed, 2 Dec 2020 18:19:35 +0000 (19:19 +0100)]
[lldb][NFC] Give class template pack test files unique class names

3 years ago[LoopVectorize] Fix optimal-epilog-vectorization-limitations.ll test on non-debug...
Simon Pilgrim [Wed, 2 Dec 2020 18:00:24 +0000 (18:00 +0000)]
[LoopVectorize] Fix optimal-epilog-vectorization-limitations.ll test on non-debug build bots

Add "REQUIRES: asserts" as the test uses the "--debug-only" switch

Should fix the clang-with-thin-lto-ubuntu buildbot failure

3 years ago[Thumb2] Regenerate predicated-liveout-unknown-lanes.ll test
Simon Pilgrim [Wed, 2 Dec 2020 17:52:04 +0000 (17:52 +0000)]
[Thumb2] Regenerate predicated-liveout-unknown-lanes.ll test

Helps to reduce diff in D90113

3 years ago[PowerPC] Regenerate cmpb tests
Simon Pilgrim [Wed, 2 Dec 2020 17:49:00 +0000 (17:49 +0000)]
[PowerPC] Regenerate cmpb tests

Helps to reduce diff in D90113

3 years agoDelete llvm::is_trivially_copyable and CMake variable HAVE_STD_IS_TRIVIALLY_COPYABLE
Fangrui Song [Wed, 2 Dec 2020 17:58:08 +0000 (09:58 -0800)]
Delete llvm::is_trivially_copyable and CMake variable HAVE_STD_IS_TRIVIALLY_COPYABLE

GCC<5 did not support std::is_trivially_copyable. Now LLVM builds
require 5.1 we can delete llvm::is_trivially_copyable after the users
have been migrated to std::is_trivially_copyable.

3 years agoUse std::is_trivially_copyable
Fangrui Song [Wed, 2 Dec 2020 07:40:38 +0000 (23:40 -0800)]
Use std::is_trivially_copyable

GCC<5 did not support std::is_trivially_copyable. Now LLVM builds require 5.1
we can migrate to std::is_trivially_copyable.

3 years ago[test] Make verify-invalid.ll work with legacy and new PMs
Arthur Eubanks [Tue, 1 Dec 2020 22:34:41 +0000 (14:34 -0800)]
[test] Make verify-invalid.ll work with legacy and new PMs