platform/upstream/llvm.git
4 years ago[mlir] Move attr-dict to end of Shape dialect ops
Tres Popp [Fri, 5 Jun 2020 09:22:10 +0000 (11:22 +0200)]
[mlir] Move attr-dict to end of Shape dialect ops

Summary: This is to be consistent with most other assemblyFormat examles in MLIR.

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

4 years ago[ORC] Always use ObjectLinkingLayer/JITLink for MachO on x86-64 and arm64.
Lang Hames [Fri, 5 Jun 2020 21:08:15 +0000 (14:08 -0700)]
[ORC] Always use ObjectLinkingLayer/JITLink for MachO on x86-64 and arm64.

JITLink supports all code and relocation models, so there's no reason to
conditionalize using JITLink on the code or relocation model settings.

Clients wanting to use RTDyldObjectLinkingLayer/RuntimeDyld will now
need to use a custom object linking layer creator.

4 years ago[mlir][mlir-rocm-runner] Detect HIP version and AMD ISA version.
Wen-Heng (Jack) Chung [Fri, 5 Jun 2020 21:26:57 +0000 (16:26 -0500)]
[mlir][mlir-rocm-runner] Detect HIP version and AMD ISA version.

Summary:
Prior to ROCm / HIP 3.5, HSA code object V2 is the default binary format.
Starting from ROCm 3.5, HSA code object V3 becomes default.

Also invoke `rocm_agent_enumerator` to detect proper AMD ISA version on the
system. Use `gfx900` as the fallback value.

Reviewers: jerryyin yaxunl

Subscribers: mgorny, yaxunl, mehdi_amini, rriddle, jpienaar, shauheen, antiagainst, nicolasvasilache, arpith-jacob, mgester, lucyrfox, aartbik, liufengdb, stephenneuendorffer, Joonsoo, grosul1, frgossen, Kayjukh, jurahul, msifontes

Tags: #mlir

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

4 years ago[gn build] Port 29203480632
LLVM GN Syncbot [Sat, 6 Jun 2020 01:50:36 +0000 (01:50 +0000)]
[gn build] Port 29203480632

4 years agoRevert "recommit "[HIP] Add default header and include path""
Nico Weber [Sat, 6 Jun 2020 01:50:04 +0000 (21:50 -0400)]
Revert "recommit "[HIP] Add default header and include path""

This reverts commit 1fa43e0b34d9736f62c6c1b6c371a5e39cd1624d.
Still breaks tests on several bots, see https://reviews.llvm.org/D81176

4 years agoRevert "Migrate the rest of COFFObjectFile to Error"
Nico Weber [Sat, 6 Jun 2020 01:20:11 +0000 (21:20 -0400)]
Revert "Migrate the rest of COFFObjectFile to Error"

This reverts commit b5289656b865d2a73cf90819e20a96fb8414ab0b.
__attribute__((optnone)) doesn't build with msvc, see
http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/16326

4 years ago[gn build] Port 1fa43e0b34d
LLVM GN Syncbot [Sat, 6 Jun 2020 00:47:43 +0000 (00:47 +0000)]
[gn build] Port 1fa43e0b34d

4 years ago[AArch64][GlobalISel] Move dup optimization into post-legalizer combiner
Jessica Paquette [Fri, 5 Jun 2020 00:08:36 +0000 (17:08 -0700)]
[AArch64][GlobalISel] Move dup optimization into post-legalizer combiner

Since all of the other G_SHUFFLE_VECTOR transforms are going there, let's do
this with dup as well. This is nice, because it lets us split up the original
code into matching, register bank selection, and instruction selection.

- Create G_DUP, make it equivalent to AArch64dup

- Add a post-legalizer combine which is 90% a copy-and-paste from
  tryOptVectorDup, except with shuffle matching closer to what SelectionDAG
  does in `ShuffleVectorSDNode::isSplatMask`.

- Teach RegBankSelect about G_DUP. Since dup selection relies on the correct
  register bank for FP/GPR dup selection, this is necessary.

- Kill `tryOptVectorDup`, since it's now entirely handled by G_DUP.

- Add testcases for the combine, RegBankSelect, and selection. The selection
  test gives the same selection results as the old test.

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

4 years ago[mlir] Fix representation of BF16 constants
Diego Caballero [Sat, 6 Jun 2020 00:29:56 +0000 (17:29 -0700)]
[mlir] Fix representation of BF16 constants

This patch is a follow-up on https://reviews.llvm.org/D81127

BF16 constants were represented as 64-bit floating point values due to the lack
of support for BF16 in APFloat. APFloat was recently extended to support
BF16 so this patch is fixing the BF16 constant representation to be 16-bit.

Reviewed By: rriddle

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

4 years agorecommit "[HIP] Add default header and include path"
Yaxun (Sam) Liu [Fri, 5 Jun 2020 20:49:38 +0000 (16:49 -0400)]
recommit "[HIP] Add default header and include path"

recommit 11d06b9511bd25aabbfad10dff548b0ce29135a5 with
fix for lit tests.

4 years agoFix convertBFloatAPFloatToAPInt for NaN/Inf values
Diego Caballero [Sat, 6 Jun 2020 00:06:42 +0000 (17:06 -0700)]
Fix convertBFloatAPFloatToAPInt for NaN/Inf values

Bfloat type has an 8-bit exponent so the exponent of NaN/Inf numbers
must be 0xff instead of 0x1f. This is probably a copy-paste mistake
from the half float type.

Reviewed By: lattner

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

4 years agoPR34581: Don't remove an 'if (p)' guarding a call to 'operator delete(p)' under -Oz.
Richard Smith [Mon, 4 May 2020 23:56:47 +0000 (16:56 -0700)]
PR34581: Don't remove an 'if (p)' guarding a call to 'operator delete(p)' under -Oz.

