platform/upstream/llvm.git
8 years agoRestrict clang-format to lib/ [NFC]
Johannes Doerfert [Thu, 24 Mar 2016 13:49:39 +0000 (13:49 +0000)]
Restrict clang-format to lib/ [NFC]

llvm-svn: 264283

8 years ago[PowerPC] Disable direct moves for extractelement and bitcast in 32-bit mode
Nemanja Ivanovic [Thu, 24 Mar 2016 13:40:33 +0000 (13:40 +0000)]
[PowerPC] Disable direct moves for extractelement and bitcast in 32-bit mode

This patch corresponds to review:
http://reviews.llvm.org/D17711

It disables direct moves on these operations in 32-bit mode since the patterns
assume 64-bit registers. The final patch is slightly different from the
Phabricator review as the bitcast operations needed to be disabled in 32-bit
mode as well. This fixes PR26617.

llvm-svn: 264282

8 years agoRecommitted r263425 "Supporting all entities declared in lexical scope in LLVM debug...
Amjad Aboud [Thu, 24 Mar 2016 13:30:41 +0000 (13:30 +0000)]
Recommitted r263425 "Supporting all entities declared in lexical scope in LLVM debug info."
After fixing PR26942 (the fix is included in this commit).

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

llvm-svn: 264281

8 years agoRecommitted r263424 "Supporting all entities declared in lexical scope in LLVM debug...
Amjad Aboud [Thu, 24 Mar 2016 13:30:16 +0000 (13:30 +0000)]
Recommitted r263424 "Supporting all entities declared in lexical scope in LLVM debug info."
After fixing PR26942 (the fix is included in this commit).

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

llvm-svn: 264280

8 years ago[mips] Range check simm10
Daniel Sanders [Thu, 24 Mar 2016 13:26:59 +0000 (13:26 +0000)]
[mips] Range check simm10

Summary:

Reviewers: vkalintiris

Subscribers: llvm-commits, dsanders

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

llvm-svn: 264279

8 years agoAdded support for different VFSs in format::getStyle. Disable platform-related test...
Eric Liu [Thu, 24 Mar 2016 13:22:42 +0000 (13:22 +0000)]
Added support for different VFSs in format::getStyle. Disable platform-related test case for MS compilers to avoid breaking buildbot.

llvm-svn: 264277

8 years agoRevert "Added support for different VFSs in format::getStyle."
Eric Liu [Thu, 24 Mar 2016 13:22:37 +0000 (13:22 +0000)]
Revert "Added support for different VFSs in format::getStyle."

This reverts commit r264253. It is breaking the buildbot http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/2203

llvm-svn: 264276

8 years agoRevert "removed redundant comment in format::getStyle."
Eric Liu [Thu, 24 Mar 2016 13:22:28 +0000 (13:22 +0000)]
Revert "removed redundant comment in format::getStyle."

This reverts commit r264254.

llvm-svn: 264275

8 years ago[FIX] Verify the alias group before returning it
Johannes Doerfert [Thu, 24 Mar 2016 13:22:16 +0000 (13:22 +0000)]
[FIX] Verify the alias group before returning it

Similar to r262612 we need to check not only the pointer SCEV and the
type of an alias group but also the actual access instruction. The
reason is again the same: The pointer SCEV is not flow sensitive but the
access function is. In r262612 we avoided consolidating alias groups
even though the pointer SCEV and the type were the same but the access
function was not. Here it is simpler as we can simply check all members
of an alias group against the given access instruction.

llvm-svn: 264274

8 years ago[DOCS] Exclude python and shell scripts
Johannes Doerfert [Thu, 24 Mar 2016 13:21:12 +0000 (13:21 +0000)]
[DOCS] Exclude python and shell scripts

llvm-svn: 264273

8 years agoAdd namespace for struct [NFC]
Johannes Doerfert [Thu, 24 Mar 2016 13:20:52 +0000 (13:20 +0000)]
Add namespace for struct [NFC]

  This will clean up the doxygen documentation.

llvm-svn: 264272

8 years agoFollow-up for r264261, adding a comment explaining what the testcase does.
Kuba Brecka [Thu, 24 Mar 2016 13:20:38 +0000 (13:20 +0000)]
Follow-up for r264261, adding a comment explaining what the testcase does.

llvm-svn: 264271

8 years agoRemove obsolete CMD option [NFC]
Johannes Doerfert [Thu, 24 Mar 2016 13:19:51 +0000 (13:19 +0000)]
Remove obsolete CMD option [NFC]

llvm-svn: 264270

8 years agoRemove obsolete code
Johannes Doerfert [Thu, 24 Mar 2016 13:19:16 +0000 (13:19 +0000)]
Remove obsolete code

  Since r261226 we should not see this situation any more, if so it is probably
  a bug that would only be hidden.

llvm-svn: 264269

8 years agoRemove weird comment [NFC]
Johannes Doerfert [Thu, 24 Mar 2016 13:16:49 +0000 (13:16 +0000)]
Remove weird comment [NFC]

llvm-svn: 264268

8 years agoMake needsPlt a plain function instead of a template.
Rafael Espindola [Thu, 24 Mar 2016 12:55:27 +0000 (12:55 +0000)]
Make needsPlt a plain function instead of a template.

llvm-svn: 264267

8 years ago[OMPT] Fix parallel_id and task_id in loop_end with schedule static
Jonas Hahnfeld [Thu, 24 Mar 2016 12:52:20 +0000 (12:52 +0000)]
[OMPT] Fix parallel_id and task_id in loop_end with schedule static

