platform/upstream/llvm.git
6 years ago[ELF] - Report valid binary filename when reporting error.
George Rimar [Mon, 5 Feb 2018 09:47:24 +0000 (09:47 +0000)]
[ELF] - Report valid binary filename when reporting error.

We did not report valid filename for duplicate symbol error when
symbol came from binary input file.
Patch fixes it.

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

llvm-svn: 324217

6 years agoRevert [SimplifyCFG] Relax restriction for folding unconditional branches
Serguei Katkov [Mon, 5 Feb 2018 09:05:43 +0000 (09:05 +0000)]
Revert [SimplifyCFG] Relax restriction for folding unconditional branches

The patch causes the failure of the test
compiler-rt/test/profile/Linux/counter_promo_nest.c

To unblock buildbot, revert the patch while investigation is in progress.

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

llvm-svn: 324214

6 years ago[X86] Add isel patterns for selecting masked SUBV_BROADCAST with bitcasts. Remove...
Craig Topper [Mon, 5 Feb 2018 08:37:37 +0000 (08:37 +0000)]
[X86] Add isel patterns for selecting masked SUBV_BROADCAST with bitcasts. Remove combineBitcastForMaskedOp.

Add test cases for the merge masked versions to make sure we have all those covered.

llvm-svn: 324210

6 years ago[NFC] Add tests for PR35743
Max Kazantsev [Mon, 5 Feb 2018 08:09:49 +0000 (08:09 +0000)]
[NFC] Add tests for PR35743

llvm-svn: 324209

6 years ago[SimplifyCFG] Relax restriction for folding unconditional branches
Serguei Katkov [Mon, 5 Feb 2018 07:56:43 +0000 (07:56 +0000)]
[SimplifyCFG] Relax restriction for folding unconditional branches

The commit rL308422 introduces a restriction for folding unconditional
branches. Specifically if empty block with unconditional branch leads to
header of the loop then elimination of this basic block is prohibited.
However it seems this condition is redundantly strict.
If elimination of this basic block does not introduce more back edges
then we can eliminate this block.

The patch implements this relax of restriction.

Reviewers: efriedma, mcrosier, pacxx, hsung, davidxl
Reviewed By: pacxx
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D42691

llvm-svn: 324208

6 years ago[X86] Remove unused lambda. NFC
Craig Topper [Mon, 5 Feb 2018 06:56:33 +0000 (06:56 +0000)]
[X86] Remove unused lambda. NFC

llvm-svn: 324206

6 years ago[X86] Remove X86ISD::SHUF128 from combineBitcastForMaskedOp. Use isel patterns instead.
Craig Topper [Mon, 5 Feb 2018 06:00:23 +0000 (06:00 +0000)]
[X86] Remove X86ISD::SHUF128 from combineBitcastForMaskedOp. Use isel patterns instead.

We always created X86ISD::SHUF128 with a 64-bit element type so we can use isel patterns to detect a bitconvert to 32-bit to handle masking.

The test changes are because we also match the bitconvert even if there is no masking. This leads to unnecessary isel pattern, but it requires more multiclass hackery in tablegen to get rid of it.

llvm-svn: 324205

6 years agoRe-apply [SCEV] Fix isLoopEntryGuardedByCond usage
Serguei Katkov [Mon, 5 Feb 2018 05:49:47 +0000 (05:49 +0000)]
Re-apply [SCEV] Fix isLoopEntryGuardedByCond usage

ScalarEvolution::isKnownPredicate invokes isLoopEntryGuardedByCond without check
that SCEV is available at entry point of the loop. It is incorrect and fixed by patch.

To bugs additionally fixed:
assert is moved after the check whether loop is not a nullptr.
Usage of isLoopEntryGuardedByCond in ScalarEvolution::isImpliedCondOperandsViaNoOverflow
is guarded by isAvailableAtLoopEntry.

Reviewers: sanjoy, mkazantsev, anna, dorit, reames
Reviewed By: mkazantsev
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D42417

llvm-svn: 324204

6 years ago[demangler] return early if conditional expr parsing failed
Erik Pilkington [Mon, 5 Feb 2018 02:34:41 +0000 (02:34 +0000)]
[demangler] return early if conditional expr parsing failed

This should fix some bugs found by oss-fuzz.

llvm-svn: 324203

6 years ago[X86] Auto-generate full checks. NFC
Craig Topper [Sun, 4 Feb 2018 23:48:51 +0000 (23:48 +0000)]
[X86] Auto-generate full checks. NFC

llvm-svn: 324202

6 years agoRecommit rL323890: [AMDGPU] Add ds_fadd, ds_fmin, ds_fmax builtins functions
Daniil Fukalov [Sun, 4 Feb 2018 22:32:07 +0000 (22:32 +0000)]
Recommit rL323890: [AMDGPU] Add ds_fadd, ds_fmin, ds_fmax builtins functions

Fixed asserts in tests.

llvm-svn: 324201

6 years agoX86 Tests: Add shuffle that can be improved by widening elements. NFC
Zvi Rackover [Sun, 4 Feb 2018 19:31:14 +0000 (19:31 +0000)]
X86 Tests: Add shuffle that can be improved by widening elements. NFC

To be improved by D42044

llvm-svn: 324200

6 years ago[PartialInliner] Update test (NFC).
Florian Hahn [Sun, 4 Feb 2018 18:40:24 +0000 (18:40 +0000)]
[PartialInliner] Update test (NFC).

llvm-svn: 324199