Summary:
This transformation is correct for a builtin call to 'free(p)', but not
for 'operator delete(p)'. There is no guarantee that a user replacement
'operator delete' has no effect when called on a null pointer.

However, the principle behind the transformation *is* correct, and can
be applied more broadly: a 'delete p' expression is permitted to
unconditionally call 'operator delete(p)'. So do that in Clang under
-Oz where possible. We do this whether or not 'p' has trivial
destruction, since the destruction might turn out to be trivial after
inlining, and even for a class-specific (but non-virtual,
non-destroying, non-array) 'operator delete'.

Reviewers: davide, dnsampaio, rjmccall

Reviewed By: dnsampaio

Subscribers: hiraditya, cfe-commits, llvm-commits

Tags: #clang, #llvm

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

4 years ago[PowerPC] Do not special case Darwin on PowerPC in target cpu handling
stevewan [Fri, 5 Jun 2020 23:54:00 +0000 (19:54 -0400)]
[PowerPC] Do not special case Darwin on PowerPC in target cpu handling

Summary: This patch removes the special handling for Darwin on PowerPC in the default target cpu handling, because Darwin is no longer supported on the PowerPC platform.

Reviewers: hubert.reinterpretcast, daltenty

Reviewed By: hubert.reinterpretcast

Subscribers: wuzish, nemanjai, shchenz, steven.zhang, cfe-commits

Tags: #clang

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

4 years ago[Tests] Migrate a number of tests to gc-live bundle representation
Philip Reames [Fri, 5 Jun 2020 21:48:52 +0000 (14:48 -0700)]
[Tests] Migrate a number of tests to gc-live bundle representation

4 years agoMigrate the rest of COFFObjectFile to Error
Reid Kleckner [Fri, 5 Jun 2020 20:56:51 +0000 (13:56 -0700)]
Migrate the rest of COFFObjectFile to Error

4 years agoRe-land "Migrate Binary::checkOffset from error_code to Error, NFC"
Reid Kleckner [Fri, 5 Jun 2020 23:12:38 +0000 (16:12 -0700)]
Re-land "Migrate Binary::checkOffset from error_code to Error, NFC"

This reverts commit 38f3ba591e3a64fa5bbe684b3171c7bda6c5b527.

Fix the XCOFF error handling. Unlike std::error_code, Error must be
consumed or handled.

4 years agoFix -Wunused-variable in -DLLVM_ENABLE_ASSERTIONS=off builds after ebcbd5ba39c017bb62...
Fangrui Song [Fri, 5 Jun 2020 23:16:49 +0000 (16:16 -0700)]
Fix -Wunused-variable in -DLLVM_ENABLE_ASSERTIONS=off builds after ebcbd5ba39c017bb621eefa3175a224aae85ddc8

4 years agoPR46209: properly determine whether a copy assignment operator is
Richard Smith [Fri, 5 Jun 2020 02:16:05 +0000 (19:16 -0700)]
PR46209: properly determine whether a copy assignment operator is
trivial.

We previously took a shortcut by assuming that if a subobject had a
trivial copy assignment operator (with a few side-conditions), we would
always invoke it, and could avoid going through overload resolution.
That turns out to not be correct in the presenve of ref-qualifiers (and
also won't be the case for copy-assignments with requires-clauses
either). Use the same logic for lazy declaration of copy-assignments
that we use for all other special member functions.

Previously committed as c57f8a3a20540fcf9fbf98c0a73f381ec32fce2a. This
now also includes an extension of LLDB's workaround for handling special
members without the help of Sema to cover copy assignments.

4 years agoSet the captures on a CXXRecordDecl representing a lambda closure type
Richard Smith [Fri, 5 Jun 2020 02:15:22 +0000 (19:15 -0700)]
Set the captures on a CXXRecordDecl representing a lambda closure type
before marking it complete.

No functionality change intended.

Previously committed as c13dd74e311d2ac70dd3ea663d800307d1aa5b6b.

4 years ago[ELF] Don't cause assertion failure if --dynamic-list or --version-script takes an...
Fangrui Song [Fri, 5 Jun 2020 22:59:34 +0000 (15:59 -0700)]
[ELF] Don't cause assertion failure if --dynamic-list or --version-script takes an empty file

Fixes PR46184
Report line 1 of the last memory buffer.

4 years ago[arm][darwin] Don't generate libcalls for wide shifts on Darwin
Alex Lorenz [Fri, 5 Jun 2020 22:40:00 +0000 (15:40 -0700)]
[arm][darwin] Don't generate libcalls for wide shifts on Darwin

Similar to ceb801612a678bdffe7e7bf163bd0eed9c9b73a2.

Darwin doesn't always use compiler-rt, and so we can't assume that these
functions are available on arm.

4 years ago[IRExecutionUnit] Early returns for clarity. NFCI.
Davide Italiano [Fri, 5 Jun 2020 21:51:58 +0000 (14:51 -0700)]
[IRExecutionUnit] Early returns for clarity. NFCI.

4 years ago[mlir][Linalg] NFC - Make useFullTileBuffersByDefault option take a boolean.
Nicolas Vasilache [Fri, 5 Jun 2020 21:44:02 +0000 (17:44 -0400)]
[mlir][Linalg] NFC - Make useFullTileBuffersByDefault option take a boolean.

4 years ago[WebAssembly] Improve clang diagnostics for wasm attributes
Dan Gohman [Fri, 5 Jun 2020 21:27:52 +0000 (14:27 -0700)]
[WebAssembly] Improve clang diagnostics for wasm attributes

This patch addresses the review comments on r352930:

 - Removes redundant diagnostic checking code
 - Removes errnoneous use of diag::err_alias_is_definition, which
   turned out to be ineffective anyway since functions can be defined later
   in the translation unit and avoid detection.
 - Adds a test for various invalid cases for import_name and import_module.

