platform/upstream/llvm.git
7 years agoFix reverse to work on const rbegin()/rend().
Pete Cooper [Wed, 17 Aug 2016 22:06:59 +0000 (22:06 +0000)]
Fix reverse to work on const rbegin()/rend().

Duncan found that reverse worked on mutable rbegin(), but the has_rbegin
trait didn't work with a const method.  See http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20160815/382890.html
for more details.

Turns out this was already solved in clang with has_getDecl.  Copied that and made it work for rbegin.

This includes the tests Duncan attached to that thread, including the traits test.

llvm-svn: 278991

7 years ago[Darwin] Stop linking libclang_rt.eprintf.a
Chris Bieneman [Wed, 17 Aug 2016 21:54:30 +0000 (21:54 +0000)]
[Darwin] Stop linking libclang_rt.eprintf.a

Summary:
The eprintf library was added before the general OS X builtins library existed as a place to store one builtin function. Since we have for several years had an actual mandated builtin library for OS X > 10.5, we should just merge eprintf into the main library.

This change will resolve PR28855.

As a follow up I'll also patch compiler-rt to not generate the eprintf library anymore.

Reviewers: ddunbar, bob.wilson

Subscribers: cfe-commits

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

llvm-svn: 278988

7 years ago[CMake] Adding toolchain targets to PGO and Apple CMake caches
Chris Bieneman [Wed, 17 Aug 2016 21:51:38 +0000 (21:51 +0000)]
[CMake] Adding toolchain targets to PGO and Apple CMake caches

The Xcode toolchain targets are useful on OS X hosts because you can construct and install multiple toolchians that can be used seamlessly.

llvm-svn: 278987

7 years ago[libFuzzer] given 0 and 255 more preference when inserting repeated bytes
Kostya Serebryany [Wed, 17 Aug 2016 21:50:54 +0000 (21:50 +0000)]
[libFuzzer] given 0 and 255 more preference when inserting repeated bytes

llvm-svn: 278986

7 years ago[macho2yaml] Don't write empty linkedit data
Chris Bieneman [Wed, 17 Aug 2016 21:46:04 +0000 (21:46 +0000)]
[macho2yaml] Don't write empty linkedit data

Since I stopped writing empty export tries it causes LinkEdit to potentially be completely empty which results in invalid yaml being generated.

To prevent this we skip linkedit data if it is empty.

llvm-svn: 278985

7 years agoAdd test missed from r278983.
Richard Smith [Wed, 17 Aug 2016 21:42:10 +0000 (21:42 +0000)]
Add test missed from r278983.

llvm-svn: 278984

7 years agoPR18417: Increase -ftemplate-depth to the value 1024 recommended by the C++
Richard Smith [Wed, 17 Aug 2016 21:41:45 +0000 (21:41 +0000)]
PR18417: Increase -ftemplate-depth to the value 1024 recommended by the C++
standard's Annex B. We now attempt to increase the process's stack rlimit to
8MiB on startup, which appears to be enough to allow this to work reliably.
(And if it turns out not to be, we can investigate increasing it further.)

llvm-svn: 278983

7 years ago[libFuzzer] one more mutation: ChangeBinaryInteger; also fix the breakage from r278970
Kostya Serebryany [Wed, 17 Aug 2016 21:30:30 +0000 (21:30 +0000)]
[libFuzzer] one more mutation: ChangeBinaryInteger; also fix the breakage from r278970

llvm-svn: 278982

7 years agoTail Duplication: Accept explicit threshold for duplicating.
Kyle Butt [Wed, 17 Aug 2016 21:07:35 +0000 (21:07 +0000)]
Tail Duplication: Accept explicit threshold for duplicating.

This will allow tail duplication and tail merging during layout to have a
shared threshold to make sure that they don't overlap. No observable change
intended.

llvm-svn: 278981

7 years agoTailDuplicator: Use optForSize instead of hasFnAttribute.
Kyle Butt [Wed, 17 Aug 2016 21:07:33 +0000 (21:07 +0000)]
TailDuplicator: Use optForSize instead of hasFnAttribute.

This will cause minsize functions to have the same threshold as optsize
functions, but otherwise should have no effects.

llvm-svn: 278980

7 years agoRevert "Add a test for clang-tidy using the clang-cl driver."
Zachary Turner [Wed, 17 Aug 2016 21:01:13 +0000 (21:01 +0000)]
Revert "Add a test for clang-tidy using the clang-cl driver."

This reverts commit fd1908ce445eba4544d64cc68b3c03249e4bf614.

This should be the correct CL to revert.  The clang-side patch
that enabled this functionality was reverted, so this test needs
to be reverted until it gets fixed.

llvm-svn: 278979

7 years agoRevert "Revert "[Include-fixer] Install executables and support scripts""
Zachary Turner [Wed, 17 Aug 2016 20:58:14 +0000 (20:58 +0000)]
Revert "Revert "[Include-fixer] Install executables and support scripts""

This reverts commit 2aff596257e1c45fa54baae823ecbe61a785174e.

I'm having a bad day apparently.  I reverted the wrong CL.  This
puts it back.

llvm-svn: 278978

7 years agoRevert "[Include-fixer] Install executables and support scripts"
Zachary Turner [Wed, 17 Aug 2016 20:56:47 +0000 (20:56 +0000)]
Revert "[Include-fixer] Install executables and support scripts"

This reverts commit b725a314a9b7f746c37f70909ec3c4dcb6d9f6b5.

The patch that made this test work needed to be reverted, so this
test needs to be reverted as well.

llvm-svn: 278977

7 years agoRevert "[Tooling] Parse compilation database command lines on Windows."
Zachary Turner [Wed, 17 Aug 2016 20:55:35 +0000 (20:55 +0000)]
Revert "[Tooling] Parse compilation database command lines on Windows."

This reverts commit 27a874790fc79f6391ad3703d7c790f51ac6ae1f.

After the introduction of windows command line parsing, some unit tests
began failing that expect to test gnu style command line quirks.  The
fix is mechanical but time consuming, so revert this for now.

llvm-svn: 278976

