platform/upstream/llvm.git
7 years agoRevert "[GVNHoist] Move GVNHoist to function simplification part of pipeline."
Evgeniy Stepanov [Sat, 17 Dec 2016 01:53:15 +0000 (01:53 +0000)]
Revert "[GVNHoist] Move GVNHoist to function simplification part of pipeline."

This reverts r289696, which caused TSan perf regression.

See PR31382.

llvm-svn: 290030

7 years agoFix compilation.
Evgeniy Stepanov [Sat, 17 Dec 2016 01:31:46 +0000 (01:31 +0000)]
Fix compilation.

unittests/ADT/TwineTest.cpp:106:38: error: field 'Count' will be initialized after base 'llvm::FormatAdapter<int>' [-Werror,-Wreorder]
    explicit formatter(int &Count) : Count(Count), FormatAdapter(0) {}

llvm-svn: 290029

7 years ago[Hexagon] Other attempt to fix build with enabled asserts broken in 290024 (NFC).
Eugene Zelenko [Sat, 17 Dec 2016 01:29:35 +0000 (01:29 +0000)]
[Hexagon] Other attempt to fix build with enabled asserts broken in 290024 (NFC).

llvm-svn: 290028

7 years ago[Hexagon] Fix build with enabled asserts broken in 290024 (NFC).
Eugene Zelenko [Sat, 17 Dec 2016 01:17:18 +0000 (01:17 +0000)]
[Hexagon] Fix build with enabled asserts broken in 290024 (NFC).

llvm-svn: 290027

7 years agoAArch64CollectLOH: Rewrite as block-local analysis.
Matthias Braun [Sat, 17 Dec 2016 01:15:59 +0000 (01:15 +0000)]
AArch64CollectLOH: Rewrite as block-local analysis.

Re-apply r288561: Liveness tracking should be correct now after r290014.

Previously this pass was using up to 5% compile time in some cases which
is a bit much for what it is doing. The pass featured a full blown
data-flow analysis which in the default configuration was restricted to a
single block.

This rewrites the pass under the assumption that we only ever work on a
single block. This is done in a single pass maintaining a state machine
per general purpose register to catch LOH patterns.

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

llvm-svn: 290026

7 years ago[libclang] Remove the 'extern "C"' blocks from the implementation files.
Argyrios Kyrtzidis [Sat, 17 Dec 2016 01:09:40 +0000 (01:09 +0000)]
[libclang] Remove the 'extern "C"' blocks from the implementation files.

These are unnecessary, the declarations already carry the 'extern C' property, and if there is mismatch
between declaration and definition then we will get linker errors via libclang.exports.

llvm-svn: 290025

7 years ago[Hexagon] Fix some Clang-tidy modernize and Include What You Use warnings; other...
Eugene Zelenko [Sat, 17 Dec 2016 01:09:05 +0000 (01:09 +0000)]
[Hexagon] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).

llvm-svn: 290024

7 years ago[analyzer] UnixAPIChecker: Don't diagnose for functions in C++ namespaces
Devin Coughlin [Sat, 17 Dec 2016 01:08:17 +0000 (01:08 +0000)]
[analyzer] UnixAPIChecker: Don't diagnose for functions in C++ namespaces

Update the UnixAPIChecker to not diagnose for calls to functions that
are declared in C++ namespaces. This avoids false positives when a
namespaced function has the same name as a Unix API.

This address PR28331.

llvm-svn: 290023

7 years agoRetry: [BPI] Use a safer constructor to calculate branch probabilities
Vedant Kumar [Sat, 17 Dec 2016 01:02:08 +0000 (01:02 +0000)]
Retry: [BPI] Use a safer constructor to calculate branch probabilities

BPI may trigger signed overflow UB while computing branch probabilities for
cold calls or to unreachables. For example, with our current choice of weights,
we'll crash if there are >= 2^12 branches to an unreachable.

Use a safer BranchProbability constructor which is better at handling fractions
with large denominators.

Changes since the initial commit:
  - Use explicit casts to ensure that multiplication operands are 64-bit
    ints.

rdar://problem/29368161

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

llvm-svn: 290022

7 years agoDelete unused file.
Zachary Turner [Sat, 17 Dec 2016 00:58:19 +0000 (00:58 +0000)]
Delete unused file.

llvm-svn: 290021

7 years agoAdd support for formatv to llvm::Twine.
Zachary Turner [Sat, 17 Dec 2016 00:38:15 +0000 (00:38 +0000)]
Add support for formatv to llvm::Twine.

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

llvm-svn: 290020

7 years agoRevert "[BPI] Use a safer constructor to calculate branch probabilities"
Vedant Kumar [Sat, 17 Dec 2016 00:19:06 +0000 (00:19 +0000)]
Revert "[BPI] Use a safer constructor to calculate branch probabilities"

This reverts commit r290016. It breaks this bot, even though the test
passes locally:

  http://bb.pgr.jp/builders/ninja-x64-msvc-RA-centos6/builds/32956/