This reapplies D59520, with the addition of adding
`InGroup<IgnoredAttributes>` to the new warnings, to fix the
Misc/warning-flags.c failure.

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

4 years ago[X86] Add test cases for PR46203. NFC
Craig Topper [Fri, 5 Jun 2020 21:27:04 +0000 (14:27 -0700)]
[X86] Add test cases for PR46203. NFC

4 years ago[mlir] Fix spurious f64 -> f16 change in CPU runner test
Nicolas Vasilache [Fri, 5 Jun 2020 21:23:15 +0000 (17:23 -0400)]
[mlir] Fix spurious f64 -> f16 change in CPU runner test

4 years ago[CGP] Remove unnecessary MaybeAlign use (NFC)
Nikita Popov [Fri, 5 Jun 2020 21:18:26 +0000 (23:18 +0200)]
[CGP] Remove unnecessary MaybeAlign use (NFC)

Stores now always have an alignment.

4 years ago[LoopIdiomRecognize] Remove unnecessary MaybeAlign use (NFC)
Nikita Popov [Fri, 5 Jun 2020 21:11:04 +0000 (23:11 +0200)]
[LoopIdiomRecognize] Remove unnecessary MaybeAlign use (NFC)

Loads and stores always have an alignment now.

4 years ago[ASan][Test] Fix globals test for Mach-O
Marco Elver [Fri, 5 Jun 2020 20:56:24 +0000 (22:56 +0200)]
[ASan][Test] Fix globals test for Mach-O

Summary: Use a portable section name, as for the test's purpose any name will do.

Reviewers: nickdesaulniers, thakis

Reviewed By: thakis

Subscribers: cfe-commits

Tags: #clang

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

4 years agoRevert "Migrate Binary::checkOffset from error_code to Error, NFC"
Nico Weber [Fri, 5 Jun 2020 21:00:20 +0000 (17:00 -0400)]
Revert "Migrate Binary::checkOffset from error_code to Error, NFC"

This reverts commit 74bd98829d82312676a60c5c2d142e20691b2f13.
Breaks LLVM::section-headers.test everywhere, see e.g.
http://lab.llvm.org:8011/builders/clang-x86_64-debian-fast/builds/29940/steps/test-check-all/logs/FAIL%3A%20LLVM%3A%3Asection-headers.test

4 years agoFix an oversight in GetXcodeContentsDirectory()
Adrian Prantl [Fri, 5 Jun 2020 18:58:05 +0000 (11:58 -0700)]
Fix an oversight in GetXcodeContentsDirectory()

Since FindXcodeContentsDirectoryInPath expects the *.app/Contents and
DEVELOPER_DIR is supposed to point to Xcode.app, we need to append the
Contents path first.

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

4 years agoFactor out GetEnvDeveloperDir() (NFC)
Adrian Prantl [Fri, 5 Jun 2020 18:38:59 +0000 (11:38 -0700)]
Factor out GetEnvDeveloperDir() (NFC)

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

4 years ago[X86] Fold undef elts to 0 in getTargetVShiftByConstNode.
Craig Topper [Fri, 5 Jun 2020 18:46:07 +0000 (11:46 -0700)]
[X86] Fold undef elts to 0 in getTargetVShiftByConstNode.

Similar to D81212.

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

4 years agoMigrate Binary::checkOffset from error_code to Error, NFC
Reid Kleckner [Fri, 5 Jun 2020 20:32:33 +0000 (13:32 -0700)]
Migrate Binary::checkOffset from error_code to Error, NFC

In my use case, this saved 100ms of time doing one-time-initialization
for std::error_code().

4 years agoAMDGPU/GlobalISel: cmp/select method for extract element
Stanislav Mekhanoshin [Wed, 27 May 2020 20:09:00 +0000 (13:09 -0700)]
AMDGPU/GlobalISel: cmp/select method for extract element

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

4 years ago[codeview] Put !heapallocsite on calls to operator new
Reid Kleckner [Tue, 2 Jun 2020 00:11:06 +0000 (17:11 -0700)]
[codeview] Put !heapallocsite on calls to operator new

Clang marks calls to operator new as heap allocation sites, but the
operator declared at global scope returns a void pointer. There is no
explicit cast in the code, so the compiler has to write down the
allocated type itself.

Also generalize a cast to use CallBase, so that we mark heap alloc sites
when exceptions are enabled.

Reviewed By: MaskRay

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

4 years ago[gn build] Port 8a8c6913a93
LLVM GN Syncbot [Fri, 5 Jun 2020 19:48:20 +0000 (19:48 +0000)]
[gn build] Port 8a8c6913a93

4 years agoSROA: Remove pointer from visited along with instruction
Stanislav Mekhanoshin [Mon, 1 Jun 2020 21:35:12 +0000 (14:35 -0700)]
SROA: Remove pointer from visited along with instruction

If an instruction is erased we also need to remove it from
Visited set. There is a very small chance that an another
newly created instruction will be created with the same
pointer value in place of an erased one.

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

4 years agoRevert "[HIP] Add default header and include path"
Yaxun (Sam) Liu [Fri, 5 Jun 2020 19:41:00 +0000 (15:41 -0400)]
Revert "[HIP] Add default header and include path"

This reverts commit 11d06b9511bd25aabbfad10dff548b0ce29135a5.

4 years agoAttempt to fix hip-include-path.hip
Yaxun (Sam) Liu [Fri, 5 Jun 2020 19:31:11 +0000 (15:31 -0400)]
Attempt to fix hip-include-path.hip

4 years agolld: use modern library search ordering
Saleem Abdulrasool [Fri, 5 Jun 2020 00:40:41 +0000 (17:40 -0700)]
lld: use modern library search ordering

This merges the static and shared library and behaves as if
`-search_paths_first` was specified which is also the default behaviour
on ld64 (and now lld). Unify the paths, and use `llvm::sys::path` to
deal with the path to be truly agnostic to the host.

