platform/upstream/llvm.git
5 years ago[OpenMP] Fixed possible array out of bound access
Jonathan Peyton [Wed, 28 Nov 2018 20:15:11 +0000 (20:15 +0000)]
[OpenMP] Fixed possible array out of bound access

There is low probability that array th_hot_teams can be
accessed out of bound (when many nested levels are requested
to keep hot teams via KMP_HOT_TEAMS_MAX_LEVEL). The patch
adds the check of index that fixes the problem.

Patch by Andrey Churbanov

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

llvm-svn: 347800

5 years ago[OpenMP] Add omp_get_device_num() and update several other device API functions
Jonathan Peyton [Wed, 28 Nov 2018 20:10:26 +0000 (20:10 +0000)]
[OpenMP] Add omp_get_device_num() and update several other device API functions

Add omp_get_device_num() function for 5.0 which returns the number of the device
the current thread is running on. Also, did some cleanup and updating of device
API functions to make them into weak functions that should be replaced with
libomptarget functions when libomptarget is present.

Patch by Terry Wilmarth

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

llvm-svn: 347799

5 years ago[unittests] Fix the File System Test on Windows
Stella Stamenova [Wed, 28 Nov 2018 19:34:01 +0000 (19:34 +0000)]
[unittests] Fix the File System Test on Windows

Two of the file system tests are failing on Windows - this updates them to expect the correct values after the refactor of the file system code.

llvm-svn: 347796

5 years agoReapply "[llvm-mca] Return the total number of cycles from method Pipeline::run()."
Andrea Di Biagio [Wed, 28 Nov 2018 19:31:19 +0000 (19:31 +0000)]
Reapply "[llvm-mca] Return the total number of cycles from method Pipeline::run()."

This reapplies r347767 (originally reviewed at: https://reviews.llvm.org/D55000)
with a fix for the missing std::move of the Error returned by the call to
Pipeline::runCycle().

Below is the original commit message from r347767.

If a user only cares about the overall latency, then the best/quickest way is to
change method Pipeline::run() so that it returns the total number of cycles to
the caller.

When the simulation pipeline is run, the number of cycles (or an error) is
returned from method Pipeline::run().
The advantage is that no hardware event listener is needed for computing that
latency. So, the whole process should be faster (and simpler - at least for that
particular use case).

llvm-svn: 347795

5 years agoRevert "[ASTImporter] Changed use of Import to Import_New in ASTImporter."
Davide Italiano [Wed, 28 Nov 2018 19:15:23 +0000 (19:15 +0000)]
Revert "[ASTImporter] Changed use of Import to Import_New in ASTImporter."

This broke the lldb bots.

llvm-svn: 347794

5 years ago[OPENMP]Fix emission of the target regions in virtual functions.
Alexey Bataev [Wed, 28 Nov 2018 19:00:07 +0000 (19:00 +0000)]
[OPENMP]Fix emission of the target regions in virtual functions.

Fixed emission of the target regions found in the virtual functions.
Previously we may end up with the situation when those regions could be
skipped.

llvm-svn: 347793

5 years agoRevert "[clang-tools-extra] r347753 - [clangd] Build and test IndexBenchmark in check...
Matthew Voss [Wed, 28 Nov 2018 18:48:32 +0000 (18:48 +0000)]
Revert "[clang-tools-extra] r347753 - [clangd] Build and test IndexBenchmark in check-clangd"

This revision was causing failures on the buildbots, and our internal CI.

See: http://lab.llvm.org:8011/builders/clang-s390x-linux/builds/20856
llvm-svn: 347792

5 years ago[NFC] Move MultIversioning::Type into Decl so that it can be used in
Erich Keane [Wed, 28 Nov 2018 18:34:14 +0000 (18:34 +0000)]
[NFC] Move MultIversioning::Type into Decl so that it can be used in
CodeGen

Change-Id: I32b14edca3501277e0e65672eafe3eea38c6f9ae
llvm-svn: 347791

5 years agoFix bad _LIBCPP_ALIGNOF test
Eric Fiselier [Wed, 28 Nov 2018 18:32:16 +0000 (18:32 +0000)]
Fix bad _LIBCPP_ALIGNOF test

llvm-svn: 347790

5 years agoImplement P0966 - string::reserve should not shrink
Marshall Clow [Wed, 28 Nov 2018 18:18:34 +0000 (18:18 +0000)]
Implement P0966 - string::reserve should not shrink

llvm-svn: 347789

5 years ago(no commit message)
Julian Lettner [Wed, 28 Nov 2018 18:17:23 +0000 (18:17 +0000)]
(no commit message)

llvm-svn: 347788

5 years agoMove internal usages of `alignof`/`__alignof` to use `_LIBCPP_ALIGNOF`.
Eric Fiselier [Wed, 28 Nov 2018 18:16:02 +0000 (18:16 +0000)]
Move internal usages of `alignof`/`__alignof` to use `_LIBCPP_ALIGNOF`.

Summary:
Starting in Clang 8.0 and GCC 8.0, `alignof` and `__alignof` return different values in same cases. Specifically `alignof` and `_Alignof` return the minimum alignment for a type, where as `__alignof` returns the preferred alignment. libc++ currently uses `__alignof` but means to use `alignof`. See  llvm.org/PR39713

This patch introduces the macro `_LIBCPP_ALIGNOF` so we can control which spelling gets used.

This patch does not introduce any ABI guard to provide the old behavior with newer compilers. However, if we decide that is needed, this patch makes it trivial to implement.

I think we should commit this change immediately, and decide what we want to do about the ABI afterwards.

Reviewers: ldionne, EricWF

Reviewed By: EricWF

Subscribers: christof, libcxx-commits

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

llvm-svn: 347787

5 years ago[X86] Make X86TTIImpl::getCastInstrCost properly handle the case where AVX512 is...
Craig Topper [Wed, 28 Nov 2018 18:11:42 +0000 (18:11 +0000)]
[X86] Make X86TTIImpl::getCastInstrCost properly handle the case where AVX512 is enabled, but 512-bit vectors aren't legal.

Unlike most cost model functions this code makes a lot of table lookups without using the results from getTypeLegalizationCost. This means 512-bit vectors can be looked up even when the type isn't legal.

This patch adds a check around the two tables that contain 512-bit types to make sure that neither of the types would be split by type legalization. Meaning 512 bit types are illegal. I wanted to write this in a somewhat generic way that uses type legalization query hooks. But if prefered, I can switch to just using is512BitVector and the subtarget feature.

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

llvm-svn: 347786

5 years ago[X86] Add some cost model entries for sext/zext for avx512bw
Craig Topper [Wed, 28 Nov 2018 18:11:39 +0000 (18:11 +0000)]
[X86] Add some cost model entries for sext/zext for avx512bw

This fixes some of scalarization costs reported for sext/zext using avx512bw. This does not fix all scalarization costs being reported. Just the worst.

I've restricted this only to combinations of types that are legal with avx512bw like v32i1/v64i1/v32i16/v64i8 and conversions between vXi1 and vXi8/vXi16 with legal vXi8/vXi16 result types.

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

llvm-svn: 347785

5 years ago[X86] Add a combine for back to back VSRAI instructions
Craig Topper [Wed, 28 Nov 2018 18:03:38 +0000 (18:03 +0000)]
[X86] Add a combine for back to back VSRAI instructions

Expansion of SIGN_EXTEND_INREG can create a VSRAI instruction. If there is already a VSRAI after it, we should combine them into a larger VSRAI

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

llvm-svn: 347784

5 years ago[libcxx] Remove dynarray
Louis Dionne [Wed, 28 Nov 2018 18:02:00 +0000 (18:02 +0000)]
[libcxx] Remove dynarray

Summary:
std::dynarray had been proposed for C++14, but it was pulled out from C++14
and there are no plans to standardize it anymore.

Reviewers: mclow.lists, EricWF

Subscribers: mgorny, christof, jkorous, dexonsmith, arphaman, libcxx-commits

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

llvm-svn: 347783

5 years ago[DebugInfo] Give inlinable calls DILocs (PR39807)
Jeremy Morse [Wed, 28 Nov 2018 17:58:45 +0000 (17:58 +0000)]
[DebugInfo] Give inlinable calls DILocs (PR39807)

In PR39807 we incorrectly handle circumstances where calls are common'd
from conditional blocks into the parent BB. Calls that can be inlined
must always have DebugLocs, however we strip them during commoning, which
the IR verifier asserts on.

Fix this by using applyMergedLocation: it will perform the same DebugLoc
stripping of conditional Locs, but will also generate an unknown location
DebugLoc that satisfies the requirement for inlinable calls to always have
locations.

Some of the prior logic for selecting a DebugLoc is now likely redundant;
I'll generate a follow-up to remove it (involves editing more regression
tests).

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

