platform/upstream/llvm.git
8 years agoFix the alignment check.
Rafael Espindola [Thu, 31 Mar 2016 12:09:36 +0000 (12:09 +0000)]
Fix the alignment check.

We have to check the final value that is written.

I don't think this has any real word implications (unless something
supports unaligned instructions), but unblocks simplifying the handling
of PC relative relocations.

llvm-svn: 265009

8 years ago[docs] Fix a typo, change the style of the clang-tidy release notes a bit.
Alexander Kornienko [Thu, 31 Mar 2016 12:06:54 +0000 (12:06 +0000)]
[docs] Fix a typo, change the style of the clang-tidy release notes a bit.

llvm-svn: 265008

8 years agonote for top-level consts in function decls tidy
Alexander Kornienko [Thu, 31 Mar 2016 12:06:47 +0000 (12:06 +0000)]
note for top-level consts in function decls tidy

Summary: Add missing release note

Reviewers: alexfh

Subscribers: LegalizeAdulthood, cfe-commits

Patch by Matt Kulukundis!

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

llvm-svn: 265007

8 years ago[OpenCL] Added nosvm attribute for OpenCL v2.0.
Anastasia Stulova [Thu, 31 Mar 2016 11:07:22 +0000 (11:07 +0000)]
[OpenCL] Added nosvm attribute for OpenCL v2.0.

It is not widely used and removed from OpenCL v2.1.

This change modifies Clang to parse the attribute for OpenCL
but ignores it afterwards.

Patch by Liu Yaxun (Sam)!

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

llvm-svn: 265006

8 years ago[TTI] Let the cost model estimate ctpop costs based on legality
Benjamin Kramer [Thu, 31 Mar 2016 10:42:40 +0000 (10:42 +0000)]
[TTI] Let the cost model estimate ctpop costs based on legality

PPC has a vector popcount, this lets the vectorizer use the correct cost
for it. Tweak X86 test to use an intrinsic that's actually scalarized (we
have a somewhat efficient lowering for vector popcount using SSE, the
cost model finds that now).

llvm-svn: 265005

8 years ago[OPENMP] Support dumping OpenMP specific constructs.
Alexey Bataev [Thu, 31 Mar 2016 09:30:50 +0000 (09:30 +0000)]
[OPENMP] Support dumping OpenMP specific constructs.

Add proper dumping support for OpenMP declarations, directives and
clauses.

llvm-svn: 265004

8 years ago[OPENMP] Allow skip expression after comma in clauses with lists.
Alexey Bataev [Thu, 31 Mar 2016 09:13:44 +0000 (09:13 +0000)]
[OPENMP] Allow skip expression after comma in clauses with lists.

Compatibility fix for better compatibility with the existing software.

llvm-svn: 265003

8 years ago[mips][microMIPS] Implement MFC*, MFHC* and DMFC* instructions
Zlatko Buljan [Thu, 31 Mar 2016 08:51:24 +0000 (08:51 +0000)]
[mips][microMIPS] Implement MFC*, MFHC* and DMFC* instructions
Differential Revision: http://reviews.llvm.org/D17334

llvm-svn: 265002

8 years agoSilence warnings in OCaml bindings
Jeroen Ketema [Thu, 31 Mar 2016 08:39:42 +0000 (08:39 +0000)]
Silence warnings in OCaml bindings

* LLVMDisposeMessage lives in llvm-c/Core.h, include this file where necessary
* LLVMAddTargetData has been removed, follow suit in the bindings

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

llvm-svn: 265001

8 years agoIndentation fix in SystemZInstrInfo.cpp
Jonas Paulsson [Thu, 31 Mar 2016 08:00:14 +0000 (08:00 +0000)]
Indentation fix in SystemZInstrInfo.cpp

llvm-svn: 265000

8 years ago[CodeGenCXX] Fix ItaniumCXXABI::getAlignmentOfExnObject to return 8-byte
Akira Hatanaka [Thu, 31 Mar 2016 06:36:07 +0000 (06:36 +0000)]
[CodeGenCXX] Fix ItaniumCXXABI::getAlignmentOfExnObject to return 8-byte
alignment on Darwin.

Itanium C++ ABI specifies that _Unwind_Exception should be double-word
aligned (16B). To conform to the ABI, libraries implementing exception
handling declare the struct with __attribute__((aligned)), which aligns
the unwindHeader field (and the end of __cxa_exception) to the default
target alignment (which is typically 16-bytes).

struct __cxa_exception {
  ...
  // struct is declared with __attribute__((aligned)).
  _Unwind_Exception unwindHeader;
};

Based on the assumption that _Unwind_Exception is declared with
__attribute__((aligned)), ItaniumCXXABI::getAlignmentOfExnObject returns
the target default alignment for __attribute__((aligned)). It turns out
that libc++abi, which is used on Darwin, doesn't declare the struct with
the attribute and therefore doesn't guarantee that unwindHeader is
aligned to the alignment specified by the ABI, which in some cases
causes the program to crash because of unaligned memory accesses.

This commit avoids crashes due to unaligned memory accesses by having
getAlignmentOfExnObject return an 8-byte alignment on Darwin. I've only
fixed the problem for Darwin, but we should also figure out whether other
platforms using libc++abi need similar fixes.

rdar://problem/25314277

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

llvm-svn: 264998

8 years agoVisual Studio native visualization for clang::TemplateDecl
Mike Spertus [Thu, 31 Mar 2016 06:09:56 +0000 (06:09 +0000)]
Visual Studio native visualization for clang::TemplateDecl

With this change, TemplateDecls display in the Locals Window something like

  template<typename T, typename U> struct A;

llvm-svn: 264997

8 years ago[InstCombine] Fix incorrect rule from rL236202
Sanjoy Das [Thu, 31 Mar 2016 05:14:34 +0000 (05:14 +0000)]
[InstCombine] Fix incorrect rule from rL236202

The rule for SMIN introduced in rL236202 doesn't work as advertised: the
check for Pred == ICmpInst::ICMP_SGT was missing.

llvm-svn: 264996