AnalysisTests: /home/bb/ninja-x64-msvc-RA-centos6/llvm-project/llvm/lib/Support/BranchProbability.cpp:52: static llvm::BranchProbability llvm::BranchProbability::getBranchProbability(uint64_t, uint64_t): Assertion `Numerator <= Denominator && "Probability cannot be bigger than 1!"' failed.
llvm-svn: 290019

7 years ago[libfuzzer] removing experimental FuzzerFnAdapter
Mike Aizatsky [Sat, 17 Dec 2016 00:12:13 +0000 (00:12 +0000)]
[libfuzzer] removing experimental FuzzerFnAdapter

Summary: This is superceded by protobuf mutation work.

Reviewers: kcc

Subscribers: mgorny

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

llvm-svn: 290018

7 years ago[sancov] skip dead files from computations
Mike Aizatsky [Sat, 17 Dec 2016 00:11:48 +0000 (00:11 +0000)]
[sancov] skip dead files from computations

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

llvm-svn: 290017

7 years ago[BPI] Use a safer constructor to calculate branch probabilities
Vedant Kumar [Sat, 17 Dec 2016 00:09:51 +0000 (00:09 +0000)]
[BPI] Use a safer constructor to calculate branch probabilities

BPI may trigger signed overflow UB while computing branch probabilities
for cold calls or to unreachables. For example, with our current choice
of weights, we'll crash if there are >= 2^12 branches to an unreachable.

Use a safer BranchProbability constructor which is better at handling
fractions with large denominators.

rdar://problem/29368161

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

llvm-svn: 290016

7 years ago[ORC][RPC] Use more meaningful template parameter names.
Lang Hames [Sat, 17 Dec 2016 00:04:24 +0000 (00:04 +0000)]
[ORC][RPC] Use more meaningful template parameter names.

llvm-svn: 290015

7 years agoAArch64: Enable post-ra liveness updates
Matthias Braun [Fri, 16 Dec 2016 23:55:43 +0000 (23:55 +0000)]
AArch64: Enable post-ra liveness updates

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

llvm-svn: 290014

7 years agoBranchRelaxation: Recompute live-ins when splitting a block
Matthias Braun [Fri, 16 Dec 2016 23:55:37 +0000 (23:55 +0000)]
BranchRelaxation: Recompute live-ins when splitting a block

Factors out and reuses live-in computation code from BranchFolding.

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

llvm-svn: 290013

7 years agoAllow "line 0" to be the first explicit debug location in a function.
Paul Robinson [Fri, 16 Dec 2016 23:54:33 +0000 (23:54 +0000)]
Allow "line 0" to be the first explicit debug location in a function.

Feedback on r289468 from Adrian Prantl.

llvm-svn: 290012

7 years agoGDB pretty printers: Basic DenseMap support
David Blaikie [Fri, 16 Dec 2016 23:53:14 +0000 (23:53 +0000)]
GDB pretty printers: Basic DenseMap support

Still prints the empty/tombstone keys (which some people would prefer,
but I find pretty noisy) because I haven't yet found a reliable way to
skip them (it requires calling into the running process to do so, which
isn't ideal for a pretty printer (doesn't work on a core file, for
example) - and gdb's ability to do so (or my ability to figure out how
to get gdb to do so) is limited) left some breadcrumbs for the next
person who might try to address that.

llvm-svn: 290011

7 years agoAdded clangLex to the dependencies for clang-import-test.
Sean Callanan [Fri, 16 Dec 2016 23:45:03 +0000 (23:45 +0000)]
Added clangLex to the dependencies for clang-import-test.

This is part of the effort to get the i686-mingw32-RA-on-linux bot to like clang-import-test.

llvm-svn: 290010

7 years agoFix MSVC build of libclang after r288438
Reid Kleckner [Fri, 16 Dec 2016 23:44:44 +0000 (23:44 +0000)]
Fix MSVC build of libclang after r288438

llvm-svn: 290009

7 years agoAdd explicit triple to test to fix arm bots.
Peter Collingbourne [Fri, 16 Dec 2016 23:43:51 +0000 (23:43 +0000)]
Add explicit triple to test to fix arm bots.

llvm-svn: 290008

7 years agoAdd isl_multi_pw_aff to GICHelper
Alexandre Isoard [Fri, 16 Dec 2016 23:41:26 +0000 (23:41 +0000)]
Add isl_multi_pw_aff to GICHelper

Add isl_multi_pw_aff* to GICHelper and add some missing isl_pw_multi_aff* handlers.

llvm-svn: 290007

7 years agoFixed library dependencies on clang-import-test to clean up the bots.
Sean Callanan [Fri, 16 Dec 2016 23:34:16 +0000 (23:34 +0000)]
Fixed library dependencies on clang-import-test to clean up the bots.

llvm-svn: 290006

7 years ago[analyzer] Extend UnixAPIChecker open() checks to handle openat().
Devin Coughlin [Fri, 16 Dec 2016 23:31:56 +0000 (23:31 +0000)]
[analyzer] Extend UnixAPIChecker open() checks to handle openat().

The openat() API has similar constraints to the open() API -- it just takes
an extra parameter.

rdar://problem/29526458

llvm-svn: 290005

7 years agoTestbed and skeleton of a new expression parser
Sean Callanan [Fri, 16 Dec 2016 23:21:38 +0000 (23:21 +0000)]
Testbed and skeleton of a new expression parser

LLVM's JIT is now the foundation of dynamic-compilation features for many languages. Clang also has low-level support for dynamic compilation (ASTImporter and ExternalASTSource, notably). How the compiler is set up for dynamic parsing is generally left up to individual clients, for example LLDB's C/C++/Objective-C expression parser and the ROOT project.

Although this arrangement offers external clients the flexibility to implement dynamic features as they see fit, the lack of an in-tree client means that subtle bugs can be introduced that cause regressions in the external clients but aren't caught by tests (or users) until much later. LLDB for example regularly encounters complicated ODR violation scenarios where it is not immediately clear who is at fault.

Other external clients (notably, Cling) rely on similar functionality, and another goal is to break this functionality up into composable parts so that any client can be built easily on top of Clang without requiring extensive additional code.

I propose that the parts required to build a simple expression parser be added to Clang.  Initially, I aim to have the following features:

- A piece that looks up external declarations from a variety of sources (e.g., from previous dynamic compilations, from modules, or from DWARF) and uses clear conflict resolution rules to reconcile differences, with easily understood errors. This functionality will be supported by in-tree tests.

- A piece that works hand in hand with the LLVM JIT to resolve the locations of external declarations so that e.g. variables can be redeclared and (for high-performance applications like DTrace) external variables can be accessed directly from the registers where they reside.

This commit adds a tester that parses a sequence of source files and then uses them as source data for an expression. External references are resolved using an ExternalASTSource that responds to name queries using an ASTImporter. This is the setup that LLDB uses, and the motivating reason for MinimalImport in ASTImporter.  When complete, this tester will implement the first of the above goals.

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

llvm-svn: 290004

7 years agoModuleSummaryAnalysis: Remove some duplicate code. NFCI.
Peter Collingbourne [Fri, 16 Dec 2016 23:19:02 +0000 (23:19 +0000)]
ModuleSummaryAnalysis: Remove some duplicate code. NFCI.

llvm-svn: 290003

7 years agoFix compiler warning.
Zachary Turner [Fri, 16 Dec 2016 23:12:58 +0000 (23:12 +0000)]
Fix compiler warning.

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

llvm-svn: 290002

7 years agoFix a bugs with using some Mach-O command line flags like "-arch armv7m".
Kevin Enderby [Fri, 16 Dec 2016 22:54:02 +0000 (22:54 +0000)]
Fix a bugs with using some Mach-O command line flags like "-arch armv7m".

The Mach-O command line flag like "-arch armv7m" does not match the
arch name part of its llvm Triple which is "thumbv7m-apple-darwin”.

I think the best way to fix this is to have
llvm::object::MachOObjectFile::getArchTriple() optionally return the
name of the Mach-O arch flag that would be used with -arch that
matches the CPUType and CPUSubType.  Then change
llvm::object::MachOUniversalBinary::ObjectForArch::getArchTypeName()
to use that and change it to getArchFlagName() as the type name is
really part of the Triple and the -arch flag name is a Mach-O thing
for a specific Triple with a specific Mcpu value.

rdar://29663637

llvm-svn: 290001

7 years agoResubmit "[CodeView] Hook CodeViewRecordIO for reading/writing symbols."
Zachary Turner [Fri, 16 Dec 2016 22:48:14 +0000 (22:48 +0000)]
Resubmit "[CodeView] Hook CodeViewRecordIO for reading/writing symbols."

The original patch was broken due to some undefined behavior
as well as warnings that were triggering -Werror.

llvm-svn: 290000

7 years ago[libFuzzer] avoid msan false positives in more cases
Kostya Serebryany [Fri, 16 Dec 2016 22:45:25 +0000 (22:45 +0000)]
[libFuzzer] avoid msan false positives in more cases

llvm-svn: 289999

7 years ago[libFuzzer] add an experimental flag -experimental_len_control=1 that sets max_len...
Kostya Serebryany [Fri, 16 Dec 2016 22:42:05 +0000 (22:42 +0000)]
[libFuzzer] add an experimental flag -experimental_len_control=1 that sets max_len to 1M and tries to increases the actual max sizes of mutations very gradually. Also remove a bit of dead code

llvm-svn: 289998

7 years agoReally revert all changes from r289979. Apparently conflict resolution failed
Reid Kleckner [Fri, 16 Dec 2016 22:11:28 +0000 (22:11 +0000)]
Really revert all changes from r289979. Apparently conflict resolution failed

llvm-svn: 289997

7 years agoIRGen: Fix assertion failure when creating debug info for an integer constant wider...
Peter Collingbourne [Fri, 16 Dec 2016 22:10:52 +0000 (22:10 +0000)]
IRGen: Fix assertion failure when creating debug info for an integer constant wider than 64 bits.

llvm-svn: 289996

7 years ago[libclang] Restore the CXXRecordDecl path for clang_Type_getNumTemplateArguments...
Argyrios Kyrtzidis [Fri, 16 Dec 2016 21:40:16 +0000 (21:40 +0000)]
[libclang] Restore the CXXRecordDecl path for clang_Type_getNumTemplateArguments and clang_Type_getTemplateArgumentAsType

Patch by Emilio Cobos Álvarez!
See https://reviews.llvm.org/D26907

llvm-svn: 289995

7 years agoFix compiler warning.
Zachary Turner [Fri, 16 Dec 2016 21:35:12 +0000 (21:35 +0000)]
Fix compiler warning.

llvm-svn: 289994

7 years ago[ThinLTO] Import composite types as declarations
Teresa Johnson [Fri, 16 Dec 2016 21:25:01 +0000 (21:25 +0000)]
[ThinLTO] Import composite types as declarations

Summary:
When reading the metadata bitcode, create a type declaration when
possible for composite types when we are importing. Doing this in
the bitcode reader saves memory. Also it works naturally in the case
when the type ODR map contains a definition for the same composite type
because it was used in the importing module (buildODRType will
automatically use the existing definition and not create a type
declaration).

For Chromium built with -g2, this reduces the aggregate size of the
generated native object files by 66% (from 31G to 10G). It reduced
the time through the ThinLTO link and backend phases by about 20% on
my machine.

Reviewers: mehdi_amini, dblaikie, aprantl

Subscribers: llvm-commits

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

llvm-svn: 289993

7 years agoPreserve loop metadata when folding branches to a common destination.
Michael Kuperstein [Fri, 16 Dec 2016 21:23:59 +0000 (21:23 +0000)]
Preserve loop metadata when folding branches to a common destination.

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

llvm-svn: 289992

7 years agoRevert r289979 due to regressions
Yaxun Liu [Fri, 16 Dec 2016 21:23:55 +0000 (21:23 +0000)]
Revert r289979 due to regressions

llvm-svn: 289991

7 years ago[Sema] Transform the default arguments of a lambda expression when the
Akira Hatanaka [Fri, 16 Dec 2016 21:16:57 +0000 (21:16 +0000)]
[Sema] Transform the default arguments of a lambda expression when the
lambda expression is instantiated.

Rather than waiting until Sema::CheckCXXDefaultArgExpr tries to
transform the default arguments (which fails because it can't get the
template arguments that are used), transform the default arguments
earlier when the lambda expression is transformed in
TransformLambdaExpr.

rdar://problem/27535319

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

llvm-svn: 289990

7 years ago[OpenMP] support the 'is_device_ptr' clause with 'target parallel' pragma
Kelvin Li [Fri, 16 Dec 2016 20:50:46 +0000 (20:50 +0000)]
[OpenMP] support the 'is_device_ptr' clause with 'target parallel' pragma

This patch is to add support of the 'is_device_ptr' clause in the 'target parallel' pragma.

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

llvm-svn: 289989

7 years ago[CodeGenPrep] Skip merging empty case blocks
Jun Bum Lim [Fri, 16 Dec 2016 20:38:39 +0000 (20:38 +0000)]
[CodeGenPrep] Skip merging empty case blocks

This is recommit of r287553 after fixing the invalid loop info after eliminating an empty block and unit test failures in AVR and WebAssembly :

Summary: Merging an empty case block into the header block of switch could cause ISel to add COPY instructions in the header of switch, instead of the case block, if the case block is used as an incoming block of a PHI. This could potentially increase dynamic instructions, especially when the switch is in a loop. I added a test case which was reduced from the benchmark I was targetting.

Reviewers: t.p.northover, mcrosier, manmanren, wmi, joerg, davidxl

Subscribers: joerg, qcolombet, danielcdh, hfinkel, mcrosier, llvm-commits

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

llvm-svn: 289988

7 years agoInline stripInvariantGroupMetadata out of existence
Sanjoy Das [Fri, 16 Dec 2016 20:29:39 +0000 (20:29 +0000)]
Inline stripInvariantGroupMetadata out of existence

As a one liner function, I don't think it is pulling its weight in terms
of helping readability.

llvm-svn: 289987

7 years agoRemove the temporary fix to the RUN line that was committed in r289924.
Akira Hatanaka [Fri, 16 Dec 2016 20:25:11 +0000 (20:25 +0000)]
Remove the temporary fix to the RUN line that was committed in r289924.

Also, dump the AST and run FileCheck to make sure the expected nodes are
created in the AST.

llvm-svn: 289986

7 years agoFix clang build
Zachary Turner [Fri, 16 Dec 2016 19:49:14 +0000 (19:49 +0000)]
Fix clang build

llvm-svn: 289985

7 years agoRevert "Update for LLVM global variable debug info API change."
Adrian Prantl [Fri, 16 Dec 2016 19:39:18 +0000 (19:39 +0000)]
Revert "Update for LLVM global variable debug info API change."

This reverts commit r289921.

llvm-svn: 289984

7 years agoRevert "Fix debug info metadata for upstream change in LLVM."
Adrian Prantl [Fri, 16 Dec 2016 19:39:18 +0000 (19:39 +0000)]
Revert "Fix debug info metadata for upstream change in LLVM."

llvm-svn: 289983

7 years agoRevert "[IR] Remove the DIExpression field from DIGlobalVariable."
Adrian Prantl [Fri, 16 Dec 2016 19:39:01 +0000 (19:39 +0000)]
Revert "[IR] Remove the DIExpression field from DIGlobalVariable."

This reverts commit 289920 (again).
I forgot to implement a Bitcode upgrade for the case where a DIGlobalVariable
has not DIExpression. Unfortunately it is not possible to safely upgrade
these variables without adding a flag to the bitcode record indicating which
version they are.
My plan of record is to roll the planned follow-up patch that adds a
unit: field to DIGlobalVariable into this patch before recomitting.
This way we only need one Bitcode upgrade for both changes (with a
version flag in the bitcode record to safely distinguish the record
formats).

Sorry for the churn!

llvm-svn: 289982

7 years agoRevert "[CodeView] Hook CodeViewRecordIO for reading/writing symbols."
Zachary Turner [Fri, 16 Dec 2016 19:25:23 +0000 (19:25 +0000)]
Revert "[CodeView] Hook CodeViewRecordIO for reading/writing symbols."

This reverts commit r289978, which is failing due to some rebase/merge
issues.

llvm-svn: 289981

7 years agoFix comment on the verifier (typo + doxygen) (NFC)
Mehdi Amini [Fri, 16 Dec 2016 19:24:13 +0000 (19:24 +0000)]
Fix comment on the verifier (typo + doxygen) (NFC)

llvm-svn: 289980

7 years ago[OpenCL] Allow disabling types and declarations associated with extensions
Yaxun Liu [Fri, 16 Dec 2016 19:22:08 +0000 (19:22 +0000)]
[OpenCL] Allow disabling types and declarations associated with extensions

Added a map to associate types and declarations with extensions.

Refactored existing diagnostic for disabled types associated with extensions and extended it to declarations for generic situation.

Fixed some bugs for types associated with extensions.

Allow users to use pragma to declare types and functions for supported extensions, e.g.

#pragma OPENCL EXTENSION the_new_extension_name : begin
// declare types and functions associated with the extension here
#pragma OPENCL EXTENSION the_new_extension_name : end

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

llvm-svn: 289979

7 years ago[CodeView] Hook CodeViewRecordIO for reading/writing symbols.
Zachary Turner [Fri, 16 Dec 2016 19:20:35 +0000 (19:20 +0000)]
[CodeView] Hook CodeViewRecordIO for reading/writing symbols.

This is the 3rd of 3 patches to get reading and writing of
CodeView symbol and type records to use a single codepath.

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

llvm-svn: 289978

7 years agoStrip invalid TBAA when reading bitcode
Mehdi Amini [Fri, 16 Dec 2016 19:16:29 +0000 (19:16 +0000)]
Strip invalid TBAA when reading bitcode

This ensures backward compatibility on bitcode loading.

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

llvm-svn: 289977

7 years agoGDB pretty printer for llvm::Optional
David Blaikie [Fri, 16 Dec 2016 19:16:22 +0000 (19:16 +0000)]
GDB pretty printer for llvm::Optional

(some other implementations of an optional pretty printer print the full
name of the optional type (including template parameter) - but seems if
the template parameter isn't printed for std::vector, not sure why it
would be printed for optional, so erring on the side of consistency in
that direction here - compact, etc, as well)

llvm-svn: 289976

7 years agoReapply "[LV] Enable vectorization of loops with conditional stores by default"
Matthew Simpson [Fri, 16 Dec 2016 19:12:02 +0000 (19:12 +0000)]
Reapply "[LV] Enable vectorization of loops with conditional stores by default"

This patch reapplies r289863. The original patch was reverted because it
exposed a bug causing the loop vectorizer to crash in the Python runtime on
PPC. The underlying issue was fixed with r289958.

llvm-svn: 289975

7 years agoImplement LaneBitmask::any(), use it to replace !none(), NFCI
Krzysztof Parzyszek [Fri, 16 Dec 2016 19:11:56 +0000 (19:11 +0000)]
Implement LaneBitmask::any(), use it to replace !none(), NFCI

llvm-svn: 289974

7 years agoFix CodeGenPrepare::stripInvariantGroupMetadata
Sanjoy Das [Fri, 16 Dec 2016 18:52:33 +0000 (18:52 +0000)]
Fix CodeGenPrepare::stripInvariantGroupMetadata

`dropUnknownNonDebugMetadata` takes a list of "known" metadata IDs.  The
only reason it worked at all is that `getMetadataID` returns something
unrelated -- it returns the subclass ID of the receiver (which is used
in `dyn_cast` etc.).  That does not numerically match
`LLVMContext::MD_invariant_group` and ends up dropping `invariant_group`
along with every other metadata that does not numerically match
`LLVMContext::MD_invariant_group`.

llvm-svn: 289973

7 years ago[ARM] Add ARMISD::VLD1DUP to match vld1_dup more consistently.
Eli Friedman [Fri, 16 Dec 2016 18:44:08 +0000 (18:44 +0000)]
[ARM] Add ARMISD::VLD1DUP to match vld1_dup more consistently.

Currently, there are substantial problems forming vld1_dup even if the
VDUP survives legalization. The lack of an actual node
leads to terrible results: not only can we not form post-increment vld1_dup
instructions, but we form scalar pre-increment and post-increment
loads which force the loaded value into a GPR. This patch fixes that
by combining the vdup+load into an ARMISD node before DAGCombine
messes it up.

Also includes a crash fix for vld2_dup (see testcase @vld2dupi8_postinc_variable).

Recommiting with fix to avoid forming vld1dup if the type of the load
doesn't match the type of the vdup (see
https://llvm.org/bugs/show_bug.cgi?id=31404).

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

llvm-svn: 289972

7 years agoFollow-up for r289831: Lower the unjoined thread count to 100 in the libcxx-future...
Kuba Mracek [Fri, 16 Dec 2016 18:44:01 +0000 (18:44 +0000)]
Follow-up for r289831: Lower the unjoined thread count to 100 in the libcxx-future.mm testcase.

Turns out 1000 unjoined threads are a bit too rough in certain environments.

llvm-svn: 289971

7 years ago[analyzer] Fix crash in MallocChecker.
Devin Coughlin [Fri, 16 Dec 2016 18:41:40 +0000 (18:41 +0000)]
[analyzer] Fix crash in MallocChecker.

Fix a crash in the MallocChecker when the extent size for the argument
to new[] is not known.

A patch by Abramo Bagnara and Dániel Krupp!

https://reviews.llvm.org/D27849

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

llvm-svn: 289970

7 years agoFix name typo in SelectonDAG
Joel Jones [Fri, 16 Dec 2016 18:22:54 +0000 (18:22 +0000)]
Fix name typo in SelectonDAG

llvm-svn: 289969

7 years ago[ELF] - Linkerscript: Implement two argument version of ALIGN()
Rui Ueyama [Fri, 16 Dec 2016 18:19:35 +0000 (18:19 +0000)]
[ELF] - Linkerscript: Implement two argument version of ALIGN()

Fixes http://llvm.org/PR31129

Patch by Alexander Richardson!

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

llvm-svn: 289968

7 years agoAMDGPU: Fix name for v_ashrrev_i16
Matt Arsenault [Fri, 16 Dec 2016 17:40:11 +0000 (17:40 +0000)]
AMDGPU: Fix name for v_ashrrev_i16

llvm-svn: 289967

7 years ago[libFuzzer] Fix index error in SearchMemory() implementation for Windows.
Marcos Pividori [Fri, 16 Dec 2016 17:35:25 +0000 (17:35 +0000)]
[libFuzzer] Fix index error in SearchMemory() implementation for Windows.

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

llvm-svn: 289966

7 years ago[libFuzzer] Remove unnecessary includes of posix headers.
Marcos Pividori [Fri, 16 Dec 2016 17:35:21 +0000 (17:35 +0000)]
[libFuzzer] Remove unnecessary includes of posix headers.

Remove includes of "unistd.h" header, which is missing in non posix
systems.

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

llvm-svn: 289965

7 years ago[libFuzzer] Update tests to use more general functions instead of posix specific.
Marcos Pividori [Fri, 16 Dec 2016 17:35:13 +0000 (17:35 +0000)]
[libFuzzer] Update tests to use more general functions instead of posix specific.

Replace sleep() posix function by a more portable sleep_for() function
from std. Also, ignore memmem() and strcasestr() on Windows.

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

llvm-svn: 289964

7 years ago[CMake] Put headers relative to clang
Chris Bieneman [Fri, 16 Dec 2016 17:30:51 +0000 (17:30 +0000)]
[CMake] Put headers relative to clang

When libcxx isn't building with an installed LLVM we copy the libcxx headers into the LLVM build directory so that a clang in that build tree can find the headers relative to itself.

This is only important in situations where you don't have headers installed under /, which is common these days on Darwin.

llvm-svn: 289963

7 years agoFix -Wself-assign from r289955
Hans Wennborg [Fri, 16 Dec 2016 17:16:46 +0000 (17:16 +0000)]
Fix -Wself-assign from r289955

llvm-svn: 289962

7 years agoRevert "dwarfdump: Support/process relocations on a CU's abbrev_off"
David Blaikie [Fri, 16 Dec 2016 17:10:17 +0000 (17:10 +0000)]
Revert "dwarfdump: Support/process relocations on a CU's abbrev_off"

Reverting because this breaks lld's gdb_index support - it's probably
double counting the abbrev relocation offset.

This reverts commit r289954.

llvm-svn: 289961

7 years agoRevert "[CodeGenPrep] Skip merging empty case blocks"
Jun Bum Lim [Fri, 16 Dec 2016 17:06:14 +0000 (17:06 +0000)]
Revert "[CodeGenPrep] Skip merging empty case blocks"

This reverts commit r289951.

llvm-svn: 289960

7 years ago[InstCombine] auto-generate checks; NFC
Sanjay Patel [Fri, 16 Dec 2016 16:58:54 +0000 (16:58 +0000)]
[InstCombine] auto-generate checks; NFC

llvm-svn: 289959

7 years ago[LV] Don't attempt to type-shrink scalarized instructions
Matthew Simpson [Fri, 16 Dec 2016 16:52:35 +0000 (16:52 +0000)]
[LV] Don't attempt to type-shrink scalarized instructions

After r288909, instructions feeding predicated instructions may be scalarized
if profitable. Since these instructions will remain scalar, we shouldn't
attempt to type-shrink them. We should only truncate vector types to their
minimal bit widths. This bug was exposed by enabling the vectorization of loops
containing conditional stores by default.

llvm-svn: 289958

7 years agoPass sample pgo flags to thinlto.
Dehao Chen [Fri, 16 Dec 2016 16:48:46 +0000 (16:48 +0000)]
Pass sample pgo flags to thinlto.

Summary: ThinLTO needs to invoke SampleProfileLoader pass during link time in order to annotate profile correctly after module importing.

Reviewers: davidxl, mehdi_amini, tejohnson

Subscribers: pcc, davide, llvm-commits, mehdi_amini

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

llvm-svn: 289957

7 years agoFix broken escaping of commands in the build
Luke Drummond [Fri, 16 Dec 2016 16:38:25 +0000 (16:38 +0000)]
Fix broken escaping of commands in the build

A combination of broken escaping in CMake and in the python swig
generation scripts meant that the swig generation step would fail
whenever there were spaces or special characters in parameters passed to
swig.

The fix for this in CMakeLists is to use the VERBATIM option on all
COMMAND-based custom builders relying on CMake to properly escape each
argument in the generated file.

Within the python swig scripts, the fix is to call subprocess.Popen with
a list of raw argument strings rather than ones that are incorrectly
manually escaped, then passed to a shell subprocess via
subprocess.Popen(' '.join(params)). This also prevents nasty things
happening such as accidental command-injection.

This allows us to have the swig / python executables in paths containing
special chars and spaces, (or on shared storage on Win32, e.g
\\some\path or C:\Program Files\swig\swig.exe).

Subscribers: lldb-commits
Differential Revision: https://reviews.llvm.org/D26757

llvm-svn: 289956

7 years ago[X86] Fold (setcc (cmp (atomic_load_add x, -C) C), COND) to (setcc (LADD x, -C),...
Hans Wennborg [Fri, 16 Dec 2016 16:34:59 +0000 (16:34 +0000)]
[X86] Fold (setcc (cmp (atomic_load_add x, -C) C), COND) to (setcc (LADD x, -C), COND) (PR31367)

atomic_load_add returns the value before addition, but sets EFLAGS based on the
result of the addition. That means it's setting the flags based on effectively
subtracting C from the value at x, which is also what the outer cmp does.

This targets a pattern that occurs frequently with reference counting pointers:

  void decrement(long volatile *ptr) {
    if (_InterlockedDecrement(ptr) == 0)
      release();
  }

Clang would previously compile it (for 32-bit at -Os) as:

00000000 <?decrement@@YAXPCJ@Z>:
   0:   8b 44 24 04             mov    0x4(%esp),%eax
   4:   31 c9                   xor    %ecx,%ecx
   6:   49                      dec    %ecx
   7:   f0 0f c1 08             lock xadd %ecx,(%eax)
   b:   83 f9 01                cmp    $0x1,%ecx
   e:   0f 84 00 00 00 00       je     14 <?decrement@@YAXPCJ@Z+0x14>
  14:   c3                      ret

and with this patch it becomes:

00000000 <?decrement@@YAXPCJ@Z>:
   0:   8b 44 24 04             mov    0x4(%esp),%eax
   4:   f0 ff 08                lock decl (%eax)
   7:   0f 84 00 00 00 00       je     d <?decrement@@YAXPCJ@Z+0xd>
   d:   c3                      ret

(Equivalent variants with _InterlockedExchangeAdd, std::atomic<>'s fetch_add
or pre-decrement operator generate the same code.)

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

llvm-svn: 289955

7 years agodwarfdump: Support/process relocations on a CU's abbrev_off
David Blaikie [Fri, 16 Dec 2016 16:31:10 +0000 (16:31 +0000)]
dwarfdump: Support/process relocations on a CU's abbrev_off

Input can be produced by ld -r, for example (a normal LLVM workflow
never hits this - LLVM only ever produces a single abbrev table in an
object (shared by multiple CUs), so the reloc's always 0, and when it's
linked together the relocation's resolved so it doesn't need to be
handled)

llvm-svn: 289954

7 years agoFix debug info metadata for upstream change in LLVM.
Adrian Prantl [Fri, 16 Dec 2016 16:17:24 +0000 (16:17 +0000)]
Fix debug info metadata for upstream change in LLVM.

llvm-svn: 289953

7 years ago[include-fixer] Desugar incomplete types.
Benjamin Kramer [Fri, 16 Dec 2016 16:09:06 +0000 (16:09 +0000)]
[include-fixer] Desugar incomplete types.

This will look through typedefs so include-fixer will look up the target
of the typedef instead of the typedef itself (which is already in
scope).

llvm-svn: 289952

7 years ago[CodeGenPrep] Skip merging empty case blocks
Jun Bum Lim [Fri, 16 Dec 2016 16:03:31 +0000 (16:03 +0000)]
[CodeGenPrep] Skip merging empty case blocks

This is recommit of r287553 after fixing the invalid loop info after eliminating an empty block:

Summary: Merging an empty case block into the header block of switch could cause ISel to add COPY instructions in the header of switch, instead of the case block, if the case block is used as an incoming block of a PHI. This could potentially increase dynamic instructions, especially when the switch is in a loop. I added a test case which was reduced from the benchmark I was targetting.

Reviewers: t.p.northover, mcrosier, manmanren, wmi, joerg, davidxl

Subscribers: joerg, qcolombet, danielcdh, hfinkel, mcrosier, llvm-commits

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

llvm-svn: 289951

7 years ago[X86][AVX] Call lowerVectorShuffleWithSHUFPS directly instead of calling DAG.getVecto...
Simon Pilgrim [Fri, 16 Dec 2016 15:23:32 +0000 (15:23 +0000)]
[X86][AVX] Call lowerVectorShuffleWithSHUFPS directly instead of calling DAG.getVectorShuffle (PR27885)

We've already done the hardwork of ensuring the mask is safe for 'SHUFPS'.

llvm-svn: 289950

7 years agoRemove an unused type declaration.
Hafiz Abid Qadeer [Fri, 16 Dec 2016 14:44:34 +0000 (14:44 +0000)]
Remove an unused type declaration.

llvm-svn: 289947

7 years ago[X86][AVX512] use a single shufps for 512-bit vectors when it can save instructions
Simon Pilgrim [Fri, 16 Dec 2016 14:30:04 +0000 (14:30 +0000)]
[X86][AVX512] use a single shufps for 512-bit vectors when it can save instructions

This is the 512-bit counterpart to the 128-bit transform checked in here:
https://reviews.llvm.org/rL289837

This patch is based on the draft by @sroland (Roland Scheidegger) that is attached to PR27885:
https://llvm.org/bugs/show_bug.cgi?id=27885

llvm-svn: 289946

7 years ago[X86][AVX512] Add tests showing missed opportunity to efficiently lower v16i32 to...
Simon Pilgrim [Fri, 16 Dec 2016 14:21:57 +0000 (14:21 +0000)]
[X86][AVX512] Add tests showing missed opportunity to efficiently lower v16i32 to VSHUFPS (PR27885)

llvm-svn: 289945

7 years agoSpeculatively revert r289925, see PR31407
Nico Weber [Fri, 16 Dec 2016 14:02:28 +0000 (14:02 +0000)]
Speculatively revert r289925, see PR31407

llvm-svn: 289944

7 years ago[MIRParser] Add parsing hex literals of arbitrary size as unsigned integers
Krzysztof Parzyszek [Fri, 16 Dec 2016 13:58:01 +0000 (13:58 +0000)]
[MIRParser] Add parsing hex literals of arbitrary size as unsigned integers

The current code does not parse hex literals larger than 32-bit.

llvm-svn: 289943

7 years agoMove VerifierSupport into namespace llvm.
Daniel Jasper [Fri, 16 Dec 2016 13:53:46 +0000 (13:53 +0000)]
Move VerifierSupport into namespace llvm.

It currently is in an unnamed namespace and then it shouldn't be used
from something in the header file. This actually triggers a warning with
GCC:
../include/llvm/IR/Verifier.h:39:7: warning: ‘llvm::TBAAVerifier’ has a field ‘llvm::TBAAVerifier::Diagnostic’ whose type uses the anonymous namespace [enabled by default]

llvm-svn: 289942

7 years ago[GlobalISel] Silence unused variable warnings in Release builds.
Benjamin Kramer [Fri, 16 Dec 2016 13:13:03 +0000 (13:13 +0000)]
[GlobalISel] Silence unused variable warnings in Release builds.

llvm-svn: 289941

7 years ago[ARM] GlobalISel: Select add i32, i32
Diana Picus [Fri, 16 Dec 2016 12:54:46 +0000 (12:54 +0000)]
[ARM] GlobalISel: Select add i32, i32

Add the minimal support necessary to select a function that returns the sum of
two i32 values.

This includes some support for argument/return lowering of i32 values through
registers, as well as the handling of copy and add instructions throughout the
GlobalISel pipeline.

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

llvm-svn: 289940

7 years ago[analyzer] Add another exception for Qt in MallocChecker
Artem Dergachev [Fri, 16 Dec 2016 12:21:55 +0000 (12:21 +0000)]
[analyzer] Add another exception for Qt in MallocChecker

Treat pointers passed to QObject::connectImpl() as escaping.

rdar://problem/29550440

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

llvm-svn: 289939

7 years ago[ELF] - Accept --sort-section=xxx command form.
George Rimar [Fri, 16 Dec 2016 11:59:52 +0000 (11:59 +0000)]
[ELF] - Accept --sort-section=xxx command form.

--sort-section=xxx is the same as --sort-section xxx,
was found in one of FreeBSD ports.

llvm-svn: 289938

7 years ago[X86][SSE] Combine shuffles to MOVSS/MOVSD whatever the domain.
Simon Pilgrim [Fri, 16 Dec 2016 11:48:51 +0000 (11:48 +0000)]
[X86][SSE] Combine shuffles to MOVSS/MOVSD whatever the domain.

We already do the same thing in shuffle lowering; but don't do it if we have SSE41 (PBLEND) instead.

llvm-svn: 289937

7 years ago[AVR] Add a test for 64-bit left shifts
Dylan McKay [Fri, 16 Dec 2016 11:40:00 +0000 (11:40 +0000)]
[AVR] Add a test for 64-bit left shifts

llvm-svn: 289936

7 years agoRevert r289863: [LV] Enable vectorization of loops with conditional
Chandler Carruth [Fri, 16 Dec 2016 11:31:39 +0000 (11:31 +0000)]
Revert r289863: [LV] Enable vectorization of loops with conditional
stores by default

This uncovers a crasher in the loop vectorizer on PPC when building the
Python runtime. I'll send the testcase to the review thread for the
original commit.

llvm-svn: 289934

7 years ago [codegen] Add generic functions to skip debug values.
Florian Hahn [Fri, 16 Dec 2016 11:10:26 +0000 (11:10 +0000)]
 [codegen] Add generic functions to skip debug values.

Summary:
This commits moves skipDebugInstructionsForward and
skipDebugInstructionsBackward from lib/CodeGen/IfConversion.cpp
to include/llvm/CodeGen/MachineBasicBlock.h and updates
some codgen files to use them.

This refactoring was suggested in https://reviews.llvm.org/D27688
and I thought it's best to do the refactoring in a separate
review, but I could also put both changes in a single review
if that's preferred.

Also, the names for the functions aren't the snappiest and
I would be happy to rename them if anybody has suggestions.

Reviewers: eli.friedman, iteratee, aprantl, MatzeB

Subscribers: MatzeB, llvm-commits

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

llvm-svn: 289933

7 years ago[ARM] Expose methods to get the CCAssignFn. NFCI
Diana Picus [Fri, 16 Dec 2016 10:35:20 +0000 (10:35 +0000)]
[ARM] Expose methods to get the CCAssignFn. NFCI

Add two public methods to ARMTargetLowering: CCAssignFnForCall and
CCAssignFnForReturn, which are just calling the already existing private method
CCAssignFnForNode. These will come in handy for GlobalISel on ARM.

We also replace all calls to CCAssignFnForNode in ARMISelLowering.cpp, because
the new methods are friendlier to the reader.

llvm-svn: 289932

7 years agoExtra coverage tests to demonstrate fixes in D72618 and D26855
Andrew V. Tischenko [Fri, 16 Dec 2016 09:56:02 +0000 (09:56 +0000)]
Extra coverage tests to demonstrate fixes in D72618 and D26855

llvm-svn: 289931

7 years ago[clang-tidy] fix missing anchor for MPI Module
Piotr Padlewski [Fri, 16 Dec 2016 09:14:47 +0000 (09:14 +0000)]
[clang-tidy] fix missing anchor for MPI Module

Summary: MPIModule was not linked to plugins

Reviewers: alexfh, Alexander_Droste, hokein

Subscribers: JDevlieghere, cfe-commits

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

llvm-svn: 289930

7 years agoRevert r289638: [PowerPC] Fix logic dealing with nop after calls (and tail-call eligi...
Chandler Carruth [Fri, 16 Dec 2016 07:31:20 +0000 (07:31 +0000)]
Revert r289638: [PowerPC] Fix logic dealing with nop after calls (and tail-call eligibility)

This patch appears to result in trampolines in vtables being miscompiled
when they in turn tail call a method.

I've posted some preliminary details about the failure on the thread for
this commit and talked to Hal. He was comfortable going ahead and
reverting until we sort out what is wrong.

llvm-svn: 289928

7 years agoExtract a TBAAVerifier out of the verifier (NFC)
Mehdi Amini [Fri, 16 Dec 2016 06:29:14 +0000 (06:29 +0000)]
Extract a TBAAVerifier out of the verifier (NFC)

This is intended to be used (in a later patch) by the BitcodeReader
to detect invalid TBAA and drop them when loading bitcode, so that
we don't break client that have legacy bitcode with possible invalid
TBAA.

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

llvm-svn: 289927