platform/upstream/llvm.git
7 years agoFix more RegisterInfo initialization issues and quiet hundreds of warnings.
Greg Clayton [Mon, 8 Aug 2016 22:48:07 +0000 (22:48 +0000)]
Fix more RegisterInfo initialization issues and quiet hundreds of warnings.

llvm-svn: 278063

7 years ago[ScopDetection] Remove unused DetectionContexts during expansion.
Michael Kruse [Mon, 8 Aug 2016 22:39:32 +0000 (22:39 +0000)]
[ScopDetection] Remove unused DetectionContexts during expansion.

The function expandRegion() frees Region* objects again when it determines that
these are not valid SCoPs. However, the DetectionContext added to the
DetectionContextMap still holds a reference. The validity is checked using the
ValidRegions lookup table. When a new Region is added to that list, it might
share the same address, such that the DetectionContext contains two
Region* associations that are in ValidRegions, but that are unrelated and of
which one has already been free.

Also remove the DetectionContext when not a valid expansion.

llvm-svn: 278062

7 years agoFix printf warnings.
Greg Clayton [Mon, 8 Aug 2016 22:16:03 +0000 (22:16 +0000)]
Fix printf warnings.

llvm-svn: 278061

7 years agoFix RegisterInfo initializers to have all the required initializers after recent...
Greg Clayton [Mon, 8 Aug 2016 22:15:35 +0000 (22:15 +0000)]
Fix RegisterInfo initializers to have all the required initializers after recent changes. This quiets a few hundred warnings on MacOSX.

llvm-svn: 278060

7 years agoDo not depend on unwind when building standalone
Petr Hosek [Mon, 8 Aug 2016 22:09:54 +0000 (22:09 +0000)]
Do not depend on unwind when building standalone

When libcxxabi is being built standalone, unwind dependency is not
available, so do not use it even when LLVM unwinder is being
requested.

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

llvm-svn: 278058

7 years agoCOFF: handle /debugtype option
Saleem Abdulrasool [Mon, 8 Aug 2016 22:02:44 +0000 (22:02 +0000)]
COFF: handle /debugtype option

Add the support infrastructure for the /debugtype option which takes a comma
delimited list of debug info to generate. The defaults are based on other
options potentially (/driver or /profile). This sets up the infrastructure to
allow us to emit RSDS records to get "build id" equivalents on COFF (similar to
binutils).

llvm-svn: 278056

7 years agoRevert "[X86] Support the "ms-hotpatch" attribute."
Charles Davis [Mon, 8 Aug 2016 21:20:15 +0000 (21:20 +0000)]
Revert "[X86] Support the "ms-hotpatch" attribute."

This reverts commit r278048. Something changed between the last time I
built this--it takes awhile on my ridiculously slow and ancient
computer--and now that broke this.

llvm-svn: 278053

7 years agoRevert "[Attr] Add support for the `ms_hook_prologue` attribute."
Charles Davis [Mon, 8 Aug 2016 21:19:08 +0000 (21:19 +0000)]
Revert "[Attr] Add support for the `ms_hook_prologue` attribute."

This reverts commit r278050. It depends on r278048, which will be
reverted.

llvm-svn: 278052

7 years ago[Driver] Enable CFI for WebAssembly
Derek Schuff [Mon, 8 Aug 2016 21:14:15 +0000 (21:14 +0000)]
[Driver] Enable CFI for WebAssembly

Since CFI support has landed in the WebAssembly backend, enable it in
the frontend driver.

Patch by Dominic Chen

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

llvm-svn: 278051

7 years ago[Attr] Add support for the `ms_hook_prologue` attribute.
Charles Davis [Mon, 8 Aug 2016 21:03:39 +0000 (21:03 +0000)]
[Attr] Add support for the `ms_hook_prologue` attribute.

Summary:
Based on a patch by Michael Mueller.