For serialized parallel regions, wrong ids were reported. Now the same code is
used as in kmp_dispatch.cpp which emits the correct ids.

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

llvm-svn: 264266

8 years ago[OMPT] Test ids reported by ompt_get_{parallel,task}_id
Jonas Hahnfeld [Thu, 24 Mar 2016 12:52:11 +0000 (12:52 +0000)]
[OMPT] Test ids reported by ompt_get_{parallel,task}_id

llvm-svn: 264265

8 years ago[OMPT] Fix duplicate implicit_task_end events for master thread with GCC
Jonas Hahnfeld [Thu, 24 Mar 2016 12:52:04 +0000 (12:52 +0000)]
[OMPT] Fix duplicate implicit_task_end events for master thread with GCC

For non-serialized parallel regions the master thread issued two callbacks:
The first one in kmp_gsupport.c and the second in __kmp_join_call. Therefore
only trigger the callback in kmp_gsupport.c for serialized parallel regions.

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

llvm-svn: 264264

8 years agoFix Sphinx errors with documentation build.
Aaron Ballman [Thu, 24 Mar 2016 12:34:44 +0000 (12:34 +0000)]
Fix Sphinx errors with documentation build.

llvm-svn: 264263

8 years agoMark R_AARCH64_CONDBR19 as relative.
Rafael Espindola [Thu, 24 Mar 2016 12:16:46 +0000 (12:16 +0000)]
Mark R_AARCH64_CONDBR19 as relative.

llvm-svn: 264262

8 years ago[tsan] Fix fork() and fork-based tests for OS X
Kuba Brecka [Thu, 24 Mar 2016 11:54:33 +0000 (11:54 +0000)]
[tsan] Fix fork() and fork-based tests for OS X

On OS X, fork() under TSan asserts (in debug builds only) because REAL(fork) calls some intercepted functions, which check that no internal locks are held via CheckNoLocks(). But the wrapper of fork intentionally holds some locks. This patch fixes that by using ScopedIgnoreInterceptors during the call to REAL(fork). After that, all the fork-based tests seem to pass on OS X, so let's just remove all the UNSUPPORTED: darwin annotations we have.

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

llvm-svn: 264261

8 years ago[X86][XOP] Support for VPPERM byte shuffle instruction
Simon Pilgrim [Thu, 24 Mar 2016 11:52:43 +0000 (11:52 +0000)]
[X86][XOP] Support for VPPERM byte shuffle instruction

This patch begins adding support for lowering to the XOP VPPERM instruction - adding the X86ISD::VPPERM opcode.

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

llvm-svn: 264260

8 years ago[tsan] Use direct syscalls for internal_mmap and internal_munmap on OS X
Kuba Brecka [Thu, 24 Mar 2016 11:50:21 +0000 (11:50 +0000)]
[tsan] Use direct syscalls for internal_mmap and internal_munmap on OS X

On OS X, internal_mmap just uses mmap, which can invoke callbacks into libmalloc (e.g. when MallocStackLogging is enabled). This can subsequently call other intercepted functions, and this breaks our Darwin-specific ThreadState initialization. Let's use direct syscalls in internal_mmap and internal_munmap. Added a testcase.

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

llvm-svn: 264259

8 years ago[mips] Tidy up cnMIPS tablegen definitions. NFC.
Daniel Sanders [Thu, 24 Mar 2016 11:40:48 +0000 (11:40 +0000)]
[mips] Tidy up cnMIPS tablegen definitions. NFC.

Summary:
In particular, make the cnMIPS predicates much more obvious and prefer
  def ... : ... {
    let Foo = bar;
  }
over:
  let Foo = bar in
  def ... : ...;

Reviewers: vkalintiris

Subscribers: dsanders, llvm-commits

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

llvm-svn: 264258

8 years agoRevert "Added support for different VFSs in format::getStyle."
Eric Liu [Thu, 24 Mar 2016 11:25:28 +0000 (11:25 +0000)]
Revert "Added support for different VFSs in format::getStyle."

This reverts commit r264253. It is breaking the buildbot http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/2203

llvm-svn: 264257

8 years agoRevert "removed redundant comment in format::getStyle."
Eric Liu [Thu, 24 Mar 2016 11:24:49 +0000 (11:24 +0000)]
Revert "removed redundant comment in format::getStyle."

This reverts commit r264254.

llvm-svn: 264256

8 years agoFix sequence point warning. NFC.
Vasileios Kalintiris [Thu, 24 Mar 2016 10:53:28 +0000 (10:53 +0000)]
Fix sequence point warning. NFC.

llvm-svn: 264255

8 years agoremoved redundant comment in format::getStyle.
Eric Liu [Thu, 24 Mar 2016 10:50:26 +0000 (10:50 +0000)]
removed redundant comment in format::getStyle.

llvm-svn: 264254

8 years agoAdded support for different VFSs in format::getStyle.
Eric Liu [Thu, 24 Mar 2016 10:50:17 +0000 (10:50 +0000)]
Added support for different VFSs in format::getStyle.

Summary:
Previously, format::getStyle assumes that the given file resides in
the real file system, which prevents the use of virtual file system in testing etc.
This patch adds a parameter in format::getStyle interface so that users can specify
the right file system. By default, the file system is the real file system.

Reviewers: djasper, klimek

Subscribers: cfe-commits, klimek

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

llvm-svn: 264253

8 years agoTest commit access to clang repo.
Eric Liu [Thu, 24 Mar 2016 10:21:00 +0000 (10:21 +0000)]
Test commit access to clang repo.