llvm-svn: 347782

5 years agoSimplify Symbol::getPltVA.
Rui Ueyama [Wed, 28 Nov 2018 17:42:59 +0000 (17:42 +0000)]
Simplify Symbol::getPltVA.

This patch also makes getPltEntryOffset a non-member function because
it doesn't depend on any private members of the TargetInfo class.

I tried a few different ideas, and it seems this change fits in best to me.

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

llvm-svn: 347781

5 years ago[libcxx] Use clang-verify in the lit test suite even when availability is enabled
Louis Dionne [Wed, 28 Nov 2018 17:31:17 +0000 (17:31 +0000)]
[libcxx] Use clang-verify in the lit test suite even when availability is enabled

llvm-svn: 347780

5 years ago[gcov] Disable instrprof-gcov-fork.test.
Matt Morehouse [Wed, 28 Nov 2018 17:24:07 +0000 (17:24 +0000)]
[gcov] Disable instrprof-gcov-fork.test.

Test has been flaky for over a week and author hasn't fixed.

llvm-svn: 347779

5 years ago[LICM] Enable control flow hoisting by default
John Brawn [Wed, 28 Nov 2018 17:23:03 +0000 (17:23 +0000)]
[LICM] Enable control flow hoisting by default

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

llvm-svn: 347778

5 years ago[analyzer] Cleanup constructors in the Z3 backend
Mikhail R. Gadelha [Wed, 28 Nov 2018 17:22:49 +0000 (17:22 +0000)]
[analyzer] Cleanup constructors in the Z3 backend

Summary: Left only the constructors that are actually required, and marked the move constructors as deleted. They are not used anymore and we were never sure they've actually worked correctly.

Reviewers: george.karpenkov, NoQ

Reviewed By: george.karpenkov

Subscribers: xazax.hun, baloghadamsoftware, szepet, a.sidorin, Szelethus, donat.nagy, dkrupp

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

llvm-svn: 347777

5 years ago[LICM] Reapply r347190 "Make LICM able to hoist phis" with fix
John Brawn [Wed, 28 Nov 2018 17:21:49 +0000 (17:21 +0000)]
[LICM] Reapply r347190 "Make LICM able to hoist phis" with fix

This commit caused failures because it failed to correctly handle cases where
we hoist a phi, then hoist a use of that phi, then have to rehoist that use. We
need to make sure that we rehoist the use to _after_ the hoisted phi, which we
do by always rehoisting to the immediate dominator instead of just rehoisting
everything to the original preheader.

An option is also added to control whether control flow is hoisted, which is
off in this commit but will be turned on in a subsequent commit.

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

llvm-svn: 347776

5 years agoRevert [llvm-mca] Return the total number of cycles from method Pipeline::run().
Andrea Di Biagio [Wed, 28 Nov 2018 16:39:48 +0000 (16:39 +0000)]
Revert [llvm-mca] Return the total number of cycles from method Pipeline::run().

This reverts commits 347767.

llvm-svn: 347775