4 years ago[llvm-pdbutil] Add missing --id-stats to dump the IPI stream
Alexandre Ganea [Thu, 4 Jun 2020 19:30:45 +0000 (15:30 -0400)]
[llvm-pdbutil] Add missing --id-stats to dump the IPI stream

Before this patch, llvm-pdbutil supported only --type-stats to dump stats about a PDB TPI stream.
Adding --id-stats for completion.

4 years agoGlobalISel: Add helper for constructing load from offset
Matt Arsenault [Sun, 31 May 2020 00:28:36 +0000 (20:28 -0400)]
GlobalISel: Add helper for constructing load from offset

4 years agoTeach GetXcodeSDK to look in the Xcode that contains LLDB
Adrian Prantl [Fri, 5 Jun 2020 02:02:11 +0000 (19:02 -0700)]
Teach GetXcodeSDK to look in the Xcode that contains LLDB

instead of preferring the one chosen with xcode-select.

<rdar://problem/64000666>

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

4 years agoMove GetXcode*Directory into HostInfo (NFC)
Adrian Prantl [Fri, 5 Jun 2020 00:57:11 +0000 (17:57 -0700)]
Move GetXcode*Directory into HostInfo (NFC)

These functions really don't belong into PlatformDarwin, since they
actualy query state of the Host and not of the remote platform.

4 years agoGlobalISel: Make known bits/alignment API more consistent
Matt Arsenault [Thu, 4 Jun 2020 02:06:49 +0000 (22:06 -0400)]
GlobalISel: Make known bits/alignment API more consistent

Just computing the alignment makes sense without caring about the
general known bits, such as for non-integral pointers. Separate the
two and start calling into the TargetLowering hooks for frame indexes.

Start calling the TargetLowering implementation for FrameIndexes,
which improves the AMDGPU matching for stack addressing modes. Also
introduce a new hook for returning known alignment of target
instructions. For AMDGPU, it would be useful to report the known
alignment implied by certain intrinsic calls.

Also stop using MaybeAlign.

4 years agoGlobalISel: Add G_EXTRACT/G_INSERT offset to legalize info
Matt Arsenault [Sat, 16 May 2020 14:41:35 +0000 (10:41 -0400)]
GlobalISel: Add G_EXTRACT/G_INSERT offset to legalize info

Immediate legalize fields were added for G_SEXT_INREG. Simiarly, these
are likely not legal except for certain offsets.

4 years agoRevert "[WebAssembly] Improve clang diagnostics for wasm attributes"
Dan Gohman [Fri, 5 Jun 2020 18:52:11 +0000 (11:52 -0700)]
Revert "[WebAssembly] Improve clang diagnostics for wasm attributes"

It broke clang-check.

This reverts commit 931fcd3ba011c27626a95e5e35b657763284882a.

4 years agoCorrectly report modified status for AMDGPUUnifyDivergentExitNodes
Jay Foad [Fri, 5 Jun 2020 16:12:32 +0000 (17:12 +0100)]
Correctly report modified status for AMDGPUUnifyDivergentExitNodes

Related to https://reviews.llvm.org/D80916

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

4 years agoFix -Wunused-variable after D80515
Fangrui Song [Fri, 5 Jun 2020 18:46:50 +0000 (11:46 -0700)]
Fix -Wunused-variable after D80515

4 years ago[gn build] (manually) merge 5eedf07ab999d
Nico Weber [Fri, 5 Jun 2020 18:39:04 +0000 (14:39 -0400)]
[gn build] (manually) merge 5eedf07ab999d

4 years agoAttempt to fix hip-include-path.hip
Yaxun (Sam) Liu [Fri, 5 Jun 2020 18:36:17 +0000 (14:36 -0400)]
Attempt to fix hip-include-path.hip

4 years agoAMDGPU: Fix incorrect selection of buffer atomic fadd
Matt Arsenault [Fri, 5 Jun 2020 17:57:29 +0000 (13:57 -0400)]
AMDGPU: Fix incorrect selection of buffer atomic fadd

There were additional standalone patterns for these nodes which were
missing the subtarget predicate.

4 years agoAMDGPU: Fix missing immarg on buffer.atomic.fadd intrinsic
Matt Arsenault [Fri, 5 Jun 2020 17:48:59 +0000 (13:48 -0400)]
AMDGPU: Fix missing immarg on buffer.atomic.fadd intrinsic

4 years ago[X86] Teach combineVectorShiftImm to constant fold undef elements to 0 not undef.
Craig Topper [Fri, 5 Jun 2020 17:49:21 +0000 (10:49 -0700)]
[X86] Teach combineVectorShiftImm to constant fold undef elements to 0 not undef.

Shifts are supposed to always shift in zeros or sign bits regardless of their inputs. It's possible the input value may have been replaced with undef by SimplifyDemandedBits, but the shift in zeros are still demanded.

This issue was reported to me by ispc from 10.0. Unfortunately their failing test does not fail on trunk. Seems to be because the shl is optimized out earlier now and doesn't become VSHLI.

ispc bug https://github.com/ispc/ispc/issues/1771

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

4 years ago[WebAssembly] Improve clang diagnostics for wasm attributes
Dan Gohman [Sat, 21 Dec 2019 06:11:03 +0000 (22:11 -0800)]
[WebAssembly] Improve clang diagnostics for wasm attributes

This patch addresses the review comments on r352930:

 - Removes redundant diagnostic checking code
 - Removes errnoneous use of diag::err_alias_is_definition, which
   turned out to be ineffective anyway since functions can be defined later
   in the translation unit and avoid detection.
 - Adds a test for various invalid cases for import_name and import_module.

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

4 years ago[hwasan] Disable malloc-fill by default.
Evgenii Stepanov [Fri, 5 Jun 2020 17:57:44 +0000 (10:57 -0700)]
[hwasan] Disable malloc-fill by default.