8 years agoDelete trailing whitespace
Sanjoy Das [Thu, 31 Mar 2016 05:14:29 +0000 (05:14 +0000)]
Delete trailing whitespace

llvm-svn: 264995

8 years ago[SCEV] Track NoWrap properties using MatchBinaryOp, NFC
Sanjoy Das [Thu, 31 Mar 2016 05:14:26 +0000 (05:14 +0000)]
[SCEV] Track NoWrap properties using MatchBinaryOp, NFC

This way once we teach MatchBinaryOp to map more things into arithmetic,
the non-wrapping add recurrence construction would understand it too.
Right now MatchBinaryOp still only understands arithmetic, so this is
solely a code-reorganization change.

llvm-svn: 264994

8 years ago[SCEV] NFC code motion to simplify later change
Sanjoy Das [Thu, 31 Mar 2016 05:14:22 +0000 (05:14 +0000)]
[SCEV] NFC code motion to simplify later change

llvm-svn: 264993

8 years ago[X86] Use MVT instead of EVT in code called after legalization.
Craig Topper [Thu, 31 Mar 2016 04:37:41 +0000 (04:37 +0000)]
[X86] Use MVT instead of EVT in code called after legalization.

llvm-svn: 264992

8 years agoFix -Wdynamic-class-memaccess to skip invalid classes.
Richard Trieu [Thu, 31 Mar 2016 04:18:07 +0000 (04:18 +0000)]
Fix -Wdynamic-class-memaccess to skip invalid classes.

This warning sometimes will infinitely recurse on CXXRecordDecl's from
ill-formed recursive classes that have fields of themselves.  Skip processing
these classes to prevent this from happening.
Fixes https://llvm.org/bugs/show_bug.cgi?id=27142

llvm-svn: 264991

8 years ago[DebugInfo] Subprograms should belong to a CU.
Davide Italiano [Thu, 31 Mar 2016 03:40:07 +0000 (03:40 +0000)]
[DebugInfo] Subprograms should belong to a CU.

Start fixing tests accordingly. There are still
about 35 failures before we can enable this check
in the IR verifier.

llvm-svn: 264990

8 years agoFix LWG issue 2469 - Use piecewise construction in map::operator[].
Eric Fiselier [Thu, 31 Mar 2016 03:13:37 +0000 (03:13 +0000)]
Fix LWG issue 2469 - Use piecewise construction in map::operator[].

map's allocator may only be used to construct objects of 'value_type',
or in this case 'pair<const Key, Value>'. In order to respect this requirement
in operator[], which requires default constructing the 'mapped_type', we have
to use pair's piecewise constructor with '(tuple<Kep>, tuple<>)'.

Unfortunately we still need to provide a fallback implementation for C++03
since we don't have <tuple>. Even worse this fallback is the last remaining
user of '__hash_map_node_destructor' and '__construct_node_with_key'.

This patch also switches try_emplace over to __tree.__emplace_unique_key_args.

llvm-svn: 264989

8 years ago[PowerPC] Load two floats directly instead of using one 64-bit integer load
Hal Finkel [Thu, 31 Mar 2016 02:56:05 +0000 (02:56 +0000)]
[PowerPC] Load two floats directly instead of using one 64-bit integer load

When dealing with complex<float>, and similar structures with two
single-precision floating-point numbers, especially when such things are being
passed around by value, we'll sometimes end up loading both float values by
extracting them from one 64-bit integer load. It looks like this:

  t13: i64,ch = load<LD8[%ref.tmp]> t0, t6, undef:i64
      t16: i64 = srl t13, Constant:i32<32>
    t17: i32 = truncate t16
  t18: f32 = bitcast t17
    t19: i32 = truncate t13
  t20: f32 = bitcast t19

The problem, especially before the P8 where those bitcasts aren't legal (and
get expanded via the stack), is that it would have been better to use two
floating-point loads directly. Here we add a target-specific DAGCombine to do
just that. In short, we turn:

ld 3, 0(5)
stw 3, -8(1)
rldicl 3, 3, 32, 32
stw 3, -4(1)
lfs 3, -4(1)
lfs 0, -8(1)

into:

        lfs 3, 4(5)
        lfs 0, 0(5)

llvm-svn: 264988

8 years ago[DarwinDriver] Increase the number of valid digits for ld64 version string.
Bruno Cardoso Lopes [Thu, 31 Mar 2016 02:45:46 +0000 (02:45 +0000)]
[DarwinDriver] Increase the number of valid digits for ld64 version string.

Previously only 3 digits were valid. Increase it to 5.

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

rdar://problem/24843016

llvm-svn: 264987

8 years agoTeach __tree how to handle map's __value_type
Eric Fiselier [Thu, 31 Mar 2016 02:15:15 +0000 (02:15 +0000)]
Teach __tree how to handle map's __value_type

This patch is fairly large and contains a number of changes. The changes all work towards
allowing __tree to properly handle __value_type esspecially when inserting into the __tree.
I chose not to break this change into smaller patches because it wouldn't be possible to
write meaningful standard-compliant tests for each patch.

It is very similar to r260513 "[libcxx] Teach __hash_table how to handle unordered_map's __hash_value_type".

Changes in <map>
 * Remove __value_type's constructors because it should never be constructed directly.

 * Make map::emplace and multimap::emplace forward to __tree and remove the old definitions

 * Remove "__construct_node" map and multimap member functions. Almost all of the construction is done within __tree.

 * Fix map's move constructor to access "__value_type.__nc" directly and pass this object to __tree::insert.

