platform/upstream/llvm.git
7 years ago[ARM] Better error message for invalid flag-preserving Thumb1 insts
Oliver Stannard [Tue, 6 Dec 2016 12:59:08 +0000 (12:59 +0000)]
[ARM] Better error message for invalid flag-preserving Thumb1 insts

When we see a non flag-setting instruction for which only the flag-setting
version is available in Thumb1, we should give a better error message than
"invalid instruction".

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

llvm-svn: 288805

7 years ago[X86][AVX512] Detect repeated constant patterns in BUILD_VECTOR suitable for broadcas...
Ayman Musa [Tue, 6 Dec 2016 12:24:14 +0000 (12:24 +0000)]
[X86][AVX512] Detect repeated constant patterns in BUILD_VECTOR suitable for broadcasting.

Check if a build_vector node includes a repeated constant pattern and replace it with a broadcast of that pattern.
For example:
"build_vector <0, 1, 2, 3, 0, 1, 2, 3>" would be replaced by "broadcast <0, 1, 2, 3>"

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

llvm-svn: 288804

7 years agoDon't crash trying to write an 0 addend.
Rafael Espindola [Tue, 6 Dec 2016 12:19:24 +0000 (12:19 +0000)]
Don't crash trying to write an 0 addend.

For preemptable symbols the dynamic linker does all the work. Trying
to compute the addend is at best wasteful and can also lead to crashes
in cases of programs that uses tls but doesn't define any tls
variables.

llvm-svn: 288803

7 years agoMake the test a bit more strict. NFC.
Rafael Espindola [Tue, 6 Dec 2016 12:15:12 +0000 (12:15 +0000)]
Make the test a bit more strict. NFC.

llvm-svn: 288802

7 years ago[X86] Add tests to show missed opportunities to calculate knownbits in SMAX/SMIN...
Simon Pilgrim [Tue, 6 Dec 2016 12:12:20 +0000 (12:12 +0000)]
[X86] Add tests to show missed opportunities to calculate knownbits in SMAX/SMIN/UMAX/UMIN

llvm-svn: 288801

7 years ago[PowerPC] Improvements for BUILD_VECTOR Vol. 4
Nemanja Ivanovic [Tue, 6 Dec 2016 11:47:14 +0000 (11:47 +0000)]
[PowerPC] Improvements for BUILD_VECTOR Vol. 4

This is the final patch in the series of patches that improves
BUILD_VECTOR handling on PowerPC. This adds a few peephole optimizations
to remove redundant instructions. It also adds a large test case which
encompasses a large set of code patterns that build vectors - this test
case was the motivator for this series of patches.

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

llvm-svn: 288800

7 years ago[globalisel][aarch64] Prefix PartialMappingIdx enumerators with 'PMI_' to fit coding...
Daniel Sanders [Tue, 6 Dec 2016 11:33:04 +0000 (11:33 +0000)]
[globalisel][aarch64] Prefix PartialMappingIdx enumerators with 'PMI_' to fit coding standards.

This also stops things like 'None' polluting the llvm::AArch64 namespace.

llvm-svn: 288799

7 years agoFix MSVC -Wmicrosoft-enum-value 'enumerator value is not representable' warning
Simon Pilgrim [Tue, 6 Dec 2016 11:27:19 +0000 (11:27 +0000)]
Fix MSVC -Wmicrosoft-enum-value 'enumerator value is not representable' warning

llvm-svn: 288798

7 years agoUse Timeout<> in EvaluateExpressionOptions class
Pavel Labath [Tue, 6 Dec 2016 11:24:51 +0000 (11:24 +0000)]
Use Timeout<> in EvaluateExpressionOptions class

llvm-svn: 288797

7 years agoFix MSVC bool to uint64_t promotion warning
Simon Pilgrim [Tue, 6 Dec 2016 11:12:53 +0000 (11:12 +0000)]
Fix MSVC bool to uint64_t promotion warning

llvm-svn: 288796

7 years ago[LCG] Add some much needed asserts and verify runs to uncover
Chandler Carruth [Tue, 6 Dec 2016 10:29:23 +0000 (10:29 +0000)]
[LCG] Add some much needed asserts and verify runs to uncover
a hilarious bug and fix it.

We somehow were never verifying the RefSCCs newly formed when
splitting an existing one apart, and when verifying them we weren't
really checking the SCC indices mapping effectively.

