platform/upstream/llvm.git
7 years ago[libFuzzer] Clean up headers and file formatting of LibFuzzer files.
Marcos Pividori [Tue, 13 Dec 2016 17:46:11 +0000 (17:46 +0000)]
[libFuzzer] Clean up headers and file formatting of LibFuzzer files.

Reorganize #includes to follow LLVM Coding Standards.
Include some missing headers. Required to use `Printf()`.

Aside from that, this patch contains no functional change.
It is purely a re-organization.

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

llvm-svn: 289560

7 years ago[libFuzzer] Properly use unsigned for workers, jobs and NumberOfCpuCores.
Marcos Pividori [Tue, 13 Dec 2016 17:45:53 +0000 (17:45 +0000)]
[libFuzzer] Properly use unsigned for workers, jobs and NumberOfCpuCores.

std::thread::hardware_concurrency() returns an unsigned, so I modify
NumberOfCpuCores() to return unsigned too.
The number of cpus is used to define the number of workers, so I decided
to update the worker and jobs flags to be declared as unsigned too.

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

llvm-svn: 289559

7 years ago[libFuzzer] Properly use unsigned for Process ID.
Marcos Pividori [Tue, 13 Dec 2016 17:45:44 +0000 (17:45 +0000)]
[libFuzzer] Properly use unsigned for Process ID.

Use unsigned for PID instead of signed int. GetCurrentProcessId() returns
an unsigned (DWORD) so we must be sure we can deal with all possible values.
I use a long unsigned to be sure it can hold a 32 bit unsigned (DWORD).

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

llvm-svn: 289558

7 years ago[libFuzzer] Improve Signal Handler interface.
Marcos Pividori [Tue, 13 Dec 2016 17:45:20 +0000 (17:45 +0000)]
[libFuzzer] Improve Signal Handler interface.

Add new flags to FuzzingOptions to represent the different conditions
on the signal handling. These options are passed when calling
SetSignalHandler().
This changes simplify the implementation of Windows's exception
handling. Now we can define a unique handler for all the exceptions.

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

llvm-svn: 289557

7 years agoFix the test cases committed in r289521.
Rong Xu [Tue, 13 Dec 2016 17:34:29 +0000 (17:34 +0000)]
Fix the test cases committed in r289521.

llvm-svn: 289556

7 years ago[X86][SSE] Regenerate vector of pointers tests
Simon Pilgrim [Tue, 13 Dec 2016 17:22:39 +0000 (17:22 +0000)]
[X86][SSE] Regenerate vector of pointers tests

llvm-svn: 289555

7 years ago[analyzer] Detect ObjC properties that are both (copy) and Mutable.
Artem Dergachev [Tue, 13 Dec 2016 17:19:18 +0000 (17:19 +0000)]
[analyzer] Detect ObjC properties that are both (copy) and Mutable.

When an Objective-C property has a (copy) attribute, the default setter
for this property performs a -copy on the object assigned.

Calling -copy on a mutable NS object such as NSMutableString etc.
produces an immutable object, NSString in our example.
Hence the getter becomes type-incorrect.

rdar://problem/21022397

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

llvm-svn: 289554

7 years agoUpdate for clang after llvm::StringLiteral.
Zachary Turner [Tue, 13 Dec 2016 17:10:16 +0000 (17:10 +0000)]
Update for clang after llvm::StringLiteral.

llvm-svn: 289553

7 years agoFixing build failure by adding triple option to new test condition.
Neil Hickey [Tue, 13 Dec 2016 17:04:33 +0000 (17:04 +0000)]
Fixing build failure by adding triple option to new test condition.

Adding -triple option to ensure target supports double for fpmath test.

llvm-svn: 289552

7 years ago[ADT] Add llvm::StringLiteral.
Zachary Turner [Tue, 13 Dec 2016 17:03:49 +0000 (17:03 +0000)]
[ADT] Add llvm::StringLiteral.

StringLiteral is a wrapper around a string literal useful for
replacing global tables of char arrays with global tables of
StringRefs that can initialized in a constexpr context, avoiding
the invocation of a global constructor.

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

llvm-svn: 289551

7 years agoRefactor duplicated expression. NFC.
Rafael Espindola [Tue, 13 Dec 2016 16:59:19 +0000 (16:59 +0000)]
Refactor duplicated expression. NFC.

llvm-svn: 289550

7 years agoFix sphinx build.
Alexander Kornienko [Tue, 13 Dec 2016 16:49:10 +0000 (16:49 +0000)]
Fix sphinx build.

llvm-svn: 289549

7 years ago[ADCE] Add code to remove dead branches
David Callahan [Tue, 13 Dec 2016 16:42:18 +0000 (16:42 +0000)]
[ADCE] Add code to remove dead branches

Summary:
This is last in of a series of patches to evolve ADCE.cpp to support
removing of unnecessary control flow.

This patch adds the code to update the control and data flow graphs
to remove the dead control flow.

Also update unit tests to test the capability to remove dead,
may-be-infinite loop which is enabled by the switch
-adce-remove-loops.

Previous patches:

D23824 [ADCE] Add handling of PHI nodes when removing control flow
D23559 [ADCE] Add control dependence computation
D23225 [ADCE] Modify data structures to support removing control flow
D23065 [ADCE] Refactor anticipating new functionality (NFC)
D23102 [ADCE] Refactoring for new functionality (NFC)

Reviewers: dberlin, majnemer, nadav, mehdi_amini

Subscribers: llvm-commits, david2050, freik, twoh

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

llvm-svn: 289548

7 years agoRemove trailing whitespace in docs and clang-tidy sources.
Alexander Kornienko [Tue, 13 Dec 2016 16:38:45 +0000 (16:38 +0000)]
Remove trailing whitespace in docs and clang-tidy sources.

llvm-svn: 289547

