platform/upstream/llvm.git
4 years ago[FIX] Repair clang-tidy check after D72304
Johannes Doerfert [Sat, 15 Feb 2020 06:58:42 +0000 (00:58 -0600)]
[FIX] Repair clang-tidy check after D72304

4 years ago[OpenMP][OMPIRBuilder] Add Directives (master and critical) to OMPBuilder.
Fady Ghanim [Sat, 15 Feb 2020 06:42:23 +0000 (00:42 -0600)]
[OpenMP][OMPIRBuilder] Add Directives (master and critical) to OMPBuilder.

Add support for Master and Critical directive in the OMPIRBuilder. Both make use of a new common interface for emitting inlined OMP regions called `emitInlinedRegion` which was added in this patch as well.

Also this patch modifies clang to use the new directives when  `-fopenmp-enable-irbuilder` commandline option is passed.

Reviewed By: jdoerfert

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

4 years ago[MCStreamer] De-capitalize EmitValue EmitIntValue{,InHex}
Fangrui Song [Sat, 15 Feb 2020 06:40:47 +0000 (22:40 -0800)]
[MCStreamer] De-capitalize EmitValue EmitIntValue{,InHex}

4 years agoNFC: add indexing operator for ArrayAttr
Uday Bondhugula [Sat, 15 Feb 2020 06:54:18 +0000 (22:54 -0800)]
NFC: add indexing operator for ArrayAttr

Summary: - add ArrayAttr::operator[](unsigned idx)

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

4 years ago[OpenMP][NFC] Update OpenMPSupport table
Johannes Doerfert [Sat, 15 Feb 2020 06:40:39 +0000 (00:40 -0600)]
[OpenMP][NFC] Update OpenMPSupport table

4 years ago[OpenMP][NFCI] Use the libFrontend DefaultKind in Clang
Atmn Patel [Sat, 15 Feb 2020 03:45:49 +0000 (21:45 -0600)]
[OpenMP][NFCI] Use the libFrontend DefaultKind in Clang

This swaps out the OpenMPDefaultClauseKind enum with a
llvm::omp::DefaultKind enum which is stored in OMPConstants.h.

This should not change any functionality.

Reviewed By: jdoerfert

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

4 years ago[Attributor] Fix -Wunused-variable for -DLLVM_ENABLE_ASSERTIONS=off builds after...
Fangrui Song [Sat, 15 Feb 2020 05:47:19 +0000 (21:47 -0800)]
[Attributor] Fix -Wunused-variable for -DLLVM_ENABLE_ASSERTIONS=off builds after b4352e43d86e

4 years ago[AsmPrinter] Omit unique ID for .stack_sizes
Fangrui Song [Sat, 15 Feb 2020 05:14:31 +0000 (21:14 -0800)]
[AsmPrinter] Omit unique ID for .stack_sizes

Follow-up for D74006.

4 years ago[AsmPrinter][XRay] Omit unique ID for xray_instr_map and xray_fn_idx
Fangrui Song [Sat, 15 Feb 2020 05:02:26 +0000 (21:02 -0800)]
[AsmPrinter][XRay] Omit unique ID for xray_instr_map and xray_fn_idx

Follow-up for D74006.

4 years ago[AArch64][FPenv] Update chain of int to fp conversion
Diogo Sampaio [Sat, 15 Feb 2020 05:05:15 +0000 (05:05 +0000)]
[AArch64][FPenv] Update chain of int to fp conversion

Summary:
When using strict fp, it is required to update the
chain when performing integer type promotion of a
operand to a integer to floating point conversion.

Reviewers: craig.topper, john.brawn

Reviewed By: craig.topper

Subscribers: kristof.beyls, hiraditya, llvm-commits

Tags: #llvm

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

4 years ago[AsmPrinter] Omit unique ID for __patchable_function_entries sections
Fangrui Song [Sat, 15 Feb 2020 04:35:04 +0000 (20:35 -0800)]
[AsmPrinter] Omit unique ID for __patchable_function_entries sections

Follow-up for D74006.

When the integrated assembler is used, we use SHF_LINK_ORDER.  The
linked-to symbol is part of ELFSectionKey, thus we can omit the unique
ID.

4 years ago[MC] Add MCSection::NonUniqueID and delete one MCContext::getELFSection overload
Fangrui Song [Sat, 15 Feb 2020 04:15:55 +0000 (20:15 -0800)]
[MC] Add MCSection::NonUniqueID and delete one MCContext::getELFSection overload

4 years ago[MC][ELF] Make linked-to symbol name part of ELFSectionKey
Fangrui Song [Tue, 4 Feb 2020 21:52:10 +0000 (13:52 -0800)]
[MC][ELF] Make linked-to symbol name part of ELFSectionKey

https://bugs.llvm.org/show_bug.cgi?id=44775

This rule has been implemented by GNU as https://sourceware.org/ml/binutils/2020-02/msg00028.html (binutils >= 2.35)

It allows us to simplify

```
.section .foo,"o",foo,unique,0
.section .foo,"o",bar,unique,1  # different section
```

to

```
.section .foo,"o",foo
.section .foo,"o",bar  # different section
```

We consider the two `.foo` different even if the linked-to symbols foo and bar
are defined in the same section.  This is a deliberate choice so that we don't
need to know the section where foo and bar are defined beforehand.

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

4 years ago[Attributor][FIX] Ensure abstract attributes are existing before manifest
Johannes Doerfert [Fri, 14 Feb 2020 16:34:31 +0000 (10:34 -0600)]
[Attributor][FIX] Ensure abstract attributes are existing before manifest

While the function return updateImpl did only look at call sites the
manifest method looked at return values. If we don't do this during the
updateImpl we might create new abstract attributes during manifest. This
is a problem when it comes to liveness information.

4 years ago[Attributor] Manifest simplified (return) values properly
Johannes Doerfert [Sat, 15 Feb 2020 02:11:22 +0000 (20:11 -0600)]
[Attributor] Manifest simplified (return) values properly

If we simplify a function return value we have to modify the return
instructions.

