platform/upstream/llvm.git
8 years ago[asan/win] Move breakpoint from Abort to internal__exit
Reid Kleckner [Thu, 10 Nov 2016 20:44:05 +0000 (20:44 +0000)]
[asan/win] Move breakpoint from Abort to internal__exit

Now that we use TerminateProcess, the debugger doesn't stop on program
exit. Add this breakpoint so that the debugger stops after asan reports
an error and is prepared to exit the program.

llvm-svn: 286501

8 years agoClean up uses of unique_ptr for RAII objects. NFC.
George Burgess IV [Thu, 10 Nov 2016 20:43:52 +0000 (20:43 +0000)]
Clean up uses of unique_ptr for RAII objects. NFC.

- EnterExpressionEvaluationContext allows you to specify whether you
  *actually* want to enter an evaluation context.
- For types that don't allow that, llvm::Optional<Foo> should do the
  same thing as std::unique_ptr<Foo>, but with 100% less heap
  allocations.

llvm-svn: 286500

8 years agoMake the .idata$4 and .idata$5 import lib sections 8 bytes on x64
Reid Kleckner [Thu, 10 Nov 2016 20:38:58 +0000 (20:38 +0000)]
Make the .idata$4 and .idata$5 import lib sections 8 bytes on x64

The MSVC linker relies on this invariant to produce a valid import
table. More ASan tests pass in a stage 2 build now. They still fail when
using LLD since there are no PDBs for the dynamic ASan runtime.

llvm-svn: 286499

8 years agoFix type ambiguity with std::max
Zachary Turner [Thu, 10 Nov 2016 20:35:21 +0000 (20:35 +0000)]
Fix type ambiguity with std::max

llvm-svn: 286498

8 years agoFix initialization order error.
Zachary Turner [Thu, 10 Nov 2016 20:23:32 +0000 (20:23 +0000)]
Fix initialization order error.

llvm-svn: 286497

8 years agoInclude version string into ".comment" section.
Rui Ueyama [Thu, 10 Nov 2016 20:20:37 +0000 (20:20 +0000)]
Include version string into ".comment" section.

Summary:
This patch adds a ".comment" section to an output. The comment
section contains the linker's version string. You can now
find out whether a binary is created by LLD or not using objdump
command like this.

  $ objdump -s -j .comment foo

  foo:     file format elf64-x86-64

  Contents of section .comment:
   0000 00474343 3a202855 62756e74 7520342e  .GCC: (Ubuntu 4.
   0010 382e342d 32756275 6e747531 7e31342e  8.4-2ubuntu1~14.
   ...
   00c0 766d2f74 72756e6b 20323835 38343629  vm/trunk 285846)
   00d0 004c696e 6b65723a 204c4c44 20342e30  .Linker: LLD 4.0
   00e0 2e302028 7472756e 6b203238 36343036  .0 (trunk 286406
   00f0 2900                                 ).

Compilers emits .comment section as well, so the output contains
both compiler and linker information.

Alternative considered:

I first tried to add a SHT_NOTE section because GNU gold does that.
A NOTE section starts with a header which contains content type.
It turned out that ld.gold sets type NT_GNU_GOLD_VERSION to their
NOTE section. So the NOTE type is only for GNU gold (surprise!)

Next, I tried to create ".linker-version" section. However, it seems
that reusing the existing ".comment" section is better because 1)
other tools already know about .comment section and is able to strip
it and 2) the result contans not only linker info but also compiler
info.

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

llvm-svn: 286496

8 years ago[Support] Improve flexibility of binary blob formatter.
Zachary Turner [Thu, 10 Nov 2016 20:16:45 +0000 (20:16 +0000)]
[Support] Improve flexibility of binary blob formatter.

This makes it possible to indent a binary blob by a certain
number of bytes, and also makes some things more idiomatic.
Finally, it integrates this binary blob formatter into ScopedPrinter
which used to have its own implementation of this algorithm.

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

llvm-svn: 286495

8 years agoCorrecting a documentation formatting bug; NFC.
Aaron Ballman [Thu, 10 Nov 2016 19:45:49 +0000 (19:45 +0000)]
Correcting a documentation formatting bug; NFC.

llvm-svn: 286494

8 years ago[LTO] Call llvm_shutdown on early exit.
Davide Italiano [Thu, 10 Nov 2016 19:39:05 +0000 (19:39 +0000)]
[LTO] Call llvm_shutdown on early exit.

In a non-LTO build is a nop. In a LTO build, we deallocate/destroy
managed static and this allows us to get the output of, e.g.,
-time-passes without performing a full shutdown.

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

llvm-svn: 286493

8 years ago[PDB] Begin adding documentation for the PDB file format.
Zachary Turner [Thu, 10 Nov 2016 19:24:21 +0000 (19:24 +0000)]
[PDB] Begin adding documentation for the PDB file format.

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

llvm-svn: 286491

8 years ago[Test-Suite] Fix all the sanitizer tests to be based on compiler capabilities
Chris Bieneman [Thu, 10 Nov 2016 19:16:17 +0000 (19:16 +0000)]
[Test-Suite] Fix all the sanitizer tests to be based on compiler capabilities