Changes in <__tree>
 * Add traits to detect, handle, and unwrap, map's "__value_type".

 * Convert methods taking "value_type" to take "__container_value_type" instead. Previously these methods caused
  unwanted implicit conversions from "std::pair<Key, Value>" to "__value_type<Key, Value>".

 * Delete __tree_node and __tree_node_base's constructors and assignment operators. The node types should never be constructed
   because the "__value_" member of __tree_node must be constructed directly by the allocator.

 * Make the __tree_node_destructor class and "__construct_node" methods unwrap "__node_value_type" into "__container_value_type" before invoking the allocator. The user's allocator can only be used to construct and destroy the container's value_type. Passing it map's "__value_type" was incorrect.

 * Cleanup the "__insert" and "__emplace" methods. Have __insert forward to an __emplace function wherever possible to reduce
   code duplication. __insert_unique(value_type const&) and __insert_unique(value_type&&) forward to __emplace_unique_key_args.
   These functions will not allocate a new node if the value is already in the tree.

 * Change the __find* functions to take the "key_type" directly instead of passing in "value_type" and unwrapping the key later.
   This change allows the find functions to be used without having to construct a "value_type" first. This allows for a number
   of optimizations.

 * Teach __move_assign and __assign_multi methods to unwrap map's __value_type.

llvm-svn: 264986

8 years agoUpdate container_test_types.h and cleanup the related tests
Eric Fiselier [Thu, 31 Mar 2016 02:13:14 +0000 (02:13 +0000)]
Update container_test_types.h and cleanup the related tests

llvm-svn: 264985

8 years agoFix case confusion.
Sean Silva [Thu, 31 Mar 2016 01:47:33 +0000 (01:47 +0000)]
Fix case confusion.

The test case was defining and using a function 'notExported()', but
the FileCheck checks were checking for the name 'not_exported'. This
changes the test to use 'notExported' across the board. Also, the test
defined a function 'not_defined()', but doesn't have any checks related
to it. For consistency, this name is changed to 'notDefined'. A later
commit will add checks for 'notDefined'.

Patch by Warren Ristow!

llvm-svn: 264984

8 years agoRevert "Remove useless unreachable. Switch coverage already gives us this. NFC"
Pete Cooper [Thu, 31 Mar 2016 01:23:23 +0000 (01:23 +0000)]
Revert "Remove useless unreachable.  Switch coverage already gives us this.  NFC"

This reverts commit r264945.

The commit only removed an unreachable in a method with a covered switch, but
GCC is likely to warn on this, and the coding standards recommend just leaving
in the unreachable.

llvm-svn: 264983

8 years agoRemove unused variants of make_dynamic_error_code. NFC.
Pete Cooper [Thu, 31 Mar 2016 01:21:50 +0000 (01:21 +0000)]
Remove unused variants of make_dynamic_error_code.  NFC.

make_dynamic_error_code was used to create a std::error_code with
a std::string message.  Now that we are migrating to llvm::Error,
there are no calls to these make_dynamic_error_code methods.

There is one single call to make_dynamic_error_code remaining, the one
inside GenericError::convertToErrorCode().  That method is only called
from File::doParse() which should be a temporary situation.  We need
to work out how to deal with File::parse() caching the error result from
doParse().  Caching errors isn't supported in the new scheme, and probably
isn't needed here, but we need to work that out.

Once thats done, dynamic error and all utilities around it can be deleted.

llvm-svn: 264982

8 years agoUse Expected<T> instead of ErrorOr<T>in yaml reader. NFC
Pete Cooper [Thu, 31 Mar 2016 01:13:04 +0000 (01:13 +0000)]
Use Expected<T> instead of ErrorOr<T>in yaml reader.  NFC

llvm-svn: 264981

8 years agoAdd --help and --long-help options to 'command alias' such that one can now specify...
Enrico Granata [Thu, 31 Mar 2016 01:10:54 +0000 (01:10 +0000)]
Add --help and --long-help options to 'command alias' such that one can now specify a help string for an alias as they are defining it

llvm-svn: 264980

8 years agoChange library search methods to return Optional instead of ErrorOr.
Pete Cooper [Thu, 31 Mar 2016 01:09:35 +0000 (01:09 +0000)]
Change library search methods to return Optional instead of ErrorOr.

These methods weren't really throwing errors.  The only error used
was that a file could not be found, which isn't really an error at all
as we are searching paths and libraries for a file.  All of the callers
also ignored errors and just used the returned path if one was available.

Changing to return Optional<StringRef> as that actually reflects what
we are trying to do here: optionally find a given path.

llvm-svn: 264979

8 years agoFix a bunch more of -Wpessimizing-move issues.
Pete Cooper [Thu, 31 Mar 2016 00:38:02 +0000 (00:38 +0000)]
Fix a bunch more of -Wpessimizing-move issues.

Thanks to Rui for pointing out this warning was firing.

llvm-svn: 264978

8 years agoFix a bunch of -Wpessimizing-move issues.
Pete Cooper [Thu, 31 Mar 2016 00:35:50 +0000 (00:35 +0000)]
Fix a bunch of -Wpessimizing-move issues.

Thanks to Rui for pointing out this warning was firing.

llvm-svn: 264977

8 years agoIntroduce a @llvm.experimental.guard intrinsic
Sanjoy Das [Thu, 31 Mar 2016 00:18:46 +0000 (00:18 +0000)]
Introduce a @llvm.experimental.guard intrinsic

Summary:
As discussed on llvm-dev[1].

This change adds the basic boilerplate code around having this intrinsic
in LLVM:

 - Changes in Intrinsics.td, and the IR Verifier
 - A lowering pass to lower @llvm.experimental.guard to normal
   control flow
 - Inliner support

[1]: http://lists.llvm.org/pipermail/llvm-dev/2016-February/095523.html

Reviewers: reames, atrick, chandlerc, rnk, JosephTremoulet, echristo

Subscribers: mcrosier, llvm-commits

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

llvm-svn: 264976

8 years ago[Sema] Fix PR27122: ICE with enable_if+ill-formed call.
George Burgess IV [Thu, 31 Mar 2016 00:16:25 +0000 (00:16 +0000)]
[Sema] Fix PR27122: ICE with enable_if+ill-formed call.

In some cases, when we encounter a direct function call with an
incorrect number of arguments, we'll emit a diagnostic, and pretend that
the call to the function was valid. For example, in C:

int foo();
int a = foo(1);

Prior to this patch, we'd get an ICE if foo had an enable_if attribute,
because CheckEnableIf assumes that the number of arguments it gets
passed is valid for the function it's passed. Now, we check that the
number of args looks valid prior to checking enable_if conditions.