Summary: Test commit access to clang repo.

Reviewers: cfe-commits

Subscribers: klimek

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

llvm-svn: 264252

8 years ago[clang-tidy] misc-assign-operator-signature checker checks return value of all assign...
Gabor Horvath [Thu, 24 Mar 2016 10:12:08 +0000 (10:12 +0000)]
[clang-tidy] misc-assign-operator-signature checker checks return value of all assign operators

The return value of every assign operator should be Type&, not only for copy and move assign operators.

Patch by Adam Balogh!

Reviewers: hokein, alexfh

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

llvm-svn: 264251

8 years ago[llvm-nm] Fix r264247
James Molloy [Thu, 24 Mar 2016 09:23:51 +0000 (09:23 +0000)]
[llvm-nm] Fix r264247

I committed the test changes successfully but managed to miss the actual code change! (lack of git -a)

llvm-svn: 264249

8 years ago[mips][microMIPS] Add CodeGen support for DIV, MOD, DIVU, MODU, DDIV, DMOD, DDIVU...
Zlatko Buljan [Thu, 24 Mar 2016 09:22:45 +0000 (09:22 +0000)]
[mips][microMIPS] Add CodeGen support for DIV, MOD, DIVU, MODU, DDIV, DMOD, DDIVU and DMODU instructions
Differential Revision: http://reviews.llvm.org/D17137

llvm-svn: 264248

8 years ago[llvm-nm] Correct -P ELF output
James Molloy [Thu, 24 Mar 2016 09:18:09 +0000 (09:18 +0000)]
[llvm-nm] Correct -P ELF output

Correctly add a space between the address and size when outputting in posix mode (-P).

llvm-svn: 264247

8 years ago[mips][microMIPS] Implement MTC*, MTHC* and DMTC* instructions
Hrvoje Varga [Thu, 24 Mar 2016 08:02:09 +0000 (08:02 +0000)]
[mips][microMIPS] Implement MTC*, MTHC* and DMTC* instructions
Differential Revision: http://reviews.llvm.org/D17328

llvm-svn: 264246

8 years ago[mips][microMIPS] Fix for "Cannot copy registers" assertion
Hrvoje Varga [Thu, 24 Mar 2016 06:05:35 +0000 (06:05 +0000)]
[mips][microMIPS] Fix for "Cannot copy registers" assertion
Differential Revision: http://reviews.llvm.org/D17068

llvm-svn: 264245

8 years ago[LAA] Formatting fix in previous change
Adam Nemet [Thu, 24 Mar 2016 05:15:24 +0000 (05:15 +0000)]
[LAA] Formatting fix in previous change

llvm-svn: 264244

8 years ago[LAA] Support memchecks involving loop-invariant addresses
Adam Nemet [Thu, 24 Mar 2016 04:28:47 +0000 (04:28 +0000)]
[LAA] Support memchecks involving loop-invariant addresses

We used to only allow SCEVAddRecExpr for pointer expressions in order to
be able to compute the bounds.  However this is also trivially possible
for loop-invariant addresses (scUnknown) since then the bounds are the
address itself.

Interestingly, we used allow this for the special case when the
loop-invariant address happens to also be an SCEVAddRecExpr (in an outer
loop).

There are a couple more loops that are vectorized in SPEC after this.
My guess is that the main reason we don't see more because for example a
loop-invariant load is vectorized into a splat vector with several
vector-inserts.  This is likely to make the vectorization unprofitable.
I.e. we don't notice that a later LICM will move all of this out of the
loop so the cost estimate should really be 0.

llvm-svn: 264243

8 years ago[OpenCL] Add ocl and spir version for spir target
Xiuli Pan [Thu, 24 Mar 2016 03:57:17 +0000 (03:57 +0000)]
[OpenCL] Add ocl and spir version for spir target

Summary: Add opencl.spir.version and opencl.ocl.version metadata for CodeGen to identify OpenCL version.

Reviewers: yaxunl, Anastasia

Subscribers: cfe-commits, pekka.jaaskelainen

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

llvm-svn: 264241

8 years ago[Support] Add conversions between Expected<T> and ErrorOr<T>.
Lang Hames [Thu, 24 Mar 2016 02:00:10 +0000 (02:00 +0000)]
[Support] Add conversions between Expected<T> and ErrorOr<T>.

More utilities to help with std::error_code -> Error transitions.

llvm-svn: 264238

8 years ago[libFuzzer] don't report memory leaks if we are dying due to a timeout (just use...
Kostya Serebryany [Thu, 24 Mar 2016 01:32:08 +0000 (01:32 +0000)]
[libFuzzer] don't report memory leaks if we are dying due to a timeout (just use _Exit instead of exit in the timeout callback)

llvm-svn: 264237

8 years agoAdd release notes for the removal of the silent include of altivec.h.
Eric Christopher [Thu, 24 Mar 2016 01:28:25 +0000 (01:28 +0000)]
Add release notes for the removal of the silent include of altivec.h.

llvm-svn: 264236

8 years agoThe time when -faltivec (or, on clang only, -maltivec) will magically
Eric Christopher [Thu, 24 Mar 2016 01:26:08 +0000 (01:26 +0000)]
The time when -faltivec (or, on clang only, -maltivec) will magically
include altivec.h has come and gone.

Rationale: This causes modules, rewrite-includes, etc to be sad and
people should just include altivec.h in their source.

llvm-svn: 264235