Summary: Non-zero malloc fill is causing way too many hard to debug issues.

Reviewers: kcc, pcc, hctim

Subscribers: #sanitizers, llvm-commits

Tags: #sanitizers

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

4 years ago[KernelAddressSanitizer] Make globals constructors compatible with kernel
Marco Elver [Fri, 29 May 2020 10:52:27 +0000 (12:52 +0200)]
[KernelAddressSanitizer] Make globals constructors compatible with kernel

Summary:
This makes -fsanitize=kernel-address emit the correct globals
constructors for the kernel. We had to do the following:

- Disable generation of constructors that rely on linker features such
  as dead-global elimination.

- Only emit constructors for globals *not* in explicit sections. The
  kernel uses sections for special globals, which we should not touch.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=203493

Tested:
1. With 'clang/test/CodeGen/asan-globals.cpp'.
2. With test_kasan.ko, we can see:

   BUG: KASAN: global-out-of-bounds in kasan_global_oob+0xb3/0xba [test_kasan]

Reviewers: glider, andreyknvl

Reviewed By: glider

Subscribers: cfe-commits, nickdesaulniers, hiraditya, llvm-commits

Tags: #llvm, #clang

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

4 years ago[LiveDebugValues] Fix output stream (NFC)
Nikita Popov [Sat, 30 May 2020 14:07:44 +0000 (16:07 +0200)]
[LiveDebugValues] Fix output stream (NFC)

This should dump to the provided Out, rather than dbgs(), though
they coincide in current usage.

4 years ago[LiveDebugValues] Remove PendingInLocs (NFC)
Nikita Popov [Sat, 30 May 2020 14:13:41 +0000 (16:13 +0200)]
[LiveDebugValues] Remove PendingInLocs (NFC)

PendingInLocs ends up having the same value as InLocs, just computed
a bit more indirectly. It is a leftover of a previous implementation
approach.

This patch drops PendingInLocs, as well as the Diff and Removed
calulations, which are no longer needed.

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

4 years agoAMDGPU/GlobalISel: Fix some broken YAML in MIR test
Matt Arsenault [Sun, 31 May 2020 18:59:52 +0000 (14:59 -0400)]
AMDGPU/GlobalISel: Fix some broken YAML in MIR test

Different tools seem to be more or less strict with the markers
between different functions.

4 years agoGlobalISel: Infer nofpexcept flag during selection for non-strict ops
Matt Arsenault [Sun, 31 May 2020 18:19:46 +0000 (14:19 -0400)]
GlobalISel: Infer nofpexcept flag during selection for non-strict ops

Match SelectionDAG's behavior of adding nofpexcept to out instructions
that may raise fp exceptions that are selected from instructions that
do not.

4 years ago[apple clang] disable in-process CC1 to preserve crashlog compatibility
Alex Lorenz [Fri, 5 Jun 2020 17:54:03 +0000 (10:54 -0700)]
[apple clang] disable in-process CC1 to preserve crashlog compatibility

The in-process CC1 currently doesn't interoperate with the macOS crash analytics,
which we would like to keep enabled for Apple clang. This commit restores the
out-of-process CC1 to the Apple clang CMake configuration for now.

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

4 years ago[llvm-objcopy] Reorder --dump-section for MachO
Sameer Arora [Fri, 5 Jun 2020 17:47:05 +0000 (10:47 -0700)]
[llvm-objcopy] Reorder --dump-section for MachO

Reorder `DumpSection` under `handleArgs` in file `MachOObjcopy.cpp`. The
operation to dump a section is now performed before both add and remove
section operations for MachO file format.

Change for the ELF format at D81097. Together fixes
https://bugs.llvm.org/show_bug.cgi?id=44283

Reviewed By: jhenderson

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

4 years ago[mlir][test][CPU] Reduce the size of mlir-cpu-runner-tests
Nicolas Vasilache [Fri, 5 Jun 2020 17:41:05 +0000 (13:41 -0400)]
[mlir][test][CPU] Reduce the size of mlir-cpu-runner-tests

Two tests regularly show up on the long tail when testing MLIR.
This revision reduces their size.

4 years ago[llvm-objcopy] Reorder --dump-section before --remove-section for ELF
Sameer Arora [Fri, 5 Jun 2020 17:42:19 +0000 (10:42 -0700)]
[llvm-objcopy] Reorder --dump-section before --remove-section for ELF

Reorder `DumpSection` under `handleArgs` in file `ELFObjcopy.cpp`.
`DumpSection` is placed before `replaceAndRemoveSections` and is
therefore now the first operation under `handleArgs`. Thus, it is now
performed before both `add` and `remove` section operations.

Change for the MachO format at D81123. Together fixes https://bugs.llvm.org/show_bug.cgi?id=44283.

Reviewed By: alexshap, jhenderson, MaskRay

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

4 years ago[libc++] Avoid passing -xc++ in Lit feature detection
Louis Dionne [Fri, 5 Jun 2020 17:39:49 +0000 (13:39 -0400)]
[libc++] Avoid passing -xc++ in Lit feature detection

Otherwise, if %{flags} contain other files like static libraries, those
files are treated as C++ source files instead of object files, and the
compiler gets all confused.

4 years ago[ARM] VQMOVN demand bits analysis
David Green [Fri, 5 Jun 2020 14:34:15 +0000 (15:34 +0100)]
[ARM] VQMOVN demand bits analysis

Similar to VMOVN, a VQMOVN will only demand the top/bottom lanes of it's
first input. However unlike VMOVN it will need access to the entire
second argument, as that value is saturated not just moved in place.

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

4 years ago[llvm-ar] Update error messages and tests as per latest preferred style
Sameer Arora [Fri, 5 Jun 2020 17:29:24 +0000 (10:29 -0700)]
[llvm-ar] Update error messages and tests as per latest preferred style