7 years ago[libFuzzer] when printing the reproducer input, also print the base input and the...
Kostya Serebryany [Wed, 17 Aug 2016 20:45:23 +0000 (20:45 +0000)]
[libFuzzer] when printing the reproducer input, also print the base input and the mutation sequence

llvm-svn: 278975

7 years agoADT: Remove UB in ilist (and use a circular linked list)
Duncan P. N. Exon Smith [Wed, 17 Aug 2016 20:44:33 +0000 (20:44 +0000)]
ADT: Remove UB in ilist (and use a circular linked list)

This removes the undefined behaviour (UB) in ilist/ilist_node/etc.,
mainly by removing (gutting) the ilist_sentinel_traits customization
point and canonicalizing on a single, efficient memory layout.  This
fixes PR26753.

The new ilist is a doubly-linked circular list.
- ilist_node_base has two ilist_node_base*: Next and Prev.  Size-of: two
  pointers.
- ilist_node<T> (size-of: two pointers) is a type-safe wrapper around
  ilist_node_base.
- ilist_iterator<T> (size-of: two pointers) operates on an
  ilist_node<T>*, and downcasts to T* on dereference.
- ilist_sentinel<T> (size-of: two pointers) is a wrapper around
  ilist_node<T> that has some extra API for list management.
- ilist<T> (size-of: two pointers) has an ilist_sentinel<T>, whose
  address is returned for end().

The new memory layout matches ilist_half_embedded_sentinel_traits<T>
exactly.  The Head pointer that previously lived in ilist<T> is
effectively glued to the ilist_half_node<T> that lived in
ilist_half_embedded_sentinel_traits<T>, becoming the Next and Prev in
the ilist_sentinel_node<T>, respectively.  sizeof(ilist<T>) is now the
size of two pointers, and there is never any additional storage for a
sentinel.

This is a much simpler design for a doubly-linked list, removing most of
the corner cases of list manipulation (add, remove, etc.).  In follow-up
commits, I intend to move as many algorithms as possible into a
non-templated base class (ilist_base) to reduce code size.

Moreover, this fixes the UB in ilist_iterator/getNext/getPrev
operations.  Previously, ilist_iterator<T> operated on a T*, even when
the sentinel was not of type T (i.e., ilist_embedded_sentinel_traits and
ilist_half_embedded_sentinel_traits).  This added UB to all operations
involving end().   Now, ilist_iterator<T> operates on an ilist_node<T>*,
and only downcasts when the full type is guaranteed to be T*.

What did we lose?  There used to be a crash (in some configurations) on
++end().  Curiously (via UB), ++end() would return begin() for users of
ilist_half_embedded_sentinel_traits<T>, but otherwise ++end() would
cause a nice dependable nullptr dereference, crashing instead of a
possible infinite loop.  Options:
 1. Lose that behaviour.
 2. Keep it, by stealing a bit from Prev in asserts builds.
 3. Crash on dereference instead, using the same technique.

Hans convinced me (because of the number of problems this and r278532
exposed on Windows) that we really need some assertion here, at least in
the short term.  I've opted for #3 since I think it catches more bugs.

I added only a couple of unit tests to root out specific bugs I hit
during bring-up, but otherwise this is tested implicitly via the
extensive usage throughout LLVM.

Planned follow-ups:
- Remove ilist_*sentinel_traits<T>.  Here I've just gutted them to
  prevent build failures in sub-projects.  Once I stop referring to them
  in sub-projects, I'll come back and delete them.
- Add ilist_base and move algorithms there.
- Check and fix move construction and assignment.

Eventually, there are other interesting directions:
- Rewrite reverse iterators, so that rbegin().getNodePtr()==&*rbegin().
  This allows much simpler logic when erasing elements during a reverse
  traversal.
- Remove ilist_traits::createNode, by deleting the remaining API that
  creates nodes.  Intrusive lists shouldn't be creating nodes
  themselves.
- Remove ilist_traits::deleteNode, by (1) asserting that lists are empty
  on destruction and (2) changing API that calls it to take a Deleter
  functor (intrusive lists shouldn't be in the memory management
  business).
- Reconfigure the remaining callback traits (addNodeToList, etc.) to be
  higher-level, pulling out a simple_ilist<T> that is much easier to
  read and understand.
- Allow tags (e.g., ilist_node<T,tag1> and ilist_node<T,tag2>) so that T
  can be a member of multiple intrusive lists.

llvm-svn: 278974

7 years agoRevert "[WebAssembly] Handle debug information and virtual registers without crashing"
Duncan P. N. Exon Smith [Wed, 17 Aug 2016 20:41:50 +0000 (20:41 +0000)]
Revert "[WebAssembly] Handle debug information and virtual registers without crashing"

This reverts commit r278967, since the new test is failing when you
don't build the WebAssembly target (most people, since it's
off-by-default).

llvm-svn: 278973

7 years ago[OpenCL] AMDGPU: add support of cl_khr_subgroups
Yaxun Liu [Wed, 17 Aug 2016 20:39:49 +0000 (20:39 +0000)]
[OpenCL] AMDGPU: add support of cl_khr_subgroups

Patch by Aaron En Ye Shi.

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

llvm-svn: 278972

7 years ago[docs] Adding "new target" rules to dev policy
Renato Golin [Wed, 17 Aug 2016 20:38:09 +0000 (20:38 +0000)]
[docs] Adding "new target" rules to dev policy

Making explicit our current policy to accept new targets as experimental and
later official. Every new target should follow these rules to be added,
and kept relevant in the upstream tree.

llvm-svn: 278971

7 years agoReplace a few more "fall through" comments with LLVM_FALLTHROUGH
Justin Bogner [Wed, 17 Aug 2016 20:30:52 +0000 (20:30 +0000)]
Replace a few more "fall through" comments with LLVM_FALLTHROUGH

Follow up to r278902. I had missed "fall through", with a space.

llvm-svn: 278970

7 years agoGlobalISel: support irtranslation of icmp instructions.
Tim Northover [Wed, 17 Aug 2016 20:25:25 +0000 (20:25 +0000)]
GlobalISel: support irtranslation of icmp instructions.