4 years ago[Attributor][FIX] Collapse `undef` to a proper value
Johannes Doerfert [Sat, 15 Feb 2020 02:08:20 +0000 (20:08 -0600)]
[Attributor][FIX] Collapse `undef` to a proper value

If we see an undef we cannot assume it's the same as "no value". For now
we just collapse it to 0.

4 years ago[Attributor][FIX] Restrict cross-SCC call deletion
Johannes Doerfert [Sat, 15 Feb 2020 02:06:34 +0000 (20:06 -0600)]
[Attributor][FIX] Restrict cross-SCC call deletion

If we know a call was not needed we might have ended up deleting it even
if it was in a different SCC. This prevents us from doing so.

4 years ago[Attributor][NFC] Add check lines for tests
Johannes Doerfert [Sat, 15 Feb 2020 01:27:41 +0000 (19:27 -0600)]
[Attributor][NFC] Add check lines for tests

4 years ago[Attributor][FIX] Carefully strip casts in AANoAlias
Johannes Doerfert [Sat, 15 Feb 2020 01:23:21 +0000 (19:23 -0600)]
[Attributor][FIX] Carefully strip casts in AANoAlias

We can strip casts in AANoAlias but that might cause us to end up with a
non-pointer type. We do properly handle that case now.

4 years ago[Attributor][FIX] Do not RAUW void values
Johannes Doerfert [Fri, 14 Feb 2020 02:10:59 +0000 (20:10 -0600)]
[Attributor][FIX] Do not RAUW void values

This caused an error when passes iterated over cached assumptions in the
tracker and assumed them to be `null` or an instruction. I failed to
create a test case so far.

4 years ago[llvm-ranlib][test] Fix rwx- after a4f3847f3d5742cfab7acdc614e7ca54643e0c85
Fangrui Song [Sat, 15 Feb 2020 03:41:05 +0000 (19:41 -0800)]
[llvm-ranlib][test] Fix rwx- after a4f3847f3d5742cfab7acdc614e7ca54643e0c85

4 years agoAMDGPU/GlobalISel: Fix missing impdef of scc on boolean bit ops
Matt Arsenault [Sat, 15 Feb 2020 03:02:31 +0000 (22:02 -0500)]
AMDGPU/GlobalISel: Fix missing impdef of scc on boolean bit ops

4 years ago[MC] De-capitalize another set of MCStreamer::Emit* functions
Fangrui Song [Sat, 15 Feb 2020 03:21:58 +0000 (19:21 -0800)]
[MC] De-capitalize another set of MCStreamer::Emit* functions

Emit{ValueTo,Code}Alignment Emit{DTP,TP,GP}* EmitSymbolValue etc

4 years ago[MC] De-capitalize some MCStreamer::Emit* functions
Fangrui Song [Sat, 15 Feb 2020 02:16:24 +0000 (18:16 -0800)]
[MC] De-capitalize some MCStreamer::Emit* functions

4 years ago[gn build] Make build locally deterministic
Nico Weber [Sat, 15 Feb 2020 02:55:33 +0000 (21:55 -0500)]
[gn build] Make build locally deterministic

This follows http://blog.llvm.org/2019/11/deterministic-builds-with-clang-and-lld.html
to make the GN build locally deterministic.

With this, I've built lld at two different build paths on my Windows box and got
identical binaries. (I'd expect the same to happen on Linux, and with other
binaries.)

This doesn't have the bits to get universal determinism yet.

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

4 years agoRemove 'process launch failed:' message prefix in Target::Launch
Jason Molenda [Sat, 15 Feb 2020 02:42:38 +0000 (18:42 -0800)]
Remove 'process launch failed:' message prefix in Target::Launch

SB API clients can describe the failure message in a more natural
way for their UI, this doesn't add information for them.

Differential Revision: https://reviews.llvm.org/D74585
<rdar://problem/49953304>

4 years ago[RISCV] Correct the CallPreservedMask for the function call in an interrupt handler
Shiva Chen [Fri, 14 Feb 2020 07:57:11 +0000 (15:57 +0800)]
[RISCV] Correct the CallPreservedMask for the function call in an interrupt handler

CallPreservedMask is used to describe the register liveness after a
function call. The function call in an interrupt handler should use the same
CallPreservedMask as normal functions. So that only callee save registers
can live through the function call.

4 years ago[Attributor] Derive memory location attributes (argmemonly, ...)
Johannes Doerfert [Sun, 26 Jan 2020 08:51:57 +0000 (02:51 -0600)]
[Attributor] Derive memory location attributes (argmemonly, ...)

In addition to memory behavior attributes (readonly/writeonly) we now
derive memory location attributes (argmemonly/inaccessiblememonly/...).
The former is part of AAMemoryBehavior and the latter part of
AAMemoryLocation. While they are similar in nature it got messy when
they were put in a single AA. Location attributes for arguments and
floating values will follow later.

Note that both memory attributes kinds can derive readnone. If there are
no accesses AAMemoryBehavior will derive readnone. If there are accesses
but only to stack (=local) locations AAMemoryLocation will derive
readnone.

Reviewed By: uenoku

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

4 years agoAMDGPU: Don't preserve analyses with div64 IR expansion
Matt Arsenault [Sat, 15 Feb 2020 00:57:38 +0000 (19:57 -0500)]
AMDGPU: Don't preserve analyses with div64 IR expansion

The dominator tree needs to be updated, but that isn't handled now.

4 years agoFix 01b02a73de78 to use correct macro spelling and fix unit tests.
Amy Huang [Fri, 14 Feb 2020 23:31:45 +0000 (15:31 -0800)]
Fix 01b02a73de78 to use correct macro spelling and fix unit tests.

4 years agoAMDGPU/GlobalISel: Fix G_EXTRACT of 96-bit results
Matt Arsenault [Fri, 7 Feb 2020 20:18:58 +0000 (15:18 -0500)]
AMDGPU/GlobalISel: Fix G_EXTRACT of 96-bit results

This would assert on an unhandled size in getRegSplitParts.

4 years agoAMDGPU: Use generated checks for memcpy expansion
Matt Arsenault [Fri, 14 Feb 2020 20:13:53 +0000 (15:13 -0500)]
AMDGPU: Use generated checks for memcpy expansion