It updates two error messages under `performOperation` in the file
llvm-ar.cpp. Furthermore, it also updates tests that print out these
error messages: `llvm/test/Object/ar-create.test` and
`llvm/test/tools/llvm-ar/print.test`.

Reviewed By: jhenderson, MaskRay

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

4 years ago[llvm-ar] Add more tests for errors in opening archives
Sameer Arora [Fri, 5 Jun 2020 17:29:18 +0000 (10:29 -0700)]
[llvm-ar] Add more tests for errors in opening archives

Add 2 more tests for the function performOperation under llvm-ar.cpp. It
tests the scenario when the archive could not be opened for reasons
other than `no_such_file_or_directory` In particular, it tests for the
cases `permission_denied` and `is_a_directory` for the target archive.

Reviewed By: alexshap, jhenderson, smeenai, MaskRay

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

4 years ago[mlir][Vector] Add folding of memref_cast into vector_transfer ops
Nicolas Vasilache [Fri, 5 Jun 2020 17:20:59 +0000 (13:20 -0400)]
[mlir][Vector] Add folding of memref_cast into vector_transfer ops

Summary:
This revision adds a common folding pattern that starts appearing on
vector_transfer ops.

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

4 years ago[gn build] Port 11d06b9511b
LLVM GN Syncbot [Fri, 5 Jun 2020 17:22:19 +0000 (17:22 +0000)]
[gn build] Port 11d06b9511b

4 years agoFix lit tests hip-include-path.hip and hip-host-cpu-macros.cu
Yaxun (Sam) Liu [Fri, 5 Jun 2020 17:21:24 +0000 (13:21 -0400)]
Fix lit tests hip-include-path.hip and hip-host-cpu-macros.cu

4 years agoReland D80640: [CodeGen][SVE] Calculate correct type legalization for scalable vectors.
Sander de Smalen [Fri, 5 Jun 2020 15:46:25 +0000 (16:46 +0100)]
Reland D80640: [CodeGen][SVE] Calculate correct type legalization for scalable vectors.

This reverts commit 9bcef270d7a319c6c0fdffc6c80984a8f0a30ecb.

4 years ago[libc++abi] Properly fix XFAILs for exception alignment
Louis Dionne [Fri, 5 Jun 2020 17:06:37 +0000 (13:06 -0400)]
[libc++abi] Properly fix XFAILs for exception alignment

Since <unwind.h> is in the SDK, not in /usr/include, the XFAILs must
be predicated on the compiler version (ideally even on the SDK version)
instead of the target system version.

4 years ago[mlir][Linalg] NFC - Cleanup debug, address post-commit review.
Nicolas Vasilache [Fri, 5 Jun 2020 17:02:13 +0000 (13:02 -0400)]
[mlir][Linalg] NFC - Cleanup debug, address post-commit review.

4 years ago[mlir] Add verify method to adaptor
Jacques Pienaar [Fri, 5 Jun 2020 16:47:37 +0000 (09:47 -0700)]
[mlir] Add verify method to adaptor