Summary: This patch reworks all the @skip... lines for sanitizer libraries to be based on whether or not the compiler actually works, rather than whether or not the compiler-rt sources are present in some magically derived directory.

Reviewers: lldb-commits

Subscribers: kubabrecka, tfiala

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

llvm-svn: 286490

8 years ago[opt-viewer] Avoid duplicated remarks
Adam Nemet [Thu, 10 Nov 2016 18:42:56 +0000 (18:42 +0000)]
[opt-viewer] Avoid duplicated remarks

This can happen if a pass is run multiple times or if the code is in a
header file which is included multiple times.

llvm-svn: 286489

8 years ago[Target] Rename X86/ARM Assembly printer to reflect reality.
Davide Italiano [Thu, 10 Nov 2016 18:39:31 +0000 (18:39 +0000)]
[Target] Rename X86/ARM Assembly printer to reflect reality.

This shows up a lot profiling LTO testcases with -time-passes, so
better have a non confusing name.

llvm-svn: 286488

8 years agoAdd -Wduplicate-protocol for existing diagnostic
Alex Lorenz [Thu, 10 Nov 2016 18:30:26 +0000 (18:30 +0000)]
Add -Wduplicate-protocol for existing diagnostic

Expose a warning flag for warn_duplicate_protocol_def. This allows control
over the severity of duplicate protocol definitions.

For example -Werror=duplicate-protocol or
#pragma clang diagnostic ignored "-Wduplicate-protocol".

Patch provided by Dave Lee!

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

llvm-svn: 286487

8 years agoHandle adding new nested namespace in old namespace.
Eric Liu [Thu, 10 Nov 2016 18:29:01 +0000 (18:29 +0000)]
Handle adding new nested namespace in old namespace.

Reviewers: hokein

Subscribers: cfe-commits

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

llvm-svn: 286486

8 years ago[change-namespace] dyn_cast -> cast.
Eric Liu [Thu, 10 Nov 2016 18:15:34 +0000 (18:15 +0000)]
[change-namespace] dyn_cast -> cast.

llvm-svn: 286485

8 years agoFix some Clang-tidy modernize-use-default and readability-redundant-member-init and...
Eugene Zelenko [Thu, 10 Nov 2016 18:02:34 +0000 (18:02 +0000)]
Fix some Clang-tidy modernize-use-default and readability-redundant-member-init and Include What You Use warnings; other minor fixes.

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

llvm-svn: 286484

8 years agoRevert r286437 r286438, they caused PR30976
Nico Weber [Thu, 10 Nov 2016 17:55:41 +0000 (17:55 +0000)]
Revert r286437 r286438, they caused PR30976

llvm-svn: 286483

8 years ago[OptDiag] Remove non-printable chars from function name
Adam Nemet [Thu, 10 Nov 2016 17:47:03 +0000 (17:47 +0000)]
[OptDiag] Remove non-printable chars from function name

The r283656 did this in the remark arguments.  We also need to do this
in the main function attribute as that is written to YAML as well.

llvm-svn: 286482

8 years ago[SelectionDAG] Add support for vector demandedelts in TRUNCATE opcodes
Simon Pilgrim [Thu, 10 Nov 2016 17:43:52 +0000 (17:43 +0000)]
[SelectionDAG] Add support for vector demandedelts in TRUNCATE opcodes

llvm-svn: 286481

8 years agoAdd comments about why we put LoopSink pass at the very late stage.
Dehao Chen [Thu, 10 Nov 2016 17:42:18 +0000 (17:42 +0000)]
Add comments about why we put LoopSink pass at the very late stage.

llvm-svn: 286480

8 years agoUnify Darwin and Non-Darwin printing of version output
Chris Bieneman [Thu, 10 Nov 2016 17:33:19 +0000 (17:33 +0000)]
Unify Darwin and Non-Darwin printing of version output

Summary:
This change unifies and simplifies the code paths between the Darwin and non-Darwin code to print the LLDB version information.

It also introduces a new variable in CMake LLDB_VERSION_STRING which can be used to specify custom version information. On Darwin this value is implicitly set based on the resource/LLDB-Info.plist file.

With the LLDB_VERSION_STRING variable set to lldb-360.99.0, the -version output is:

> ./bin/lldb -version
lldb version 4.0.0 (lldb-360.99.0)
  clang revision 286264
  llvm revision 286265

This behavior is unified across all target platforms.

Reviewers: lldb-commits

Subscribers: mgorny, tfiala

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

llvm-svn: 286479

8 years ago[lsan] fix a rare lsan false positive: ensure that we don't re-sort the chunks_ array...
Kostya Serebryany [Thu, 10 Nov 2016 17:27:28 +0000 (17:27 +0000)]
[lsan] fix a rare lsan false positive: ensure that we don't re-sort the chunks_ array while iterating over it. A test is hard to create, but I've added a consistency check that fires w/o the fix on existing tests. The bug analysis and the initial patch were provided by Pierre Bourdon

llvm-svn: 286478

8 years ago[X86] Add knownbits vector TRUNC test
Simon Pilgrim [Thu, 10 Nov 2016 17:24:33 +0000 (17:24 +0000)]
[X86] Add knownbits vector TRUNC test

In preparation for demandedelts support