8 years agoAvoid UB when creating empty atoms. NFC.
Pete Cooper [Thu, 24 Mar 2016 01:16:06 +0000 (01:16 +0000)]
Avoid UB when creating empty atoms.  NFC.

The stack-size.yaml test had an empty atom content array.  This is
legal, but asking a BumpPtrAllocator for 0 sized data may not be
legal.  Instead just avoid requesting any data when we can just return
an empty ArrayRef instead.

llvm-svn: 264234

8 years agoAvoid UB deref of nullptr to reference. NFC.
Pete Cooper [Thu, 24 Mar 2016 01:14:10 +0000 (01:14 +0000)]
Avoid UB deref of nullptr to reference.  NFC.

Its possible for file to have no entry atom which means that there
is no atom to check for being a thumb function.  Instead just skip
the thumb check and set the entry address to 0, which matches the
current behaviour of getting a default initialised int from a map.

llvm-svn: 264233

8 years agoUse a memcpy to avoid unaligned store UB.
Pete Cooper [Thu, 24 Mar 2016 01:05:17 +0000 (01:05 +0000)]
Use a memcpy to avoid unaligned store UB.

On a 32-bit output, we may write LC_MAIN (which contains a uint64_t) to
an unaligned address.  This changes it to use a memcpy instead which is UB safe.

llvm-svn: 264232

8 years agoUse unaligned read to fix UB. NFC.
Pete Cooper [Thu, 24 Mar 2016 01:03:44 +0000 (01:03 +0000)]
Use unaligned read to fix UB.  NFC.

We were casting a potentially unaligned pointer to uint32_t and
dereferencing.  As the pointer ultimately comes from the object file,
there's no way to guarantee alignment, so use the little32_t read instead.

Also, little32_t knows about endianness, so in theory this may have broken on
big endian machines.

llvm-svn: 264231

8 years ago[libFuzzer] use fdopen+vfprintf instead of fsnprintf+write
Kostya Serebryany [Thu, 24 Mar 2016 00:57:32 +0000 (00:57 +0000)]
[libFuzzer] use fdopen+vfprintf instead of fsnprintf+write

llvm-svn: 264230

8 years agoDisplay const/volatile/restrict qualifiers in Visual Studio visualizations
Mike Spertus [Thu, 24 Mar 2016 00:38:54 +0000 (00:38 +0000)]
Display const/volatile/restrict qualifiers in Visual Studio visualizations

llvm-svn: 264229

8 years agoParsed alignment should be a power of 2.
Pete Cooper [Thu, 24 Mar 2016 00:36:37 +0000 (00:36 +0000)]
Parsed alignment should be a power of 2.

The .o path always makes sure to store a power of 2 value in the
Section alignment.  However, the YAML code didn't verify this.

Added verification and updated all the tests which had a 3 but meant
to have 2^3.

llvm-svn: 264228

8 years agoModules builds are necessarily compile actions, but they don't
Eric Christopher [Thu, 24 Mar 2016 00:34:02 +0000 (00:34 +0000)]
Modules builds are necessarily compile actions, but they don't
necessarily produce object files. Turn off split dwarf if we're not
producing a file that the driver believes is an object file.

llvm-svn: 264227

8 years agoNFC: clarify comment on lock-free macros
JF Bastien [Thu, 24 Mar 2016 00:20:44 +0000 (00:20 +0000)]
NFC: clarify comment on lock-free macros

Used by both libstdc++ and libc++.

llvm-svn: 264226

8 years ago[X86][SSE] Added tests to ensure that consecutive loads including any/all volatiles...
Simon Pilgrim [Thu, 24 Mar 2016 00:14:37 +0000 (00:14 +0000)]
[X86][SSE] Added tests to ensure that consecutive loads including any/all volatiles are not combined

llvm-svn: 264225

8 years ago[PS4] Guarantee an instruction after a 'noreturn' call.
Paul Robinson [Thu, 24 Mar 2016 00:10:03 +0000 (00:10 +0000)]
[PS4] Guarantee an instruction after a 'noreturn' call.

We need the "return address" of a noreturn call to be within the
bounds of the calling function; TrapUnreachable turns 'unreachable'
into a 'ud2' instruction, which has that desired effect.

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

llvm-svn: 264224

8 years agoFix lazy linking of comdat members.
Rafael Espindola [Thu, 24 Mar 2016 00:06:03 +0000 (00:06 +0000)]
Fix lazy linking of comdat members.

If not for lazy linking of linkonce GVs, comdats are just a
preprocessing before symbol resolution.

Lazy linking complicates it since when we pick a visible member of
comdat, we have to make sure the rest of it passes symbol resolution
too.

llvm-svn: 264223

8 years ago[sancov] -print-coverage-stats option to print various coverage statistics.
Mike Aizatsky [Thu, 24 Mar 2016 00:00:08 +0000 (00:00 +0000)]
[sancov] -print-coverage-stats option to print various coverage statistics.

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

llvm-svn: 264222

8 years ago[Support] Make all Errors convertible to std::error_code.
Lang Hames [Wed, 23 Mar 2016 23:57:28 +0000 (23:57 +0000)]
[Support] Make all Errors convertible to std::error_code.

This is a temporary crutch to enable code that currently uses std::error_code
to be incrementally moved over to Error. Requiring all Error instances be
convertible enables clients to call errorToErrorCode on any error (not just
ECErrors created by conversion *from* an error_code).

This patch also moves code for Error from ErrorHandling.cpp into a new
Error.cpp file.

llvm-svn: 264221