llvm-svn: 278969

7 years agoAdd a test for clang-tidy using the clang-cl driver.
Zachary Turner [Wed, 17 Aug 2016 20:14:10 +0000 (20:14 +0000)]
Add a test for clang-tidy using the clang-cl driver.

Reviewed By: alexfh
Differential Revision: https://reviews.llvm.org/D23480

llvm-svn: 278968

7 years ago[WebAssembly] Handle debug information and virtual registers without crashing
Dominic Chen [Wed, 17 Aug 2016 20:11:03 +0000 (20:11 +0000)]
[WebAssembly] Handle debug information and virtual registers without crashing

Summary: Currently, enabling debug information when compiling for WebAssembly crashes the backend. This commit fixes these by skipping debug values in backend passes.

Reviewers: jfb, aprantl, dschuff, echristo

Subscribers: mehdi_amini, yurydelendik, dexonsmith, MatzeB, jfb, dschuff, llvm-commits

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

llvm-svn: 278967

7 years ago[GraphWriter] Change GraphWriter to use NodeRef in GraphTraits
Tim Shen [Wed, 17 Aug 2016 20:07:29 +0000 (20:07 +0000)]
[GraphWriter] Change GraphWriter to use NodeRef in GraphTraits

Summary:
This is part of the "NodeType* -> NodeRef" migration. Notice that since
GraphWriter prints object address as identity, I added a static_assert on
NodeRef to be a pointer type.

Reviewers: dblaikie

Subscribers: llvm-commits, MatzeB

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

llvm-svn: 278966

7 years agoAMDGPU: Remove dead option
Matt Arsenault [Wed, 17 Aug 2016 20:07:16 +0000 (20:07 +0000)]
AMDGPU: Remove dead option

llvm-svn: 278965

7 years ago[Tooling] Parse compilation database command lines on Windows.
Zachary Turner [Wed, 17 Aug 2016 20:04:35 +0000 (20:04 +0000)]
[Tooling] Parse compilation database command lines on Windows.

When a compilation database is used on Windows, the command lines cannot
be parsed using the standard GNU style syntax. LLVM provides functions for
parsing Windows style command lines, so use them where appropriate.

After this patch, clang-tidy runs correctly on Windows.

Reviewed by: alexfh
Differential Revision: https://reviews.llvm.org/D23455

llvm-svn: 278964

7 years ago[GraphWriter] Change GraphWriter to use NodeRef in GraphTraits
Tim Shen [Wed, 17 Aug 2016 20:02:38 +0000 (20:02 +0000)]
[GraphWriter] Change GraphWriter to use NodeRef in GraphTraits

Summary: Corresponding LLVM patch: D23580

Reviewers: dblaikie

Subscribers: cfe-commits

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

llvm-svn: 278963

7 years agoImplement vstore_half{,n}
Jan Vesely [Wed, 17 Aug 2016 20:02:11 +0000 (20:02 +0000)]
Implement vstore_half{,n}

Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
llvm-svn: 278962

7 years ago[GenericDomTree] Change GenericDomTree to use NodeRef in GraphTraits. NFC.
Tim Shen [Wed, 17 Aug 2016 20:01:58 +0000 (20:01 +0000)]
[GenericDomTree] Change GenericDomTree to use NodeRef in GraphTraits. NFC.

Summary:
Looking at the implementation, GenericDomTree has more specific
requirements on NodeRef, e.g. NodeRefObject->getParent() should compile,
and NodeRef should be a pointer. We can remove the pointer requirement,
but it seems to have little gain, given the limited use cases.

Also changed GraphTraits<Inverse<Inverse<T>> to be more accurate.

Reviewers: dblaikie, chandlerc

Subscribers: llvm-commits

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

llvm-svn: 278961

7 years ago[InstCombine] minimize tests and autogenerate checks
Sanjay Patel [Wed, 17 Aug 2016 19:56:10 +0000 (19:56 +0000)]
[InstCombine] minimize tests and autogenerate checks

llvm-svn: 278960

7 years agoSplit DescribeAddressIfGlobal between a function that gets all the information, and...
Filipe Cabecinhas [Wed, 17 Aug 2016 19:52:12 +0000 (19:52 +0000)]
Split DescribeAddressIfGlobal between a function that gets all the information, and one that prints it.

Summary:
Replacement for part of D23518
This deals with global variable addresses.

(This commit is written on top of D23605, but can be applied by itself)

Reviewers: kcc, samsonov

Subscribers: kubabrecka, llvm-commits

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

llvm-svn: 278959

7 years agoSplit DescribeAddressIfStack between a function that gets all the information, and...
Filipe Cabecinhas [Wed, 17 Aug 2016 19:52:06 +0000 (19:52 +0000)]
Split DescribeAddressIfStack between a function that gets all the information, and one that prints it.

Summary:
Replacement for part of D23518
This deals with stack addresses.

Reviewers: kcc, samsonov

Subscribers: kubabrecka, llvm-commits

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

llvm-svn: 278958

7 years ago[InstCombine] more clean up of foldICmpXorConstant(); NFCI
Sanjay Patel [Wed, 17 Aug 2016 19:45:18 +0000 (19:45 +0000)]
[InstCombine] more clean up of foldICmpXorConstant(); NFCI

Use m_APInt for the xor constant, but this is all still guarded by the initial
ConstantInt check, so no vector types should make it in here.

llvm-svn: 278957

7 years ago[CodeGen][ObjC] Fix infinite recursion in getObjCEncodingForTypeImpl.
Akira Hatanaka [Wed, 17 Aug 2016 19:42:22 +0000 (19:42 +0000)]
[CodeGen][ObjC] Fix infinite recursion in getObjCEncodingForTypeImpl.

Check that ExpandStructures is true before visiting the list of ivars.

rdar://problem/27135221

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

llvm-svn: 278956

7 years ago[InstCombine] clean up foldICmpXorConstant(); NFCI
Sanjay Patel [Wed, 17 Aug 2016 19:23:42 +0000 (19:23 +0000)]
[InstCombine] clean up foldICmpXorConstant(); NFCI

