platform/upstream/llvm.git
7 years agoFix use of C++14 constexpr in C++11
Eric Fiselier [Wed, 12 Oct 2016 09:20:58 +0000 (09:20 +0000)]
Fix use of C++14 constexpr in C++11

llvm-svn: 283993

7 years ago[Support/ELF] - Sort PT_OPENBSD_* added previously. NFC.
George Rimar [Wed, 12 Oct 2016 09:20:28 +0000 (09:20 +0000)]
[Support/ELF] - Sort PT_OPENBSD_* added previously. NFC.

llvm-svn: 283992

7 years agoRemove use of _VSTD::__invoke in the not_fn tests
Eric Fiselier [Wed, 12 Oct 2016 09:06:12 +0000 (09:06 +0000)]
Remove use of _VSTD::__invoke in the not_fn tests

llvm-svn: 283991

7 years agoAdd AArch64 unit tests
Diana Picus [Wed, 12 Oct 2016 09:00:44 +0000 (09:00 +0000)]
Add AArch64 unit tests

Add unit tests for checking a few tricky instruction sizes. Also remove the old
tests for the instruction sizes, which were clunky and brittle.

Since this is the first set of target-specific unit tests, we need to add some
CMake plumbing. In the future, adding unit tests for a given target will be as
simple as creating a directory with the same name as the target under
unittests/Target. The tests are only run if the target is enabled in
LLVM_TARGETS_TO_BUILD.

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

llvm-svn: 283990

7 years agoLTO: Don't follow lazy references when seeing new definitions in the combined LTO...
Hans Wennborg [Wed, 12 Oct 2016 09:00:06 +0000 (09:00 +0000)]
LTO: Don't follow lazy references when seeing new definitions in the combined LTO object

Following the lazy reference might bring in an object file that depends
on bitcode files that weren't part of the LTO step.

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

llvm-svn: 283989

7 years agoProvide a fallback __cxa_thread_atexit() implementation. Patch from Tavian Barnes
Eric Fiselier [Wed, 12 Oct 2016 08:54:10 +0000 (08:54 +0000)]
Provide a fallback __cxa_thread_atexit() implementation. Patch from Tavian Barnes

llvm-svn: 283988

7 years ago[LCG] Cleanup various places where comments said `SCC` but meant
Chandler Carruth [Wed, 12 Oct 2016 08:40:51 +0000 (08:40 +0000)]
[LCG] Cleanup various places where comments said `SCC` but meant
`RefSCC`.

Also improve the comments surrounding the lazy post-order iterator as
they had grown stale since the RefSCC/SCC split.

I'm sure there are more comments that need updating here, but I saw and
fixed these and didn't want to lose them. I've not gotten to doing
a really complete audit of every comment yet.

llvm-svn: 283987

7 years ago[clang-tidy-vs] Fix ClangTidy extension name in the manifest.
Marek Kurdej [Wed, 12 Oct 2016 08:32:59 +0000 (08:32 +0000)]
[clang-tidy-vs] Fix ClangTidy extension name in the manifest.

llvm-svn: 283986

7 years agoRevert "[ClangTidy] Add UsingInserter and NamespaceAliaser"
Haojian Wu [Wed, 12 Oct 2016 08:19:44 +0000 (08:19 +0000)]
Revert "[ClangTidy] Add UsingInserter and NamespaceAliaser"

This reverts commit r283981. This patch breaks the buildbot.

llvm-svn: 283985

7 years agoDon't crash if reloc targets discarded section
Eugene Leviant [Wed, 12 Oct 2016 08:19:30 +0000 (08:19 +0000)]
Don't crash if reloc targets discarded section

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

llvm-svn: 283984

7 years agoProtect special members of NullBase archetype to avoid exposing them
Eric Fiselier [Wed, 12 Oct 2016 08:09:22 +0000 (08:09 +0000)]
Protect special members of NullBase archetype to avoid exposing them

llvm-svn: 283983

7 years ago[LCG] Add the necessary functionality to the LazyCallGraph to support inlining.
Chandler Carruth [Wed, 12 Oct 2016 07:59:56 +0000 (07:59 +0000)]
[LCG] Add the necessary functionality to the LazyCallGraph to support inlining.

The basic inlining operation makes the following changes to the call graph:
1) Add edges that were previously transitive edges. This is always trivial and
   this patch gives the LCG helper methods to make this more convenient.
2) Remove the inlined edge. We had existing support for this, but it contained
   bugs that needed to be fixed. Testing in the same pattern as the inliner
   exposes these bugs very nicely.
3) Delete a function when it becomes dead because it is internal and all calls
   have been inlined. The LCG had no support at all for this operation, so this
   adds that support.

Two unittests have been added that exercise this specific mutation pattern to
the call graph. They were extremely effective in uncovering bugs. Sadly,
a large fraction of the code here is just to implement those unit tests, but
I think they're paying for themselves. =]

This was split out of a patch that actually uses the routines to
implement inlining in the new pass manager in order to isolate (with
unit tests) the logic that was entirely within the LCG.

Many thanks for the careful review from folks! There will be a few minor
follow-up patches based on the comments in the review as well.

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

llvm-svn: 283982

