platform/upstream/llvm.git
8 years ago[PM] Port LoopUnroll.
Sean Silva [Tue, 19 Jul 2016 23:54:23 +0000 (23:54 +0000)]
[PM] Port LoopUnroll.

We just set PreserveLCSSA to always true since we don't have an
analogous method `mustPreserveAnalysisID(LCSSA)`.

Also port LoopInfo verifier pass to test LoopUnrollPass.

llvm-svn: 276063

8 years agoCodegen: Factor out canTailDuplicate
Kyle Butt [Tue, 19 Jul 2016 23:54:21 +0000 (23:54 +0000)]
Codegen: Factor out canTailDuplicate

canTailDuplicate accepts two blocks and returns true if the first can be
duplicated into the second successfully. Use this function to
encapsulate the heuristic.

llvm-svn: 276062

8 years agoFix an issue where the libc++ std::list formatter wasn't recognizing the new memory...
Enrico Granata [Tue, 19 Jul 2016 23:50:31 +0000 (23:50 +0000)]
Fix an issue where the libc++ std::list formatter wasn't recognizing the new memory layout correctly

rdar://problem/26999542

llvm-svn: 276061

8 years agoThis code block breaks the docs build (http://lab.llvm.org:8011/builders/llvm-sphinx...
Aaron Ballman [Tue, 19 Jul 2016 23:50:11 +0000 (23:50 +0000)]
This code block breaks the docs build (lab.llvm.org:8011/builders/llvm-sphinx-docs/builds/11925/steps/docs-llvm-html/logs/stdio). Setting the code highlighting to none instead of llvm.

llvm-svn: 276060

8 years agoAdd heterogeneous comparator support for __debug_less. Fixes PR17147.
Eric Fiselier [Tue, 19 Jul 2016 23:27:18 +0000 (23:27 +0000)]
Add heterogeneous comparator support for __debug_less. Fixes PR17147.

llvm-svn: 276059

8 years ago[ADT] Warn on unused results from ArrayRef and StringRef functions that read like...
Justin Lebar [Tue, 19 Jul 2016 23:19:25 +0000 (23:19 +0000)]
[ADT] Warn on unused results from ArrayRef and StringRef functions that read like they might mutate.

Summary:
Functions like "slice" and "drop_front" sound like they might mutate the
underlying object, but they don't.  Warning on unused results would have
saved me an hour yesterday, and I'm sure I'm not the only one.

LLVM and Clang are clean wrt this warning after D22540.

Reviewers: majnemer

Subscribers: sanjoy, chandlerc, llvm-commits

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

llvm-svn: 276058

8 years agoGet rid of call to StringRef::substr that's never used.
Justin Lebar [Tue, 19 Jul 2016 23:19:22 +0000 (23:19 +0000)]
Get rid of call to StringRef::substr that's never used.

Summary: substr doesn't modify the string, so this line has no effect.

Reviewers: majnemer

Subscribers: llvm-commits

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

llvm-svn: 276057

8 years ago[LSV] Insert stores at the right point.
Justin Lebar [Tue, 19 Jul 2016 23:19:20 +0000 (23:19 +0000)]
[LSV] Insert stores at the right point.

Summary:
Previously, the insertion point for stores was the last instruction in
Chain *before calling getVectorizablePrefixEndIdx*.  Thus if
getVectorizablePrefixEndIdx didn't return Chain.size(), we still would
insert at the last instruction in Chain.

This patch changes our internal API a bit in an attempt to make it less
prone to this sort of error.  As a result, we end up recalculating the
Chain's boundary instructions, but I think worrying about the speed hit
of this is a premature optimization right now.

Reviewers: asbirlea, tstellarAMD

Subscribers: mzolotukhin, arsenm, llvm-commits

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

llvm-svn: 276056

8 years ago[LSV] Use make_range, and reformat a DEBUG message. NFC
Justin Lebar [Tue, 19 Jul 2016 23:19:18 +0000 (23:19 +0000)]
[LSV] Use make_range, and reformat a DEBUG message. NFC

Summary:
The DEBUG message was hard to read because two Values were being printed
on the same line with only the delimiter "aliases".  This change makes
us print each Value on its own line.

Reviewers: asbirlea

Subscribers: llvm-commits, arsenm, mzolotukhin

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

llvm-svn: 276055

8 years ago[LSV] Nix two global (ish) variables in the LoadStoreVectorizer. NFC
Justin Lebar [Tue, 19 Jul 2016 23:19:16 +0000 (23:19 +0000)]
[LSV] Nix two global (ish) variables in the LoadStoreVectorizer.  NFC

Reviewers: asbirlea

Subscribers: mzolotukhin, llvm-commits, arsenm

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

llvm-svn: 276054

8 years ago[LSV] Add detail to correct-order.ll test.
Justin Lebar [Tue, 19 Jul 2016 23:18:59 +0000 (23:18 +0000)]
[LSV] Add detail to correct-order.ll test.

Summary:
This helps keep us honest -- there were a number of ways we could screw
up and still have passed this test.

Reviewers: asbirlea

Subscribers: llvm-commits, arsenm

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

llvm-svn: 276053

8 years ago[libFuzzer] extend the messages printed by afl_driver
Kostya Serebryany [Tue, 19 Jul 2016 23:18:28 +0000 (23:18 +0000)]
[libFuzzer] extend the messages printed by afl_driver

llvm-svn: 276052

8 years agoAMDGPU: Change fdiv lowering based on !fpmath metadata
Matt Arsenault [Tue, 19 Jul 2016 23:16:53 +0000 (23:16 +0000)]
AMDGPU: Change fdiv lowering based on !fpmath metadata

If 2.5 ulp is acceptable, denormals are not required, and
isn't a reciprocal which will already be handled, replace
with a faster fdiv.

Simplify the lowering tests by using per function
subtarget features.

llvm-svn: 276051

8 years agoFix unused variable
Daniel Berlin [Tue, 19 Jul 2016 23:08:08 +0000 (23:08 +0000)]
Fix unused variable

llvm-svn: 276050

8 years ago[libcxx] Add support for benchmark tests using Google Benchmark.
Eric Fiselier [Tue, 19 Jul 2016 23:07:03 +0000 (23:07 +0000)]
[libcxx] Add support for benchmark tests using Google Benchmark.

Summary:
This patch does the following:

1. Checks in a copy of the Google Benchmark library into the libc++ repo under `utils/google-benchmark`.
2. Teaches libc++ how to build Google Benchmark against both (A) in-tree libc++ and (B) the platforms native STL.
3. Allows performance benchmarks to be built as part of the libc++ build.

Building the benchmarks (and Google Benchmark) is off by default. It must be enabled using the CMake option `-DLIBCXX_INCLUDE_BENCHMARKS=ON`. When this option is enabled the tests under `libcxx/benchmarks`  can be built using the `libcxx-benchmarks` target.

On Linux platforms where libstdc++ is the default STL the CMake option `-DLIBCXX_BUILD_BENCHMARKS_NATIVE_STDLIB=ON` can be used to build each benchmark test against libstdc++ as well. This is useful for comparing performance between standard libraries.

Support for benchmarks is currently very minimal. They must be manually run by the user and there is no mechanism for detecting performance regressions.

Known Issues:

* `-DLIBCXX_INCLUDE_BENCHMARKS=ON` is only supported for Clang, and not GCC, since the `-stdlib=libc++` option is needed to build Google Benchmark.

Reviewers: danalbert, dberlin, chandlerc, mclow.lists, jroelofs

Subscribers: chandlerc, dberlin, tberghammer, danalbert, srhines, hfinkel

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

llvm-svn: 276049

8 years agoMake GVN Hoisting obey optnone/bisect.
Paul Robinson [Tue, 19 Jul 2016 22:57:14 +0000 (22:57 +0000)]
Make GVN Hoisting obey optnone/bisect.

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

llvm-svn: 276048

8 years agoMake MemorySSA::dominates/locallydominates constant time
Daniel Berlin [Tue, 19 Jul 2016 22:49:43 +0000 (22:49 +0000)]
Make MemorySSA::dominates/locallydominates constant time

Summary: Make MemorySSA::dominates/locallydominates constant time

Reviewers: george.burgess.iv, gberry

Subscribers: llvm-commits

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

llvm-svn: 276046

8 years agoAdd AIX support to Path.inc, Host.h, and CMake.
Chandler Carruth [Tue, 19 Jul 2016 22:46:39 +0000 (22:46 +0000)]
Add AIX support to Path.inc, Host.h, and CMake.

Patch by Andrew Paprocki!

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

llvm-svn: 276045

8 years agoRegScavenging: Add scavengeRegisterBackwards()
Matthias Braun [Tue, 19 Jul 2016 22:37:09 +0000 (22:37 +0000)]
RegScavenging: Add scavengeRegisterBackwards()

This is a variant of scavengeRegister() that works for
enterBasicBlockEnd()/backward(). The benefit of the backward mode is
that it is not affected by incomplete kill flags.

This patch also changes
PrologEpilogInserter::doScavengeFrameVirtualRegs() to use the register
scavenger in backwards mode.

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

llvm-svn: 276044

8 years agoRegisterScavenger: Introduce backward() mode.
Matthias Braun [Tue, 19 Jul 2016 22:37:02 +0000 (22:37 +0000)]
RegisterScavenger: Introduce backward() mode.

This adds two pieces:
- RegisterScavenger:::enterBasicBlockEnd() which behaves similar to
  enterBasicBlock() but starts tracking at the end of the basic block.
- A RegisterScavenger::backward() method. It is subtly different
  from the existing unprocess() method which only considers uses with
  the kill flag set: If a value is dead at the end of a basic block with
  a last use inside the basic block, unprocess() will fail to mark it as
  live. However we cannot change/fix this behaviour because unprocess()
  needs to perform the exact reverse operation of forward().

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

llvm-svn: 276043

8 years agoregenerate checks
Sanjay Patel [Tue, 19 Jul 2016 22:32:15 +0000 (22:32 +0000)]
regenerate checks

llvm-svn: 276042

8 years ago[AArch64] Properly validate the reciprocal estimation.
Evandro Menezes [Tue, 19 Jul 2016 22:31:11 +0000 (22:31 +0000)]
[AArch64] Properly validate the reciprocal estimation.

Add check for legal data types when expanding into a Newton series.

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

llvm-svn: 276041

8 years ago[Profile] Test cleanup -- use new lit var for IR PGO tests /NFC
Xinliang David Li [Tue, 19 Jul 2016 22:12:00 +0000 (22:12 +0000)]
[Profile] Test cleanup -- use new lit var for IR PGO tests /NFC

llvm-svn: 276036

8 years ago[InstCombine] fold add(zext(xor X, C), C) --> sext X when C is INT_MIN in the source...
Sanjay Patel [Tue, 19 Jul 2016 22:09:34 +0000 (22:09 +0000)]
[InstCombine] fold add(zext(xor X, C), C) --> sext X when C is INT_MIN in the source type

The pattern may look more obviously like a sext if written as:

  define i32 @g(i16 %x) {
    %zext = zext i16 %x to i32
    %xor = xor i32 %zext, 32768
    %add = add i32 %xor, -32768
    ret i32 %add
  }

We already have that fold in visitAdd().

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

llvm-svn: 276035

8 years ago[Profile] Introduce lit test vars for IR based instrumentation
Xinliang David Li [Tue, 19 Jul 2016 21:55:55 +0000 (21:55 +0000)]
[Profile] Introduce lit test vars for IR based instrumentation

llvm-svn: 276034

8 years agoDon't check the value of the unset variables on iOS
Enrico Granata [Tue, 19 Jul 2016 21:50:39 +0000 (21:50 +0000)]
Don't check the value of the unset variables on iOS

llvm-svn: 276033

8 years agoAttempt to appease MSVC buildbots.
George Burgess IV [Tue, 19 Jul 2016 21:35:47 +0000 (21:35 +0000)]
Attempt to appease MSVC buildbots.

Broken by r276026.

llvm-svn: 276032

8 years ago[asan] trying to fix the android bot
Kostya Serebryany [Tue, 19 Jul 2016 21:35:01 +0000 (21:35 +0000)]
[asan] trying to fix the android bot

llvm-svn: 276031

8 years ago[AMDGPU] Remove spurious line (should've been removed in r276029).
Davide Italiano [Tue, 19 Jul 2016 21:16:30 +0000 (21:16 +0000)]
[AMDGPU] Remove spurious line (should've been removed in r276029).

llvm-svn: 276030

8 years ago[AMDGPU] Remove dead code.
Davide Italiano [Tue, 19 Jul 2016 21:10:49 +0000 (21:10 +0000)]
[AMDGPU] Remove dead code.

LGTM'd by Matt Arsenault.

llvm-svn: 276029

8 years ago[CFLAA] Make a test tell the truth. NFC.
George Burgess IV [Tue, 19 Jul 2016 20:56:41 +0000 (20:56 +0000)]
[CFLAA] Make a test tell the truth. NFC.

Dishonesty noted by Jia Chen.

llvm-svn: 276028

8 years ago[Profile] introduce reusable internal interfaces to find dir separator \NFC
Xinliang David Li [Tue, 19 Jul 2016 20:48:00 +0000 (20:48 +0000)]
[Profile] introduce reusable internal interfaces to find dir separator \NFC

llvm-svn: 276027

8 years ago[CFLAA] Add some interproc. analysis to CFLAnders.
George Burgess IV [Tue, 19 Jul 2016 20:47:15 +0000 (20:47 +0000)]
[CFLAA] Add some interproc. analysis to CFLAnders.

This patch adds function summary support to CFLAnders. It also comes
with a lot of tests! Woohoo!

Patch by Jia Chen.

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

llvm-svn: 276026

8 years agoNext step along the way to getting good error messages for bad archives.
Kevin Enderby [Tue, 19 Jul 2016 20:47:07 +0000 (20:47 +0000)]
Next step along the way to getting good error messages for bad archives.

This step builds on Lang Hames work to change Archive::child_iterator
for better interoperation with Error/Expected.  Building on that it is now
possible to return an error message when the size field of an archive
contains non-decimal characters.

llvm-svn: 276025

8 years agoadd even more missing tests for simplifySelectBitTest()
Sanjay Patel [Tue, 19 Jul 2016 20:47:00 +0000 (20:47 +0000)]
add even more missing tests for simplifySelectBitTest()

llvm-svn: 276024

8 years ago[CFLAA] Teach CFLAnders to distinguish reads from writes.
George Burgess IV [Tue, 19 Jul 2016 20:38:21 +0000 (20:38 +0000)]
[CFLAA] Teach CFLAnders to distinguish reads from writes.

This patch adds more specific edges to CFLAndersAliasAnalysis. The goal
of these edges is to give us more information about *how* two values
that MayAlias alias. With this, we can now tell cases like

a = b; // ergo, a may alias b

apart from

a = c;
b = c;

// so, a may alias b, but only because they were both assigned to c.

...And others.

Patch by Jia Chen.

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

llvm-svn: 276023

8 years agoAttempt to bring peace to -Werror buildbots.
Richard Smith [Tue, 19 Jul 2016 20:35:09 +0000 (20:35 +0000)]
Attempt to bring peace to -Werror buildbots.

llvm-svn: 276022

8 years ago[Profile] move utility interfaces to the right header /NFC
Xinliang David Li [Tue, 19 Jul 2016 20:31:46 +0000 (20:31 +0000)]
[Profile] move utility interfaces to the right header /NFC

llvm-svn: 276021

8 years ago[SemaObjC] Improve ObjCDictionaryLiteral and ObjCArryLiteral diagnostics
Bruno Cardoso Lopes [Tue, 19 Jul 2016 20:21:18 +0000 (20:21 +0000)]
[SemaObjC] Improve ObjCDictionaryLiteral and ObjCArryLiteral diagnostics

Sema actions on ObjCDictionaryLiteral and ObjCArryLiteral are currently
done as a side-effect of Sema upon parent expressions, which incurs of
delayed typo corrections for such literals to be performed by TypoTransforms
upon the ObjCDictionaryLiteral and ObjCArryLiteral themselves instead of
its elements individually.

This is specially bad because it was not designed to act on several
elements; searching through all possible combinations of corrections for
several elements is very expensive. Additionally, when one of the
elements has no correction candidate, we still explore all options and
at the end emit no typo corrections whatsoever.

Do the proper sema actions by acting on each element alone during appropriate
literal parsing time to get proper diagonistics and decent compile time
behavior.

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

rdar://problem/21046678

llvm-svn: 276020

8 years ago[Profile] use portable macro /NFC
Xinliang David Li [Tue, 19 Jul 2016 20:20:20 +0000 (20:20 +0000)]
[Profile] use portable macro /NFC

llvm-svn: 276019

8 years agoThis code block breaks the docs build (http://lab.llvm.org:8011/builders/llvm-sphinx...
Aaron Ballman [Tue, 19 Jul 2016 20:20:03 +0000 (20:20 +0000)]
This code block breaks the docs build (lab.llvm.org:8011/builders/llvm-sphinx-docs/builds/11921/steps/docs-llvm-html/logs/stdio). Setting the code highlighting to none instead of llvm to hopefully get the bot stumbling back towards green.

llvm-svn: 276018

8 years agoUse posix_fallocate instead of ftruncate.
Rafael Espindola [Tue, 19 Jul 2016 20:19:56 +0000 (20:19 +0000)]
Use posix_fallocate instead of ftruncate.

This makes sure that space is actually available. With this change
running lld on a full file system causes it to exit with

failed to open foo: No space left on device

instead of crashing with a sigbus.

llvm-svn: 276017

8 years ago[libcxxabi] When catching an exception of type nullptr_t with a handler of
Richard Smith [Tue, 19 Jul 2016 20:19:37 +0000 (20:19 +0000)]
[libcxxabi] When catching an exception of type nullptr_t with a handler of
pointer-to-member type, produce a null value of the right type.

This fixes a bug where throwing an exception of type nullptr_t and catching it
as a pointer-to-member would not guarantee to produce a null value in the catch
handler. The fix is pretty simple: we statically allocate a constant null
pointer-to-data-member representation and a constant null
pointer-to-member-function representation, and produce the address of the
relevant value as the adjusted pointer for the exception.

llvm-svn: 276016

8 years ago[tsan] Don't instrument __llvm_gcov_global_state_pred or __llvm_gcda*
Vedant Kumar [Tue, 19 Jul 2016 20:16:08 +0000 (20:16 +0000)]
[tsan] Don't instrument __llvm_gcov_global_state_pred or __llvm_gcda*

r274801 did not go far enough to allow gcov+tsan to cooperate. With this
commit it's possible to run the following code without false positives:

  std::thread T1(fib), T2(fib);
  T1.join(); T2.join();

llvm-svn: 276015

8 years agoLet FuncAttrs infer the 'returned' argument attribute
David Majnemer [Tue, 19 Jul 2016 19:59:24 +0000 (19:59 +0000)]
Let FuncAttrs infer the 'returned' argument attribute

This reverts commit r275756.

llvm-svn: 276014

8 years agoARM: move feature for Thumb2 pkhbt/pkhtb onto architectures.
Tim Northover [Tue, 19 Jul 2016 19:49:13 +0000 (19:49 +0000)]
ARM: move feature for Thumb2 pkhbt/pkhtb onto architectures.

There's not much functional change, but it really is an architectural feature
(on v6T2, v7A, v7R and v7EM) rather than something each CPU implements
individually.

The main functional change is the default behaviour you get when specifying
only "-triple".

llvm-svn: 276013

8 years ago[GlobalISel] Mark newly-created gvregs as having a bank.
Ahmed Bougacha [Tue, 19 Jul 2016 19:48:36 +0000 (19:48 +0000)]
[GlobalISel] Mark newly-created gvregs as having a bank.

Also verify that we never try to set the size of a vreg associated
to a register class.

Report an error when we encounter that in MIR. Fix a testcase that
hit that error and had a size for no reason.

llvm-svn: 276012

8 years ago[GlobalISel] Simplify more RegClassOrRegBank is+get. NFC.
Ahmed Bougacha [Tue, 19 Jul 2016 19:47:06 +0000 (19:47 +0000)]
[GlobalISel] Simplify more RegClassOrRegBank is+get. NFC.

llvm-svn: 276011

8 years ago[OpenCL] Fixes bug of missing OCL version metadata on the AMDGCN target
Yaxun Liu [Tue, 19 Jul 2016 19:39:45 +0000 (19:39 +0000)]
[OpenCL] Fixes bug of missing OCL version metadata on the AMDGCN target

Added the opencl.ocl.version metadata to be emitted with amdgcn. Created a static function emitOCLVerMD which is shared between triple spir and target amdgcn.

Also added new testcases to existing test file, spir_version.cl inside test/CodeGenOpenCL.

Patch by Aaron En Ye Shi.

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

llvm-svn: 276010

8 years agoamdgpu: Use right builtn for rsq
Matt Arsenault [Tue, 19 Jul 2016 19:02:01 +0000 (19:02 +0000)]
amdgpu: Use right builtn for rsq

The r600 path has never actually worked sinced double is not implemented
there.

llvm-svn: 276009

8 years ago[FunctionAttrs] Correct the safety analysis for inference of 'returned'
David Majnemer [Tue, 19 Jul 2016 18:50:26 +0000 (18:50 +0000)]
[FunctionAttrs] Correct the safety analysis for inference of 'returned'

We skipped over ReturnInsts which didn't return an argument which would
lead us to incorrectly conclude that an argument returned by another
ReturnInst was 'returned'.

This reverts commit r275756.

This fixes PR28610.

llvm-svn: 276008

8 years ago[SCCP] Improve assert messages. NFCI.
Davide Italiano [Tue, 19 Jul 2016 18:31:07 +0000 (18:31 +0000)]
[SCCP] Improve assert messages. NFCI.

I've been hitting those already while working on SCCP and I think
it's be useful to provide a more explanatory diagnostic.

llvm-svn: 276007

8 years ago[libFuzzer] properly intercept memmem
Kostya Serebryany [Tue, 19 Jul 2016 18:29:06 +0000 (18:29 +0000)]
[libFuzzer] properly intercept memmem

llvm-svn: 276006

8 years ago[DSE] Add additional debug output. NFC.
Chad Rosier [Tue, 19 Jul 2016 18:11:11 +0000 (18:11 +0000)]
[DSE] Add additional debug output. NFC.

llvm-svn: 276005

8 years agoAdd detect_stack_use_after_scope runtime flag
Vitaly Buka [Tue, 19 Jul 2016 18:11:08 +0000 (18:11 +0000)]
Add detect_stack_use_after_scope runtime flag

Summary: This flag could be used to disable check in runtime.

Subscribers: kubabrecka

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

llvm-svn: 276004

8 years agoFix undefined behavior in __tree
Eric Fiselier [Tue, 19 Jul 2016 17:56:20 +0000 (17:56 +0000)]
Fix undefined behavior in __tree

Summary:
This patch attempts to fix the undefined behavior in __tree by changing the node pointer types used throughout. The pointer types are changed for raw pointers in the current ABI and for fancy pointers in ABI V2 (since the fancy pointer types may not be ABI compatible).

The UB in `__tree` arises because tree downcasts the embedded end node and then deferences that pointer. Currently there are 3 node types in __tree.

* `__tree_end_node` which contains the `__left_` pointer. This node is embedded within the container.
* `__tree_node_base` which contains `__right_`, `__parent_` and `__is_black`. This node is used throughout the tree rebalancing algorithms.
* `__tree_node` which contains `__value_`.

Currently `__tree` stores the start of the tree, `__begin_node_`, as a pointer to a `__tree_node`. Additionally the iterators store their position as a pointer to a `__tree_node`. In both of these cases the pointee can be the end node. This is fixed by changing them to store `__tree_end_node` pointers instead.

To make this change I introduced an `__iter_pointer` typedef which is defined to be a pointer to either `__tree_end_node` in the new ABI or `__tree_node` in the current one.
Both `__tree::__begin_node_` and iterator pointers are now stored as `__iter_pointers`.

The other situation where `__tree_end_node` is stored as the wrong type is in `__tree_node_base::__parent_`.  Currently `__left_`, `__right_`, and `__parent_` are all `__tree_node_base` pointers. Since the end node will only be stored in `__parent_` the fix is to change `__parent_` to be a pointer to `__tree_end_node`.

To make this change I introduced a `__parent_pointer` typedef which is defined to be a pointer to either `__tree_end_node` in the new ABI or `__tree_node_base` in the current one.

Note that in the new ABI `__iter_pointer` and `__parent_pointer` are the same type (but not in the old one). The confusion between these two types is unfortunate but it was the best solution I could come up with that maintains the ABI.

The typedef changes force a ton of explicit type casts to correct pointer types and to make current code compatible with both the old and new pointer typedefs. This is the bulk of the change and it's really messy. Unfortunately I don't know how to avoid it.

Please let me know what you think.

Reviewers: howard.hinnant, mclow.lists

Subscribers: howard.hinnant, bbannier, cfe-commits

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

llvm-svn: 276003

8 years agoAdd a testcase for r275581
David Majnemer [Tue, 19 Jul 2016 17:52:41 +0000 (17:52 +0000)]
Add a testcase for r275581

llvm-svn: 276002

8 years ago[RegionInfo] Some cleanups
David Majnemer [Tue, 19 Jul 2016 17:50:30 +0000 (17:50 +0000)]
[RegionInfo] Some cleanups

- Use unique_ptr instead of managing a container of new'd pointers.
- Use range based for loops.

No functional change is intended.

llvm-svn: 276001

8 years ago[RegionPass] Some minor cleanups
David Majnemer [Tue, 19 Jul 2016 17:50:27 +0000 (17:50 +0000)]
[RegionPass] Some minor cleanups

No functional change is intended.

llvm-svn: 276000

8 years ago[LoopPass] Some minor cleanups
David Majnemer [Tue, 19 Jul 2016 17:50:24 +0000 (17:50 +0000)]
[LoopPass] Some minor cleanups

No functional change is intended.

llvm-svn: 275999

8 years agoThis code block breaks the docs build (http://lab.llvm.org:8011/builders/llvm-sphinx...
Aaron Ballman [Tue, 19 Jul 2016 17:46:55 +0000 (17:46 +0000)]
This code block breaks the docs build (lab.llvm.org:8011/builders/llvm-sphinx-docs/builds/11920/steps/docs-llvm-html/logs/stdio), but I cannot see anything immediately wrong with it and cannot reproduce the diagnostic locally. Setting the code highlighting to none instead of nasm to hopefully get the bot stumbling back towards green.

llvm-svn: 275998

8 years agolibunwind: sync some coments with NetBSD's version
Ed Maste [Tue, 19 Jul 2016 17:28:38 +0000 (17:28 +0000)]
libunwind: sync some coments with NetBSD's version

NetBSD's system unwinder is a modified version of LLVM's libunwind.
Slightly reduce diffs by updating comments to match theirs where
appropriate.

llvm-svn: 275997

8 years agolibunwind: Use conventional DWARF capitalization in comments and errors
Ed Maste [Tue, 19 Jul 2016 17:15:50 +0000 (17:15 +0000)]
libunwind: Use conventional DWARF capitalization in comments and errors

llvm-svn: 275996

8 years agoadd tests related to PR28466
Sanjay Patel [Tue, 19 Jul 2016 17:07:35 +0000 (17:07 +0000)]
add tests related to PR28466

llvm-svn: 275995

8 years ago[X86][AVX512] Added AVX512 subvector broadcast tests
Simon Pilgrim [Tue, 19 Jul 2016 17:04:28 +0000 (17:04 +0000)]
[X86][AVX512] Added AVX512 subvector broadcast tests

llvm-svn: 275994

8 years agocppcoreguidelines-pro-bounds-constant-array-index: ignore implicit constructor
Matthias Gehre [Tue, 19 Jul 2016 17:02:54 +0000 (17:02 +0000)]
cppcoreguidelines-pro-bounds-constant-array-index: ignore implicit constructor

Summary:
The code

  struct A {
    int x[3];
  };

gets an compiler-generated copy constructor that uses ArraySubscriptExpr (see below).
Previously, the check would generate a warning on that copy constructor.
This commit disables the warning on implicitly generated code.
AST:

  |-CXXConstructorDecl 0x337b3c8 <col:8> col:8 implicit used constexpr A 'void (const struct A &) noexcept' inline
  | |-ParmVarDecl 0x337b510 <col:8> col:8 used 'const struct A &'
  | |-CXXCtorInitializer Field 0x3379238 'x' 'int [3]'
  | | `-ImplicitCastExpr 0x337e158 <col:8> 'int' <LValueToRValue>
  | |   `-ArraySubscriptExpr 0x337e130 <col:8> 'const int' lvalue
  | |     |-ImplicitCastExpr 0x337e118 <col:8> 'const int *' <ArrayToPointerDecay>
  | |     | `-MemberExpr 0x337dfc8 <col:8> 'int const[3]' lvalue .x 0x3379238
  | |     |   `-DeclRefExpr 0x337dfa0 <col:8> 'const struct A' lvalue ParmVar 0x337b510 '' 'const struct A &'
  | |     `-ImplicitCastExpr 0x337e098 <col:8> 'unsigned long' <LValueToRValue>
  | |       `-DeclRefExpr 0x337e070 <col:8> 'unsigned long' lvalue Var 0x337e010 '__i0' 'unsigned long'

Reviewers: alexfh, aaron.ballman

Subscribers: aemerson, nemanjai, cfe-commits

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

llvm-svn: 275993

8 years ago[X86][AVX] Fixed typo in test names
Simon Pilgrim [Tue, 19 Jul 2016 16:52:05 +0000 (16:52 +0000)]
[X86][AVX] Fixed typo in test names

llvm-svn: 275992

8 years ago[DSE] Add additional debug output. NFC.
Chad Rosier [Tue, 19 Jul 2016 16:50:57 +0000 (16:50 +0000)]
[DSE] Add additional debug output. NFC.

llvm-svn: 275991

8 years agoadd missing test for simplifySelectBitTest()
Sanjay Patel [Tue, 19 Jul 2016 16:49:55 +0000 (16:49 +0000)]
add missing test for simplifySelectBitTest()

llvm-svn: 275990

8 years ago[InstCombine] Enable cast-folding in logic(cast(icmp), cast(icmp))
Tobias Grosser [Tue, 19 Jul 2016 16:39:17 +0000 (16:39 +0000)]
[InstCombine] Enable cast-folding in logic(cast(icmp), cast(icmp))

Summary:
Currently, InstCombine is already able to fold expressions of the form `logic(cast(A), cast(B))` to the simpler form `cast(logic(A, B))`, where logic designates one of `and`/`or`/`xor`. This transformation is implemented in `foldCastedBitwiseLogic()` in InstCombineAndOrXor.cpp. However, this optimization will not be performed if both `A` and `B` are `icmp` instructions. The decision to preclude casts of `icmp` instructions originates in r48715 in combination with r261707, and can be best understood by the title of the former one:

> Transform (zext (or (icmp), (icmp))) to (or (zext (cimp), (zext icmp))) if at least one of the (zext icmp) can be transformed to eliminate an icmp.

Apparently, it introduced a transformation that is a reverse of the transformation that is done in `foldCastedBitwiseLogic()`. Its purpose is to expose pairs of `zext icmp` that would subsequently be optimized by `transformZExtICmp()` in InstCombineCasts.cpp. Therefore, in order to avoid an endless loop of switching back and forth between these two transformations, the one in `foldCastedBitwiseLogic()` has been restricted to exclude `icmp` instructions which is mirrored in the responsible check:

`if ((!isa<ICmpInst>(Cast0Src) || !isa<ICmpInst>(Cast1Src)) && ...`

This check seems to sort out more cases than necessary because:
- the reverse transformation is obviously done for `or` instructions only
- and also not every `zext icmp` pair is necessarily the result of this reverse transformation

Therefore we now remove this check and replace it by a more finegrained one in `shouldOptimizeCast()` that now rejects only those `logic(zext(icmp), zext(icmp))` that would be able to be optimized by `transformZExtICmp()`, which also avoids the mentioned endless loop. That means we are now able to also simplify expressions of the form `logic(cast(icmp), cast(icmp))` to `cast(logic(icmp, icmp))` (`cast` being an arbitrary `CastInst`).

As an example, consider the following IR snippet

```
%1 = icmp sgt i64 %a, %b
%2 = zext i1 %1 to i8
%3 = icmp slt i64 %a, %c
%4 = zext i1 %3 to i8
%5 = and i8 %2, %4
```

which would now be transformed to

```
%1 = icmp sgt i64 %a, %b
%2 = icmp slt i64 %a, %c
%3 = and i1 %1, %2
%4 = zext i1 %3 to i8
```

This issue became apparent when experimenting with the programming language Julia, which makes use of LLVM. Currently, Julia lowers its `Bool` datatype to LLVM's `i8` (also see https://github.com/JuliaLang/julia/pull/17225). In fact, the above IR example is the lowered form of the Julia snippet `(a > b) & (a < c)`. Like shown above, this may introduce `zext` operations, casting between `i1` and `i8`, which could for example hinder ScalarEvolution and Polly on certain code.

Reviewers: grosser, vtjnash, majnemer

Subscribers: majnemer, llvm-commits

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

Contributed-by: Matthias Reisinger
llvm-svn: 275989

8 years agoAMDGPU: Only use legal inline immediates with kill pseudo
Matt Arsenault [Tue, 19 Jul 2016 16:27:56 +0000 (16:27 +0000)]
AMDGPU: Only use legal inline immediates with kill pseudo

Only if the value is negative or positive is what matters,
so use a constant that doesn't require an instruction to
materialize.

These should really just emit the write exec directly,
but for stick with the kill pseudo-terminator.

llvm-svn: 275988

8 years agoGPGPU: Bail out of scops with hoisted invariant loads
Tobias Grosser [Tue, 19 Jul 2016 15:56:25 +0000 (15:56 +0000)]
GPGPU: Bail out of scops with hoisted invariant loads

This is currently not supported and will only be added later. Also update the
test cases to ensure no invariant code hoisting is applied.

llvm-svn: 275987

8 years agoclangRename: Update libdeps to add clangASTMatchers.
NAKAMURA Takumi [Tue, 19 Jul 2016 15:53:11 +0000 (15:53 +0000)]
clangRename: Update libdeps to add clangASTMatchers.

Note, ClangRenameTests is linking USRFindingAction.cpp directly.

llvm-svn: 275986

8 years agoClangRenameTests: Update libdeps. r275958 introduced clangASTMatchers.
NAKAMURA Takumi [Tue, 19 Jul 2016 15:33:14 +0000 (15:33 +0000)]
ClangRenameTests: Update libdeps. r275958 introduced clangASTMatchers.

llvm-svn: 275985

8 years agofix compiler warnings [NFC]
Etienne Bergeron [Tue, 19 Jul 2016 15:30:22 +0000 (15:30 +0000)]
fix compiler warnings [NFC]

llvm-svn: 275984

8 years agoTypo corrections identified by codespell
Ed Maste [Tue, 19 Jul 2016 15:28:02 +0000 (15:28 +0000)]
Typo corrections identified by codespell

Submitted by giffunip@yahoo.com; I fixed a couple of nearby errors and
incorrect changes in the patch.

llvm.org/pr27634

llvm-svn: 275983

8 years ago[compiler-rt] Fix Asan imports/exports unittest
Etienne Bergeron [Tue, 19 Jul 2016 15:27:23 +0000 (15:27 +0000)]
[compiler-rt] Fix Asan imports/exports unittest

Summary:
Avoid mismatch between imports/exports for 32-bit and 64-bits version.

The test is running grep over macros to detect which functions are
intercepted. Unfortunately, exception handlers differ in 32-bit and
64-bit.

This patch is removing the exception handlers from the test.

Reviewers: rnk

Subscribers: llvm-commits, wang0109, kubabrecka, chrisha

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

llvm-svn: 275982

8 years ago[X86][SSE] Reimplement SSE fp2si conversion intrinsics instead of using generic IR
Simon Pilgrim [Tue, 19 Jul 2016 15:07:43 +0000 (15:07 +0000)]
[X86][SSE] Reimplement SSE fp2si conversion intrinsics instead of using generic IR

D20859 and D20860 attempted to replace the SSE (V)CVTTPS2DQ and VCVTTPD2DQ truncating conversions with generic IR instead.

It turns out that the behaviour of these intrinsics is different enough from generic IR that this will cause problems, INF/NAN/out of range values are guaranteed to result in a 0x80000000 value - which plays havoc with constant folding which converts them to either zero or UNDEF. This is also an issue with the scalar implementations (which were already generic IR and what I was trying to match).

This patch changes both scalar and packed versions back to using x86-specific builtins.

It also deals with the other scalar conversion cases that are runtime rounding mode dependent and can have similar issues with constant folding.

A companion clang patch is at D22105

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

llvm-svn: 275981

8 years ago[include-fixer] A refactoring of IncludeFixerContext.
Haojian Wu [Tue, 19 Jul 2016 14:49:04 +0000 (14:49 +0000)]
[include-fixer] A refactoring of IncludeFixerContext.

Summary:
No functional changes in this patch. It is a refactoring (pull out a
structure representing the symbol being queried).

This is a preparing step for inserting missing namespace qualifiers to all
instances of an unidentified symbol.

Reviewers: bkramer

Subscribers: cfe-commits

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

llvm-svn: 275980

8 years ago[ARM] Refactor Thumb2 Mul and Mla instr descs
Sam Parker [Tue, 19 Jul 2016 14:44:05 +0000 (14:44 +0000)]
[ARM] Refactor Thumb2 Mul and Mla instr descs

Recommitting after r274347 was reverted. This patch introduces some
classes to refactor the 3 and 4 register Thumb2 multiplication
instruction descriptions, plus improved tests for some of those
instructions.

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

llvm-svn: 275979

8 years ago[AArch64] PredictableSelectIsExpensive for Vulcan.
Pankaj Gode [Tue, 19 Jul 2016 14:30:21 +0000 (14:30 +0000)]
[AArch64] PredictableSelectIsExpensive for Vulcan.

Adding PredictableSelectIsExpensive for Vulcan

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

llvm-svn: 275978

8 years agoAdd support for tlsldm assembler operator to ARM target
Peter Smith [Tue, 19 Jul 2016 14:15:33 +0000 (14:15 +0000)]
Add support for tlsldm assembler operator to ARM target

The standard local dynamic model for TLS on ARM systems needs two
relocations:
- R_ARM_TLS_LDM32 (module idx)
- R_ARM_TLS_LDO32 (offset of object from origin of module TLS block)

In GNU style assembler we use symbol(tlsldm) and symbol(tlsldo) to
produce these relocations.

llvm-mc for ARM supports symbol(tlsldo) but does not support symbol(tlsldm).
This patch wires up the existing symbol(tlsldm) to R_ARM_TLS_LDM32.

TLS for ARM is defined in Addenda to, and Errata in, the ABI for the
ARM Architecture

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

llvm-svn: 275977

8 years ago[AARCH64] Fix linu triple typo
Simon Pilgrim [Tue, 19 Jul 2016 14:12:45 +0000 (14:12 +0000)]
[AARCH64] Fix linu triple typo

As promised in D22191

llvm-svn: 275976

8 years agoAdd support of the latest Ubuntu (Yakkety Yak - 16.10)
Sylvestre Ledru [Tue, 19 Jul 2016 14:00:57 +0000 (14:00 +0000)]
Add support of the latest Ubuntu (Yakkety Yak - 16.10)

llvm-svn: 275975

8 years agoFix for failing bot sanitizer-x86_64-linux-fast after r275970
Dmitry Polukhin [Tue, 19 Jul 2016 13:35:15 +0000 (13:35 +0000)]
Fix for failing bot sanitizer-x86_64-linux-fast after r275970

More info http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/14774/steps/check-clang%20msan/logs/stdio

llvm-svn: 275974

8 years ago[AARCH64] Enable AARCH64 lit tests on windows dev machines
Simon Pilgrim [Tue, 19 Jul 2016 13:35:11 +0000 (13:35 +0000)]
[AARCH64] Enable AARCH64 lit tests on windows dev machines

As discussed on PR27654, this patch fixes the triples of a lot of aarch64 tests and enables lit tests on windows

This will hopefully help stop cases where windows developers break the aarch64 target

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

llvm-svn: 275973

8 years agoFix build with gcc 6.
Rafael Espindola [Tue, 19 Jul 2016 12:33:46 +0000 (12:33 +0000)]
Fix build with gcc 6.

llvm-svn: 275972

8 years agoGet rid of VS2015 operator precedence warning. NFCI.
Simon Pilgrim [Tue, 19 Jul 2016 12:26:51 +0000 (12:26 +0000)]
Get rid of VS2015 operator precedence warning. NFCI.

llvm-svn: 275971

8 years agoDeprecated (legacy) string literal conversion to 'char *' causes strange overloading...
Dmitry Polukhin [Tue, 19 Jul 2016 11:29:16 +0000 (11:29 +0000)]
Deprecated (legacy) string literal conversion to 'char *' causes strange overloading resolution

It's a patch for PR28050. Seems like overloading resolution wipes out
the first standard conversion sequence (before user-defined conversion)
in case of deprecated string literal conversion.

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

Patch by Alexander Makarov

llvm-svn: 275970

8 years agoGPGPU: Disable invariant load hoisting for GPU code generation
Tobias Grosser [Tue, 19 Jul 2016 11:13:58 +0000 (11:13 +0000)]
GPGPU: Disable invariant load hoisting for GPU code generation

This simplifies the upcoming patches to add code generation for ScopStmts. Load
hoisting support will later be added in a separate commit. This commit will
be implicitly tested by the subsequent GPGPU changes.

llvm-svn: 275969

8 years ago[mips][ias] R_MIPS_GOT_(PAGE|OFST) do not need symbols
Daniel Sanders [Tue, 19 Jul 2016 10:58:06 +0000 (10:58 +0000)]
[mips][ias] R_MIPS_GOT_(PAGE|OFST) do not need symbols

Reviewers: sdardis

Subscribers: dsanders, llvm-commits, sdardis

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

llvm-svn: 275968

8 years ago[mips] Correct label prefixes for N32 and N64.
Daniel Sanders [Tue, 19 Jul 2016 10:49:03 +0000 (10:49 +0000)]
[mips] Correct label prefixes for N32 and N64.

Summary:
N32 and N64 follow the standard ELF conventions (.L) whereas O32 uses its own
($).

This fixes the majority of object differences between -fintegrated-as and
-fno-integrated-as.

Reviewers: sdardis

Subscribers: dsanders, sdardis, llvm-commits

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

llvm-svn: 275967

8 years ago[mips] Recognise the triple used by Debian stretch for mips64el.
Daniel Sanders [Tue, 19 Jul 2016 10:22:19 +0000 (10:22 +0000)]
[mips] Recognise the triple used by Debian stretch for mips64el.

Summary:
The triple used for this distribution is mips64el-linux-gnuabi64.

Reviewers: sdardis

Subscribers: sdardis, llvm-commits

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

llvm-svn: 275966

8 years ago[ELF] Minimal PHDRS parser and section to segment assignment support
Eugene Leviant [Tue, 19 Jul 2016 09:25:43 +0000 (09:25 +0000)]
[ELF] Minimal PHDRS parser and section to segment assignment support

llvm-svn: 275965

8 years ago[InstCombine] Minor cleanup of cast simplification code [NFC]
Tobias Grosser [Tue, 19 Jul 2016 09:06:08 +0000 (09:06 +0000)]
[InstCombine] Minor cleanup of cast simplification code [NFC]

Summary:
This patch cleans up parts of InstCombine to raise its compliance with the LLVM coding standards and to increase its readability. The changes and according rationale are summarized in the following:

- Rename `ShouldOptimizeCast()` to `shouldOptimizeCast()` since functions should start with a lower case letter.

- Move `shouldOptimizeCast()` from InstCombineCasts.cpp to InstCombineAndOrXor.cpp since it's only used there.

- Simplify interface of `shouldOptimizeCast()`.

- Minor code style adaptions in `shouldOptimizeCast()`.

- Remove the documentation on the function definition of `shouldOptimizeCast()` since it just repeats the documentation on its declaration. Also enhance the documentation on its declaration with more information describing its intended use and make it doxygen-compliant.

- Change a comment in `foldCastedBitwiseLogic()` from `fold (logic (cast A), (cast B)) -> (cast (logic A, B))` to `fold logic(cast(A), cast(B)) -> cast(logic(A, B))` since the surrounding comments use this format.

- Remove comment `Only do this if the casts both really cause code to be generated.` in `foldCastedBitwiseLogic()` since it just repeats parts of the documentation of `shouldOptimizeCast()` and does not help to improve readability.

- Simplify the interface of `isEliminableCastPair()`.

- Removed the documentation on the function definition of `isEliminableCastPair()` which only contained obvious statements about its implementation. Instead added more general doxygen-compliant documentation to its declaration.

- Renamed parameter `DoXform` of `transformZExtIcmp()` to `DoTransform` to make its intention clearer.

- Moved documentation of `transformZExtIcmp()` from its definition to its declaration and made it doxygen-compliant.

Reviewers: vtjnash, grosser

Subscribers: majnemer, llvm-commits

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

Contributed-by: Matthias Reisinger
llvm-svn: 275964

8 years agoStyle: drop some unnecessary ';' [NFC]
Tobias Grosser [Tue, 19 Jul 2016 09:01:46 +0000 (09:01 +0000)]
Style: drop some unnecessary ';' [NFC]

llvm-svn: 275963

8 years agotest: Add missing 'REQUIRES' line
Tobias Grosser [Tue, 19 Jul 2016 07:47:27 +0000 (07:47 +0000)]
test: Add missing 'REQUIRES' line

llvm-svn: 275962

8 years agoReformat comment from 3 to 2 lines. NFC.
George Rimar [Tue, 19 Jul 2016 07:42:07 +0000 (07:42 +0000)]
Reformat comment from 3 to 2 lines. NFC.

llvm-svn: 275961

8 years agotest: Add missing 'REQUIRES' line
Tobias Grosser [Tue, 19 Jul 2016 07:39:54 +0000 (07:39 +0000)]
test: Add missing 'REQUIRES' line

llvm-svn: 275960

8 years agoFixed comment. NFC.
George Rimar [Tue, 19 Jul 2016 07:39:07 +0000 (07:39 +0000)]
Fixed comment. NFC.

llvm-svn: 275959