4 years agoAMDGPU/GlobalISel: Improve 16-bit bswap
Matt Arsenault [Fri, 14 Feb 2020 15:56:46 +0000 (10:56 -0500)]
AMDGPU/GlobalISel: Improve 16-bit bswap

Match the new DAG behavior and use v_perm_b32 when available. Also
does better on SI/CI by expanding 16-bit swaps. Also fix
non-power-of-2 cases.

4 years agoGlobalISel: Remove unused function argument
Matt Arsenault [Fri, 7 Feb 2020 20:51:04 +0000 (15:51 -0500)]
GlobalISel: Remove unused function argument

4 years ago[TBLGEN] Allow to override RC weight
Stanislav Mekhanoshin [Wed, 12 Feb 2020 22:45:21 +0000 (14:45 -0800)]
[TBLGEN] Allow to override RC weight

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

4 years ago[WebAssembly] Add section names for some DWARF5 sections
Derek Schuff [Fri, 14 Feb 2020 23:29:32 +0000 (15:29 -0800)]
[WebAssembly] Add section names for some DWARF5 sections

Summary:
Addresses PR44728 but no tests because I've not yet made any attempt to verify
correctness of the debug info.

Reviewers: sbc100, aardappel

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

4 years agoFix -Wstring-compare warnings in new OpenMP code
Reid Kleckner [Fri, 14 Feb 2020 23:23:42 +0000 (15:23 -0800)]
Fix -Wstring-compare warnings in new OpenMP code

4 years ago[FIX] Add missing InGroup to warning introduced as part of D71830
Johannes Doerfert [Fri, 14 Feb 2020 23:21:13 +0000 (17:21 -0600)]
[FIX] Add missing InGroup to warning introduced as part of D71830

4 years ago[Attributor][FIX] Validate the type for AAValueConstantRange as needed
Johannes Doerfert [Thu, 13 Feb 2020 20:22:26 +0000 (14:22 -0600)]
[Attributor][FIX] Validate the type for AAValueConstantRange as needed

Due to the genericValueTraversal we might visit values for which we did
not create an AAValueConstantRange object, e.g., as they are behind a
PHI or select or call with `returned` argument. As a consequence we need
to validate the types as we are about to query AAValueConstantRange for
operands.

4 years agoDon't call computeHostNumPhysicalCores when LLVM_ENABLE_THREADS is off
Amy Huang [Fri, 14 Feb 2020 22:52:25 +0000 (14:52 -0800)]
Don't call computeHostNumPhysicalCores when LLVM_ENABLE_THREADS is off

Summary:
Fix change from 8404aeb56a73 to avoid calling
computeHostNumPhysicalCores if LLVM_ENABLE_THREADS is off.

Reviewers: rnk, aganea

Subscribers: hiraditya, llvm-commits

Tags: #llvm

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

4 years ago[lli] Add a '-dlopen <library-path>' option to lli.
Lang Hames [Fri, 14 Feb 2020 22:22:59 +0000 (14:22 -0800)]
[lli] Add a '-dlopen <library-path>' option to lli.

Passing '-dlopen <library-path>' to lli will cause the specified library to be
loaded (via llvm::sys::DynamicLibrary::LoadLibraryPermanently) before JIT'd code
is executed, making the library's symbols accessible to JIT'd code.

4 years ago[OpenMP][Part 2] Use reusable OpenMP context/traits handling
Johannes Doerfert [Fri, 20 Dec 2019 02:42:12 +0000 (20:42 -0600)]
[OpenMP][Part 2] Use reusable OpenMP context/traits handling

This patch implements an almost complete handling of OpenMP
contexts/traits such that we can reuse most of the logic in Flang
through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP.

All but construct SIMD specifiers, e.g., inbranch, and the device ISA
selector are define in `llvm/lib/Frontend/OpenMP/OMPKinds.def`. From
these definitions we generate the enum classes `TraitSet`,
`TraitSelector`, and `TraitProperty` as well as conversion and helper
functions in `llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}`.

The above enum classes are used in the parser, sema, and the AST
attribute. The latter is not a collection of multiple primitive variant
arguments that contain encodings via numbers and strings but instead a
tree that mirrors the `match` clause (see `struct OpenMPTraitInfo`).

The changes to the parser make it more forgiving when wrong syntax is
read and they also resulted in more specialized diagnostics. The tests
are updated and the core issues are detected as before. Here and
elsewhere this patch tries to be generic, thus we do not distinguish
what selector set, selector, or property is parsed except if they do
behave exceptionally, as for example `user={condition(EXPR)}` does.

The sema logic changed in two ways: First, the OMPDeclareVariantAttr
representation changed, as mentioned above, and the sema was adjusted to
work with the new `OpenMPTraitInfo`. Second, the matching and scoring
logic moved into `OMPContext.{h,cpp}`. It is implemented on a flat
representation of the `match` clause that is not tied to clang.
`OpenMPTraitInfo` provides a method to generate this flat structure (see
`struct VariantMatchInfo`) by computing integer score values and boolean
user conditions from the `clang::Expr` we keep for them.

The OpenMP context is now an explicit object (see `struct OMPContext`).
This is in anticipation of construct traits that need to be tracked. The
OpenMP context, as well as the `VariantMatchInfo`, are basically made up
of a set of active or respectively required traits, e.g., 'host', and an
ordered container of constructs which allows duplication. Matching and
scoring is kept as generic as possible to allow easy extension in the
future.

---

Test changes:

The messages checked in `OpenMP/declare_variant_messages.{c,cpp}` have
been auto generated to match the new warnings and notes of the parser.
The "subset" checks were reversed causing the wrong version to be
picked. The tests have been adjusted to correct this.
We do not print scores if the user did not provide one.
We print spaces to make lists in the `match` clause more legible.

Reviewers: kiranchandramohan, ABataev, RaviNarayanaswamy, gtbercea, grokos, sdmitriev, JonChesterfield, hfinkel, fghanim

Subscribers: merge_guards_bot, rampitec, mgorny, hiraditya, aheejin, fedor.sergeev, simoncook, bollu, guansong, dexonsmith, jfb, s.egerton, llvm-commits, cfe-commits