7 years ago[ClangTidy] Add UsingInserter and NamespaceAliaser
Haojian Wu [Wed, 12 Oct 2016 07:59:54 +0000 (07:59 +0000)]
[ClangTidy] Add UsingInserter and NamespaceAliaser

Summary: This adds helper classes to add using declaractions and namespace aliases to function bodies. These help making function calls to deeply nested functions concise (e.g. when calling helpers in a refactoring)

Patch by Julian Bangert!

Reviewers: alexfh, hokein

Subscribers: cfe-commits

Tags: #clang-tools-extra

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

llvm-svn: 283981

7 years agoImplement N4606 optional
Eric Fiselier [Wed, 12 Oct 2016 07:46:20 +0000 (07:46 +0000)]
Implement N4606 optional

Summary:
Adapt implementation of Library Fundamentals TS optional into an implementation of N4606 optional.

  - Update relational operators per http://wg21.link/P0307
  - Update to requirements of http://wg21.link/P0032
  - Extension: Implement trivial copy/move construction/assignment for `optional<T>` when `T` is trivially copyable.

Audit P/Rs for optional LWG issues:
  - 2756 "C++ WP optional<T> should 'forward' T's implicit conversions" Implemented, which also resolves 2753 "Optional's constructors and assignments need constraints" (modulo my refusal to explicitly delete the move operations, which is a design error that I'm working on correcting in the 2756 P/R).
  - 2736 "nullopt_t insufficiently constrained" Already conforming. I've added a test ensuring that `nullopt_t` is not copy-initializable from an empty braced-init-list, which I believe is the root intent of the issue, to avoid regression.
  - 2740 "constexpr optional<T>::operator->" Already conforming.
  - 2746 "Inconsistency between requirements for emplace between optional and variant" No P/R, but note that the author's '"suggested resolution" is already implemented.
  - 2748 "swappable traits for optionals" Already conforming.
  - 2753 "Optional's constructors and assignments need constraints" Implemented.

Most of the work for this patch was done by Casey Carter @ Microsoft. Thank you Casey!

Reviewers: mclow.lists, CaseyCarter, EricWF

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

llvm-svn: 283980

7 years agoRevert "[libFuzzer] refactoring to speed things up, NFC"
Daniel Jasper [Wed, 12 Oct 2016 07:26:46 +0000 (07:26 +0000)]
Revert "[libFuzzer] refactoring to speed things up, NFC"

This reverts commit r283946.

This breaks when build with GCC:
lib/Fuzzer/FuzzerTracePC.cpp:169:6: error: always_inline function might not be inlinable [-Werror=attributes]
lib/Fuzzer/FuzzerTracePC.cpp:169:6: error: inlining failed in call to always_inline 'void fuzzer::TracePC::HandleCmp(void*, T, T) [with T = long unsigned int]': target specific option mismatch
lib/Fuzzer/FuzzerTracePC.cpp:198:65: error: called from here

llvm-svn: 283979

7 years agoRevert Add <optional>. Will recommit with better commit message
Eric Fiselier [Wed, 12 Oct 2016 06:48:31 +0000 (06:48 +0000)]
Revert Add <optional>. Will recommit with better commit message

llvm-svn: 283978

7 years agoAdd <optional> header.
Eric Fiselier [Wed, 12 Oct 2016 06:45:11 +0000 (06:45 +0000)]
Add <optional> header.

This patch is largely thanks to Casey Carter @ Microsoft. He did the initial
work of porting our experimental implementation and tests over to namespace
std.

llvm-svn: 283977

7 years agoFix two more tests that hang when testing against libstdc++
Eric Fiselier [Wed, 12 Oct 2016 04:56:23 +0000 (04:56 +0000)]
Fix two more tests that hang when testing against libstdc++

llvm-svn: 283976

7 years agoPrevent the test suite from hanging when run against libstdc++
Eric Fiselier [Wed, 12 Oct 2016 04:29:50 +0000 (04:29 +0000)]
Prevent the test suite from hanging when run against libstdc++

llvm-svn: 283975

7 years ago[AArch64][InstructionSelector] Fix unintended test changes in r283973.
Quentin Colombet [Wed, 12 Oct 2016 04:12:44 +0000 (04:12 +0000)]
[AArch64][InstructionSelector] Fix unintended test changes in r283973.

I screwed up my merge conflict and lost some of the CHECK lines.

llvm-svn: 283974

7 years ago[AArch64][InstrustionSelector] Teach the selector about G_BITCAST.
Quentin Colombet [Wed, 12 Oct 2016 03:57:52 +0000 (03:57 +0000)]
[AArch64][InstrustionSelector] Teach the selector about G_BITCAST.

llvm-svn: 283973

7 years ago[AArch64][InstructionSelector] Refactor the handling of copies.
Quentin Colombet [Wed, 12 Oct 2016 03:57:49 +0000 (03:57 +0000)]
[AArch64][InstructionSelector] Refactor the handling of copies.

Although Copies are not specific to preISel, we still have to assign them
a proper register class. However, given they are not constrained to
anything we do not have to handle the source register at the copy. It
will be properly mapped when reaching the related definition.

In the process, the handlong of G_ANYEXT is slightly modified as those
end up being selected as copy. The difference is that when register size
do not match on both sides, we need to insert SUBREG_TO_REG operation,
otherwise the post RA copy expansion will not be happy!

llvm-svn: 283972

7 years ago[AArch64][InstructionSelector] Fix typos in the related mir file. NFC.
Quentin Colombet [Wed, 12 Oct 2016 03:57:46 +0000 (03:57 +0000)]
[AArch64][InstructionSelector] Fix typos in the related mir file. NFC.

llvm-svn: 283971

7 years ago[AArch64][MachineLegalizer] Mark more bitcasts as legal.
Quentin Colombet [Wed, 12 Oct 2016 03:57:43 +0000 (03:57 +0000)]
[AArch64][MachineLegalizer] Mark more bitcasts as legal.

Those are copies, we do not have to do any legalization action for them.

llvm-svn: 283970

7 years agoAdd an arm64 unit test where the function saves x20 in the
Jason Molenda [Wed, 12 Oct 2016 03:53:01 +0000 (03:53 +0000)]
Add an arm64 unit test where the function saves x20 in the
prologue, then loads & stores x20 on the stack from a different
location in the middle of the function, and then restores the
reg in the epilogue.  The saving/restoring of x20 in the middle
of the function should be ignored.

llvm-svn: 283969

7 years ago[lit] Run unit tests as part of lit test suite
Brian Gesiak [Wed, 12 Oct 2016 03:35:04 +0000 (03:35 +0000)]
[lit] Run unit tests as part of lit test suite

Summary:
The Python file `utils/lit/lit/ShUtil.py` contains:

1. Logic used by lit itself
2. A set of unit tests for that logic, which can be run by invoking
  `python utils/lit/lit/ShUtil.py`

Move these unit tests to a `tests/unit` subdirectory of lit, and run
the tests as part of lit's test suite. This ensures that, should the
lit test suite be included in LLVM's own regression test suite, these
unit tests will also be run.

(Instructions on how to run lit's test suite can be found in
`utils/lit/README.txt`.)

Reviewers: ddunbar, echristo, delcypher, beanz

Subscribers: mehdi_amini, llvm-commits

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

llvm-svn: 283968

7 years agoMemory-SSA cleanup of clobbers interface, NFC
Sebastian Pop [Wed, 12 Oct 2016 03:08:40 +0000 (03:08 +0000)]
Memory-SSA cleanup of clobbers interface, NFC

This implements the cleanup that Danny asked to commit separately from the
previous fix to GVN-hoist in https://reviews.llvm.org/D25476#inline-219818

Tested with ninja check on x86_64-linux.

llvm-svn: 283967

7 years agoAdd a simple frameless function test case to the arm64 unwind unit tests
Jason Molenda [Wed, 12 Oct 2016 02:46:22 +0000 (02:46 +0000)]
Add a simple frameless function test case to the arm64 unwind unit tests
with return statements in the body of the function.

llvm-svn: 283966

7 years agoGVN-hoist: fix store past load dependence analysis (PR30216, PR30499)
Sebastian Pop [Wed, 12 Oct 2016 02:23:39 +0000 (02:23 +0000)]
GVN-hoist: fix store past load dependence analysis (PR30216, PR30499)

This is a refreshed version of a patch that was reverted: it fixes
the problems reported in both PR30216 and PR30499, and
contains all the test-cases from both bugs.

To hoist stores past loads, we used to search for potential
conflicting loads on the hoisting path by following a MemorySSA
def-def link from the store to be hoisted to the previous
defining memory access, and from there we followed the def-use
chains to all the uses that occur on the hoisting path. The
problem is that the def-def link may point to a store that does
not alias with the store to be hoisted, and so the loads that are
walked may not alias with the store to be hoisted, and even as in
the testcase of PR30216, the loads that may alias with the store
to be hoisted are not visited.

The current patch visits all loads on the path from the store to
be hoisted to the hoisting position and uses the alias analysis
to ask whether the store may alias the load. I was not able to
use the MemorySSA functionality to ask for whether load and
store are clobbered: I'm not sure which function to call, so I
used a call to AA->isNoAlias().

Store past store is still working as before using a MemorySSA
query: I added an extra test to pr30216.ll to make sure store
past store does not regress.

Tested on x86_64-linux with check and a test-suite run.

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

llvm-svn: 283965

7 years agoAdded REQUIRED triples to the test that fails on some ARM buildbots.
Artem Belevich [Wed, 12 Oct 2016 02:08:08 +0000 (02:08 +0000)]
Added REQUIRED triples to the test that fails on some ARM buildbots.

llvm-svn: 283964

7 years ago[CUDA] Make touching a kernel from a __host__ __device__ function a deferred error.
Justin Lebar [Wed, 12 Oct 2016 01:30:08 +0000 (01:30 +0000)]
[CUDA] Make touching a kernel from a __host__ __device__ function a deferred error.

Previously, this was an immediate, don't pass go, don't collect $200
error.  But this precludes us from writing code like

  __host__ __device__ void launch_kernel() {
    kernel<<<...>>>();
  }

Such code isn't wrong, following our notions of right and wrong in CUDA,
unless it's codegen'ed.

llvm-svn: 283963

7 years agoFix libc++abi test config after recent libc++ changes
Eric Fiselier [Wed, 12 Oct 2016 01:19:16 +0000 (01:19 +0000)]
Fix libc++abi test config after recent libc++ changes

llvm-svn: 283962

7 years ago[PPCMIPeephole] Fix splat elimination
Tim Shen [Wed, 12 Oct 2016 00:48:25 +0000 (00:48 +0000)]
[PPCMIPeephole] Fix splat elimination

Summary:
In PPCMIPeephole, when we see two splat instructions, we can't simply do the following transformation:
  B = Splat A
  C = Splat B
=>
  C = Splat A
because B may still be used between these two instructions. Instead, we should make the second Splat a PPC::COPY and let later passes decide whether to remove it or not:
  B = Splat A
  C = Splat B
=>
  B = Splat A
  C = COPY B

Fixes PR30663.

Reviewers: echristo, iteratee, kbarton, nemanjai

Subscribers: mehdi_amini, llvm-commits

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

llvm-svn: 283961

7 years agoAdd mork workarounds for running the test suite against libstdc++
Eric Fiselier [Wed, 12 Oct 2016 00:28:14 +0000 (00:28 +0000)]
Add mork workarounds for running the test suite against libstdc++

llvm-svn: 283960

7 years agoThis test now passes.
Jim Ingham [Wed, 12 Oct 2016 00:05:36 +0000 (00:05 +0000)]
This test now passes.

llvm-svn: 283959

7 years agoMake it easier to run the libc++ test suite against libstdc++
Eric Fiselier [Wed, 12 Oct 2016 00:00:37 +0000 (00:00 +0000)]
Make it easier to run the libc++ test suite against libstdc++

llvm-svn: 283958

7 years agoThis was skipped due to a clang PR that has been fixed.
Jim Ingham [Tue, 11 Oct 2016 23:55:13 +0000 (23:55 +0000)]
This was skipped due to a clang PR that has been fixed.

llvm-svn: 283957

7 years agoAdded a radar on our end for this test's failure.
Jim Ingham [Tue, 11 Oct 2016 23:30:38 +0000 (23:30 +0000)]
Added a radar on our end for this test's failure.

llvm-svn: 283956

7 years agoFix _recalloc redefinition link error in ASan RTL
Reid Kleckner [Tue, 11 Oct 2016 23:13:13 +0000 (23:13 +0000)]
Fix _recalloc redefinition link error in ASan RTL

Fixes PR30329

Patch by Hans-Bernhard Broeker!

llvm-svn: 283955

7 years agoFix the stage2 MSVC 2013 build with less constexpr in RNG
Reid Kleckner [Tue, 11 Oct 2016 23:02:21 +0000 (23:02 +0000)]
Fix the stage2 MSVC 2013 build with less constexpr in RNG

llvm-svn: 283954

7 years ago[DAG] Fix crash in build_vector -> vector_shuffle combine
Michael Kuperstein [Tue, 11 Oct 2016 22:44:31 +0000 (22:44 +0000)]
[DAG] Fix crash in build_vector -> vector_shuffle combine

Fixes a crash in the build_vector -> vector_shuffle combine
when the first vector input is twice as wide as the output,
and the second input vector is even wider.

llvm-svn: 283953

7 years agoGlobalISel: support same-size casts on AArch64.
Tim Northover [Tue, 11 Oct 2016 22:29:23 +0000 (22:29 +0000)]
GlobalISel: support same-size casts on AArch64.

Mostly Ahmed's work again, I'm just sprucing things up slightly before
committing.

llvm-svn: 283952

7 years agoFix LWG2683 - filesystem::copy() should always clear the user-provided error_code
Eric Fiselier [Tue, 11 Oct 2016 22:18:09 +0000 (22:18 +0000)]
Fix LWG2683 - filesystem::copy() should always clear the user-provided error_code

llvm-svn: 283951

7 years agoRevert - When optimizing for size, enable loop rerolling by default
Mike Edwards [Tue, 11 Oct 2016 22:09:13 +0000 (22:09 +0000)]
Revert - When optimizing for size, enable loop rerolling by default

This reverts r283685 as it is causing test failures on Green Dragon.

llvm-svn: 283950

7 years ago[Profile] Update testcase for r283948 (NFC)
Vedant Kumar [Tue, 11 Oct 2016 21:56:05 +0000 (21:56 +0000)]
[Profile] Update testcase for r283948 (NFC)

Old: "__DATA,__llvm_prf_data"
New: "__DATA,__llvm_prf_data,regular,live_support"

This should fix the following bot failure:

  http://bb.pgr.jp/builders/cmake-clang-x86_64-linux/builds/55158

llvm-svn: 283949

7 years ago[profile] Add test for dead_strip+live_support functionality
Vedant Kumar [Tue, 11 Oct 2016 21:48:48 +0000 (21:48 +0000)]
[profile] Add test for dead_strip+live_support functionality

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

llvm-svn: 283948

7 years ago[InstrProf] Add support for dead_strip+live_support functionality
Vedant Kumar [Tue, 11 Oct 2016 21:48:16 +0000 (21:48 +0000)]
[InstrProf] Add support for dead_strip+live_support functionality

On Darwin, marking a section as "regular,live_support" means that a
symbol in the section should only be kept live if it has a reference to
something that is live. Otherwise, the linker is free to dead-strip it.

Turn this functionality on for the __llvm_prf_data section.

This means that counters and data associated with dead functions will be
removed from dead-stripped binaries. This will result in smaller
profiles and binaries, and should speed up profile collection.

Tested with check-profile, llvm-lit test/tools/llvm-{cov,profdata}, and
check-llvm.

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

llvm-svn: 283947

7 years ago[libFuzzer] refactoring to speed things up, NFC
Kostya Serebryany [Tue, 11 Oct 2016 21:27:37 +0000 (21:27 +0000)]
[libFuzzer] refactoring to speed things up, NFC

llvm-svn: 283946

7 years agoRemove extraneous 'const' in the implementation of is_move_assignable. Howard pleads...
Marshall Clow [Tue, 11 Oct 2016 21:24:06 +0000 (21:24 +0000)]
Remove extraneous 'const' in the implementation of is_move_assignable. Howard pleads temporary insanity about this.  Discussed at stackoverflow.com/questions/39986185

llvm-svn: 283945

7 years agoFix std::pair on FreeBSD
Eric Fiselier [Tue, 11 Oct 2016 21:22:21 +0000 (21:22 +0000)]
Fix std::pair on FreeBSD

Summary:
FreeBSD ships an old ABI for std::pair which requires that it have non-trivial copy/move constructors. Currently the non-trivial copy/move is achieved by providing explicit definitions of the constructors. This is problematic because it means the constructors don't SFINAE properly. In order to SFINAE copy/move constructors they have to be explicitly defaulted and hense non-trivial.

This patch attempts to provide SFINAE'ing copy/move constructors for std::pair while still making them non-trivial. It does this by adding a base class with a non-trivial copy constructor and then allowing pair's constructors to be generated by the compiler. This also allows the constructors to be constexpr.

Reviewers: emaste, theraven, rsmith, dim

Subscribers: cfe-commits

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

llvm-svn: 283944

7 years agoModule: for ObjectiveC, be consistent when checking hidden decls.
Manman Ren [Tue, 11 Oct 2016 21:18:20 +0000 (21:18 +0000)]
Module: for ObjectiveC, be consistent when checking hidden decls.

In MatchAllMethodDeclarations, when checking a hidden decl, be sure
to allow hidden when searching for methods.

rdar://28699972

llvm-svn: 283943

7 years agoRe-land "[Thumb] Save/restore high registers in Thumb1 pro/epilogues"
Reid Kleckner [Tue, 11 Oct 2016 21:14:03 +0000 (21:14 +0000)]
Re-land "[Thumb] Save/restore high registers in Thumb1 pro/epilogues"

Reverts r283938 to reinstate r283867 with a fix.

The original change had an ArrayRef referring to a destroyed temporary
initializer list. Use plain C arrays instead.

llvm-svn: 283942

7 years agoFix incorrect exception handling behavior in the uninitialized algorithms
Eric Fiselier [Tue, 11 Oct 2016 21:13:44 +0000 (21:13 +0000)]
Fix incorrect exception handling behavior in the uninitialized algorithms

llvm-svn: 283941

7 years agoAdd the radar number on our end.
Jim Ingham [Tue, 11 Oct 2016 21:08:27 +0000 (21:08 +0000)]
Add the radar number on our end.

llvm-svn: 283940

7 years agoNext set of additional error checks for invalid Mach-O files for the
Kevin Enderby [Tue, 11 Oct 2016 21:04:39 +0000 (21:04 +0000)]
Next set of additional error checks for invalid Mach-O files for the
load commands that uses the MachO::linker_option_command
type but not used in llvm libObject code but used in llvm tool code.

This includes just LC_LINKER_OPTION load command.

llvm-svn: 283939

7 years agoRevert "[Thumb] Save/restore high registers in Thumb1 pro/epilogues"
Reid Kleckner [Tue, 11 Oct 2016 20:54:41 +0000 (20:54 +0000)]
Revert "[Thumb] Save/restore high registers in Thumb1 pro/epilogues"

This reverts r283867.

This appears to be an infinite loop:

    while (HiRegToSave != AllHighRegs.end() && CopyReg != AllCopyRegs.end()) {
      if (HiRegsToSave.count(*HiRegToSave)) {
        ...

        CopyReg = findNextOrderedReg(++CopyReg, CopyRegs, AllCopyRegs.end());
        HiRegToSave =
            findNextOrderedReg(++HiRegToSave, HiRegsToSave, AllHighRegs.end());
      }
    }

llvm-svn: 283938

7 years agoGlobalISel: support selection of extend operations.
Tim Northover [Tue, 11 Oct 2016 20:50:21 +0000 (20:50 +0000)]
GlobalISel: support selection of extend operations.

Patch mostly by Ahmed Bougaca.

llvm-svn: 283937

7 years agoMIRParser: allow types on registers with a RegBank.
Tim Northover [Tue, 11 Oct 2016 20:50:04 +0000 (20:50 +0000)]
MIRParser: allow types on registers with a RegBank.

This fixes some GlobalISel regression tests.

llvm-svn: 283936

7 years agoRe-apply "Disallow ArrayRef assignment from temporaries."
Jordan Rose [Tue, 11 Oct 2016 20:39:16 +0000 (20:39 +0000)]
Re-apply "Disallow ArrayRef assignment from temporaries."

This re-applies r283798, disabled in r283803, with the static_assert
tests disabled under MSVC. The deleted functions still seem to catch
mistakes in MSVC, so it's not a significant loss.

Part of rdar://problem/16375365

llvm-svn: 283935

7 years agoCodegen: Tail-duplicate during placement.
Kyle Butt [Tue, 11 Oct 2016 20:36:43 +0000 (20:36 +0000)]
Codegen: Tail-duplicate during placement.

The tail duplication pass uses an assumed layout when making duplication
decisions. This is fine, but passes up duplication opportunities that
may arise when blocks are outlined. Because we want the updated CFG to
affect subsequent placement decisions, this change must occur during
placement.

In order to achieve this goal, TailDuplicationPass is split into a
utility class, TailDuplicator, and the pass itself. The pass delegates
nearly everything to the TailDuplicator object, except for looping over
the blocks in a function. This allows the same code to be used for tail
duplication in both places.

This change, in concert with outlining optional branches, allows
triangle shaped code to perform much better, esepecially when the
taken/untaken branches are correlated, as it creates a second spine when
the tests are small enough.

Issue from previous rollback fixed, and a new test was added for that
case as well. Issue was worklist/scheduling/taildup issue in layout.

Issue from 2nd rollback fixed, with 2 additional tests. Issue was
tail merging/loop info/tail-duplication causing issue with loops that share
a header block.

Issue with early tail-duplication of blocks that branch to a fallthrough
predecessor fixed with test case: tail-dup-branch-to-fallthrough.ll

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

llvm-svn: 283934

7 years agoSwift Calling Convention: Parameters are allowed after the
Arnold Schwaighofer [Tue, 11 Oct 2016 20:34:06 +0000 (20:34 +0000)]
Swift Calling Convention: Parameters are allowed after the
swift_error/swift_context parameter

We need to be able to decelare witness functions which append the self type and
the self witness tables at the end of the parameter list.

rdar://28720996

llvm-svn: 283933

7 years agoPass the end of a component to SwiftAggLowering's enumerateComponents callback
Arnold Schwaighofer [Tue, 11 Oct 2016 20:34:03 +0000 (20:34 +0000)]
Pass the end of a component to SwiftAggLowering's enumerateComponents callback

This is usefull for determining whether components overlap.

llvm-svn: 283932

7 years agoFix a test to pacify llvm-clang-lld-x86_64-scei-ps4-windows10pro bot.
Rui Ueyama [Tue, 11 Oct 2016 20:15:36 +0000 (20:15 +0000)]
Fix a test to pacify llvm-clang-lld-x86_64-scei-ps4-windows10pro bot.

I don't really understand why we get a larger .rodata section only
on this bot. I guess it may be picking up a library which contains
a .rodata. I removed the specific values since their values are not
important for this test case.

llvm-svn: 283931

7 years ago[x86] add tests for negate bool
Sanjay Patel [Tue, 11 Oct 2016 20:15:20 +0000 (20:15 +0000)]
[x86] add tests for negate bool

llvm-svn: 283930

7 years agoThis test now passes.
Jim Ingham [Tue, 11 Oct 2016 20:09:40 +0000 (20:09 +0000)]
This test now passes.

llvm-svn: 283929

7 years agoAvoid braced initialization for default member initializers for MSVC 2013
Reid Kleckner [Tue, 11 Oct 2016 20:02:57 +0000 (20:02 +0000)]
Avoid braced initialization for default member initializers for MSVC 2013

llvm-svn: 283928

7 years agoSilence -Wunused-but-set-variable warning
Arnold Schwaighofer [Tue, 11 Oct 2016 19:49:29 +0000 (19:49 +0000)]
Silence -Wunused-but-set-variable warning

llvm-svn: 283927

7 years agoRe-submit r283825: Add section header stream to PDB.
Rui Ueyama [Tue, 11 Oct 2016 19:45:07 +0000 (19:45 +0000)]
Re-submit r283825: Add section header stream to PDB.

It was reverted because the change that depends on was reverted.
Now it was submitted as r283925, so we can submit this as well.

llvm-svn: 283926

7 years agoRe-submit r283823: Define DbiStreamBuilder::addDbgStream to add stream.
Rui Ueyama [Tue, 11 Oct 2016 19:43:12 +0000 (19:43 +0000)]
Re-submit r283823: Define DbiStreamBuilder::addDbgStream to add stream.

The previous commit was failing because we filled empty slots of
the debug stream index with kInvalidStreamIndex. It should've been 0.

llvm-svn: 283925

7 years ago[sanitizer-coverage] use private linkage for coverage guards, delete old commented...
Kostya Serebryany [Tue, 11 Oct 2016 19:36:50 +0000 (19:36 +0000)]
[sanitizer-coverage] use private linkage for coverage guards, delete old commented-out code.

llvm-svn: 283924

7 years agoAdded a bugreport tracking the failure to get float return values
Jim Ingham [Tue, 11 Oct 2016 19:29:25 +0000 (19:29 +0000)]
Added a bugreport tracking the failure to get float return values
on i386.

llvm-svn: 283923

7 years agoFix build error on LP64 platforms.
Rui Ueyama [Tue, 11 Oct 2016 19:28:56 +0000 (19:28 +0000)]
Fix build error on LP64 platforms.

llvm-svn: 283922

7 years ago[raw_ostream] Raise some helper functions out of raw_ostream.
Zachary Turner [Tue, 11 Oct 2016 19:24:45 +0000 (19:24 +0000)]
[raw_ostream] Raise some helper functions out of raw_ostream.

Low level functionality to format numbers were embedded in the
implementation of raw_ostream.  I have need to use these through
an interface other than the overloaded stream operators, so they
need to be raised to a level that they can be used from either
raw_ostream operators or other code.

llvm-svn: 283921

7 years agoRevert "Change Builtins name to be stored as StringRef instead of raw pointers (NFC)"
Mehdi Amini [Tue, 11 Oct 2016 19:04:24 +0000 (19:04 +0000)]
Revert "Change Builtins name to be stored as StringRef instead of raw pointers (NFC)"

This reverts commit r283802. It introduces temporarily static
initializers, because StringRef ctor isn't (yet) constexpr for
string literals.
I plan to get there this week, but apparently GCC is so terrible
with these static initializer right now (10 min+ extra codegen
time was reported) that I'll hold on to this patch till the
constexpr one is ready, and land these at the same time.

llvm-svn: 283920

7 years ago[AMDGPU] Refactor waitcnt encoding
Konstantin Zhuravlyov [Tue, 11 Oct 2016 18:58:22 +0000 (18:58 +0000)]
[AMDGPU] Refactor waitcnt encoding

- Refactor bit packing/unpacking
- Calculate bit mask given bit shift and bit width
- Introduce function for decoding bits of waitcnt
- Introduce function for encoding bits of waitcnt
- Introduce function for getting waitcnt mask (instead of using bare numbers)
- Introduce function fot getting max waitcnt(s) (instead of using bare numbers)

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

llvm-svn: 283919

7 years agoAllow Switch instruction to have extractProfTotalWeight called as it can terminate...
Dehao Chen [Tue, 11 Oct 2016 18:53:00 +0000 (18:53 +0000)]
Allow Switch instruction to have extractProfTotalWeight called as it can terminate a basic block. (NFC)

llvm-svn: 283918

7 years ago[Driver] Use -fsyntax-only in test/Driver/show-option-names.c
Bruno Cardoso Lopes [Tue, 11 Oct 2016 18:38:33 +0000 (18:38 +0000)]
[Driver] Use -fsyntax-only in test/Driver/show-option-names.c

Make the test less expensive, follow up from r283915.

llvm-svn: 283917

7 years agoAvoid unnecessary constexpr to appease MSVC 2013
Reid Kleckner [Tue, 11 Oct 2016 18:35:13 +0000 (18:35 +0000)]
Avoid unnecessary constexpr to appease MSVC 2013

llvm-svn: 283916

7 years ago[Driver] Fix test from r283913 to unbreak bots
Bruno Cardoso Lopes [Tue, 11 Oct 2016 18:31:45 +0000 (18:31 +0000)]
[Driver] Fix test from r283913 to unbreak bots

Followup from r283913 & r283827

http://bb.pgr.jp/builders/cmake-clang-x86_64-linux/builds/55135

llvm-svn: 283915

7 years agoFix "static initialization order fiasco" for the XCore Target.
Mehdi Amini [Tue, 11 Oct 2016 18:22:41 +0000 (18:22 +0000)]
Fix "static initialization order fiasco" for the XCore Target.

I fixed all the other Targets in r283702, and interestingly the
sanitizers are only now "sometimes" catching this bug on the only
one I missed.

llvm-svn: 283914

7 years agoReapply [Driver][Diagnostics] Make 'show option names' default for driver warnings
Bruno Cardoso Lopes [Tue, 11 Oct 2016 18:21:26 +0000 (18:21 +0000)]
Reapply [Driver][Diagnostics] Make 'show option names' default for driver warnings

Reapply r283827 by fixing the tests to not be target specific

Currently, driver level warnings do not show option names (e.g. warning:
complain about foo [-Woption-name]) in a diagnostic unless
-fdiagnostics-show-option is explictly specified. OTOH, the driver by
default turn this option on for CC1. Change the logic to show option
names by default in the driver as well.

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

rdar://problem/27300909

llvm-svn: 283913

7 years ago[Support] Fix undefined behavior in RandomNumberGenerator.
Zachary Turner [Tue, 11 Oct 2016 18:17:26 +0000 (18:17 +0000)]
[Support] Fix undefined behavior in RandomNumberGenerator.

This has existed pretty much forever AFAICT, but the code was
never being exercised because nobody was using the class.  A
user of this class surfaced, and now we're breaking with UB.
The code was obviously wrong, so it's fixed here.

llvm-svn: 283912

7 years ago[AMDGPU] Fix test that was broken by rL283893
Konstantin Zhuravlyov [Tue, 11 Oct 2016 18:16:56 +0000 (18:16 +0000)]
[AMDGPU] Fix test that was broken by rL283893

llvm-svn: 283911

7 years agoMake variable name consistent with other -z options.
Rui Ueyama [Tue, 11 Oct 2016 17:46:48 +0000 (17:46 +0000)]
Make variable name consistent with other -z options.

llvm-svn: 283910

7 years agoARMMachineFunctionInfo.cpp: Add an initializer of ARMFunctionInfo::ReturnRegsCount...
NAKAMURA Takumi [Tue, 11 Oct 2016 17:38:30 +0000 (17:38 +0000)]
ARMMachineFunctionInfo.cpp: Add an initializer of ARMFunctionInfo::ReturnRegsCount in the explicit ctor.

It caused crash since r283867.

llvm-svn: 283909

7 years agoReformat.
NAKAMURA Takumi [Tue, 11 Oct 2016 17:38:25 +0000 (17:38 +0000)]
Reformat.

llvm-svn: 283908

7 years ago[CUDA] Re-land support for <complex> (r283683 and r283680).
Justin Lebar [Tue, 11 Oct 2016 17:36:03 +0000 (17:36 +0000)]
[CUDA] Re-land support for <complex> (r283683 and r283680).

These were reverted in r283753 and r283747.

The first patch added a header to the root 'Headers' install directory,
instead of into 'Headers/cuda_wrappers'.  This was fixed in the second
patch, but by then the damage was done: The bad header stayed in the
'Headers' directory, continuing to break the build.

We reverted both patches in an attempt to fix things, but that still
didn't get rid of the header, so the Windows boostrap build remained
broken.

It's probably worth fixing up our cmake logic to remove things from the
install dirs, but in the meantime, re-land these patches, since we
believe they no longer have this bug.

llvm-svn: 283907

7 years agoFix the build with MSVC 2013 after r283856
Reid Kleckner [Tue, 11 Oct 2016 17:24:09 +0000 (17:24 +0000)]
Fix the build with MSVC 2013 after r283856

llvm-svn: 283906

7 years ago[DAG] add fold for masked negated sign-extended bool
Sanjay Patel [Tue, 11 Oct 2016 17:05:52 +0000 (17:05 +0000)]
[DAG] add fold for masked negated sign-extended bool

This enhances the fold added with:
https://reviews.llvm.org/rL283900

llvm-svn: 283905

7 years agoClarified the explanation of expr --top-level.
Sean Callanan [Tue, 11 Oct 2016 16:57:21 +0000 (16:57 +0000)]
Clarified the explanation of expr --top-level.

llvm-svn: 283904

7 years ago[x86] add sext variants of tests added with r283894
Sanjay Patel [Tue, 11 Oct 2016 16:49:52 +0000 (16:49 +0000)]
[x86] add sext variants of tests added with r283894

llvm-svn: 283903

7 years agoLet test pass for builds that support X86, but do not default to it
Bernard Ogden [Tue, 11 Oct 2016 16:34:49 +0000 (16:34 +0000)]
Let test pass for builds that support X86, but do not default to it

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

llvm-svn: 283902

7 years agoFix test on non-x86 hosts
Bernard Ogden [Tue, 11 Oct 2016 16:32:37 +0000 (16:32 +0000)]
Fix test on non-x86 hosts

Summary:
This test is allowed to run on non-x86 hosts and thus must use
llvm-nm rather than nm.

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

llvm-svn: 283901

7 years ago[DAG] add fold for masked negated extended bool
Sanjay Patel [Tue, 11 Oct 2016 16:26:36 +0000 (16:26 +0000)]
[DAG] add fold for masked negated extended bool

The non-obvious motivation for adding this fold (which already happens in InstCombine)
is that we want to canonicalize IR towards select instructions and canonicalize DAG
nodes towards boolean math. So we need to recreate some folds in the DAG to handle that
change in direction.

An interesting implementation difference for cases like this is that InstCombine
generally works top-down while the DAG goes bottom-up. That means we need to detect
different patterns. In this case, the SimplifyDemandedBits fold prevents us from
performing a zext to sext fold that would then be recognized as a negation of a sext.

llvm-svn: 283900

7 years agoSilence unused warning in non-assert builds.
Daniel Jasper [Tue, 11 Oct 2016 16:22:36 +0000 (16:22 +0000)]
Silence unused warning in non-assert builds.

llvm-svn: 283899

7 years ago[opt-viewer] Remove unnecessary call to demangle
Adam Nemet [Tue, 11 Oct 2016 16:20:40 +0000 (16:20 +0000)]
[opt-viewer] Remove unnecessary call to demangle

llvm-svn: 283898

7 years ago[opt-viewer] Print hotness as percentage of the maximum hotness
Adam Nemet [Tue, 11 Oct 2016 16:20:38 +0000 (16:20 +0000)]
[opt-viewer] Print hotness as percentage of the maximum hotness

llvm-svn: 283897

7 years ago[opt-viewer] Convert another HTML output to use a multiline string
Adam Nemet [Tue, 11 Oct 2016 16:19:06 +0000 (16:19 +0000)]
[opt-viewer] Convert another HTML output to use a multiline string

llvm-svn: 283896

7 years agoFix clang-offload-bundler test.
Zachary Turner [Tue, 11 Oct 2016 16:06:32 +0000 (16:06 +0000)]
Fix clang-offload-bundler test.

A recent change to llvm::cl slightly changed the format of
the help output, and it broke this test.  NFC

llvm-svn: 283895

7 years ago[x86] add tests to show missed folds for masked bools
Sanjay Patel [Tue, 11 Oct 2016 16:04:37 +0000 (16:04 +0000)]
[x86] add tests to show missed folds for masked bools

llvm-svn: 283894