platform/upstream/llvm.git
7 years agoAMDGPU: Select i16 instructions to VOP3 forms
Matt Arsenault [Fri, 9 Dec 2016 06:19:12 +0000 (06:19 +0000)]
AMDGPU: Select i16 instructions to VOP3 forms

These were selecting directly to the VOP2 form instead
of VOP3 like the i32 instructions. Fixes regressions in
future commits where an immediate isn't folded because it was
initially used for the second operand.

Because uniform 16-bit operations are promoted to i32, it's
difficult to get a simple testcase where this matters. Fold
failures in SIFoldOperands here tend to be hidden by commute
and fold in SIShrinkInstructions.

llvm-svn: 289189

7 years agoRemove some more uses of Args::GetArgumentAtIndex.
Zachary Turner [Fri, 9 Dec 2016 05:46:41 +0000 (05:46 +0000)]
Remove some more uses of Args::GetArgumentAtIndex.

llvm-svn: 289188

7 years agoRe-commit r289184, "Support: Use a 64-bit seek in raw_fd_ostream::seek()." with a...
Peter Collingbourne [Fri, 9 Dec 2016 05:20:43 +0000 (05:20 +0000)]
Re-commit r289184, "Support: Use a 64-bit seek in raw_fd_ostream::seek()." with a configure-time check for lseek64.

llvm-svn: 289187

7 years ago[X86] Add masked versions of VPERMT2* and VPERMI2* to load folding tables.
Craig Topper [Fri, 9 Dec 2016 05:20:11 +0000 (05:20 +0000)]
[X86] Add masked versions of VPERMT2* and VPERMI2* to load folding tables.

llvm-svn: 289186

7 years agoRevert r289184, we need more configury for Darwin and *BSD.
Peter Collingbourne [Fri, 9 Dec 2016 05:04:30 +0000 (05:04 +0000)]
Revert r289184, we need more configury for Darwin and *BSD.

llvm-svn: 289185

7 years agoSupport: Use a 64-bit seek in raw_fd_ostream::seek().
Peter Collingbourne [Fri, 9 Dec 2016 04:57:19 +0000 (04:57 +0000)]
Support: Use a 64-bit seek in raw_fd_ostream::seek().

llvm-svn: 289184

7 years agoAdd type records to TPI stream.
Rui Ueyama [Fri, 9 Dec 2016 04:46:54 +0000 (04:46 +0000)]
Add type records to TPI stream.

I don't think the data I add to a TPI stream in this patch is correct,
but at least it can be displayed using llvm-pdbdump. Until I add more
streams to a PDB file, I'm not able to know whether the data will be
accepted by MSVC tools or not.

llvm-svn: 289183

7 years ago[SCCP] Make the test added in r289175 more meaningful.
Davide Italiano [Fri, 9 Dec 2016 03:49:20 +0000 (03:49 +0000)]
[SCCP] Make the test added in r289175 more meaningful.

Add a comment while here.

llvm-svn: 289182

7 years ago[Headers] Add #include_next for tgmath.h on Darwin
Bruno Cardoso Lopes [Fri, 9 Dec 2016 03:30:46 +0000 (03:30 +0000)]
[Headers] Add #include_next for tgmath.h on Darwin

Allow darwin to provide additional definitions and implementation
specifc values for tgmath.h on Apple platforms.

rdar://problem/19019845

llvm-svn: 289181

7 years agoReverting rL289088 while investigating some test issue on the build servers
Kostya Kortchinsky [Fri, 9 Dec 2016 03:28:12 +0000 (03:28 +0000)]
Reverting rL289088 while investigating some test issue on the build servers

Subscribers: kubabrecka

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

llvm-svn: 289180

7 years ago[OpenMP] Sema and parsing for 'teams distribute parallel for' pragma
Kelvin Li [Fri, 9 Dec 2016 03:24:30 +0000 (03:24 +0000)]
[OpenMP] Sema and parsing for 'teams distribute parallel for' pragma

This patch is to implement sema and parsing for 'teams distribute parallel for' pragma.

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

llvm-svn: 289179

7 years agofix misspelling in .clang-format
Eric Fiselier [Fri, 9 Dec 2016 03:18:45 +0000 (03:18 +0000)]
fix misspelling in .clang-format

llvm-svn: 289178

7 years agoTurn off header sorting and comment formatting
Eric Fiselier [Fri, 9 Dec 2016 03:17:25 +0000 (03:17 +0000)]
Turn off header sorting and comment formatting

llvm-svn: 289177

7 years ago[CrashReproducer] Provide a clean dir path for -fmodules-cache-path
Bruno Cardoso Lopes [Fri, 9 Dec 2016 03:11:48 +0000 (03:11 +0000)]
[CrashReproducer] Provide a clean dir path for -fmodules-cache-path

The most common workflow with module reproducers involves deleting the
module cache before running the script. This happens because leftovers
from the crash are present in the cache and could trigger unrelated and
confusing errors, misleading from the initial reproduction intent.
Change this to point to a clean path but leave the leftovers untouched.

rdar://problem/28655070

llvm-svn: 289176

7 years ago[SCCP] Teach the pass about `mul %x 0` even if %x is overdefined.
Davide Italiano [Fri, 9 Dec 2016 03:08:42 +0000 (03:08 +0000)]
[SCCP] Teach the pass about `mul %x 0` even if %x is overdefined.

The motivating example is:

extern int patatino;
int goo() {
    int x = 0;
    for (int i = 0; i < 1000000; ++i) {
        x *= patatino;
    }
    return x;
}

Currently SCCP will not realize that this function returns always zero,
therefore will try to unroll and vectorize the loop at -O3 producing an
awful lot of (useless) code. With this change, it will just produce:

0000000000000000 <g>:
   xor    %eax,%eax
   retq

llvm-svn: 289175

7 years ago[CrashReproducer] Rewrite relative include paths
Bruno Cardoso Lopes [Fri, 9 Dec 2016 02:22:47 +0000 (02:22 +0000)]
[CrashReproducer] Rewrite relative include paths

When -fmodules is on, the reproducer invocation currently leave paths
for include-like flags as is. If the path is relative, the reproducer
doesn't know how to access that file during reproduction time because
the VFS cannot reason about relative paths.

Expand relative paths to absolute ones when creating the reproducer
command line. This allows, for example, the reproducer to work for
crashes while building clang with modules; this wasn't possible before
because building clang requires using relative inc dir from within the
build directory.

rdar://problem/28655070

llvm-svn: 289174

7 years ago[AVX-512] Add vpermilps/pd to load folding tables.
Craig Topper [Fri, 9 Dec 2016 02:18:11 +0000 (02:18 +0000)]
[AVX-512] Add vpermilps/pd to load folding tables.

llvm-svn: 289173

7 years ago[AVX-512] Move some floating point stack folding test cases out of the integer test.
Craig Topper [Fri, 9 Dec 2016 02:18:07 +0000 (02:18 +0000)]
[AVX-512] Move some floating point stack folding test cases out of the integer test.

llvm-svn: 289172

7 years ago[Analysis] Fix typo in comment. NFC
Craig Topper [Fri, 9 Dec 2016 02:18:04 +0000 (02:18 +0000)]
[Analysis] Fix typo in comment. NFC

llvm-svn: 289171

7 years agoCOFF: Use make() in SymbolTable and Writer.
Rui Ueyama [Fri, 9 Dec 2016 02:13:12 +0000 (02:13 +0000)]
COFF: Use make() in SymbolTable and Writer.

llvm-svn: 289170

7 years agoCalling SBDebugger::CeeateTarget being called on multiple threads was crashing LLDB.
Greg Clayton [Fri, 9 Dec 2016 01:21:14 +0000 (01:21 +0000)]
Calling SBDebugger::CeeateTarget being called on multiple threads was crashing LLDB.

I found the race condition in:

ScriptInterpreter *CommandInterpreter::GetScriptInterpreter(bool can_create);

More than one "ScriptInterpreter *" was being returned due to the race which caused any clients with the first one to now be pointing to freed memory and we would quickly crash.

Added a test to catch this so we don't regress.

<rdar://problem/28356584>

llvm-svn: 289169

7 years agoFix some occurrences of passing StringRef to Printf.
Zachary Turner [Fri, 9 Dec 2016 01:20:58 +0000 (01:20 +0000)]
Fix some occurrences of passing StringRef to Printf.

Hopefully these will all disappear in the future once we move
to formatv.

llvm-svn: 289168

7 years agoSpecify -std=gnu++98 on some Rewriter tests. NFC.
Paul Robinson [Fri, 9 Dec 2016 01:20:40 +0000 (01:20 +0000)]
Specify -std=gnu++98 on some Rewriter tests. NFC.

Rewriter tests rewrite Objective-C++ to C++, and then compile the
result.  The rewritten result sometimes doesn't work with C++11.  As
we want to allow Clang's default dialect to become C++11, we need to
make sure the tests will still pass.

llvm-svn: 289167