Tags: #clang, #llvm

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

4 years ago[lldb/Editline] Fix mistake in HistoryOperation mapping
Jonas Devlieghere [Fri, 14 Feb 2020 21:21:00 +0000 (13:21 -0800)]
[lldb/Editline] Fix mistake in HistoryOperation mapping

In 0e9b0b6d11e882efec8505d97c4b65e1562e6715 I introduced the
HistoryOperation enum to navigate the history. While this fixed the
behavior of HistoryOperation::Older and HistoryOperation::Newer, it
confused the mapping for HistoryOperation::Oldest and
HistoryOperation::Newest.

I tried to write a PExpect test to make sure this doesn't regress, but
I'm unable to prime the history in such a way that it recalls a known
element. I suspect this is an LLDB bug, but the  most recent entry
doesn't get update with entries from the current session. I considered
spoofing the home directory but that needs to happen before libLLDB is
loaded and you'll need to account for the widechar support. If anyone
has another suggestion I'd love to hear it.

4 years ago[NFC][llvm-exegesis] CombinationGenerator::performGeneration(): pull put state increm...
Roman Lebedev [Fri, 14 Feb 2020 21:47:13 +0000 (00:47 +0300)]
[NFC][llvm-exegesis] CombinationGenerator::performGeneration(): pull put state increment into lambda

This avoids questionable code such as taking address of current
range-based for variable and comparing it with vector begin iterator.
While this may not be a problem in itself, it can be written more consice.
This was initially suggested by @aaronpuchert.

4 years ago[compiler-rt] Make various Apple lit substitutions work correctly for other Apple...
Dan Liew [Fri, 14 Feb 2020 21:27:51 +0000 (13:27 -0800)]
[compiler-rt] Make various Apple lit substitutions work correctly for other Apple platforms.

This change makes the following lit substitutions expand to the correct
thing for macOS, iOS, tvOS, and watchOS.

%darwin_min_target_with_full_runtime_arc_support
%macos_min_target_10_11

rdar://problem/59463146

4 years ago[compiler-rt] Disable building LibFuzzer for WatchOS and the corresponding simulator.
Dan Liew [Fri, 14 Feb 2020 19:43:35 +0000 (11:43 -0800)]
[compiler-rt] Disable building LibFuzzer for WatchOS and the corresponding simulator.

rdar://problem/59466685

4 years ago[compiler-rt] Provide a lit config variable that defines the minimum deployment OS...
Dan Liew [Fri, 14 Feb 2020 19:35:06 +0000 (11:35 -0800)]
[compiler-rt] Provide a lit config variable that defines the minimum deployment OS version flag appropriate for the configured OS.

This patch defines `config.apple_platform_min_deployment_target_flag`
in the ASan, LibFuzzer, TSan, and UBSan lit test configs.

rdar://problem/59463146

4 years ago[compiler-rt] Add `DARWIN_osx_MIN_VER_FLAG` variable to match the other Apple platforms.
Dan Liew [Fri, 14 Feb 2020 19:01:02 +0000 (11:01 -0800)]
[compiler-rt] Add `DARWIN_osx_MIN_VER_FLAG` variable to match the other Apple platforms.

rdar://problem/59463146

4 years ago[compiler-rt] Use the correct minimum version flag for simulators on Apple
Dan Liew [Fri, 14 Feb 2020 18:28:05 +0000 (10:28 -0800)]
[compiler-rt] Use the correct minimum version flag for simulators on Apple
platforms.

For the simulators this changes the following compilation flags (
used both for building the runtime and lit tests).

iOS simulator: `-miphoneos-version-min` -> `-mios-simulator-version-min`
watchOS simulator: `-mwatchos-version-min` -> `-mwatchos-simulator-version-min`
tvOS simulator: `-mtvos-version-min` -> `-mtvos-simulator-version-min`

rdar://problem/59463146

4 years ago[llvm-exegesis] Rename range based for loop variable in a unit test so its different...
Craig Topper [Fri, 14 Feb 2020 21:41:50 +0000 (13:41 -0800)]
[llvm-exegesis] Rename range based for loop variable in a unit test so its different than the container being iterated over. NFC

It seems like gcc 5.5 wants to iterate over the new variable instead
of the container that lives outside the loop. But of course this
new container is empty.

Plus using a different variable names makes the code more readable.

4 years ago[Hexagon] Add an explicit makeArrayRef to pacify gcc 5.5
Craig Topper [Fri, 14 Feb 2020 21:38:50 +0000 (13:38 -0800)]
[Hexagon] Add an explicit makeArrayRef to pacify gcc 5.5

The array seemed to have decayed to a pointer before the ArrayRef
constructor got called so there was no size information available.

4 years ago[mlir] Add MemRef filter to affine data copy optimization
Diego Caballero [Fri, 14 Feb 2020 21:41:01 +0000 (13:41 -0800)]
[mlir] Add MemRef filter to affine data copy optimization

This patch extends affine data copy optimization utility with an
optional memref filter argument. When the memref filter is used, data
copy optimization will only generate copies for such a memref.

Note: this patch is just porting the memref filter feature from Uday's
'hop' branch: https://github.com/bondhugula/llvm-project/tree/hop.

Reviewed By: bondhugula

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

4 years ago[scudo][standalone] Allow setting release to OS
Christopher Ferris [Fri, 14 Feb 2020 20:24:03 +0000 (12:24 -0800)]
[scudo][standalone] Allow setting release to OS

Summary:
Add a method to set the release to OS value as the system runs,
and allow this to be set differently in the primary and the secondary.
Also, add a default value to use for primary and secondary. This
allows Android to have a default that is different for
primary/secondary.

Update mallopt to support setting the release to OS value.

Reviewers: pcc, cryptoad

Reviewed By: cryptoad

Subscribers: cryptoad, jfb, #sanitizers, llvm-commits

Tags: #sanitizers, #llvm

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

4 years ago[AsmPrinter] Use the McASMInfo to determine if we need descriptors.
Sean Fertile [Fri, 14 Feb 2020 16:15:26 +0000 (11:15 -0500)]
[AsmPrinter] Use the McASMInfo to determine if we need descriptors.