7 years ago[Clang-tidy] check for malloc, realloc and free calls
Alexander Kornienko [Tue, 13 Dec 2016 16:38:18 +0000 (16:38 +0000)]
[Clang-tidy] check for malloc, realloc and free calls

Summary:
This checker flags the use of C-style memory management functionality and notes about modern alternatives.
In an earlier revision it tried to autofix some kind of patterns, but that was a bad idea. Since memory management can be so widespread in a program, manual updating is most likely necessary.
Maybe for special cases, there could be later additions to this basic checker.

This is the first checker I wrote and I never did something with clang (only compiling programs). So whenever I missed conventions or did plain retarded stuff, feel free to point it out! I am willing to fix them and write a better checker.

I hope the patch does work, I never did this either. On a testapply in my repository it did, but I am pretty unconfident in my patching skills :)

Reviewers: aaron.ballman, hokein, alexfh, malcolm.parsons

Subscribers: cfe-commits, JDevlieghere, nemanjai, Eugene.Zelenko, Prazek, mgorny, modocache

Tags: #clang-tools-extra

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

Patch by Jonas Toth!

llvm-svn: 289546

7 years agoUse more detailed assertion messages in the code introduced by r289538
Artur Pilipenko [Tue, 13 Dec 2016 16:26:15 +0000 (16:26 +0000)]
Use more detailed assertion messages in the code introduced by r289538

llvm-svn: 289545

7 years agoImprove handling of floating point literals in OpenCL to only use double precision...
Neil Hickey [Tue, 13 Dec 2016 16:22:50 +0000 (16:22 +0000)]
Improve handling of floating point literals in OpenCL to only use double precision if the target supports fp64.

This change makes sure single-precision floating point types are used if the
cl_fp64 extension is not supported by the target.

Also removed the check to see whether the OpenCL version is >= 1.2, as this has
been incorporated into the extension setting code.

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

llvm-svn: 289544

7 years agoRemove deprecated methods ast_matchers::BoundNodes::{getStmtAs,getDeclAs}
Alexander Kornienko [Tue, 13 Dec 2016 16:19:34 +0000 (16:19 +0000)]
Remove deprecated methods ast_matchers::BoundNodes::{getStmtAs,getDeclAs}

llvm-svn: 289543

7 years agoRemove deprecated methods ast_matchers::BoundNodes::{getStmtAs,getDeclAs}
Alexander Kornienko [Tue, 13 Dec 2016 16:19:19 +0000 (16:19 +0000)]
Remove deprecated methods ast_matchers::BoundNodes::{getStmtAs,getDeclAs}

llvm-svn: 289542

7 years ago[clang-move] Fix incorrect EndLoc for declarations in macros.
Haojian Wu [Tue, 13 Dec 2016 15:35:47 +0000 (15:35 +0000)]
[clang-move] Fix incorrect EndLoc for declarations in macros.

Reviewers: ioeric

Subscribers: cfe-commits

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

llvm-svn: 289541

7 years agoFix a buildbot failure introduced by r289538
Artur Pilipenko [Tue, 13 Dec 2016 14:55:31 +0000 (14:55 +0000)]
Fix a buildbot failure introduced by r289538

Build failed because of unused variable in product mode.

llvm-svn: 289540

7 years ago[sancov] Disable failing test on SystemZ as well
Ulrich Weigand [Tue, 13 Dec 2016 14:44:25 +0000 (14:44 +0000)]
[sancov] Disable failing test on SystemZ as well

This doesn't work at all on big-endian systems, even just reading in the
magic bytes in the binary .sancov file header gets byte order wrong.

llvm-svn: 289539

7 years ago[DAGCombiner] Match load by bytes idiom and fold it into a single load
Artur Pilipenko [Tue, 13 Dec 2016 14:21:14 +0000 (14:21 +0000)]
[DAGCombiner] Match load by bytes idiom and fold it into a single load

Match a pattern where a wide type scalar value is loaded by several narrow loads and combined by shifts and ors. Fold it into a single load or a load and a bswap if the targets supports it.

Assuming little endian target:
  i8 *a = ...
  i32 val = a[0] | (a[1] << 8) | (a[2] << 16) | (a[3] << 24)
=>
  i32 val = *((i32)a)

  i8 *a = ...
  i32 val = (a[0] << 24) | (a[1] << 16) | (a[2] << 8) | a[3]
=>
  i32 val = BSWAP(*((i32)a))

This optimization was discussed on llvm-dev some time ago in "Load combine pass" thread. We came to the conclusion that we want to do this transformation late in the pipeline because in presence of atomic loads load widening is irreversible transformation and it might hinder other optimizations.

Eventually we'd like to support folding patterns like this where the offset has a variable and a constant part:
  i32 val = a[i] | (a[i + 1] << 8) | (a[i + 2] << 16) | (a[i + 3] << 24)

Matching the pattern above is easier at SelectionDAG level since address reassociation has already happened and the fact that the loads are adjacent is clear. Understanding that these loads are adjacent at IR level would have involved looking through geps/zexts/adds while looking at the addresses.

The general scheme is to match OR expressions by recursively calculating the origin of individual bits which constitute the resulting OR value. If all the OR bits come from memory verify that they are adjacent and match with little or big endian encoding of a wider value. If so and the load of the wider type (and bswap if needed) is allowed by the target generate a load and a bswap if needed.

Reviewed By: hfinkel, RKSimon, filcab

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

llvm-svn: 289538

7 years agoMove BaseIndexOffset in DAGCombiner.cpp so it will be available for the upcoming...
Artur Pilipenko [Tue, 13 Dec 2016 14:16:02 +0000 (14:16 +0000)]
Move BaseIndexOffset in DAGCombiner.cpp so it will be available for the upcoming user

llvm-svn: 289537