7 years ago[libFuzzer] implement crash-resistant merge (https://github.com/google/sanitizers...
Kostya Serebryany [Fri, 9 Dec 2016 01:17:24 +0000 (01:17 +0000)]
[libFuzzer] implement crash-resistant merge (https://github.com/google/sanitizers/issues/722). This is a first experimental variant that needs some more testing, thus not yet adding a lit test (but there are unit tests).

llvm-svn: 289166

7 years agoWholeProgramDevirt: Teach the pass to handle structs of arrays.
Peter Collingbourne [Fri, 9 Dec 2016 01:10:11 +0000 (01:10 +0000)]
WholeProgramDevirt: Teach the pass to handle structs of arrays.

This will become necessary in some cases once D22296 lands.

llvm-svn: 289165

7 years agoModernize the Args access pattern in a few more commands.
Zachary Turner [Fri, 9 Dec 2016 01:08:29 +0000 (01:08 +0000)]
Modernize the Args access pattern in a few more commands.

llvm-svn: 289164

7 years ago[LCG] Minor cleanup to the LCG walk over a function, NFC.
Chandler Carruth [Fri, 9 Dec 2016 00:46:44 +0000 (00:46 +0000)]
[LCG] Minor cleanup to the LCG walk over a function, NFC.

This just hoists the check for declarations up a layer which allows
various sets used in the walk to be smaller. Also moves the relevant
comments to match, and catches a few other cleanups in this code.

llvm-svn: 289163

7 years agoMake WholeProgramDevirt understand ConstStruct vtables.
Peter Collingbourne [Fri, 9 Dec 2016 00:33:27 +0000 (00:33 +0000)]
Make WholeProgramDevirt understand ConstStruct vtables.

Based on a patch by LemonBoy!

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

llvm-svn: 289162

7 years ago[ObjectYAML] Support for DWARF debug_aranges
Chris Bieneman [Fri, 9 Dec 2016 00:26:44 +0000 (00:26 +0000)]
[ObjectYAML] Support for DWARF debug_aranges

This patch adds support for round tripping DWARF debug_aranges in and out of YAML.

llvm-svn: 289161

7 years ago[AST, ASTMatchers, Basic] Fix some Clang-tidy modernize and Include What You Use...
Eugene Zelenko [Fri, 9 Dec 2016 00:11:53 +0000 (00:11 +0000)]
[AST, ASTMatchers, Basic] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).

llvm-svn: 289160

7 years ago[DOXYGEN] Improved doxygen comments for xmmintrin.h intrinsics.
Ekaterina Romanova [Thu, 8 Dec 2016 23:58:39 +0000 (23:58 +0000)]
[DOXYGEN] Improved doxygen comments for xmmintrin.h intrinsics.

Tagged parameter names with \a doxygen command to display parameters in italics.
Formatted comments to fit into 80 chars.

llvm-svn: 289159

7 years agoFix PR27374 - Remove the implicit reduced-arity-extension in tuple.
Eric Fiselier [Thu, 8 Dec 2016 23:57:08 +0000 (23:57 +0000)]
Fix PR27374 - Remove the implicit reduced-arity-extension in tuple.

This patch removes libc++'s tuple extension which allowed it to be
constructed from fewer initializers than elements; with the remaining
elements being default constructed. However the implicit version of
this extension breaks conforming code. For example:

    int fun(std::string);
    int fun(std::tuple<std::string, int>);
    int x = fun("hello"); // ambigious

Because existing code may already depend on this extension it can be re-enabled
by defining _LIBCPP_ENABLE_TUPLE_IMPLICIT_REDUCED_ARITY_EXTENSION.

Note that the explicit version of this extension is still supported,
although it's somewhat less useful than the implicit one.

llvm-svn: 289158

7 years ago[InstCombine] add tests for umin+icmp; NFC
Sanjay Patel [Thu, 8 Dec 2016 23:44:58 +0000 (23:44 +0000)]
[InstCombine] add tests for umin+icmp; NFC

llvm-svn: 289157

7 years ago[InstCombine] add tests for umax+icmp; NFC
Sanjay Patel [Thu, 8 Dec 2016 23:36:57 +0000 (23:36 +0000)]
[InstCombine] add tests for umax+icmp; NFC

llvm-svn: 289156

7 years agoClean up the new TestInterruptThreadNames test a bit.
Jason Molenda [Thu, 8 Dec 2016 23:34:56 +0000 (23:34 +0000)]
Clean up the new TestInterruptThreadNames test a bit.

llvm-svn: 289155

7 years ago[DOXYGEN] Improved doxygen comments.
Ekaterina Romanova [Thu, 8 Dec 2016 23:32:07 +0000 (23:32 +0000)]
[DOXYGEN] Improved doxygen comments.

Improved doxygen comments for fxsrintrin.h and mmintrin.h intrinsics by taagging parameter names with \a doxygen command to display parameters in italics.

Formatted comments to fit into 80 chars.

llvm-svn: 289154

7 years ago[InstSimplify] Add "X / 1.0" to SimplifyFDivInst.
Zia Ansari [Thu, 8 Dec 2016 23:27:40 +0000 (23:27 +0000)]
[InstSimplify] Add "X / 1.0" to SimplifyFDivInst.

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

llvm-svn: 289153

7 years ago[ELF] Allow output section data commands to take expressions
Meador Inge [Thu, 8 Dec 2016 23:21:30 +0000 (23:21 +0000)]
[ELF] Allow output section data commands to take expressions

The current implementation of the output section data store commands
can only handle integer literals, but it should really handle arbitrary
expressions [1].  This commit fixes that.

[1] https://sourceware.org/binutils/docs-2.27/ld/Output-Section-Data.html#Output-Section-Data

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

llvm-svn: 289152

7 years ago[InstCombine] add tests for smax+icmp; NFC
Sanjay Patel [Thu, 8 Dec 2016 23:16:06 +0000 (23:16 +0000)]
[InstCombine] add tests for smax+icmp; NFC

llvm-svn: 289151

7 years agoGlobalISel: fall back gracefully for debug intrinsics.
Tim Northover [Thu, 8 Dec 2016 22:44:13 +0000 (22:44 +0000)]
GlobalISel: fall back gracefully for debug intrinsics.

Supporting them properly is a reasonably complex chunk of work, so to allow bot
testing before then we should at least be able to fall back to DAG ISel.

llvm-svn: 289150

7 years agoGlobalISel: factor overflow handling into separate function. NFC.
Tim Northover [Thu, 8 Dec 2016 22:44:00 +0000 (22:44 +0000)]
GlobalISel: factor overflow handling into separate function. NFC.

llvm-svn: 289149

7 years agoSplit linkerscript.s into small test files.
Rui Ueyama [Thu, 8 Dec 2016 22:36:12 +0000 (22:36 +0000)]
Split linkerscript.s into small test files.

linkerscript.s is the first test file for linker script, and at the moment
it contains all tests for linker scripts. Now that test file doesn't make
sense.

linkerscript2.s was just badly named. Renamed searchdir.s.

llvm-svn: 289148

7 years ago[SCCP] Make sure SCCP and ConstantFolding agree on undef >> a.
Davide Italiano [Thu, 8 Dec 2016 22:28:53 +0000 (22:28 +0000)]
[SCCP] Make sure SCCP and ConstantFolding agree on undef >> a.

Currently SCCP folds the value to -1, while ConstantProp folds to
0. This changes SCCP to do what ConstantFolding does.

llvm-svn: 289147

7 years agoPrint a warning message if ENTRY() symbol is not found.
Rui Ueyama [Thu, 8 Dec 2016 22:26:31 +0000 (22:26 +0000)]
Print a warning message if ENTRY() symbol is not found.

llvm-svn: 289146

7 years ago[sanitizer] Add workaround for empty strings
Vitaly Buka [Thu, 8 Dec 2016 22:26:03 +0000 (22:26 +0000)]
[sanitizer] Add workaround for empty strings

Summary: I see crashes on this check when some reports are being generated.

Reviewers: eugenis

Subscribers: kubabrecka, llvm-commits

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

llvm-svn: 289145

7 years ago[sanitizers] lsan+sancov doesn't need ubsanrt (multi def error)
Mike Aizatsky [Thu, 8 Dec 2016 22:25:01 +0000 (22:25 +0000)]
[sanitizers] lsan+sancov doesn't need ubsanrt (multi def error)

Reviewers: eugenis

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

llvm-svn: 289144

7 years ago[mips] Make the test case more specific and provide OS component of a triple. NFC
Simon Atanasyan [Thu, 8 Dec 2016 22:10:52 +0000 (22:10 +0000)]
[mips] Make the test case more specific and provide OS component of a triple. NFC

llvm-svn: 289117

7 years ago[DOXYGEN] Improved doxygen comments for emmintrin.h intrinsics.
Ekaterina Romanova [Thu, 8 Dec 2016 22:10:51 +0000 (22:10 +0000)]
[DOXYGEN] Improved doxygen comments for emmintrin.h intrinsics.

Tagged parameter names with \a doxygen command to display parameters in italics.
Formatted comments to fit into 80 chars.

llvm-svn: 289116

7 years ago[mips] Change instruction s/daddiu/addiu/ since O32 prohibits the use of 64-bit GPRs...
Simon Atanasyan [Thu, 8 Dec 2016 22:10:48 +0000 (22:10 +0000)]
[mips] Change instruction s/daddiu/addiu/ since O32 prohibits the use of 64-bit GPRs. NFC

llvm-svn: 289115

7 years ago[mips] Change gnueabi to gnu in the triple because EABI has been removed recently...
Simon Atanasyan [Thu, 8 Dec 2016 22:10:44 +0000 (22:10 +0000)]
[mips] Change gnueabi to gnu in the triple because EABI has been removed recently. NFC

llvm-svn: 289114

7 years ago[mips] Remove N32 Android test because Android does not support N32 ABI. NFC
Simon Atanasyan [Thu, 8 Dec 2016 22:10:38 +0000 (22:10 +0000)]
[mips] Remove N32 Android test because Android does not support N32 ABI. NFC

llvm-svn: 289113

7 years agoFix -Wunused-private-field.
Rui Ueyama [Thu, 8 Dec 2016 21:49:18 +0000 (21:49 +0000)]
Fix -Wunused-private-field.

llvm-svn: 289112

7 years ago[libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible loss...
Stephan T. Lavavej [Thu, 8 Dec 2016 21:38:57 +0000 (21:38 +0000)]
[libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible loss of data", part 7/7.

test/std/input.output/iostream.format/input.streams/istream.unformatted/get.pass.cpp
Add static_cast<char> because basic_istream::get() returns int_type (N4606 27.7.2.3 [istream.unformatted]/4).

test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/minus1.pass.cpp
Add static_cast<char> because toupper() returns int (C11 7.4.2.2/1).

test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/assign_t.pass.cpp
This test is intentionally writing doubles to ostream_iterator<int>.
It's silencing -Wliteral-conversion for Clang, so I'm adding C4244 silencing for MSVC.

test/std/language.support/support.limits/limits/numeric.limits.members/infinity.pass.cpp
Given `extern float zero;`, the expression `1./zero` has type double, which emits a truncation warning
when being passed to test<float>() taking float. The fix is to say `1.f/zero` which has type float.

test/std/numerics/complex.number/cmplx.over/arg.pass.cpp
test/std/numerics/complex.number/cmplx.over/norm.pass.cpp
These tests were constructing std::complex<double>(x, 0), emitting truncation warnings when x is long long.
Saying static_cast<double>(x) avoids this.

test/std/numerics/rand/rand.eng/rand.eng.lcong/seed_result_type.pass.cpp
This was using `int s` to construct and seed a linear_congruential_engine<T, stuff>, where T is
unsigned short/unsigned int/unsigned long/unsigned long long. That emits a truncation warning in the
unsigned short case. Because the range [0, 20) is tiny and we aren't doing anything else with the index,
we can just iterate with `T s`.

test/std/re/re.traits/value.pass.cpp
regex_traits<wchar_t>::value()'s first parameter is wchar_t (N4606 28.7 [re.traits]/13). This loop is
using int to iterate through ['g', 0xFFFF), emitting a truncation warning from int to wchar_t
(which is 16-bit for some of us). Because the bound is exclusive, we can just iterate with wchar_t.

test/std/strings/basic.string/string.cons/size_char_alloc.pass.cpp
This test is a little strange. It's trying to verify that basic_string's (InIt, InIt) range constructor
isn't confused by "N copies of C" when N and C have the same integral type. To do this, it was
testing (100, 65), but that eventually emits truncation warnings from int to char. There's a simple way
to avoid this - passing (static_cast<char>(100), static_cast<char>(65)) also exercises the disambiguation.
(And 100 is representable even when char has a signed range.)

test/std/strings/string.view/string.view.hash/string_view.pass.cpp
Add static_cast<char_type> because `'0' + i` has type int.

test/std/utilities/function.objects/bind/func.bind/func.bind.bind/nested.pass.cpp
What's more horrible than nested bind()? pow() overloads! This operator()(T a, T b) was assuming that
std::pow(a, b) can be returned as T. (In this case, T is int.) However, N4606 26.9.1 [cmath.syn]/2
says that pow(int, int) returns double, so this was truncating double to int.
Adding static_cast<T> silences this.

test/std/utilities/function.objects/unord.hash/integral.pass.cpp
This was iterating `for (int i = 0; i <= 5; ++i)` and constructing `T t(i);` but that's truncating
when T is short. (And super truncating when T is bool.) Adding static_cast<T> silences this.

test/std/utilities/utility/exchange/exchange.pass.cpp
First, this was exchanging 67.2 into an int, but that's inherently truncating.
Changing this to static_cast<short>(67) avoids the truncation while preserving the
"what if T and U are different" test coverage.
Second, this was exchanging {} with the explicit type float into an int, and that's also
inherently truncating. Specifying short is just as good.

test/std/utilities/utility/pairs/pairs.spec/make_pair.pass.cpp
Add static_cast<short>. Note that this affects template argument deduction for make_pair(),
better fulfilling the test's intent. For example, this was saying
`typedef std::pair<int, short> P1; P1 p1 = std::make_pair(3, 4);` but that was asking
make_pair() to return pair<int, int>, which was then being converted to pair<int, short>.
(pair's converting constructors are tested elsewhere.)
Now, std::make_pair(3, static_cast<short>(4)) actually returns pair<int, short>.
(There's still a conversion from pair<nullptr_t, short> to pair<unique_ptr<int>, short>.)

Fixes D27544.

llvm-svn: 289111

7 years ago[libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible loss...
Stephan T. Lavavej [Thu, 8 Dec 2016 21:38:44 +0000 (21:38 +0000)]
[libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible loss of data", part 6/7.

test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp
(Affects 64-bit architectures.) Include <cstddef> so we can take/return std::ptrdiff_t
(instead of int) in random_shuffle()'s RNG. (C++14 D.12 [depr.alg.random.shuffle]/2 says that
difference_type is used, and we're shuffling a plain array.)

test/std/algorithms/alg.sorting/alg.sort/sort/sort.pass.cpp
test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort.pass.cpp
(Affects 64-bit architectures.) Include <iterator> because we're already using iterator_traits.
Then, store the result of subtracting two RanIts as difference_type instead of long
(which truncates on LLP64 architectures like MSVC x64).

test/std/containers/sequences/forwardlist/forwardlist.ops/splice_after_flist.pass.cpp
test/std/containers/sequences/forwardlist/forwardlist.ops/splice_after_one.pass.cpp
(Affects 64-bit architectures.) Include <cstddef> so we can store the result of
subtracting two pointers as std::ptrdiff_t (instead of int).

test/std/input.output/iostream.format/input.streams/istream.unformatted/ignore_0xff.pass.cpp
(Affects 32-bit architectures.) Sometimes, size_t is too small. That's the case here,
where tellg() returns pos_type (N4606 27.7.2.3 [istream.unformatted]/39). Implementations can
have 64-bit pos_type (to handle large files) even when they have 32-bit size_t.

Fixes D27543.

llvm-svn: 289110

7 years ago[libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible loss...
Stephan T. Lavavej [Thu, 8 Dec 2016 21:38:32 +0000 (21:38 +0000)]
[libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible loss of data", part 5/7.

Instead of storing double in double and then truncating to int, store int in long
and then widen to long long. This preserves test coverage (as these tests are
interested in various tuple conversions) while avoiding truncation warnings.

test/std/utilities/tuple/tuple.tuple/tuple.cnstr/const_pair.pass.cpp
Since we aren't physically truncating anymore, t1 is equal to p0.

test/std/utilities/tuple/tuple.tuple/tuple.cnstr/convert_copy.pass.cpp
One edit is different from the usual pattern. Previously, we were storing
double in double and then converting to A, which has an implicitly converting
constructor from int. Now, we're storing int in int and then converting to A,
avoiding the truncation.

Fixes D27542.

llvm-svn: 289109

7 years ago[libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible loss...
Stephan T. Lavavej [Thu, 8 Dec 2016 21:38:23 +0000 (21:38 +0000)]
[libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible loss of data", part 4/7.

Change char to long and remove some char casts. This preserves test coverage for tuple's
heterogeneous comparisons, while avoiding int-to-char truncation warnings.

Fixes D27541.

llvm-svn: 289108

7 years ago[libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible loss...
Stephan T. Lavavej [Thu, 8 Dec 2016 21:38:14 +0000 (21:38 +0000)]
[libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible loss of data", part 3/7.

Add static_cast<short> when constructing pair<Whatever, short> from (Something, int).

Fixes D27540.

llvm-svn: 289107

7 years ago[libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible loss...
Stephan T. Lavavej [Thu, 8 Dec 2016 21:38:01 +0000 (21:38 +0000)]
[libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible loss of data", part 2/7.

These tests for some guy's transparent operator functors were needlessly truncating their
double results to int. Preserving the doubleness makes compilers happier. I'm following
existing practice by adding an "// exact in binary" comment when the result isn't a whole number.
(The changes from 6 to 6.0 and so forth are stylistic, not critical.)

Fixes D27539.

llvm-svn: 289106

7 years ago[libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible loss...
Stephan T. Lavavej [Thu, 8 Dec 2016 21:37:47 +0000 (21:37 +0000)]
[libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible loss of data", part 1/7.

Given `std::basic_streambuf<CharT>::int_type __c`, `std::basic_string<CharT> str_`,
and having checked `__c != std::basic_streambuf<CharT>::traits_type::eof()` (substituting typedefs
for clarity), the line `str_.push_back(__c);` is safe according to humans, but truncates according
to compilers. `str_.push_back(static_cast<CharT>(__c));` avoids that problem.

Fixes D27538.

llvm-svn: 289105

7 years agoCOFF: Use a string saver in Memory.h in Driver.
Rui Ueyama [Thu, 8 Dec 2016 21:27:09 +0000 (21:27 +0000)]
COFF: Use a string saver in Memory.h in Driver.

llvm-svn: 289104

7 years ago[DebugInfo] Relax test case for long double constants.
David Gross [Thu, 8 Dec 2016 21:15:17 +0000 (21:15 +0000)]
[DebugInfo] Relax test case for long double constants.

Summary:
D27549 (partial fix for PR26619) emits a constant value in the debug
metadata for a floating-point static const that does not exceed 64
bits in size.  The regression test accompanying that fix assumes that
a long double exceeds 64 bits in size and hence does not get a
constant value in the debug metadata.  However, for some targets --
such as "--target=hexagon-unknown-elf" -- a long double does not
exceed 64 bits in size, and hence the test fails.

As a temporary fix, modify the regression test to no longer inspect
the debug metadata for a long double.

Reviewers: cfe-commits, probinson

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

llvm-svn: 289103

7 years agoRemove unnecessary `llvm::`.
Rui Ueyama [Thu, 8 Dec 2016 20:50:47 +0000 (20:50 +0000)]
Remove unnecessary `llvm::`.

llvm-svn: 289102

7 years agoDon't emit .seh_handler directives for any cleanup funclets
Reid Kleckner [Thu, 8 Dec 2016 20:38:46 +0000 (20:38 +0000)]
Don't emit .seh_handler directives for any cleanup funclets

We were falsely claiming that we had an LSDA for the relevant EH
personality before this change, which could lead to the EH machinery
interpreting random adjacent data as an LSDA.

Fixes PR31317

This change is safe because cleanups can't contain exception handlers
today. We do these things to maintain that invariant:
- C++ destructors are naturally out-of-line
- __finally blocks are outlined in clang
- LLVM's inliner will not inline EH constructs into cleanups

llvm-svn: 289101

7 years agoFixed a crasher that has been borking out heap for a long time.
Greg Clayton [Thu, 8 Dec 2016 20:38:19 +0000 (20:38 +0000)]
Fixed a crasher that has been borking out heap for a long time.

ThreadList had an assignment operator that didn't lock the "rhs" thread list object. This means a thread list can be mutated while it is being copied.

The copy constructor calls the assignment operator as well. So this fixes the unsafe threaded access to ThreadList which we believe is responsible for a lot of crashes.

<rdar://problem/28075793>

llvm-svn: 289100

7 years ago[RDF] Fix incorrect lane mask calculation
Krzysztof Parzyszek [Thu, 8 Dec 2016 20:33:45 +0000 (20:33 +0000)]
[RDF] Fix incorrect lane mask calculation

This was exposed by some code that used more than one level of sub-
registers. There is no testcase, because there is no such code in the
Hexagon backend.

llvm-svn: 289099

7 years ago[InstSimplify] add fdiv x/1.0 test and update checks; NFC
Sanjay Patel [Thu, 8 Dec 2016 20:23:56 +0000 (20:23 +0000)]
[InstSimplify] add fdiv x/1.0 test and update checks; NFC

llvm-svn: 289098

7 years agoCOFF: Use make() to create a new file object in createFile.
Rui Ueyama [Thu, 8 Dec 2016 20:20:22 +0000 (20:20 +0000)]
COFF: Use make() to create a new file object in createFile.

llvm-svn: 289097

7 years agoAMDGPU: Make f16 ConstantFP legal
Matt Arsenault [Thu, 8 Dec 2016 20:14:46 +0000 (20:14 +0000)]
AMDGPU: Make f16 ConstantFP legal

Not having this legal led to combine failures, resulting
in dumb things like bitcasts of constants not being folded
away.

The only reason I'm leaving the v_mov_b32 hack that f32
already uses is to avoid madak formation test regressions.
PeepholeOptimizer has an ordering issue where the immediate
fold attempt is into the sgpr->vgpr copy instead of the actual
use. Running it twice avoids that problem.

llvm-svn: 289096

7 years ago[AMDGPU] Fix number of reserved SGPRs on CI to reflect flat scratch use
Stanislav Mekhanoshin [Thu, 8 Dec 2016 20:07:23 +0000 (20:07 +0000)]
[AMDGPU] Fix number of reserved SGPRs on CI to reflect flat scratch use

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

llvm-svn: 289095

7 years ago[DebugInfo] Add support for __fp16, float, and double constants.
David Gross [Thu, 8 Dec 2016 20:02:46 +0000 (20:02 +0000)]
[DebugInfo] Add support for __fp16, float, and double constants.

Summary:
Partial fix for PR26619.

Prior to this change, a DIGlobalVariable corresponding to a static
const was marked with an expression corresponding to its constant
value only if it is of integral type.  With this change, we now do the
same if it is of __fp16, float, or double type (that is,
floating-point types that do not exceed 64 bits in size, and hence are
supported easily by the existing LLVM machinery for creating constant
expressions in debug info).

Reviewers: llvm-commits

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

llvm-svn: 289094

7 years agoAMDGPU: Fix commuting v_sub_u16
Matt Arsenault [Thu, 8 Dec 2016 19:52:38 +0000 (19:52 +0000)]
AMDGPU: Fix commuting v_sub_u16

The correct commutable opcode was set to itself, so this
was simply swapping the operands to commute instead of also
changing the opcode to v_subrev_u16.

llvm-svn: 289093

7 years ago[AMDGPU] Add amdgpu-unify-metadata pass
Stanislav Mekhanoshin [Thu, 8 Dec 2016 19:46:04 +0000 (19:46 +0000)]
[AMDGPU] Add amdgpu-unify-metadata pass

Multiple metadata values for records such as opencl.ocl.version, llvm.ident
and similar are created after linking several modules. For some of them, notably
opencl.ocl.version, this creates semantic problem because we cannot tell which
version of OpenCL the composite module conforms.

Moreover, such repetitions of identical values often create a huge list of
unneeded metadata, which grows bitcode size both in memory and stored on disk.
It can go up to several Mb when linked against our OpenCL library. Lastly, such
long lists obscure reading of dumped IR.

The pass unifies metadata after linking.

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

llvm-svn: 289092

7 years ago[CUDA] Ignore implicit target attributes during function template instantiation.
Artem Belevich [Thu, 8 Dec 2016 19:38:13 +0000 (19:38 +0000)]
[CUDA] Ignore implicit target attributes during function template instantiation.

Some functions and templates are treated as __host__ __device__ even
when they don't have explicitly specified target attributes.
What's worse, this treatment may change depending on command line
options (-fno-cuda-host-device-constexpr) or
#pragma clang force_cuda_host_device.

Combined with strict checking for matching function target that comes
with D25809(r288962), it makes it hard to write code which would
explicitly instantiate or specialize some functions regardless of
pragmas or command line options in effect.

This patch changes the way we match target attributes of base template
vs attributes used in explicit instantiation or specialization so that
only explicitly specified attributes are considered. This makes base
template selection behave consistently regardless of pragma of command
line options that may affect CUDA target.

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

llvm-svn: 289091

7 years ago[asan] Add test which detects bugs undetectable before r288563
Vitaly Buka [Thu, 8 Dec 2016 19:13:13 +0000 (19:13 +0000)]
[asan] Add test which detects bugs undetectable before r288563

Reviewers: kcc, eugenis

Subscribers: llvm-commits, kubabrecka

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

llvm-svn: 289090

7 years agoStart using make() in COFF (with a smaller change.)
Rui Ueyama [Thu, 8 Dec 2016 19:10:28 +0000 (19:10 +0000)]
Start using make() in COFF (with a smaller change.)

llvm-svn: 289089

7 years ago[sanitizer] Do not use the alignment-rounded-up size when using the secondary
Kostya Kortchinsky [Thu, 8 Dec 2016 19:05:46 +0000 (19:05 +0000)]
[sanitizer] Do not use the alignment-rounded-up size when using the secondary

Summary:
The combined allocator rounds up the requested size with regard to the
alignment, which makes sense when being serviced by the primary as it comes
with alignment guarantees, but not with the secondary. For the rare case of
large alignments, it wastes memory, and entices unnecessarily large fields for
the Scudo header. With this patch, we pass the non-alignement-rounded-up size
to the secondary, and adapt the Scudo code for this change.

Reviewers: alekseyshl, kcc

Subscribers: llvm-commits, kubabrecka

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

llvm-svn: 289088

7 years agoIR, X86: Understand !absolute_symbol metadata on global variables.
Peter Collingbourne [Thu, 8 Dec 2016 19:01:00 +0000 (19:01 +0000)]
IR, X86: Understand !absolute_symbol metadata on global variables.

Summary:
Attaching !absolute_symbol to a global variable does two things:
1) Marks it as an absolute symbol reference.
2) Specifies the value range of that symbol's address.
Teach the X86 backend to allow absolute symbols to appear in place of
immediates by extending the relocImm and mov64imm32 matchers. Start using
relocImm in more places where it is legal.

As previously proposed on llvm-dev:
http://lists.llvm.org/pipermail/llvm-dev/2016-October/105800.html

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

llvm-svn: 289087

7 years agoRevert r289084: Start using make() in COFF.
Rui Ueyama [Thu, 8 Dec 2016 18:49:04 +0000 (18:49 +0000)]
Revert r289084: Start using make() in COFF.

This reverts commit r289084 to appease buildbots.

llvm-svn: 289086

7 years agoStart using make() in COFF.
Rui Ueyama [Thu, 8 Dec 2016 18:31:18 +0000 (18:31 +0000)]
Start using make() in COFF.

We don't want ELF and COFF to diverge too much.

llvm-svn: 289085

7 years agoMove Memory.{h,cpp} to lld/Support so that we can use them from COFF.
Rui Ueyama [Thu, 8 Dec 2016 18:31:13 +0000 (18:31 +0000)]
Move Memory.{h,cpp} to lld/Support so that we can use them from COFF.

llvm-svn: 289084

7 years ago[DOXYGEN] Improved doxygen comments.
Ekaterina Romanova [Thu, 8 Dec 2016 17:57:23 +0000 (17:57 +0000)]
[DOXYGEN] Improved doxygen comments.

Improved doxygen comments for __wmmintrin_pclmul.h and ammintrin.h intrinsics by taagging parameter names with \a doxygen command to display parameters in italics.

Formatted comments to fit into 80 chars.

llvm-svn: 289083

7 years agoChange the implementation of --dynamic-list to use linker script parsing.
Rafael Espindola [Thu, 8 Dec 2016 17:54:26 +0000 (17:54 +0000)]
Change the implementation of --dynamic-list to use linker script parsing.

The feature is documented as
-----------------------------
The format of the dynamic list is the same as the version node
without scope and node name.  See *note VERSION:: for more
information.
--------------------------------

And indeed qt uses a dynamic list with an 'extern "C++"' in it. With
this patch we support that

The change to gc-sections-shared makes us match bfd. Just because we
kept bar doesn't mean it has to be in the dynamic symbol table.

The changes to invalid-dynamic-list.test and reproduce.s are because
of the new parser.

The changes to version-script.s are the only case where we change
behavior with regards to bfd, but I would like to see a mix of
--version-script and --dynamic-list used in the wild before
complicating the code.

llvm-svn: 289082

7 years agoUse `make` to simplify. NFC.
Rui Ueyama [Thu, 8 Dec 2016 17:48:52 +0000 (17:48 +0000)]
Use `make` to simplify. NFC.

llvm-svn: 289081

7 years ago[ObjectYAML] Remove DWARF from class names
Chris Bieneman [Thu, 8 Dec 2016 17:46:57 +0000 (17:46 +0000)]
[ObjectYAML] Remove DWARF from class names

Since all the DWARF classes are in a DWARFYAML namespace having every class start with DWARF seems like a bit of overkill.

llvm-svn: 289080

7 years agoUse make to instantiate Target and LinkerScript. NFC.
Rui Ueyama [Thu, 8 Dec 2016 17:44:39 +0000 (17:44 +0000)]
Use make to instantiate Target and LinkerScript. NFC.

llvm-svn: 289079

7 years agoSplit LinkerDriver::link. NFC.
Rui Ueyama [Thu, 8 Dec 2016 17:44:37 +0000 (17:44 +0000)]
Split LinkerDriver::link. NFC.

llvm-svn: 289078

7 years agoRemove a special handling of AMDGPU entry points.
Rui Ueyama [Thu, 8 Dec 2016 17:32:58 +0000 (17:32 +0000)]
Remove a special handling of AMDGPU entry points.

This is the last peculiar semantics left in the linker. If you want to
always set an entry point to 0, you can pass `-e 0` to the linker.

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

llvm-svn: 289077

7 years ago[AMDGPU] Scalarization of global uniform loads.
Alexander Timofeev [Thu, 8 Dec 2016 17:28:47 +0000 (17:28 +0000)]
[AMDGPU] Scalarization of global uniform loads.

Summary:
LC can currently select scalar load for uniform memory access
basing on readonly memory address space only. This restriction
originated from the fact that in HW prior to VI vector and scalar caches
are not coherent. With MemoryDependenceAnalysis we can check that the
memory location corresponding to the memory operand of the LOAD is not
clobbered along the all paths from the function entry.

Reviewers: rampitec, tstellarAMD, arsenm

Subscribers: wdng, arsenm, nhaehnle

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

llvm-svn: 289076

7 years agoFixing test to work when the compiler defaults to a different C++ standard version.
Douglas Yung [Thu, 8 Dec 2016 17:27:20 +0000 (17:27 +0000)]
Fixing test to work when the compiler defaults to a different C++ standard version.

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

llvm-svn: 289075

7 years agoAdd support for 'extern "C"'.
Rafael Espindola [Thu, 8 Dec 2016 17:26:53 +0000 (17:26 +0000)]
Add support for 'extern "C"'.

It is used by Qt.

llvm-svn: 289074

7 years agoConstantFolding: Don't crash when encountering vector GEP
Keno Fischer [Thu, 8 Dec 2016 17:22:35 +0000 (17:22 +0000)]
ConstantFolding: Don't crash when encountering vector GEP

ConstantFolding tried to cast one of the scalar indices to a vector
type. Instead, use the vector type only for the first index (which
is the only one allowed to be a vector) and use its scalar type
otherwise.

Fixes PR31250.

Reviewers: majnemer
Differential Revision: https://reviews.llvm.org/D27389

llvm-svn: 289073

7 years agoMake function names shorter. NFC.
Rui Ueyama [Thu, 8 Dec 2016 17:18:09 +0000 (17:18 +0000)]
Make function names shorter. NFC.

llvm-svn: 289072

7 years agoDo not use template where template is not needed.
Rui Ueyama [Thu, 8 Dec 2016 17:04:18 +0000 (17:04 +0000)]
Do not use template where template is not needed.

Compilers can inline and optimize this code in the same way as template.

llvm-svn: 289071

7 years agoFix ASAN buildbots by fixing a double free crash.
Greg Clayton [Thu, 8 Dec 2016 16:57:04 +0000 (16:57 +0000)]
Fix ASAN buildbots by fixing a double free crash.

The dwarfgen::Generator::StringPool was in a unique_ptr but it was owned by the Allocator member variable so it was being free twice.

llvm-svn: 289070

7 years agoMake this test more strict. NFC.
Rafael Espindola [Thu, 8 Dec 2016 16:51:56 +0000 (16:51 +0000)]
Make this test more strict. NFC.

llvm-svn: 289069

7 years ago[CodeCompletion][ObjC] Use a parameterized NSSet return type for
Alex Lorenz [Thu, 8 Dec 2016 16:49:05 +0000 (16:49 +0000)]
[CodeCompletion][ObjC] Use a parameterized NSSet return type for
keyPathsForValuesAffecting* KVO completion results

rdar://23791701

llvm-svn: 289068

7 years agoInline function called only once.
Rafael Espindola [Thu, 8 Dec 2016 16:26:20 +0000 (16:26 +0000)]
Inline function called only once.

llvm-svn: 289067

7 years agoHandle C++ names in anon scripts.
Rafael Espindola [Thu, 8 Dec 2016 16:20:29 +0000 (16:20 +0000)]
Handle C++ names in anon scripts.

llvm-svn: 289066

7 years agoInline two functions called only once. NFC.
Rafael Espindola [Thu, 8 Dec 2016 16:02:48 +0000 (16:02 +0000)]
Inline two functions called only once. NFC.

llvm-svn: 289065

7 years agoAdd two helper functions. NFC.
Rafael Espindola [Thu, 8 Dec 2016 15:56:33 +0000 (15:56 +0000)]
Add two helper functions. NFC.

llvm-svn: 289064