6 years ago[InlineFunction] Set arg attrs even if there only are VarArg attrs.
Florian Hahn [Sun, 4 Feb 2018 18:27:47 +0000 (18:27 +0000)]
[InlineFunction] Set arg attrs even if there only are VarArg attrs.

When using the partial inliner, we might have attributes for forwarded
varargs, but the CodeExtractor does not create an empty argument
attribute set for regular arguments in that case, because it does not know
of the additional arguments. So in case we have attributes for VarArgs, we
also have to make sure we create (empty) attributes for all regular arguments.

This fixes PR36210.

llvm-svn: 324197

6 years ago[TableGen][AsmMatcherEmitter] Fix tied-constraint checking for InstAliases
Sander de Smalen [Sun, 4 Feb 2018 16:24:17 +0000 (16:24 +0000)]
[TableGen][AsmMatcherEmitter] Fix tied-constraint checking for InstAliases

Summary:
This is a bit of a reimplementation the work done in
https://reviews.llvm.org/D41446, since that patch only really works for
tied operands of instructions, not aliases.

Instead of checking the constraints based on the matched instruction's opcode,
this patch uses the match-info's convert function to check the operand
constraints for that specific instruction/alias.
This is based on the matched operands for the instruction, not the
resulting opcode of the MCInst.

This patch adds the following enum/table to the *GenAsmMatcher.inc file:
  enum {
    Tie0_1_1,
    Tie0_1_2,
    Tie0_1_5,
    ...
  };

  const char TiedAsmOperandTable[][3] = {
    /* Tie0_1_1 */ { 0, 1, 1 },
    /* Tie0_1_2 */ { 0, 1, 2 },
    /* Tie0_1_5 */ { 0, 1, 5 },
    ...
  };