5 years ago[RISCV] Support .option push and .option pop
Alex Bradbury [Wed, 28 Nov 2018 16:39:14 +0000 (16:39 +0000)]
[RISCV] Support .option push and .option pop

This adds support in the RISCVAsmParser the storing of Subtarget feature bits to a stack so that they can be pushed/popped to enable/disable multiple features at once.

Differential Revision: https://reviews.llvm.org/D46424
Patch by Lewis Revill.

llvm-svn: 347774

5 years ago[InstCombine] Combine saturating add/sub with constant operands
Nikita Popov [Wed, 28 Nov 2018 16:37:15 +0000 (16:37 +0000)]
[InstCombine] Combine saturating add/sub with constant operands

Combine
  sat(sat(X + C1) + C2) -> sat(X + (C1+C2))
and
  sat(sat(X - C1) - C2) -> sat(X - (C1+C2))
if the sign of C1 and C2 matches.

In the unsigned case we can compute C1+C2 with saturating arithmetic,
and InstSimplify will reduce this just to the saturation value. For
the signed case, we cannot perform the simplification if the result
of the addition overflows.

This change is part of https://reviews.llvm.org/D54534.

llvm-svn: 347773

5 years ago[InstCombine] Canonicalize ssub.sat to sadd.sat
Nikita Popov [Wed, 28 Nov 2018 16:37:09 +0000 (16:37 +0000)]
[InstCombine] Canonicalize ssub.sat to sadd.sat

Canonicalize ssub.sat(X, C) to ssub.sat(X, -C) if C is constant and
not signed minimum. This will help further optimizations to apply.

This change is part of https://reviews.llvm.org/D54534.

llvm-svn: 347772

5 years ago[ValueTracking] Determine always-overflow condition for unsigned sub
Nikita Popov [Wed, 28 Nov 2018 16:37:04 +0000 (16:37 +0000)]
[ValueTracking] Determine always-overflow condition for unsigned sub

Always-overflow was already determined for unsigned addition, but
not subtraction. This patch establishes parity.

This allows us to perform some additional simplifications for
signed saturating subtractions.

This change is part of https://reviews.llvm.org/D54534.

llvm-svn: 347771

5 years ago[InstCombine] Use known overflow information for saturating add/sub
Nikita Popov [Wed, 28 Nov 2018 16:36:59 +0000 (16:36 +0000)]
[InstCombine] Use known overflow information for saturating add/sub

If ValueTracking can determine that the add/sub can newer overflow,
replace it with the corresponding nuw/nsw add/sub.

Additionally, for the unsigned case, if ValueTracking determines
that the add/sub always overflows, replace the result with the
saturation value.

This change is part of https://reviews.llvm.org/D54534.

llvm-svn: 347770

5 years ago[InstCombine] Canonicalize const arg for saturating adds
Nikita Popov [Wed, 28 Nov 2018 16:36:52 +0000 (16:36 +0000)]
[InstCombine] Canonicalize const arg for saturating adds

If a saturating add intrinsic has one constant argument, make sure
it is on the RHS. This will simplify further transformations.

This change is part of https://reviews.llvm.org/D54534.

llvm-svn: 347769

5 years ago[Hexagon] Add missing flags to ELF YAMLIO
Krzysztof Parzyszek [Wed, 28 Nov 2018 16:25:47 +0000 (16:25 +0000)]
[Hexagon] Add missing flags to ELF YAMLIO

llvm-svn: 347768

5 years ago[llvm-mca] Return the total number of cycles from method Pipeline::run().
Andrea Di Biagio [Wed, 28 Nov 2018 16:24:51 +0000 (16:24 +0000)]
[llvm-mca] Return the total number of cycles from method Pipeline::run().

If a user only cares about the overall latency, then the best/quickest way is to
change method Pipeline::run() so that it returns the total number of cycles to
the caller.

When the simulation pipeline is run, the number of cycles (or an error) is
returned from method Pipeline::run().
The advantage is that no hardware event listener is needed for computing that
latency. So, the whole process should be faster (and simpler - at least for that
particular use case).

llvm-svn: 347767

5 years agollvm-git: More tweaks.
James Y Knight [Wed, 28 Nov 2018 15:30:39 +0000 (15:30 +0000)]
llvm-git: More tweaks.

On python3, use bytes for reading and applying the patch file, rather
than str. This fixes encoding issues when applying patches with
python3.X (reported by zturner).

Also, simplify and speed up "svn update" via svn's "--parents"
argument, instead of manually computing and supplying the list of
parent directories to update.

llvm-svn: 347766

5 years ago[libcxx] Apply _LIBCPP_INLINE_VISIBILITY for std::hash for string_view
Louis Dionne [Wed, 28 Nov 2018 15:22:30 +0000 (15:22 +0000)]
[libcxx] Apply _LIBCPP_INLINE_VISIBILITY for std::hash for string_view

llvm-svn: 347765

5 years agoFix DynamicLibraryTests build on Windows when LLVM_EXPORT_SYMBOLS_FOR_PLUGINS is ON
Michael Platings [Wed, 28 Nov 2018 15:19:55 +0000 (15:19 +0000)]
Fix DynamicLibraryTests build on Windows when LLVM_EXPORT_SYMBOLS_FOR_PLUGINS is ON

extract_symbols.py (introduced in D18826) expects all of its library arguments
to be in the same directory - typically <config>/lib. DynamicLibraryLib.lib is
instead to be found in lib/<config>.
This patch intended to make DynamicLibraryLib.lib be created in <config>/lib
alongside most of the other libraries.

I previously tried passing absolute paths to extract_symbols.py but this
generated command lines that were too long for Visual Studio 2015: D54587

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

llvm-svn: 347764

5 years ago[ThinLTO] Correct linkonce_any function import linkage. NFC.
Xin Tong [Wed, 28 Nov 2018 15:16:35 +0000 (15:16 +0000)]
[ThinLTO] Correct linkonce_any function import linkage. NFC.

Summary:
This is a NFC as we do not import non-odr vague linkage when computing
for import list for a module.