In https://reviews.llvm.org/rG8b737688c21a9755cae14cb9343930e0882164ab I
switched the condition gating the creation of the descriptor symbol from
checking the MCAsmInfo if we need to support descriptors, to if the OS
was AIX. Technically the 2 should be interchangeable: if we are
targeting AIX then we need to emit XCOFF object files, and the MCAsmInfo
must return true for needing function descriptors.

This doesn't account for lit test with runsteps that only set the arch.
Eg: test/CodeGen/XCore/section-name.ll
which when run natively on AIX we end up with a target xcore-ibm-aix and
needFunctionDescriptors is false.

This patch reverts to using the MCAsmInfo and adds an assert that the
target OS must be AIX since that is the only target using the descriptor
hook.

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

4 years agofix some comment typos to cycle bots
Nico Weber [Fri, 14 Feb 2020 20:18:50 +0000 (15:18 -0500)]
fix some comment typos to cycle bots

4 years ago[windows] Add /Gw to compiler flags
Nico Weber [Fri, 14 Feb 2020 20:15:00 +0000 (15:15 -0500)]
[windows] Add /Gw to compiler flags

This is like -fdata-sections, and it's not part of /O2 by default for some reason.

In the cmake build, reduces the size of clang.exe from 70,358,016 bytes to 69,982,720 bytes.

clang-format.exe goes from 3,703,296 bytes to 3,331,072 bytes.

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

4 years ago[AMDGPU] Always enable XNACK feature when support is explicitly requested
Austin Kerbow [Fri, 14 Feb 2020 17:22:33 +0000 (09:22 -0800)]
[AMDGPU] Always enable XNACK feature when support is explicitly requested

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

4 years ago[docs] Add note on using cmake to perform the build
Evandro Menezes [Fri, 14 Feb 2020 19:41:42 +0000 (13:41 -0600)]
[docs] Add note on using cmake to perform the build

Repeat the build instructions from the top level README in the Getting
Started guide.

4 years agoAMDGPU: Add option to disable CGP division expansion
Matt Arsenault [Tue, 11 Feb 2020 22:00:11 +0000 (17:00 -0500)]
AMDGPU: Add option to disable CGP division expansion

The division expansions in AMDGPUCodeGenPrepare can't be relied on for
correctness, since they punt to later optimization and possibly
legalization in some cases. We still need a way to be able to write
tests for the legalizer versions of the expansion. This is mostly for
GlobalISel, since the expected optimzations is expecting aren't
implemented.

The interaction with the flag to expand 64-bit division in the IR is
pretty confusing, but these flags have different purposes.

4 years ago[x86] remove stray test assertions; NFC
Sanjay Patel [Fri, 14 Feb 2020 19:28:50 +0000 (14:28 -0500)]
[x86] remove stray test assertions; NFC

I updated the prefix and forgot to manually remove the old names
as part of rG6071fc57a45.f

4 years ago[x86] regenerate complete test checks for sqrt{est}; NFC
Sanjay Patel [Fri, 14 Feb 2020 19:06:00 +0000 (14:06 -0500)]
[x86] regenerate complete test checks for sqrt{est}; NFC

The existing checks were trying to test both CPU-specific
codegen and generic codegen with explicit attributes for
the various sqrt estimate possibilities, but that was hard
to decipher and update (D69989).

Instead generate the complete results for various CPUs,
and that makes it clear which models have slow/fast sqrt
attributes along with all of the other potential diffs
(FMA, AVX2, scheduling).

Also, explicitly add the function attributes corresponding
to whether DAZ/FTZ denorm settings are expected.

4 years agoAMDGPU: Add option to expand 64-bit integer division in IR
Matt Arsenault [Sun, 19 Jan 2020 03:41:36 +0000 (22:41 -0500)]
AMDGPU: Add option to expand 64-bit integer division in IR

I didn't realize we were already expanding 24/32-bit division here
already. Use the available IntegerDivision utilities. This uses loops,
so produces significantly smaller code than the inline DAG expansion.

This now requires width reductions of 64-bit divisions before
introducing the expanded loops.

This helps work around missing legalization in GlobalISel for
division, which are the only remaining core instructions that didn't
work at all.

I think this is plausibly a better implementation than exists in the
DAG, although turning it on by default misses out on the constant
value optimizations and also needs benchmarking.

4 years ago[X86] Use ZERO_EXTEND instead of SIGN_EXTEND in the fast isel handling of convert_fro...
Craig Topper [Fri, 14 Feb 2020 18:37:06 +0000 (10:37 -0800)]
[X86] Use ZERO_EXTEND instead of SIGN_EXTEND in the fast isel handling of convert_from_fp16.

4 years ago[X86] Add AVX512 support to the fast isel code for Intrinsic::convert_from_fp16/conve...
Craig Topper [Fri, 14 Feb 2020 18:26:14 +0000 (10:26 -0800)]
[X86] Add AVX512 support to the fast isel code for Intrinsic::convert_from_fp16/convert_to_fp16.

4 years ago[LoopRotate] Get and update MSSA only if available in legacy pass manager.
Alina Sbirlea [Thu, 13 Feb 2020 18:49:44 +0000 (10:49 -0800)]
[LoopRotate] Get and update MSSA only if available in legacy pass manager.

Summary:
Potential fix for: https://bugs.llvm.org/show_bug.cgi?id=44889 and https://bugs.llvm.org/show_bug.cgi?id=44408

In the legacy pass manager, loop rotate need not compute MemorySSA when not being in the same loop pass manager with other loop passes.
There isn't currently a way to differentiate between the two cases, so this attempts to limit the usage in LoopRotate to only update MemorySSA when the analysis is already available.
The side-effect of this is that it will split the Loop pipeline.

This issue does not apply to the new pass manager, where we have a flag specifying if all loop passes in that loop pass manager preserve MemorySSA.

Reviewers: dmgreen, fedor.sergeev, nikic

Subscribers: Prazek, hiraditya, george.burgess.iv, llvm-commits

Tags: #llvm

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

4 years agoGlobalISel: Lower s64->s16 G_FPTRUNC
Matt Arsenault [Sat, 18 Jan 2020 15:08:11 +0000 (10:08 -0500)]
GlobalISel: Lower s64->s16 G_FPTRUNC