This attribute specifies that a function can be hooked or patched. This
mechanism was originally devised by Microsoft for hotpatching their
binaries (which they're constantly updating to stay ahead of crackers,
script kiddies, and other ne'er-do-wells on the Internet), but it's now
commonly abused by Windows programs that want to hook API functions. It
is for this reason that this attribute was added to GCC--hence the name,
`ms_hook_prologue`.

Depends on D19908.

Reviewers: rnk, aaron.ballman

Subscribers: cfe-commits

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

llvm-svn: 278050

7 years agoInstCombine: Remove a redundant #ifdef NDEBUG. NFC
Justin Bogner [Mon, 8 Aug 2016 21:02:11 +0000 (21:02 +0000)]
InstCombine: Remove a redundant #ifdef NDEBUG. NFC

The DEBUG() macro already does this.

llvm-svn: 278049

7 years ago[X86] Support the "ms-hotpatch" attribute.
Charles Davis [Mon, 8 Aug 2016 21:01:39 +0000 (21:01 +0000)]
[X86] Support the "ms-hotpatch" attribute.

Summary:
Based on two patches by Michael Mueller.

This is a target attribute that causes a function marked with it to be
emitted as "hotpatchable". This particular mechanism was originally
devised by Microsoft for patching their binaries (which they are
constantly updating to stay ahead of crackers, script kiddies, and other
ne'er-do-wells on the Internet), but is now commonly abused by Windows
programs to hook API functions.

This mechanism is target-specific. For x86, a two-byte no-op instruction
is emitted at the function's entry point; the entry point must be
immediately preceded by 64 (32-bit) or 128 (64-bit) bytes of padding.
This padding is where the patch code is written. The two byte no-op is
then overwritten with a short jump into this code. The no-op is usually
a `movl %edi, %edi` instruction; this is used as a magic value
indicating that this is a hotpatchable function.

Reviewers: majnemer, sanjoy, rnk

Subscribers: dberris, llvm-commits

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

llvm-svn: 278048

7 years agoRefactor getMipsEFlags.
Rui Ueyama [Mon, 8 Aug 2016 19:39:45 +0000 (19:39 +0000)]
Refactor getMipsEFlags.

Previously, we incrementally updated the reuslting flag as we check
file flags, so it was not very clear who is updating what flags.
This patch makes them pure functions -- that has no side effect and
don't update arguments to improve readability.

Now each function construct a patial result, and all resutls are then
bitwise-OR'ed to construct the final result.

This patch also creates a new file, Mips.cpp, to move all these
MIPS functions to a separate file.

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

llvm-svn: 278042

7 years ago[MemorySSA] Fix windows build breakage caused by r278028 (take 2)
Geoff Berry [Mon, 8 Aug 2016 19:33:27 +0000 (19:33 +0000)]
[MemorySSA] Fix windows build breakage caused by r278028 (take 2)

r278028: [MemorySSA] Ensure address stability of MemorySSA object.
llvm-svn: 278041

7 years ago[Hexagon] Add pattern for 64-bit mulhs
Krzysztof Parzyszek [Mon, 8 Aug 2016 19:24:25 +0000 (19:24 +0000)]
[Hexagon] Add pattern for 64-bit mulhs

llvm-svn: 278040

7 years ago[GPGPU] Support Values referenced from both isl expr and llvm instructions
Tobias Grosser [Mon, 8 Aug 2016 19:22:19 +0000 (19:22 +0000)]
[GPGPU] Support Values referenced from both isl expr and llvm instructions

When adding code that avoids to pass values used in isl expressions and
LLVM instructions twice, we forgot to make single variable passed to the
kernel available in the ValueMap that makes it usable for instructions that
are not replaced with isl ast expressions. This change adds the variable
that is passed to the kernel to the ValueMap to ensure it is available
for such use cases as well.

llvm-svn: 278039

7 years ago[LoopUnroll] Simplify loops created by unrolling.
Michael Zolotukhin [Mon, 8 Aug 2016 19:02:15 +0000 (19:02 +0000)]
[LoopUnroll] Simplify loops created by unrolling.

Summary:
Currently loop-unrolling doesn't preserve loop-simplified form. This patch
fixes it by resimplifying affected loops.

Reviewers: chandlerc, sanjoy, hfinkel

Subscribers: llvm-commits

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

llvm-svn: 278038

7 years agoRefreshCallGraph does not modify the SCC, adding "const" to make it clear (NFC)
Mehdi Amini [Mon, 8 Aug 2016 18:51:05 +0000 (18:51 +0000)]
RefreshCallGraph does not modify the SCC, adding "const" to make it clear (NFC)

llvm-svn: 278037

7 years agoFix linking of omp_foreign_thread_team_reuse test on FreeBSD
Dimitry Andric [Mon, 8 Aug 2016 18:34:05 +0000 (18:34 +0000)]
Fix linking of omp_foreign_thread_team_reuse test on FreeBSD

Summary:
On FreeBSD, linking the misc_bugs/omp_foreign_thread_team_reuse.c test
case fails with:

   /usr/local/bin/ld: /tmp/omp_foreign_thread_team_reuse-c5e71b.o: undefined reference to symbol 'pthread_create@@FBSD_1.0'

This is because the program is linked without `-lpthread`.  Since the
%libomp-compile-and-run macro does not allow that option to be added to
the compile command line, split it up and add the required `-lpthread`
between %libomp-compile and %libomp-run.

Reviewers: jlpeyton, hfinkel, Hahnfeld

Subscribers: Hahnfeld, emaste, openmp-commits

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

llvm-svn: 278036

7 years ago[MemorySSA] Fix windows build breakage caused by r278028
Geoff Berry [Mon, 8 Aug 2016 18:27:22 +0000 (18:27 +0000)]
[MemorySSA] Fix windows build breakage caused by r278028

r278028: [MemorySSA] Ensure address stability of MemorySSA object.
llvm-svn: 278035

7 years agoRe-add SystemZ SNaN test
Elliot Colp [Mon, 8 Aug 2016 18:11:13 +0000 (18:11 +0000)]
Re-add SystemZ SNaN test

The floating-point bug affecting ninja-x64-msvc-RA-centos6 is fixed (r277813) so this test should
now pass

llvm-svn: 278034

7 years ago[BuildingAJIT] Fix a couple of typos in the Chapter 3 draft.
Lang Hames [Mon, 8 Aug 2016 18:09:56 +0000 (18:09 +0000)]
[BuildingAJIT] Fix a couple of typos in the Chapter 3 draft.

llvm-svn: 278033

7 years agoCMakeLists.txt cleanups: synchronize version with rest of LLVM, consistent spacing.
Eugene Zelenko [Mon, 8 Aug 2016 18:01:50 +0000 (18:01 +0000)]
CMakeLists.txt cleanups: synchronize version with rest of LLVM, consistent spacing.

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

llvm-svn: 278032

7 years ago[X86] Improve code size on X86 segment moves
Nirav Dave [Mon, 8 Aug 2016 18:01:04 +0000 (18:01 +0000)]
[X86] Improve code size on X86 segment moves

Moves of a value to a segment register from a 16-bit register is
equivalent to one from it's corresponding 32-bit register. Match gas's
behavior and rewrite instructions to the shorter of equivalent forms.

Reviewers: rnk, ab

Subscribers: llvm-commits

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

llvm-svn: 278031

7 years agoCMakeLists.txt cleanups: synchronize version with rest of LLVM, consistent spacing.
Eugene Zelenko [Mon, 8 Aug 2016 17:59:02 +0000 (17:59 +0000)]
CMakeLists.txt cleanups: synchronize version with rest of LLVM, consistent spacing.

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

llvm-svn: 278030

7 years agoCMakeLists.txt cleanups: synchronize version and CMake minimum required version with...
Eugene Zelenko [Mon, 8 Aug 2016 17:56:28 +0000 (17:56 +0000)]
CMakeLists.txt cleanups: synchronize version and CMake minimum required version with rest of LLVM, consistent spacing.

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

llvm-svn: 278029

7 years ago[MemorySSA] Ensure address stability of MemorySSA object.
Geoff Berry [Mon, 8 Aug 2016 17:52:01 +0000 (17:52 +0000)]
[MemorySSA] Ensure address stability of MemorySSA object.

Summary:
Ensure that the MemorySSA object never changes address when using the
new pass manager since the walkers contained by MemorySSA cache pointers
to it at construction time.  This is achieved by wrapping the
MemorySSAAnalysis result in a unique_ptr.  Also add some asserts that
check for this bug.

Reviewers: george.burgess.iv, dberlin

Subscribers: mcrosier, hfinkel, chandlerc, silvas, llvm-commits

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

llvm-svn: 278028

7 years ago[esan] Add iterator to esan's generic hashtable
Derek Bruening [Mon, 8 Aug 2016 17:37:19 +0000 (17:37 +0000)]
[esan] Add iterator to esan's generic hashtable

Summary: Adds simple iterator support to the esan hashtable.

Reviewers: aizatsky

Subscribers: vitalybuka, zhaoqin, kcc, eugenis, llvm-commits, kubabrecka

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

llvm-svn: 278027

7 years ago[GPGPU] Create code to verify run-time conditions
Tobias Grosser [Mon, 8 Aug 2016 17:35:55 +0000 (17:35 +0000)]
[GPGPU] Create code to verify run-time conditions

llvm-svn: 278026

7 years agoFix compilation in 'asserts' mode
Tobias Grosser [Mon, 8 Aug 2016 17:35:52 +0000 (17:35 +0000)]
Fix compilation in 'asserts' mode

llvm-svn: 278025

7 years ago[esan] Add generic resizing hashtable
Derek Bruening [Mon, 8 Aug 2016 17:25:40 +0000 (17:25 +0000)]
[esan] Add generic resizing hashtable

Summary:
Adds a new, generic, resizing hashtable data structure for use by esan
tools.  No existing sanitizer hashtable is suitable for the use case for
most esan tools: we need non-fixed-size tables, parameterized keys and
payloads, and write access to payloads.  The new hashtable uses either
simple internal or external mutex locking and supports custom hash and
comparision operators.  The focus is on functionality, not performance, to
catalyze creation of a variety of tools.  We can optimize the more
successful tools later.

Adds tests of the data structure.

Reviewers: aizatsky

Subscribers: vitalybuka, zhaoqin, kcc, eugenis, llvm-commits, kubabrecka

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

llvm-svn: 278024

7 years ago[clang-tidy] enhance modernize-use-bool-literals to check ternary operator
Kirill Bobyrev [Mon, 8 Aug 2016 17:11:56 +0000 (17:11 +0000)]
[clang-tidy] enhance modernize-use-bool-literals to check ternary operator

modernize-use-bool-literals doesn't checks operands in ternary operator.

For example:

``` c++
static int Value = 1;

bool foo() {
  bool Result = Value == 1 ? 1 : 0;
  return Result;
}

bool boo() {
  return Value == 1 ? 1 : 0;
}
```

This issue was reported in bug 28854. The patch fixes it.

Reviewers: alexfh, aaron.ballman, Prazek

Subscribers: Prazek, Eugene.Zelenko

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

llvm-svn: 278022

7 years ago[StreamExecutor] Add DeviceMemory and kernel arg packing
Jason Henline [Mon, 8 Aug 2016 16:45:19 +0000 (16:45 +0000)]
[StreamExecutor] Add DeviceMemory and kernel arg packing

Summary:
Add types for device memory and add the code that knows how to pack these
device memory types if they are passed as arguments to kernel launches.

Reviewers: jlebar, tra

Subscribers: parallel_libs-commits

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

llvm-svn: 278021

7 years ago[analyzer] Change -analyze-function to accept qualified names.
Artem Dergachev [Mon, 8 Aug 2016 16:01:02 +0000 (16:01 +0000)]
[analyzer] Change -analyze-function to accept qualified names.

Both -analyze-function and -analyzer-display-progress now share the same
convention for naming functions, which allows discriminating between
methods with the same name in different classes, C++ overloads, and also
presents Objective-C instance and class methods in the convenient notation.

This also allows looking up the name for the particular function you're trying
to restrict analysis to in the -analyzer-display-progress output,
in case it was not instantly obvious.

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

llvm-svn: 278018

7 years ago[IslNodeBuilder] Move run-time check generation to NodeBuilder [NFC]
Tobias Grosser [Mon, 8 Aug 2016 15:41:52 +0000 (15:41 +0000)]
[IslNodeBuilder] Move run-time check generation to NodeBuilder [NFC]

This improves the structure of the code and allows us to reuse the runtime
code generation in the PPCGCodeGeneration.

llvm-svn: 278017

7 years ago[ARM] Command-line options for embedded position-independent code
Oliver Stannard [Mon, 8 Aug 2016 15:28:40 +0000 (15:28 +0000)]
[ARM] Command-line options for embedded position-independent code

This patch (with the corresponding ARM backend patch) adds support for
some new relocation models:

* Read-only position independence (ROPI): Code and read-only data is accessed
  PC-relative. The offsets between all code and RO data sections are known at
  static link time.
* Read-write position independence (RWPI): Read-write data is accessed relative
  to a static base register. The offsets between all writeable data sections
  are known at static link time.

These two modes are independent (they specify how different objects
should be addressed), so they can be used individually or together.

These modes are intended for bare-metal systems or systems with small
real-time operating systems. They are designed to avoid the need for a
dynamic linker, the only initialisation required is setting the static
base register to an appropriate value for RWPI code.

There is one C construct not currently supported by these modes: global
variables initialised to the address of another global variable or
function, where that address is not known at static-link time. There are
a few possible ways to solve this:

* Disallow this, and require the user to write their own initialisation
  function if they need variables like this.
* Emit dynamic initialisers for these variables in the compiler, called from
  the .init_array section (as is currently done for C++ dynamic initialisers).
  We have a patch to do this, described in my original RFC email
  (http://lists.llvm.org/pipermail/llvm-dev/2015-December/093022.html), but the
  feedback from that RFC thread was that this is not something that belongs in
  clang.
* Use a small dynamic loader to fix up these variables, by adding the
  difference between the load and execution address of the relevant section.
  This would require linker co-operation to generate a table of addresses that
  need fixing up.

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

llvm-svn: 278016

7 years ago[ARM] Add support for embedded position-independent code
Oliver Stannard [Mon, 8 Aug 2016 15:28:31 +0000 (15:28 +0000)]
[ARM] Add support for embedded position-independent code

This patch adds support for some new relocation models to the ARM
backend:

* Read-only position independence (ROPI): Code and read-only data is accessed
  PC-relative. The offsets between all code and RO data sections are known at
  static link time. This does not affect read-write data.
* Read-write position independence (RWPI): Read-write data is accessed relative
  to the static base register (r9). The offsets between all writeable data
  sections are known at static link time. This does not affect read-only data.

These two modes are independent (they specify how different objects
should be addressed), so they can be used individually or together. They
are otherwise the same as the "static" relocation model, and are not
compatible with SysV-style PIC using a global offset table.

These modes are normally used by bare-metal systems or systems with
small real-time operating systems. They are designed to avoid the need
for a dynamic linker, the only initialisation required is setting r9 to
an appropriate value for RWPI code.

I have only added support to SelectionDAG, not FastISel, because
FastISel is currently disabled for bare-metal targets where these modes
would be used.

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

llvm-svn: 278015

7 years ago[CodeGeneration] Do not set insert position redundantly
Tobias Grosser [Mon, 8 Aug 2016 15:25:50 +0000 (15:25 +0000)]
[CodeGeneration] Do not set insert position redundantly

There is no need to reset the position of the builder, as we can just continue
to insert code at the current position of the IRBuilder, which happens to
be precisely the location we reset the builder to.

llvm-svn: 278014

7 years ago[IslNodeBuilder] Directly use the insert location of our Builder
Tobias Grosser [Mon, 8 Aug 2016 15:25:46 +0000 (15:25 +0000)]
[IslNodeBuilder] Directly use the insert location of our Builder

... instead of adding instructions at the end of the basic block the builder
is currently at. This makes it easier to reason about where IR is generated,
as with the IRBuilder there is just a single location that specificies where
IR is generated.

llvm-svn: 278013

7 years ago[SystemZ] Add support for the .insn directive
Zhan Jun Liau [Mon, 8 Aug 2016 15:13:08 +0000 (15:13 +0000)]
[SystemZ] Add support for the .insn directive

Summary:
Add support for the .insn directive.

.insn is an s390 specific directive that allows encoding of an instruction
instead of using a mnemonic. The motivating case is some code in node.js that
requires support for the .insn directive.

Reviewers: koriakin, uweigand

Subscribers: koriakin, llvm-commits

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

llvm-svn: 278012

7 years agoRevert r2277979.
Nico Weber [Mon, 8 Aug 2016 14:51:53 +0000 (14:51 +0000)]
Revert r2277979.

For some reason, MSVC2013's cl.exe crashes with
  fatal error C1001: An internal error has occurred in the compiler
with this when compiling e.g. LoopDistribute.cpp.

llvm-svn: 278011

7 years agoGVN-hoist: enable by default
Sebastian Pop [Mon, 8 Aug 2016 14:46:15 +0000 (14:46 +0000)]
GVN-hoist: enable by default

llvm-svn: 278010

7 years ago[LVI] NFC. On the fast dest path use inverse predicate instead of inverse range result
Artur Pilipenko [Mon, 8 Aug 2016 14:33:11 +0000 (14:33 +0000)]
[LVI] NFC. On the fast dest path use inverse predicate instead of inverse range result

Gathering constantins from a condition on the false path ask makeAllowedICmpRegion about inverse predicate instead of inversing the resulting range.

This change was separated from the review "[LVI] Make LVI smarter about comparisons with non-constants" (https://reviews.llvm.org/D23205#inline-198361)

llvm-svn: 278009

7 years ago[LVI] NFC. Rename confusing local NegOffset to Offset
Artur Pilipenko [Mon, 8 Aug 2016 14:13:56 +0000 (14:13 +0000)]
[LVI] NFC. Rename confusing local NegOffset to Offset

NegOffset is not necessarily negative

llvm-svn: 278008

7 years ago[LVI] NFC. Extract LHS, RHS, Predicate locals in getValueFromCondition
Artur Pilipenko [Mon, 8 Aug 2016 14:08:37 +0000 (14:08 +0000)]
[LVI] NFC. Extract LHS, RHS, Predicate locals in getValueFromCondition

llvm-svn: 278007

7 years ago[analyzer] Command line option to show enabled checker list.
Gabor Horvath [Mon, 8 Aug 2016 13:41:04 +0000 (13:41 +0000)]
[analyzer] Command line option to show enabled checker list.

This patch adds a command line option to list the checkers that were enabled
by analyzer-checker and not disabled by -analyzer-disable-checker.

It can be very useful to debug long command lines when it is not immediately
apparent which checkers are turned on and which checkers are turned off.

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

llvm-svn: 278006

7 years agoFix uninitialized field warnings in GDBRemoteRegisterContext
Pavel Labath [Mon, 8 Aug 2016 13:38:33 +0000 (13:38 +0000)]
Fix uninitialized field warnings in GDBRemoteRegisterContext

also take the opportunity to replace NULL with nullptr and add clang-format guards to prevent it
from messing up the nice table there.

llvm-svn: 278005

7 years agoFixes calculateRangesAfterReplacements crash when Replacements is empty.
Eric Liu [Mon, 8 Aug 2016 13:37:39 +0000 (13:37 +0000)]
Fixes calculateRangesAfterReplacements crash when Replacements is empty.

Reviewers: klimek, djasper

Subscribers: cfe-commits, klimek

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

llvm-svn: 278004

7 years agokmp_gsupport: Fix library initialization with taskgroup
Jonas Hahnfeld [Mon, 8 Aug 2016 13:23:08 +0000 (13:23 +0000)]
kmp_gsupport: Fix library initialization with taskgroup

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

llvm-svn: 278003

7 years ago[AArch64] PR28877: Don't assume we're running after legalization when creating vcvtfp2fxs
Silviu Baranga [Mon, 8 Aug 2016 13:13:57 +0000 (13:13 +0000)]
[AArch64] PR28877: Don't assume we're running after legalization when creating vcvtfp2fxs

Summary:
The DAG combine transformation that was generating the
aarch64_neon_vcvtfp2fxs node was assuming that all
inputs where legal and wasn't accounting that the input
could be a v4f64 if we're trying to do the transformation
before legalization. We now bail out in this case.

All illegal types besides v4f64 were already rejected.

Fixes https://llvm.org/bugs/show_bug.cgi?id=28877.

Reviewers: jmolloy

Subscribers: aemerson, rengolin, llvm-commits

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

llvm-svn: 278002

7 years agoClean up linux/Ptrace.h
Pavel Labath [Mon, 8 Aug 2016 13:13:03 +0000 (13:13 +0000)]
Clean up linux/Ptrace.h

This removes references to PT_XXX macros from the file, as they were not used anyway. It also
changes the macro used to check for the definition of __ptrace_request, as there are other C
libraries which do not define this type.

llvm-svn: 278001

7 years agoRemove Android.h
Pavel Labath [Mon, 8 Aug 2016 12:54:36 +0000 (12:54 +0000)]
Remove Android.h

It only contained a reimplementation of std::to_string, which I have replaced with usages of
pre-existing llvm::to_string (also, injecting members into the std namespace is evil).

llvm-svn: 278000

7 years agoRemove SYS_tgkill from Android.h
Pavel Labath [Mon, 8 Aug 2016 12:40:11 +0000 (12:40 +0000)]
Remove SYS_tgkill from Android.h

instead, use __NR_tgkill directly, which seems to be the preferred form in the codebase anyway.

llvm-svn: 277999

7 years agoRemove _isatty from Android.h
Pavel Labath [Mon, 8 Aug 2016 12:26:57 +0000 (12:26 +0000)]
Remove _isatty from Android.h

it is just #defined to isatty anyway, which lldb already knows how to use.

llvm-svn: 277997

7 years agoMark tests with task dependencies as unsupported with GCC
Jonas Hahnfeld [Mon, 8 Aug 2016 11:52:49 +0000 (11:52 +0000)]
Mark tests with task dependencies as unsupported with GCC

llvm-svn: 277996

7 years agoRe-commit r277988: [mips][ias] Fix all the hacks related to MIPS-specific unary opera...
Daniel Sanders [Mon, 8 Aug 2016 11:50:25 +0000 (11:50 +0000)]
Re-commit r277988: [mips][ias] Fix all the hacks related to MIPS-specific unary operators (%hi/%lo/%gp_rel/etc.).

Hopefully with the MSVC builds fixed. I've added a missing '#include <tuple>'
that gcc and clang don't seem to need.

llvm-svn: 277995

7 years agoFix Wdocumentation unknown parameter warning
Simon Pilgrim [Mon, 8 Aug 2016 11:49:24 +0000 (11:49 +0000)]
Fix Wdocumentation unknown parameter warning

llvm-svn: 277994

7 years ago[X86][SSE] Assert if the shuffle mask indices are not -1 or within a valid input...
Simon Pilgrim [Mon, 8 Aug 2016 11:07:34 +0000 (11:07 +0000)]
[X86][SSE] Assert if the shuffle mask indices are not -1 or within a valid input range

As discussed in post-review rL277959

llvm-svn: 277993

7 years agoDo not block on explicit task depending on proxy task
Jonas Hahnfeld [Mon, 8 Aug 2016 10:08:14 +0000 (10:08 +0000)]
Do not block on explicit task depending on proxy task

Consider the following code:

    int dep;
    #pragma omp target nowait depend(out: dep)
    {
        sleep(1);
    }
    #pragma omp task depend(in: dep)
    {
        printf("Task with dependency\n");
    }
    printf("Doing some work...\n");

In its current state the runtime will block on the second task and not
continue execution.

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

llvm-svn: 277992

7 years ago__kmp_free_task: Fix for serial explicit tasks producing proxy tasks
Jonas Hahnfeld [Mon, 8 Aug 2016 10:08:07 +0000 (10:08 +0000)]
__kmp_free_task: Fix for serial explicit tasks producing proxy tasks

Consider the following code which may be executed by a serial team:

    int dep;
    #pragma omp target nowait depend(out: dep)
    {
        sleep(1);
    }
    #pragma omp task depend(in: dep)
    {
        #pragma omp target nowait
        {
            sleep(1);
        }
    }

Here the explicit task may not be freed until the nested proxy task has
finished. The current code hasn't considered this and called __kmp_free_task
anyway which triggered an assert because of remaining incomplete children:

    KMP_DEBUG_ASSERT( TCR_4(taskdata->td_incomplete_child_tasks) == 0 );

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

llvm-svn: 277991

7 years agoRevert r277988: [mips][ias] Fix all the hacks related to MIPS-specific unary operator...
Daniel Sanders [Mon, 8 Aug 2016 09:33:14 +0000 (09:33 +0000)]
Revert r277988: [mips][ias] Fix all the hacks related to MIPS-specific unary operators (%hi/%lo/%gp_rel/etc.).

It seems that MSVC doesn't like std::tie().

llvm-svn: 277990

7 years ago[analyzer] Model base to derived casts more precisely.
Gabor Horvath [Mon, 8 Aug 2016 09:22:59 +0000 (09:22 +0000)]
[analyzer] Model base to derived casts more precisely.

Dynamic casts are handled relatively well by the static analyzer.
BaseToDerived casts however are treated conservatively. This can cause some
false positives with the NewDeleteLeaks checker.

This patch alters the behavior of BaseToDerived casts. In case a dynamic cast
would succeed use the same semantics. Otherwise fall back to the conservative
approach.

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

llvm-svn: 277989

7 years ago[mips][ias] Fix all the hacks related to MIPS-specific unary operators (%hi/%lo/...
Daniel Sanders [Mon, 8 Aug 2016 09:20:52 +0000 (09:20 +0000)]
[mips][ias] Fix all the hacks related to MIPS-specific unary operators (%hi/%lo/%gp_rel/etc.).

Summary:
They are now lexed as a single token on targets where
MCAsmInfo::HasMipsExpressions is true and then parsed in a similar way to
the '~' operator as part of MCExpr::parseExpression.

As a result:
* expressions and immediates no longer have different parsing rules. The
  difference is now solely down to whether evaluateAsAbsolute() succeeds.
* %hi(%neg(%gp_rel(x))) are no longer parsed as a single operator and
  decomposed into the three MipsMCExpr nodes. They are parsed directly as
  three MipsMCExpr nodes.
  * parseMemOperand no longer needs to eat all the surrounding parenthesis
    to get at the outermost operator to make this work
* %hi(%neg(%gp_rel(x))) and %lo(%neg(%gp_rel(x))) are no longer the only
  3-in-1 relocs that parse for N64. They're still the only combinations that
  are permitted in relocatable expressions though. Fixing that should be a
  later patch.
* We no longer need to list all the tokens that can occur as the first token of
  an expression or immediate.

test/MC/Mips/expr1.s:
    This change also prevents the incorrect lowering of %lo(2*4)+foo to
    %lo(8+foo) which is not an equivalent expression (the difference is
    whether foo is truncated to 16-bit or not) and the test has been
    updated to account for the macro expansion the correct expression requires.

Reviewers: sdardis

Subscribers: dsanders, sdardis, llvm-commits

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

llvm-svn: 277988

7 years ago[SelectionDAG] Refactor visitInlineAsm a bit. NFCI.
Diana Picus [Mon, 8 Aug 2016 08:54:39 +0000 (08:54 +0000)]
[SelectionDAG] Refactor visitInlineAsm a bit. NFCI.

This shaves off ~100 lines from visitInlineAsm.

llvm-svn: 277987

7 years ago[ELF] - Linkerscript: do not define _edata,_end,_etext if SECTIONS is used.
George Rimar [Mon, 8 Aug 2016 08:42:48 +0000 (08:42 +0000)]
[ELF] - Linkerscript: do not define _edata,_end,_etext if SECTIONS is used.

I faced that when tried to link FreeBSD kernel.
It was "duplicate symbol: _edata in (internal) and (internal)" error.
_data was a shared symbol that came from hack.so. At first it was replaced with DefinedRegular by the code
disabled in this patch and later when script tried to define the same symbol - the error was shown.

In the same situation (as given in testcase) ld defines them as UND. gold defines as ABS with zero value.
Patch just disables any operations of creating these symbols if script do layout.

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

llvm-svn: 277986

7 years agoFix two bugs for musl-libc on ARM
Diana Picus [Mon, 8 Aug 2016 08:27:36 +0000 (08:27 +0000)]
Fix two bugs for musl-libc on ARM

Bug 1: triples like armv7-pc-linux-musl use the wrong linker name
ld-musl-armv7.so.1; the right name should be ld-musl-arm.so.1, disregarding the
subarch field.

Bug 2: when compiler option -mhard-float is used, we should use the "hardfloat"
linker, no matter whether the triple itself mentions "hardfloat".

Patch by Lei Zhang!

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

llvm-svn: 277985

7 years agoAdd some comments linking back to PR28400.
Sean Silva [Mon, 8 Aug 2016 07:03:49 +0000 (07:03 +0000)]
Add some comments linking back to PR28400.

Thanks to Mehdi for the suggestion!

llvm-svn: 277984

7 years ago[compiler-rt][XRay] Only add xray dependency if XRay is built and is available for...
Dean Michael Berris [Mon, 8 Aug 2016 05:49:29 +0000 (05:49 +0000)]
[compiler-rt][XRay] Only add xray dependency if XRay is built and is available for the platform

llvm-svn: 277983

7 years ago[PM] More workaround for PR28400
Sean Silva [Mon, 8 Aug 2016 05:38:06 +0000 (05:38 +0000)]
[PM] More workaround for PR28400

llvm-svn: 277982

7 years ago[PM] BasicAA needs to be invalidated since it holds pointers to other stuff.
Sean Silva [Mon, 8 Aug 2016 05:38:03 +0000 (05:38 +0000)]
[PM] BasicAA needs to be invalidated since it holds pointers to other stuff.

llvm-svn: 277981

7 years ago[PM] Invalidate CallGraphAnalysis because it holds AssertingVH
Sean Silva [Mon, 8 Aug 2016 05:38:01 +0000 (05:38 +0000)]
[PM] Invalidate CallGraphAnalysis because it holds AssertingVH

This is essentially PR28400. The fix here is similar to that implemented
in r274656.

llvm-svn: 277980

7 years ago[PM] Function-level TLI is also immutable.
Sean Silva [Mon, 8 Aug 2016 05:37:58 +0000 (05:37 +0000)]
[PM] Function-level TLI is also immutable.

llvm-svn: 277979

7 years ago[MSSA] Fix PR28880 by fixing use optimizer's lower bound tracking behavior.
Daniel Berlin [Mon, 8 Aug 2016 04:44:53 +0000 (04:44 +0000)]
[MSSA] Fix PR28880 by fixing use optimizer's lower bound tracking behavior.

Summary:
In the use optimizer, we need to keep of whether the lower bound still
dominates us or else we may decide a lower bound is still valid when it
is not due to intervening pushes/pops.  Fixes PR28880 (and probably a
bunch of other things).

Reviewers: george.burgess.iv

Subscribers: MatzeB, llvm-commits, sebpop

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

llvm-svn: 277978

7 years ago[JumpThreading] Fix handling of aliasing metadata.
Eli Friedman [Mon, 8 Aug 2016 04:10:22 +0000 (04:10 +0000)]
[JumpThreading] Fix handling of aliasing metadata.

Summary:
The correctness fix here is that when we CSE a load with another load,
we need to combine the metadata on the two loads. This matches the
behavior of other passes, like instcombine and GVN.

There's also a minor optimization improvement here: for load PRE, the
aliasing metadata on the inserted load should be the same as the
metadata on the original load. Not sure why the old code was throwing
it away.

Issue found by inspection.

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

llvm-svn: 277977

7 years agoPass information in a record instead of stack. NFC
Serge Pavlov [Mon, 8 Aug 2016 04:02:15 +0000 (04:02 +0000)]
Pass information in a record instead of stack. NFC

Functions of Sema that work with building of nested name specifiers have too
many parameters (BuildCXXNestedNameSpecifier already expects 10 arguments).
With this change the information about identifier and its context is packed
into a structure, which is then passes to the semantic functions.

llvm-svn: 277976

7 years ago[compiler-rt][XRay] Default COMPILER_RT_BUILD_XRAY to ON
Dean Michael Berris [Mon, 8 Aug 2016 03:58:57 +0000 (03:58 +0000)]
[compiler-rt][XRay] Default COMPILER_RT_BUILD_XRAY to ON

llvm-svn: 277975

7 years ago[compiler-rt][XRay] Fix XRay test build dependencies
Dean Michael Berris [Mon, 8 Aug 2016 03:42:11 +0000 (03:42 +0000)]
[compiler-rt][XRay] Fix XRay test build dependencies

llvm-svn: 277974

7 years ago[MC] Delete use of *structors_used.
Davide Italiano [Mon, 8 Aug 2016 03:30:01 +0000 (03:30 +0000)]
[MC] Delete use of *structors_used.

Jim Grosbach and Kevin Enderby think those are not used anymore.
Originally submitted by: Rafael Espindola

llvm-svn: 277973

7 years ago[SimplifyLibCalls] Emit sqrt intrinsic instead of a libcall.
Davide Italiano [Mon, 8 Aug 2016 03:23:01 +0000 (03:23 +0000)]
[SimplifyLibCalls] Emit sqrt intrinsic instead of a libcall.

llvm-svn: 277972

7 years ago[compiler-rt][XRay] Implement __xray_unpatch() and __xray_remove_handler()
Dean Michael Berris [Mon, 8 Aug 2016 03:10:22 +0000 (03:10 +0000)]
[compiler-rt][XRay] Implement __xray_unpatch() and __xray_remove_handler()

Summary:
We also add one test (and the XRay testing infrastructure) to exercise
the patching and unpatching code. This uses the XRay API exported
through the headers as well, installing a custom log handler.

Depends on D23101 for the updated emitted code alignment for the
return/entry sleds.

Reviewers: rSerge, echristo, rnk

Subscribers: tberghammer, danalbert, srhines, mehdi_amini, llvm-commits

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

llvm-svn: 277971

7 years agoFix copy/move constructor annotation for the uses-allocator test types.
Eric Fiselier [Mon, 8 Aug 2016 02:22:41 +0000 (02:22 +0000)]
Fix copy/move constructor annotation for the uses-allocator test types.

Previously the copy/move constructors of the test types did not
properly set the arg_id to T const& or T&& respectivly.

llvm-svn: 277970

7 years ago[SROA] Fix crash with lifetime intrinsic partially covering alloca.
Eli Friedman [Mon, 8 Aug 2016 01:30:53 +0000 (01:30 +0000)]
[SROA] Fix crash with lifetime intrinsic partially covering alloca.

Summary:
PromoteMemToReg looks specifically for the pattern
bitcast+lifetime.start (or a bitcast-equivalent GEP); any offset
will lead to an assertion failure.

Fixes https://llvm.org/bugs/show_bug.cgi?id=27999 .

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

llvm-svn: 277969

7 years ago[libcxx] Add "flag" default arg: basic_regex ptr_size_flag ctor
Hubert Tong [Sun, 7 Aug 2016 22:26:04 +0000 (22:26 +0000)]
[libcxx] Add "flag" default arg: basic_regex ptr_size_flag ctor

Summary:
The synopsis in C++11 subclause 28.8 [re.regex] has:
```
basic_regex(const charT* p, size_t len,
            flag_type f = regex_constants::ECMAScript);
```

The default argument is added to libc++ by this change.

Reviewers: mclow.lists, rsmith, hubert.reinterpretcast

Subscribers: cfe-commits

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

Reapplies r277966.
Patch by Jason Liu!

llvm-svn: 277968

7 years agoRevert r277966. Forgot patch attribution.
Hubert Tong [Sun, 7 Aug 2016 22:23:24 +0000 (22:23 +0000)]
Revert r277966. Forgot patch attribution.

llvm-svn: 277967

7 years ago[libcxx] Add "flag" default arg: basic_regex ptr_size_flag ctor
Hubert Tong [Sun, 7 Aug 2016 22:18:33 +0000 (22:18 +0000)]
[libcxx] Add "flag" default arg: basic_regex ptr_size_flag ctor

Summary:
The synopsis in C++11 subclause 28.8 [re.regex] has:
```
basic_regex(const charT* p, size_t len,
            flag_type f = regex_constants::ECMAScript);
```

The default argument is added to libc++ by this change.

Reviewers: mclow.lists, rsmith, hubert.reinterpretcast

Subscribers: cfe-commits

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

llvm-svn: 277966

7 years ago[AVX-512] Improve lowering of inserting a single element into lowest element of a...
Craig Topper [Sun, 7 Aug 2016 21:52:59 +0000 (21:52 +0000)]
[AVX-512] Improve lowering of inserting a single element into lowest element of a 512-bit vector of zeroes by using vmovq/vmovd/vmovss/vmovsd.

llvm-svn: 277965

7 years agoMark LWG 2726 as complete. No code change needed.
Eric Fiselier [Sun, 7 Aug 2016 21:47:06 +0000 (21:47 +0000)]
Mark LWG 2726 as complete. No code change needed.

llvm-svn: 277964

7 years ago[SLC] Emit an intrinsic instead of a libcall for pow.
Davide Italiano [Sun, 7 Aug 2016 20:27:03 +0000 (20:27 +0000)]
[SLC] Emit an intrinsic instead of a libcall for pow.

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

llvm-svn: 277963

7 years agoRevert r277905, it caused PR28894
Nico Weber [Sun, 7 Aug 2016 20:18:04 +0000 (20:18 +0000)]
Revert r277905, it caused PR28894

llvm-svn: 277962

7 years ago[AVX-512] Add 512-bit logical operations to load folding tables. Add avx512f stack...
Craig Topper [Sun, 7 Aug 2016 17:14:09 +0000 (17:14 +0000)]
[AVX-512] Add 512-bit logical operations to load folding tables. Add avx512f stack folding test and move some tests from the avx512vl test.

llvm-svn: 277961

7 years ago[AVX-512] Add EVEX encoded floating point MAX/MIN instructions to the load folding...
Craig Topper [Sun, 7 Aug 2016 17:14:05 +0000 (17:14 +0000)]
[AVX-512] Add EVEX encoded floating point MAX/MIN instructions to the load folding tables.

llvm-svn: 277960

7 years ago[X86] lowerVectorShuffle - ensure that undefined mask elements only use SM_SentinelUndef
Simon Pilgrim [Sun, 7 Aug 2016 15:29:12 +0000 (15:29 +0000)]
[X86] lowerVectorShuffle - ensure that undefined mask elements only use SM_SentinelUndef

Help lowering and combining (which can specify SM_SentinelZero mask elements) share more shuffle matching code.

llvm-svn: 277959

7 years agoAVX-512: Changed lowering of BITCAST between i1 vectors and i8/i16/i32 integer values
Elena Demikhovsky [Sun, 7 Aug 2016 13:05:58 +0000 (13:05 +0000)]
AVX-512: Changed lowering of BITCAST between i1 vectors and i8/i16/i32 integer values

Optimized lowering of BITCAST node. The BITCAST node can be replaced with COPY_TO_REG instead of KMOV.
It allows to suppress two opposite BITCAST operations and avoid redundant "movs".

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

llvm-svn: 277958

7 years ago[X86][AVX512BW] Add sext/zext AVX512BW 512-bit vector tests
Simon Pilgrim [Sun, 7 Aug 2016 12:41:36 +0000 (12:41 +0000)]
[X86][AVX512BW] Add sext/zext AVX512BW 512-bit vector tests

llvm-svn: 277957

7 years ago[X86][AVX512] Add sext/zext to 512-bit vector tests
Simon Pilgrim [Sun, 7 Aug 2016 12:10:46 +0000 (12:10 +0000)]
[X86][AVX512] Add sext/zext to 512-bit vector tests

llvm-svn: 277956

7 years ago[AVX512] integer comparisions enumeration.
Asaf Badouh [Sun, 7 Aug 2016 10:43:04 +0000 (10:43 +0000)]
[AVX512] integer comparisions enumeration.

fix Bug 28842 https://llvm.org/bugs/show_bug.cgi?id=28842

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

llvm-svn: 277955

7 years agoAVX-512: Added a test for cmp intrinsics
Elena Demikhovsky [Sun, 7 Aug 2016 09:29:34 +0000 (09:29 +0000)]
AVX-512: Added a test for cmp intrinsics

This is a new test that should explore a current suboptimal sequence in passing values between cmp and kor intrinsics.
The code will be optimized in an upcoming patch.

Submitted bug here:
https://llvm.org/bugs/show_bug.cgi?id=28839

llvm-svn: 277954

7 years agoUpdate clang tests for LLVM r277950
David Majnemer [Sun, 7 Aug 2016 08:28:58 +0000 (08:28 +0000)]
Update clang tests for LLVM r277950

We infer inbounds on GEPs of allocas leading to minor perturbations in
tests.

llvm-svn: 277953

7 years ago[InstSimplify] Fold gep (gep V, C), (sub 0, V) to C
David Majnemer [Sun, 7 Aug 2016 07:58:12 +0000 (07:58 +0000)]
[InstSimplify] Fold gep (gep V, C), (sub 0, V) to C

llvm-svn: 277952

7 years ago[InstSimplify] Try hard to simplify pointer comparisons
David Majnemer [Sun, 7 Aug 2016 07:58:10 +0000 (07:58 +0000)]
[InstSimplify] Try hard to simplify pointer comparisons

Simplify ptrtoint comparisons involving operands with different source
types.

llvm-svn: 277951