platform/upstream/llvm.git
8 years agoRemove usage of LLVM_PREFIX.
Chaoren Lin [Fri, 18 Mar 2016 00:05:37 +0000 (00:05 +0000)]
Remove usage of LLVM_PREFIX.

Summary: LLVM_PREFIX could be undefined if CMAKE_INSTALL_PREFIX were set to empty.

Reviewers: kparzysz, bkramer, chandlerc

Subscribers: cfe-commits

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

llvm-svn: 263766

8 years agoDebugInfo: Add ability to not emit DW_AT_vtable_elem_location for virtual functions.
Peter Collingbourne [Thu, 17 Mar 2016 23:58:03 +0000 (23:58 +0000)]
DebugInfo: Add ability to not emit DW_AT_vtable_elem_location for virtual functions.

A virtual index of -1u indicates that the subprogram's virtual index is
unrepresentable (for example, when using the relative vtable ABI), so do
not emit a DW_AT_vtable_elem_location attribute for it.

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

llvm-svn: 263765

8 years ago[Support] Address some of dblaikie's feedback for r263749.
Lang Hames [Thu, 17 Mar 2016 23:43:33 +0000 (23:43 +0000)]
[Support] Address some of dblaikie's feedback for r263749.

Fixes some missing std::moves and take Expected<T> by rvalue reference in the
call operator.

llvm-svn: 263764

8 years ago[LTO] Test lto passes are actually working.
Davide Italiano [Thu, 17 Mar 2016 23:36:31 +0000 (23:36 +0000)]
[LTO] Test lto passes are actually working.

This should have been part of r263761.

llvm-svn: 263763

8 years agoMake evaluation order explicit.
Rafael Espindola [Thu, 17 Mar 2016 23:36:19 +0000 (23:36 +0000)]
Make evaluation order explicit.

llvm-svn: 263762

8 years ago[LTO] Call the optimizer before invoking codegen.
Davide Italiano [Thu, 17 Mar 2016 23:35:34 +0000 (23:35 +0000)]
[LTO] Call the optimizer before invoking codegen.

This is the required plumbing needed to run the LTO passes.

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

llvm-svn: 263761

8 years agoRevert "allow lambdas in mapped_iterator"
Mike Aizatsky [Thu, 17 Mar 2016 23:32:20 +0000 (23:32 +0000)]
Revert "allow lambdas in mapped_iterator"

MSVC as usual:

C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\include\llvm/ADT/STLExtras.h(120):
error C2100: illegal indirection
C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\include\llvm/IR/Instructions.h(3966):
note: see reference to class template instantiation
'llvm::mapped_iterator<llvm::User::op_iterator,llvm::CatchSwitchInst::DerefFnTy>'
being compiled

This reverts commit e091dd63f1f34e043748e28ad160d3bc17731168.

llvm-svn: 263760

8 years agoallow lambdas in mapped_iterator
Mike Aizatsky [Thu, 17 Mar 2016 23:22:22 +0000 (23:22 +0000)]
allow lambdas in mapped_iterator

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

llvm-svn: 263759

8 years ago[Docs] Fix a typo.
Alexey Samsonov [Thu, 17 Mar 2016 23:08:01 +0000 (23:08 +0000)]
[Docs] Fix a typo.

llvm-svn: 263754

8 years ago[PPC, FastISel] Fix ordered/unordered fcmp
Tim Shen [Thu, 17 Mar 2016 22:27:58 +0000 (22:27 +0000)]
[PPC, FastISel] Fix ordered/unordered fcmp

For fcmp, major concern about the following 6 cases is NaN result. The
comparison result consists of 4 bits, indicating lt, eq, gt and un (unordered),
only one of which will be set. The result is generated by fcmpu
instruction. However, bc instruction only inspects one of the first 3
bits, so when un is set, bc instruction may jump to to an undesired
place.

More specifically, if we expect an unordered comparison and un is set, we
expect to always go to true branch; in such case UEQ, UGT and ULT still
give false, which are undesired; but UNE, UGE, ULE happen to give true,
since they are tested by inspecting !eq, !lt, !gt, respectively.

Similarly, for ordered comparison, when un is set, we always expect the
result to be false. In such case OGT, OLT and OEQ is good, since they are
actually testing GT, LT, and EQ respectively, which are false. OGE, OLE
and ONE are tested through !lt, !gt and !eq, and these are true.

llvm-svn: 263753

8 years agoRevert r263687 for ubsan bot failure.
Manman Ren [Thu, 17 Mar 2016 22:13:50 +0000 (22:13 +0000)]
Revert r263687 for ubsan bot failure.

llvm-svn: 263752

8 years ago[CMake] Remove bash-ism in SanitizerLintCheck
Alexey Samsonov [Thu, 17 Mar 2016 21:41:08 +0000 (21:41 +0000)]
[CMake] Remove bash-ism in SanitizerLintCheck

llvm-svn: 263751

8 years agoRevert "Reapply [VFS] Add 'overlay-relative' field to YAML files"
Bruno Cardoso Lopes [Thu, 17 Mar 2016 21:30:55 +0000 (21:30 +0000)]
Revert "Reapply [VFS] Add 'overlay-relative' field to YAML files"

Tests failing on
http://bb.pgr.jp/builders/cmake-clang-x86_64-linux/builds/46102

This reverts commit a1683cd6c9e07359c09f86e98a4db6b4e1bc51fc.

llvm-svn: 263750

8 years ago[Support] Add ExitOnError utility to support tools that use the exit-on-error
Lang Hames [Thu, 17 Mar 2016 21:28:49 +0000 (21:28 +0000)]
[Support] Add ExitOnError utility to support tools that use the exit-on-error
idiom.

Most LLVM tool code exits immediately when an error is encountered and prints an
error message to stderr. The ExitOnError class supports this by providing two
call operators - one for Errors, and one for Expected<T>s. Calls to code that
can return Errors (or Expected<T>s) can use these calls to bail out on error,
and otherwise continue as if the operation had succeeded. E.g.

Error foo();
Expected<int> bar();