This is more or less directly ported from the AMDGPU custom lowering
for FP_TO_FP16. I made a few minor fixups (using G_UNMERGE_VALUES
instead of creating shift/trunc to extract the two halves, and zexting
an inverted compare instead of select_cc).

This also does not include the fast math expansion the DAG which
converts to f32 and then to f16. I think that belongs in a
pre-legalize combine instead.

4 years ago[GlobalISel] LegalizationArtifactCombiner: Fix a bug in tryCombineMerges
Volkan Keles [Fri, 14 Feb 2020 18:43:12 +0000 (10:43 -0800)]
[GlobalISel] LegalizationArtifactCombiner: Fix a bug in tryCombineMerges

Like COPY instructions explained in D70616, we don't check the constraints
when combining G_UNMERGE_VALUES. Use the same logic used in D70616 to check
if registers can be replaced, or a COPY instruction needs to be built.

https://reviews.llvm.org/D70564

4 years ago[Hexagon] v67+ HVX register pairs should support either direction
Brian Cain [Tue, 14 Aug 2018 21:17:46 +0000 (16:17 -0500)]
[Hexagon] v67+ HVX register pairs should support either direction

Assembler now permits pairs like 'v0:1', which are encoded
differently from the odd-first pairs like 'v1:0'.

The compiler will require more work to leverage these new register
pairs.

4 years agoFix tests after previous commit
Aaron Puchert [Fri, 14 Feb 2020 18:41:01 +0000 (19:41 +0100)]
Fix tests after previous commit

We don't want to test for this warning, so we just fix it.

4 years agoWarn about zero-parameter K&R definitions in -Wstrict-prototypes
Aaron Puchert [Fri, 14 Feb 2020 17:42:44 +0000 (18:42 +0100)]
Warn about zero-parameter K&R definitions in -Wstrict-prototypes

Summary:
Zero-parameter K&R definitions specify that the function has no
parameters, but they are still not prototypes, so calling the function
with the wrong number of parameters is just a warning, not an error.

The C11 standard doesn't seem to directly define what a prototype is,
but it can be inferred from 6.9.1p7: "If the declarator includes a
parameter type list, the list also specifies the types of all the
parameters; such a declarator also serves as a function prototype
for later calls to the same function in the same translation unit."
This refers to 6.7.6.3p5: "If, in the declaration “T D1”, D1 has
the form
    D(parameter-type-list)
or
    D(identifier-list_opt)
[...]". Later in 6.11.7 it also refers only to the parameter-type-list
variant as prototype: "The use of function definitions with separate
parameter identifier and declaration lists (not prototype-format
parameter type and identifier declarators) is an obsolescent feature."

We already correctly treat an empty parameter list as non-prototype
declaration, so we can just take that information.

GCC also warns about this with -Wstrict-prototypes.

This shouldn't affect C++, because there all FunctionType's are
FunctionProtoTypes. I added a simple test for that.

Reviewed By: aaron.ballman

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

4 years ago[APInt] Add some basic APInt::byteSwap unit tests
Simon Pilgrim [Fri, 14 Feb 2020 18:15:02 +0000 (18:15 +0000)]
[APInt] Add some basic APInt::byteSwap unit tests

As noted on D74621 we currently have no test coverage

4 years agoTTI: Fix vectorization cost for bswap
Matt Arsenault [Fri, 14 Feb 2020 15:32:02 +0000 (10:32 -0500)]
TTI: Fix vectorization cost for bswap

4 years ago[lldb/Plugin] s/LLDB_PLUGIN/LLDB_PLUGIN_DEFINE/ (NFC)
Jonas Devlieghere [Fri, 14 Feb 2020 17:46:02 +0000 (09:46 -0800)]
[lldb/Plugin] s/LLDB_PLUGIN/LLDB_PLUGIN_DEFINE/ (NFC)

Rename LLDB_PLUGIN to LLDB_PLUGIN_DEFINE as Pavel suggested in D73067 to
avoid name conflict.

4 years ago[libc++] Add missing include for is_same in test
Eric Fiselier [Fri, 14 Feb 2020 17:55:02 +0000 (18:55 +0100)]
[libc++] Add missing include for is_same in test

4 years agoAMDGPU: Improve i16/v2i16 bswap
Matt Arsenault [Fri, 14 Feb 2020 15:31:38 +0000 (10:31 -0500)]
AMDGPU: Improve i16/v2i16 bswap

4 years ago[X86] Fix copy/paste mistake in comment. NFC
Craig Topper [Thu, 13 Feb 2020 22:49:07 +0000 (14:49 -0800)]
[X86] Fix copy/paste mistake in comment. NFC

4 years agoAMDGPU: Add baseline tests for 16-bit bswap
Matt Arsenault [Fri, 14 Feb 2020 15:15:20 +0000 (10:15 -0500)]
AMDGPU: Add baseline tests for 16-bit bswap

4 years agoAMDGPU/GlobalISel: Handle G_BSWAP
Matt Arsenault [Thu, 13 Feb 2020 02:09:09 +0000 (21:09 -0500)]
AMDGPU/GlobalISel: Handle G_BSWAP

4 years ago[libc++] Remove cycle between <type_traits> and <cstddef>
Eric Fiselier [Fri, 14 Feb 2020 16:34:46 +0000 (17:34 +0100)]
[libc++] Remove cycle between <type_traits> and <cstddef>

This was caused by byte depending on traits. This patch moves
the minimal amount of meta-programming into <cstddef> to break the cycle.

4 years agoFix compilation breakage introduced by 8404aeb56a73ab24f9b295111de3b37a37f0b841.
Alexandre Ganea [Fri, 14 Feb 2020 16:16:32 +0000 (11:16 -0500)]
Fix compilation breakage introduced by 8404aeb56a73ab24f9b295111de3b37a37f0b841.

Also fix BitVector unittest failure when DLLVM_ENABLE_ASSERTIONS are OFF, introduced by d110c3a9f5253c4d94c10299c61fbbb33edab7db.