llvm-svn: 286477

8 years agoUn-XFail test on Windows. Has been in "unexpected success" mode for a while.
Adrian McCarthy [Thu, 10 Nov 2016 17:21:22 +0000 (17:21 +0000)]
Un-XFail test on Windows.  Has been in "unexpected success" mode for a while.

llvm-svn: 286476

8 years agoRestore part of "[ThinLTO] Prevent exporting of locals used/defined in module level...
Teresa Johnson [Thu, 10 Nov 2016 16:57:32 +0000 (16:57 +0000)]
Restore part of "[ThinLTO] Prevent exporting of locals used/defined in module level asm"

This restores the part of r286297 that didn't require adding a
dependency from the Analysis to Object library. There are two parts
to the original fix, and this will address the handling for the case
where locals are used in module level asm.

The part that requires functionality in libObject handles local defs
in module level asm, and was reverted because our downstream build
of clang builds lib/Bitcode into a single library, and this new
dependency introduced a cycle there. I am trying to get that fixed
(see D26502), so for now that change isn't being restored

llvm-svn: 286475

8 years agoProtect bitset tests under libcpp-no-exceptions
Roger Ferrer Ibanez [Thu, 10 Nov 2016 16:54:55 +0000 (16:54 +0000)]
Protect bitset tests under libcpp-no-exceptions

Bitset tests feature a sequence of tests of increasing bitset sizes,
but these tests rely on exceptions when the bitset size is less than
50 elements.

This change adds a flag to tell whether a test should throw. If it must
throw it will be skipped under no-exceptions.

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

llvm-svn: 286474

8 years agoUse common SDLoc. NFCI.
Simon Pilgrim [Thu, 10 Nov 2016 16:47:09 +0000 (16:47 +0000)]
Use common SDLoc. NFCI.

llvm-svn: 286473

8 years ago[clang-tidy] Add modernize-use-equals-delete check
Malcolm Parsons [Thu, 10 Nov 2016 16:46:59 +0000 (16:46 +0000)]
[clang-tidy] Add modernize-use-equals-delete check

Summary: Fixes PR27872

Reviewers: klimek, hokein, alexfh, aaron.ballman

Subscribers: Prazek, Eugene.Zelenko, danielmarjamaki, cfe-commits, mgorny

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

llvm-svn: 286472

8 years ago[SelectionDAG] Add support for vector demandedelts in MUL opcodes
Simon Pilgrim [Thu, 10 Nov 2016 16:27:42 +0000 (16:27 +0000)]
[SelectionDAG] Add support for vector demandedelts in MUL opcodes

llvm-svn: 286471

8 years agoreproducer for pr29002
Asaf Badouh [Thu, 10 Nov 2016 16:27:27 +0000 (16:27 +0000)]
reproducer for pr29002

https://reviews.llvm.org/D26449

llvm-svn: 286470

8 years agodrop kw_module from ASI protection block
Martin Probst [Thu, 10 Nov 2016 16:21:04 +0000 (16:21 +0000)]
drop kw_module from ASI protection block

llvm-svn: 286469

8 years agoclang-format: [JS] do not break after declare namespace.
Martin Probst [Thu, 10 Nov 2016 16:21:02 +0000 (16:21 +0000)]
clang-format: [JS] do not break after declare namespace.

Summary:
See TypeScript grammar for tokens following 'declare':
https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md#A.10

Additional minor change:
clang-format: [JS] Prevent ASI before const.

Reviewers: djasper

Subscribers: cfe-commits, klimek

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

llvm-svn: 286468

8 years agoclang-format: [JS] do not break after declare namespace.
Martin Probst [Thu, 10 Nov 2016 16:20:58 +0000 (16:20 +0000)]
clang-format: [JS] do not break after declare namespace.

See TypeScript grammar for tokens following 'declare':
https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md#A.10

llvm-svn: 286467

8 years ago[clang-tidy] Add missing meta refresh for cert-msc30-c doc. NFC
Malcolm Parsons [Thu, 10 Nov 2016 16:19:17 +0000 (16:19 +0000)]
[clang-tidy] Add missing meta refresh for cert-msc30-c doc. NFC

llvm-svn: 286466

8 years ago[Sema] Avoid -Wshadow warnings for shadowed variables that
Alex Lorenz [Thu, 10 Nov 2016 16:19:11 +0000 (16:19 +0000)]
[Sema] Avoid -Wshadow warnings for shadowed variables that
aren't captured by lambdas with a default capture specifier

This commit is a follow-up to r286354. It avoids the -Wshadow warning for
variables which shadow variables that aren't captured by lambdas with a default
capture specifier. It provides an additional note that points to location of
the capture.

The old behaviour is preserved with -Wshadow-all or -Wshadow-uncaptured-local.

rdar://14984176

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

llvm-svn: 286465

8 years agoAMDGPU: Add VI i16 support
Tom Stellard [Thu, 10 Nov 2016 16:02:37 +0000 (16:02 +0000)]
AMDGPU: Add VI i16 support

Patch By: Wei Ding

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

llvm-svn: 286464

8 years ago[X86] Add knownbits vector MUL test
Simon Pilgrim [Thu, 10 Nov 2016 15:57:33 +0000 (15:57 +0000)]
[X86] Add knownbits vector MUL test