1. Change variable names
2. Use local variables to reduce code
3. Early exit to reduce indent

llvm-svn: 278955

7 years agoFix for PR29010
Marina Yatsina [Wed, 17 Aug 2016 19:07:40 +0000 (19:07 +0000)]
Fix for PR29010

This is a fix for https://llvm.org/bugs/show_bug.cgi?id=29010
Root cause of the bug is that the register class of the machine instruction operand does not fully reflect if this registers that can be allocated.
Both for i386 and x86_64 the operand's register class is VR128RegClass and thus contains xmm0-xmm15, though in i386 we can only use xmm0-xmm8.
In order to get the actual allocable registers of the class we need to use RegisterClassInfo.

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

llvm-svn: 278954

7 years agoMerge readAt and readAlign.
Rui Ueyama [Wed, 17 Aug 2016 18:59:16 +0000 (18:59 +0000)]
Merge readAt and readAlign.

Now that they are identical.

llvm-svn: 278953

7 years agoModule debug info: Fix a bug in handling record decls without fields.
Adrian Prantl [Wed, 17 Aug 2016 18:27:24 +0000 (18:27 +0000)]
Module debug info: Fix a bug in handling record decls without fields.

The previous condition would erroneously mark all CXXRecordDecls
that didn't have any fields as being defined in a clang module.
This patch fixes the condition to only apply to explicit template
instantiations.

<rdar://problem/27771823>

llvm-svn: 278952

7 years agocleanup: fixed names of dummy arguments of Fortran interfaces declarations, no functi...
Andrey Churbanov [Wed, 17 Aug 2016 18:18:21 +0000 (18:18 +0000)]
cleanup: fixed names of dummy arguments of Fortran interfaces declarations, no functional changes done

llvm-svn: 278951

7 years ago[libFuzzer] more mutations
Kostya Serebryany [Wed, 17 Aug 2016 18:10:42 +0000 (18:10 +0000)]
[libFuzzer] more mutations

llvm-svn: 278950

7 years ago[Include-fixer] Install executables and support scripts
Eugene Zelenko [Wed, 17 Aug 2016 17:27:56 +0000 (17:27 +0000)]
[Include-fixer] Install executables and support scripts

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

llvm-svn: 278949

7 years agoMove tests to the appropriate subdirectory.
Adrian Prantl [Wed, 17 Aug 2016 16:55:56 +0000 (16:55 +0000)]
Move tests to the appropriate subdirectory.

llvm-svn: 278948

7 years agoCorrect makefile.rules to use arm/aarch64 target specific AR and OBJCOPY
Omair Javaid [Wed, 17 Aug 2016 16:45:34 +0000 (16:45 +0000)]
Correct makefile.rules to use arm/aarch64 target specific AR and OBJCOPY

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

llvm-svn: 278947

7 years agoSimplify condition. (NFC)
Adrian Prantl [Wed, 17 Aug 2016 16:42:15 +0000 (16:42 +0000)]
Simplify condition. (NFC)

llvm-svn: 278946

7 years ago[InstCombine] use m_APInt to allow icmp (or X, Y), C folds for splat constant vectors
Sanjay Patel [Wed, 17 Aug 2016 16:38:57 +0000 (16:38 +0000)]
[InstCombine] use m_APInt to allow icmp (or X, Y), C folds for splat constant vectors

This is a sibling of:
https://reviews.llvm.org/rL278859
https://reviews.llvm.org/rL278935

llvm-svn: 278945

7 years ago[InstCombine] clean up foldICmpOrConstant(); NFCI
Sanjay Patel [Wed, 17 Aug 2016 16:30:43 +0000 (16:30 +0000)]
[InstCombine] clean up foldICmpOrConstant(); NFCI

1. Change variable names
2. Use local variables to reduce code
3. Use ? instead of if/else
4. Use the APInt variable instead of 'RHS' so the removal of the FIXME code will be direct

llvm-svn: 278944

7 years ago[InstCombine] add tests for missing vector icmp folds
Sanjay Patel [Wed, 17 Aug 2016 16:23:15 +0000 (16:23 +0000)]
[InstCombine] add tests for missing vector icmp folds

llvm-svn: 278943

7 years agoDebug info: Mark noreturn functions with DIFlagNoReturn.
Adrian Prantl [Wed, 17 Aug 2016 16:20:32 +0000 (16:20 +0000)]
Debug info: Mark noreturn functions with DIFlagNoReturn.

This affects functions with the C++11 [[ noreturn ]] and C11 _Noreturn
specifiers.

Patch by Victor Leschuk!

https://reviews.llvm.org/D23168

llvm-svn: 278942

7 years ago[analyzer] Add a checker for loss of sign or precision in integral casts.
Artem Dergachev [Wed, 17 Aug 2016 16:02:45 +0000 (16:02 +0000)]
[analyzer] Add a checker for loss of sign or precision in integral casts.

This new checker tries to find execution paths on which implicit integral casts
cause definite loss of information: a certainly-negative integer is converted
to an unsigned integer, or an integer is definitely truncated to fit into
a smaller type.

Being implicit, such casts are likely to produce unexpected results.

Patch by Daniel Marjamäki!

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

llvm-svn: 278941

7 years agoSupport the DW_AT_noreturn DWARF flag.
Adrian Prantl [Wed, 17 Aug 2016 16:02:43 +0000 (16:02 +0000)]
Support the DW_AT_noreturn DWARF flag.
This is used to mark functions with the C++11 [[ noreturn ]] or C11 _Noreturn
attributes.

Patch by Victor Leschuk!

https://reviews.llvm.org/D23167

llvm-svn: 278940

7 years agoRevert "Reassociate: Reprocess RedoInsts after each inst".
Chad Rosier [Wed, 17 Aug 2016 15:54:39 +0000 (15:54 +0000)]
Revert "Reassociate: Reprocess RedoInsts after each inst".

This reverts commit r258830, which introduced a bug described in PR28367.

PR28367

llvm-svn: 278938