And it is referenced directly in the ConversionTable, like this:
static const uint8_t ConversionTable[CVT_NUM_SIGNATURES][13] = {
  ...
  { CVT_95_addRegOperands, 1,
    CVT_95_addRegOperands, 2,
    CVT_Tied, Tie0_1_5,
    CVT_95_addRegOperands, 6, CVT_Done },
  ...

The Tie0_1_5 (and corresponding table) encodes that:
* Result operand 0 is the operand to copy (which is e.g. done when
  building up the operands to the MCInst in convertToMCInst())
* Asm operands 1 and 5 should be the same operands (which is checked
  in checkAsmTiedOperandConstraints()).

Reviewers: olista01, rengolin, fhahn, craig.topper, echristo, apazos, dsanders

Reviewed By: olista01

Subscribers: llvm-commits

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

llvm-svn: 324196

6 years ago[LV] Use Demanded Bits and ValueTracking for reduction type-shrinking
Chad Rosier [Sun, 4 Feb 2018 15:42:24 +0000 (15:42 +0000)]
[LV] Use Demanded Bits and ValueTracking for reduction type-shrinking

The type-shrinking logic in reduction detection, although narrow in scope, is
also rather ad-hoc, which has led to bugs (e.g., PR35734). This patch modifies
the approach to rely on the demanded bits and value tracking analyses, if
available. We currently perform type-shrinking separately for reductions and
other instructions in the loop. Long-term, we should probably think about
computing minimal bit widths in a more complete way for the loops we want to
vectorize.

PR35734
Differential Revision: https://reviews.llvm.org/D42309

llvm-svn: 324195

6 years agoFix initialization of array<const T, 0> with GCC.
Eric Fiselier [Sun, 4 Feb 2018 08:02:35 +0000 (08:02 +0000)]
Fix initialization of array<const T, 0> with GCC.

Previously, when handling zero-sized array of const objects we
used a const version of aligned_storage_t, which is not an array type.
However, GCC complains about initialization of the form: array<const T, 0> arr = {};

This patch fixes that bug by making the dummy object used to represent
the zero-sized array an array itself. This avoids GCC's complaints
about the uninitialized const member.

llvm-svn: 324194

6 years agoMark LWG 3014 as complete. No code changes needed
Eric Fiselier [Sun, 4 Feb 2018 07:37:09 +0000 (07:37 +0000)]
Mark LWG 3014 as complete. No code changes needed

llvm-svn: 324193

6 years agoImplement LWG 3014 - Fix more noexcept issues in filesystem.
Eric Fiselier [Sun, 4 Feb 2018 07:35:36 +0000 (07:35 +0000)]
Implement LWG 3014 - Fix more noexcept issues in filesystem.

This patch removes the noexcept declaration from filesystem
operations which require creating temporary paths or
creating a directory iterator. Either of these operations
can throw.

llvm-svn: 324192

6 years agoMark LWG 3013 as already complete. See r316941
Eric Fiselier [Sun, 4 Feb 2018 07:29:53 +0000 (07:29 +0000)]
Mark LWG 3013 as already complete. See r316941

llvm-svn: 324191

6 years agoRemove debug println from rec.dir.itr.increment test
Eric Fiselier [Sun, 4 Feb 2018 03:26:55 +0000 (03:26 +0000)]
Remove debug println from rec.dir.itr.increment test

llvm-svn: 324190

6 years agoImplement LWG2989: path's streaming operators allow everything under the sun.
Eric Fiselier [Sun, 4 Feb 2018 03:10:53 +0000 (03:10 +0000)]
Implement LWG2989: path's streaming operators allow everything under the sun.

Because path can be constructed from a ton of different types, including string
and wide strings, this caused it's streaming operators to suck up all sorts
of silly types via silly conversions. For example:

using namespace std::experimental::filesystem::v1;
std::wstring w(L"wide");
std::cout << w; // converts to path.

This patch tentatively adopts the resolution to LWG2989 and fixes the issue
by making the streaming operators friends of path.

llvm-svn: 324189

6 years agoMark issue 2851 as complete
Eric Fiselier [Sun, 4 Feb 2018 02:45:33 +0000 (02:45 +0000)]
Mark issue 2851 as complete

llvm-svn: 324188

6 years agoAddress LWG 2849 and fix missing failure condition in copy_file.
Eric Fiselier [Sun, 4 Feb 2018 02:43:32 +0000 (02:43 +0000)]
Address LWG 2849 and fix missing failure condition in copy_file.

Previously copy_file didn't handle the case where the input and
output were the same file.

llvm-svn: 324187

6 years agocorrect comment about C++03 assignment operators
Eric Fiselier [Sun, 4 Feb 2018 02:22:33 +0000 (02:22 +0000)]
correct comment about C++03 assignment operators

llvm-svn: 324186

6 years agoMake array<const T, 0> non-CopyAssignable and make swap and fill ill-formed.
Eric Fiselier [Sun, 4 Feb 2018 02:17:02 +0000 (02:17 +0000)]
Make array<const T, 0> non-CopyAssignable and make swap and fill ill-formed.

The standard isn't exactly clear how std::array should handle zero-sized arrays
with const element types. In particular W.R.T. copy assignment, swap, and fill.

This patch takes the position that those operations should be ill-formed,
and makes changes to libc++ to make it so.

This follows up on commit r324182.

llvm-svn: 324185

6 years ago[X86] Add DAG combine to turn (bitcast (and/or/xor (bitcast X), Y)) -> (and/or/xor...
Craig Topper [Sun, 4 Feb 2018 01:43:48 +0000 (01:43 +0000)]
[X86] Add DAG combine to turn (bitcast (and/or/xor (bitcast X), Y)) -> (and/or/xor X, (bitcast Y)) when casting between GPRs and mask operations.

This reduces the number of transitions between k-registers and GPRs, reducing the number of instructions.

There's still some room for improvement to remove more transitions, but this is a good start.

llvm-svn: 324184

6 years ago[X86] Remove unused function argument. NFC
Craig Topper [Sun, 4 Feb 2018 01:43:44 +0000 (01:43 +0000)]
[X86] Remove unused function argument. NFC

llvm-svn: 324183

6 years ago[libc++] Fix PR35491 - std::array of zero-size doesn't work with non-default construc...
Eric Fiselier [Sun, 4 Feb 2018 01:03:08 +0000 (01:03 +0000)]
[libc++] Fix PR35491 - std::array of zero-size doesn't work with non-default constructible types.

Summary:
This patch fixes llvm.org/PR35491 and LWG2157  (https://cplusplus.github.io/LWG/issue2157)

The fix attempts to maintain ABI compatibility by replacing the array with a instance of `aligned_storage`.

Reviewers: mclow.lists, EricWF

Reviewed By: EricWF

Subscribers: lichray, cfe-commits

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

llvm-svn: 324182

6 years ago[DAGCombiner] When folding fold (sext/zext (and/or/xor (sextload/zextload x), cst...
Craig Topper [Sat, 3 Feb 2018 23:00:31 +0000 (23:00 +0000)]
[DAGCombiner] When folding fold (sext/zext (and/or/xor (sextload/zextload x), cst)) -> (and/or/xor (sextload/zextload x), (sext/zext cst)) make sure we check the legality of the full extended load.

Summary:
If the load is already an extended load we should be using the memory VT for the legality check, not just the VT of the current extension.

I don't have a test case, just noticed it while investigating some load extension improvements.

Reviewers: RKSimon, spatel, niravd

Reviewed By: niravd

Subscribers: llvm-commits

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

llvm-svn: 324181

6 years ago[MIPS] Regenerate vector tests with update script
Simon Pilgrim [Sat, 3 Feb 2018 22:11:22 +0000 (22:11 +0000)]
[MIPS] Regenerate vector tests with update script

Hopefully help make this a lot more maintainable

llvm-svn: 324180

6 years ago[SelectionDAG] Don't use simple VT in generic shuffle code
Simon Pilgrim [Sat, 3 Feb 2018 21:34:42 +0000 (21:34 +0000)]
[SelectionDAG] Don't use simple VT in generic shuffle code

Better to assume that any value type may be commuted, not just MVTs.

No test case right now, but discovered while investigating possible shuffle combines.

llvm-svn: 324179

6 years ago[X86][SSE] Don't chain shuffles together in schedule tests
Simon Pilgrim [Sat, 3 Feb 2018 21:20:19 +0000 (21:20 +0000)]
[X86][SSE] Don't chain shuffles together in schedule tests

This is necessary to prevent the shuffles from being combined/simplified in an upcoming patch.

llvm-svn: 324178

6 years ago[X86] Remove and autoupgrade kand/kandn/kor/kxor/kxnor/knot intrinsics.
Craig Topper [Sat, 3 Feb 2018 20:18:25 +0000 (20:18 +0000)]
[X86] Remove and autoupgrade kand/kandn/kor/kxor/kxnor/knot intrinsics.

Clang already stopped using these a couple months ago.

The test cases aren't great as there is nothing forcing the operations to stay in k-registers so some of them moved back to scalar ops due to the bitcasts being moved around.

llvm-svn: 324177

6 years agoRemove unneeded -debug argument from new test
David Green [Sat, 3 Feb 2018 17:33:50 +0000 (17:33 +0000)]
Remove unneeded -debug argument from new test

llvm-svn: 324176

6 years ago[ORC] Rename NullResolver to NullLegacyResolver.
Lang Hames [Sat, 3 Feb 2018 16:52:48 +0000 (16:52 +0000)]
[ORC] Rename NullResolver to NullLegacyResolver.

This resolver conforms to the LegacyJITSymbolResolver interface, and will be
replaced with a null-returning resolver conforming to the newer
orc::SymbolResolver interface in the near future. This patch renames the class
to avoid a clash.

llvm-svn: 324175

6 years ago[InstCombine] Allow common type conversions to i8/i16/i32
David Green [Sat, 3 Feb 2018 16:51:03 +0000 (16:51 +0000)]
[InstCombine] Allow common type conversions to i8/i16/i32

This, in instcombine, allows conversions to i8/i16/i32 (very
common cases) even if the resulting type is not legal according
to the data layout. This can often open up extra combine
opportunities.

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

llvm-svn: 324174

6 years agoRecommit rL323952: [DebugInfo] Enable debug information for C99 VLA types.
Sander de Smalen [Sat, 3 Feb 2018 13:55:59 +0000 (13:55 +0000)]
Recommit rL323952: [DebugInfo] Enable debug information for C99 VLA types.

Fixed build issue when building with g++-4.8 (specialization after instantiation).

llvm-svn: 324173

6 years ago[RISCV] Update two RISCV codegen tests after rL323991
Alex Bradbury [Sat, 3 Feb 2018 13:02:30 +0000 (13:02 +0000)]
[RISCV] Update two RISCV codegen tests after rL323991

From the discussion in D41835 it looks possible the change will be backed out,
but for now let's fix the RISCV tests.

llvm-svn: 324172

6 years agoFix MSVC signed/unsigned comparison warning. NFCI.
Simon Pilgrim [Sat, 3 Feb 2018 12:38:56 +0000 (12:38 +0000)]
Fix MSVC signed/unsigned comparison warning. NFCI.

llvm-svn: 324171

6 years ago[RISCV] Create a LinuxTargetInfo when targeting Linux
Alex Bradbury [Sat, 3 Feb 2018 11:56:11 +0000 (11:56 +0000)]
[RISCV] Create a LinuxTargetInfo when targeting Linux

Previously, RISCV32TargetInfo or RISCV64TargetInfo were created
unconditionally. Use LinuxTargetInfo<RISCV??TargetInfo> to ensure that the
proper OS-specific defines are present.

This patch only adds logic to instantiate LinuxTargetInfo and leaves a TODO,
as I'm reluctant to add logic for other targets (e.g. FreeBSD, RTEMS) until
I've produced and tested at least one binary for that OS+target combo.

Thanks to @mgrang to reporting the issue.

llvm-svn: 324170

6 years ago[ScopBuilder] Make -polly-stmt-granularity=scalar-indep the default.
Michael Kruse [Sat, 3 Feb 2018 06:59:47 +0000 (06:59 +0000)]
[ScopBuilder] Make -polly-stmt-granularity=scalar-indep the default.

Splitting basic blocks into multiple statements if there are now
additional scalar dependencies gives more freedom to the scheduler, but
more statements also means higher compile-time complexity. Switch to
finer statement granularity, the additional compile time should be
limited by the number of operations quota.

The regression tests are written for the -polly-stmt-granularity=bb
setting, therefore we add that flag to those tests that break with the
new default. Some of the tests only fail because the statements are
named differently due to a basic block resulting in multiple statements,
but which are removed during simplification of statements without
side-effects. Previous commits tried to reduce this effect, but it is
not completely avoidable.

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

llvm-svn: 324169

6 years ago[ScopInfo] Allow epilogues to be the main statement of a BB.
Michael Kruse [Sat, 3 Feb 2018 05:43:00 +0000 (05:43 +0000)]
[ScopInfo] Allow epilogues to be the main statement of a BB.

Do not add a "_last" suffix to the statement name if there is no (other)
main statement for a basic block. In other words, it becomes the main
statement itself. This further reduces the statement naming difference
between -polly-stmt-granularity=bb and
-polly-stmt-granularity=scalar-indep.

llvm-svn: 324168

6 years agoRevert r324166 "[analyzer] Add a checker for mmap()...".
Artem Dergachev [Sat, 3 Feb 2018 03:57:32 +0000 (03:57 +0000)]
Revert r324166 "[analyzer] Add a checker for mmap()...".

Due to Buildbot failures - most likely that's because target triples were not
specified in the tests, even though the checker behaves differently with
different target triples.

llvm-svn: 324167

6 years ago[analyzer] Add a checker for mmap()s which are both writable and executable.
Artem Dergachev [Sat, 3 Feb 2018 02:33:42 +0000 (02:33 +0000)]
[analyzer] Add a checker for mmap()s which are both writable and executable.

This is a security check which is disabled by default but will be enabled
whenever the user consciously enables the security package. If mmap()ed memory
is both writable and executable, it makes it easier for the attacker to execute
arbitrary code when contents of this memory are compromised. Some applications
require such mmap()s though, such as different sorts of JIT.

Patch by David Carlier!

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

llvm-svn: 324166

6 years agoWork around GCC constexpr initialization bug
Eric Fiselier [Sat, 3 Feb 2018 01:48:21 +0000 (01:48 +0000)]
Work around GCC constexpr initialization bug

llvm-svn: 324165

6 years agoWork around Clang bug introduced in r324062
Eric Fiselier [Sat, 3 Feb 2018 01:45:35 +0000 (01:45 +0000)]
Work around Clang bug introduced in r324062

When Clang encounters an already invalid class declaration, it can
emit incorrect diagnostics about the exception specification on
some of its members. This patch temporarily works around that
incorrect diagnostic.

The clang bug was introduced in r324062.

llvm-svn: 324164

6 years ago[hwasan] Add a paragraph on stack instrumentation.
Evgeniy Stepanov [Sat, 3 Feb 2018 01:06:21 +0000 (01:06 +0000)]
[hwasan] Add a paragraph on stack instrumentation.

Reviewers: kcc

Subscribers: cfe-commits

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

llvm-svn: 324163

6 years ago[analyzer] Do not infer nullability inside function-like macros, even when macro...
George Karpenkov [Sat, 3 Feb 2018 00:55:21 +0000 (00:55 +0000)]
[analyzer] Do not infer nullability inside function-like macros, even when macro is explicitly returning NULL

We already suppress such reports for inlined functions, we should then
get the same behavior for macros.
The underlying reason is that the same macro, can be called from many
different contexts, and nullability can only be expected in _some_ of
them.
Assuming that the macro can return null in _all_ of them sometimes leads
to a large number of false positives.

E.g. consider the test case for the dynamic cast implementation in
macro: in such cases, the bug report is unwanted.

Tracked in rdar://36304776

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

llvm-svn: 324161

6 years agoFix crash when trying to pack-expand a GNU statement expression.
Richard Smith [Sat, 3 Feb 2018 00:44:57 +0000 (00:44 +0000)]
Fix crash when trying to pack-expand a GNU statement expression.

We could in principle support such pack expansion, using techniques similar to
what we do for pack expansion of lambdas, but it's not clear it's worthwhile.
For now at least, cleanly reject these cases rather than crashing.

llvm-svn: 324160

6 years agoTurn off the deprecated ALWAYS_SEARCH_USER_PATHS feature
Jason Molenda [Sat, 3 Feb 2018 00:37:46 +0000 (00:37 +0000)]
Turn off the deprecated ALWAYS_SEARCH_USER_PATHS feature
in debugserver.  This is already set this way in the lldb
project files but not in debugserver.  Updating for
consistency.

llvm-svn: 324158

6 years ago[WebAssembly] Refactor linker-generated symbols. NFC.
Sam Clegg [Fri, 2 Feb 2018 22:59:56 +0000 (22:59 +0000)]
[WebAssembly] Refactor linker-generated symbols. NFC.

Group all synthetic symbols in the in single struct to match
the ELF linker.

This change is part of a larger change to add more linker
symbols such as `_end` and `_edata`.

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

llvm-svn: 324157

6 years agoFix a copy of a fixed length, possibly non-nul terminated, string
Jason Molenda [Fri, 2 Feb 2018 22:48:45 +0000 (22:48 +0000)]
Fix a copy of a fixed length, possibly non-nul terminated, string
into a std::string so we don't run off the end of the array when
there is no nul byte in ProcessElfCore::parseLinuxNotes.
Found with ASAN testing.

<rdar://problem/37134319>

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

llvm-svn: 324156

6 years agoSimplify.
Rui Ueyama [Fri, 2 Feb 2018 22:48:09 +0000 (22:48 +0000)]
Simplify.

llvm-svn: 324155

6 years agoUpdate Eq so that it uses NAME just like B does. NFC.
Rui Ueyama [Fri, 2 Feb 2018 22:45:47 +0000 (22:45 +0000)]
Update Eq so that it uses NAME just like B does. NFC.

llvm-svn: 324154

6 years agoFix has_unique_object_representation after Clang commit r324134.
Eric Fiselier [Fri, 2 Feb 2018 22:39:59 +0000 (22:39 +0000)]
Fix has_unique_object_representation after Clang commit r324134.

Clang previously reported an empty union as having a unique object
representation. This was incorrect and was fixed in a recent Clang commit.

This patch fixes the libc++ tests.

llvm-svn: 324153

6 years agoFix incorrect usage of std::is_assignable.
Richard Smith [Fri, 2 Feb 2018 22:29:54 +0000 (22:29 +0000)]
Fix incorrect usage of std::is_assignable.

We want to check that we can assign to an lvalue here, not a prvalue.

llvm-svn: 324152

6 years agoAdd missing direct-init / parameter-declaration-clause disambiguation when
Richard Smith [Fri, 2 Feb 2018 22:24:54 +0000 (22:24 +0000)]
Add missing direct-init / parameter-declaration-clause disambiguation when
parsing a trailing-return-type of a (function pointer) variable declaration.

llvm-svn: 324151

6 years agoAdd -{no,}-check-sections flags to enable/disable section overlchecking
Rui Ueyama [Fri, 2 Feb 2018 22:24:06 +0000 (22:24 +0000)]
Add -{no,}-check-sections flags to enable/disable section overlchecking

GNU linkers have this option.

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

llvm-svn: 324150

6 years ago[InstCombine] Use getDestAlignment in SimplifyMemSet (NFC)
Daniel Neilson [Fri, 2 Feb 2018 22:03:03 +0000 (22:03 +0000)]
[InstCombine] Use getDestAlignment in SimplifyMemSet (NFC)

Summary:
Small NFC change to change the name of the function used getting and setting
the alignment of a memset.

llvm-svn: 324148

6 years ago[X86] Prefer to create a ISD::SETCC over X86ISD::PCMPEQ in combineVectorSizedSetCCEqu...
Craig Topper [Fri, 2 Feb 2018 21:59:46 +0000 (21:59 +0000)]
[X86] Prefer to create a ISD::SETCC over X86ISD::PCMPEQ in combineVectorSizedSetCCEquality.

This is running pre-legalize, we should try to use target independent nodes. This will give the best opportunity for target independent optimizations.

llvm-svn: 324147

6 years agoStrip .note.gnu.build-id sections if --build-id is given.
Rui Ueyama [Fri, 2 Feb 2018 21:56:24 +0000 (21:56 +0000)]
Strip .note.gnu.build-id sections if --build-id is given.

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

llvm-svn: 324146

6 years agoAdd --no-gnu-unique and --no-undefined-version for completeness.
Rui Ueyama [Fri, 2 Feb 2018 21:44:06 +0000 (21:44 +0000)]
Add --no-gnu-unique and --no-undefined-version for completeness.

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

llvm-svn: 324145

6 years ago[InstCombine] make sure tests are providing coverage for the stated pattern; NFC
Sanjay Patel [Fri, 2 Feb 2018 21:40:54 +0000 (21:40 +0000)]
[InstCombine] make sure tests are providing coverage for the stated pattern; NFC

Without extra instructions and uses, swapMayExposeCSEOpportunities() would change
the icmp (as seen in the check lines), so we were not actually testing patterns
that should be handled by D41480.

llvm-svn: 324143

6 years agoMore documentation cleanup for Decl.h.
James Dennett [Fri, 2 Feb 2018 21:38:22 +0000 (21:38 +0000)]
More documentation cleanup for Decl.h.

llvm-svn: 324142

6 years agoConsolidate --foo and --no-foo options. NFC.
Rui Ueyama [Fri, 2 Feb 2018 21:25:51 +0000 (21:25 +0000)]
Consolidate --foo and --no-foo options. NFC.

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

llvm-svn: 324141

6 years agoUse NULL instead of nullptr in invalid-pointer-pairs-compare-null.cc; nullptr is...
Kuba Mracek [Fri, 2 Feb 2018 20:42:29 +0000 (20:42 +0000)]
Use NULL instead of nullptr in invalid-pointer-pairs-compare-null.cc; nullptr is not available on older Darwin systems.

llvm-svn: 324136

6 years ago[X86] Pass SDLoc by const reference in a few more places in X86ISelLowering.cpp. NFC
Craig Topper [Fri, 2 Feb 2018 20:32:00 +0000 (20:32 +0000)]
[X86] Pass SDLoc by const reference in a few more places in X86ISelLowering.cpp. NFC

llvm-svn: 324135

6 years agoMake __has_unique_object_representations reject empty union types.
Eric Fiselier [Fri, 2 Feb 2018 20:30:39 +0000 (20:30 +0000)]
Make __has_unique_object_representations reject empty union types.

Summary:
Clang incorrectly reports empty unions as having a unique object representation. However, this is not correct since `sizeof(EmptyUnion) == 1` AKA it has 8 bits of padding. Therefore it should be treated the same as an empty struct and report `false`.

@erichkeane also suggested this fix should be merged into the 6.0 release branch, so the initial release of `__has_unique_object_representations` is as bug-free as possible.

Reviewers: erichkeane, rsmith, aaron.ballman, majnemer

Reviewed By: erichkeane

Subscribers: cfe-commits, erichkeane

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

llvm-svn: 324134

6 years agoDocumentation cleanup, no functional change.
James Dennett [Fri, 2 Feb 2018 20:22:29 +0000 (20:22 +0000)]
Documentation cleanup, no functional change.

llvm-svn: 324133

6 years ago[clang-proto-to-cxx] Accept protobufs with missing fields.
Matt Morehouse [Fri, 2 Feb 2018 20:22:20 +0000 (20:22 +0000)]
[clang-proto-to-cxx] Accept protobufs with missing fields.

libprotobuf-mutator accepts protobufs with missing fields, which means
clang-proto-fuzzer does as well.  clang-proto-to-cxx should match this
behavior.

llvm-svn: 324132

6 years ago[clang-format] New format param ObjCBinPackProtocolList
Ben Hamilton [Fri, 2 Feb 2018 20:15:14 +0000 (20:15 +0000)]
[clang-format] New format param ObjCBinPackProtocolList

Summary:
This is an alternative approach to D42014 after some
investigation by stephanemoore@ and myself.

Previously, the format parameter `BinPackParameters` controlled both
C function parameter list bin-packing and Objective-C protocol conformance
list bin-packing.

We found in the Google style, some teams were changing
`BinPackParameters` from its default (`true`) to `false` so they could
lay out Objective-C protocol conformance list items one-per-line
instead of bin-packing them into as few lines as possible.

To allow teams to use one-per-line Objective-C protocol lists without
changing bin-packing for other areas like C function parameter lists,
this diff introduces a new LibFormat parameter
`ObjCBinPackProtocolList` to control the behavior just for ObjC
protocol conformance lists.

The new parameter is an enum which defaults to `Auto` to keep the
previous behavior (delegating to `BinPackParameters`).

Depends On D42649

Test Plan: New tests added. make -j12 FormatTests && ./tools/clang/unittests/Format/FormatTests

Reviewers: jolesiak, stephanemoore, djasper

Reviewed By: stephanemoore

Subscribers: Wizard, hokein, cfe-commits, klimek

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

llvm-svn: 324131

6 years ago[X86] Add avx512 command line to ptest.ll to demonstrate that 512-bit vectors are...
Craig Topper [Fri, 2 Feb 2018 20:12:45 +0000 (20:12 +0000)]
[X86] Add avx512 command line to ptest.ll to demonstrate that 512-bit vectors are not handled by LowerVectorAllZeroTest.

llvm-svn: 324130

6 years agoPartially revert r324124 [X86] Add tests for missed opportunities to use ptest for...
Craig Topper [Fri, 2 Feb 2018 20:12:44 +0000 (20:12 +0000)]
Partially revert r324124 [X86] Add tests for missed opportunities to use ptest for all ones comparison.

Turns out I misunderstood the flag behavior of PTEST because I read the documentation for KORTEST which is different than PTEST/KTEST and made a bad assumption.

Keep the test rename though cause that's useful.

llvm-svn: 324129

6 years ago Emit label names according to -discard-value-names.
Eric Fiselier [Fri, 2 Feb 2018 19:58:34 +0000 (19:58 +0000)]
 Emit label names according to -discard-value-names.

Summary:
Previously, Clang only emitted label names in assert builds.
However there is a CC1 option -discard-value-names that should have been used to control emission instead.

This patch removes the NDEBUG preprocessor block and instead allows LLVM to handle removing the names in accordance with the option.

Reviewers: erichkeane, aaron.ballman, majnemer

Reviewed By: aaron.ballman

Subscribers: cfe-commits

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

llvm-svn: 324127

6 years ago[asan] Make concurrent_overflow.cc less flaky
Kuba Mracek [Fri, 2 Feb 2018 19:49:24 +0000 (19:49 +0000)]
[asan] Make concurrent_overflow.cc less flaky

The "sleep(5)" sometimes times out on our bots, causing the test to fail. Let's use pthread_join.

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

llvm-svn: 324126

6 years ago[GISel][NFC]: Move RegisterBankInfo::getSizeInBits into TargetRegisterInfo.
Aditya Nandakumar [Fri, 2 Feb 2018 19:42:07 +0000 (19:42 +0000)]
[GISel][NFC]: Move RegisterBankInfo::getSizeInBits into TargetRegisterInfo.

llvm-svn: 324125

6 years ago[X86] Add tests for missed opportunities to use ptest for all ones comparison.
Craig Topper [Fri, 2 Feb 2018 19:34:10 +0000 (19:34 +0000)]
[X86] Add tests for missed opportunities to use ptest for all ones comparison.

Also rename the test from pr12312.ll to ptest.ll so its more recognizable.

llvm-svn: 324124

6 years agoFix typo
Alex Denisov [Fri, 2 Feb 2018 19:20:37 +0000 (19:20 +0000)]
Fix typo

llvm-svn: 324123

6 years ago[InstCombine] simplify logic for swapMayExposeCSEOpportunities; NFCI
Sanjay Patel [Fri, 2 Feb 2018 19:08:12 +0000 (19:08 +0000)]
[InstCombine] simplify logic for swapMayExposeCSEOpportunities; NFCI

llvm-svn: 324122

6 years agoCorrect FileCheck usage in two newly added tests
Kamil Rytarowski [Fri, 2 Feb 2018 18:48:15 +0000 (18:48 +0000)]
Correct FileCheck usage in two newly added tests

llvm-svn: 324121

6 years agoAdd new NetBSD interceptors: devname(3), devname_r(3)
Kamil Rytarowski [Fri, 2 Feb 2018 18:45:33 +0000 (18:45 +0000)]
Add new NetBSD interceptors: devname(3), devname_r(3)

Summary:
devname, devname_r - get device name

Sponsored by <The NetBSD Foundation>

Reviewers: joerg, vitalybuka

Reviewed By: vitalybuka

Subscribers: kubamracek, llvm-commits, #sanitizers

Tags: #sanitizers

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

llvm-svn: 324120

6 years agoAdd the ability to restrict the breakpoint to a module
Jim Ingham [Fri, 2 Feb 2018 18:39:25 +0000 (18:39 +0000)]
Add the ability to restrict the breakpoint to a module
for run_to_{source,name}_breakpoint.

llvm-svn: 324119

6 years ago[InstCombine] fix typos, formatting; NFC
Sanjay Patel [Fri, 2 Feb 2018 18:39:05 +0000 (18:39 +0000)]
[InstCombine] fix typos, formatting; NFC

llvm-svn: 324118

6 years agoUse an alternative approach to prevent Spotlight from indexing the build directory.
Adrian Prantl [Fri, 2 Feb 2018 18:32:29 +0000 (18:32 +0000)]
Use an alternative approach to prevent Spotlight from indexing the build directory.

llvm-svn: 324115

6 years ago[analyzer] [tests] Fix crash in SATestBuild.py
George Karpenkov [Fri, 2 Feb 2018 18:27:14 +0000 (18:27 +0000)]
[analyzer] [tests] Fix crash in SATestBuild.py

llvm-svn: 324114

6 years ago[Tooling] Returns non-zero status code when files are skipped.
Eric Liu [Fri, 2 Feb 2018 18:19:22 +0000 (18:19 +0000)]
[Tooling] Returns non-zero status code when files are skipped.

Reviewers: hokein, bkramer

Reviewed By: bkramer

Subscribers: bkramer, klimek, cfe-commits

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

llvm-svn: 324113

6 years agoRun clang-format after r324003. NFC.
Michael Kruse [Fri, 2 Feb 2018 18:11:58 +0000 (18:11 +0000)]
Run clang-format after r324003. NFC.

llvm-svn: 324112

6 years ago[demangler] Clean up the expression parser
Erik Pilkington [Fri, 2 Feb 2018 18:04:32 +0000 (18:04 +0000)]
[demangler] Clean up the expression parser

This commit cleans up the expression parser, using a new style:
  - parse* functions now return Node pointers.
  - The mangled name is now held in Db and accessed with look() and consume()
  - LLVM coding style

This style is meant to avoid the 2 most common types of bugs in the
old demanger, namely misusing the Names stack (ie, calling back() on
empty) and going out of bounds on the mangled name. I also think it
makes the demangler a lot cleaner.

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

llvm-svn: 324111

6 years ago[AArch64][GlobalISel] Use getRegClassForTypeOnBank() in selectCopy.
Amara Emerson [Fri, 2 Feb 2018 18:03:30 +0000 (18:03 +0000)]
[AArch64][GlobalISel] Use getRegClassForTypeOnBank() in selectCopy.

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

llvm-svn: 324110

6 years ago[InstCombine] add baseline tests for unsigned saturated sub (D41480); NFC
Sanjay Patel [Fri, 2 Feb 2018 17:43:16 +0000 (17:43 +0000)]
[InstCombine] add baseline tests for unsigned saturated sub (D41480); NFC

llvm-svn: 324109

6 years agoRevert "Start setting dso_local in clang."
Rafael Espindola [Fri, 2 Feb 2018 17:29:22 +0000 (17:29 +0000)]
Revert "Start setting dso_local in clang."

This reverts commit r324107.

I will have to test it on OS X.

llvm-svn: 324108

6 years agoStart setting dso_local in clang.
Rafael Espindola [Fri, 2 Feb 2018 17:17:39 +0000 (17:17 +0000)]
Start setting dso_local in clang.

This starts adding dso_local to clang.

The hope is to eventually have TargetMachine::shouldAssumeDsoLocal go
away. My objective for now is to move enough of it to clang to remove
the need for the TargetMachine one to handle PIE copy relocations and
-fno-plt. With that it should then be easy to implement a
-fno-copy-reloc in clang.

This patch just adds the cases where we assume a symbol to be local
based on the file being compiled for an executable or a shared
library.

llvm-svn: 324107

6 years ago[X86] Remove checks for FeatureAVX512 from the X86 assembly parser. Remove mcpu/mattr...
Craig Topper [Fri, 2 Feb 2018 17:02:58 +0000 (17:02 +0000)]
[X86] Remove checks for FeatureAVX512 from the X86 assembly parser. Remove mcpu/mattr from assembly test command lines.

Summary:
We should always be able to accept AVX512 registers and instructions in llvm-mc. The only subtarget mode that should be checked is 16-bit vs 32-bit vs 64-bit mode.

I've also removed all the mattr/mcpu lines from test RUN lines to be consistent with this. Most were due to AVX512, but a few were for other features.

Fixes PR36202

Reviewers: RKSimon, echristo, bkramer

Reviewed By: echristo

Subscribers: llvm-commits

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

llvm-svn: 324106

6 years ago[clangd] Fix ExternC test broken by r324081
Sam McCall [Fri, 2 Feb 2018 17:01:36 +0000 (17:01 +0000)]
[clangd] Fix ExternC test broken by r324081

llvm-svn: 324105

6 years agoMake utils/UpdateTestChecks/common.py Python 2/3 compatible and fix print statements.
Fangrui Song [Fri, 2 Feb 2018 16:41:07 +0000 (16:41 +0000)]
Make utils/UpdateTestChecks/common.py Python 2/3 compatible and fix print statements.

Subscribers: llvm-commits

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

llvm-svn: 324104

6 years ago[AMDGPU] Switch to the new addr space mapping by default
Yaxun Liu [Fri, 2 Feb 2018 16:08:24 +0000 (16:08 +0000)]
[AMDGPU] Switch to the new addr space mapping by default

This requires corresponding llvm change.

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

llvm-svn: 324102

6 years ago[AMDGPU] Switch to the new addr space mapping by default
Yaxun Liu [Fri, 2 Feb 2018 16:07:16 +0000 (16:07 +0000)]
[AMDGPU] Switch to the new addr space mapping by default

This requires corresponding clang change.

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

llvm-svn: 324101

6 years agoAdd llc tests for comparison chains.
Clement Courbet [Fri, 2 Feb 2018 15:54:17 +0000 (15:54 +0000)]
Add llc tests for comparison chains.

See https://reviews.llvm.org/D42793#996098 for context.

llvm-svn: 324099

6 years ago[CodeGen][va_args] Correct Vector Struct va-arg 'in_reg' code gen
Erich Keane [Fri, 2 Feb 2018 15:53:35 +0000 (15:53 +0000)]
[CodeGen][va_args] Correct Vector Struct va-arg 'in_reg' code gen

When trying to track down a different bug, we discovered
that calling __builtin_va_arg on a vec3f type caused
the SROA pass to issue a warning that there was an illegal
access.

Further research showed that the vec3f type is
alloca'ed as size '12', but the _builtin_va_arg code
on x86_64 was always loading this out of registers as
{double, double}. Thus, the 2nd store into the vec3f
was storing in bytes 12-15!

This patch alters the original implementation which always
assumed {double, double} to use the actual coerced type
instead, so the LLVM-IR generated is a load/GEP/store of
a <2 x float> and a float, rather than a double and a double.

Tests were added for all combinations I could think of that
would fit in 2 FP registers, and all work exactly as expected.

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

llvm-svn: 324098