In preparation for demandedelts support

llvm-svn: 286463

8 years agoReplace duplicated '16' with a named constant.
Rafael Espindola [Thu, 10 Nov 2016 15:41:34 +0000 (15:41 +0000)]
Replace duplicated '16' with a named constant.

Thanks to Michael Spencer for the suggestion.

llvm-svn: 286462

8 years ago[SelectionDAG] Add support for vector demandedelts in SRA opcodes
Simon Pilgrim [Thu, 10 Nov 2016 15:05:09 +0000 (15:05 +0000)]
[SelectionDAG] Add support for vector demandedelts in SRA opcodes

llvm-svn: 286461

8 years ago[InstCombine] auto-generate better checks; NFC
Sanjay Patel [Thu, 10 Nov 2016 14:58:17 +0000 (14:58 +0000)]
[InstCombine] auto-generate better checks; NFC

Note that the existing metadata checking was re-added by hand because the
script doesn't currently know how to generate checks for lines outside of
functions.

llvm-svn: 286460

8 years agoParse relocations only once.
Rafael Espindola [Thu, 10 Nov 2016 14:53:24 +0000 (14:53 +0000)]
Parse relocations only once.

Relocations are the last thing that we wore storing a raw section
pointer to and parsing on demand.

With this patch we parse it only once and store a pointer to the
actual data.

The patch also changes where we store it. It is now in
InputSectionBase. Not all sections have relocations, but most do and
this simplifies the logic. It also means that we now only support one
relocation section per section. Given that that constraint is
maintained even with -r with gold bfd and lld, I think it is OK.

llvm-svn: 286459

8 years agoReverted r286451 "[ELF] - Allow separate form for -f (alias for -auxiliary)."
George Rimar [Thu, 10 Nov 2016 14:48:39 +0000 (14:48 +0000)]
Reverted r286451 "[ELF] - Allow separate form for -f (alias for -auxiliary)."

Though the patch was technically correct,
the only FreeBSD port (noticed atm) that tried using it was
www/mod_jk. And it seems just passed gcc option to linker by mistake:

"-Wl,-L-L/usr/local/lib -Wl,-rpath,/usr/local/lib -Wl,-fstack-protector -Wl,-fstack-protector -o mod_jk.la "

Given that it is an easy mistake to make, reverting for now.

llvm-svn: 286458

8 years ago[X86] Add knownbits vector arithmetic shift test
Simon Pilgrim [Thu, 10 Nov 2016 14:46:24 +0000 (14:46 +0000)]
[X86] Add knownbits vector arithmetic shift test

In preparation for demandedelts support

llvm-svn: 286457

8 years agoAdd the loop end location to the loop metadata. This additional information
Amara Emerson [Thu, 10 Nov 2016 14:44:30 +0000 (14:44 +0000)]
Add the loop end location to the loop metadata. This additional information
can be used to improve the locations when generating remarks for loops.

Depends on the companion LLVM change r286227.

Patch by Florian Hahn.

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

llvm-svn: 286456

8 years ago[PowerPC] Implement plain VSX load/store builtins.
Tony Jiang [Thu, 10 Nov 2016 14:39:56 +0000 (14:39 +0000)]
[PowerPC] Implement plain VSX load/store builtins.

Implement all the different 24 overloads for vec_xl and vec_xst.

llvm-svn: 286455

8 years ago[DAGCombiner] Correctly extract the ConstOrConstSplat shift value for SHL nodes
Simon Pilgrim [Thu, 10 Nov 2016 14:35:09 +0000 (14:35 +0000)]
[DAGCombiner] Correctly extract the ConstOrConstSplat shift value for SHL nodes

We were failing to extract a constant splat shift value if the shifted value was being masked.

The (shl (and (setcc) N01CV) N1CV) -> (and (setcc) N01CV<<N1CV) combine was unnecessarily preventing this.

llvm-svn: 286454

8 years agoRemove unnecessary check prefix directives. NFC.
Chad Rosier [Thu, 10 Nov 2016 14:28:44 +0000 (14:28 +0000)]
Remove unnecessary check prefix directives. NFC.

llvm-svn: 286453

8 years ago[DAGCombiner] Show missed opportunity to UNDEF out-of-range SHL
Simon Pilgrim [Thu, 10 Nov 2016 14:19:45 +0000 (14:19 +0000)]
[DAGCombiner] Show missed opportunity to UNDEF out-of-range SHL

Fails to match constant shift value due to presence of AND mask.

llvm-svn: 286452

8 years ago[ELF] - Allow separate form for -f (alias for -auxiliary).
George Rimar [Thu, 10 Nov 2016 14:07:15 +0000 (14:07 +0000)]
[ELF] - Allow separate form for -f (alias for -auxiliary).

Without that FreeBSD port was failing with next confuxing error:
/usr/bin/ld: error: unknown argument: -fstack-protector

llvm-svn: 286451

8 years ago[RegionInfo] Add three tests that include infinite loops
Tobias Grosser [Thu, 10 Nov 2016 13:56:19 +0000 (13:56 +0000)]
[RegionInfo] Add three tests that include infinite loops