7 years ago[OpenCL] Improve address space diagnostics.
Egor Churaev [Tue, 13 Dec 2016 14:07:23 +0000 (14:07 +0000)]
[OpenCL] Improve address space diagnostics.

Reviewers: Anastasia

Subscribers: bader, yaxunl, cfe-commits

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

llvm-svn: 289536

7 years ago[OpenCL] Enable unroll hint for OpenCL 1.x.
Egor Churaev [Tue, 13 Dec 2016 14:02:35 +0000 (14:02 +0000)]
[OpenCL] Enable unroll hint for OpenCL 1.x.

Summary: Although the feature was introduced only in OpenCL C v2.0 spec., it's useful for OpenCL 1.x too and doesn't require HW support.

Reviewers: Anastasia

Subscribers: yaxunl, cfe-commits, bader

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

llvm-svn: 289535

7 years ago[SelectionDAG] computeKnownBits - simplified knownbits sign extension. NFCI.
Simon Pilgrim [Tue, 13 Dec 2016 13:36:27 +0000 (13:36 +0000)]
[SelectionDAG] computeKnownBits - simplified knownbits sign extension. NFCI.

We don't need to extract+test the sign bit of the known ones/zeros, we can use sext which will handle all of this.

llvm-svn: 289534

7 years agoAdjust clang-format formatting to r289531
Tobias Grosser [Tue, 13 Dec 2016 12:44:00 +0000 (12:44 +0000)]
Adjust clang-format formatting to r289531

clang-format has been updated in r289531 to keep labels and values on
the same line. This change updates Polly to the new formatting style.

llvm-svn: 289533

7 years ago[mips][rtdyld] Move MIPS relocation resolution to a subclass and implement N32 reloca...
Simon Dardis [Tue, 13 Dec 2016 11:39:18 +0000 (11:39 +0000)]
[mips][rtdyld] Move MIPS relocation resolution to a subclass and implement N32 relocations

N32 relocations are only correct for individual relocations at the moment.
Support for relocation composition will follow in a later patch.

Patch By: Daniel Sanders

Reviwers: vkalintiris, atanasyan

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

llvm-svn: 289532

7 years agoclang-format: Keep string-literal-label + value pairs on a line.
Daniel Jasper [Tue, 13 Dec 2016 11:16:42 +0000 (11:16 +0000)]
clang-format: Keep string-literal-label + value pairs on a line.

We have previously done that for <<-operators. This patch also adds
this logic for "," and "+".

Before:
  string v = "aaaaaaaaaaaaaaaa: " + aaaaaaaaaaaaaaaa + "aaaaaaaaaaaaaaaa: " +
             aaaaaaaaaaaaaaaa + "aaaaaaaaaaaaaaaa: " + aaaaaaaaaaaaaaaa;
  string v = StrCat("aaaaaaaaaaaaaaaa: ", aaaaaaaaaaaaaaaa, "aaaaaaaaaaaaaaaa: ",
                    aaaaaaaaaaaaaaaa, "aaaaaaaaaaaaaaaa: ", aaaaaaaaaaaaaaaa);

After:
  string v = "aaaaaaaaaaaaaaaa: " + aaaaaaaaaaaaaaaa +
     "aaaaaaaaaaaaaaaa: " + aaaaaaaaaaaaaaaa +
     "aaaaaaaaaaaaaaaa: " + aaaaaaaaaaaaaaaa;
  string v = StrCat("aaaaaaaaaaaaaaaa: ", aaaaaaaaaaaaaaaa,
    "aaaaaaaaaaaaaaaa: ", aaaaaaaaaaaaaaaa,
    "aaaaaaaaaaaaaaaa: ", aaaaaaaaaaaaaaaa);

llvm-svn: 289531

7 years ago[mips] Fix comment to respect 80 chars per line; NFC
Simon Dardis [Tue, 13 Dec 2016 11:10:53 +0000 (11:10 +0000)]
[mips] Fix comment to respect 80 chars per line; NFC

llvm-svn: 289530

7 years ago[mips] Fix compact branch hazard detection
Simon Dardis [Tue, 13 Dec 2016 11:07:51 +0000 (11:07 +0000)]
[mips] Fix compact branch hazard detection

In certain cases it is possible that transient instructions such as
%reg = IMPLICIT_DEF as a single instruction in a basic block to reach
the MipsHazardSchedule pass. This patch teaches MipsHazardSchedule to
properly look through such cases.

Reviewers: vkalintiris, zoran.jovanovic

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

llvm-svn: 289529

7 years ago[GlobalISel] Move extendRegister where it belongs. NFCI
Diana Picus [Tue, 13 Dec 2016 10:46:12 +0000 (10:46 +0000)]
[GlobalISel] Move extendRegister where it belongs. NFCI

Apparently I missed this one when I moved ValueHandler back in r288658. Sorry!

llvm-svn: 289528

7 years ago[ELF] Add R_ARM_RELATIVE to relocations that can be applied to GotSection
Peter Smith [Tue, 13 Dec 2016 10:42:05 +0000 (10:42 +0000)]
[ELF] Add R_ARM_RELATIVE to relocations that can be applied to GotSection

When compiling -fpie and linking with the --pie option the R_ARM_GOTBREL
relocation to D is resolved by writing the value of D into the .got slot
and emitting an R_ARM_RELATIVE relocation for it.

This changes adds the R_ARM_RELATIVE relocation to the switch in
relocateOne() so we can process the GotSection relocation to write the
value of the variable as well as emitting the dynamic relocation.

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

llvm-svn: 289527

7 years ago[sancov] Mark as unstable on ARM, not XFAIL, since it does pass on some config
Renato Golin [Tue, 13 Dec 2016 10:22:49 +0000 (10:22 +0000)]
[sancov] Mark as unstable on ARM, not XFAIL, since it does pass on some config

llvm-svn: 289526