Reviewers: tejohnson, pcc

Subscribers: inglorion, dexonsmith, llvm-commits

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

llvm-svn: 347763

5 years agoFix build error due to missing cctype include
David Spickett [Wed, 28 Nov 2018 15:12:33 +0000 (15:12 +0000)]
Fix build error due to missing cctype include
in ARMTargetParser.cpp.

llvm-svn: 347762

5 years agoFix false positive with lambda assignments in cert-err58-cpp.
Aaron Ballman [Wed, 28 Nov 2018 15:04:38 +0000 (15:04 +0000)]
Fix false positive with lambda assignments in cert-err58-cpp.

This check is about preventing exceptions from being thrown before main() executes, and assigning a lambda (rather than calling it) to a global object cannot throw any exceptions.

llvm-svn: 347761

5 years ago[clang-tidy] Added a test -export-fixes with relative paths.
Ilya Biryukov [Wed, 28 Nov 2018 14:43:26 +0000 (14:43 +0000)]
[clang-tidy] Added a test -export-fixes with relative paths.

Summary: A test for D51864.

Reviewers: ioeric, steveire

Reviewed By: steveire

Subscribers: xazax.hun, cfe-commits

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

llvm-svn: 347760

5 years ago[SLP]Fix PR39774: Set ReductionRoot if the original instruction is vectorized.
Alexey Bataev [Wed, 28 Nov 2018 14:34:11 +0000 (14:34 +0000)]
[SLP]Fix PR39774: Set ReductionRoot if the original instruction is vectorized.

Summary:
If the original reduction root instruction was vectorized, it might be
removed from the tree. It means that the insertion point may become
invalidated and the whole vectorization of the reduction leads to the
incorrect output result.
The ReductionRoot instruction must be marked as externally used so it
could not be removed. Otherwise it might cause inconsistency with the
cost model and we may end up with too optimistic optimization.

Reviewers: RKSimon, spatel, hfinkel, mkuper

Subscribers: llvm-commits

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

llvm-svn: 347759

5 years agoRevert r347673 "Catch up with EvaluateAsInt() clang API change."
Hans Wennborg [Wed, 28 Nov 2018 14:30:18 +0000 (14:30 +0000)]
Revert r347673 "Catch up with EvaluateAsInt() clang API change."

r347417 was re-committed in Clang.

llvm-svn: 347758

5 years agoRe-commit r347419 "Update call to EvaluateAsInt() to the new syntax."
Hans Wennborg [Wed, 28 Nov 2018 14:04:26 +0000 (14:04 +0000)]
Re-commit r347419 "Update call to EvaluateAsInt() to the new syntax."

llvm-svn: 347757

5 years agoRe-commit r347417 "Re-Reinstate 347294 with a fix for the failures."
Hans Wennborg [Wed, 28 Nov 2018 14:04:12 +0000 (14:04 +0000)]
Re-commit r347417 "Re-Reinstate 347294 with a fix for the failures."

This was reverted in r347656 due to me thinking it caused a miscompile of
Chromium. Turns out it was the Chromium code that was broken.

llvm-svn: 347756

5 years ago[clangd] Fix test broken in r347754.
Eric Liu [Wed, 28 Nov 2018 14:00:09 +0000 (14:00 +0000)]
[clangd] Fix test broken in r347754.

llvm-svn: 347755

5 years ago[clangd] Less penalty for cross-namespace completions.
Eric Liu [Wed, 28 Nov 2018 13:45:25 +0000 (13:45 +0000)]
[clangd] Less penalty for cross-namespace completions.

llvm-svn: 347754

5 years ago[clangd] Build and test IndexBenchmark in check-clangd
Haojian Wu [Wed, 28 Nov 2018 13:31:05 +0000 (13:31 +0000)]
[clangd] Build and test IndexBenchmark in check-clangd

Summary:
Include IndexBenchmark in check-clangd to make sure we won't forget to update
it when doing breaking changes; also fix an out-of-date test input.

Reviewers: ilya-biryukov

Subscribers: mgorny, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits

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

llvm-svn: 347753

5 years ago[ASTImporter] Changed use of Import to Import_New in ASTImporter.
Balazs Keri [Wed, 28 Nov 2018 13:21:26 +0000 (13:21 +0000)]
[ASTImporter] Changed use of Import to Import_New in ASTImporter.

Reviewers: a.sidorin, shafik, a_sidorin

Reviewed By: a_sidorin

Subscribers: gamesh411, a_sidorin, dkrupp, martong, Szelethus, cfe-commits

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

llvm-svn: 347752

5 years agoFix a typo.
Haojian Wu [Wed, 28 Nov 2018 13:20:39 +0000 (13:20 +0000)]
Fix a typo.

llvm-svn: 347751

5 years agoFix build error.
Haojian Wu [Wed, 28 Nov 2018 13:15:06 +0000 (13:15 +0000)]
Fix build error.

llvm-svn: 347750

5 years agoFix -Winfinite-recursion compile error.
Haojian Wu [Wed, 28 Nov 2018 12:32:53 +0000 (12:32 +0000)]
Fix -Winfinite-recursion compile error.

llvm-svn: 347749

5 years agoFix build of r347741 by adding missing vector
David Spickett [Wed, 28 Nov 2018 12:05:36 +0000 (12:05 +0000)]
Fix build of r347741 by adding missing vector
include to ARMTargetParser.h.

llvm-svn: 347748

5 years ago[MachineScheduler] Add support for clustering mem ops with FI base operands
Francis Visoiu Mistrih [Wed, 28 Nov 2018 12:00:28 +0000 (12:00 +0000)]
[MachineScheduler] Add support for clustering mem ops with FI base operands

Before this patch, the following stores in `merge_fail` would fail to be
merged, while they would get merged in `merge_ok`:

```
void use(unsigned long long *);
void merge_fail(unsigned key, unsigned index)
{
  unsigned long long args[8];
  args[0] = key;
  args[1] = index;
  use(args);
}
void merge_ok(unsigned long long *dst, unsigned a, unsigned b)
{
  dst[0] = a;
  dst[1] = b;
}
```

The reason is that `getMemOpBaseImmOfs` would return false for FI base
operands.

This adds support for this.

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

llvm-svn: 347747

5 years ago[CodeGen][NFC] Make `TII::getMemOpBaseImmOfs` return a base operand
Francis Visoiu Mistrih [Wed, 28 Nov 2018 12:00:20 +0000 (12:00 +0000)]
[CodeGen][NFC] Make `TII::getMemOpBaseImmOfs` return a base operand

Currently, instructions doing memory accesses through a base operand that is
not a register can not be analyzed using `TII::getMemOpBaseRegImmOfs`.

This means that functions such as `TII::shouldClusterMemOps` will bail
out on instructions using an FI as a base instead of a register.

The goal of this patch is to refactor all this to return a base
operand instead of a base register.

Then in a separate patch, I will add FI support to the mem op clustering
in the MachineScheduler.

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

llvm-svn: 347746

5 years agoFix a false-positive with cert-err58-cpp.
Aaron Ballman [Wed, 28 Nov 2018 11:57:13 +0000 (11:57 +0000)]
Fix a false-positive with cert-err58-cpp.

If a variable is declared constexpr then its initializer needs to be a constant expression, and thus, cannot throw. This check is about not throwing exceptions before main() runs, and so it doesn't apply if the initializer cannot throw. This silences the diagnostic when initializing a constexpr variable and fixes PR35457.

llvm-svn: 347745

5 years ago[DebugInfo] Rename EmitDebugThreadLocal back to EmitDebugValue. NFC
Simon Atanasyan [Wed, 28 Nov 2018 11:48:07 +0000 (11:48 +0000)]
[DebugInfo] Rename EmitDebugThreadLocal back to EmitDebugValue. NFC

This reverts r294500. DwarfCompileUnit::addAddressExpr uses DIEExpr
for PCOffset. In that case the expression is unrelated to thread locals
and so emitting a value of the DIEExpr does not have to always mean
emit-debug-thread-local.

llvm-svn: 347744

5 years ago[TableGen] Better error checking for TIED_TO constraints.
Simon Tatham [Wed, 28 Nov 2018 11:43:49 +0000 (11:43 +0000)]
[TableGen] Better error checking for TIED_TO constraints.

There are quite strong constraints on how you can use the TIED_TO
constraint between MC operands, many of which are currently not
checked until compiler run time.

MachineVerifier enforces that operands can only be tied together in
pairs (no three-way ties), and MachineInstr::tieOperands enforces that
one of the tied operands must be an output operand (def) and the other
must be an input operand (use).

Now we check these at TableGen time, so that if you violate any of
them in a new instruction definition, you find out immediately,
instead of having to wait until you compile something that makes code
generation hit one of those assertions.

Also in this commit, all the error reports in ParseConstraint now
include the name and source location of the def where the problem
happened, so that if you do trigger any of these errors, it's easier
to find the part of your TableGen input where you made the mistake.

The trunk sources already build successfully with this additional
error check, so I think no in-tree target has any of these problems.

Reviewers: fhahn, lhames, nhaehnle, MatzeB

Reviewed By: MatzeB

Subscribers: llvm-commits

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

llvm-svn: 347743

5 years ago[ELF][MIPS] Handle mips in the OUTPUT_FORMAT directive
Simon Atanasyan [Wed, 28 Nov 2018 11:41:20 +0000 (11:41 +0000)]
[ELF][MIPS] Handle mips in the OUTPUT_FORMAT directive

Differential Revision: http://reviews.llvm.org/D54920

llvm-svn: 347742

5 years ago[ARM, AArch64] Move ARM/AArch64 target parsers into
David Spickett [Wed, 28 Nov 2018 11:38:10 +0000 (11:38 +0000)]
[ARM, AArch64] Move ARM/AArch64 target parsers into
separate files to enable future changes.

This moves ARM and AArch64 target parsing into their
own files. They are still accessible through
TargetParser.h as before.

Several functions in AArch64 which were just forwarders to ARM
have been removed. All except AArch64::getFPUName were unused,
and that was only used in a test. Which itself was overlapping
one in ARM, so it has also been removed.

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

llvm-svn: 347741

5 years ago[clangd] Canonicalize file path in URIForFile.
Eric Liu [Wed, 28 Nov 2018 10:30:42 +0000 (10:30 +0000)]
[clangd] Canonicalize file path in URIForFile.

Summary:
File paths in URIForFile can come from index or local AST. Path from
index goes through URI transformation and the final path is resolved by URI
scheme and could be potentially different from the original path. Hence, we
should do the same transformation for all paths. We do this in URIForFile, which
now converts a path to URI and back to a canonicalized path.

Reviewers: sammccall

Reviewed By: sammccall

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

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

llvm-svn: 347739

5 years ago[clangd] Fix backward-compatibility - follow-up to textDocument/SymbolInfo
Jan Korous [Wed, 28 Nov 2018 10:24:07 +0000 (10:24 +0000)]
[clangd] Fix backward-compatibility - follow-up to textDocument/SymbolInfo

Apparently clang 3.6 couldn't build the preceding patch.

llvm-svn: 347738

5 years ago[clangd] Bump vscode-clangd v0.0.7
Haojian Wu [Wed, 28 Nov 2018 10:23:15 +0000 (10:23 +0000)]
[clangd] Bump vscode-clangd v0.0.7

llvm-svn: 347737

5 years ago[ELF] Use more specific method to calculate DT_PLTRELSZ
Peter Smith [Wed, 28 Nov 2018 10:04:55 +0000 (10:04 +0000)]
[ELF] Use more specific method to calculate DT_PLTRELSZ