These examples are variations that were inspired from a small subgraph taken
from paper.ll which are interesting as they show certain issues with infinite
loops.

llvm-svn: 286450

8 years agoFix -Wdocumentation warning
Simon Pilgrim [Thu, 10 Nov 2016 13:54:39 +0000 (13:54 +0000)]
Fix -Wdocumentation warning

llvm-svn: 286449

8 years ago[SelectionDAG] Add support for vector demandedelts in SHL/SRL opcodes
Simon Pilgrim [Thu, 10 Nov 2016 13:52:42 +0000 (13:52 +0000)]
[SelectionDAG] Add support for vector demandedelts in SHL/SRL opcodes

llvm-svn: 286448

8 years ago[X86] Add knownbits vector logical shift test
Simon Pilgrim [Thu, 10 Nov 2016 13:34:17 +0000 (13:34 +0000)]
[X86] Add knownbits vector logical shift test

In preparation for demandedelts support

llvm-svn: 286447

8 years ago[ARM] Thumb2 LDR (literal) should accept PC as the destination
Oliver Stannard [Thu, 10 Nov 2016 13:20:41 +0000 (13:20 +0000)]
[ARM] Thumb2 LDR (literal) should accept PC as the destination

The version of this instruction with the .w suffix already correctly accepts
this, but the alias without the .w did not.

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

llvm-svn: 286446

8 years ago[ELF] Make SyntheticSection::writeTo pure virtual. NFC.
Eugene Leviant [Thu, 10 Nov 2016 12:50:59 +0000 (12:50 +0000)]
[ELF] Make SyntheticSection::writeTo pure virtual. NFC.

llvm-svn: 286445

8 years agoSCEVAffinator: pass parameter-only set to addRestriction if BB=nullptr
Tobias Grosser [Thu, 10 Nov 2016 11:44:10 +0000 (11:44 +0000)]
SCEVAffinator: pass parameter-only set to addRestriction if BB=nullptr

Assumptions can either be added for a given basic block, in which case the set
describing the assumptions is expected to match the dimensions of its domain.
In case no basic block is provided a parameter-only set is expected to describe
the assumption.

The piecewise expressions that are generated by the SCEVAffinator sometimes
have a zero-dimensional domain (e.g., [p] -> { [] : p <= -129 or p >= 128 }),
which looks similar to a parameter-only domain, but is still a set domain.

This change adds an assert that checks that we always pass parameter domains to
addAssumptions if BB is empty to make mismatches here fail early.

We also change visitTruncExpr to always convert to parameter sets, if BB is
null. This change resolves http://llvm.org/PR30941

Another alternative to this change would have been to inspect all code to make
sure we directly generate in the SCEV affinator parameter sets in case of empty
domains. However, this would likely complicate the code which combines parameter
and non-parameter domains when constructing a statement domain. We might still
consider doing this at some point, but as this likely requires several non-local
changes this should probably be done as a separate refactoring.

Reported-by: Eli Friedman <efriedma@codeaurora.org>
llvm-svn: 286444

8 years ago[ELF] Convert .got.plt section to input section
Eugene Leviant [Thu, 10 Nov 2016 09:48:29 +0000 (09:48 +0000)]
[ELF] Convert .got.plt section to input section

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

llvm-svn: 286443

8 years agoIslAst: always use the context during ast generation
Tobias Grosser [Thu, 10 Nov 2016 09:39:58 +0000 (09:39 +0000)]
IslAst: always use the context during ast generation

Providing the context to the ast generator allows for additional simplifcations
and -- more importantly -- allows to generate loops with only partially bounded
domains, assuming the domains are bounded for all parameter configurations
that are valid as defined by the context.

This change fixes the crash reported in http://llvm.org/PR30956

The original reason why we did not include the context when generating an
AST was that CLooG and later isl used to sometimes transfer some of the
constraints that bound the size of parameters from the context into the
generated AST. This resulted in operations with very large constants, which
sometimes introduced problematic integer overflows. The latest versions of
the isl AST generator are careful to not introduce such constants.

Reported-by: Eli Friedman <efriedma@codeaurora.org>
llvm-svn: 286442

8 years agoAdded check for malloc return.
Andrey Churbanov [Thu, 10 Nov 2016 09:08:03 +0000 (09:08 +0000)]
Added check for malloc return.

Patch by Victor Campos.

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

llvm-svn: 286441

8 years ago[ELF] - Implemented --symbol-ordering-file option.
George Rimar [Thu, 10 Nov 2016 09:05:20 +0000 (09:05 +0000)]
[ELF] - Implemented --symbol-ordering-file option.

Patch allows to pass a symbols file to linker.
LLD will map symbols to sections and sort sections
in output according to symbol ordering file.

That can help to reduce the startup time and/or
amount of pagefaults during startup.

Also, interesting benchmark result was produced by Rafael Espíndola.
After applying the symbols file for clang he timed compiling
X86MCTargetDesc.ii to an object file.

The page faults went from just
56,988 to 56,946 since most faults are not in the binary.
Running time went from 4.403053515 to 4.178112244.
The speedup seems to be because of better cache
locality.

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

llvm-svn: 286440