4 years ago[Driver] Rename AddGoldPlugin to addLTOOptions. NFC
Fangrui Song [Fri, 14 Feb 2020 06:35:18 +0000 (22:35 -0800)]
[Driver] Rename AddGoldPlugin to addLTOOptions. NFC

AddGoldPlugin does more than adding `-plugin path/to/LLVMgold.so`.
It works with lld and GNU ld, and adds other LTO options.
So AddGoldPlugin is no longer a suitable name.

Reviewed By: tejohnson

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

4 years agoReverting D73027 [DependenceAnalysis] Dependecies for loads marked with "ivnariant...
Evgeniy Brevnov [Fri, 14 Feb 2020 15:55:13 +0000 (22:55 +0700)]
Reverting D73027 [DependenceAnalysis] Dependecies for loads marked with "ivnariant.load" should not be shared with general accesses(PR42151).

4 years agoadd type_traits include as required for std::integral_constant
Eric Fiselier [Fri, 14 Feb 2020 15:38:16 +0000 (16:38 +0100)]
add type_traits include as required for std::integral_constant

4 years agoRevert "Reland D74436 "Change clang option -ffp-model=precise to select ffp-contract...
Melanie Blower [Fri, 14 Feb 2020 14:44:20 +0000 (06:44 -0800)]
Revert "Reland D74436 "Change clang option -ffp-model=precise to select ffp-contract=on""

This reverts commit 0a1123eb43f945593b26dd037490e0c909fa3c4f.
Want to revert this because it's causing trouble for PowerPC
I also fixed test fp-model.c which was looking for an incorrect error message

4 years ago[Support] On Windows, ensure hardware_concurrency() extends to all CPU sockets and...
Alexandre Ganea [Fri, 14 Feb 2020 03:49:57 +0000 (22:49 -0500)]
[Support] On Windows, ensure hardware_concurrency() extends to all CPU sockets and all NUMA groups

The goal of this patch is to maximize CPU utilization on multi-socket or high core count systems, so that parallel computations such as LLD/ThinLTO can use all hardware threads in the system. Before this patch, on Windows, a maximum of 64 hardware threads could be used at most, in some cases dispatched only on one CPU socket.

== Background ==
Windows doesn't have a flat cpu_set_t like Linux. Instead, it projects hardware CPUs (or NUMA nodes) to applications through a concept of "processor groups". A "processor" is the smallest unit of execution on a CPU, that is, an hyper-thread if SMT is active; a core otherwise. There's a limit of 32-bit processors on older 32-bit versions of Windows, which later was raised to 64-processors with 64-bit versions of Windows. This limit comes from the affinity mask, which historically is represented by the sizeof(void*). Consequently, the concept of "processor groups" was introduced for dealing with systems with more than 64 hyper-threads.

By default, the Windows OS assigns only one "processor group" to each starting application, in a round-robin manner. If the application wants to use more processors, it needs to programmatically enable it, by assigning threads to other "processor groups". This also means that affinity cannot cross "processor group" boundaries; one can only specify a "preferred" group on start-up, but the application is free to allocate more groups if it wants to.

This creates a peculiar situation, where newer CPUs like the AMD EPYC 7702P (64-cores, 128-hyperthreads) are projected by the OS as two (2) "processor groups". This means that by default, an application can only use half of the cores. This situation could only get worse in the years to come, as dies with more cores will appear on the market.

== The problem ==
The heavyweight_hardware_concurrency() API was introduced so that only *one hardware thread per core* was used. Once that API returns, that original intention is lost, only the number of threads is retained. Consider a situation, on Windows, where the system has 2 CPU sockets, 18 cores each, each core having 2 hyper-threads, for a total of 72 hyper-threads. Both heavyweight_hardware_concurrency() and hardware_concurrency() currently return 36, because on Windows they are simply wrappers over std::thread::hardware_concurrency() -- which can only return processors from the current "processor group".

== The changes in this patch ==
To solve this situation, we capture (and retain) the initial intention until the point of usage, through a new ThreadPoolStrategy class. The number of threads to use is deferred as late as possible, until the moment where the std::threads are created (ThreadPool in the case of ThinLTO).

When using hardware_concurrency(), setting ThreadCount to 0 now means to use all the possible hardware CPU (SMT) threads. Providing a ThreadCount above to the maximum number of threads will have no effect, the maximum will be used instead.
The heavyweight_hardware_concurrency() is similar to hardware_concurrency(), except that only one thread per hardware *core* will be used.

When LLVM_ENABLE_THREADS is OFF, the threading APIs will always return 1, to ensure any caller loops will be exercised at least once.

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

4 years ago[clang-scan-deps] Switch to using a ThreadPool
Alexandre Ganea [Thu, 13 Feb 2020 21:53:25 +0000 (16:53 -0500)]
[clang-scan-deps] Switch to using a ThreadPool

Use a ThreadPool instead of plain std::threads in clang-scan-deps.
This is needed to further support https://reviews.llvm.org/D71775.

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

4 years ago[ADT] Support BitVector as a key in DenseSet/Map
Alexandre Ganea [Thu, 13 Feb 2020 21:31:05 +0000 (16:31 -0500)]
[ADT] Support BitVector as a key in DenseSet/Map

This patch adds DenseMapInfo<> support for BitVector and SmallBitVector.

This is part of https://reviews.llvm.org/D71775, where a BitVector is used as a thread affinity mask.

4 years agoFix line endings produced by update_cc_test_checks.py
Alex Richardson [Fri, 14 Feb 2020 15:17:27 +0000 (15:17 +0000)]
Fix line endings produced by update_cc_test_checks.py

Use the same appraoch as update_llc_test_checks.py to always write \n
line endings. This should fix the Windows buildbots.

4 years ago[libc++] Remove unnecessary typenames from std/numerics/c.math/abs.pass.cpp
Louis Dionne [Fri, 14 Feb 2020 15:03:25 +0000 (16:03 +0100)]
[libc++] Remove unnecessary typenames from std/numerics/c.math/abs.pass.cpp

There are some unnecessary typenames in std/numerics/c.math/abs.pass.cpp;
e.g. they're not in a dependent context.

Patch by Bryce Adelstein Lelbach

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