This fix was not done inside of CheckEnableIf because the problem
presently can only occur in one caller of CheckEnableIf (ActOnCallExpr).
Additionally, checking inside of CheckEnableIf would make us emit
multiple diagnostics for the same error (one "enable_if failed", one
"you gave this function the wrong number of arguments"), which seems
worse than just complaining about the latter.

llvm-svn: 264975

8 years agoConvert a few macho reader/writer helpers to new error handling. NFC.
Pete Cooper [Thu, 31 Mar 2016 00:08:16 +0000 (00:08 +0000)]
Convert a few macho reader/writer helpers to new error handling.  NFC.

These methods were responsible for some of the few remaining calls
to llvm::errorCodeToError.  Converting them makes us have more Error's
in the api and fewer error_code's.

llvm-svn: 264974

8 years agoConvert readBinary to llvm::Error. NFC
Pete Cooper [Wed, 30 Mar 2016 23:58:24 +0000 (23:58 +0000)]
Convert readBinary to llvm::Error.  NFC

llvm-svn: 264973

8 years agoAdd some more triples after r264966
Hans Wennborg [Wed, 30 Mar 2016 23:55:22 +0000 (23:55 +0000)]
Add some more triples after r264966

llvm-svn: 264972

8 years ago[CrashReproducer] Add a module map callback for added headers
Bruno Cardoso Lopes [Wed, 30 Mar 2016 23:54:25 +0000 (23:54 +0000)]
[CrashReproducer] Add a module map callback for added headers

The current ModuleDependencyCollector has a AST listener to collect
header files present in loaded modules, but this isn't enough to collect
all headers needed in the crash reproducer. One of the reasons is that
the AST writer doesn't write symbolic link header paths in the pcm modules,
this makes the listeners on the reader only able to collect the real files.

Since the module maps could contain submodules that use headers which
are symbolic links, not collecting those forbid the reproducer scripts
to regen the modules.

For instance:

usr/include/module.map:
  ...
  module pthread {
    header "pthread.h"
    export *

    module impl {
      header "pthread_impl.h"
      export *
    }
  }
  ...

usr/include/pthread/pthread_impl.h
usr/include/pthread_impl.h -> pthread/pthread_impl.h

The AST dump for the module above:

  <SUBMODULE_HEADER abbrevid=6/> blob data = 'pthread_impl.h'
  <SUBMODULE_TOPHEADER abbrevid=7/> blob data = '/<path_to_sdk>/usr/include/pthread/pthread_impl.h'

Note that we don't have "usr/include/pthread_impl.h" which is requested
by the module.map in case we want to reconstruct the module in the
reproducer. The reason the original symbolic link path isn't used is
because the headers are kept by name and requested through the
FileManager, which unique files and returns the real path only.

To fix that, add a callback to be invoked everytime a header is added
while parsing module maps and hook that up to the module dependecy
collector. This callback is only registered when generating the
reproducer.

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

rdar://problem/24499339

llvm-svn: 264971

8 years ago[VFS] Handle empty entries in directory traversal
Bruno Cardoso Lopes [Wed, 30 Mar 2016 23:54:00 +0000 (23:54 +0000)]
[VFS] Handle empty entries in directory traversal

The VFS YAML files contain empty directory entries to describe that it's
returning from a subdirectory before describing new files in the parent.
In the future, we should properly sort and write YAML files avoiding
such empty dirs and mitigate the extra recurson cost. However, since
this is used by previous existing YAMLs, make the traversal work in
their presence.

rdar://problem/24499339

llvm-svn: 264970

8 years ago[CUDA] Add -disable-llvm-passes to CodeGenCUDA/link-device-bitcode.cu. NFC
Justin Lebar [Wed, 30 Mar 2016 23:45:38 +0000 (23:45 +0000)]
[CUDA] Add -disable-llvm-passes to CodeGenCUDA/link-device-bitcode.cu.  NFC

We already have this flag in most of the file, but we need it everywhere
else, to disable the NVVMReflect pass, which we're explicitly checking
doesn't run here.  (Upcoming changes to llvm will cause it to be run.)

llvm-svn: 264969

8 years agoConvert normalized file to atoms methods to new error handling. NFC.
Pete Cooper [Wed, 30 Mar 2016 23:43:27 +0000 (23:43 +0000)]
Convert normalized file to atoms methods to new error handling.  NFC.

This converts almost all of the error handling in atom creation
to llvm::Error instead of std::error_code.

llvm-svn: 264968

8 years agoFix deduction of __atomic_load's parameter types.
Eric Fiselier [Wed, 30 Mar 2016 23:39:56 +0000 (23:39 +0000)]
Fix deduction of __atomic_load's parameter types.

Summary:
__atomic_load's allows it's first argument to be a pointer to a const type. However the second argument is an output parameter and must be a pointer to non-const.
This patch fixes the signature of __atomic_load generated by clang so that it respects the above requirements.

Reviewers: rsmith, majnemer

Subscribers: cfe-commits

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

llvm-svn: 264967

8 years ago[X86] Enable call frame optimization ("mov to push") not only for optsize (PR26325)
Hans Wennborg [Wed, 30 Mar 2016 23:38:01 +0000 (23:38 +0000)]
[X86] Enable call frame optimization ("mov to push") not only for optsize (PR26325)

The size savings are significant, and from what I can tell, both ICC and GCC do this.

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

llvm-svn: 264966

8 years ago[CUDA] Don't initialize the CUDA toolchain if we don't have any CUDA inputs.
Justin Lebar [Wed, 30 Mar 2016 23:30:25 +0000 (23:30 +0000)]
[CUDA] Don't initialize the CUDA toolchain if we don't have any CUDA inputs.

Summary:
This prevents errors when you invoke clang with a flag that the NVPTX
toolchain doesn't support.  For example, on x86-64,

  clang -mthread-model single -x c++ /dev/null -o /dev/null

should output just one error about "invalid thread model 'single' in
'-mthread-model single' for this target"; x86-64 doesn't support
-mthread-model, but we shouldn't also instantiate a NVPTX target!

Reviewers: echristo