8 years agoMake output of -ast-print a valid C++ code.
Serge Pavlov [Thu, 10 Nov 2016 08:49:37 +0000 (08:49 +0000)]
Make output of -ast-print a valid C++ code.

Output generated by option -ast-print looks like C/C++ code, and it
really is for plain C. For C++ the produced output was not valid C++
code, but the differences were small. With this change the output
is fixed and can be compiled. Tests are changed so that output produced
by -ast-print is compiled again with the same flags and both outputs are
compared.

Option -ast-print is extensively used in clang tests but it itself
was tested poorly, existing tests only checked that compiler did not
crash. There are unit tests in file DeclPrinterTest.cpp, but they test
only terse output mode.

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

llvm-svn: 286439

8 years ago[SCEVExpander] Hoist unsigned divisons when safe
Sanjoy Das [Thu, 10 Nov 2016 07:56:12 +0000 (07:56 +0000)]
[SCEVExpander] Hoist unsigned divisons when safe

That is, when the divisor is a constant non-zero.

llvm-svn: 286438

8 years ago[SCEVExpander] Don't hoist divisions
Sanjoy Das [Thu, 10 Nov 2016 07:56:09 +0000 (07:56 +0000)]
[SCEVExpander] Don't hoist divisions

Fixes PR30942.

llvm-svn: 286437

8 years agoLift out a helper lambda; NFC
Sanjoy Das [Thu, 10 Nov 2016 07:56:05 +0000 (07:56 +0000)]
Lift out a helper lambda; NFC

llvm-svn: 286436

8 years ago[AVX-512] Allow legacy cvtpd2dq intrinsics to select EVEX encoded instruction when...
Craig Topper [Thu, 10 Nov 2016 07:47:17 +0000 (07:47 +0000)]
[AVX-512] Allow legacy cvtpd2dq intrinsics to select EVEX encoded instruction when available.

llvm-svn: 286435

8 years ago[AVX-512][X86] Convert avx_cvtt_ps2dq_256 and sse2_cvttps2dq intrinsics to ISD::FP_TO...
Craig Topper [Thu, 10 Nov 2016 07:24:52 +0000 (07:24 +0000)]
[AVX-512][X86] Convert avx_cvtt_ps2dq_256 and sse2_cvttps2dq intrinsics to ISD::FP_TO_SINT in the intrinsics table and delete patterns. While nearby also move CVTDQ2PS patterns into their instructions.

This allows these intrinsics to also use EVEX instructons.

llvm-svn: 286434

8 years ago[X86] Convert int_x86_avx_cvtt_pd2dq_256 to fp_to_sint using the intrinsics table...
Craig Topper [Thu, 10 Nov 2016 06:45:39 +0000 (06:45 +0000)]
[X86] Convert int_x86_avx_cvtt_pd2dq_256 to fp_to_sint using the intrinsics table. Removes extra patterns and allows legacy intrinsic to select EVEX encoded instructions when available.

llvm-svn: 286433

8 years ago[X86] Move some custom patterns into the currently empty pattern of their correspondi...
Craig Topper [Thu, 10 Nov 2016 06:45:37 +0000 (06:45 +0000)]
[X86] Move some custom patterns into the currently empty pattern of their corresponding instructions. NFC

llvm-svn: 286432

8 years ago[X86] Remove some patterns still referencing int_x86_sse2_cvttpd2dq that should have...
Craig Topper [Thu, 10 Nov 2016 06:45:34 +0000 (06:45 +0000)]
[X86] Remove some patterns still referencing int_x86_sse2_cvttpd2dq that should have been removed in r286344. NFC

llvm-svn: 286431

8 years agoSCEVValidator: add new parameters resulting from constant extraction
Tobias Grosser [Thu, 10 Nov 2016 06:45:28 +0000 (06:45 +0000)]
SCEVValidator: add new parameters resulting from constant extraction

When extracting constant expressions out of SCEVs, new parameters may be
introduced, which have not been registered before. This change scans
SCEV expressions after constant extraction again to make sure newly
introduced parameters are registered.

We may for example extract the constant '8' from the expression '((8 * ((%a *
%b) + %c)) + (-8 * %a))' and obtain the expression '(((-1 + %b) * %a) + %c)'.
The new expression has a new parameter '(-1 + %b) * %a)', which was not
registered before, but must be registered to not crash.

This closes http://llvm.org/PR30953

Reported-by: Eli Friedman <efriedma@codeaurora.org>
llvm-svn: 286430

8 years ago[SCEV] Eta reduce some lambdas; NFC
Sanjoy Das [Thu, 10 Nov 2016 06:33:54 +0000 (06:33 +0000)]
[SCEV] Eta reduce some lambdas; NFC

llvm-svn: 286429

8 years ago[LangRef] Drop "experimental" caveat from operand bundles
Sanjoy Das [Thu, 10 Nov 2016 06:21:10 +0000 (06:21 +0000)]
[LangRef] Drop "experimental" caveat from operand bundles

I think we're past that point now.

llvm-svn: 286428

8 years ago[clang-move] Support template class.
Haojian Wu [Thu, 10 Nov 2016 05:33:26 +0000 (05:33 +0000)]
[clang-move] Support template class.

Reviewers: ioeric

Subscribers: cfe-commits

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