If we had been, it would have been blindingly obvious that right after
putting something int `RC.SCCs` we should update `RC.SCCIndices` instead
of `SCCIndices` which we were about to clear and rebuild anyways. =[

Anyways, this is thoroughly covered by existing tests now that we
actually verify things properly.

llvm-svn: 288795

7 years ago[framelowering] Improve tracking of first CS pop instruction.
Florian Hahn [Tue, 6 Dec 2016 10:24:55 +0000 (10:24 +0000)]
[framelowering] Improve tracking of first CS pop instruction.

Summary: This patch makes sure FirstCSPop and MBBI never point to DBG_VALUE instructions, which affected the code generated.

Reviewers: mkuper, aprantl, MatzeB

Subscribers: llvm-commits

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

llvm-svn: 288794

7 years agoAlso recognize -std=iso9899:201x
Benjamin Kramer [Tue, 6 Dec 2016 10:23:07 +0000 (10:23 +0000)]
Also recognize -std=iso9899:201x

It should already be handled but a typo in the LANGSTANDARD() definition
was introduced in r147220.

Patch by Alexander Richardson, test case by me.

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

llvm-svn: 288793

7 years agoAdd missing parens in assert.
Sam McCall [Tue, 6 Dec 2016 10:14:36 +0000 (10:14 +0000)]
Add missing parens in assert.

Summary: Add missing parens in assert, which warn in GCC.

Subscribers: llvm-commits

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

llvm-svn: 288792

7 years ago[clang-move] ignore unsupported symbol kinds when checking if all symbols are moved.
Eric Liu [Tue, 6 Dec 2016 10:12:23 +0000 (10:12 +0000)]
[clang-move] ignore unsupported symbol kinds when checking if all symbols are moved.

llvm-svn: 288791

7 years ago[PM] Basic cleanups to CGSCC update code, NFC.
Chandler Carruth [Tue, 6 Dec 2016 10:06:06 +0000 (10:06 +0000)]
[PM] Basic cleanups to CGSCC update code, NFC.

Just using InstIterator, simpler loop structures, and making better use
of the visit callback infrastructure.

llvm-svn: 288790

7 years agoRevert r288787: Add missing stdbool.h module.
Eric Fiselier [Tue, 6 Dec 2016 09:48:32 +0000 (09:48 +0000)]
Revert r288787: Add missing stdbool.h module.

Reverting because I didn't properly test this patch. Although it's probably
correct to add a stdbool_h module I thought the change fixed more than it did.
I'll re-commit after more investigation.

llvm-svn: 288789

7 years ago[XRay][compiler-rt] Only add unit tests if we're building XRay.
Dean Michael Berris [Tue, 6 Dec 2016 09:43:44 +0000 (09:43 +0000)]
[XRay][compiler-rt] Only add unit tests if we're building XRay.

As constructed before this patch, in case we run into case where we
don't actually build the XRay library, we really ought to not be adding
the unit test runs. This should fix the bootstrap build failures.

This is a follow-up further to D26232.

llvm-svn: 288788

7 years agoAdd missing stdbool.h module. The test suite now passes on OS X with modules
Eric Fiselier [Tue, 6 Dec 2016 09:41:50 +0000 (09:41 +0000)]
Add missing stdbool.h module. The test suite now passes on OS X with modules

llvm-svn: 288787

7 years ago[XRay][compiler-rt] CMake fixes for XRay -- take 2.
Dean Michael Berris [Tue, 6 Dec 2016 08:40:16 +0000 (08:40 +0000)]
[XRay][compiler-rt] CMake fixes for XRay -- take 2.

The bootstrap buildbot complains about not being able to find the
unittests for XRay, when the conditionals to include or not include
tests and unit tests don't match.

This is a follow-up to D26232.

llvm-svn: 288786

7 years ago[XRay][compiler-rt] Fix unit test adding logic.
Dean Michael Berris [Tue, 6 Dec 2016 08:22:31 +0000 (08:22 +0000)]
[XRay][compiler-rt] Fix unit test adding logic.

Before this change we would add the unit tests potentially even if we
don't actually include the unit tests.

This is a follow-up on D26232.

llvm-svn: 288785

7 years ago[X86] Remove another weird scalar sqrt/rcp/rsqrt pattern.
Craig Topper [Tue, 6 Dec 2016 08:08:12 +0000 (08:08 +0000)]
[X86] Remove another weird scalar sqrt/rcp/rsqrt pattern.

This pattern turned a vector sqrt/rcp/rsqrt operation of sse_load_f32/f64 into the the scalar instruction for the operation and put undef into the upper bits. For correctness, the resulting code should still perform the sqrt/rcp/rsqrt on the upper bits after the load is extended since that's what the operation asked for. Particularly in the case where the upper bits are 0, in that case we need calculate the sqrt/rcp/rsqrt of the zeroes and keep the result in the upper-bits. This implies we should be using the packed instruction still.

The only test case for this pattern is one I just added so there was no coverage of this.

llvm-svn: 288784

7 years ago[X86] Add test case demonstrating a case where a vector sqrt being passed (scalar_to_...
Craig Topper [Tue, 6 Dec 2016 08:08:09 +0000 (08:08 +0000)]
[X86] Add test case demonstrating a case where a vector sqrt being passed (scalar_to_vector loadf64) uses a scalar sqrt instruction.

This occurs due to a pattern that uses sse_load_f32/f64 with vector sqrt/rcp/rsqrt operations and turns them into scalar instructions. Perhaps for the case were the upper bits come from undef this is ok.  I believe a (vzmovl load64) would do the same thing but those seems to become vzload instead and selectScalarSSELoad doesn't handle that today. In that case we should be performing the vector operation on the zeros in the upper bits which is not equivalent to using a scalar instruction.

I will remove this pattern in a follow up patch. There appears to be no other test content for it.

llvm-svn: 288783

7 years ago[X86] Regenerate a test using update_llc_test_checks.py
Craig Topper [Tue, 6 Dec 2016 08:08:07 +0000 (08:08 +0000)]
[X86] Regenerate a test using update_llc_test_checks.py

llvm-svn: 288782

7 years ago[X86] Remove bad pattern that caused 128-bit loads being used by scalar sqrt/rcp...
Craig Topper [Tue, 6 Dec 2016 08:08:04 +0000 (08:08 +0000)]
[X86] Remove bad pattern that caused 128-bit loads being used by scalar sqrt/rcp/rsqrt intrinsics to select the memory form of the corresponding instruction and violate the semantics of the intrinsic.

The intrinsics are supposed to pass the upper bits straight through to their output register. This means we need to make sure we still perform the 128-bit load to get those upper bits to pass to give to the instruction since the memory form of the instruction only reads 32 or 64 bits.

llvm-svn: 288781

7 years ago[X86] Add test case that shows a scalar sqrtsd intrinsic of a 128-bit vector load...
Craig Topper [Tue, 6 Dec 2016 08:08:01 +0000 (08:08 +0000)]
[X86] Add test case that shows a scalar sqrtsd intrinsic of a 128-bit vector load using the load form of the sqrtsd instruction which violates the intrinsic semantics.

The sqrtsd instruction only loads 64-bits and writes bits 63:0 with the sqrt result. Bits 127:64 are preserved in the destination register. The semantics of the intrinsic indicate bits 127:64 should come from the intrinsic argument which in this case is a 128-bit load. So the generated code should have a 128-bit load and use a register form of sqrtsd.

llvm-svn: 288780

7 years ago[X86] Correct pattern for VSQRTSSr_Int, VSQRTSDr_Int, VRCPSSr_Int, and VRSQRTSSr_Int...
Craig Topper [Tue, 6 Dec 2016 08:07:58 +0000 (08:07 +0000)]
[X86] Correct pattern for VSQRTSSr_Int, VSQRTSDr_Int, VRCPSSr_Int, and VRSQRTSSr_Int to not have an IMPLICIT_DEF on the first input. The semantics of the intrinsic are clear and not undefined.

The intrinsic takes one argument, the lower bits are affected by the operation and the upper bits should be passed through. The instruction itself takes two operands, the high bits of the first operand are passed through and the low bits of the second operand are modified by the operation. To match this to the intrinsic we should pass the single intrinsic input to both operands.

I had to remove the stack folding test for these instructions since they depended on the incorrect behavior. The same register is now used for both inputs so the load can't be folded.

llvm-svn: 288779

7 years agoFix stdio module build on OS X
Eric Fiselier [Tue, 6 Dec 2016 07:40:46 +0000 (07:40 +0000)]
Fix stdio module build on OS X

llvm-svn: 288778

7 years agobuiltins: Add ARM Thumb1 implementation for uidiv and uidivmod
Weiming Zhao [Tue, 6 Dec 2016 07:13:15 +0000 (07:13 +0000)]
builtins: Add ARM Thumb1 implementation for uidiv and uidivmod

This is a resubmit of r288710 due to breakage of Darwin armv7em.

llvm-svn: 288777

7 years ago[XRay][compiler-rt] Explicitly initialise members.
Dean Michael Berris [Tue, 6 Dec 2016 06:58:15 +0000 (06:58 +0000)]
[XRay][compiler-rt] Explicitly initialise members.

Before this, the change committed in D26232 might have an uninitialised
std::atomic<bool> that may or may not have a valid state. On aarch64
this breaks consistently, while it doesn't manifest as a problem in
x86_64.

This is an attempt to un-break this in aarch64.

llvm-svn: 288776

7 years ago[XRay][compiler-rt] XRay Buffer Queue
Dean Michael Berris [Tue, 6 Dec 2016 06:24:08 +0000 (06:24 +0000)]
[XRay][compiler-rt] XRay Buffer Queue

This implements a simple buffer queue to manage a pre-allocated queue of
fixed-sized buffers to hold XRay records. We need this to support
Flight Data Recorder (FDR) mode. We also implement this as a sub-library
first to allow for development before actually using it in an
implementation.

Some important properties of the buffer queue:

- Thread-safe enqueueing/dequeueing of fixed-size buffers.
- Pre-allocation of buffers at construction.

This is a re-roll of the previous attempt to submit, because it caused
failures in arm and aarch64.

Reviewers: majnemer, echristo, rSerge

Subscribers: tberghammer, danalbert, srhines, modocache, mehdi_amini, mgorny, llvm-commits

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

llvm-svn: 288775

7 years ago[ObjectYAML] First bit of support for encoding DWARF in MachO
Chris Bieneman [Tue, 6 Dec 2016 06:00:49 +0000 (06:00 +0000)]
[ObjectYAML] First bit of support for encoding DWARF in MachO

This patch adds the starting support for encoding data from the MachO __DWARF segment. The first section supported is the __debug_str section because it is the simplest.

llvm-svn: 288774

7 years agoRevert "builtins: Add ARM Thumb1 implementation for uidiv and uidivmod"
Chris Bieneman [Tue, 6 Dec 2016 05:41:32 +0000 (05:41 +0000)]
Revert "builtins: Add ARM Thumb1 implementation for uidiv and uidivmod"

This reverts commit r288710.

r288710 breaks building the builtin libraries on Darwin for armv7em.

Build logs may still be avaialable here:
http://lab.llvm.org:8080/green/job/clang-stage2-configure-Rlto_build/12035/console

llvm-svn: 288773

7 years ago[llgo] set debuglocs for calls in synthetic functions
Andrew Wilkins [Tue, 6 Dec 2016 05:39:14 +0000 (05:39 +0000)]
[llgo] set debuglocs for calls in synthetic functions

Synthesized functions do not have valid locations,
and so we were not setting a debug location. Recent
changes to DI require that function call instructions
within a function having DI must have a location set.
We just set the debug location to line=0, col=0.

Reviewers: pcc

Subscribers: llvm-commits

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

llvm-svn: 288772

7 years ago[X86] Remove scalar logical op alias instructions. Just use COPY_FROM/TO_REGCLASS...
Craig Topper [Tue, 6 Dec 2016 04:58:39 +0000 (04:58 +0000)]
[X86] Remove scalar logical op alias instructions. Just use COPY_FROM/TO_REGCLASS and the normal packed instructions instead

Summary:
This patch removes the scalar logical operation alias instructions. We can just use reg class copies and use the normal packed instructions instead. This removes the need for putting these instructions in the execution domain fixing tables as was done recently.

I removed the loadf64_128 and loadf32_128 patterns as DAG combine creates a narrower load for (extractelt (loadv4f32)) before we ever get to isel.

I plan to add similar patterns for AVX512DQ in a future commit to allow use of the larger register class when available.

Reviewers: spatel, delena, zvi, RKSimon

Subscribers: llvm-commits

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

llvm-svn: 288771

7 years ago[CMake] Cleanup TableGen include flags
Chris Bieneman [Tue, 6 Dec 2016 04:45:11 +0000 (04:45 +0000)]
[CMake] Cleanup TableGen include flags

It is kinda crazy to have llvm/include and llvm/lib/Target in the include path for every tablegen invocation for every tablegen-like tool.

This patch removes those flags from the tablgen function that is called everywhere by instead creating a variable LLVM_TABLEGEN_FLAGS which is setup in the LLVM source directories.

This removes TableGen.cmake's dependency on LLVM_MAIN_SRC_DIR, and LLVM_MAIN_INCLUDE_DIR.

llvm-svn: 288770

7 years ago[llgo] Update to use the latest IR attribute bindings
Meador Inge [Tue, 6 Dec 2016 04:01:11 +0000 (04:01 +0000)]
[llgo] Update to use the latest IR attribute bindings

A recent commit (r286087) to the LLVM Go bindings that
changed things over to use the new attribute API broke
llgo.  This commit updates llgo accordingly.

llvm-svn: 288769

7 years ago[llgo] Fix `debug` to use latest `DIBuilder` bindings
Meador Inge [Tue, 6 Dec 2016 04:00:12 +0000 (04:00 +0000)]
[llgo] Fix `debug` to use latest `DIBuilder` bindings

Two recent commits to the LLVM Go bindings caused breaking changes
to llgo:

  1. r284707 - Moving the `AlignInBits` field from `DIBasicType` to
               `DIAutoVariable`.

  2. r284482 - The `AlignInBits` fields going from `uint64` to `uint32`.

This commit updates llgo accordingly.

llvm-svn: 288768

7 years ago[LVI] Remove dead code in mergeIn
Philip Reames [Tue, 6 Dec 2016 03:34:33 +0000 (03:34 +0000)]
[LVI] Remove dead code in mergeIn

Integers are expressed in the lattice via constant ranges.  They can never be represented by constants or not-constants; those are reserved for non-integer types.  This code has been dead for literaly years.

llvm-svn: 288767

7 years ago[LVI] Extract a helper function
Philip Reames [Tue, 6 Dec 2016 03:22:03 +0000 (03:22 +0000)]
[LVI] Extract a helper function

Extracting a helper function out of solveBlockValue makes the contract around the cache much easier to understand.

llvm-svn: 288766

7 years ago[LVI] Hide the last markX function on LVILatticeVal
Philip Reames [Tue, 6 Dec 2016 03:01:08 +0000 (03:01 +0000)]
[LVI] Hide the last markX function on LVILatticeVal

This completes a small series of patches to hide the stateful updates of LVILatticeVal from the consuming code.  The only remaining stateful API is mergeIn.

llvm-svn: 288765

7 years ago[LVI] Hide a confusing internal interface
Philip Reames [Tue, 6 Dec 2016 02:54:16 +0000 (02:54 +0000)]
[LVI] Hide a confusing internal interface

llvm-svn: 288764

7 years ago[llvm] Fix D26214: Move error handling out of MC and to the callers.
Mandeep Singh Grang [Tue, 6 Dec 2016 02:49:17 +0000 (02:49 +0000)]
[llvm] Fix D26214: Move error handling out of MC and to the callers.

Summary: Related clang patch; https://reviews.llvm.org/D27360

Reviewers: t.p.northover, grosbach, compnerd, echristo

Subscribers: compnerd, mehdi_amini, llvm-commits

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

llvm-svn: 288763

7 years ago[clang] Fix D26214: Move error handling out of MC and to the callers.
Mandeep Singh Grang [Tue, 6 Dec 2016 02:49:16 +0000 (02:49 +0000)]
[clang] Fix D26214: Move error handling out of MC and to the callers.

Summary: Related llvm patch: https://reviews.llvm.org/D27359

Reviewers: echristo, t.p.northover, rengolin, grosbach, compnerd

Subscribers: mehdi_amini, cfe-commits, llvm-commits

Tags: #clang-c

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

llvm-svn: 288762

7 years ago[LVI] Remove duplicate code using existing helper function
Philip Reames [Tue, 6 Dec 2016 02:36:58 +0000 (02:36 +0000)]
[LVI] Remove duplicate code using existing helper function

llvm-svn: 288761

7 years agostd::get<0>([std::variant constant expression]) *is* noexcept.
Casey Carter [Tue, 6 Dec 2016 02:28:19 +0000 (02:28 +0000)]
std::get<0>([std::variant constant expression]) *is* noexcept.

Differential review: http://reviews.llvm.org/D27436

llvm-svn: 288760

7 years agoRevert "[SCCP] Remove manual folding of terminator instructions."
Davide Italiano [Tue, 6 Dec 2016 02:26:50 +0000 (02:26 +0000)]
Revert "[SCCP] Remove manual folding of terminator instructions."

This reverts commit r288725 as it broke a bot.

llvm-svn: 288759

7 years agoRefactor TargetParserTests.
Zijiao Ma [Tue, 6 Dec 2016 02:22:08 +0000 (02:22 +0000)]
Refactor TargetParserTests.

The TargetParser tests are a bit redundant. Refactor them in a more
repeatable way.

llvm-svn: 288758

7 years agoInline MergeInputSection::getData().
Rui Ueyama [Tue, 6 Dec 2016 02:19:30 +0000 (02:19 +0000)]
Inline MergeInputSection::getData().

This change seems to make LLD 0.6% faster when linking Clang with
debug info. I don't want us to have lots of local optimizations,
but this function is very hot, and the improvement is small but
not negligible, so I think it's worth doing.

llvm-svn: 288757

7 years agoClean up some Sema checking code. NFC
Richard Trieu [Tue, 6 Dec 2016 01:42:28 +0000 (01:42 +0000)]
Clean up some Sema checking code.  NFC

- Rename CheckMinZero to CheckMaxUnsignedZero to reflect its actual purpose.
- Remove unused parameters from CheckAbsoluteValueFunction and
  CheckMaxUnsignedZero functions.
- Refactor the function name check so both functions can use the same one.

llvm-svn: 288756

7 years agoFix C++03 modules build
Eric Fiselier [Tue, 6 Dec 2016 01:34:24 +0000 (01:34 +0000)]
Fix C++03 modules build

llvm-svn: 288755

7 years agoIntroduces cmake option `LLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING`
Mehdi Amini [Tue, 6 Dec 2016 01:23:04 +0000 (01:23 +0000)]
Introduces cmake option `LLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING`

Summary:
We recently introduced a feature that enforce at link-time that the
LLVM headers used by a clients are matching the ABI setting of the
LLVM library linked to.

However for clients that are using only headers from ADT and promise
they won't call into LLVM, this is forcing to link libSupport. This
new flag is intended to provide a way to configure LLVM with this
promise for such client.

Reviewers: bob.wilson, compnerd

Subscribers: mgorny, llvm-commits

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

llvm-svn: 288754

7 years ago[libcxx] [test] D27269: Fix MSVC x64 warning C4267 "conversion from 'size_t' to ...
Stephan T. Lavavej [Tue, 6 Dec 2016 01:14:51 +0000 (01:14 +0000)]
[libcxx] [test] D27269: Fix MSVC x64 warning C4267 "conversion from 'size_t' to 'int' [or 'unsigned int'], possible loss of data", part 3/4.

test/std/containers/sequences/vector.bool/copy.pass.cpp
test/std/containers/sequences/vector.bool/copy_alloc.pass.cpp
test/std/containers/sequences/vector/vector.cons/copy.pass.cpp
test/std/containers/sequences/vector/vector.cons/copy_alloc.pass.cpp
Change "unsigned s = x.size();" to "typename C::size_type s = x.size();"
because that's what it returns.

test/std/strings/basic.string/string.cons/pointer_alloc.pass.cpp
Include <cstddef>, then change "unsigned n = T::length(s);"
to "std::size_t n = T::length(s);" because that's what char_traits returns.

test/std/strings/basic.string/string.cons/substr.pass.cpp
Change unsigned to typename S::size_type because that's what str.size() returns.

test/std/utilities/template.bitset/bitset.cons/ull_ctor.pass.cpp
This was needlessly truncating std::size_t to unsigned.
It's being used to compare and initialize std::size_t.

llvm-svn: 288753

7 years ago[libcxx] [test] D27268: Fix MSVC x64 warning C4267 "conversion from 'size_t' to ...
Stephan T. Lavavej [Tue, 6 Dec 2016 01:14:43 +0000 (01:14 +0000)]
[libcxx] [test] D27268: Fix MSVC x64 warning C4267 "conversion from 'size_t' to 'int' [or 'unsigned int'], possible loss of data", part 2/4.

Use static_cast<int> when storing size_t in int (or passing size_t to int).

Also, remove a spurious semicolon in test/support/archetypes.hpp.

test/support/count_new.hpp
Additionally, change data members (and parameters) to size_t.

llvm-svn: 288752

7 years ago[libcxx] [test] D27267: Fix MSVC x64 warning C4267 "conversion from 'size_t' to ...
Stephan T. Lavavej [Tue, 6 Dec 2016 01:14:29 +0000 (01:14 +0000)]
[libcxx] [test] D27267: Fix MSVC x64 warning C4267 "conversion from 'size_t' to 'int' [or 'unsigned int'], possible loss of data", part 1/4.

Replace "int n = str_.size();" with "int n = static_cast<int>(str_.size());".

int is the correct type to use, because we're eventually calling
"base::pbump(n+1);" where base is std::basic_streambuf.
N4606 27.6.3.3.3 [streambuf.put.area]/4 declares: "void pbump(int n);"

llvm-svn: 288751

7 years ago[libcxx] [test] D27266: Remove spurious semicolons.
Stephan T. Lavavej [Tue, 6 Dec 2016 01:14:06 +0000 (01:14 +0000)]
[libcxx] [test] D27266: Remove spurious semicolons.

llvm-svn: 288750

7 years ago[libcxx] [test] D27025: Fix MSVC warning C4389 "signed/unsigned mismatch", part 12/12.
Stephan T. Lavavej [Tue, 6 Dec 2016 01:13:51 +0000 (01:13 +0000)]
[libcxx] [test] D27025: Fix MSVC warning C4389 "signed/unsigned mismatch", part 12/12.

Various changes:

test/std/algorithms/alg.sorting/alg.merge/inplace_merge.pass.cpp
This is comparing value_type to unsigned. value_type is sometimes int and sometimes struct S (implicitly constructible from int).
static_cast<value_type>(unsigned) silences the warning and doesn't do anything bad (as the values in question are small).

test/std/algorithms/alg.sorting/alg.nth.element/nth_element_comp.pass.cpp
This is comparing an int remote-element to size_t. The values in question are small and non-negative,
so either type is fine. I think that converting int to size_t is marginally better here than the reverse.

test/std/containers/sequences/deque/deque.cons/size.pass.cpp
DefaultOnly::count is int (and non-negative). When comparing to unsigned, use static_cast<unsigned>.

test/std/strings/basic.string/string.access/index.pass.cpp
We're comparing char to '0' through '9', but formed with the type size_t. Add static_cast<char>.

test/std/utilities/template.bitset/bitset.cons/ull_ctor.pass.cpp
Include <cstddef> for pedantic correctness (this test was already mentioning std::size_t).

"v[i] == (i & 1)" was comparing bool to size_t. Saying "v[i] == ((i & 1) != 0)" smashes the RHS to bool.

llvm-svn: 288749

7 years ago[libcxx] [test] D27024: Fix MSVC warning C4389 "signed/unsigned mismatch", part 11/12.
Stephan T. Lavavej [Tue, 6 Dec 2016 01:13:40 +0000 (01:13 +0000)]
[libcxx] [test] D27024: Fix MSVC warning C4389 "signed/unsigned mismatch", part 11/12.

Change "unsigned n = 0;" to "int n = 0;". It's being compared to int elements and ptrdiff_t distances.

test/std/containers/sequences/forwardlist/forwardlist.cons/move.pass.cpp
This one's a little special, but not really. "*i == n" is comparing MoveOnly to n.
MoveOnly is implicitly constructible from int, so int is the correct type to use here.

llvm-svn: 288748

7 years ago[libcxx] [test] D27023: Fix MSVC warning C4389 "signed/unsigned mismatch", part 10/12.
Stephan T. Lavavej [Tue, 6 Dec 2016 01:13:29 +0000 (01:13 +0000)]
[libcxx] [test] D27023: Fix MSVC warning C4389 "signed/unsigned mismatch", part 10/12.

Add static_cast<int>. In these cases, the values are guaranteed to be small-ish,
and they're being compared to int elements.

test/std/containers/sequences/deque/deque.capacity/access.pass.cpp
Use int instead of unsigned to iterate from 0 to 10.

llvm-svn: 288747

7 years ago[libcxx] [test] D27022: Fix MSVC warning C4389 "signed/unsigned mismatch", part 9/12.
Stephan T. Lavavej [Tue, 6 Dec 2016 01:13:14 +0000 (01:13 +0000)]
[libcxx] [test] D27022: Fix MSVC warning C4389 "signed/unsigned mismatch", part 9/12.

Add static_cast<std::size_t> to more comparisons. (Performed manually, unlike part 8/12.)

Also, include <cstddef> when it wasn't already being included.

llvm-svn: 288746

7 years ago[libcxx] [test] D27021: Fix MSVC warning C4389 "signed/unsigned mismatch", part 8/12.
Stephan T. Lavavej [Tue, 6 Dec 2016 01:12:34 +0000 (01:12 +0000)]
[libcxx] [test] D27021: Fix MSVC warning C4389 "signed/unsigned mismatch", part 8/12.

Add static_cast<std::size_t> when comparing distance() to size().

These replacements were performed programmatically with regex_replace():

const vector<pair<regex, string>> reg_fmt = {
    { regex(R"(assert\((\w+)\.size\(\) == std::distance\((\w+, \w+)\)\))"),
        "assert($1.size() == static_cast<std::size_t>(std::distance($2)))" },
    { regex(R"(assert\(distance\((\w+\.begin\(\), \w+\.end\(\))\) == (\w+)\.size\(\)\))"),
        "assert(static_cast<std::size_t>(distance($1)) == $2.size())" },
    { regex(R"(assert\(std::distance\((\w+\.\w*begin\(\), \w+\.\w*end\(\))\) == (\w+)\.size\(\)\))"),
        "assert(static_cast<std::size_t>(std::distance($1)) == $2.size())" },
};

Also, include <cstddef> when it wasn't already being included.

llvm-svn: 288745

7 years agoAMDGPU: Don't required structured CFG
Matt Arsenault [Tue, 6 Dec 2016 01:02:51 +0000 (01:02 +0000)]
AMDGPU: Don't required structured CFG

The structured CFG is just an aid to inserting exec
mask modification instructions, once that is done
we don't really need it anymore. We also
do not analyze blocks with terminators that
modify exec, so this should only be impacting
true branches.

llvm-svn: 288744

7 years agoAdd support for writing -verify shell tests
Eric Fiselier [Tue, 6 Dec 2016 01:02:15 +0000 (01:02 +0000)]
Add support for writing -verify shell tests

llvm-svn: 288743

7 years agorevert inadvertedly introduced build break
Bob Haarman [Tue, 6 Dec 2016 00:55:55 +0000 (00:55 +0000)]
revert inadvertedly introduced build break

Summary:
r288722 introduced a build break due some code that should
not have been part of the commit. This change removes the offending
code.

Reviewers: davide, ruiu

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

llvm-svn: 288742

7 years agoRevert r288626, which reverts r288449. Original commit message:
Richard Smith [Tue, 6 Dec 2016 00:40:17 +0000 (00:40 +0000)]
Revert r288626, which reverts r288449. Original commit message:

Recover better from an incompatible .pcm file being provided by -fmodule-file=. We try to include the headers of the module textually in this case, still enforcing the modules semantic rules. In order to make that work, we need to still track that we're entering and leaving the module. Also, if the module was also marked as unavailable (perhaps because it was missing a file), we shouldn't mark the module unavailable -- we don't need the module to be complete if we're going to enter it textually.

llvm-svn: 288741

7 years agoAdd test for r288732, warn on unsigned zero in std::max
Richard Trieu [Tue, 6 Dec 2016 00:27:21 +0000 (00:27 +0000)]
Add test for r288732, warn on unsigned zero in std::max

llvm-svn: 288740

7 years agoAdditional test file missed from r288737.
Richard Smith [Tue, 6 Dec 2016 00:14:22 +0000 (00:14 +0000)]
Additional test file missed from r288737.

llvm-svn: 288738

7 years ago[modules] Use the "redundant #include" diagnostic rather than the "module
Richard Smith [Tue, 6 Dec 2016 00:12:39 +0000 (00:12 +0000)]
[modules] Use the "redundant #include" diagnostic rather than the "module
import can't appear here" diagnostic if an already-visible module is textually
entered (because we have the module map but not the AST file) within a
function/namespace scope.

llvm-svn: 288737

7 years agoAllow enabling/disabling testing with module using env LIBCXX_USE_MODULES=1
Eric Fiselier [Tue, 6 Dec 2016 00:01:04 +0000 (00:01 +0000)]
Allow enabling/disabling testing with module using env LIBCXX_USE_MODULES=1

The Clang modules implementation breaks enough that libc++ needs an easy way
to enable/disable using modules on the Zorg builders. Editing Zorg itself
requires a buildmaster restart which only happens weekly. This patch
allows LIBCXX_USE_MODULES to be used to enable/disable the feature,
allowing the buildslave to disable it as need be.

llvm-svn: 288736

7 years agoAdd module definitions for <experimental/foo> headers
Eric Fiselier [Mon, 5 Dec 2016 23:55:34 +0000 (23:55 +0000)]
Add module definitions for <experimental/foo> headers

llvm-svn: 288735

7 years agoSummary: Currently there is no way to disable deprecated warning from asm like this
Weiming Zhao [Mon, 5 Dec 2016 23:55:13 +0000 (23:55 +0000)]
Summary: Currently there is no way to disable deprecated warning from asm like this

clang  -target arm deprecated-asm.s -c
  deprecated-asm.s:30:9: warning: use of SP or PC in the list is deprecated
       stmia   r4!, {r12-r14}

We have to have an option what can disable it.

Patched by Yin Ma!

Reviewers: joey, echristo, weimingz

Subscribers: llvm-commits, aemerson

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

llvm-svn: 288734

7 years agoAdd module definitions for string_view
Eric Fiselier [Mon, 5 Dec 2016 23:53:23 +0000 (23:53 +0000)]
Add module definitions for string_view

llvm-svn: 288733

7 years agoWarn on unsigned zero in call to std::max
Richard Trieu [Mon, 5 Dec 2016 23:41:46 +0000 (23:41 +0000)]
Warn on unsigned zero in call to std::max

New default warning that triggers when an unsigned zero is used in a call to
std::max.  For unsigned values, zero is the minimum value, so any call to
std::max is always equal to the other value.  A common pattern was to take
the max of zero and the difference of two unsigned values, not taking into
account that unsigned values wrap around below zero.  This warning also emits
a note with a fixit hint to remove the zero and call to std::max.

llvm-svn: 288732

7 years ago[libFuzzer] refactor the code to allow collecting features in different ways. Also...
Kostya Serebryany [Mon, 5 Dec 2016 23:35:22 +0000 (23:35 +0000)]
[libFuzzer] refactor the code to allow collecting features in different ways. Also initialize a couple of Fuzzer:: members that might have been used uninitialized :(

llvm-svn: 288731

7 years agoAdd modules for any/optional/variant
Eric Fiselier [Mon, 5 Dec 2016 23:33:19 +0000 (23:33 +0000)]
Add modules for any/optional/variant

llvm-svn: 288730

7 years ago[XRay][AArch64] Attempt to fix unstable test XRay-aarch64-linux::patching-unpatching.cc
Serge Rogatch [Mon, 5 Dec 2016 23:29:56 +0000 (23:29 +0000)]
[XRay][AArch64] Attempt to fix unstable test XRay-aarch64-linux::patching-unpatching.cc

Summary: Currently test XRay-aarch64-linux::patching-unpatching.cc sometimes passes, sometimes fails. This is an attempt to fix it by handling better the situations when both `__arm__` and `__aarch64__` are defined.

Reviewers: dberris, rengolin

Subscribers: llvm-commits, iid_iunknown, aemerson, rengolin, dberris

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

llvm-svn: 288729

7 years agoAdjust libc++ test infastructure to fully support modules
Eric Fiselier [Mon, 5 Dec 2016 23:16:07 +0000 (23:16 +0000)]
Adjust libc++ test infastructure to fully support modules

This patch overhalls the libc++ test format/configuration in order to fully support modules. By "fully support" I mean get almost all of the tests passing. The main hurdle for doing this is handling tests that `#define _LIBCPP_FOO` macros to test a different configuration. This patch deals with these tests in the following ways:

1. For tests that define single `_LIBCPP_ABI_FOO` macros have been annotated with `// MODULES_DEFINES: _LIBCPP_ABI_FOO`. This allows the test suite to define the macro on the command line so it uses a different set of modules.
2. Tests for libc++'s debug mode (which define custom `_LIBCPP_ASSERT`) are automatically detected by the test suite and are compiled and run with modules disabled.

This patch also cleans up how the `CXXCompiler` helper class handles enabling/disabling language features.

NOTE: This patch uses `LIT` features which were only committed to LLVM today. If this patch breaks running the libc++ tests you probably need to update LLVM.
llvm-svn: 288728

7 years agoGlobalISel: avoid looking too closely at PHIs when we bail.
Tim Northover [Mon, 5 Dec 2016 23:10:19 +0000 (23:10 +0000)]
GlobalISel: avoid looking too closely at PHIs when we bail.

The function used to finish off PHIs by adding the relevant basic blocks can
fail if we're aborting and still don't actually have the needed
MachineBasicBlocks. So avoid trying in that case.

llvm-svn: 288727

7 years ago[sanitizers] mac prints null differently
Mike Aizatsky [Mon, 5 Dec 2016 23:06:07 +0000 (23:06 +0000)]
[sanitizers] mac prints null differently

llvm-svn: 288726

7 years ago[SCCP] Remove manual folding of terminator instructions.
Davide Italiano [Mon, 5 Dec 2016 23:04:21 +0000 (23:04 +0000)]
[SCCP] Remove manual folding of terminator instructions.

There are two cases handled here:
1) a branch on undef
2) a switch with an undef condition.

Both cases are currently handled by ResolvedUndefsIn. If we have
a branch on undef, we force its value to false (which is trivially
foldable). If we have a switch on undef, we force to the first
constant (which is also foldable).

llvm-svn: 288725

7 years ago[TableGen] Centralize/Unify error handling.
Davide Italiano [Mon, 5 Dec 2016 22:58:01 +0000 (22:58 +0000)]
[TableGen] Centralize/Unify error handling.

llvm-svn: 288724

7 years ago[docs] Use x86_64 and i386 instead of x86 as arch for triples.
Florian Hahn [Mon, 5 Dec 2016 22:52:20 +0000 (22:52 +0000)]
[docs] Use x86_64 and i386 instead of x86 as arch for triples.

Summary: x86 is not a valid arch for target triples, but x86_64 and i386 are.

Reviewers: rengolin, silvas

Subscribers: cfe-commits

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

llvm-svn: 288723

7 years ago[pdb] handle missing pdb streams more gracefully
Bob Haarman [Mon, 5 Dec 2016 22:44:00 +0000 (22:44 +0000)]
[pdb] handle missing pdb streams more gracefully

Summary: The code we use to read PDBs assumed that streams we ask it to read exist, and would read memory outside a vector and crash if this wasn't the case. This would, for example, cause llvm-pdbdump to crash on PDBs generated by lld. This patch handles such cases more gracefully: the PDB reading code in LLVM now reports errors when asked to get a stream that is not present, and llvm-pdbdump will report missing streams and continue processing streams that are present.

Reviewers: ruiu, zturner

Subscribers: thakis, amccarth

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

llvm-svn: 288722

7 years agoCodeGen: fix windows itanium RTTI in EH mode
Saleem Abdulrasool [Mon, 5 Dec 2016 22:40:20 +0000 (22:40 +0000)]
CodeGen: fix windows itanium RTTI in EH mode

When emitting RTTI for EH only, we would mark the locally defined (LinkOnceODR)
RTTI definition as dllimport, which is incorrect.  Ensure that if we are
generating the type information for EH only, it is marked as LinkOnceODR and we
do not make it dllimport.

llvm-svn: 288721

7 years agoGlobalISel: place constants correctly in the entry block.
Tim Northover [Mon, 5 Dec 2016 22:40:13 +0000 (22:40 +0000)]
GlobalISel: place constants correctly in the entry block.

When the entry block was empty after arg lowering, we were always placing
constants at the end. This is probably hamrless while translating the same
block, but horribly wrong once its terminator has been translated. So switch to
inserting at the beginning.

llvm-svn: 288720

7 years agoTest only the relevant bits.
Rafael Espindola [Mon, 5 Dec 2016 22:27:21 +0000 (22:27 +0000)]
Test only the relevant bits.

This test only needs to test the Type (SharedObject), the address of
the first PT_LOAD and the presence of PT_DYNAMIC.

llvm-svn: 288719

7 years agoAMDGPU: Consolidate inline immediate predicate functions
Matt Arsenault [Mon, 5 Dec 2016 22:26:17 +0000 (22:26 +0000)]
AMDGPU: Consolidate inline immediate predicate functions

llvm-svn: 288718

7 years agoGlobalISel: handle pointer arguments that get assigned to the stack.
Tim Northover [Mon, 5 Dec 2016 22:20:32 +0000 (22:20 +0000)]
GlobalISel: handle pointer arguments that get assigned to the stack.

llvm-svn: 288717

7 years agoDon't check the symbol values is this test.
Rafael Espindola [Mon, 5 Dec 2016 22:16:32 +0000 (22:16 +0000)]
Don't check the symbol values is this test.

It only needs to find how many are local.

llvm-svn: 288716

7 years agoAMDGPU: Minor assembler refactoring
Matt Arsenault [Mon, 5 Dec 2016 22:07:21 +0000 (22:07 +0000)]
AMDGPU: Minor assembler refactoring

Fix return before else, check types for selecting
fltSemantics, refactor immediate checks.

llvm-svn: 288715

7 years ago[IR] Fix some Clang-tidy modernize-use-equals-delete and Include What You Use warning...
Eugene Zelenko [Mon, 5 Dec 2016 21:55:02 +0000 (21:55 +0000)]
[IR] Fix some Clang-tidy modernize-use-equals-delete and Include What You Use warnings; other minor fixes (NFC).

Also remove obsolete comment from CommandLine.h spotted by Malcolm Parsons.

llvm-svn: 288714

7 years agoGlobalISel: translate constants larger than 64 bits.
Tim Northover [Mon, 5 Dec 2016 21:54:17 +0000 (21:54 +0000)]
GlobalISel: translate constants larger than 64 bits.

llvm-svn: 288713

7 years agoGlobalISel: make G_CONSTANT take a ConstantInt rather than int64_t.
Tim Northover [Mon, 5 Dec 2016 21:47:07 +0000 (21:47 +0000)]
GlobalISel: make G_CONSTANT take a ConstantInt rather than int64_t.

This makes it more similar to the floating-point constant, and also allows for
larger constants to be translated later. There's no real functional change in
this patch though, just syntax updates.

llvm-svn: 288712

7 years ago[sanitizers] __sanitizer_get_module_and_offset_for_pc interface function
Mike Aizatsky [Mon, 5 Dec 2016 21:45:14 +0000 (21:45 +0000)]
[sanitizers] __sanitizer_get_module_and_offset_for_pc interface function

Summary: The function computes full module name and coverts pc into offset.

Reviewers: kcc

Subscribers: kubabrecka

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

llvm-svn: 288711

7 years agobuiltins: Add ARM Thumb1 implementation for uidiv and uidivmod
Weiming Zhao [Mon, 5 Dec 2016 21:40:36 +0000 (21:40 +0000)]
builtins: Add ARM Thumb1 implementation for uidiv and uidivmod

Summary:
The current uidiv supports archs without clz. However, the asm is for thumb2/arm.
For uidivmod, the existing code calls the C version of uidivmodsi4, which then calls uidiv. The extra push/pop/bl makes it less efficient.

Reviewers: jmolloy, jroelofs, joerg, compnerd, rengolin

Subscribers: llvm-commits, aemerson

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

llvm-svn: 288710

7 years agoGlobalISel: improve translation fallback for constants.
Tim Northover [Mon, 5 Dec 2016 21:40:33 +0000 (21:40 +0000)]
GlobalISel: improve translation fallback for constants.

Returning 0 (NoReg) from getOrCreateVReg leads to unexpected situations later
in the translation. It's better to return a valid (if undefined) register and
let the rest of the instruction carry on as planned.

llvm-svn: 288709

7 years agoRevert r288707: Split removeUnusedSyntheticSections into two functions.
Rui Ueyama [Mon, 5 Dec 2016 21:39:35 +0000 (21:39 +0000)]
Revert r288707: Split removeUnusedSyntheticSections into two functions.

That patch broke build.

llvm-svn: 288708

7 years agoSplit removeUnusedSyntheticSections into two functions.
Rui Ueyama [Mon, 5 Dec 2016 21:37:16 +0000 (21:37 +0000)]
Split removeUnusedSyntheticSections into two functions.

llvm-svn: 288707

7 years agoGlobalISel: handle 1-element aggregates during ABI lowering.
Tim Northover [Mon, 5 Dec 2016 21:25:33 +0000 (21:25 +0000)]
GlobalISel: handle 1-element aggregates during ABI lowering.

llvm-svn: 288706

7 years ago[LAA] Prevent invalid IR for loop-invariant bound in loop body
Keno Fischer [Mon, 5 Dec 2016 21:25:03 +0000 (21:25 +0000)]
[LAA] Prevent invalid IR for loop-invariant bound in loop body

Summary:
If LAA expands a bound that is loop invariant, but not hoisted out
of the loop body, it used to use that value anyway, causing a
non-domination error, because the memcheck block is of course not
dominated by the scalar loop body. Detect this situation and expand
the SCEV expression instead.

Fixes PR31251

Reviewers: anemet
Subscribers: mzolotukhin, llvm-commits

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

llvm-svn: 288705