8 years agoAPFloat: Fix signalling nans for scalbn
Matt Arsenault [Wed, 23 Mar 2016 23:51:45 +0000 (23:51 +0000)]
APFloat: Fix signalling nans for scalbn

llvm-svn: 264219

8 years agoFix a typo, Tiles -> Files, NFC
Vedant Kumar [Wed, 23 Mar 2016 23:51:36 +0000 (23:51 +0000)]
Fix a typo, Tiles -> Files, NFC

llvm-svn: 264218

8 years ago[JITLoaderGDB] Read jit entry struct manually.
Siva Chandra [Wed, 23 Mar 2016 23:27:23 +0000 (23:27 +0000)]
[JITLoaderGDB] Read jit entry struct manually.

Summary:
Though r264012 was fancy enough to make reading the jit entry struct
work with templates, the packing and alignment attributes do not work on
Windows. So, this change makes it plain and simple with manual reading
of the jit entry struct.

Reviewers: clayborg

Subscribers: lldb-commits

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

llvm-svn: 264217

8 years agoclang-cl: Add a FIXME for bumping the default msc version.
Nico Weber [Wed, 23 Mar 2016 23:26:59 +0000 (23:26 +0000)]
clang-cl: Add a FIXME for bumping the default msc version.

llvm-svn: 264216

8 years agoAMDGPU: Remove atomic inc/dec patterns
Matt Arsenault [Wed, 23 Mar 2016 23:23:38 +0000 (23:23 +0000)]
AMDGPU: Remove atomic inc/dec patterns

There is no benefit to these since materializing the constant 1
requires the same number of instructions as materializing uint_max

llvm-svn: 264215

8 years agoAMDGPU: Promote alloca should skip volatiles
Matt Arsenault [Wed, 23 Mar 2016 23:17:29 +0000 (23:17 +0000)]
AMDGPU: Promote alloca should skip volatiles

llvm-svn: 264214

8 years ago[sancov] code readability improvement.
Mike Aizatsky [Wed, 23 Mar 2016 23:15:03 +0000 (23:15 +0000)]
[sancov] code readability improvement.

Summary: Reply to http://reviews.llvm.org/D18341

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

llvm-svn: 264213

8 years ago[llgo] Increment "Debug Info Version"
Andrew Wilkins [Wed, 23 Mar 2016 23:09:00 +0000 (23:09 +0000)]
[llgo] Increment "Debug Info Version"

Patch by Michal Cierniak!

This patch increments the "Debug Info Version" from 2 to 3.
This is a nop if you just want to generate binaries. I verified
that with and without this patch, when I run llgo -g on a Go
source file, I get exactly the same binary. The purpose of the
patch is to make it possible to run the llvm-dis tool. Without
the patch, it is impossible to disassemble files generated with
llgo:

  $ llgo -c -g -emit-llvm src/hello.go
  $ llvm-dis hello.o
  llvm-dis: warning: ignoring debug info with an invalid version (2) in hello.o

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

llvm-svn: 264212

8 years agoFix typo in test from r264210, sigh.
Nico Weber [Wed, 23 Mar 2016 23:01:38 +0000 (23:01 +0000)]
Fix typo in test from r264210, sigh.

(The test passes both with and without this change, but it's confusing without
it.)

llvm-svn: 264211

8 years agoclang-cl: With -fmsc-version=1900, use MSVS2015 diag formatting.
Nico Weber [Wed, 23 Mar 2016 22:57:55 +0000 (22:57 +0000)]
clang-cl: With -fmsc-version=1900, use MSVS2015 diag formatting.

Remove tests that have neither a triple nor an explicit -fmsc-version flag,
since in the absence of an -fmsc-version flag, the implicit value of the flag
is 17 (MSVC2013) with MSVC triples but 0 (not set) for other triples, and
the default triple is platform dependent.

This relands r263974 with a test fix.

llvm-svn: 264210

8 years agodocs: Fix a missing language in a code-block
Justin Bogner [Wed, 23 Mar 2016 22:54:19 +0000 (22:54 +0000)]
docs: Fix a missing language in a code-block

This should fix the docs build.
Spotted by spstarr, thanks!

llvm-svn: 264209

8 years ago[CUDA] Update docs to reflect that we no longer define __NVCC__.
Justin Lebar [Wed, 23 Mar 2016 22:43:10 +0000 (22:43 +0000)]
[CUDA] Update docs to reflect that we no longer define __NVCC__.

llvm-svn: 264208

8 years ago[CUDA] Merge most of CodeGenCUDA/function-overload.cu into SemaCUDA/function-overload.cu.
Justin Lebar [Wed, 23 Mar 2016 22:42:30 +0000 (22:42 +0000)]
[CUDA] Merge most of CodeGenCUDA/function-overload.cu into SemaCUDA/function-overload.cu.

Summary:
Previously we were using the codegen test to ensure that we choose the
right overload.  But we can do this within sema, with a bit of
cleverness.

I left the constructor/destructor checks in CodeGen, because these
overloads (particularly on the destructors) are hard to check in Sema.

Reviewers: tra

Subscribers: cfe-commits

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

llvm-svn: 264207

8 years ago[CUDA] Simplify SemaCUDA/function-overload.cu test.
Justin Lebar [Wed, 23 Mar 2016 22:42:28 +0000 (22:42 +0000)]
[CUDA] Simplify SemaCUDA/function-overload.cu test.

Summary:
Principally, don't hardcode the line numbers of various notes.  This
lets us make changes to the test without recomputing linenos everywhere.