int main(int argc, char *argv[]) {
  ExitOnError ExitOnErr;

  ExitOnErr.setBanner(std::string("Error in ") + argv[0] + ":");

  // Exit if foo returns an error. No need to manually check error return.
  ExitOnErr(foo());

  // Exit if bar returns an error, otherwise unwrap the contained int and
  // continue.
  int X = ExitOnErr(bar());

  // ...

  return 0;
}

llvm-svn: 263749

8 years agoReapply [VFS] Add 'overlay-relative' field to YAML files
Bruno Cardoso Lopes [Thu, 17 Mar 2016 21:11:23 +0000 (21:11 +0000)]
Reapply [VFS] Add 'overlay-relative' field to YAML files

This reapplies r261552.

The VFS overlay mapping between virtual paths and real paths is done through
the 'external-contents' entries in YAML files, which contains hardcoded paths
to the real files.

When a module compilation crashes, headers are dumped into <name>.cache/vfs
directory and are mapped via the <name>.cache/vfs/vfs.yaml. The script
generated for reproduction uses -ivfsoverlay pointing to file to gather the
mapping between virtual paths and files inside <name>.cache/vfs. Currently, we
are only capable of reproducing such crashes in the same machine as they
happen, because of the hardcoded paths in 'external-contents'.

To be able to reproduce a crash in another machine, this patch introduces a new
option in the VFS yaml file called 'overlay-relative'. When it's equal to
'true' it means that the provided path to the YAML file through the
-ivfsoverlay option should also be used to prefix the final path for every
'external-contents'.

Example, given the invocation snippet "... -ivfsoverlay
<name>.cache/vfs/vfs.yaml" and the following entry in the yaml file:

"overlay-relative": "true",
"roots": [
...
  "type": "directory",
  "name": "/usr/include",
  "contents": [
    {
      "type": "file",
      "name": "stdio.h",
      "external-contents": "/usr/include/stdio.h"
    },
...

Here, a file manager request for virtual "/usr/include/stdio.h", that will map
into real path "/<absolute_path_to>/<name>.cache/vfs/usr/include/stdio.h.

This is a useful feature for debugging module crashes in machines other than
the one where the error happened.

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

rdar://problem/24499339

llvm-svn: 263748

8 years agoRe-add (user defined) move ops to UnresolvedSetImpl to allow UnresolvedSet to be...
David Blaikie [Thu, 17 Mar 2016 20:45:38 +0000 (20:45 +0000)]
Re-add (user defined) move ops to UnresolvedSetImpl to allow UnresolvedSet to be implicitly movable

llvm-svn: 263747

8 years agounord: Extract key to avoid preemptive mallocs in insert/emplace
Duncan P. N. Exon Smith [Thu, 17 Mar 2016 20:45:20 +0000 (20:45 +0000)]
unord: Extract key to avoid preemptive mallocs in insert/emplace

unordered_set::emplace and unordered_map::emplace construct a node, then
try to insert it.  If insertion fails, the node gets deleted.

To avoid this unnecessary malloc traffic, check to see if the argument
to emplace has the appropriate key_type.  If so, we can use that key
directly and delay the malloc until we're sure we're inserting something
new.

Test updates by Eric Fiselier, who rewrote the old allocation tests to
include the new cases.

There are two orthogonal future directions:

1. Apply the same optimization to set and map.

2. Extend the optimization to when the argument is not key_type, but can
   be converted to it without side effects.  Ideally, we could do this
   whenever key_type is trivially destructible and the argument is
   trivially convertible to key_type, but in practise the relevant type
   traits "blow up sometimes".  At least, we should catch a few simple
   cases (such as when both are primitive types).

llvm-svn: 263746

8 years ago[Support] Make Error::isA<T>() works on success values.
Lang Hames [Thu, 17 Mar 2016 20:35:00 +0000 (20:35 +0000)]
[Support] Make Error::isA<T>() works on success values.

llvm-svn: 263745

8 years ago[LoopVectorize] Annotate versioned loop with noalias metadata
Adam Nemet [Thu, 17 Mar 2016 20:32:37 +0000 (20:32 +0000)]
[LoopVectorize] Annotate versioned loop with noalias metadata

Summary:
Use the new LoopVersioning facility (D16712) to add noalias metadata in
the vector loop if we versioned with memchecks.  This can enable some
optimization opportunities further down the pipeline (see the included
test or the benchmark improvement quoted in D16712).

The test also covers the bug I had in the initial version in D16712.

The vectorizer did not previously use LoopVersioning.  The reason is
that the vectorizer performs its transformations in single shot.  It
creates an empty single-block vector loop that it then populates with
the widened, if-converted instructions.  Thus creating an intermediate
versioned scalar loop seems wasteful.

So this patch (rather than bringing in LoopVersioning fully) adds a
special interface to LoopVersioning to allow the vectorizer to add
no-alias annotation while still performing its own versioning.

As the vectorizer propagates metadata from the instructions in the
original loop to the vector instructions we also check the pointer in
the original instruction and see if LoopVersioning can add no-alias
metadata based on the issued memchecks.

Reviewers: hfinkel, nadav, mzolotukhin

Subscribers: mzolotukhin, llvm-commits

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

llvm-svn: 263744

8 years ago[LoopVersioning] Annotate versioned loop with noalias metadata
Adam Nemet [Thu, 17 Mar 2016 20:32:32 +0000 (20:32 +0000)]
[LoopVersioning] Annotate versioned loop with noalias metadata

Summary:
If we decide to version a loop to benefit a transformation, it makes
sense to record the now non-aliasing accesses in the newly versioned
loop.  This allows non-aliasing information to be used by subsequent
passes.

One example is 456.hmmer in SPECint2006 where after loop distribution,
we vectorize one of the newly distributed loops.  To vectorize we
version this loop to fully disambiguate may-aliasing accesses.  If we
add the noalias markers, we can use the same information in a later DSE
pass to eliminate some dead stores which amounts to ~25% of the
instructions of this hot memory-pipeline-bound loop.  The overall
performance improves by 18% on our ARM64.

The scoped noalias annotation is added in LoopVersioning.  The patch
then enables this for loop distribution.  A follow-on patch will enable
it for the vectorizer.  Eventually this should be run by default when
versioning the loop but first I'd like to get some feedback whether my
understanding and application of scoped noalias metadata is correct.

Essentially my approach was to have a separate alias domain for each
versioning of the loop.  For example, if we first version in loop
distribution and then in vectorization of the distributed loops, we have
a different set of memchecks for each versioning.  By keeping the scopes
in different domains they can conveniently be defined independently
since different alias domains don't affect each other.

As written, I also have a separate domain for each loop.  This is not
necessary and we could save some metadata here by using the same domain
across the different loops.  I don't think it's a big deal either way.

Probably the best is to review the tests first to see if I mapped this
problem correctly to scoped noalias markers.  I have plenty of comments
in the tests.

Note that the interface is prepared for the vectorizer which needs the
annotateInstWithNoAlias API.  The vectorizer does not use LoopVersioning
so we need a way to pass in the versioned instructions.  This is also
why the maps have to become part of the object state.

Also currently, we only have an AA-aware DSE after the vectorizer if we
also run the LTO pipeline.  Depending how widely this triggers we may
want to schedule a DSE toward the end of the regular pass pipeline.

Reviewers: hfinkel, nadav, ashutosh.nema

Subscribers: mssimpso, aemerson, llvm-commits, mcrosier

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

llvm-svn: 263743

8 years agoBitcode: Error out instead of crashing on corrupt metadata
Justin Bogner [Thu, 17 Mar 2016 20:12:06 +0000 (20:12 +0000)]
Bitcode: Error out instead of crashing on corrupt metadata

I hit a crash in the bitcode reader on some corrupt input where an
MDString had somehow been attached to an instruction instead of an
MDNode. This input is pretty bogus, but we shouldn't be crashing on bad
input here.

This change adds error handling in all of the places where we
currently have unchecked casts from Metadata to MDNode, which means
we'll error out instead of crashing for that sort of input.

Unfortunately, I don't have tests. Hitting this requires flipping bits
in the input bitcode, and committing corrupt binary files to catch
these cases is a bit too opaque and unmaintainable.

llvm-svn: 263742

8 years agoARM: stop asserting on weird <3 x Ty> vectors in ISelLowering.
Tim Northover [Thu, 17 Mar 2016 20:10:28 +0000 (20:10 +0000)]
ARM: stop asserting on weird <3 x Ty> vectors in ISelLowering.

llvm-svn: 263741

8 years agoRevert "For MS ABI, emit dllexport friend functions defined inline in class"
Reid Kleckner [Thu, 17 Mar 2016 20:06:58 +0000 (20:06 +0000)]
Revert "For MS ABI, emit dllexport friend functions defined inline in class"

This reverts commit r263738.

This appears to cause a failure in
CXX/temp/temp.decls/temp.friend/p1.cpp

llvm-svn: 263740

8 years ago[libFuzzer] deprecate several flags
Kostya Serebryany [Thu, 17 Mar 2016 19:59:39 +0000 (19:59 +0000)]
[libFuzzer] deprecate several flags

llvm-svn: 263739

8 years agoFor MS ABI, emit dllexport friend functions defined inline in class
Reid Kleckner [Thu, 17 Mar 2016 19:52:20 +0000 (19:52 +0000)]
For MS ABI, emit dllexport friend functions defined inline in class

Summary: ...as that is apparently what MSVC does

Reviewers: rnk

Patch by Stephan Bergmann

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

llvm-svn: 263738

8 years ago[libFuzzer] add __attribute__((no_sanitize_memory)) to two functions that may be...
Kostya Serebryany [Thu, 17 Mar 2016 19:42:35 +0000 (19:42 +0000)]
[libFuzzer] add __attribute__((no_sanitize_memory)) to two functions that may be called from signal handler(s) or from msan. This will hopefully avoid msan false reports which I can't reproduce

llvm-svn: 263737

8 years ago[msan fix] unitalized variable
Michael J. Spencer [Thu, 17 Mar 2016 19:16:54 +0000 (19:16 +0000)]
[msan fix] unitalized variable

llvm-svn: 263736

8 years agoFix deadlock due to thread list locking in 'bt all' with obj-c
Stephane Sezer [Thu, 17 Mar 2016 18:52:41 +0000 (18:52 +0000)]
Fix deadlock due to thread list locking in 'bt all' with obj-c

Summary:
The gdb-remote async thread cannot modify thread state while the main thread
holds a lock on the state. Don't use locking thread iteration for bt all.

Specifically, the deadlock manifests when lldb attempts to JIT code to
symbolicate objective c while backtracing. As part of this code path,
SetPrivateState() is called on an async thread. This async thread will
block waiting for the thread_list lock held by the main thread in
CommandObjectIterateOverThreads. The main thread will also block on the
async thread during DoResume (although with a timeout), leading to a
deadlock. Due to the timeout, the deadlock is not immediately apparent,
but the inferior will be left in an invalid state after the bt all completes,
and objective-c symbols will not be successfully resolved in the backtrace.

Reviewers: andrew.w.kaylor, jingham, clayborg

Subscribers: sas, lldb-commits

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

Change by Francis Ricci <fjricci@fb.com>

llvm-svn: 263735

8 years ago[InstCombine] Combine A->B->A BitCast
Guozhi Wei [Thu, 17 Mar 2016 18:47:20 +0000 (18:47 +0000)]
[InstCombine] Combine A->B->A BitCast

This patch enhances InstCombine to handle following case:

        A  ->  B    bitcast
        PHI
        B  ->  A    bitcast

llvm-svn: 263734

8 years ago[Statepoints] Export a magic constant into a header; NFC
Sanjoy Das [Thu, 17 Mar 2016 18:42:17 +0000 (18:42 +0000)]
[Statepoints] Export a magic constant into a header; NFC

llvm-svn: 263733

8 years agoRemove defaulted move ops, the type is zero-cost copyable anyway, so there's no need...
David Blaikie [Thu, 17 Mar 2016 18:28:16 +0000 (18:28 +0000)]
Remove defaulted move ops, the type is zero-cost copyable anyway, so there's no need for specific move ops

(addresses MSVC build error, since MSVC 2013 can't generate default move
ops)

llvm-svn: 263732

8 years ago[lit] Enqueue tests on a separate thread to not hit limits on parallel queues
Filipe Cabecinhas [Thu, 17 Mar 2016 18:27:33 +0000 (18:27 +0000)]
[lit] Enqueue tests on a separate thread to not hit limits on parallel queues

Summary:
The multiprocessing.Queue.put() call can hang if we try queueing all the
tests before starting to take them out of the queue.
The current implementation hangs if tests exceed 2^^15, on Mac OS X.
This might happen with a ninja check-all if one has a bunch of llvm
projects.

Reviewers: delcypher, bkramer

Subscribers: llvm-commits

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

llvm-svn: 263731

8 years agoFix implicit copy ctor and copy assignment operator warnings when -Wdeprecated passed.
David Blaikie [Thu, 17 Mar 2016 18:05:07 +0000 (18:05 +0000)]
Fix implicit copy ctor and copy assignment operator warnings when -Wdeprecated passed.

Fix implicit copy ctor and copy assignment operator warnings
when -Wdeprecated passed.

Patch by Don Hinton!

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

llvm-svn: 263730

8 years ago[AMDGPU] add VI disassembler tests. NFC.
Valery Pykhtin [Thu, 17 Mar 2016 17:56:33 +0000 (17:56 +0000)]
[AMDGPU] add VI disassembler tests. NFC.

Autogenerated from the corresponding assembler tests with a few FIXME added (will fix soon).

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

llvm-svn: 263729

8 years ago[PowerPC] Disable CTR loops optimization for soft float operations
Petar Jovanovic [Thu, 17 Mar 2016 17:11:33 +0000 (17:11 +0000)]
[PowerPC] Disable CTR loops optimization for soft float operations

This patch prevents CTR loops optimization when using soft float operations
inside loop body. Soft float operations use function calls, but function
calls are not allowed inside CTR optimized loops.

Patch by Aleksandar Beserminji.

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

llvm-svn: 263727

8 years agoFix Clang-tidy modernize-deprecated-headers warnings; other minor fixes.
Eugene Zelenko [Thu, 17 Mar 2016 17:02:25 +0000 (17:02 +0000)]
Fix Clang-tidy modernize-deprecated-headers warnings; other minor fixes.

Differential revision: http://reviews.llvm.org/D18231

llvm-svn: 263726

8 years ago[WebAssembly] Stackify code emitted by eliminateFrameIndex and SP writeback
Derek Schuff [Thu, 17 Mar 2016 17:00:29 +0000 (17:00 +0000)]
[WebAssembly] Stackify code emitted by eliminateFrameIndex and SP writeback

Summary:
MRI::eliminateFrameIndex can emit several instructions to do address
calculations; these can usually be stackified. Because instructions with
FI operands can have subsequent operands which may be expression trees,
find the top of the leftmost tree and insert the code before it, to keep
the LIFO property.

Also use stackified registers when writing back the SP value to memory
in the epilog; it's unnecessary because SP will not be used after the
epilog, and it results in better code.

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

llvm-svn: 263725

8 years ago[COFF] Use coff_section::getAlignment
David Majnemer [Thu, 17 Mar 2016 16:58:08 +0000 (16:58 +0000)]
[COFF] Use coff_section::getAlignment

Use LLVM's section alignment calculation instead of having LLD calculate
it.

llvm-svn: 263724

8 years ago[COFF] Fix invalid alignment in tests
David Majnemer [Thu, 17 Mar 2016 16:56:31 +0000 (16:56 +0000)]
[COFF] Fix invalid alignment in tests

Some COFF tests used INT_MIN for the alignment of the directive section.
This is invalid; replace the alignment with something more sensible: 1.

llvm-svn: 263723

8 years ago[COFF] Refactor section alignment calculation
David Majnemer [Thu, 17 Mar 2016 16:55:18 +0000 (16:55 +0000)]
[COFF] Refactor section alignment calculation

Section alignment isn't completely trivial, let it live in one place so
that we may reuse it in LLVM.

llvm-svn: 263722

8 years agoForgot to commit this with r263692
David Majnemer [Thu, 17 Mar 2016 16:55:11 +0000 (16:55 +0000)]
Forgot to commit this with r263692

llvm-svn: 263721

8 years agoAMDGPU/SI: Do not generate s_waitcnt after ds_permute/ds_bpermute
Changpeng Fang [Thu, 17 Mar 2016 16:43:50 +0000 (16:43 +0000)]
AMDGPU/SI: Do not generate s_waitcnt after ds_permute/ds_bpermute

Symmary:
  ds_permute/ds_bpermute do not read memory so s_waitcnt is not needed.

Reviewers
  arsenm, tstellarAMD

Subscribers
  llvm-commits, arsenm

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

llvm-svn: 263720

8 years agoAMDGPU: mark atomic instructions as sources of divergence
Nicolai Haehnle [Thu, 17 Mar 2016 16:21:59 +0000 (16:21 +0000)]
AMDGPU: mark atomic instructions as sources of divergence

Summary:
As explained by the comment, threads will typically see different values
returned by atomic instructions even if the arguments are equal.

Reviewers: arsenm, tstellarAMD

Subscribers: arsenm, llvm-commits

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

llvm-svn: 263719

8 years agoUse a simpler set of mock headers for the vfs+modules crash recovery tests.
Benjamin Kramer [Thu, 17 Mar 2016 16:19:51 +0000 (16:19 +0000)]
Use a simpler set of mock headers for the vfs+modules crash recovery tests.

The System/ mock is large and too complex for this test. It can cause
the tests to fail in mysterious ways as it depends on the resource dir
being present, which is not really supported for driver tests (using
%clang instead of %clang_cc1). Copy the tree and trim out all the
%unnecessary fat.

llvm-svn: 263718

8 years ago[X86][SSE] Simplified blend-with-zero combining
Simon Pilgrim [Thu, 17 Mar 2016 15:59:36 +0000 (15:59 +0000)]
[X86][SSE] Simplified blend-with-zero combining

We were being too aggressive in trying to combine a shuffle into a blend-with-zero pattern, often resulting in a endless loop of contrasting combines

This patch stops the combine if we already have a blend in place (means we miss some domain corrections)

llvm-svn: 263717

8 years agopropagate 'unpredictable' metadata on select instructions
Sanjay Patel [Thu, 17 Mar 2016 15:30:52 +0000 (15:30 +0000)]
propagate 'unpredictable' metadata on select instructions

This is similar to D18133 where we allowed profile weights on select instructions.
This extends that change to also allow the 'unpredictable' attribute of branches to apply to selects.

A test to check that 'unpredictable' metadata is preserved when cloning instructions was checked in at:
http://reviews.llvm.org/rL263648

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

llvm-svn: 263716

8 years agoARM: Revert SVN r253865, 254158, fix windows division
Saleem Abdulrasool [Thu, 17 Mar 2016 14:10:49 +0000 (14:10 +0000)]
ARM: Revert SVN r253865, 254158, fix windows division

The two changes together weakened the test and caused a regression with division
handling in MSVC mode.  They were applied to avoid an assertion being triggered
in the block frequency analysis.  However, the underlying problem was simply
being masked rather than solved properly.  Address the actual underlying problem
and revert the changes.  Rather than analyze the cause of the assertion, the
division failure was assumed to be an overflow.

The underlying issue was a subtle bug in the BB construction in the emission of
the div-by-zero check (WIN__DBZCHK).  We did not construct the proper successor
information in the basic blocks, nor did we update the PHIs associated with the
basic block when we split them.  This would result in assertions being triggered
in the block frequency analysis pass.

Although the original tests are being removed, the tests themselves performed
very little in terms of validation but merely tested that we did not assert when
generating code.  Update this with new tests that actually ensure that we do not
regress on the code generation.

llvm-svn: 263714

8 years agoclang-format: [JS] Make requoting of JavaScript string literals only
Daniel Jasper [Thu, 17 Mar 2016 13:03:41 +0000 (13:03 +0000)]
clang-format: [JS] Make requoting of JavaScript string literals only
change affected ranges.

llvm-svn: 263713

8 years ago[ELF][MIPS] Support R_MIPS_TLS_DTPREL_HI16/LO16 and R_MIPS_TLS_TPREL_HI16/LO16 reloca...
Simon Atanasyan [Thu, 17 Mar 2016 12:36:08 +0000 (12:36 +0000)]
[ELF][MIPS] Support R_MIPS_TLS_DTPREL_HI16/LO16 and R_MIPS_TLS_TPREL_HI16/LO16 relocations

That is initial and the most trivial patch to support TLS for MIPS targets.

llvm-svn: 263712

8 years ago[ELF][MIPS] Add test case to check number of redundant entries in the local part...
Simon Atanasyan [Thu, 17 Mar 2016 12:36:00 +0000 (12:36 +0000)]
[ELF][MIPS] Add test case to check number of redundant entries in the local part of MIPS GOT. NFC.

llvm-svn: 263711

8 years agoclang-format: [JS] Fix incorrect spacing around contextual keywords.
Daniel Jasper [Thu, 17 Mar 2016 12:17:59 +0000 (12:17 +0000)]
clang-format: [JS] Fix incorrect spacing around contextual keywords.

Before:
  x.of ();

After:
  x.of();

llvm-svn: 263710

8 years agoclang-format: Slightly weaken AlignAfterOpenBracket=AlwaysBreak.
Daniel Jasper [Thu, 17 Mar 2016 12:00:22 +0000 (12:00 +0000)]
clang-format: Slightly weaken AlignAfterOpenBracket=AlwaysBreak.

If a call takes a single argument, using AlwaysBreak can lead to lots
of wasted lines and additional indentation without improving the
readability in a significant way.

Before:
  caaaaaaaaaaaall(
      caaaaaaaaaaaall(
          caaaaaaaaaaaall(
              caaaaaaaaaaaaaaaaaaaaaaall(aaaaaaaaaaaaaaaaaaaaaaa))));

After:
  caaaaaaaaaaaall(caaaaaaaaaaaall(caaaaaaaaaaaall(
      caaaaaaaaaaaaaaaaaaaaaaall(aaaaaaaaaaaaaaaaaaaaaaa))));

llvm-svn: 263709

8 years ago[llvm-objdump] Add REQUIRES x86 directive to fix buildbots
Simon Atanasyan [Thu, 17 Mar 2016 11:09:21 +0000 (11:09 +0000)]
[llvm-objdump] Add REQUIRES x86 directive to fix buildbots

llvm-svn: 263708

8 years agoAvoid using braces. NFC.
George Rimar [Thu, 17 Mar 2016 11:00:27 +0000 (11:00 +0000)]
Avoid using braces. NFC.

llvm-svn: 263707

8 years ago[OPENMP 4.5] Allow to use private data members in 'copyprivate' clause.
Alexey Bataev [Thu, 17 Mar 2016 10:50:17 +0000 (10:50 +0000)]
[OPENMP 4.5] Allow to use private data members in 'copyprivate' clause.

OpenMP 4.5 allows privatization of non-static data members in non-static
member functions. This patch adds support of private data members in
'copyprivate' clauses.

llvm-svn: 263706

8 years ago[llvm-objdump] Add '0x' prefix to a target displacement number to accent its hex...
Simon Atanasyan [Thu, 17 Mar 2016 10:43:44 +0000 (10:43 +0000)]
[llvm-objdump] Add '0x' prefix to a target displacement number to accent its hex format

It might be hard to recognize a hexadecimal number without '0x' prefix.
Besides that '0x' prefix corresponds to GNU objdump behaviour.

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

llvm-svn: 263705

8 years ago[mips] Use `formatImm` call to print immediate value in the `MipsInstPrinter`
Simon Atanasyan [Thu, 17 Mar 2016 10:43:36 +0000 (10:43 +0000)]
[mips] Use `formatImm` call to print immediate value in the `MipsInstPrinter`

That allows, for example, to print hex-formatted immediates using
llvm-objdump --print-imm-hex command line option.

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

llvm-svn: 263704

8 years ago[mips] Eliminate instances of "potentially uninitialised local variable" warnings...
Scott Egerton [Thu, 17 Mar 2016 10:37:51 +0000 (10:37 +0000)]
[mips] Eliminate instances of "potentially uninitialised local variable" warnings, NFC

Summary:
This should eliminate all occurrences of this within LLVMMipsAsmParser.
This patch is in response to http://reviews.llvm.org/D17983. I was unable
to reproduce the warnings on my machine so please advise if this fixes the
warnings.

Reviewers: ariccio, vkalintiris, dsanders

Subscribers: dblaikie, dsanders, llvm-commits

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

llvm-svn: 263703

8 years agoRemove obselete reference to TypeResolve from the tutorial.
Wilfred Hughes [Thu, 17 Mar 2016 10:20:58 +0000 (10:20 +0000)]
Remove obselete reference to TypeResolve from the tutorial.

TypeResolve went away in r134829 in 2011.

llvm-svn: 263702

8 years ago[OPENMP 4.0] Use 'declare reduction' constructs in 'reduction' clauses.
Alexey Bataev [Thu, 17 Mar 2016 10:19:46 +0000 (10:19 +0000)]
[OPENMP 4.0] Use 'declare reduction' constructs in 'reduction' clauses.

OpenMP 4.0 allows to define custom reduction operations using '#pragma
omp declare reduction' construct. Patch allows to use this custom
defined reduction operations in 'reduction' clauses.

llvm-svn: 263701

8 years agoMinor grammar fix in kaleidoscope tutorial.
Wilfred Hughes [Thu, 17 Mar 2016 10:18:13 +0000 (10:18 +0000)]
Minor grammar fix in kaleidoscope tutorial.

llvm-svn: 263700

8 years ago[libcxxabi] Disable cxa_thread_atexit_test if unavailable
Jonas Hahnfeld [Thu, 17 Mar 2016 10:00:24 +0000 (10:00 +0000)]
[libcxxabi] Disable cxa_thread_atexit_test if unavailable

The feature check is already in place when building the library but wasn't
honored for the tests.

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

llvm-svn: 263699

8 years agoRemoving a non-intentional debug output that got committed in r263695.
Kuba Brecka [Thu, 17 Mar 2016 09:27:40 +0000 (09:27 +0000)]
Removing a non-intentional debug output that got committed in r263695.

llvm-svn: 263698

8 years agoFurther typo fixes in kaleidoscope tutorial.
Wilfred Hughes [Thu, 17 Mar 2016 09:26:45 +0000 (09:26 +0000)]
Further typo fixes in kaleidoscope tutorial.

llvm-svn: 263697

8 years agoFix typo in kaleidoscope tutorial.
Wilfred Hughes [Thu, 17 Mar 2016 09:09:07 +0000 (09:09 +0000)]
Fix typo in kaleidoscope tutorial.

llvm-svn: 263696

8 years ago[sanitizer] On OS X, verify that interceptors work and abort if not, take 2
Kuba Brecka [Thu, 17 Mar 2016 08:37:25 +0000 (08:37 +0000)]
[sanitizer] On OS X, verify that interceptors work and abort if not, take 2

On OS X 10.11+, we have "automatic interceptors", so we don't need to use DYLD_INSERT_LIBRARIES when launching instrumented programs. However, non-instrumented programs that load TSan late (e.g. via dlopen) are currently broken, as TSan will still try to initialize, but the program will crash/hang at random places (because the interceptors don't work). This patch adds an explicit check that interceptors are working, and if not, it aborts and prints out an error message suggesting to explicitly use DYLD_INSERT_LIBRARIES.

TSan unit tests run with a statically linked runtime, where interceptors don't work. To avoid aborting the process in this case, the patch replaces `DisableReexec()` with a weak `ReexecDisabled()` function which is defined to return true in unit tests.

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

llvm-svn: 263695

8 years agoMinor code cleanups. NFC.
Junmo Park [Thu, 17 Mar 2016 06:41:27 +0000 (06:41 +0000)]
Minor code cleanups. NFC.

llvm-svn: 263694

8 years ago[ELF] - -pie/--pic-executable option implemented
George Rimar [Thu, 17 Mar 2016 05:57:33 +0000 (05:57 +0000)]
[ELF] - -pie/--pic-executable option implemented

-pie
--pic-executable

Create a position independent executable.  This is currently only
 supported on ELF platforms.  Position independent executables are
 similar to shared libraries in that they are relocated by the
 dynamic linker to the virtual address the OS chooses for them
 (which can vary between invocations).  Like normal dynamically
 linked executables they can be executed and symbols defined in the
 executable cannot be overridden by shared libraries.

Differential revision: http://reviews.llvm.org/D18183

llvm-svn: 263693

8 years ago[yaml2obj, COFF] Correctly handle section alignment
David Majnemer [Thu, 17 Mar 2016 05:43:26 +0000 (05:43 +0000)]
[yaml2obj, COFF] Correctly handle section alignment

The section alignment field was marked optional but not provided a
default value: initialize it with 0.

While we are here, ensure that the section alignment is plausible.

llvm-svn: 263692

8 years ago[VFS] Remove wrong header include
Bruno Cardoso Lopes [Thu, 17 Mar 2016 04:59:52 +0000 (04:59 +0000)]
[VFS] Remove wrong header include

Follow up from r263686. Forgot to remove the wrong header file.

llvm-svn: 263691

8 years ago[ELF] Use braces for muti-line if(s).
Davide Italiano [Thu, 17 Mar 2016 04:28:41 +0000 (04:28 +0000)]
[ELF] Use braces for muti-line if(s).

Reported by: Joerg Sonnenberg.

llvm-svn: 263690

8 years ago[index] Make sure that declarations of builtin functions are indexed.
Argyrios Kyrtzidis [Thu, 17 Mar 2016 04:28:19 +0000 (04:28 +0000)]
[index] Make sure that declarations of builtin functions are indexed.

rdar://25154630

llvm-svn: 263689

8 years agoMake std::addressof constexpr in C++17 (Clang only).
Eric Fiselier [Thu, 17 Mar 2016 03:30:56 +0000 (03:30 +0000)]
Make std::addressof constexpr in C++17 (Clang only).

llvm-svn: 263688

8 years agoAdd an optional named argument (replacement = "xxx") to AvailabilityAttr.
Manman Ren [Thu, 17 Mar 2016 03:09:55 +0000 (03:09 +0000)]
Add an optional named argument (replacement = "xxx") to AvailabilityAttr.

This commit adds a named argument to AvailabilityAttr, while r263652 adds an
optional string argument to __attribute__((deprecated)). This enables the
compiler to provide Fix-Its for deprecated declarations.

rdar://20588929

llvm-svn: 263687

8 years agoReapply [2]: [VFS] Add support for handling path traversals
Bruno Cardoso Lopes [Thu, 17 Mar 2016 02:20:43 +0000 (02:20 +0000)]
Reapply [2]: [VFS] Add support for handling path traversals

This was applied twice r261551 and 263617 and later reverted because:

(1) Windows bot failing on unittests. Change the current behavior to do
not handle path traversals on windows.

(2) Windows bot failed to include llvm/Config/config.h in order to use
HAVE_REALPATH. Use LLVM_ON_UNIX instead, as done in lib/Basic/FileManager.cpp.

Handle ".", ".." and "./" with trailing slashes while collecting files
to be dumped into the vfs overlay directory.

Include the support for symlinks into components. Given the path:

/install-dir/bin/../lib/clang/3.8.0/include/altivec.h, if "bin"
component is a symlink, it's not safe to use `path::remove_dots` here,
and `realpath` is used to get the right answer. Since `realpath`
is expensive, we only do it at collecting time (which only happens
during the crash reproducer) and cache the base directory for fast lookups.

Overall, this makes the input to the VFS YAML file to be canonicalized
to never contain traversal components.

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

rdar://problem/24499339

llvm-svn: 263686

8 years ago[Statepoints] Separate out logic for statepoint directives; NFC
Sanjoy Das [Thu, 17 Mar 2016 01:56:10 +0000 (01:56 +0000)]
[Statepoints] Separate out logic for statepoint directives; NFC

This splits out the logic that maps the `"statepoint-id"` attribute into
the actual statepoint ID, and the `"statepoint-num-patch-bytes"`
attribute into the number of patchable bytes the statpeoint is lowered
into.  The new home of this logic is in IR/Statepoint.cpp, and this
refactoring will support similar functionality when lowering calls with
deopt operand bundles in the future.

llvm-svn: 263685

8 years ago[Statepoint] Remove unused header; NFC
Sanjoy Das [Thu, 17 Mar 2016 01:15:27 +0000 (01:15 +0000)]
[Statepoint] Remove unused header; NFC

llvm-svn: 263684

8 years ago[Statepoints] Minor NFC cleanups
Sanjoy Das [Thu, 17 Mar 2016 00:47:18 +0000 (00:47 +0000)]
[Statepoints] Minor NFC cleanups

Mostly code simplifcations, and bringing up IR/Statepoints.cpp up to
LLVM coding style.

llvm-svn: 263683

8 years ago[SelectionDAG] Remove visitStatepoint; NFC
Sanjoy Das [Thu, 17 Mar 2016 00:47:14 +0000 (00:47 +0000)]
[SelectionDAG] Remove visitStatepoint; NFC

This way we have a single entry point into StatepointLowering.  The
method was a direct dispatch to LowerStatepoint anyway.

llvm-svn: 263682

8 years agoRequire allocator parameter to YAML traits.
Pete Cooper [Thu, 17 Mar 2016 00:34:54 +0000 (00:34 +0000)]
Require allocator parameter to YAML traits.

The allocator here can still be a nullptr, but this atleast makes the
single caller which needed nullptr be explicit about it.

Note, lld started always passing a parameter here as of r263680.  If
anything builds out of sync, that would be why errors may occur.

llvm-svn: 263681

8 years agoAlways pass an allocator to YAMLTraits.
Pete Cooper [Thu, 17 Mar 2016 00:33:58 +0000 (00:33 +0000)]
Always pass an allocator to YAMLTraits.

The YAML traits new's when not passed an allocator to parse data.
For atom types, this is a leak as we don't destruct atoms.  For
the File here, we do actually destruct File's so that single case of
not using an allocator will be fine.

Should fix a bunch more leaks.

llvm-svn: 263680

8 years agouse FileCheck for tighter checking
Sanjay Patel [Wed, 16 Mar 2016 23:39:37 +0000 (23:39 +0000)]
use FileCheck for tighter checking

llvm-svn: 263679

8 years agoScopInfo: Do not generate dependences for i1 values used in affine branches
Tobias Grosser [Wed, 16 Mar 2016 23:33:54 +0000 (23:33 +0000)]
ScopInfo: Do not generate dependences for i1 values used in affine branches

Affine branches are fully modeled and regenerated from the polyhedral domain and
consequently do not require any input conditions to be propagated.

llvm-svn: 263678

8 years agoUse allocator in YAML code to avoid leaking atom content.
Pete Cooper [Wed, 16 Mar 2016 23:30:27 +0000 (23:30 +0000)]
Use allocator in YAML code to avoid leaking atom content.

In lld we allocate atoms on an allocator and so don't run their
destructors.  This means we also shouldn't allocate memory inside
them without that also being on an allocator.

Reviewed by Lang Hames and Rafael Espindola.

llvm-svn: 263677

8 years agoAdd optional allocator to YAML code to avoid leaking lld atoms.
Pete Cooper [Wed, 16 Mar 2016 23:29:31 +0000 (23:29 +0000)]
Add optional allocator to YAML code to avoid leaking lld atoms.

In lld we allocate atoms on an allocator and so don't run their
destructors.  This means we also shouldn't allocate memory inside
them without that also being on an allocator.

Reviewed by Lang Hames and Rafael Espindola.

llvm-svn: 263676

8 years agoreduce check strings; no need to check IR comments
Sanjay Patel [Wed, 16 Mar 2016 23:22:01 +0000 (23:22 +0000)]
reduce check strings; no need to check IR comments

llvm-svn: 263675

8 years agouse FileCheck for tighter checking
Sanjay Patel [Wed, 16 Mar 2016 23:20:20 +0000 (23:20 +0000)]
use FileCheck for tighter checking

llvm-svn: 263674

8 years agoUpgrade TBAA *before* upgrading intrinsics
Chris Bieneman [Wed, 16 Mar 2016 23:17:54 +0000 (23:17 +0000)]
Upgrade TBAA *before* upgrading intrinsics

Summary: If TBAA is on an intrinsic and it gets upgraded and drops the TBAA we hit an odd assert. We should just upgrade the TBAA first because it doesn't have side-effects.

Reviewers: reames, apilipenko, manmanren

Subscribers: llvm-commits

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

llvm-svn: 263673

8 years agoFix indentation; NFC
Sanjoy Das [Wed, 16 Mar 2016 23:11:21 +0000 (23:11 +0000)]
Fix indentation; NFC

llvm-svn: 263672

8 years agoExtract out a SelectionDAGBuilder::LowerAsStatepoint; NFC
Sanjoy Das [Wed, 16 Mar 2016 23:08:00 +0000 (23:08 +0000)]
Extract out a SelectionDAGBuilder::LowerAsStatepoint; NFC

Summary:
This is a step towards implementing "direct" lowering of calls and
invokes with deopt operand bundles into STATEPOINT nodes (as opposed to
having them mandatorily pass through RewriteStatepointsForGC, which is
the case today).

This change extracts out a `SelectionDAGBuilder::LowerAsStatepoint`
helper function that is able to lower a "statepoint like thing", and
uses it to lower `gc.statepoint` calls.  This is an NFC now, but in a
later change we will use `LowerAsStatepoint` to directly lower calls and
invokes with operand bundles without going through an intermediate
`gc.statepoint` IR representation.

FYI: I expect `SelectionDAGBuilder::StatepointInfo` will evolve as I add
support for lowering non gc.statepoints, right now it is fairly tightly
coupled with an IR level `gc.statepoint`.

Reviewers: reames, pgavlin, JosephTremoulet

Subscribers: sanjoy, mcrosier, llvm-commits

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

llvm-svn: 263671

8 years agoDon't pass SymbolBody to the relax* functions.
Rafael Espindola [Wed, 16 Mar 2016 23:01:56 +0000 (23:01 +0000)]
Don't pass SymbolBody to the relax* functions.

We already pass the symbol value.

llvm-svn: 263670

8 years agoDon't create a got entry if we optimize it out.
Rafael Espindola [Wed, 16 Mar 2016 22:43:36 +0000 (22:43 +0000)]
Don't create a got entry if we optimize it out.

llvm-svn: 263669

8 years agouse FileCheck for tighter checking
Sanjay Patel [Wed, 16 Mar 2016 22:34:57 +0000 (22:34 +0000)]
use FileCheck for tighter checking

I'm testing out a script that auto-generates the check lines.
It's 98% copied from utils/update_llc_test_checks.py.
If others think this is useful, please let me know.

llvm-svn: 263668

8 years agouse FileCheck for tighter checking
Sanjay Patel [Wed, 16 Mar 2016 22:29:07 +0000 (22:29 +0000)]
use FileCheck for tighter checking

I'm testing out a script that auto-generates the check lines.
It's 98% copied from utils/update_llc_test_checks.py.
If others think this is useful, please let me know.

llvm-svn: 263667

8 years agoVariable name cleanup /NFC
Xinliang David Li [Wed, 16 Mar 2016 22:13:41 +0000 (22:13 +0000)]
Variable name cleanup /NFC

llvm-svn: 263666

8 years agoTweak some atomics functions in preparation for larger changes; NFC.
James Y Knight [Wed, 16 Mar 2016 22:12:04 +0000 (22:12 +0000)]
Tweak some atomics functions in preparation for larger changes; NFC.

- Rename getATOMIC to getSYNC, as llvm will soon be able to emit both
  '__sync' libcalls and '__atomic' libcalls, and this function is for
  the '__sync' ones.

- getInsertFencesForAtomic() has been replaced with
  shouldInsertFencesForAtomic(Instruction), so that the decision can be
  made per-instruction. This functionality will be used soon.

- emitLeadingFence/emitTrailingFence are no longer called if
  shouldInsertFencesForAtomic returns false, and thus don't need to
  check the condition themselves.

llvm-svn: 263665

8 years ago[ELF] SHF_MERGE section with 0 entsize is not fatal
Ed Maste [Wed, 16 Mar 2016 21:12:53 +0000 (21:12 +0000)]
[ELF] SHF_MERGE section with 0 entsize is not fatal

For now just treat such sections as non-mergeable.

Resubmit r263660 with test fix.

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

llvm-svn: 263664

8 years ago[SelectionDAG] Extract out populateCallLoweringInfo; NFC
Sanjoy Das [Wed, 16 Mar 2016 20:49:31 +0000 (20:49 +0000)]
[SelectionDAG] Extract out populateCallLoweringInfo; NFC

SelectionDAGBuilder::populateCallLoweringInfo is now used instead of
SelectionDAGBuilder::lowerCallOperands.  The populateCallLoweringInfo
interface is more composable in face of design changes like
http://reviews.llvm.org/D18106

llvm-svn: 263663

8 years ago[ProfileData] Make a utility method public, NFC
Vedant Kumar [Wed, 16 Mar 2016 20:49:26 +0000 (20:49 +0000)]
[ProfileData] Make a utility method public, NFC

The swift frontend needs to be able to look up PGO function name
variables based on the original raw function name. That's because it's
not possible to create PGO function name variables while emitting swift
IR. Instead, we have to create the name variables while lowering swift
IR to llvm IR, at which point we fix up all calls to the increment
intrinsic to point to the right name variable.

llvm-svn: 263662

8 years agoRevert r263660 as one of the tests is broken.
Ed Maste [Wed, 16 Mar 2016 20:42:27 +0000 (20:42 +0000)]
Revert r263660 as one of the tests is broken.

llvm-svn: 263661