llvm-svn: 286427

8 years agoDo not allow switch statements in loop latches
Tobias Grosser [Thu, 10 Nov 2016 05:20:29 +0000 (05:20 +0000)]
Do not allow switch statements in loop latches

In r248701 "Allow switch instructions in SCoPs" support for switch statements
has been introduced, but support for switch statements in loop latches was
incomplete. This change completely disables switch statements in loop latches.

The original commit changed addLoopBoundsToHeaderDomain to support non-branch
terminator instructions, but this change was incorrect: it added a check for
BI != null to the if-branch of a condition, but BI was used in the else branch
es well. As a result, when a non-branch terminator instruction is encounted a
nullptr dereference is triggered. Due to missing test coverage, this bug was
overlooked.

r249273 "[FIX] Approximate non-affine loops correctly" added code to disallow
switch statements for non-affine loops, if they appear in either a loop latch
or a loop exit. We adapt this code to now prohibit switch statements in
loop latches even if the control condition is affine.

We could possibly add support for switch statements in loop latches, but such
support should be evaluated and tested separately.

This fixes llvm.org/PR30952

Reported-by: Eli Friedman <efriedma@codeaurora.org>
llvm-svn: 286426

8 years ago[AVX-512] Add test cases to show missed opportunities for using VALIGND/Q to handle...
Craig Topper [Thu, 10 Nov 2016 03:39:19 +0000 (03:39 +0000)]
[AVX-512] Add test cases to show missed opportunities for using VALIGND/Q to handle shuffles.

llvm-svn: 286425

8 years ago[clang-tidy] Do not issue fix for functions that are referenced outside of callExpr
Felix Berger [Thu, 10 Nov 2016 01:28:22 +0000 (01:28 +0000)]
[clang-tidy] Do not issue fix for functions that are referenced outside of callExpr

Summary: Suppress fixes for functions that are referenced within the
compilation unit outside of a call expression as the signature change
could break the code referencing the function.

We still issue a warning in this case so that users can decide to
manually change the function signature.

Reviewers: alexfh, sbenza, aaron.ballman

Subscribers: cfe-commits

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

llvm-svn: 286424

8 years ago[InstCombine] avoid infinite loop from shuffle-extract-insert sequence (PR30923)
Sanjay Patel [Thu, 10 Nov 2016 00:15:14 +0000 (00:15 +0000)]
[InstCombine] avoid infinite loop from shuffle-extract-insert sequence (PR30923)

Removing the limitation in visitInsertElementInst() causes several regressions
because we're not prepared to fold sequences of shuffles or inserts and extracts
separated by shuffles. Fixing that appears to be a difficult mission because we
are purposely trying to avoid creating shuffles with arbitrary shuffle masks
because some targets may choke on those.

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

llvm-svn: 286423

8 years agoAdd comment and simplify code a bit. NFC.
Rui Ueyama [Thu, 10 Nov 2016 00:12:28 +0000 (00:12 +0000)]
Add comment and simplify code a bit. NFC.

llvm-svn: 286422

8 years ago[libclang] Fix issue with clang_tokenize and make sure it interprets CXSourceRange...
Argyrios Kyrtzidis [Wed, 9 Nov 2016 23:58:39 +0000 (23:58 +0000)]
[libclang] Fix issue with clang_tokenize and make sure it interprets CXSourceRange as half-open character range.