The DT_PLTRELSZ dynamic tag is calculated using the size of the
OutputSection containing the In.RelaPlt InputSection. This will work for the
default no linker script case and the majority of linker scripts.
Unfortunately it doesn't work for some 'almost' sensible linker scripts. It
is permitted by ELF to have a single OutputSection containing both
In.RelaDyn, In.RelaPlt and In.RelaIPlt. It is also permissible for the range
of memory [DT_RELA, DT_RELA + DT_RELASZ) and the range
[DT_JMPREL, DT_JMPREL + DT_JMPRELSZ) to overlap as long as the the latter
range is at the end.

To support this type of linker script use the specific InputSection sizes.

Fixes pr39678

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

llvm-svn: 347736

5 years ago[SystemZ::TTI] Improve cost for compare of i64 with extended i32 load
Jonas Paulsson [Wed, 28 Nov 2018 08:58:27 +0000 (08:58 +0000)]
[SystemZ::TTI]  Improve cost for compare of i64 with extended i32 load

CGF/CLGF compares an i64 register with a sign/zero extended loaded i32 value
in memory.

This patch makes such a load considered foldable and so gets a 0 cost.

Review: Ulrich Weigand
https://reviews.llvm.org/D54944

llvm-svn: 347735

5 years ago[SystemZ::TTI] Improve costs for i16 add, sub and mul against memory.
Jonas Paulsson [Wed, 28 Nov 2018 08:31:50 +0000 (08:31 +0000)]
[SystemZ::TTI]  Improve costs for i16 add, sub and mul against memory.

AH, SH and MH costs are already covered in the cases where LHS is 32 bits and
RHS is 16 bits of memory sign-extended to i32.

As these instructions are also used when LHS is i16, this patch recognizes
that the loads will get folded then as well.

Review: Ulrich Weigand
https://reviews.llvm.org/D54940

llvm-svn: 347734

5 years ago[SystemZ::TTI] Improved cost values for comparison against memory.
Jonas Paulsson [Wed, 28 Nov 2018 08:08:05 +0000 (08:08 +0000)]
[SystemZ::TTI] Improved cost values for comparison against memory.

Single instructions exist for i8 and i16 comparisons of memory against a
small immediate.

This patch makes sure that if the load in these cases has a single user (the
ICmp), it gets a 0 cost (folded), and also that the ICmp gets a cost of 1.

Review: Ulrich Weigand
https://reviews.llvm.org/D54897

llvm-svn: 347733

5 years ago[SystemZ::TTI] Return zero cost for scalar load/store connected with a bswap.
Jonas Paulsson [Wed, 28 Nov 2018 07:52:34 +0000 (07:52 +0000)]
[SystemZ::TTI]  Return zero cost for scalar load/store connected with a bswap.

Since byte-swapping loads and stores are supported, a 'load -> bswap' or
'bswap -> store' sequence should have the cost of one.

Review: Ulrich Weigand
https://reviews.llvm.org/D54870

llvm-svn: 347732

5 years ago[llvm-objcopy] Hook up the -V alias to --version, output "GNU strip"
Martin Storsjo [Wed, 28 Nov 2018 06:51:50 +0000 (06:51 +0000)]
[llvm-objcopy] Hook up the -V alias to --version, output "GNU strip"

This allows libtool to detect the presence of llvm-strip and use
it with the options --strip-debug and --strip-unneeded.

Also hook up the -V alias for objcopy.

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

llvm-svn: 347731

5 years agoPR39809: (const void*)0 is not a null pointer constant in C.
Richard Smith [Wed, 28 Nov 2018 06:25:06 +0000 (06:25 +0000)]
PR39809: (const void*)0 is not a null pointer constant in C.

llvm-svn: 347730

5 years agoPR12884: Add test (bug is already fixed).
Richard Smith [Wed, 28 Nov 2018 05:15:46 +0000 (05:15 +0000)]
PR12884: Add test (bug is already fixed).

llvm-svn: 347729

5 years agoMove LoopHint.h from Sema to Parse
Richard Trieu [Wed, 28 Nov 2018 04:36:31 +0000 (04:36 +0000)]
Move LoopHint.h from Sema to Parse

struct LoopHint was only used within Parse and not in any of the Sema or
Codegen files.  In the non-Parse files where it was included, it either wasn't
used or LoopHintAttr was used, so its inclusion did nothing.

llvm-svn: 347728

5 years ago[CodeGen] Fix included headers.
Richard Trieu [Wed, 28 Nov 2018 04:14:29 +0000 (04:14 +0000)]
[CodeGen] Fix included headers.

Remove the included Parse header because CodeGen should not depend on Parse.
Instead, include the Lex headers that it needs instead.

llvm-svn: 347727

5 years ago[diagtool] Remove unneeded header includes.
Richard Trieu [Wed, 28 Nov 2018 03:59:35 +0000 (03:59 +0000)]
[diagtool] Remove unneeded header includes.

llvm-svn: 347726