7 years ago[analyzer] Add LocationContext information to SymbolMetadata.
Artem Dergachev [Wed, 17 Aug 2016 15:37:52 +0000 (15:37 +0000)]
[analyzer] Add LocationContext information to SymbolMetadata.

Like SymbolConjured, SymbolMetadata also needs to be uniquely
identified by the moment of its birth.

Such moments are coded by the (Statement, LocationContext, Block count) triples.
Each such triple represents the moment of analyzing a statement with a certain
call backtrace, with corresponding CFG block having been entered a given amount
of times during analysis of the current code body.

The LocationContext information was accidentally omitted for SymbolMetadata,
which leads to reincarnation of SymbolMetadata upon re-entering a code body
with a different backtrace; the new symbol is incorrectly unified with
the old symbol, which leads to unsound assumptions.

Patch by Alexey Sidorin!

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

llvm-svn: 278937

7 years agoUpdate ISL to isl-0.17.1-200-gd8de4ea.
Michael Kruse [Wed, 17 Aug 2016 15:24:45 +0000 (15:24 +0000)]
Update ISL to isl-0.17.1-200-gd8de4ea.

This version fixes a bug in set coalescing.

llvm-svn: 278936

7 years ago[InstCombine] use m_APInt to allow icmp (add X, Y), C folds for splat constant vectors
Sanjay Patel [Wed, 17 Aug 2016 15:24:30 +0000 (15:24 +0000)]
[InstCombine] use m_APInt to allow icmp (add X, Y), C folds for splat constant vectors

This is a sibling of:
https://reviews.llvm.org/rL278859

llvm-svn: 278935

7 years agoAdapt to TraverseLambdaCapture interface change from D23204
Martin Bohme [Wed, 17 Aug 2016 15:00:22 +0000 (15:00 +0000)]
Adapt to TraverseLambdaCapture interface change from D23204

Summary:
Depends on D23204.

This is intended to be submitted immediately after D23204 lands.

Reviewers: jdennett, alexfh

Subscribers: cfe-commits

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

llvm-svn: 278934

7 years agoVisit lambda capture inits from RecursiveASTVisitor::TraverseLambdaCapture().
Martin Bohme [Wed, 17 Aug 2016 14:59:53 +0000 (14:59 +0000)]
Visit lambda capture inits from RecursiveASTVisitor::TraverseLambdaCapture().

Summary:
rL277342 made RecursiveASTVisitor visit lambda capture initialization
expressions (these are the Exprs in LambdaExpr::capture_inits()).

jdennett identified two issues with rL277342 (see comments there for details):

- It visits initialization expressions for implicit lambda captures, even if
  shouldVisitImplicitCode() returns false.

- It visits initialization expressions for init captures twice (because these
  were already traveresed in TraverseLambdaCapture() before rL277342)

This patch fixes these issues and moves the code for traversing initialization
expressions into TraverseLambdaCapture().

This patch also makes two changes required for the tests:

- It adds Lang_CXX14 to the Language enum in TestVisitor.

- It adds a parameter to ExpectedLocationVisitor::ExpectMatch() that specifies
  the number of times a match is expected to be seen.

Reviewers: klimek, jdennett, alexfh

Subscribers: cfe-commits

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

llvm-svn: 278933

7 years agoClarify the statement on using #if 0 ... #endif in CodingStandards.
Andrey Bokhanko [Wed, 17 Aug 2016 14:53:18 +0000 (14:53 +0000)]
Clarify the statement on using #if 0 ... #endif in CodingStandards.

The statement on using #if 0 ... #endif is not very clear (for people like me
:-)). This patch clarifies it a bit to avoid confusion.

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

llvm-svn: 278932

7 years ago[ELF] - Linkerscript: make readAt() signature to be consistent with others read*...
George Rimar [Wed, 17 Aug 2016 14:48:17 +0000 (14:48 +0000)]
[ELF] - Linkerscript: make readAt() signature to be consistent with others read*(). NFC.

llvm-svn: 278931

7 years ago[mips] Add l.[sd] and s.[sd] instruction aliases
Simon Dardis [Wed, 17 Aug 2016 14:45:09 +0000 (14:45 +0000)]
[mips] Add l.[sd] and s.[sd] instruction aliases

Reviewers: dsanders, vkalintiris

Differential Review: https://reviews.llvm.org/D23121

llvm-svn: 278930

7 years agoRevert "[Reassociate] Avoid iterator invalidation when negating value."
Chad Rosier [Wed, 17 Aug 2016 14:31:34 +0000 (14:31 +0000)]
Revert "[Reassociate] Avoid iterator invalidation when negating value."

This reverts commit r278928 due to lit test failures.

llvm-svn: 278929

7 years ago[Reassociate] Avoid iterator invalidation when negating value.
Chad Rosier [Wed, 17 Aug 2016 14:16:45 +0000 (14:16 +0000)]
[Reassociate] Avoid iterator invalidation when negating value.

Differential Revision: https://reviews.llvm.org/D23464
PR28367

llvm-svn: 278928

7 years ago[LoopStrenghtReduce] Refactoring and addition of a new target cost function.
Jonas Paulsson [Wed, 17 Aug 2016 13:24:19 +0000 (13:24 +0000)]
[LoopStrenghtReduce] Refactoring and addition of a new target cost function.

Refactored so that a LSRUse owns its fixups, as oppsed to letting the
LSRInstance own them. This makes it easier to rate formulas for
LSRUses, since the fixups are available directly. The Offsets vector
has been removed since it was no longer necessary.

New target hook isFoldableMemAccessOffset(), which is used during formula
rating.

For SystemZ, this is useful to express that loads and stores with
float or vector types with a big/negative offset should be avoided in
loops. Without this, LSR will generate a lot of negative offsets that
would require extra instructions for loading the address.

Updated tests:
test/CodeGen/SystemZ/loop-01.ll

Reviewed by: Quentin Colombet and Ulrich Weigand.
https://reviews.llvm.org/D19152

llvm-svn: 278927

7 years agoAdd an AST matcher for external formal linkage.
Aaron Ballman [Wed, 17 Aug 2016 13:10:42 +0000 (13:10 +0000)]
Add an AST matcher for external formal linkage.