7 years agoclang-format: Improve braced-list detection.
Daniel Jasper [Tue, 13 Dec 2016 10:05:03 +0000 (10:05 +0000)]
clang-format: Improve braced-list detection.

Before:
  vector<int> v { 12 }
      GUARDED_BY(mutex);

After:
  vector<int> v{12} GUARDED_BY(mutex);

llvm-svn: 289525

7 years ago[clang-tidy] Add check for redundant function pointer dereferences
Malcolm Parsons [Tue, 13 Dec 2016 08:04:11 +0000 (08:04 +0000)]
[clang-tidy] Add check for redundant function pointer dereferences

Reviewers: alexfh, aaron.ballman, hokein

Subscribers: mgorny, JDevlieghere, cfe-commits

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

llvm-svn: 289524

7 years ago[X86][InstCombine] Fix SimplifyDemandedVectorElts to handle frcz scalar intrinsics...
Craig Topper [Tue, 13 Dec 2016 07:45:45 +0000 (07:45 +0000)]
[X86][InstCombine] Fix SimplifyDemandedVectorElts to handle frcz scalar intrinsics correctly.

Only the lower bits of the input element are used. And only the lower element can be undef since the upper bits are zeroed.

Have InstCombineCalls call SimplifyDemandedVectorElts for these intrinsics to reuse this support.

llvm-svn: 289523

7 years agollvm/test/Transforms/PGOProfile/noreturncall.ll REQUIRES asserts due to -debug-only.
NAKAMURA Takumi [Tue, 13 Dec 2016 07:04:03 +0000 (07:04 +0000)]
llvm/test/Transforms/PGOProfile/noreturncall.ll REQUIRES asserts due to -debug-only.

llvm-svn: 289522

7 years ago[PGO] Fix insane counts due to nonreturn calls
Rong Xu [Tue, 13 Dec 2016 06:41:14 +0000 (06:41 +0000)]
[PGO] Fix insane counts due to nonreturn calls

Summary:
Since we don't break BBs for function calls. We might get some insane counts
(wrap of unsigned) in the presence of noreturn calls.

This patch sets these counts to zero instead of the wrapped number.

Reviewers: davidxl

Subscribers: xur, eraman, llvm-commits

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

llvm-svn: 289521

7 years agoSmall tweaks to the markup in StructuredDataPlugins.
Jason Molenda [Tue, 13 Dec 2016 05:59:24 +0000 (05:59 +0000)]
Small tweaks to the markup in StructuredDataPlugins.

llvm-svn: 289520

7 years ago[SCCP] Debug diagnostic goes under DEBUG(). NFCI.
Davide Italiano [Tue, 13 Dec 2016 05:56:04 +0000 (05:56 +0000)]
[SCCP] Debug diagnostic goes under DEBUG(). NFCI.

llvm-svn: 289519

7 years agoTouch-up the markup of the DarwinLog.md documentation.
Jason Molenda [Tue, 13 Dec 2016 05:54:17 +0000 (05:54 +0000)]
Touch-up the markup of the DarwinLog.md documentation.

llvm-svn: 289518

7 years ago[AVR] Add an 'relax memory operation' pass
Dylan McKay [Tue, 13 Dec 2016 05:53:14 +0000 (05:53 +0000)]
[AVR] Add an 'relax memory operation' pass

Summary:
This pass will be used to relax instructions which use out of bounds
memory accesses to equivalent operations that can work with the
addresses.

The pass currently implements relaxation for the STDWPtrQRr instruction.

Without this pass, an assertion error would be hit in the pseudo expansion pass.

In the future, we will need to add more instructions to this pass. We can do
that on a case-by-case basic.

Reviewers: arsenm, kparzysz

Subscribers: wdng, llvm-commits, mgorny

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

llvm-svn: 289517

7 years ago[sanitizers] dso order is random, test shouldnt depend on it
Mike Aizatsky [Tue, 13 Dec 2016 05:24:57 +0000 (05:24 +0000)]
[sanitizers] dso order is random, test shouldnt depend on it

llvm-svn: 289516

7 years ago[sanitizers] powerpc4 is also unsupported platform
Mike Aizatsky [Tue, 13 Dec 2016 05:21:19 +0000 (05:21 +0000)]
[sanitizers] powerpc4 is also unsupported platform

llvm-svn: 289515

7 years agoCodeGen: clean up -Wpedantic warning (NFC)
Saleem Abdulrasool [Tue, 13 Dec 2016 03:27:35 +0000 (03:27 +0000)]
CodeGen: clean up -Wpedantic warning (NFC)

  lib/CodeGen/CGExpr.cpp:2511:2: warning: extra ';' [-Wpedantic]
   };
    ^

Clean up warning from gcc 6.

llvm-svn: 289514

7 years ago[libc++abi] Mark failing test on Darwin as XFAIL
Shoaib Meenai [Tue, 13 Dec 2016 02:43:04 +0000 (02:43 +0000)]
[libc++abi] Mark failing test on Darwin as XFAIL

The macOS thread-local variable finalizer routines do not handle the
case where a termination function registers another termination function
correctly, causing this test to fail. I've filed a radar for this;
mark the test XFAIL in the meantime. See [1] for more details.

[1] http://lists.llvm.org/pipermail/cfe-dev/2016-November/051376.html

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

llvm-svn: 289513

7 years ago[libcxx] [test] Fix size_t-to-int truncation warnings in syserr.hash.
Stephan T. Lavavej [Tue, 13 Dec 2016 01:54:58 +0000 (01:54 +0000)]
[libcxx] [test] Fix size_t-to-int truncation warnings in syserr.hash.

After r289363, these tests were triggering MSVC x64 warning C4267
"conversion from 'size_t' to 'int', possible loss of data" by taking 0, 2, and 10
as std::size_t, then constructing error_code(int, const error_category&) or
error_condition(int, const error_category&) from that (N4618 19.5.3.2
[syserr.errcode.constructors]/3, 19.5.4.2 [syserr.errcondition.constructors]/3).