Patch provided by Emilio Cobos Álvarez! (https://reviews.llvm.org/D26446)

llvm-svn: 286421

8 years agoRe-apply r286384, "X86: Introduce the "relocImm" ComplexPattern, which represents...
Peter Collingbourne [Wed, 9 Nov 2016 23:53:43 +0000 (23:53 +0000)]
Re-apply r286384, "X86: Introduce the "relocImm" ComplexPattern, which represents a relocatable immediate.", with a fix for 32-bit x86.

Teach X86InstrInfo::analyzeCompare() not to crash on CMP and SUB instructions
that take a global address operand.

llvm-svn: 286420

8 years ago[Sema] Use MS ABI behavior for dllexport in Itanium
Shoaib Meenai [Wed, 9 Nov 2016 23:52:20 +0000 (23:52 +0000)]
[Sema] Use MS ABI behavior for dllexport in Itanium

Similar to r284288, make the Itanium ABI follow MS ABI dllexport
semantics in the case of an explicit instantiation declaration followed
by a dllexport explicit instantiation definition.

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

llvm-svn: 286419

8 years ago[AVR] Add a selection of CodeGen tests
Dylan McKay [Wed, 9 Nov 2016 23:46:52 +0000 (23:46 +0000)]
[AVR] Add a selection of CodeGen tests

Summary: This adds all of the CodeGen tests which currently pass.

Reviewers: arsenm, kparzysz

Subscribers: japaric, wdng

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

llvm-svn: 286418

8 years ago[AVR] Add all of the machine code test suite
Dylan McKay [Wed, 9 Nov 2016 23:46:25 +0000 (23:46 +0000)]
[AVR] Add all of the machine code test suite

Summary: This adds all of the AVR machine code tests.

Reviewers: arsenm, kparzysz

Subscribers: wdng, japaric

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

llvm-svn: 286417

8 years agoRemove an overloaded function to simplify.
Rui Ueyama [Wed, 9 Nov 2016 23:37:40 +0000 (23:37 +0000)]
Remove an overloaded function to simplify.

This version of addRegular is almost identical to the other except
it lacked "size" parameter.

llvm-svn: 286416

8 years agoAdd isHotBB helper function to ProfileSummaryInfo
Dehao Chen [Wed, 9 Nov 2016 23:36:02 +0000 (23:36 +0000)]
Add isHotBB helper function to ProfileSummaryInfo

Summary: This will unify all BB hotness checks.

Reviewers: eraman, davidxl

Subscribers: llvm-commits

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

llvm-svn: 286415

8 years agoMake OutputSectionBase a class instead of class template.
Rafael Espindola [Wed, 9 Nov 2016 23:23:45 +0000 (23:23 +0000)]
Make OutputSectionBase a class instead of class template.

The disadvantage is that we use uint64_t instad of uint32_t for some
value in 32 bit files. The advantage is a substantially simpler code,
faster builds and less code duplication.

llvm-svn: 286414

8 years agoFix weak symbol linkage in SBStructuredData, update docs.
Todd Fiala [Wed, 9 Nov 2016 23:21:04 +0000 (23:21 +0000)]
Fix weak symbol linkage in SBStructuredData, update docs.

Summary:
This change fixes an issue where I was leaking a weakly-linked symbol in
the SBAPI. It also updates the docs to call out what I did wrong.

Fixes:
rdar://28882483

Reviewers: jingham

Subscribers: lldb-commits

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

llvm-svn: 286413

8 years agoRemove extra whitespace
Adrian Prantl [Wed, 9 Nov 2016 23:10:44 +0000 (23:10 +0000)]
Remove extra whitespace

llvm-svn: 286412

8 years agoRelax testcase so it also works on Windows.
Adrian Prantl [Wed, 9 Nov 2016 23:05:16 +0000 (23:05 +0000)]
Relax testcase so it also works on Windows.

llvm-svn: 286411

8 years agoPreserve assumption cache in loop-rotate.
Eli Friedman [Wed, 9 Nov 2016 23:05:01 +0000 (23:05 +0000)]
Preserve assumption cache in loop-rotate.

No testcase included because I can't figure out how to reduce it.
(It's easy to write a testcase where rotation clones an assume,
but that doesn't actually seem to trigger the crash in opt on
its own; maybe an issue with the laziness?)

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

llvm-svn: 286410

8 years ago[Sema][NFC] Reset HasFallthroughStmt when clearing FunctionScopeInfo
Erik Pilkington [Wed, 9 Nov 2016 22:52:23 +0000 (22:52 +0000)]
[Sema][NFC] Reset HasFallthroughStmt when clearing FunctionScopeInfo

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

llvm-svn: 286409

8 years agoGlobalISel: fix typo. NFC
Tim Northover [Wed, 9 Nov 2016 22:40:02 +0000 (22:40 +0000)]
GlobalISel: fix typo. NFC

llvm-svn: 286408

8 years agoGlobalISel: translate invoke and landingpad instructions
Tim Northover [Wed, 9 Nov 2016 22:39:54 +0000 (22:39 +0000)]
GlobalISel: translate invoke and landingpad instructions

Pretty bare-bones support for exception handling (no weird MSVC stuff, no SjLj
etc), but it should get things going.

llvm-svn: 286407

8 years agoSimplify parseEmulation. NFC.
Rui Ueyama [Wed, 9 Nov 2016 22:32:43 +0000 (22:32 +0000)]
Simplify parseEmulation. NFC.

llvm-svn: 286406

8 years agoSplit OutputSection ctor. NFC.
Rui Ueyama [Wed, 9 Nov 2016 22:32:42 +0000 (22:32 +0000)]
Split OutputSection ctor. NFC.

llvm-svn: 286405

8 years ago[clang-tidy docs] Minor formatting changes.
Alexander Kornienko [Wed, 9 Nov 2016 22:31:07 +0000 (22:31 +0000)]
[clang-tidy docs] Minor formatting changes.

llvm-svn: 286404

8 years agoUpdate vectorization debug info unittest.
Dehao Chen [Wed, 9 Nov 2016 22:25:19 +0000 (22:25 +0000)]
Update vectorization debug info unittest.

Summary:
The change will test the change in r286159.
The idea behind the change: Make the dbg location different between loop header and preheader/exit. Originally, dbg location 21 exists in 3 BBs: preheader, header, critical edge (exit). Update the debug location of inside the loop header from !21 to !22 so that it will reflect the correct location.

Reviewers: probinson

Subscribers: llvm-commits

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

llvm-svn: 286403

8 years ago[InstCombine] regenerate checks; NFC
Sanjay Patel [Wed, 9 Nov 2016 22:21:58 +0000 (22:21 +0000)]
[InstCombine] regenerate checks; NFC

llvm-svn: 286402

8 years ago[ELF][MIPS] Attempt to fix buildbot
Simon Atanasyan [Wed, 9 Nov 2016 21:46:42 +0000 (21:46 +0000)]
[ELF][MIPS] Attempt to fix buildbot

llvm-svn: 286401