Patch by Visoiu Mistrih

llvm-svn: 278926

7 years agoFix unittests on windows after r278915
Pavel Labath [Wed, 17 Aug 2016 12:00:19 +0000 (12:00 +0000)]
Fix unittests on windows after r278915

Apparently clang will happily capture a const variable in a lambda without it being specified in
the capture clause. MSVC does not like that.

llvm-svn: 278925

7 years agoRemove cmake legacy code
Pavel Labath [Wed, 17 Aug 2016 11:55:50 +0000 (11:55 +0000)]
Remove cmake legacy code

Summary: Cmake 2.8 support is gone and not coming back. We can remove a bit of legacy code now.

Reviewers: zturner

Subscribers: lldb-commits

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

llvm-svn: 278924

7 years agoFixing bug committed in rev. 278321
Marina Yatsina [Wed, 17 Aug 2016 11:40:21 +0000 (11:40 +0000)]
Fixing bug committed in rev. 278321

In theory the indices of RC (and thus the index used for LiveRegs) may differ from the indices of OpRC.
Fixed the code to extract the correct RC index.
OpRC contains the first X consecutive elements of RC, and thus their indices are currently de facto the same, therefore a test cannot be added at this point.

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

llvm-svn: 278923

7 years ago[include-fixer] Update -help message.
Haojian Wu [Wed, 17 Aug 2016 11:31:19 +0000 (11:31 +0000)]
[include-fixer] Update -help message.

llvm-svn: 278922

7 years ago[AMDGPU] llvm-objdump: Skip amd_kernel_code_t only at the begining of kernel symbol.
Sam Kolton [Wed, 17 Aug 2016 10:17:57 +0000 (10:17 +0000)]
[AMDGPU] llvm-objdump: Skip amd_kernel_code_t only at the begining of kernel symbol.

Summary: This change fix bug in AMDGPU disassembly. Previously, presence of symbols other than kernel symbols caused objdump to skip begining of those symbols.

Reviewers: tstellarAMD, vpykhtin, Bigcheese, ruiu

Subscribers: kzhuravl, arsenm

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

llvm-svn: 278921

7 years agoLiveIntervals: add removeRegUnit
Nicolai Haehnle [Wed, 17 Aug 2016 09:34:55 +0000 (09:34 +0000)]
LiveIntervals: add removeRegUnit

Summary:
See D22198 for the motivation: We have a pass that uses LiveIntervals anyway,
and there is now a requirement to track a physical register that is not
usually tracked at this point of the compilation. The pass also introduces
instructions that affect this physical register, but we want to preserve
LiveIntervals.

Rather than add brittle and rarely exercised code to keep the tracking of
the physical register intact, we want to just remove the corresponding
LiveRange -- it didn't exist before anyway, and subsequent passes don't
expect it to be there.

Reviewers: MatzeB, arsenm

Subscribers: llvm-commits, MatzeB

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

llvm-svn: 278920