The fix is simple: take these ints as int, pass them to the int-taking
constructor, and perform a value-preserving static_cast<std::size_t>
when comparing them to `std::size_t result`.

Fixes D27691.

llvm-svn: 289512

7 years ago[analyzer] Run clang-format and fix style
Dominic Chen [Tue, 13 Dec 2016 01:40:41 +0000 (01:40 +0000)]
[analyzer] Run clang-format and fix style

Summary: Split out formatting and style changes from D26061

Reviewers: zaks.anna, dcoughlin

Subscribers: cfe-commits

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

llvm-svn: 289511

7 years ago[peephole] Enhance folding logic to work for STATEPOINTs
Philip Reames [Tue, 13 Dec 2016 01:38:41 +0000 (01:38 +0000)]
[peephole] Enhance folding logic to work for STATEPOINTs

The general idea here is to get enough of the existing restrictions out of the way that the already existing folding logic in foldMemoryOperand can kick in for STATEPOINTs and fold references to immutable stack slots. The key changes are:

    Support for folding multiple operands at once which reference the same load
    Support for folding multiple loads into a single instruction
    Walk all the operands of the instruction for varidic instructions (this is a bug fix!)

Once this lands, I'll post another patch which refactors the TII interface here. There's nothing actually x86 specific about the x86 code used here.

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

llvm-svn: 289510

7 years ago[Statepoints] Reuse stack slots more than once within a basic block
Philip Reames [Tue, 13 Dec 2016 01:21:15 +0000 (01:21 +0000)]
[Statepoints] Reuse stack slots more than once within a basic block

The stack slot reuse code had a really amusing bug. We ended up only reusing a stack slot exact once (initial use + reuse) within a basic block. If we had a third statepoint to process, we ended up allocating a new set of stack slots. If we crossed a basic block boundary, the set got cleared. As a result, code which is invoke heavy doesn't see the problem, but multiple calls within a basic block does. Net result: as we optimize invokes into calls, lowering gets worse.

The root error here is that the bitmap uses by the custom allocator wasn't kept in sync. The result was that we ended up resizing the bitmap on the next statepoint (to handle the cross block case), reset the bit once, but then never reset it again.

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

llvm-svn: 289509

7 years ago[sanitizers] disabling dso test as well where appropriate
Mike Aizatsky [Tue, 13 Dec 2016 01:11:46 +0000 (01:11 +0000)]
[sanitizers] disabling dso test as well where appropriate

llvm-svn: 289508

7 years ago[sanitizers] trace-pc-guard doesn't work on mac as well
Mike Aizatsky [Tue, 13 Dec 2016 01:10:21 +0000 (01:10 +0000)]
[sanitizers] trace-pc-guard doesn't work on mac as well

fatal error: error in backend: Global variable '__sancov_gen_' has an
invalid section specifier '__sancov_guards': mach-o section specifier
requires a segment and section separated by a comma.

llvm-svn: 289507

7 years ago[libFuzzer] don't require extra flags with -minimize_crash=1 (default to -max_total_t...
Kostya Serebryany [Tue, 13 Dec 2016 00:40:47 +0000 (00:40 +0000)]
[libFuzzer] don't require extra flags with -minimize_crash=1 (default to -max_total_time=600). Also respect exact_artifact_path when outputting the end result

llvm-svn: 289506

7 years ago[sanitizers] sancov really works on x86 only
Mike Aizatsky [Tue, 13 Dec 2016 00:34:33 +0000 (00:34 +0000)]
[sanitizers] sancov really works on x86 only

llvm-svn: 289505

7 years agoMissed a file in r289503.
Chris Bieneman [Tue, 13 Dec 2016 00:32:43 +0000 (00:32 +0000)]
Missed a file in r289503.

llvm-svn: 289504

7 years ago[LIT] Fix system-windows
Chris Bieneman [Tue, 13 Dec 2016 00:29:56 +0000 (00:29 +0000)]
[LIT] Fix system-windows

Turns out if you were on windows and your default target wasn't windows the system-windows feature wasn't getting enabled.

This fixes that and updates the coff-dwarf test to rely on the new "target-windows" feature. That test was the reason why system-windows was changed to not always be enabled on Windows hosts.

llvm-svn: 289503

7 years agoRevert "Suppress LLVM::tools/llvm-symbolizer/coff-dwarf.test for mingw, for now."
Chris Bieneman [Tue, 13 Dec 2016 00:29:51 +0000 (00:29 +0000)]
Revert "Suppress LLVM::tools/llvm-symbolizer/coff-dwarf.test for mingw, for now."

This reverts commit r249937.

llvm-svn: 289502

7 years ago[XRay][compiler-rt] Use explicit comparisons in unit tests.
Dean Michael Berris [Tue, 13 Dec 2016 00:17:31 +0000 (00:17 +0000)]
[XRay][compiler-rt] Use explicit comparisons in unit tests.

Summary:
This should improve the error messages generated providing a bit more
information when the failures are printed out. One example of a
contrived error looks like:

```
Expected: (Buffers.getBuffer(Buf)) != (std::error_code()), actual:
system:0 vs system:0
```

Because we're using error codes, the default printing gets us more
useful information in case of failure.

This is a follow-up on D26232.

Reviewers: rSerge

Subscribers: llvm-commits

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

llvm-svn: 289501

7 years agoSimplify the test. NFC.
Rafael Espindola [Mon, 12 Dec 2016 23:52:21 +0000 (23:52 +0000)]
Simplify the test. NFC.

llvm-svn: 289499

7 years ago[sancov] __sanitizer_dump_coverage api
Mike Aizatsky [Mon, 12 Dec 2016 23:45:38 +0000 (23:45 +0000)]
[sancov] __sanitizer_dump_coverage api