Subscribers: tra, sunfish, cfe-commits

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

llvm-svn: 264965

8 years ago[CUDA] Make unattributed constexpr functions implicitly host+device.
Justin Lebar [Wed, 30 Mar 2016 23:30:21 +0000 (23:30 +0000)]
[CUDA] Make unattributed constexpr functions implicitly host+device.

With this patch, by a constexpr function is implicitly host+device
unless:

 a) it's a variadic function (variadic functions are not allowed on the
    device side), or
 b) it's preceeded by a __device__ overload in a system header.

The restriction on overloading __host__ __device__ functions on the
basis of their CUDA attributes remains in place, but we use (b) to allow
us to define __device__ overloads for constexpr functions in cmath,
which would otherwise be __host__ __device__ and thus not overloadable.

You can disable this behavior with -fno-cuda-host-device-constexpr.

Reviewers: tra, rnk, rsmith

Subscribers: cfe-commits

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

llvm-svn: 264964

8 years ago[CUDA] Add math forward declares to CUDA header wrapper.
Justin Lebar [Wed, 30 Mar 2016 23:30:14 +0000 (23:30 +0000)]
[CUDA] Add math forward declares to CUDA header wrapper.

Summary:
This is necessary for a future patch which will make all constexpr
functions implicitly host+device.  cmath may declare constexpr
functions, but these we do *not* want to be host+device.  The forward
declares added in this patch prevent this (because the rule will be,
constexpr functions become implicitly host+device unless they're
preceeded by a decl with __device__).

Reviewers: tra

Subscribers: cfe-commits, rnk, rsmith

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

llvm-svn: 264963

8 years agoFix MachO test which is failing on a Windows bot.
Pete Cooper [Wed, 30 Mar 2016 23:28:49 +0000 (23:28 +0000)]
Fix MachO test which is failing on a Windows bot.

This is breaking http://lab.llvm.org:8011/builders/lld-x86_64-win7/builds/31647/steps/test%20lld/logs/stdio.

The issue seems to be that it can't write to a file in /tmp, probably because that path doesn't
exist on Windows.  This was failing after I added EXPECT_FALSE(ec) in r264961 for the error
handling migration.

llvm-svn: 264962

8 years agoConvert lld file writing to llvm::Error. NFC.
Pete Cooper [Wed, 30 Mar 2016 23:10:39 +0000 (23:10 +0000)]
Convert lld file writing to llvm::Error.  NFC.

This converts the writeFile method, as well as some of the ones it calls
in the normalized binary file writer and yaml writer.

llvm-svn: 264961

8 years agoAMDGPU: Add frexp_mant + frexp_exp builtins
Matt Arsenault [Wed, 30 Mar 2016 22:57:40 +0000 (22:57 +0000)]
AMDGPU: Add frexp_mant + frexp_exp builtins

llvm-svn: 264960

8 years agoCodeGen: Factor out code for tail call result compatibility check; NFC
Matthias Braun [Wed, 30 Mar 2016 22:46:04 +0000 (22:46 +0000)]
CodeGen: Factor out code for tail call result compatibility check; NFC

llvm-svn: 264959

8 years agoAvoid unnecessary #include; NFC
Matthias Braun [Wed, 30 Mar 2016 22:45:58 +0000 (22:45 +0000)]
Avoid unnecessary #include; NFC

llvm-svn: 264958

8 years agoEnhance the 'type X list' commands such that they actually alert the user if no forma...
Enrico Granata [Wed, 30 Mar 2016 22:45:13 +0000 (22:45 +0000)]
Enhance the 'type X list' commands such that they actually alert the user if no formatters matching the constraints could be found

llvm-svn: 264957

8 years ago[ELF][MIPS] Revert r264761 and add test case to demonstrate the problem
Simon Atanasyan [Wed, 30 Mar 2016 22:43:14 +0000 (22:43 +0000)]
[ELF][MIPS] Revert r264761 and add test case to demonstrate the problem

If we make R_MIPS_LO16 a relative relocation, linker:
- never creates R_MIPS_COPY relocation for it
- attempts to create R_MIPS_REL32 dynamic relocation if R_MIPS_LO16's
  target is a preemptible symbol

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

llvm-svn: 264956

8 years agoUpdate copyright year to 2016.
Paul Robinson [Wed, 30 Mar 2016 22:41:38 +0000 (22:41 +0000)]
Update copyright year to 2016.

llvm-svn: 264955

8 years agoUpdate copyright year to 2016.
Paul Robinson [Wed, 30 Mar 2016 22:41:06 +0000 (22:41 +0000)]
Update copyright year to 2016.

llvm-svn: 264954

8 years agoUpdate copyright year to 2016.
Paul Robinson [Wed, 30 Mar 2016 22:40:59 +0000 (22:40 +0000)]
Update copyright year to 2016.

llvm-svn: 264953

8 years agoUpdate copyright year to 2016.
Paul Robinson [Wed, 30 Mar 2016 22:40:47 +0000 (22:40 +0000)]
Update copyright year to 2016.

llvm-svn: 264952

8 years agoFix -Wpessimizing-move warnings.
Rui Ueyama [Wed, 30 Mar 2016 22:40:16 +0000 (22:40 +0000)]
Fix -Wpessimizing-move warnings.

llvm-svn: 264951

8 years agoUpdate copyright year to 2016.
Paul Robinson [Wed, 30 Mar 2016 22:39:53 +0000 (22:39 +0000)]
Update copyright year to 2016.

llvm-svn: 264950

8 years agoUpdate copyright year to 2016.
Paul Robinson [Wed, 30 Mar 2016 22:39:03 +0000 (22:39 +0000)]
Update copyright year to 2016.

llvm-svn: 264949

8 years agoUpdate copyright year to 2016.
Paul Robinson [Wed, 30 Mar 2016 22:38:50 +0000 (22:38 +0000)]
Update copyright year to 2016.

llvm-svn: 264948

8 years agoUpdate copyright year to 2016.
Paul Robinson [Wed, 30 Mar 2016 22:38:47 +0000 (22:38 +0000)]
Update copyright year to 2016.