This allows verifying op-indepent attributes (e.g., attributes that do not require the op to have been created) before constructing an operation. These include checking whether required attributes are defined or constraints on attributes (such as I32 attribute). This is not perfect (e.g., if one had a disjunctive constraint where one part relied on the op and the other doesn't, then this would not try and extract the op independent from the op dependent).

The next step is to move these out to a trait that could be verified earlier than in the generated method. The first use case is for inferring the return type while constructing the op. At that point you don't have an Operation yet and that ends up in one having to duplicate the same checks, e.g., verify that attribute A is defined before querying A in shape function which requires that duplication. Instead this allows one to invoke a method to verify all the traits and, if this is checked first during verification, then all other traits could use attributes knowing they have been verified.

It is a little bit funny to have these on the adaptor, but I see the adaptor as a place to collect information about the op before the op is constructed (e.g., avoiding stringly typed accessors, verifying what is possible to verify before the op is constructed) while being cheap to use even with constructed op (so layer of indirection between the op constructed/being constructed). And from that point of view it made sense to me.

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

4 years ago[CMake] Do not append -lm to CMAKE_REQUIRED_LIBRARIES on Apple
Louis Dionne [Fri, 5 Jun 2020 15:12:47 +0000 (11:12 -0400)]
[CMake] Do not append -lm to CMAKE_REQUIRED_LIBRARIES on Apple

On Apple platforms, linking against libSystem.dylib is sufficient, and
some Apple platforms don't provide libm.dylib. On those platforms, adding
-lm to CMAKE_REQUIRED_LIBRARIES causes all subsequent compile-flag checks
to fail due to the missing library.

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

4 years ago[HIP] Add default header and include path
Yaxun (Sam) Liu [Wed, 3 Jun 2020 14:05:52 +0000 (10:05 -0400)]
[HIP] Add default header and include path

To support std::complex and some other standard C/C++ functions in HIP device code,
they need to be forced to be __host__ __device__ functions by pragmas. This is done
by some clang standard C++ wrapper headers which are shared between cuda-clang and hip-Clang.

For these standard C++ wapper headers to work properly, specific include path order
has to be enforced:

  clang C++ wrapper include path
  standard C++ include path
  clang include path

Also, these C++ wrapper headers require device version of some standard C/C++ functions
must be declared before including them. This needs to be done by including a default
header which declares or defines these device functions. The default header is always
included before any other headers are included by users.

This patch adds the the default header and include path for HIP.

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

4 years agoScalarEvolutionNormalization.h - reduce ScalarEvolutionExpressions.h include to forwa...
Simon Pilgrim [Fri, 5 Jun 2020 16:40:19 +0000 (17:40 +0100)]
ScalarEvolutionNormalization.h - reduce ScalarEvolutionExpressions.h include to forward declaration. NFC.

4 years agoTypeMetadataUtils.h - reduce Instructions.h include to forward declaration. NFC.
Simon Pilgrim [Fri, 5 Jun 2020 16:27:55 +0000 (17:27 +0100)]
TypeMetadataUtils.h - reduce Instructions.h include to forward declaration. NFC.

Move implicit include dependencies down to source file.

4 years ago[x86] form reduction intrinsics from vectorizers instead of raw IR
Sanjay Patel [Fri, 5 Jun 2020 16:20:13 +0000 (12:20 -0400)]
[x86] form reduction intrinsics from vectorizers instead of raw IR

Motivating examples are seen in the PhaseOrdering tests based on:
https://bugs.llvm.org/show_bug.cgi?id=43953#c2 - if we have
intrinsics there, some pass can fold them.

The intrinsics are still named "experimental" at this point, but
if there is no fallout from this patch, that will be a good
indicator that it is safe to finalize them.

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

4 years ago[PhaseOrdering] add tests for reductions; NFC (PR43953)
Sanjay Patel [Fri, 5 Jun 2020 14:11:21 +0000 (10:11 -0400)]
[PhaseOrdering] add tests for reductions; NFC (PR43953)

4 years ago[gn build] (manually) port a6fcf5ca033
Nico Weber [Fri, 5 Jun 2020 16:32:23 +0000 (12:32 -0400)]
[gn build] (manually) port a6fcf5ca033

4 years agoAdd ASan metadata globals to @llvm.compiler.used under COFF
Arthur Eubanks [Thu, 4 Jun 2020 16:48:42 +0000 (09:48 -0700)]
Add ASan metadata globals to @llvm.compiler.used under COFF

Summary:
This matches ELF.

This makes the number of ASan failures under the new pass manager on
Windows go from 18 to 1.

Under the old pass manager, the ASan module pass was one of the very
last things run, so these globals didn't get removed due to GlobalOpt.
But with the NPM the ASan module pass that adds these globals are run
much earlier in the pipeline and GlobalOpt ends up removing them.

Reviewers: vitalybuka, hans

Subscribers: hiraditya, llvm-commits

Tags: #llvm

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

4 years agoMark lambda in use-after-scope-capture.cpp as noinline
Arthur Eubanks [Thu, 4 Jun 2020 20:08:35 +0000 (13:08 -0700)]
Mark lambda in use-after-scope-capture.cpp as noinline

Summary:
As explained in https://bugs.llvm.org/show_bug.cgi?id=46208,
symbolization on Windows after inlining and around
lambdas/std::functions doesn't work very well. Under the new pass
manager, there is inlining at -O1.
use-after-scope-capture.cpp checks that the symbolization points to the
line containing "return x;", but the combination of
Windows/inlining/lambdas makes the symbolization point to the line
"f = [&x]() {".

Mark the lambda as noinline since this test is not a test for
symbolization.

Reviewers: hans, dblaikie, vitalybuka

Subscribers: #sanitizers

Tags: #sanitizers

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

4 years ago[X86][SSE] Simplify MOVMSK patterns based on comparison
Simon Pilgrim [Fri, 5 Jun 2020 15:53:10 +0000 (16:53 +0100)]
[X86][SSE] Simplify MOVMSK patterns based on comparison

An initial patch adding combineSetCCMOVMSK to simplify MOVMSK and its vector input based on the comparison of the MOVMSK result.

This first stage just adds support for some simple MOVMSK(PACKSSBW()) cases where we remove the PACKSS if we're comparing ne/eq zero (any_of patterns), allowing us to directly compare against the v8i16 source vector(s) bitcasted to v16i8, with suitable masking to take into account of which signbits are valid.

Future combines could peek through further PACKSS, target shuffles, handle all_of patterns (ne/eq -1), optimize to a PTEST op, etc.

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

4 years agoFix the roundtrip test under llvm-profdata
Xun Li [Fri, 5 Jun 2020 15:51:54 +0000 (08:51 -0700)]
Fix the roundtrip test under llvm-profdata

Summary:
According to the comments, we want to convert the profile into two binary formats, and then into the md5text format.
We seems to have ignored the intermediate files.
This patch uses them to complete the full roundtrips.

Reviewers: wmi, wenlei

Reviewed By: wmi

Subscribers: llvm-commits

Tags: #llvm

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

4 years ago[flang] Fix crash on erroneous expressions
Pete Steinfeld [Wed, 3 Jun 2020 15:03:14 +0000 (08:03 -0700)]
[flang] Fix crash on erroneous expressions

Summary:
If you create an expression with parse errors, the `parser::Expr.typedExpr`
will be empty, which causes a compiler crash.  The crash is caused by the
check in check-do-forall.cpp that scans all expresssions to see if `DO`
variables are being modified.

It turned out that the problem was that I was fetching subexpressions of type
`parser::Expr`, which are not guaranteed to have a non-null `typedExpr`.  I
fixed this by only grabbing the top-level expression from which to gather
arguments as part of the DO loop analysis.  This, in turn, exposed a problem
where I wasn't collecting all of the actual arguments in an expression.  This
was caused by the fact that I wasn't recursing through the rest of the
expression after finding an argument.  I fixed this by recursing through the
argument in the member function in `CollectActualArgumentsHelper`.

Reviewers: klausler, tskeith, DavidTruby

Subscribers: llvm-commits

Tags: #llvm

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

4 years ago[ELF] Handle -u before input files
Fangrui Song [Fri, 5 Jun 2020 15:41:03 +0000 (08:41 -0700)]
[ELF] Handle -u before input files

If both a.a and b.so define foo

```
ld.bfd -u foo a.a b.so  # foo is defined
ld.bfd a.a b.so -u foo  # foo is defined
ld.bfd -u foo b.so a.a  # foo is undefined (provided at runtime by b.so)
ld.bfd b.so a.a -u foo  # foo is undefined (provided at runtime by b.so)
```

In all cases we make foo undefined in the output.  I tend to think the
GNU ld behavior makes more sense.

* In their model, they have to treat -u as a fake object file with an
  undefined symbol before all input files, otherwise the first archive would not be fetched.
* Following their behavior allows us to drop a --warn-backrefs special case.

Reviewed By: psmith

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

4 years agoFix crash on misc-redundant-expression
Zinovy Nis [Sun, 31 May 2020 18:53:13 +0000 (21:53 +0300)]
Fix crash on misc-redundant-expression

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

4 years ago[dsymutil] Don't emit N_AST symbol entries in the Mach-O companion file
Jonas Devlieghere [Fri, 5 Jun 2020 15:39:02 +0000 (08:39 -0700)]
[dsymutil] Don't emit N_AST symbol entries in the Mach-O companion file

Treat N_AST symbol table entries like other debug entries and don't emit
them in the linked binary.

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

4 years ago[mlir][SCF] Add single iteration scf.for promotion to the FuncOp level helper.
Nicolas Vasilache [Fri, 5 Jun 2020 15:23:43 +0000 (11:23 -0400)]
[mlir][SCF] Add single iteration scf.for promotion to the FuncOp level helper.

Previously only the Affine version would be folded.

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

4 years ago[lit] Improve naming of test result categories
Julian Lettner [Wed, 8 Apr 2020 05:48:39 +0000 (22:48 -0700)]
[lit] Improve naming of test result categories

Improve consistency when printing test results:
Previously we were using different labels for group names (the header
for the list of, e.g., failing tests) and summary count lines.  For
example, "Failing Tests"/"Unexpected Failures".  This commit changes lit
to label things consistently.

Improve wording of labels:
When talking about individual test results, the first word in
"Unexpected Failures", "Expected Passes", and "Individual Timeouts" is
superfluous.  Some labels contain the word "Tests" and some don't.
Let's simplify the names.

Before:
```
Failing Tests (1):
  ...

Expected Passes    : 3
Unexpected Failures: 1
```

After:
```
Failed Tests (1):
  ...

Passed: 3
Failed: 1
```

Reviewed By: ldionne

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

4 years agoRevert "[CodeGen][SVE] Calculate correct type legalization for scalable vectors."
Sander de Smalen [Fri, 5 Jun 2020 15:03:13 +0000 (16:03 +0100)]
Revert "[CodeGen][SVE] Calculate correct type legalization for scalable vectors."

Seems to break some buildbots, reverting the patch for now.

This reverts commit 164f4b9d26fdf3cd640a09b63b5ec44d033cbe8a.

4 years ago[AST] Record SourceLocation for TypoExpr.
Haojian Wu [Tue, 2 Jun 2020 14:35:29 +0000 (16:35 +0200)]
[AST] Record SourceLocation for TypoExpr.

Reviewers: sammccall

Subscribers: cfe-commits

Tags: #clang

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

4 years ago[VE] Support logical operation instructions in MC layer
Kazushi (Jam) Marukawa [Fri, 5 Jun 2020 14:57:37 +0000 (16:57 +0200)]
[VE] Support logical operation instructions in MC layer

Summary:
Add regression tests of asmparser, mccodeemitter, and disassembler for
logical operation instructions. Also change asmparser to support CMOV
instruction. And, add new EQV/MRG/NND isntructions also.

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

4 years ago[mlir][gpu] Introduce mlir-rocm-runner.
Wen-Heng (Jack) Chung [Wed, 20 May 2020 21:07:49 +0000 (16:07 -0500)]
[mlir][gpu] Introduce mlir-rocm-runner.

Summary:
`mlir-rocm-runner` is introduced in this commit to execute GPU modules on ROCm
platform. A small wrapper to encapsulate ROCm's HIP runtime API is also inside
the commit.

Due to behavior of ROCm, raw pointers inside memrefs passed to `gpu.launch`
must be modified on the host side to properly capture the pointer values
addressable on the GPU.

LLVM MC is used to assemble AMD GCN ISA coming out from
`ConvertGPUKernelToBlobPass` to binary form, and LLD is used to produce a shared
ELF object which could be loaded by ROCm HIP runtime.

gfx900 is the default target be used right now, although it could be altered via
an option in `mlir-rocm-runner`. Future revisions may consider using ROCm Agent
Enumerator to detect the right target on the system.

Notice AMDGPU Code Object V2 is used in this revision. Future enhancements may
upgrade to AMDGPU Code Object V3.

Bitcode libraries in ROCm-Device-Libs, which implements math routines exposed in
`rocdl` dialect are not yet linked, and is left as a TODO in the logic.

Reviewers: herhut

Subscribers: mgorny, tpr, dexonsmith, mehdi_amini, rriddle, jpienaar, shauheen, antiagainst, nicolasvasilache, csigg, arpith-jacob, mgester, lucyrfox, aartbik, liufengdb, stephenneuendorffer, Joonsoo, grosul1, frgossen, Kayjukh, jurahul, llvm-commits

Tags: #mlir, #llvm

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

4 years ago[CodeGen][SVE] Calculate correct type legalization for scalable vectors.
Sander de Smalen [Fri, 5 Jun 2020 11:54:39 +0000 (12:54 +0100)]
[CodeGen][SVE] Calculate correct type legalization for scalable vectors.

This patch updates TargetLoweringBase::computeRegisterProperties and
TargetLoweringBase::getTypeConversion to support scalable vectors,
and make the right calls on how to legalise them. These changes are required
to legalise both MVTs and EVTs.

Reviewers: efriedma, david-arm, ctetreau

Reviewed By: efriedma

Tags: #llvm

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

4 years ago[SCCP] Report changes after removing stores to constant global
serge-sans-paille [Thu, 4 Jun 2020 21:33:03 +0000 (23:33 +0200)]
[SCCP] Report changes after removing stores to constant global

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