Subscribers: kubabrecka, mgorny

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

llvm-svn: 289498

7 years ago[llvm-config] Unsupported should be win32
Chris Bieneman [Mon, 12 Dec 2016 23:42:08 +0000 (23:42 +0000)]
[llvm-config] Unsupported should be win32

Hopefully this will fix the failing Windows bot.

llvm-svn: 289497

7 years agoStop lying about pointers' required alignments.
Tim Northover [Mon, 12 Dec 2016 23:29:07 +0000 (23:29 +0000)]
Stop lying about pointers' required alignments.

These extra specializations were added in the depths of history (r67984 from
2009) and are clearly problematic now. The pointers actually are aligned to the
default (8 bytes), since otherwise UBsan would be complaining loudly.

I *think* it originally made sense because there was no "alignof" to infer the
correct value so the generic case went with what malloc returned (8-byte
aliged objects), and on 32-bit machines this specialization was correct. It
became wrong when we started compiling for 64-bit, and caused a UBSan failure
when we tried to put a ValueHandle into a DenseMap.

Should fix the Green Dragon UBSan bot.

llvm-svn: 289496

7 years ago[libFuzzer] Implement Timers for Windows.
Marcos Pividori [Mon, 12 Dec 2016 23:25:11 +0000 (23:25 +0000)]
[libFuzzer] Implement Timers for Windows.

Implemented timeouts for Windows using TimerQueueTimers.
Timers are used to supervise the time of execution of the
callback function that is being fuzzed.

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

llvm-svn: 289495

7 years agoRevert "[Modules] Make header inclusion order from umbrella dirs deterministic"
Bruno Cardoso Lopes [Mon, 12 Dec 2016 23:22:30 +0000 (23:22 +0000)]
Revert "[Modules] Make header inclusion order from umbrella dirs deterministic"

Reverts commit r289478.