llvm-svn: 264947

8 years agoUpdate copyright year to 2016.
Paul Robinson [Wed, 30 Mar 2016 22:38:44 +0000 (22:38 +0000)]
Update copyright year to 2016.

llvm-svn: 264946

8 years agoRemove useless unreachable. Switch coverage already gives us this. NFC
Pete Cooper [Wed, 30 Mar 2016 22:34:37 +0000 (22:34 +0000)]
Remove useless unreachable.  Switch coverage already gives us this.  NFC

llvm-svn: 264945

8 years agoAMDGPU: Add frexp_exp intrinsic
Matt Arsenault [Wed, 30 Mar 2016 22:28:52 +0000 (22:28 +0000)]
AMDGPU: Add frexp_exp intrinsic

llvm-svn: 264944

8 years agoAMDGPU: Constant folding for frexp_mant
Matt Arsenault [Wed, 30 Mar 2016 22:28:26 +0000 (22:28 +0000)]
AMDGPU: Constant folding for frexp_mant

llvm-svn: 264943

8 years agoDocs: keep copyright years up-to-date.
Paul Robinson [Wed, 30 Mar 2016 22:25:04 +0000 (22:25 +0000)]
Docs: keep copyright years up-to-date.

llvm-svn: 264942

8 years agoDocs: keep copyright years up-to-date.
Paul Robinson [Wed, 30 Mar 2016 22:24:57 +0000 (22:24 +0000)]
Docs: keep copyright years up-to-date.

llvm-svn: 264941

8 years agoFix Clang crash with template type diffing.
Richard Trieu [Wed, 30 Mar 2016 22:23:00 +0000 (22:23 +0000)]
Fix Clang crash with template type diffing.

Fixes https://llvm.org/bugs/show_bug.cgi?id=27129 which is crash involving type
aliases and template type diffing.  Template arguments for type aliases and
template arguments for the underlying desugared type may not have one-to-one
relations, which could mess us the attempt to get more information from the
desugared type.  For type aliases, ignore the iterator over the desugared type.

llvm-svn: 264940

8 years agoAdd -emit-llvm-only to the regression test for PR21547.
Vassil Vassilev [Wed, 30 Mar 2016 22:22:50 +0000 (22:22 +0000)]
Add -emit-llvm-only to the regression test for PR21547.

llvm-svn: 264939

8 years ago[asan] Mark the initialization-bug.cc unsupported on OS X Yosemite and older
Ryan Govostes [Wed, 30 Mar 2016 22:21:58 +0000 (22:21 +0000)]
[asan] Mark the initialization-bug.cc unsupported on OS X Yosemite and older

This test should fail on OS X Yosemite and older, and pass on OS X El Capitan
and newer as well as on other platforms.

llvm-svn: 264938

8 years agoCanonicalize UnaryTransformType types when they don't have a known underlying type.
Vassil Vassilev [Wed, 30 Mar 2016 22:18:29 +0000 (22:18 +0000)]
Canonicalize UnaryTransformType types when they don't have a known underlying type.

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

Reviewed by Richard Smith.

llvm-svn: 264937

8 years agoUse existing PrintEscapedString in AssemblyWriter
Teresa Johnson [Wed, 30 Mar 2016 22:17:28 +0000 (22:17 +0000)]
Use existing PrintEscapedString in AssemblyWriter

r264884 introduced a helper to escape the backslashes in the source file
path, but I since discovered an existing mechanism to escape strings.

llvm-svn: 264936

8 years agoCloning: Reduce complexity of debug info cloning and fix correctness issue.
Peter Collingbourne [Wed, 30 Mar 2016 22:05:13 +0000 (22:05 +0000)]
Cloning: Reduce complexity of debug info cloning and fix correctness issue.

Commit r260791 contained an error in that it would introduce a cross-module
reference in the old module. It also introduced O(N^2) complexity in the
module cloner by requiring the entire module to be visited for each function.
Fix both of these problems by avoiding use of the CloneDebugInfoMetadata
function (which is only designed to do intra-module cloning) and cloning
function-attached metadata in the same way that we clone all other metadata.

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

llvm-svn: 264935

8 years agoFix bug when KMP_USE_ADAPTIVE_LOCKS is 0
Jonathan Peyton [Wed, 30 Mar 2016 21:50:59 +0000 (21:50 +0000)]
Fix bug when KMP_USE_ADAPTIVE_LOCKS is 0

#endif was one line too low.  If KMP_USE_ADAPTIVE_LOCKS is 0,
then queuing locks would incorrectly use drdpa lock mechanism.
This is a fix for https://llvm.org/bugs/show_bug.cgi?id=26649

llvm-svn: 264934

8 years agofix typos
Sanjay Patel [Wed, 30 Mar 2016 21:38:20 +0000 (21:38 +0000)]
fix typos

llvm-svn: 264933

8 years agoSilencing warnings from MSVC 2015 Update 2. Both of these changes silence "C4334...
Aaron Ballman [Wed, 30 Mar 2016 21:33:34 +0000 (21:33 +0000)]
Silencing warnings from MSVC 2015 Update 2. Both of these changes silence "C4334 '<<': result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)". NFC.

llvm-svn: 264932

8 years agoAMDGPU: Remove separate r600 double data layout
Matt Arsenault [Wed, 30 Mar 2016 21:32:37 +0000 (21:32 +0000)]
AMDGPU: Remove separate r600 double data layout

This is identical to the other r600 datalayout string.

llvm-svn: 264931

8 years ago[Clang][ARM] __va_list declaration is not saved in ASTContext causing compilation...
Oleg Ranevskyy [Wed, 30 Mar 2016 21:30:30 +0000 (21:30 +0000)]
[Clang][ARM] __va_list declaration is not saved in ASTContext causing compilation error or crash

Summary:
When the code is compiled for arm32 and the builtin `__va_list` declaration is created by `CreateAAPCSABIBuiltinVaListDecl`, the declaration is not saved in the `ASTContext` which may lead to a compilation error or crash.

Minimal reproducer I was able to find:
**header.h**
```
#include <stdarg.h>
typedef va_list va_list_1;
```