4 years agoRevert "[clang-tools-extra] fix the check for if '-latomic' is necessary"
Luís Marques [Fri, 14 Feb 2020 15:01:52 +0000 (15:01 +0000)]
Revert "[clang-tools-extra] fix the check for if '-latomic' is necessary"

This reverts commit 1d40c4150630729a9c1ce5119a8027dac93a5b2d.
This seemed to have caused build failures on ARM/AArch64.

4 years ago[clangd] Update the CompletionItemKind.
Haojian Wu [Fri, 14 Feb 2020 13:55:51 +0000 (14:55 +0100)]
[clangd] Update the CompletionItemKind.

Summary: Fix some FIXMEs.

Reviewers: kadircet

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

Tags: #clang

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

4 years agoMove update_cc_test_checks.py tests to clang
Alex Richardson [Fri, 14 Feb 2020 10:26:07 +0000 (10:26 +0000)]
Move update_cc_test_checks.py tests to clang

Having tests that depend on clang inside llvm/ are not a good idea since
it can break incremental `ninja check-llvm`.

Fixes https://llvm.org/PR44798

Reviewed By: lebedev.ri, MaskRay, rsmith
Differential Revision: https://reviews.llvm.org/D74051

4 years ago[clangd] Add tracer to the rename workflow, NFC
Haojian Wu [Tue, 11 Feb 2020 11:37:09 +0000 (12:37 +0100)]
[clangd] Add tracer to the rename workflow, NFC

Reviewers: kbobyrev

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

Tags: #clang

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

4 years agoReenable "Always import constants" after compile time fixes
Teresa Johnson [Wed, 12 Feb 2020 23:17:56 +0000 (15:17 -0800)]
Reenable "Always import constants" after compile time fixes

Summary:
Reenables importing of constants by default, which was disabled in
D73724 due to excessive thin link times. These inefficiencies were
fixed in D73851.

I re-measured thin link times for a number of binaries that had compile
time explosions with importing of constants previously and confirmed
they no longer have any notable increases with it enabled.

Reviewers: wmi, evgeny777

Subscribers: hiraditya, arphaman, llvm-commits

Tags: #llvm

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

4 years ago[AArch64] Add BIT/BIF support.
Pavel Iliin [Tue, 4 Feb 2020 14:51:17 +0000 (14:51 +0000)]
[AArch64] Add BIT/BIF support.

This patch added generation of SIMD bitwise insert BIT/BIF instructions.
In the absence of GCC-like functionality for optimal constraints satisfaction
during register allocation the bitwise insert and select patterns are matched
by pseudo bitwise select BSP instruction with not tied def.
It is expanded later after register allocation with def tied
to BSL/BIT/BIF depending on operands registers.
This allows to get rid of redundant moves.

Reviewers: t.p.northover, samparker, dmgreen

Reviewed By: dmgreen

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

4 years ago[clang-tools-extra] fix the check for if '-latomic' is necessary
Gokturk Yuksek [Fri, 14 Feb 2020 14:12:45 +0000 (14:12 +0000)]
[clang-tools-extra] fix the check for if '-latomic' is necessary

Summary:
The CheckAtomic module performs two tests to determine if passing
'-latomic' to the linker is required: one for 64-bit atomics, and
another for non-64-bit atomics. clangd only uses the result from
HAVE_CXX_ATOMICS64_WITHOUT_LIB. This is incomplete because there are
uses of non-64-bit atomics in the code, such as the ReplyOnce::Replied
of type std::atomic<bool> defined in clangd/ClangdLSPServer.cpp.

Fix by also checking for the result of HAVE_CXX_ATOMICS_WITHOUT_LIB.

See also: https://reviews.llvm.org/D68964

Reviewers: ilya-biryukov, nridge, kadircet, beanz, compnerd, luismarques
Reviewed By: luismarques
Tags: #clang
Differential Revision: https://reviews.llvm.org/D69869

4 years ago[Driver][RISCV] Add RedHat Linux RISC-V triple
Luís Marques [Fri, 14 Feb 2020 13:44:42 +0000 (13:44 +0000)]
[Driver][RISCV] Add RedHat Linux RISC-V triple

Summary: Adds the RedHat Linux triple to the list of 64-bit RISC-V triples.
Without this the gcc libraries wouldn't be found by clang on a redhat/fedora
system, as the search list included `/usr/lib/gcc/riscv64-redhat-linux-gnu`
but the correct path didn't include the `-gnu` suffix.

Reviewers: lenary, asb, dlj
Reviewed By: lenary
Tags: #clang
Differential Revision: https://reviews.llvm.org/D74399

4 years ago[test][DebugInfo] Fix signed/unsigned comparison problem in test
James Henderson [Fri, 14 Feb 2020 13:39:41 +0000 (13:39 +0000)]
[test][DebugInfo] Fix signed/unsigned comparison problem in test

This caused build bot failures:
http://lab.llvm.org:8011/builders/ppc64le-lld-multistage-test/builds/8568/

4 years ago[libc++] span: Fix incorrect static asserts
Louis Dionne [Fri, 14 Feb 2020 13:31:15 +0000 (14:31 +0100)]
[libc++] span: Fix incorrect static asserts

The static asserts in span<T, N>::front() and span<T, N>::back() are
incorrect as they may be triggered from valid code due to evaluation
of a never taken branch:

    span<int, 0> foo;
    if (!foo.empty()) {
        auto x = foo.front();
    }

The problem is that the branch is always evaluated by the compiler,
creating invalid compile errors for span<T, 0>.

Thanks to Michael Schellenberger Costa for the patch.

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

4 years ago[clang][Index] Introduce a TemplateParm SymbolKind
Kadir Cetinkaya [Thu, 30 Jan 2020 13:07:42 +0000 (14:07 +0100)]
[clang][Index] Introduce a TemplateParm SymbolKind

Summary:
Currently template parameters has symbolkind `Unknown`. This patch
introduces a new kind `TemplateParm` for templatetemplate, templatetype and
nontypetemplate parameters.

Also adds tests in clangd hover feature.

Reviewers: sammccall

Subscribers: kristof.beyls, ilya-biryukov, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

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