This broke
http://lab.llvm.org:8011/builders/clang-ppc64be-linux/builds/2070
(and maybe
http://lab.llvm.org:8011/builders/clang-x86_64-linux-selfhost-modules-2/builds/2246)

llvm-svn: 289494

7 years ago[x86] fix test specifications
Sanjay Patel [Mon, 12 Dec 2016 23:16:35 +0000 (23:16 +0000)]
[x86] fix test specifications

llvm-svn: 289493

7 years ago[x86] fix test specifications and auto-generate checks
Sanjay Patel [Mon, 12 Dec 2016 23:15:15 +0000 (23:15 +0000)]
[x86] fix test specifications and auto-generate checks

llvm-svn: 289492

7 years ago[CMake] Multi-target builtins build
Petr Hosek [Mon, 12 Dec 2016 23:15:10 +0000 (23:15 +0000)]
[CMake] Multi-target builtins build

This change enables building builtins for multiple different targets
using LLVM runtimes directory.

To specify the builtin targets to be built, use the LLVM_BUILTIN_TARGETS
variable, where the value is the list of targets.  To pass a per target
variable to the builtin build, you can set BUILTINS_<target>_<variable>
where <variable> will be passed to the builtin build for <target>.

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

llvm-svn: 289491

7 years agoRevert "Disable all llvm-config tests for now, will investigate later"
Chris Bieneman [Mon, 12 Dec 2016 23:14:58 +0000 (23:14 +0000)]
Revert "Disable all llvm-config tests for now, will investigate later"

This reverts commit r260386.

These tests all pass for me locally. I have no idea if they will pass on all configurations, so I'll watch the bots closely.

llvm-svn: 289490

7 years ago[compiler-rt] Support building builtins for a single target
Petr Hosek [Mon, 12 Dec 2016 23:14:02 +0000 (23:14 +0000)]
[compiler-rt] Support building builtins for a single target

This is used when building builtins for multiple targets as part
of LLVM runtimes.

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

llvm-svn: 289489

7 years ago[llvm-config] Fix bug where `--libfiles` and `--names` would produce
Dan Liew [Mon, 12 Dec 2016 23:07:22 +0000 (23:07 +0000)]
[llvm-config] Fix bug where `--libfiles` and `--names` would produce
incorrect output when LLVM is built with `LLVM_BUILD_LLVM_DYLIB`.

`llvm-config` previously produced output like this

```
$ llvm-config --libfiles
/usr/lib/liblibLLVM-4.0svn.so.so
$ llvm-config --libnames
liblibLLVM-4.0svn.so.so
```

The library prefix and shared library extension were added to
the library name twice which was wrong.

I wanted to write a test cases for this but it looks like **all**
`llvm-config` tests were disabled by r260386 so I'll leave this for
now.

Subscribers: llvm-commits, tstellarAMD

Reviewers: beanz, DiamondLovesYou, axw

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

llvm-svn: 289488

7 years agoRevert "[Headers] Add #include_next for tgmath.h on Darwin"
Bruno Cardoso Lopes [Mon, 12 Dec 2016 23:06:58 +0000 (23:06 +0000)]
Revert "[Headers] Add #include_next for tgmath.h on Darwin"

Reverts r289181: it's currently breaking modules using simd.h in
10.12 SDK.

This reverts commit 6e73e3464e96a4e00492c24aa790d36e1adb5702.

llvm-svn: 289487

7 years agoAvoid infinite loops in branch folding
Andrew Kaylor [Mon, 12 Dec 2016 23:05:38 +0000 (23:05 +0000)]
Avoid infinite loops in branch folding

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

llvm-svn: 289486

7 years agoclang-format to fix post-commit feedback
Chris Bieneman [Mon, 12 Dec 2016 23:05:15 +0000 (23:05 +0000)]
clang-format to fix post-commit feedback

Thanks dblaikie!

llvm-svn: 289485

7 years ago[llvm-config] Fix cflags test looking for "error"
Chris Bieneman [Mon, 12 Dec 2016 23:03:28 +0000 (23:03 +0000)]
[llvm-config] Fix cflags test looking for "error"

This test is (I think) actually trying to make sure no errors are printed, but it hits on the string "error" in flags.

llvm-svn: 289484

7 years agoRevert "Remove system-libs.test for now"
Chris Bieneman [Mon, 12 Dec 2016 23:03:01 +0000 (23:03 +0000)]
Revert "Remove system-libs.test for now"

This reverts commit r260281.

llvm-svn: 289483

7 years agoRevert "[SCEVExpander] Use llvm data structures; NFC"
Sanjoy Das [Mon, 12 Dec 2016 23:00:12 +0000 (23:00 +0000)]
Revert "[SCEVExpander] Use llvm data structures; NFC"

This reverts r289215 (git SHA1 cb7b86a1).  It breaks the ubsan build
because a DenseMap that keys off of `AssertingVH<T>` will hit UB when it
tries to cast the empty and tombstone keys to `T *` (due to insufficient
alignment).

This is the relevant stack trace (thanks to Mike Aizatsky):

    #0 0x25cf100 in llvm::AssertingVH<llvm::PHINode>::getValPtr() const llvm/include/llvm/IR/ValueHandle.h:212:39
    #1 0x25cea20 in llvm::AssertingVH<llvm::PHINode>::operator=(llvm::AssertingVH<llvm::PHINode> const&) llvm/include/llvm/IR/ValueHandle.h:234:19
    #2 0x25d0092 in llvm::DenseMapBase<llvm::DenseMap<llvm::AssertingVH<llvm::PHINode>, llvm::detail::DenseSetEmpty, llvm::DenseMapInfo<llvm::AssertingVH<llvm::PHINode> >, llvm::detail::DenseSetPair<llvm::AssertingVH<llvm::PHINode> > >, llvm::AssertingVH<llvm::PHINode>, llvm::detail::DenseSetEmpty, llvm::DenseMapInfo<llvm::AssertingVH<llvm::PHINode> >, llvm::detail::DenseSetPair<llvm::AssertingVH<llvm::PHINode> > >::clear() llvm/include/llvm/ADT/DenseMap.h:113:23

llvm-svn: 289482

7 years ago[libFuzzer] split one slow test into several, for more parallel testing
Kostya Serebryany [Mon, 12 Dec 2016 22:55:25 +0000 (22:55 +0000)]
[libFuzzer] split one slow test into several, for more parallel testing

llvm-svn: 289481

7 years agoFix MSVC build after 289461; MSVC isn't sure if this is std:: or llvm::
Nico Weber [Mon, 12 Dec 2016 22:46:40 +0000 (22:46 +0000)]
Fix MSVC build after 289461; MSVC isn't sure if this is std:: or llvm::

llvm-svn: 289480

7 years agoRemoving myself from code ownership file
Todd Fiala [Mon, 12 Dec 2016 22:42:00 +0000 (22:42 +0000)]
Removing myself from code ownership file

I'm transitioning away from my current employer, and I do not foresee myself
spending much time on LLDB in the near future. Ideally somebody on the Google
Android team takes over the gdb-remote protocol tests, and somebody with decent
familiarity with the test suite infrastructure takes over the parallel test
runner and test event stream portions of the Python test suite.

llvm-svn: 289479

7 years ago[Modules] Make header inclusion order from umbrella dirs deterministic
Bruno Cardoso Lopes [Mon, 12 Dec 2016 22:41:20 +0000 (22:41 +0000)]
[Modules] Make header inclusion order from umbrella dirs deterministic

Sort the headers by name before adding the includes in
collectModuleHeaderIncludes. This makes the include order for building
umbrellas deterministic across different filesystems and also guarantees
that the ASTWriter always dump top headers in the same order.

There's currently no good way to test for this behavior.

rdar://problem/28116411

llvm-svn: 289478

7 years ago[libFuzzer] make SimpleCmpTest a bit simpler to crack and more verbose
Kostya Serebryany [Mon, 12 Dec 2016 22:39:33 +0000 (22:39 +0000)]
[libFuzzer] make  SimpleCmpTest a bit simpler to crack and more verbose

llvm-svn: 289477

7 years ago[x86] fix formatting; NFC
Sanjay Patel [Mon, 12 Dec 2016 22:31:01 +0000 (22:31 +0000)]
[x86] fix formatting; NFC

llvm-svn: 289476

7 years ago[AMDGPU, PowerPC, TableGen] Fix some Clang-tidy modernize and Include What You Use...
Eugene Zelenko [Mon, 12 Dec 2016 22:23:53 +0000 (22:23 +0000)]
[AMDGPU, PowerPC, TableGen] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).

llvm-svn: 289475

7 years ago[APFloatTest] Use std::make_tuple to make GCC 4.8 happy
Tim Shen [Mon, 12 Dec 2016 22:16:08 +0000 (22:16 +0000)]
[APFloatTest] Use std::make_tuple to make GCC 4.8 happy

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

llvm-svn: 289474

7 years ago[PPC] Prefer direct move on power8 if load 1 or 2 bytes to VSR
Guozhi Wei [Mon, 12 Dec 2016 22:09:02 +0000 (22:09 +0000)]
[PPC] Prefer direct move on power8 if load 1 or 2 bytes to VSR

Power8 has MTVSRWZ but no LXSIBZX/LXSIHZX, so move 1 or 2 bytes to VSR through MTVSRWZ is much faster than store the extended value into stack and load it with LXSIWZX.
This patch fixes pr31144.

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

llvm-svn: 289473

7 years ago[APFloat] Implement PPCDoubleDouble add and subtract.
Tim Shen [Mon, 12 Dec 2016 21:59:30 +0000 (21:59 +0000)]
[APFloat] Implement PPCDoubleDouble add and subtract.