5 years ago[unittest] Fix the FileSystem test on Windows. (Attempt #2)
Jonas Devlieghere [Wed, 28 Nov 2018 01:18:10 +0000 (01:18 +0000)]
[unittest] Fix the FileSystem test on Windows. (Attempt #2)

This fixes the double escaping and compares FileSpecs instead of
strings.

llvm-svn: 347725

5 years agoDo not insert prefetches with unsupported memory operands.
Mircea Trofin [Wed, 28 Nov 2018 01:08:45 +0000 (01:08 +0000)]
Do not insert prefetches with unsupported memory operands.

Summary:
Ignore advices where the memory operand of the 'anchor' instruction
uses unsupported register types.

Reviewers: davidxl

Subscribers: llvm-commits

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

llvm-svn: 347724

5 years ago[OPENMP] remove redundant ColonExpected flag in ParseOpenMP.cpp (NFC)
Kelvin Li [Wed, 28 Nov 2018 00:51:08 +0000 (00:51 +0000)]
[OPENMP] remove redundant ColonExpected flag in ParseOpenMP.cpp (NFC)

The flag ColonExpected is not changed after being initialized to
false at declaration.

Patch by Ahsan Saghir

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

llvm-svn: 347723

5 years ago[X86] Add test cases to show that we don't properly take -mprefer-vector-width=256...
Craig Topper [Wed, 28 Nov 2018 00:33:34 +0000 (00:33 +0000)]
[X86] Add test cases to show that we don't properly take -mprefer-vector-width=256 and -min-legal-vector-width=256 into account when costing sext/zext.

The check lines marked AVX256 in the zext256/sext256 functions should be closer to the AVX values which would take into account a splitting cost.

llvm-svn: 347722

5 years agoRemove dead code from IOHandler
Alex Langford [Tue, 27 Nov 2018 23:37:47 +0000 (23:37 +0000)]
Remove dead code from IOHandler

This has been dead since 2014 according to the blame

llvm-svn: 347721

5 years ago[RISCV] Mark unit tests as "requires: riscv-registered-target"
Mandeep Singh Grang [Tue, 27 Nov 2018 22:53:57 +0000 (22:53 +0000)]
[RISCV] Mark unit tests as "requires: riscv-registered-target"

Some of these tests break if the RISCV backend has not been built.

Reland D54816.

llvm-svn: 347720

5 years ago[X86] Add exhaustive cost model testing for sext/zext for all vector types we reasona...
Craig Topper [Tue, 27 Nov 2018 22:46:05 +0000 (22:46 +0000)]
[X86] Add exhaustive cost model testing for sext/zext for all vector types we reasonably support. Add cost model tests for truncating to vXi1.

Our sext/zext cost modeling was somewhat incomplete. And had no coverage for the fact that avx512bw v32i16/v64i8 types return a scalarization cost.

Truncates are a whole different mess because isTruncateFree is returning true for vectors when it shouldn't and that's the fall back for anything not in the tables.

llvm-svn: 347719

5 years agoFix typo in "[clang][ARC] Fix test for commit r347699"
Tatyana Krasnukha [Tue, 27 Nov 2018 22:22:33 +0000 (22:22 +0000)]
Fix typo in "[clang][ARC] Fix test for commit r347699"

llvm-svn: 347718

5 years ago[lldbsuite] Each lldb suite test must have a unique class name
Stella Stamenova [Tue, 27 Nov 2018 22:18:02 +0000 (22:18 +0000)]
[lldbsuite] Each lldb suite test must have a unique class name

A couple of new tests have been added that use existing class names. This causes failures on Windows if the tests run at the same time and on any platform it results in the logs being overwritten.

llvm-svn: 347717

5 years ago[Reproducers] Improve reproducer API and add unit tests.
Jonas Devlieghere [Tue, 27 Nov 2018 22:11:02 +0000 (22:11 +0000)]
[Reproducers] Improve reproducer API and add unit tests.

When I landed the initial reproducer framework I knew there were some
things that needed improvement. Rather than bundling it with a patch
that adds more functionality I split it off into this patch. I also
think the API is stable enough to add unit testing, which is included in
this patch as well.

Other improvements include:

 - Refactor how we initialize the loader and generator.
 - Improve naming consistency: capture and replay seems the least ambiguous.
 - Index providers by name and make sure there's only one of each.
 - Add convenience methods for creating and accessing providers.

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

llvm-svn: 347716

5 years ago[OPENMP][NVPTX]Basic support for reductions across the teams.
Alexey Bataev [Tue, 27 Nov 2018 21:24:54 +0000 (21:24 +0000)]
[OPENMP][NVPTX]Basic support for reductions across the teams.

Added basic codegen support for the reductions across the teams.

llvm-svn: 347715

5 years ago[OpenMP][libomptarget] Add new version of SPMD deinit kernel function with argument
Gheorghe-Teodor Bercea [Tue, 27 Nov 2018 21:23:40 +0000 (21:23 +0000)]
[OpenMP][libomptarget] Add new version of SPMD deinit kernel function with argument

Summary: To enable the compiler to optimize parts of the function that are not needed when runtime can be omitted, a new version of the SPMD deinit kernel function is needed. This function takes the runtime required flag as an argument.

Reviewers: ABataev, kkwli0, caomhin

Reviewed By: ABataev

Subscribers: guansong, openmp-commits

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

llvm-svn: 347714

5 years ago[MS] Push outermost class DeclContexts only in -fdelayed-template-parsing
Reid Kleckner [Tue, 27 Nov 2018 21:20:42 +0000 (21:20 +0000)]
[MS] Push outermost class DeclContexts only in -fdelayed-template-parsing

This is more or less a complete rewrite of r347627, and it fixes PR38460
I added a reduced test case to DelayedTemplateParsing.cpp.

llvm-svn: 347713

5 years ago[unittest] Fix the FileSystem test on Windows.
Jonas Devlieghere [Tue, 27 Nov 2018 21:20:35 +0000 (21:20 +0000)]
[unittest] Fix the FileSystem test on Windows.

On Windows, when using the VFS without going through FileSpec, the
absolute path to `/foo` is `\\foo`. This updates the unittest to expect
that.

llvm-svn: 347712

5 years ago[libcxx] Make sure the re-export logic works when paths contain spaces
Louis Dionne [Tue, 27 Nov 2018 21:13:31 +0000 (21:13 +0000)]
[libcxx] Make sure the re-export logic works when paths contain spaces

llvm-svn: 347711

5 years ago[OPENMP][NVPTX]Basic support for reductions across the teams.
Alexey Bataev [Tue, 27 Nov 2018 21:06:09 +0000 (21:06 +0000)]
[OPENMP][NVPTX]Basic support for reductions across the teams.

Summary:
Added functions __kmpc_nvptx_teams_reduce_nowait_simple and
__kmpc_nvptx_teams_end_reduce_nowait_simple to implement basic support
for reductions across the teams.

Reviewers: gtbercea, kkwli0

Subscribers: guansong, jfb, caomhin, openmp-commits

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

llvm-svn: 347710

5 years ago[Driver] Use libOption with tablegen.
Jonas Devlieghere [Tue, 27 Nov 2018 21:00:32 +0000 (21:00 +0000)]
[Driver] Use libOption with tablegen.

This patch modifies the lldb driver to use libOption for option parsing.
It allows us to decouple option parsing from option processing which is
important when arguments affect initialization. This was previously not
possible because the debugger need to be initialized as some option
interpretation (like the scripting language etc) was handled by the
debugger, rather than in the driver.

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

llvm-svn: 347709

5 years ago[libcxx] Fix libc++ re-exporting logic when Command Line Tools are not installed
Louis Dionne [Tue, 27 Nov 2018 20:59:47 +0000 (20:59 +0000)]
[libcxx] Fix libc++ re-exporting logic when Command Line Tools are not installed

Summary:
When the Xcode Command Line tools are not installed but CMAKE_OSX_SYSROOT is
set, we would try to re-export symbols from the libc++abi.dylib shipped in
the sysroot, which does not exist. This commit changes the build on OS X to
always re-export symbols from the explicit re-export lists, which doesn't
change depending on what system you're building on, and is therefore much
less flaky.

Reviewers: EricWF, mclow.lists

Subscribers: mgorny, christof, jkorous, dexonsmith, libcxx-commits

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

llvm-svn: 347708

5 years ago[TableGen] Improve readability of generated code (NFC)
Evandro Menezes [Tue, 27 Nov 2018 20:59:01 +0000 (20:59 +0000)]
[TableGen] Improve readability of generated code (NFC)

Improve the readability of the generated code for `MCOpcodeSwitchStatement`.

llvm-svn: 347707

5 years ago[TableGen] Refactor macro names (NFC)
Evandro Menezes [Tue, 27 Nov 2018 20:58:27 +0000 (20:58 +0000)]
[TableGen] Refactor macro names (NFC)

Make the names for the macros for `TargetInstrInfo` uniform.

llvm-svn: 347706

5 years ago[clang][ARC] Fix test for commit r347699
Tatyana Krasnukha [Tue, 27 Nov 2018 20:56:30 +0000 (20:56 +0000)]
[clang][ARC] Fix test for commit r347699

llvm-svn: 347705

5 years ago[COFF] Remove empty sections before calculating the size of section headers
Martin Storsjo [Tue, 27 Nov 2018 20:48:09 +0000 (20:48 +0000)]
[COFF] Remove empty sections before calculating the size of section headers

The number of sections is used in assignAddresses (in
finalizeAddresses) and the space for all sections is permanent from
that point on, even if we later decide we won't write some of them.

The VirtualSize field also gets calculated in assignAddresses, so we
need to manually check whether the section is empty here instead.

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

llvm-svn: 347704

5 years ago[yaml2obj] Treat COFF/ARM64 as a 64 bit architecture
Martin Storsjo [Tue, 27 Nov 2018 20:47:38 +0000 (20:47 +0000)]
[yaml2obj] Treat COFF/ARM64 as a 64 bit architecture

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

llvm-svn: 347703

5 years ago[gn build] Add enough build files to be able to build llvm-tblgen.
Nico Weber [Tue, 27 Nov 2018 20:10:26 +0000 (20:10 +0000)]
[gn build] Add enough build files to be able to build llvm-tblgen.

Adds build files for:

- llvm/lib/DebugInfo/CodeView
- llvm/lib/DebugInfo/MSF
- llvm/lib/MC
- llvm/lib/TableGen
- llvm/utils/TableGen

All the build files just list sources and deps and are uninteresting.

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

llvm-svn: 347702

5 years ago[clang][slh] add attribute for speculative load hardening
Zola Bridges [Tue, 27 Nov 2018 19:56:46 +0000 (19:56 +0000)]
[clang][slh] add attribute for speculative load hardening

Summary:
Resubmit this with no changes because I think the build was broken
by a different diff.
-----
The prior diff had to be reverted because there were two tests
that failed. I updated the two tests in this diff

clang/test/Misc/pragma-attribute-supported-attributes-list.test
clang/test/SemaCXX/attr-speculative-load-hardening.cpp

----- Summary from Previous Diff (Still Accurate) -----

LLVM IR already has an attribute for speculative_load_hardening. Before
this commit, when a user passed the -mspeculative-load-hardening flag to
Clang, every function would have this attribute added to it. This Clang
attribute will allow users to opt into SLH on a function by function basis.

This can be applied to functions and Objective C methods.

Reviewers: chandlerc, echristo, kristof.beyls, aaron.ballman

Subscribers: llvm-commits

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

llvm-svn: 347701

5 years ago[InstCombine] Add tests for saturating add/sub; NFC
Nikita Popov [Tue, 27 Nov 2018 19:52:56 +0000 (19:52 +0000)]
[InstCombine] Add tests for saturating add/sub; NFC

These are baseline tests for D54534.

llvm-svn: 347700

5 years ago[clang][ARC] Add ARCTargetInfo
Tatyana Krasnukha [Tue, 27 Nov 2018 19:52:10 +0000 (19:52 +0000)]
[clang][ARC] Add ARCTargetInfo

Based-on-patch-by: Pete Couperus <petecoup@synopsys.com>
Differential Revision: https://reviews.llvm.org/D53100

llvm-svn: 347699

5 years ago[OpenMP][libomptarget] Refactor SPMD and runtime requirement checking
Gheorghe-Teodor Bercea [Tue, 27 Nov 2018 19:45:10 +0000 (19:45 +0000)]
[OpenMP][libomptarget] Refactor SPMD and runtime requirement checking

Summary: Refactor the checking for SPMD mode and whether the runtime is initialized or not. This uses constant flags which enables the runtime to optimize out unused sections of code that depend on these flags.

Reviewers: ABataev, caomhin

Reviewed By: ABataev

Subscribers: guansong, jfb, openmp-commits

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

llvm-svn: 347698