Instead, just tell -verify that we may get 0 or more notes pointing to
the relevant function definitions.  Checking that we get exactly the
right note isn't so important (and anyway is checked elsewhere).

Reviewers: tra

Subscribers: cfe-commits

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

llvm-svn: 264206

8 years ago[CUDA] Don't define __NVCC__.
Justin Lebar [Wed, 23 Mar 2016 22:42:27 +0000 (22:42 +0000)]
[CUDA] Don't define __NVCC__.

Summary:
We decided this makes life too difficult for code authors.  For example,
people may want to detect NVCC and disable variadic templates, which
NVCC does not support, but which we do.

Since people are going to have to change compiler flags *anyway* in
order to compile with clang, if they really want the old behavior, they
can pass -D__NVCC__.

Tested with tensorflow and thrust, no apparent problems.

Reviewers: tra

Subscribers: cfe-commits

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

llvm-svn: 264205

8 years agoFix more cases of UB from allocating 0 sized data. NFC.
Pete Cooper [Wed, 23 Mar 2016 22:19:16 +0000 (22:19 +0000)]
Fix more cases of UB from allocating 0 sized data.  NFC.

The size of a section can be zero, even when it contains atoms, so
long as all of the atoms are also size 0.  In this case we were
allocating space for a 0 sized buffer.

Changed this to only allocate when we need the space, but also cleaned
up all the code to use MutableArrayRef instead of uint8_t* so its much much
safer as we get bounds checking on all of our section creation logic.

llvm-svn: 264204

8 years agoAdd missing __builtin_bitreverse8
Matt Arsenault [Wed, 23 Mar 2016 22:14:43 +0000 (22:14 +0000)]
Add missing __builtin_bitreverse8

Also add documentation for bitreverse builtins

llvm-svn: 264203

8 years agoUse a memcpy to avoid unaligned store UB.
Pete Cooper [Wed, 23 Mar 2016 22:00:09 +0000 (22:00 +0000)]
Use a memcpy to avoid unaligned store UB.

On a 32-bit output, we may write LC_SOURCE_VERSION (which contains a uint64_t) to
an unaligned address.  This changes it to use a memcpy instead which is UB safe.

llvm-svn: 264202

8 years agoStringRef::copy shouldn't allocate anything for length 0 strings.
Pete Cooper [Wed, 23 Mar 2016 21:49:31 +0000 (21:49 +0000)]
StringRef::copy shouldn't allocate anything for length 0 strings.

The BumpPtrAllocator currently doesn't handle zero length allocations well.
The discussion for how to fix that is ongoing.  However, there's no need
for StringRef::copy to actually allocate anything here anyway, so just
return StringRef() when we get a zero length copy.

Reviewed by David Blaikie

llvm-svn: 264201

8 years agoAMDGPU: Insert moves of frame index to value operands
Matt Arsenault [Wed, 23 Mar 2016 21:49:25 +0000 (21:49 +0000)]
AMDGPU: Insert moves of frame index to value operands

Strengthen tests of storing frame indices.

Right now this just creates irrelevant scheduling changes.

We don't want to have multiple frame index operands
on an instruction. There seem to be various assumptions
that at least the same frame index will not appear twice
in the LocalStackSlotAllocation pass.

There's no reason to have this happen, and it just
makes it easy to introduce bugs where the immediate
offset is appplied to the storing instruction when it should
really be applied to the value being stored as a separate
add.

This might not be sufficient. It might still be problematic
to have an add fi, fi situation, but that's even less unlikely
to happen in real code.

llvm-svn: 264200

8 years agoAllow X86::COND_NE_OR_P and X86::COND_NP_OR_E to be reversed.
Cong Hou [Wed, 23 Mar 2016 21:45:37 +0000 (21:45 +0000)]
Allow X86::COND_NE_OR_P and X86::COND_NP_OR_E to be reversed.