Summary:
I looked at libgcc's implementation (which is based on the paper,
Software for Doubled-Precision Floating-Point Computations", by Seppo Linnainmaa,
ACM TOMS vol 7 no 3, September 1981, pages 272-283.) and made it generic to
arbitrary IEEE floats.

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

llvm-svn: 289472

7 years ago[ELF][MIPS] Calculate default _gp value relative to the GPREL section with the lowest...
Simon Atanasyan [Mon, 12 Dec 2016 21:34:11 +0000 (21:34 +0000)]
[ELF][MIPS] Calculate default _gp value relative to the GPREL section with the lowest address

llvm-svn: 289471

7 years ago[SLP] Fix sign-extends for type-shrinking
Matthew Simpson [Mon, 12 Dec 2016 21:11:04 +0000 (21:11 +0000)]
[SLP] Fix sign-extends for type-shrinking

This patch ensures the correct minimum bit width during type-shrinking.
Previously when type-shrinking, we always sign-extended values back to their
original width. However, if we are going to sign-extend, and the sign bit is
unknown, we have to increase the minimum bit width by one bit so the
sign-extend will fill the upper bits correctly. If the sign bit is known to be
zero, we can perform a zero-extend instead. This should fix PR31243.

Reference: https://llvm.org/bugs/show_bug.cgi?id=31243
Differential Revision: https://reviews.llvm.org/D27466

llvm-svn: 289470

7 years ago[libFuzzer] build libFuzzer itself with asan
Kostya Serebryany [Mon, 12 Dec 2016 20:58:10 +0000 (20:58 +0000)]
[libFuzzer] build libFuzzer itself with asan

llvm-svn: 289469

7 years agoRecommit r288212: Emit 'no line' information for interesting 'orphan' instructions.
Paul Robinson [Mon, 12 Dec 2016 20:49:11 +0000 (20:49 +0000)]
Recommit r288212: Emit 'no line' information for interesting 'orphan' instructions.

DWARF specifies that "line 0" really means "no appropriate source
location" in the line table.  By default, use this for branch targets
and some other cases that have no specified source location, to
prevent inheriting unfortunate line numbers from physically preceding
instructions (which might be from completely unrelated source).

Updated patch allows enabling or suppressing this behavior for all
unspecified source locations.

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

llvm-svn: 289468

7 years ago[libFuzzer] respect -max_len during merge
Kostya Serebryany [Mon, 12 Dec 2016 20:39:35 +0000 (20:39 +0000)]
[libFuzzer] respect -max_len during merge

llvm-svn: 289467

7 years ago[ThinLTO] Remove useless code (NFC)
Teresa Johnson [Mon, 12 Dec 2016 20:34:28 +0000 (20:34 +0000)]
[ThinLTO] Remove useless code (NFC)

Should have been removed in r288446.

llvm-svn: 289466

7 years ago[clang-move] Fix buildbot failures
Alexander Shaposhnikov [Mon, 12 Dec 2016 20:24:44 +0000 (20:24 +0000)]
[clang-move] Fix buildbot failures

Fix the buildbot failures introduced by D27669

llvm-svn: 289465

7 years ago[clang-move] Use appendArgumentsAdjuster for adding extra arguments
Alexander Shaposhnikov [Mon, 12 Dec 2016 19:56:37 +0000 (19:56 +0000)]
[clang-move] Use appendArgumentsAdjuster for adding extra arguments

1. Remove some boilerplate code for appending -fparse-all-comments to the list of arguments.
2. Run clang-format -i against ClangMoveMain.cpp.

Test plan: make check-all

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

llvm-svn: 289464

7 years ago[libcxx] [test] Change ifstream constructor tests to handle read-only files.
Stephan T. Lavavej [Mon, 12 Dec 2016 19:50:22 +0000 (19:50 +0000)]
[libcxx] [test] Change ifstream constructor tests to handle read-only files.

Certain source control systems like to set the read-only bit on their files,
which interferes with opening "test.dat" for both input and output.
Fortunately, we can work around this without losing test coverage.
Now, the ifstream.cons tests have comments referring to the ofstream.cons tests.
There, we're creating writable files (not checked into source control),
where the ifstream constructor tests will succeed.

Fixes D26814.

llvm-svn: 289463

7 years ago[libcxx] [test] Fix an improper assumption about Null Forward Iterators.
Stephan T. Lavavej [Mon, 12 Dec 2016 19:50:14 +0000 (19:50 +0000)]
[libcxx] [test] Fix an improper assumption about Null Forward Iterators.

Value-initialized iterators still can't be compared to those with parents.

Fixes D26626.

llvm-svn: 289462

7 years agoRefactor BitcodeReader: move Metadata and ValueId handling in their own class/file
Mehdi Amini [Mon, 12 Dec 2016 19:34:26 +0000 (19:34 +0000)]
Refactor BitcodeReader: move Metadata and ValueId handling in their own class/file

Summary:
I'm planning on changing the way we load metadata to enable laziness.
I'm getting lost in this gigantic files, and gigantic class that is the bitcode
reader. This is a first toward splitting it in a few coarse components that
are more easily understandable.

Reviewers: pcc, tejohnson

Subscribers: mgorny, llvm-commits, dexonsmith

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

llvm-svn: 289461

7 years ago[CrashReproducer] Collect PCH included via -include-pch
Bruno Cardoso Lopes [Mon, 12 Dec 2016 19:28:25 +0000 (19:28 +0000)]
[CrashReproducer] Collect PCH included via -include-pch

Collect the necessary input PCH files.

Do not try to validate the AST before copying it out because if the
crash is in this path, we won't be able to collect it. Instead only
check if it's a file containg an AST.

rdar://problem/27913709

llvm-svn: 289460