**test.cpp**
```
typedef __builtin_va_list va_list_2;
void foo(const char* format, ...) { va_list args; va_start( args, format ); }
```

Steps to reproduce:
```
clang -x c++-header --target=armv7l-linux-eabihf header.h
clang -c -include header.h --target=armv7l-linux-eabihf test.cpp
```

Compilation error:
```
error: non-const lvalue reference to type '__builtin_va_list'
      cannot bind to a value of unrelated type 'va_list' (aka '__builtin_va_list')
```

Compiling the same code as a C source leads to a crash:
```
clang --target=armv7l-linux-eabihf header.h
clang -c -x c -include header.h --target=armv7l-linux-eabihf test.cpp
```

Reviewers: logan, rsmith

Subscribers: cfe-commits, asl, aemerson, rengolin

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

llvm-svn: 264930

8 years agoSilencing warnings from MSVC 2015 Update 2. All of these changes silence "C4334 ...
Aaron Ballman [Wed, 30 Mar 2016 21:30:00 +0000 (21:30 +0000)]
Silencing warnings from MSVC 2015 Update 2. All of these changes silence "C4334 '<<': result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)". NFC.

llvm-svn: 264929

8 years agoLegalizeDAG: Don't replace vector store with integer if not legal
Matt Arsenault [Wed, 30 Mar 2016 21:15:18 +0000 (21:15 +0000)]
LegalizeDAG: Don't replace vector store with integer if not legal

For the same reason as the corresponding load change.

Note that ExpandStore is completely broken for non-byte sized element
vector stores, but preserve the current broken behavior which has tests
for it. The behavior should be the same, but now introduces a new typed
store that is incorrectly split later rather than doing it directly.

llvm-svn: 264928

8 years agoLegalizeDAG: Don't replace vector load with integer unless legal
Matt Arsenault [Wed, 30 Mar 2016 21:15:10 +0000 (21:15 +0000)]
LegalizeDAG: Don't replace vector load with integer unless legal

On AMDGPU we want to be able to promote i64/f64 loads to v2i32.
If the access is unaligned, this would conclude that since i64 is legal,
it would convert it back to i64 and there is an endless legalization
loop.

Extract the logic for scalarizing the load into a new TargetLowering
function, where this can also replace the custom function AMDGPU
has for this.

llvm-svn: 264927

8 years ago[IndVarSimplify] Don't insert after a catchswitch
David Majnemer [Wed, 30 Mar 2016 21:12:06 +0000 (21:12 +0000)]
[IndVarSimplify] Don't insert after a catchswitch

Widening a PHI requires us to insert a trunc.
The logical place for this trunc is in the same BB as the PHI.
This is not possible if the BB is terminated by a catchswitch.

This fixes PR27133.

llvm-svn: 264926

8 years ago[LTO] Add a test to ensure we treat externally available symbols correctly.
Davide Italiano [Wed, 30 Mar 2016 21:01:14 +0000 (21:01 +0000)]
[LTO] Add a test to ensure we treat externally available symbols correctly.

We already get it right, but there was no coverage for it.

llvm-svn: 264925

8 years agoConvert file handle* methods to llvm::Error instead of std::error_code. NFC.
Pete Cooper [Wed, 30 Mar 2016 20:56:54 +0000 (20:56 +0000)]
Convert file handle* methods to llvm::Error instead of std::error_code.  NFC.

This updates most of the file handling methods in the linking context and
resolver to use the new API.

llvm-svn: 264924

8 years agoAdd #include <functional> to PassManagerBuilder, now that it uses std::function. NFC
Justin Lebar [Wed, 30 Mar 2016 20:52:40 +0000 (20:52 +0000)]
Add #include <functional> to PassManagerBuilder, now that it uses std::function. NFC

llvm-svn: 264923

8 years ago[X86][AVX] Ensure EltsFromConsecutiveLoads tests the entire vector for consecutive...
Simon Pilgrim [Wed, 30 Mar 2016 20:52:24 +0000 (20:52 +0000)]
[X86][AVX] Ensure EltsFromConsecutiveLoads tests the entire vector for consecutive loads/zeros

Fix for issue introduced D17297, where we were breaking early from the loop detecting consecutive loads which could leave us thinking a consecutive load with zeros was possible.

llvm-svn: 264922

8 years agoChange loadFileList to llvm::Error. NFC
Pete Cooper [Wed, 30 Mar 2016 20:44:14 +0000 (20:44 +0000)]
Change loadFileList to llvm::Error.  NFC

llvm-svn: 264921

8 years ago[Sema] s/UseUsingDeclRules/UseMemberUsingDeclRules/
Justin Lebar [Wed, 30 Mar 2016 20:41:05 +0000 (20:41 +0000)]
[Sema] s/UseUsingDeclRules/UseMemberUsingDeclRules/

Summary:
IsOverload has a param named UseUsingDeclRules.  But as far as I can
tell, it should be called UseMemberUsingDeclRules.  That is, it only
applies to "using" declarations inside classes or structs.

Reviewers: rsmith

Subscribers: cfe-commits

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

llvm-svn: 264920

8 years ago[NVPTX] Make NVVMReflect a function pass.
Justin Lebar [Wed, 30 Mar 2016 20:40:11 +0000 (20:40 +0000)]
[NVPTX] Make NVVMReflect a function pass.

Summary:
Currently it's a module pass.  Make it a function pass so that we can
move it to PassManagerBuilder's EP_EarlyAsPossible extension point,
which only accepts function passes.

Reviewers: rnk

Subscribers: tra, llvm-commits, jholewinski

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

llvm-svn: 264919

8 years ago[PassManager] Make PassManagerBuilder::addExtension take an std::function, rather...
Justin Lebar [Wed, 30 Mar 2016 20:39:29 +0000 (20:39 +0000)]
[PassManager] Make PassManagerBuilder::addExtension take an std::function, rather than a function pointer.

Summary:
This gives callers flexibility to pass lambdas with captures, which lets
callers avoid the C-style void*-ptr closure style.  (Currently, callers
in clang store state in the PassManagerBuilderBase arg.)