7 years agoDeal with buildbot fallout from r278917: s/AllocType()/GetAllocType()/ (had the same...
Filipe Cabecinhas [Wed, 17 Aug 2016 09:24:33 +0000 (09:24 +0000)]
Deal with buildbot fallout from r278917: s/AllocType()/GetAllocType()/ (had the same name as the enum)

llvm-svn: 278919

7 years agoFix unittest compilation error in r278915
Pavel Labath [Wed, 17 Aug 2016 09:17:08 +0000 (09:17 +0000)]
Fix unittest compilation error in r278915

llvm-svn: 278918

7 years agoRename DescribeHeapAddress to DescribeAddressIfHeap and split it into a function...
Filipe Cabecinhas [Wed, 17 Aug 2016 09:16:08 +0000 (09:16 +0000)]
Rename DescribeHeapAddress to DescribeAddressIfHeap and split it into a function to get all the information about the address, and one to print it.

Summary:
Replacement for part of D23518
This deals with heap addresses, and renames DescribeHeapAddress.
Requires D23520, which moves code around to make it accessible in asan_describers.cc (and still accessible in asan_report.cc if needed).

Reviewers: kcc, samsonov

Subscribers: kubabrecka, llvm-commits

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

llvm-svn: 278917

7 years agoRemove manual packet construction from GDBRemoteRegisterContext::SetPrimordialRegister
Pavel Labath [Wed, 17 Aug 2016 09:12:21 +0000 (09:12 +0000)]
Remove manual packet construction from GDBRemoteRegisterContext::SetPrimordialRegister

llvm-svn: 278916

7 years agoMove packet construction from GDBRemoteRegisterContext go the communication class
Pavel Labath [Wed, 17 Aug 2016 08:53:31 +0000 (08:53 +0000)]
Move packet construction from GDBRemoteRegisterContext go the communication class

Summary:
When saving/restoring registers the GDBRemoteRegisterContext class was manually constructing
the register save/restore packets. This creates appropriate helper functions in
GDBRemoteCommunicationClient, and switches the class to use those. It also removes what a
duplicate packet send in some of those functions, a thing that I can only attribute to a bad
merge artefact.

I also add a test framework for testing gdb-remote client functionality and add tests for the new
functions I introduced. I'd like to be able to test the register context changes in isolation as
well, but currently there doesn't seem to be a way to reasonably construct a standalone register
context object, so we'll have to rely on the end-to-end tests to verify that.

Reviewers: clayborg

Subscribers: lldb-commits

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

llvm-svn: 278915

7 years agoAttemp to fix linux build bot after r278911 ("[ELF] - linkerscript AT keyword (in...
George Rimar [Wed, 17 Aug 2016 08:16:57 +0000 (08:16 +0000)]
Attemp to fix linux build bot after r278911 ("[ELF] - linkerscript AT keyword (in output section description) implemented.")

http://lab.llvm.org:8011/builders/lld-x86_64-darwin13/builds/26289/steps/build_Lld/logs/stdio

llvm-svn: 278914

7 years agoFix bug in DAGBuilder for getelementptr with expanded vector.
Ayman Musa [Wed, 17 Aug 2016 07:52:15 +0000 (07:52 +0000)]
Fix bug in DAGBuilder for getelementptr with expanded vector.

Replacing the usage of MVT with EVT in case the vector type is expanded.
Differential Revision: https://reviews.llvm.org/D23306

llvm-svn: 278913

7 years ago[LTO] Fix a use-after-free introduced in r278907 and caught by ASan.
Chandler Carruth [Wed, 17 Aug 2016 07:48:34 +0000 (07:48 +0000)]
[LTO] Fix a use-after-free introduced in r278907 and caught by ASan.

The ASan build bot caught this right away:
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/15580/steps/check-llvm%20asan/logs/stdio

This was also breaking a Windows build bot I'm pretty sure.

llvm-svn: 278912

7 years ago[ELF] - linkerscript AT keyword (in output section description) implemented.
George Rimar [Wed, 17 Aug 2016 07:44:19 +0000 (07:44 +0000)]
[ELF] - linkerscript AT keyword (in output section description) implemented.

The linker will normally set the LMA equal to the VMA.
You can change that by using the AT keyword.
The expression lma that follows the AT keyword specifies
the load address of the section.

Patch implements this keyword.

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

llvm-svn: 278911

7 years agoFirst commit (test commit) - Adding empty line.
Ayman Musa [Wed, 17 Aug 2016 07:37:34 +0000 (07:37 +0000)]
First commit (test commit) - Adding empty line.

llvm-svn: 278910

7 years agoRestrict the use of the C++17 attribute to C++17 (at least as best we
Chandler Carruth [Wed, 17 Aug 2016 07:18:44 +0000 (07:18 +0000)]
Restrict the use of the C++17 attribute to C++17 (at least as best we
can given the current __cplusplus definitions).

Without this, Clang triggers TONS of warnings about using a C++17
extension. I tried using LLVM_EXTENSION to turn these off and it doesn't
work.

Suggestions on a better approach are welcome, but at least this makes
the build usable for me again.

llvm-svn: 278909

7 years agoAdd missing tests
Roger Ferrer Ibanez [Wed, 17 Aug 2016 06:52:15 +0000 (06:52 +0000)]
Add missing tests

Change r278483 was missing the tests

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

llvm-svn: 278908

7 years ago[LTO] Introduce an Output class to wrap the output stream creation (NFC)
Mehdi Amini [Wed, 17 Aug 2016 06:23:09 +0000 (06:23 +0000)]
[LTO] Introduce an Output class to wrap the output stream creation (NFC)

Summary:
While NFC for now, this will allow more flexibility on the client side
to hold state necessary to back up the stream.
Also when adding caching, this class will grow in complexity.

Note I blindly modified the gold-plugin as I can't compile it.

Reviewers: tejohnson

Subscribers: mehdi_amini, llvm-commits

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

llvm-svn: 278907

7 years ago[ThinLTO] Adapt backend invocation to llvm API changes.
Mehdi Amini [Wed, 17 Aug 2016 06:23:08 +0000 (06:23 +0000)]
[ThinLTO] Adapt backend invocation to llvm API changes.

Reviewers: tejohnson

Subscribers: mehdi_amini, llvm-commits

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

llvm-svn: 278906

7 years agoSupport allocators with explicit conversion constructors. Fixes bug #29000
Marshall Clow [Wed, 17 Aug 2016 05:58:40 +0000 (05:58 +0000)]
Support allocators with explicit conversion constructors. Fixes bug #29000

llvm-svn: 278904

7 years agoFix a use of LLVM_FALLTHROUGH that wasn't even in a switch.
Justin Bogner [Wed, 17 Aug 2016 05:25:38 +0000 (05:25 +0000)]
Fix a use of LLVM_FALLTHROUGH that wasn't even in a switch.

I was over-aggressive in my conversions from comments to the
fallthrough attribute.

llvm-svn: 278903

7 years agoReplace "fallthrough" comments with LLVM_FALLTHROUGH
Justin Bogner [Wed, 17 Aug 2016 05:10:15 +0000 (05:10 +0000)]
Replace "fallthrough" comments with LLVM_FALLTHROUGH

This is a mechanical change of comments in switches like fallthrough,
fall-through, or fall-thru to use the LLVM_FALLTHROUGH macro instead.

llvm-svn: 278902

7 years agoFix the RangeMapVector::FindEntryThatContainsOrFollows method to
Jason Molenda [Wed, 17 Aug 2016 03:56:04 +0000 (03:56 +0000)]
Fix the RangeMapVector::FindEntryThatContainsOrFollows method to
back up the iterator, as long as it still contains the address.
std::lower_bound will point us to the entry after the one we
are really interested in, leading to problems with backtracing
in corefiles.

<rdar://problem/27823549>

llvm-svn: 278901

7 years ago[ppc64] Don't apply sibling call optimization if callee has any byval arg
Chuang-Yu Cheng [Wed, 17 Aug 2016 03:17:44 +0000 (03:17 +0000)]
[ppc64] Don't apply sibling call optimization if callee has any byval arg

This is a quick work around, because in some cases, e.g. caller's stack
size > callee's stack size, we are still able to apply sibling call
optimization even callee has any byval arg.

This patch fix: https://llvm.org/bugs/show_bug.cgi?id=28328

Reviewers: hfinkel kbarton nemanjai amehsan
Subscribers: hans, tjablin

https://reviews.llvm.org/D23441

llvm-svn: 278900

7 years agoRemove the Triple tests that stressing the TargetParser's behaviour.
Zijiao Ma [Wed, 17 Aug 2016 03:17:07 +0000 (03:17 +0000)]
Remove the Triple tests that stressing the TargetParser's behaviour.

Now the tests of TargetParser is in place:
unittests/Support/TargetParserTest.cpp.
So the tests in TripleTest.cpp which actually stressing TargetParser's behavior could be removed.

llvm-svn: 278899

7 years agoCodeGen: Avoid dereferencing end() in ScalarExprEmitter::EmitOverflowCheckedBinOp
Duncan P. N. Exon Smith [Wed, 17 Aug 2016 03:15:29 +0000 (03:15 +0000)]
CodeGen: Avoid dereferencing end() in ScalarExprEmitter::EmitOverflowCheckedBinOp

Use BB.getNextNode(), which returns nullptr on end(), instead of
&*BB.getIterator(), which is UB on end().
CodeGenFunction::createBasicBlock expects nullptr in this case already.

llvm-svn: 278898

7 years ago[PM] Update Clang for LLVM's r278896 which re-organized a header.
Chandler Carruth [Wed, 17 Aug 2016 03:09:11 +0000 (03:09 +0000)]
[PM] Update Clang for LLVM's r278896 which re-organized a header.

(sorry this didn't get landed closer in time...)

llvm-svn: 278897

7 years ago[PM] Port the always inliner to the new pass manager in a much more
Chandler Carruth [Wed, 17 Aug 2016 02:56:20 +0000 (02:56 +0000)]
[PM] Port the always inliner to the new pass manager in a much more
minimal and boring form than the old pass manager's version.

This pass does the very minimal amount of work necessary to inline
functions declared as always-inline. It doesn't support a wide array of
things that the legacy pass manager did support, but is alse ... about
20 lines of code. So it has that going for it. Notably things this
doesn't support:

- Array alloca merging
  - To support the above, bottom-up inlining with careful history
    tracking and call graph updates
- DCE of the functions that become dead after this inlining.
- Inlining through call instructions with the always_inline attribute.
  Instead, it focuses on inlining functions with that attribute.

The first I've omitted because I'm hoping to just turn it off for the
primary pass manager. If that doesn't pan out, I can add it here but it
will be reasonably expensive to do so.

The second should really be handled by running global-dce after the
inliner. I don't want to re-implement the non-trivial logic necessary to
do comdat-correct DCE of functions. This means the -O0 pipeline will
have to be at least 'always-inline,global-dce', but that seems
reasonable to me. If others are seriously worried about this I'd like to
hear about it and understand why. Again, this is all solveable by
factoring that logic into a utility and calling it here, but I'd like to
wait to do that until there is a clear reason why the existing
pass-based factoring won't work.

The final point is a serious one. I can fairly easily add support for
this, but it seems both costly and a confusing construct for the use
case of the always inliner running at -O0. This attribute can of course
still impact the normal inliner easily (although I find that
a questionable re-use of the same attribute). I've started a discussion
to sort out what semantics we want here and based on that can figure out
if it makes sense ta have this complexity at O0 or not.

One other advantage of this design is that it should be quite a bit
faster due to checking for whether the function is a viable candidate
for inlining exactly once per function instead of doing it for each call
site.

Anyways, hopefully a reasonable starting point for this pass.

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

llvm-svn: 278896

7 years agoIfConversion: Use references instead of pointers where possible; NFC
Matthias Braun [Wed, 17 Aug 2016 02:52:01 +0000 (02:52 +0000)]
IfConversion: Use references instead of pointers where possible; NFC

Also put some commonly used subexpressions into variables.

llvm-svn: 278895

7 years agoIfConversion: Use range based for; NFC
Matthias Braun [Wed, 17 Aug 2016 02:51:59 +0000 (02:51 +0000)]
IfConversion: Use range based for; NFC

Also avoid some pointless use of auto! Because that's friendlier to
readers and avoids several types accidentally resolving to unnecessary
references here (MachineInstr *&, unsigned &).

llvm-svn: 278894

7 years agoIfConversion: Improve doxygen comments
Matthias Braun [Wed, 17 Aug 2016 02:51:57 +0000 (02:51 +0000)]
IfConversion: Improve doxygen comments

llvm-svn: 278893

7 years ago[Inliner] Add a flag to disable manual alloca merging in the Inliner.
Chandler Carruth [Wed, 17 Aug 2016 02:40:23 +0000 (02:40 +0000)]
[Inliner] Add a flag to disable manual alloca merging in the Inliner.

This is off for now while testing can take place to make sure that in
fact we do sufficient stack coloring to fully obviate the manual alloca
array merging.

Some context on why we should be using stack coloring rather than
merging allocas in this way:

LLVM relies very heavily on analyzing pointers as coming from different
allocas in order to make aliasing decisions. These are some of the most
powerful aliasing signals available in LLVM. So merging allocas is an
extremely destructive operation on the LLVM IR -- it takes away highly
valuable and hard to reconstruct information.

As a consequence, inlined functions which happen to have array allocas
that this pattern matches will fail to be properly interleaved unless
SROA manages to hoist everything to an SSA register. Instead, the
inliner will have added an unnecessary dependence that one inlined
function execute after the other because they will have been rewritten
to refer to the same memory.

All that said, folks will reasonably want some time to experiment here
and make sure there are no significant regressions. A flag should give
us an easy knob to test.

For more context, see the thread here:
http://lists.llvm.org/pipermail/llvm-dev/2016-July/103277.html
http://lists.llvm.org/pipermail/llvm-dev/2016-August/103285.html

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

llvm-svn: 278892

7 years agoAdd missing close brace to fix Windows bots. Oops :(
Richard Smith [Wed, 17 Aug 2016 02:22:39 +0000 (02:22 +0000)]
Add missing close brace to fix Windows bots. Oops :(

llvm-svn: 278891

7 years agoSome missing usage of TargetParser. NFC.
Zijiao Ma [Wed, 17 Aug 2016 02:13:33 +0000 (02:13 +0000)]
Some missing usage of TargetParser. NFC.

llvm-svn: 278890

7 years ago[ELF] Set MAXPAGESIZE to 2MiB on x86-64 to match bfd and gold.
Michael J. Spencer [Wed, 17 Aug 2016 02:10:51 +0000 (02:10 +0000)]
[ELF] Set MAXPAGESIZE to 2MiB on x86-64 to match bfd and gold.

The FreeBSD kernel relies on this behavior to not overwrite the boot loader.

llvm-svn: 278889

7 years agoSome places that could using TargetParser in LLVM. NFC.
Zijiao Ma [Wed, 17 Aug 2016 02:08:28 +0000 (02:08 +0000)]
Some places that could using TargetParser in LLVM. NFC.

llvm-svn: 278888