Currently, AnalyzeBranch() fails non-equality comparison between floating points
on X86 (see https://llvm.org/bugs/show_bug.cgi?id=23875). This is because this
function can modify the branch by reversing the conditional jump and removing
unconditional jump if there is a proper fall-through. However, in the case of
non-equality comparison between floating points, this can turn the branch
"unanalyzable". Consider the following case:

jne.BB1
jp.BB1
jmp.BB2
.BB1:
...
.BB2:
...

AnalyzeBranch() will reverse "jp .BB1" to "jnp .BB2" and then "jmp .BB2" will be
removed:

jne.BB1
jnp.BB2
.BB1:
...
.BB2:
...

However, AnalyzeBranch() cannot analyze this branch anymore as there are two
conditional jumps with different targets. This may disable some optimizations
like block-placement: in this case the fall-through behavior is enforced even if
the fall-through block is very cold, which is suboptimal.

Actually this optimization is also done in block-placement pass, which means we
can remove this optimization from AnalyzeBranch(). However, currently
X86::COND_NE_OR_P and X86::COND_NP_OR_E are not reversible: there is no defined
negation conditions for them.

In order to reverse them, this patch defines two new CondCode X86::COND_E_AND_NP
and X86::COND_P_AND_NE. It also defines how to synthesize instructions for them.
Here only the second conditional jump is reversed. This is valid as we only need
them to do this "unconditional jump removal" optimization.

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

llvm-svn: 264199

8 years agoFix a cut-and-paste error in the changes for r264187 which I think is
Kevin Enderby [Wed, 23 Mar 2016 21:45:21 +0000 (21:45 +0000)]
Fix a cut-and-paste error in the changes for r264187 which I think is
the cause of the tools/llvm-objdump/X86/macho-symbolized-disassembly.test
crashing on linux.  Either way clearly incorrect code.

llvm-svn: 264198

8 years agoreorganize llc checks script to allow more flexibility; NFCI
Sanjay Patel [Wed, 23 Mar 2016 21:40:53 +0000 (21:40 +0000)]
reorganize llc checks script to allow more flexibility; NFCI

The goal is to enhance this script to be used with opt and clang:
Group all of the regexes together, so it's easier to see what's going on.
This will make it easier to break main() up into pieces too.
Also, note that some of the regexes are for x86-specific asm.

llvm-svn: 264197

8 years agoObjC: add getter/setter for class properties to global pool.
Manman Ren [Wed, 23 Mar 2016 21:39:31 +0000 (21:39 +0000)]
ObjC: add getter/setter for class properties to global pool.

rdar://problem/25323072

llvm-svn: 264196

8 years ago[sanitizer] Add strnlen to the common interceptors
Derek Bruening [Wed, 23 Mar 2016 21:24:28 +0000 (21:24 +0000)]
[sanitizer] Add strnlen to the common interceptors

Summary:
Adds strnlen to the common interceptors, under the existing flag
intercept_strlen.

Removes the now-duplicate strnlen interceptor from asan and msan.
This adds strnlen to tsan, which previously did not intercept it.

Adds a new test of strnlen to the sanitizer_common test cases.

Reviewers: samsonov

Subscribers: zhaoqin, llvm-commits, kcc

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

llvm-svn: 264195

8 years agoMore more change need as part of r264187 where ErrorOr<> was added
Kevin Enderby [Wed, 23 Mar 2016 21:20:16 +0000 (21:20 +0000)]
More more change need as part of r264187 where ErrorOr<> was added
to getSymbolType().

llvm-svn: 264194

8 years agoELF: Split BitcodeCompiler::compile.
Rui Ueyama [Wed, 23 Mar 2016 21:19:27 +0000 (21:19 +0000)]
ELF: Split BitcodeCompiler::compile.

http://reviews.llvm.org/D18410

llvm-svn: 264193

8 years agoFix logic for which symbols to keep with comdats.
Rafael Espindola [Wed, 23 Mar 2016 21:16:33 +0000 (21:16 +0000)]
Fix logic for which symbols to keep with comdats.

If a comdat is dropped, all symbols in it are dropped.
If a comdat is kept, the symbols survive to pass regular symbol
resolution.
With this patch we do that for all global symbols.

The added test is a copy of test/tools/gold/X86/comdat.ll that we now
pass.

llvm-svn: 264192

8 years agoGuard a number of tests relying on threads support when built in
Richard Barton [Wed, 23 Mar 2016 21:04:11 +0000 (21:04 +0000)]
Guard a number of tests relying on threads support when built in
single-threaded mode.

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

llvm-svn: 264191

8 years ago[asan] Export new and delete operators on Windows
Reid Kleckner [Wed, 23 Mar 2016 20:45:52 +0000 (20:45 +0000)]
[asan] Export new and delete operators on Windows

This is necessary to support the dynamic CRT (/MD) with VS2015. In
VS2015, these symbols are no longer imported from a DLL, they provided
statically by msvcrt.lib. This means our approach of hotpatching the DLL
no longer works.

By exporting the symbols, we end up relying on the same mechanism that
we use to intercept symbols in the static CRT (/MT) case. The ASan
runtime always needs to appear first on the link line, and the linker
searches for symbol definitions from left to right. This means we can
stop hotpatching operator new and delete in the CRT, which is nice.

I think that the only reason we weren't exporting the symbols already is
because MSVC doesn't allow you to do it directly with
__declspec(dllexport). Instead, we can use
`#pragma comment(linker, "/export:foo")`, which is most of what the
attribute does under the hood. It does mean we have to write down the
mangled names of the operators, but that's not too bad.

llvm-svn: 264190

8 years agoMake SemaAccess smarter about determining when a dependent class might
Richard Smith [Wed, 23 Mar 2016 20:39:06 +0000 (20:39 +0000)]
Make SemaAccess smarter about determining when a dependent class might
instantiate to match a friend class declaration. It's still pretty dumb,
though.

llvm-svn: 264189

8 years agoAdd the needed lld change for r264187 in llvm.
Kevin Enderby [Wed, 23 Mar 2016 20:37:23 +0000 (20:37 +0000)]
Add the needed lld change for r264187 in llvm.

Sorry had this fixed in my check out but failed mention it in my
commit message for r264187.

llvm-svn: 264188

8 years agoFix a crash in running llvm-objdump -t with an invalid Mach-O file already
Kevin Enderby [Wed, 23 Mar 2016 20:27:00 +0000 (20:27 +0000)]
Fix a crash in running llvm-objdump -t with an invalid Mach-O file already
in the test suite. While this is not really an interesting tool and option to run
on a Mach-O file to show the symbol table in a generic libObject format
it shouldn’t crash.

The reason for the crash was in MachOObjectFile::getSymbolType() when it was
calling MachOObjectFile::getSymbolSection() without checking its return value
for the error case.

What makes this fix require a fair bit of diffs is that the method getSymbolType() is
in the class ObjectFile defined without an ErrorOr<> so I needed to add that all
the sub classes.  And all of the uses needed to be updated and the return value
needed to be checked for the error case.

The MachOObjectFile version of getSymbolType() “can” get an error in trying to
come up with the libObject’s internal SymbolRef::Type when the Mach-O symbol
symbol type is an N_SECT type because the code is trying to select from the
SymbolRef::ST_Data or SymbolRef::ST_Function values for the SymbolRef::Type.
And it needs the Mach-O section to use isData() and isBSS to determine if
it will return SymbolRef::ST_Data.

One other possible fix I considered is to simply return SymbolRef::ST_Other
when MachOObjectFile::getSymbolSection() returned an error.  But since in
the past when I did such changes that “ate an error in the libObject code” I
was asked instead to push the error out of the libObject code I chose not
to implement the fix this way.

As currently written both the COFF and ELF versions of getSymbolType()
can’t get an error.  But if isReservedSectionNumber() wanted to check for
the two known negative values rather than allowing all negative values or
the code wanted to add the same check as in getSymbolAddress() to use
getSection() and check for the error then these versions of getSymbolType()
could return errors.

At the end of the day the error printed now is the generic “Invalid data was
encountered while parsing the file” for object_error::parse_failed.  In the
future when we thread Lang’s new TypedError for recoverable error handling
though libObject this will improve.  And where the added // Diagnostic(…
comment is, it would be changed to produce and error message
like “bad section index (42) for symbol at index 8” for this case.

llvm-svn: 264187

8 years ago[x86] make peekThroughBitcasts() a helper function
Sanjay Patel [Wed, 23 Mar 2016 20:16:37 +0000 (20:16 +0000)]
[x86] make peekThroughBitcasts() a helper function

This should be hoisted further up so it can be used in DAGCombiner and other backends,
but I'm limiting the scope in the interest of patch minimalism.

It's not quite NFC because some of the replaced code was using an 'if' check rather
than a 'while' loop, so those cases would only look through a single bitcast.

llvm-svn: 264186

8 years ago[AArch64] Replace return 0 with return false. NFC.
Chad Rosier [Wed, 23 Mar 2016 20:07:28 +0000 (20:07 +0000)]
[AArch64] Replace return 0 with return false. NFC.

llvm-svn: 264185

8 years agoMake sure to perform dependent access checks when instantiating a
Richard Smith [Wed, 23 Mar 2016 20:07:07 +0000 (20:07 +0000)]
Make sure to perform dependent access checks when instantiating a
lambda-expression. We don't actually instantiate the closure type / operator()
in the template in order to produce the closure type / operator() in the
instantiation, so this isn't caught by the normal path.

llvm-svn: 264184

8 years agoCodegen: [PPC] Word Rotates are Zero Extending.
Kyle Butt [Wed, 23 Mar 2016 19:51:22 +0000 (19:51 +0000)]
Codegen: [PPC] Word Rotates are Zero Extending.

Add Word rotates to the list of instructions that are zero extending.
This allows them to be used in dot form to compare with zero.

llvm-svn: 264183

8 years agoclang-cl: Fix remaining bugs in interaction of /Yc and /FI /showIncludes.
Nico Weber [Wed, 23 Mar 2016 18:46:57 +0000 (18:46 +0000)]
clang-cl: Fix remaining bugs in interaction of /Yc and /FI /showIncludes.

Instead of putting the /Yc header into ExtraDeps, give DependencyOutputOptions
a dedicated field for /Yc mode, and let HeaderIncludesCallback hang on to the
full DependencyOutputOptions object, not just ExtraDeps.

Reverts parts of r263352 that are now no longer needed.

llvm-svn: 264182

8 years ago[LTO] Keep linkonce symbols when required.
Davide Italiano [Wed, 23 Mar 2016 18:41:48 +0000 (18:41 +0000)]
[LTO] Keep linkonce symbols when required.

Similarly to how we do with linkonce_odr symbols already, but
change their linkage to weak.

llvm-svn: 264181

8 years agoFix bugs in the MemorySSA walker.
George Burgess IV [Wed, 23 Mar 2016 18:31:55 +0000 (18:31 +0000)]
Fix bugs in the MemorySSA walker.

There are a few bugs in the walker that this patch addresses.
Primarily:
- Caching can break when we have multiple BBs without phis
- We weren't optimizing some phis properly
- Because of how the DFS iterator works, there were times where we
  wouldn't cache any results of our DFS

I left the test cases with FIXMEs in, because I'm not sure how much
effort it will take to get those to work (read: We'll probably
ultimately have to end up redoing the walker, or we'll have to come up
with some creative caching tricks), and more test coverage = better.

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

llvm-svn: 264180

8 years agoAdd getBlockProfileCount method to BlockFrequencyInfo
Easwaran Raman [Wed, 23 Mar 2016 18:18:26 +0000 (18:18 +0000)]
Add getBlockProfileCount method to BlockFrequencyInfo

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

llvm-svn: 264179

8 years agoclang-cl: Add more tests for the interaction of /FI and /Yc /Yu.
Nico Weber [Wed, 23 Mar 2016 18:17:02 +0000 (18:17 +0000)]
clang-cl: Add more tests for the interaction of /FI and /Yc /Yu.

Most things even work; see the included FIXMEs for things that need polishing.

Also don't warn about unused flags for the `/Yuh2.h /FIh1.h /FIh2.h`.  The
common case is that the pch was built with `/Ych2.h /FIh1.h /FIh2.h`, so h1.h
is in the PCH, and we shouldn't warn about /FIh1.h not having an effect.
(If we wanted to get fancy, we could store the list of -include flags in the
pch and then check that it matches later on.)

llvm-svn: 264178