No functional change, and the new API is backwards-compatible.

Reviewers: chandlerc

Subscribers: joker.eph, cfe-commits

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

llvm-svn: 264918

8 years agoConvert lld Pass::runOnFile to llvm::Error from std::error_code. NFC.
Pete Cooper [Wed, 30 Mar 2016 20:36:31 +0000 (20:36 +0000)]
Convert lld Pass::runOnFile to llvm::Error from std::error_code.  NFC.

Pretty mechanical change here.  Just replacing all the std::error_code() with
llvm::Error() and make_dynamic_error_code with make_error<GenericError>

llvm-svn: 264917

8 years agotest: Remove a test for a transform that hasn't existed in 5 years.
Justin Bogner [Wed, 30 Mar 2016 20:36:07 +0000 (20:36 +0000)]
test: Remove a test for a transform that hasn't existed in 5 years.

The TailDup transform was removed in r138841 in 2011, along with most
of the tests for it. This test, however, was missed. Probably because
it had already been XFAIL'd for 3 years at that point (since r52243!)
and continued to fail when the opt flag for -tailduplicate stopped
being valid.

llvm-svn: 264916

8 years agoAttempt to fix test failure on Windows.
Rui Ueyama [Wed, 30 Mar 2016 20:25:26 +0000 (20:25 +0000)]
Attempt to fix test failure on Windows.

Windows seems to complain that the file cannot be removed because
it is still in use. We don't have to remove the file but instead
just overwrite it, so do that.

llvm-svn: 264915

8 years agoFixed a problem where a dSYM wasn't properly found because it had the wrong name
Sean Callanan [Wed, 30 Mar 2016 20:17:41 +0000 (20:17 +0000)]
Fixed a problem where a dSYM wasn't properly found because it had the wrong name

<rdar://problem/25447765>

llvm-svn: 264914

8 years ago[modules] Write out identifiers if the ID is local, too.
Vassil Vassilev [Wed, 30 Mar 2016 20:16:03 +0000 (20:16 +0000)]
[modules] Write out identifiers if the ID is local, too.

In some cases a slot for an identifier is requested but it gets written to
another module, causing an assertion.

At the point when we start serializing Rtypes, we have no imported IdentifierID
for float_round_style. We start serializing stuff and allocate an ID for it.
Then, during the serialization process, we pull in the identifier info for it
from TSchemaHelper. Finally, WriteIdentifierTable decides that the identifier
has not changed since it was deserialized, so doesn't emit it.

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

Discussed on IRC with Richard Smith. Agreed on post commit review if needed.

llvm-svn: 264913

8 years agoFix the detection of the shell feature and disable some tests when its not present
Reid Kleckner [Wed, 30 Mar 2016 20:15:50 +0000 (20:15 +0000)]
Fix the detection of the shell feature and disable some tests when its not present

llvm-svn: 264912

8 years agoRemove unused fwd decl for LLVM IR stuff that lives in LTO now
Reid Kleckner [Wed, 30 Mar 2016 20:15:41 +0000 (20:15 +0000)]
Remove unused fwd decl for LLVM IR stuff that lives in LTO now

llvm-svn: 264911

8 years agoChange getReferenceInfo/getPairReferenceInfo to use new Error handling. NFC.
Pete Cooper [Wed, 30 Mar 2016 20:15:06 +0000 (20:15 +0000)]
Change getReferenceInfo/getPairReferenceInfo to use new Error handling.  NFC.

Adds a GenericError class to lld/Core which can carry a string.  This is
analygous to the dynamic_error we currently use in lld/Core.

Use this GenericError instead of make_dynamic_error_code.  Also, provide
an implemention of GenericError::convertToErrorCode which for now converts
it in to the dynamic_error_code we used to have.  This will go away once
all the APIs are converted.

llvm-svn: 264910

8 years agoWhen support for DWO files was added, there were two ways to pass lldb::user_id_t...
Greg Clayton [Wed, 30 Mar 2016 20:14:35 +0000 (20:14 +0000)]
When support for DWO files was added, there were two ways to pass lldb::user_id_t out to the rest of LLDB:
1 - DWARF in .o files with debug map in executable: we would place the compile unit index in the upper 32 bits of the 64 bit value and the lower 32 bits would be the DIE offset
2 - DWO: we would place the compile unit offset in the upper 32 bits of the 64 bit value and the lower 32 bits would be the DIE offset

There was a mixing and matching of this and it wasn't done consistently.

Major changes include:

The DIERef constructor that takes a lldb::user_id_t now requires a SymbolFileDWARF:

DIERef(lldb::user_id_t uid, SymbolFileDWARF *dwarf)

It is needed so that it can be decoded correctly. If it is DWARF in .o files with debug map in executable, then we get the right compile unit from the SymbolFileDWARFDebugMap, otherwise, we use the compile unit offset and DIE offset for DWO or normal DWARF.

The function:

lldb::user_id_t DIERef::GetUID() const;

Now becomes

lldb::user_id_t DIERef::GetUID(SymbolFileDWARF *dwarf) const;

Again, we need the DWARF file to encode it correctly.

This removes the need for "lldb::user_id_t SymbolFileDWARF::MakeUserID() const" and for bool SymbolFileDWARF::UserIDMatches (lldb::user_id_t uid) const". There were also many places were doing things inneficiently like:

1 - encode a dw_offset_t into a lldb::user_id_t
2 - call the public SymbolFile interface to resolve types using the lldb::user_id_t
3 - This would then decode the lldb::user_id_t into a DIERef, and then try to find that type.

There are many places that are now doing this more efficiently by storing DW_AT_type form values as DWARFFormValue objects and then making a DIERef from them and directly calling the underlying function to resolve the lldb_private::Type, lldb_private::CompilerType, lldb_private::CompilerDecl, lldb_private::CompilerDeclContext.

If there are any regressions in DWARF with DWO, we will need to fix any issues that arise since the original patch wasn't functional for the much more widely used DWARF in .o files with debug map.

<rdar://problem/25200976>

llvm-svn: 264909