platform/upstream/llvm.git
6 years agoRe-commit: Make STATISTIC() values available programmatically
Daniel Sanders [Mon, 5 Mar 2018 19:38:16 +0000 (19:38 +0000)]
Re-commit: Make STATISTIC() values available programmatically

Summary:
It can be useful for tools to be able to retrieve the values of variables
declared via STATISTIC() directly without having to emit them and parse
them back. Use cases include:
* Needing to report specific statistics to a test harness
* Wanting to post-process statistics. For example, to produce a percentage of
  functions that were fully selected by GlobalISel

Make this possible by adding llvm::GetStatistics() which returns an
iterator_range that can be used to inspect the statistics that have been
touched during execution. When statistics are disabled (NDEBUG and not
LLVM_ENABLE_STATISTICS) this method will return an empty range.

This patch doesn't address the effect of multiple compilations within the same
process. In such situations, the statistics will be cumulative for all
compilations up to the GetStatistics() call.

Reviewers: qcolombet, rtereshin, aditya_nandakumar, bogner

Reviewed By: rtereshin, bogner

Subscribers: llvm-commits, mgorny

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

This re-commit fixes a missing include of <vector> which it seems clang didn't
mind but G++ and MSVC objected to. It seems that, clang was ok with std::vector
only being forward declared at the point of use since it was fully defined
eventually but G++/MSVC both rejected it at the point of use.

llvm-svn: 326738

6 years agoOn Windows we need to be able to process response files with Windows-style
Dmitry Mikulin [Mon, 5 Mar 2018 19:34:33 +0000 (19:34 +0000)]
On Windows we need to be able to process response files with Windows-style
path names.

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

llvm-svn: 326737

6 years ago[PowerPC] Do not emit record-form rotates when record-form andi suffices
Nemanja Ivanovic [Mon, 5 Mar 2018 19:27:16 +0000 (19:27 +0000)]
[PowerPC] Do not emit record-form rotates when record-form andi suffices

Up until Power9, the performance profile for rlwinm., rldicl. and andi. looked
more or less equivalent. However with Power9, the rotates are still 2-way
cracked whereas the and-immediate is not.

This patch just ensures that we don't emit record-form rotates when an andi.
is adequate.

As first pointed out by Carrot in https://bugs.llvm.org/show_bug.cgi?id=30833
(this patch is a fix for that PR).

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

llvm-svn: 326736

6 years ago[x86] auto-generate full checks for fabs tests
Sanjay Patel [Mon, 5 Mar 2018 19:11:20 +0000 (19:11 +0000)]
[x86] auto-generate full checks for fabs tests

Also, change the x86-64 test to optimized and remove the
unnecessary platform specification from the RUN lines..

llvm-svn: 326735

6 years agoOn Windows expansion of regex file name patterns is the responsibility of each
Dmitry Mikulin [Mon, 5 Mar 2018 18:54:56 +0000 (18:54 +0000)]
On Windows expansion of regex file name patterns is the responsibility of each
tool. Fix ar to do that.

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

llvm-svn: 326734

6 years agoImprove OpenMP threadprivate implementation.
Andrey Churbanov [Mon, 5 Mar 2018 18:42:01 +0000 (18:42 +0000)]
Improve OpenMP threadprivate implementation.

Patch by Terry Wilmarth

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

llvm-svn: 326733

6 years agoFix an unused variable warning introduced by rr326703. NFC
Eric Liu [Mon, 5 Mar 2018 18:36:39 +0000 (18:36 +0000)]
Fix an unused variable warning introduced by rr326703. NFC

llvm-svn: 326732

6 years ago[llvm-pdbdump] Dump restrict type qualifier
Aaron Smith [Mon, 5 Mar 2018 18:29:43 +0000 (18:29 +0000)]
[llvm-pdbdump] Dump restrict type qualifier

Reviewers: zturner, llvm-commits, rnk

Reviewed By: zturner

Subscribers: majnemer

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

llvm-svn: 326731

6 years ago[InstCombine] Don't blow up in foldICmpWithCastAndCast on vector icmp instructions.
Daniel Neilson [Mon, 5 Mar 2018 18:05:51 +0000 (18:05 +0000)]
[InstCombine] Don't blow up in foldICmpWithCastAndCast on vector icmp instructions.

Summary:
Presently, InstCombiner::foldICmpWithCastAndCast() implicitly assumes that it is
only invoked with icmp instructions of integer type. If that assumption is broken,
and it is called with an icmp of vector type, then it fails (asserts/crashes).

This patch addresses the deficiency. It allows it to simplify
icmp (ptrtoint x), (ptrtoint/c) of vector type into a compare of the inputs,
much as is done when the type is integer.

Reviewers: apilipenko, fedor.sergeev, mkazantsev, anna

Reviewed By: anna

Subscribers: llvm-commits

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

llvm-svn: 326730

6 years ago[InstCombine] Add constant vector support to getMinimumFPType for visitFPTrunc.
Craig Topper [Mon, 5 Mar 2018 18:04:12 +0000 (18:04 +0000)]
[InstCombine] Add constant vector support to getMinimumFPType for visitFPTrunc.

This patch teaches getMinimumFPType to support shrinking a vector of ConstantFPs. This should improve our ability to combine vector fptrunc with fp binops.

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

llvm-svn: 326729

6 years agoFixed build of the OpenMP stubs library.
Andrey Churbanov [Mon, 5 Mar 2018 18:01:47 +0000 (18:01 +0000)]
Fixed build of the OpenMP stubs library.

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

llvm-svn: 326728

6 years agoIncluding <functional> for std::bind
Raphael Isemann [Mon, 5 Mar 2018 17:54:23 +0000 (17:54 +0000)]
Including <functional> for std::bind

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

llvm-svn: 326727

6 years agoRevert r326723: Make STATISTIC() values available programmatically
Daniel Sanders [Mon, 5 Mar 2018 17:52:43 +0000 (17:52 +0000)]
Revert r326723: Make STATISTIC() values available programmatically

Despite building cleanly on my machine in three separate configs, it's failing on pretty much all bots due to missing includes among other things. Investigating.

llvm-svn: 326726

6 years ago[AMDGPU] Clean up old address space mapping and fix constant address space value
Yaxun Liu [Mon, 5 Mar 2018 17:50:10 +0000 (17:50 +0000)]
[AMDGPU] Clean up old address space mapping and fix constant address space value

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

llvm-svn: 326725

6 years ago[AArch64] Harden test case
Evandro Menezes [Mon, 5 Mar 2018 17:42:18 +0000 (17:42 +0000)]
[AArch64] Harden test case

NFC

llvm-svn: 326724

6 years agoMake STATISTIC() values available programmatically
Daniel Sanders [Mon, 5 Mar 2018 17:41:45 +0000 (17:41 +0000)]
Make STATISTIC() values available programmatically

Summary:
It can be useful for tools to be able to retrieve the values of variables
declared via STATISTIC() directly without having to emit them and parse
them back. Use cases include:
* Needing to report specific statistics to a test harness
* Wanting to post-process statistics. For example, to produce a percentage of
  functions that were fully selected by GlobalISel

Make this possible by adding llvm::GetStatistics() which returns an
iterator_range that can be used to inspect the statistics that have been
touched during execution. When statistics are disabled (NDEBUG and not
LLVM_ENABLE_STATISTICS) this method will return an empty range.

This patch doesn't address the effect of multiple compilations within the same
process. In such situations, the statistics will be cumulative for all
compilations up to the GetStatistics() call.

Reviewers: qcolombet, rtereshin, aditya_nandakumar, bogner

Reviewed By: rtereshin, bogner

Subscribers: llvm-commits, mgorny

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

llvm-svn: 326723

6 years agofix PR36582
Sebastian Pop [Mon, 5 Mar 2018 17:35:49 +0000 (17:35 +0000)]
fix PR36582

The error occurs when reading i16 elements (as in the testcase) from a v8i8
with a pattern of <0,2,4,6>. As all the data in the vector is accessed, the
operation is not a VUZP. The patch stops the pattern recognition of VUZP when
EXTRACT_VECTOR_ELT has a different element type than BUILD_VECTOR.

llvm-svn: 326722

6 years ago[clangd] Fix unintentionally loose fuzzy matching, and the tests masking it.
Sam McCall [Mon, 5 Mar 2018 17:34:33 +0000 (17:34 +0000)]
[clangd] Fix unintentionally loose fuzzy matching, and the tests masking it.

Summary:
The intent was that [ar] doesn't match "FooBar"; the first character must match
a Head character (hard requirement, not just a low score).
This matches VSCode, and was "tested" but the tests were defective.

The tests expected matches("FooBar") to fail for lack of a match. But instead
it fails because the string should be annotated - matches("FooB[ar]").
This patch makes matches("FooBar") ignore annotations, as was intended.

Fixing the code to reject weak matches for the first char causes problems:
-  [bre] no longer matches "HTMLBRElement".
   We allow matching against an uppercase char even if we don't think it's head.
   Only do this if there's at least one lowercase, to avoid triggering on MACROS
-  [print] no longer matches "sprintf".
   This is hard to fix without false positives (e.g. [int] vs "sprintf"])
   This patch leaves this case broken. A future patch will add a dictionary
   providing custom segmentation to common names from the standard library.

Fixed a couple of index tests that indirectly relied on broken fuzzy matching.
Added const in a couple of missing places for consistency with new code.

Subscribers: klimek, ilya-biryukov, jkorous-apple, ioeric, cfe-commits

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

llvm-svn: 326721

6 years ago[IPSCCP] Add getCompare which returns either true, false, undef or null.
Florian Hahn [Mon, 5 Mar 2018 17:33:50 +0000 (17:33 +0000)]
[IPSCCP] Add getCompare which returns either true, false, undef or null.

getCompare returns true, false or undef constants if the comparison can
be evaluated, or nullptr if it cannot. This is in line with what
ConstantExpr::getCompare returns. It also allows us to use
ConstantExpr::getCompare for comparing constants.

Reviewers: davide, mssimpso, dberlin, anna

Reviewed By: davide

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

llvm-svn: 326720

6 years ago[clangd] Extract ClangdServer::Options struct.
Sam McCall [Mon, 5 Mar 2018 17:28:54 +0000 (17:28 +0000)]
[clangd] Extract ClangdServer::Options struct.

Summary:
This subsumes most of the params to ClangdServer and ClangdLSPServer.
Adjacent changes:
 - tests use a consistent set of options, except when testing specific options
 - tests that previously used synchronous mode for convenience no longer do
 - added a runAddDocument helper to SyncAPIs to mitigate the extra code
 - rearranged main a bit to follow the structure of the options

Reviewers: ilya-biryukov

Subscribers: klimek, jkorous-apple, ioeric, cfe-commits

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

llvm-svn: 326719

6 years ago[AArch64] Improve code generation of constant vectors
Evandro Menezes [Mon, 5 Mar 2018 17:02:47 +0000 (17:02 +0000)]
[AArch64] Improve code generation of constant vectors

Use the whole gammut of constant immediates available to set up a vector.
Instead of using, for example, `mov w0, #0xffff; dup v0.4s, w0`, which
transfers between register files, use the more efficient `movi v0.4s, #-1`
instead.  Not limited to just a few values, but any immediate value that can
be encoded by all the variants of `FMOV`, `MOVI`, `MVNI`, thus eliminating
the need to there be patterns to optimize special cases.

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

llvm-svn: 326718

6 years ago[demangler] Modernize parse_name.
Erik Pilkington [Mon, 5 Mar 2018 16:35:06 +0000 (16:35 +0000)]
[demangler] Modernize parse_name.

llvm-svn: 326717

6 years ago[MachineScheduler] Dump SUnits before calling SchedImpl->initialize()
Jonas Paulsson [Mon, 5 Mar 2018 16:31:49 +0000 (16:31 +0000)]
[MachineScheduler] Dump SUnits before calling SchedImpl->initialize()

This is a NFC simple patch that changes the DEBUG dumping in the
MachineScheduler so that the dumping of the built SUnits is done before the
SchedImpl->initialize() is called.

This is better on SystemZ, since it has a strategy that does some dumping at
the start of the region, and it is not possible to easily read it if it is
output above a long list of SU.

Review: Javed Absar
https://reviews.llvm.org/D44089

llvm-svn: 326716

6 years agoAMDGPU/GlobalISel: Add InstrMapping for G_EXTRACT
Matt Arsenault [Mon, 5 Mar 2018 16:25:18 +0000 (16:25 +0000)]
AMDGPU/GlobalISel: Add InstrMapping for G_EXTRACT

llvm-svn: 326715

6 years agoAMDGPU/GlobalISel: Make some G_EXTRACTs legal
Matt Arsenault [Mon, 5 Mar 2018 16:25:15 +0000 (16:25 +0000)]
AMDGPU/GlobalISel: Make some G_EXTRACTs legal

As far as I can tell legalization of weird sizes for the
output type isn't implemented.

llvm-svn: 326714

6 years agoAMDGPU: Fix build warning about override
Matt Arsenault [Mon, 5 Mar 2018 16:25:10 +0000 (16:25 +0000)]
AMDGPU: Fix build warning about override

llvm-svn: 326713

6 years ago[CVP] fix formatting; NFC
Sanjay Patel [Mon, 5 Mar 2018 16:08:34 +0000 (16:08 +0000)]
[CVP] fix formatting; NFC

llvm-svn: 326711

6 years agoFuzzer: remove temporary files after we're done with them.
Tim Northover [Mon, 5 Mar 2018 15:49:00 +0000 (15:49 +0000)]
Fuzzer: remove temporary files after we're done with them.

These were just copies of the relevant fuzzer binary with (presumably)
meaningful suffixes, but accounted for more than 10% of my build
directory (> 8GB). Hard drive space is cheap, but not that cheap.

llvm-svn: 326710

6 years ago[analyzer] Improves the logic of GenericTaintChecker identifying stdin.
Henry Wong [Mon, 5 Mar 2018 15:41:15 +0000 (15:41 +0000)]
[analyzer] Improves the logic of GenericTaintChecker identifying stdin.

Summary:
GenericTaintChecker can't recognize stdin in some cases. The reason is that `if (PtrTy->getPointeeType() == C.getASTContext().getFILEType()` does not hold when stdin is encountered.

My platform is ubuntu16.04 64bit, gcc 5.4.0, glibc 2.23. The definition of stdin is as follows:
```
__BEGIN_NAMESPACE_STD
/* The opaque type of streams.  This is the definition used elsewhere.  */
typedef struct _IO_FILE FILE;
___END_NAMESPACE_STD

  ...

/* The opaque type of streams.  This is the definition used elsewhere.  */
typedef struct _IO_FILE __FILE;

  ...

/* Standard streams.  */
extern struct _IO_FILE *stdin;      /* Standard input stream.  */
extern struct _IO_FILE *stdout;     /* Standard output stream.  */
extern struct _IO_FILE *stderr;     /* Standard error output stream.  */
```

The type of stdin is as follows AST:
```
ElaboratedType 0xc911170'struct _IO_FILE'sugar
`-RecordType 0xc911150'struct _IO_FILE'
 `-CXXRecord 0xc923ff0'_IO_FILE'
```

`C.getASTContext().GetFILEType()` is as follows AST:
```
TypedefType 0xc932710 'FILE' sugar
|-Typedef 0xc9111c0 'FILE'
`-ElaboratedType 0xc911170 'struct _IO_FILE' sugar
  `-RecordType 0xc911150 'struct _IO_FILE'
      `-CXXRecord 0xc923ff0 '_IO_FILE'
```

So I think it's better to use `getCanonicalType()`.

Reviewers: zaks.anna, NoQ, george.karpenkov, a.sidorin

Reviewed By: zaks.anna, a.sidorin

Subscribers: a.sidorin, cfe-commits, xazax.hun, szepet, MTC

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

llvm-svn: 326709

6 years agoTableGen: Resolve all template args simultaneously in ResolveMulticlassDefARgs
Nicolai Haehnle [Mon, 5 Mar 2018 15:21:19 +0000 (15:21 +0000)]
TableGen: Resolve all template args simultaneously in ResolveMulticlassDefARgs

Summary:
Use the new resolver interface more explicitly, and avoid traversing
all the initializers multiple times.

Change-Id: I679e86988b309d19f25e6cca8b0b14ea150198a6

Reviewers: arsenm, craig.topper, tra, MartinO

Subscribers: wdng, llvm-commits

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

llvm-svn: 326708

6 years agoTableGen: Resolve all template args simultaneously in AddSubMultiClass
Nicolai Haehnle [Mon, 5 Mar 2018 15:21:15 +0000 (15:21 +0000)]
TableGen: Resolve all template args simultaneously in AddSubMultiClass

Summary:
Use the new resolver interface more explicitly, and avoid traversing
all the initializers multiple times.

Change-Id: Ia4dcc6d42dd8b65e6079d318c6a202f36f320fee

Reviewers: arsenm, craig.topper, tra, MartinO

Subscribers: wdng, llvm-commits

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

llvm-svn: 326707

6 years agoTableGen: Resolve all template args simultaneously in AddSubClass
Nicolai Haehnle [Mon, 5 Mar 2018 15:21:11 +0000 (15:21 +0000)]
TableGen: Resolve all template args simultaneously in AddSubClass

Summary:
Use the new resolver interface more explicitly, and avoid traversing
all the initializers multiple times.

Add a test case for a pattern that was broken by an earlier version
of this change.

An additional change is that we now remove *all* template arguments
after resolving them.

Change-Id: I86c828c8cc84c18b052dfe0f64c0d5cbf3c4e13c

Reviewers: arsenm, craig.topper, tra, MartinO

Subscribers: wdng, llvm-commits

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

llvm-svn: 326706

6 years agoTableGen: Reimplement !foreach using the resolving mechanism
Nicolai Haehnle [Mon, 5 Mar 2018 15:21:04 +0000 (15:21 +0000)]
TableGen: Reimplement !foreach using the resolving mechanism

Summary:
This changes the syntax of !foreach so that the first "parameter" is
a new syntactic variable: !foreach(x, lst, expr) will define the
variable x within the scope of expr, and evaluation of the !foreach
will substitute elements of the given list (or dag) for x in expr.

Aside from leading to a nicer syntax, this allows more complex
expressions where x is deeply nested, or even constant expressions
in which x does not occur at all.

!foreach is currently not actually used anywhere in trunk, but I
plan to use it in the AMDGPU backend. If out-of-tree targets are
using it, they can adjust to the new syntax very easily.

Change-Id: Ib966694d8ab6542279d6bc358b6f4d767945a805

Reviewers: arsenm, craig.topper, tra, MartinO

Subscribers: wdng, llvm-commits, tpr

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

llvm-svn: 326705

6 years agoTableGen: Introduce an abstract variable resolver interface
Nicolai Haehnle [Mon, 5 Mar 2018 15:20:51 +0000 (15:20 +0000)]
TableGen: Introduce an abstract variable resolver interface

Summary:
The intention is to allow us to more easily restructure how resolving is
done, e.g. resolving multiple variables simultaneously, or using the
resolving mechanism to implement !foreach.

Change-Id: I4b976b54a32e240ad4f562f7eb86a4d663a20ea8

Reviewers: arsenm, craig.topper, tra, MartinO

Subscribers: wdng, llvm-commits

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

llvm-svn: 326704

6 years agoPass Divergence Analysis data to Selection DAG to drive divergence
Alexander Timofeev [Mon, 5 Mar 2018 15:12:21 +0000 (15:12 +0000)]
Pass Divergence Analysis data to Selection DAG to drive divergence
dependent instruction selection.

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

llvm-svn: 326703

6 years ago[Polly][CMake] Fix lit setup for building the in the mono repo
Philip Pfaffe [Mon, 5 Mar 2018 14:43:04 +0000 (14:43 +0000)]
[Polly][CMake] Fix lit setup for building the in the mono repo

Summary:
When building polly as part of the monorepo (actually, as part of any setup
using LLVM_ENABLE_PROJECTS), the LLVMPolly library used in the lit tests ends
up in a different directory in the build tree than in an in-tree build

Reviewers: Meinersbur, grosser, bollu

Reviewed By: Meinersbur

Subscribers: mgorny, bollu, pollydev, llvm-commits

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

llvm-svn: 326702

6 years ago[Power9] Add more missing instructions to the Power 9 scheduler
Stefan Pintilie [Mon, 5 Mar 2018 14:34:59 +0000 (14:34 +0000)]
[Power9] Add more missing instructions to the Power 9 scheduler

Adding more instructions using InstRW so that we can move away from ItinRW
and ultimately have a complete Power 9 scheduler.

llvm-svn: 326701

6 years agoTableGen: Allow NAME in template arguments in defm in multiclass
Nicolai Haehnle [Mon, 5 Mar 2018 14:01:38 +0000 (14:01 +0000)]
TableGen: Allow NAME in template arguments in defm in multiclass

Summary:
NAME has already worked for def in a multiclass, since the (protoype)
record including its NAME variable is created before parsing the
superclasses. Since defm's do not have an associated single record,
support for NAME has to be implemented differently here.

Original test cases provided by Artem Belevich (tra)

Change-Id: I933b74f328c0ff202e7dc23a35b78f3505760cc9

Reviewers: arsenm, craig.topper, tra, MartinO

Subscribers: wdng, llvm-commits

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

llvm-svn: 326700

6 years agoTableGen: Use DefInit::getDef() instead of the type's getRecord()
Nicolai Haehnle [Mon, 5 Mar 2018 14:01:30 +0000 (14:01 +0000)]
TableGen: Use DefInit::getDef() instead of the type's getRecord()

The former simply makes more sense: we want to access the data here in
the backend, not information about the type.

More importantly, removing users of RecordRecTy::getRecord() allows us
more freedom to refactor the frontend.

Change-Id: Iee8905fd22cdb9b11c42ca03246c03d8fe4dd77f
llvm-svn: 326699

6 years ago[MergeICmp] We can discard initial blocks that do other work
Xin Tong [Mon, 5 Mar 2018 13:54:47 +0000 (13:54 +0000)]
[MergeICmp] We can discard initial blocks that do other work

Summary:
 We can discard initial blocks that do other work
We do not need to limit ourselves to just the first block in the chain.

Reviewers: courbet, davide

Reviewed By: courbet

Subscribers: llvm-commits

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

llvm-svn: 326698

6 years ago[WebAssembly] Add validation to reloc section
Nicholas Wilson [Mon, 5 Mar 2018 13:32:38 +0000 (13:32 +0000)]
[WebAssembly] Add validation to reloc section

We now check relocations offsets are within range, and the relocation
index is valid.

Also updated tests which contained invalid Wasm files that were
previously not checked.

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

llvm-svn: 326697

6 years ago[ARM][Asm] VMOVSRR and VMOVRRS need sequential S registers
Oliver Stannard [Mon, 5 Mar 2018 13:27:26 +0000 (13:27 +0000)]
[ARM][Asm] VMOVSRR and VMOVRRS need sequential S registers

These instructions require that the two S registers are adjacent (but not the R
registers), because only the first register is included in the encoding, but we
were not checking this in the assembler.

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

llvm-svn: 326696

6 years ago[WebAssembly] Reorder reloc sections to come between symtab and name
Nicholas Wilson [Mon, 5 Mar 2018 12:59:03 +0000 (12:59 +0000)]
[WebAssembly] Reorder reloc sections to come between symtab and name

This is required in order to enable relocs to be validated
as they are read in.

Also update tests with new section ordering.

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

llvm-svn: 326694

6 years ago[WebAssembly] Reorder reloc sections to come after symtab
Nicholas Wilson [Mon, 5 Mar 2018 12:33:58 +0000 (12:33 +0000)]
[WebAssembly] Reorder reloc sections to come after symtab

This matches LLVM change D43940.

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

llvm-svn: 326693

6 years ago[WebAssembly] Fix tests with invalid yaml (required CODE section missing)
Nicholas Wilson [Mon, 5 Mar 2018 12:28:01 +0000 (12:28 +0000)]
[WebAssembly] Fix tests with invalid yaml (required CODE section missing)

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

llvm-svn: 326692

6 years ago[WebAssembly] Attach a name to globals similarly to function naming
Nicholas Wilson [Mon, 5 Mar 2018 12:16:32 +0000 (12:16 +0000)]
[WebAssembly] Attach a name to globals similarly to function naming

This allows LLD to print the name for an InputGlobal when encountering
an error.

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

llvm-svn: 326691

6 years agoFix location of comment in EmitPopInst
Thomas Preud'homme [Mon, 5 Mar 2018 11:49:00 +0000 (11:49 +0000)]
Fix location of comment in EmitPopInst

Comment about folding return in LDM was not moved along with the
corresponding code in r242714. This commit fixes that.

llvm-svn: 326690

6 years ago[x86][CET] Introduce _get_ssp, _inc_ssp intrinsics
Alexander Ivchenko [Mon, 5 Mar 2018 11:30:28 +0000 (11:30 +0000)]
[x86][CET] Introduce _get_ssp, _inc_ssp intrinsics

Summary:
The _get_ssp intrinsic can be used to retrieve the
shadow stack pointer, independent of the current arch -- in
contract with the rdsspd and the rdsspq intrinsics.
Also, this intrinsic returns zero on CPUs which don't
support CET. The rdssp[d|q] instruction is decoded as nop,
essentially just returning the input operand, which is zero.
Example result of compilation:

```
xorl    %eax, %eax
movl    %eax, %ecx
rdsspq  %rcx         # NOP when CET is not supported
movq    %rcx, %rax   # return zero
```

Reviewers: craig.topper

Subscribers: cfe-commits

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

llvm-svn: 326689

6 years ago[ELF] - Support moving location counter when MEMORY is used.
George Rimar [Mon, 5 Mar 2018 10:54:03 +0000 (10:54 +0000)]
[ELF] - Support moving location counter when MEMORY is used.

We do not expand memory region correctly for following scripts:

.foo.1 :
 {
   *(.foo.1)
   . += 0x1000;
 } > ram
Patch generalizes expanding of output sections and memory
regions in one place and fixes the issue.

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

llvm-svn: 326688

6 years ago[test] Add dotest wrapper
Jonas Devlieghere [Mon, 5 Mar 2018 10:03:44 +0000 (10:03 +0000)]
[test] Add dotest wrapper

This adds a wrapper around dotest, similar to llvm-lit in llvm. The
wrapper is created in the binary directory, next to LLDB and allows you
to invoke dotest without having to pass any of the configuration
arguments yourself. I think this could also be useful for re-running a
particular test case when it fails, as an alternative to "Command
Invoked".

The motivation for this is that I'd like to replace the driver part of
dotest with lit. As a first step, I'd like to have lit invoke dotest,
which would just run the complete test suite, completely identical to
what the CMake target does today. Once this is in place, we can have lit
run dotest for the different test directories, and ultimately once per
python file. Along the way we can strip out driver functionality from
dotest where appropriate.

https://reviews.llvm.org/D44002

llvm-svn: 326687

6 years ago[ELF] - Report location for div/mod by zero.
George Rimar [Mon, 5 Mar 2018 10:02:44 +0000 (10:02 +0000)]
[ELF] - Report location for div/mod by zero.

"division by zero" or "modulo by zero" are not
very informative errors and even probably confusing
as does not let to know that error is coming from linker script.
Patch adds location reporting.

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

llvm-svn: 326686

6 years ago[Bash-autocompletion] Fixed formatting
Yuka Takahashi [Mon, 5 Mar 2018 09:01:31 +0000 (09:01 +0000)]
[Bash-autocompletion] Fixed formatting

Fixed a trivial formatting and indent.

llvm-svn: 326685

6 years ago[Bash-autocompletion] Pass all flags in shell command-line to Clang
Yuka Takahashi [Mon, 5 Mar 2018 08:54:20 +0000 (08:54 +0000)]
[Bash-autocompletion] Pass all flags in shell command-line to Clang

Previously, we passed "#" to --autocomplete to indicate to enable cc1
flags. For example, when -cc1 or -Xclang was passed to bash, bash
executed `clang --autocomplete=#-<flag they want to complete>`.

However, this was not a good implementation because it depends -Xclang
and -cc1 parsing to shell. So I changed this to pass all flags shell
has, so that Clang can handle them internally.

I had to change many testcases because API spec changed quite a lot.

Reviewers: teemperor, v.g.vassilev

Subscribers: cfe-commits

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

llvm-svn: 326684

6 years ago[MergeICmps][NFC] Improve logging.
Clement Courbet [Mon, 5 Mar 2018 08:21:47 +0000 (08:21 +0000)]
[MergeICmps][NFC] Improve logging.

llvm-svn: 326683

6 years ago[X86] Replace usages of X86Subtarget::hasFp256 with hasAVX. Remove hasFP256.
Craig Topper [Mon, 5 Mar 2018 00:13:35 +0000 (00:13 +0000)]
[X86] Replace usages of X86Subtarget::hasFp256 with hasAVX. Remove hasFP256.

Almost none of these usages were FP specific. And we had no clear guideliness on when to use hasAVX vs hasFP256.

I might also remove hasInt256 too since its an alias for hasAVX2.

llvm-svn: 326682

6 years ago[X86] Add a DAG combine to turn stores of vXi1 constants into scalar stores.
Craig Topper [Sun, 4 Mar 2018 19:33:15 +0000 (19:33 +0000)]
[X86] Add a DAG combine to turn stores of vXi1 constants into scalar stores.

llvm-svn: 326679

6 years ago[X86] Add a 32-bit mode command line to avx512-mask-op.ll. Add tests for storing...
Craig Topper [Sun, 4 Mar 2018 19:33:13 +0000 (19:33 +0000)]
[X86] Add a 32-bit mode command line to avx512-mask-op.ll. Add tests for storing v2i1 and v4i1 constants.

llvm-svn: 326678

6 years ago[DAGCombiner] Add a peekThroughBitcast to MergeStoresOfConstantsOrVecElts to fix...
Craig Topper [Sun, 4 Mar 2018 18:51:46 +0000 (18:51 +0000)]
[DAGCombiner] Add a peekThroughBitcast to MergeStoresOfConstantsOrVecElts to fix a crash if we are storing a bitcast of a constant.

Loading a constant into a k-register in AVX512 requires a bitcast from a scalar constant. In the test case here we have a k-register store that gets split into multiple parts of KNL. MergeConsecutiveStores sees each of these pieces as a consecutive store and looks through the bitcast to find the underly scalar constant. But when we went to create the combined store we didn't look through the same bitcast.

llvm-svn: 326677

6 years agoAmend r326665 to print out the `used` attribute subjects in a different order.
Aaron Ballman [Sun, 4 Mar 2018 16:24:10 +0000 (16:24 +0000)]
Amend r326665 to print out the `used` attribute subjects in a different order.

llvm-svn: 326676

6 years agoReplace the custom handling for several attributes; NFC.
Aaron Ballman [Sun, 4 Mar 2018 15:32:01 +0000 (15:32 +0000)]
Replace the custom handling for several attributes; NFC.

These attributes were only customized because of the need to check for attribute mutual exclusion, but we now have the handleSimpleAttributeWithExclusions() helper function to handle these scenarios.

llvm-svn: 326675

6 years ago[X86][X87] Add X87 folded integer arithmetic tests
Simon Pilgrim [Sun, 4 Mar 2018 15:00:19 +0000 (15:00 +0000)]
[X86][X87] Add X87 folded integer arithmetic tests

Add tests for FIADD/FISUB/FISUBR/FIMUL/FIDIV/FIDIVR

Shows we have more FILD stack usage than necessary (arg load, spill, reload to x87)

llvm-svn: 326674

6 years ago[X86][MMX] Remove completed _mm_cvtsi32_si64 todo
Simon Pilgrim [Sun, 4 Mar 2018 14:57:26 +0000 (14:57 +0000)]
[X86][MMX] Remove completed _mm_cvtsi32_si64 todo

rL322525 - mmx zero constant support
rL322553 - mmx i32 zero extended value
rL326497 - mmx i64 general constant handling

Not all constants are folded, we generate some on the GPRs (similar to SSE build vector) where appropriate

llvm-svn: 326673

6 years ago[X86] Fix unused variable in release builds.
Craig Topper [Sun, 4 Mar 2018 02:14:16 +0000 (02:14 +0000)]
[X86] Fix unused variable in release builds.

llvm-svn: 326672

6 years agollgs-tests: use the auto-parsing form of SendMessage for sending the continue packets
Pavel Labath [Sun, 4 Mar 2018 02:12:18 +0000 (02:12 +0000)]
llgs-tests: use the auto-parsing form of SendMessage for sending the continue packets

llvm-svn: 326671

6 years ago[X86] Combine (store (v1i1 (scalar_to_vector (i8 X)))) -> (store (i8 X)).
Craig Topper [Sun, 4 Mar 2018 01:48:02 +0000 (01:48 +0000)]
[X86] Combine (store (v1i1 (scalar_to_vector (i8 X)))) -> (store (i8 X)).

llvm-svn: 326670

6 years ago[X86] Lower v1i1/v2i1/v4i1/v8i1 load/stores to i8 load/store during op legalization...
Craig Topper [Sun, 4 Mar 2018 01:48:00 +0000 (01:48 +0000)]
[X86] Lower v1i1/v2i1/v4i1/v8i1 load/stores to i8 load/store during op legalization if AVX512DQ is not supported.

We were previously doing this with isel patterns. Moving it to op legalization gives us chance to see the required bitcast earlier. And it lets us remove some isel patterns.

llvm-svn: 326669

6 years ago[CallSiteSplitting] fix use after-free
Fedor Indutny [Sat, 3 Mar 2018 22:34:38 +0000 (22:34 +0000)]
[CallSiteSplitting] fix use after-free

Iterating through predecessors of `TailBB` while removing their
terminators leads to use after-free, because the predecessor list is
changing on each removal.

llvm-svn: 326668

6 years agoObjectFileMachO: use early return to remove one nesting level from CreateSections()
Pavel Labath [Sat, 3 Mar 2018 22:07:47 +0000 (22:07 +0000)]
ObjectFileMachO: use early return to remove one nesting level from CreateSections()

NFCI

llvm-svn: 326667

6 years ago[CallSiteSplitting] properly split musttail calls
Fedor Indutny [Sat, 3 Mar 2018 21:40:14 +0000 (21:40 +0000)]
[CallSiteSplitting] properly split musttail calls

Summary:
`musttail` calls can't be naively splitted. The split blocks must
include not only the call instruction itself, but also (optional)
`bitcast` and `return` instructions that follow it.

Clone `bitcast` and `ret`, place them into the split blocks, and
remove the tail block when done.

Reviewers: junbuml, mcrosier, davidxl, davide, fhahn

Reviewed By: fhahn

Subscribers: JDevlieghere, llvm-commits

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

llvm-svn: 326666

6 years agoCreate a subject list for the `used` attribute rather than use custom checking logic.
Aaron Ballman [Sat, 3 Mar 2018 21:02:09 +0000 (21:02 +0000)]
Create a subject list for the `used` attribute rather than use custom checking logic.

This changes the diagnostic wording somewhat, but otherwise intends no functional change to the attribute.

llvm-svn: 326665

6 years ago[ScopInfo] Do not use the set dimension ids to carry loop information
Tobias Grosser [Sat, 3 Mar 2018 19:27:54 +0000 (19:27 +0000)]
[ScopInfo] Do not use the set dimension ids to carry loop information

isl does not guarantee that set dimension ids will be preserved, so using them
to carry information is not a good idea. Furthermore, the loop information can
be derived without problem from the statement itself. As this even requires
less code than propagating loop information on set dimension ids, starting from
this commit we just derive the loop information in collectSurroundingLoops
directly from the IR.

Interestingly this also results in a couple of isl sets to take a simpler
representation.

llvm-svn: 326664

6 years agoRemove more references to ptrace_pt_{g,s}et_sigmask
Kamil Rytarowski [Sat, 3 Mar 2018 18:41:38 +0000 (18:41 +0000)]
Remove more references to ptrace_pt_{g,s}et_sigmask

These operations are now obsolete on NetBSD and will be removed.

No functional change for other OSes.

Sponsored by <The NetBSD Foundation>

llvm-svn: 326663

6 years agoFix NetBSD 32-bit build
Kamil Rytarowski [Sat, 3 Mar 2018 18:38:20 +0000 (18:38 +0000)]
Fix NetBSD 32-bit build

Replace 'defined(SANITIZER_OPENBSD)' with appropriate 'SANITIZER_OPENBSD'.

This is a fallout from adding OpenBSD partial support.

llvm-svn: 326662

6 years ago[InstCombine] add test for vectors with undef elts; NFC
Sanjay Patel [Sat, 3 Mar 2018 18:00:15 +0000 (18:00 +0000)]
[InstCombine] add test for vectors with undef elts; NFC

llvm-svn: 326661

6 years ago[InstCombine] (~X) - (~Y) --> Y - X
Sanjay Patel [Sat, 3 Mar 2018 17:53:25 +0000 (17:53 +0000)]
[InstCombine] (~X) - (~Y) --> Y - X

llvm-svn: 326660

6 years ago[InstCombine] add tests for notnotsub; NFC
Sanjay Patel [Sat, 3 Mar 2018 17:20:37 +0000 (17:20 +0000)]
[InstCombine] add tests for notnotsub; NFC

As shown in D44043, we may need this fold in the backend,
but it's also missing in the IR optimizer.

llvm-svn: 326659

6 years ago[X86] This bit-test TODO has been moved in PR36551
Simon Pilgrim [Sat, 3 Mar 2018 16:31:17 +0000 (16:31 +0000)]
[X86] This bit-test TODO has been moved in PR36551

llvm-svn: 326658

6 years agoRemove obsolete ptrace(2) operations from NetBSD
Kamil Rytarowski [Sat, 3 Mar 2018 16:21:13 +0000 (16:21 +0000)]
Remove obsolete ptrace(2) operations from NetBSD

PT_SET_SIGMASK and PT_GET_SIGMASK will be removed from NetBSD
without backward compat (it shortlived in a development branch).

Sponsored by <The NetBSD Foundation>

llvm-svn: 326657

6 years agoRevert "[Acc] Fix for PR33208"
Philip Pfaffe [Sat, 3 Mar 2018 15:34:49 +0000 (15:34 +0000)]
Revert "[Acc] Fix for PR33208"

This reverts commit r326643. Fix didn't really fix anything.

llvm-svn: 326656

6 years agoRevert D44035
Kamil Rytarowski [Sat, 3 Mar 2018 14:50:36 +0000 (14:50 +0000)]
Revert D44035

Broken syntax.

llvm-svn: 326655

6 years agoHotfix for D44035
Kamil Rytarowski [Sat, 3 Mar 2018 14:31:06 +0000 (14:31 +0000)]
Hotfix for D44035

Try to fix the syntax.

llvm-svn: 326654

6 years agoSupport OpenBSD in common interceptors
Kamil Rytarowski [Sat, 3 Mar 2018 14:13:08 +0000 (14:13 +0000)]
Support OpenBSD in common interceptors

Summary:
Extract  INIT_PTHREAD_ATTR_GET_SCHED from INIT_PTHREAD_ATTR_GET,
as the former is not supported on OpenBSD.

Supported interceptors
getdetachstate, getguardsize, getscope, getstacksize, getgrouplist and getstack
Unsupported
getschedparam, getgroupmembership and getschedpolicy

Patch by David CARLIER

Reviewers: krytarowski, vitalybuka

Reviewed By: vitalybuka

Subscribers: fedor.sergeev, srhines, kubamracek, mgorny, llvm-commits, #sanitizers

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

llvm-svn: 326653

6 years agoDisable tests of -fsanitize on OpenBSD
Kamil Rytarowski [Sat, 3 Mar 2018 12:28:54 +0000 (12:28 +0000)]
Disable tests of -fsanitize on OpenBSD

This causes failures on buildbots:
/export/users/atombot/llvm/clang-atom-d525-fedora-rel/llvm/tools/clang/test/Driver/fsanitize.c:18:29: error: expected string not found in input
// CHECK-UNDEFINED-OPENBSD: "-fsanitize={{((signed-integer-overflow|integer-divide-by-zero|float-divide-by-zero|shift-base|shift-exponent|unreachable|return|vla-bound|alignment|null|pointer-overflow|float-cast-overflow|array-bounds|enum|bool|builtin|returns-nonnull-attribute|nonnull-attribute),?){18}"}}
                            ^
<stdin>:1:1: note: scanning from here
clang version 7.0.0 (trunk 326648)
^

This will be investigated.

llvm-svn: 326652

6 years agoOpenBSD UBsan support enabling SANITIZER_OPENBSD widely
Kamil Rytarowski [Sat, 3 Mar 2018 12:12:03 +0000 (12:12 +0000)]
OpenBSD UBsan support enabling SANITIZER_OPENBSD widely

Summary: Adding OpenBSD platform

Patch by: David CARLIER

Reviewers: krytarowski, vitalybuka

Reviewed By: vitalybuka

Subscribers: srhines, kubamracek, fedor.sergeev, llvm-commits, #sanitizers

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

llvm-svn: 326651

6 years agoOpenBSD UBsan support / common
Kamil Rytarowski [Sat, 3 Mar 2018 12:04:40 +0000 (12:04 +0000)]
OpenBSD UBsan support / common

Summary:
Sanitizer common, enable OpenBSD platform.
- Enable common interceptors as possible and create few distinct ones.
- Create necessary sanitizer_struct types.

Patch by: David CARLIER

Reviewers: krytarowski, vitalybuka, visa, kettenis

Reviewed By: vitalybuka

Subscribers: emaste, srhines, kubamracek, mgorny, fedor.sergeev, llvm-commits, #sanitizers

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

llvm-svn: 326650

6 years ago[msan] Restrict -ftls-model=initial-exec to FreeBSD
Kamil Rytarowski [Sat, 3 Mar 2018 12:00:12 +0000 (12:00 +0000)]
[msan] Restrict -ftls-model=initial-exec to FreeBSD

Noted by <eugenis> in D43613

llvm-svn: 326649

6 years agoOpenBSD Driver basic sanitiser support
Kamil Rytarowski [Sat, 3 Mar 2018 11:52:52 +0000 (11:52 +0000)]
OpenBSD Driver basic sanitiser support

Summary:
Basic support of Sanitiser to follow-up ubsan support in compiler-rt.
Needs to use lld instead of base ld to be fully workable.

Patch by: David CARLIER

Reviewers: krytarowski, vitalybuka, kettenis

Reviewed By: vitalybuka

Subscribers: cfe-commits

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

llvm-svn: 326648

6 years agoSanitiser common, using u64 type for GetTid on posix systems
Kamil Rytarowski [Sat, 3 Mar 2018 11:50:58 +0000 (11:50 +0000)]
Sanitiser common, using u64 type for GetTid on posix systems

Summary: Moving from ptr to u64 for GetTid posix implementation.
[FreeBSD] Moving from pthread_self to thr_self more appropriate to get thread ID.

Patch by: David CARLIER

Reviewers: krytarowski, vitalybuka

Reviewed By: vitalybuka

Subscribers: kubamracek, llvm-commits, #sanitizers

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

llvm-svn: 326647

6 years agoOpenBSD UBsan support, cmake part
Kamil Rytarowski [Sat, 3 Mar 2018 11:48:54 +0000 (11:48 +0000)]
OpenBSD UBsan support, cmake part

Summary:
On OpenBSD no multi arch support
Enabling only UBsan and disabling Asan.

Patch by: David CARLIER

Reviewers: krytarowski, vitalybuka

Reviewed By: vitalybuka

Subscribers: srhines, mgorny, fedor.sergeev, llvm-commits, #sanitizers

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

llvm-svn: 326646

6 years agoBetter OpenBSD frontend support
Kamil Rytarowski [Sat, 3 Mar 2018 11:47:27 +0000 (11:47 +0000)]
Better OpenBSD frontend support

Summary:
- Like other *BSD, conditioning certain flags to pass
- To prepare future OpenBSD sanitisers.

Patch by: David CARLIER

Reviewers: dlj, krytarowski, vitalybuka

Reviewed By: vitalybuka

Subscribers: krytarowski, cfe-commits

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

llvm-svn: 326645

6 years agoAdding Msan support to FreeBSD
Kamil Rytarowski [Sat, 3 Mar 2018 11:43:11 +0000 (11:43 +0000)]
Adding Msan support to FreeBSD

Summary:
Enabling the memory sanitizer support for FreeBSD, most of unit tests are compatible.
- Adding fstat and stressor_r interceptors.
- Updating the struct link_map access since most likely the struct Obj_Entry had been updated since.
- Disabling few unit tests until further work is needed (or we can assume it can work in real world code).

Patch by: David CARLIER

Reviewers: vitalybuka, krytarowski

Reviewed By: vitalybuka

Subscribers: eugenis, dim, srhines, emaste, kubamracek, mgorny, fedor.sergeev, hintonda, llvm-commits, #sanitizers

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

llvm-svn: 326644

6 years ago[Acc] Fix for PR33208
Philip Pfaffe [Sat, 3 Mar 2018 10:47:37 +0000 (10:47 +0000)]
[Acc] Fix for PR33208

During codegen, Polly attempts to clear all loops from ScalarEvolution
and LoopInfo, and it does so one block at a time. This causes undefined
behaviour, since this way a loop header might be removed from a loop
before the entire loop is erased, causing ScalarEvolution to run into an
error.

Instead, just delete the entire loop atomically. This fixes currently
failing testcases.

llvm-svn: 326643

6 years ago[X86] Remove 'else' after return. NFC
Craig Topper [Sat, 3 Mar 2018 05:18:21 +0000 (05:18 +0000)]
[X86] Remove 'else' after return. NFC

llvm-svn: 326642

6 years agoSimplify. NFC.
Rafael Espindola [Sat, 3 Mar 2018 02:13:50 +0000 (02:13 +0000)]
Simplify. NFC.

Since r321982 we don't set VersionId in scanShlibUndefined, which
makes InVersionScript redundant.

llvm-svn: 326641

6 years agoMark ObjC testcase as skipUnlessDarwin and fix a typo in test function.
Adrian Prantl [Fri, 2 Mar 2018 23:57:09 +0000 (23:57 +0000)]
Mark ObjC testcase as skipUnlessDarwin and fix a typo in test function.

llvm-svn: 326640

6 years agoDo not generate calls to fentry with __attribute__((no_instrument_function))
Manoj Gupta [Fri, 2 Mar 2018 23:52:44 +0000 (23:52 +0000)]
Do not generate calls to fentry with __attribute__((no_instrument_function))

Summary:
Currently only calls to mcount were suppressed with
no_instrument_function attribute.
Linux kernel requires that calls to fentry should also not be
generated.
This is an extended fix for PR PR33515.

Reviewers: hfinkel, rengolin, srhines, rnk, rsmith, rjmccall, hans

Reviewed By: rjmccall

Subscribers: cfe-commits

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

llvm-svn: 326639

6 years ago[ThinLTO] Revert r325320: Import global variables
Chandler Carruth [Fri, 2 Mar 2018 23:40:08 +0000 (23:40 +0000)]
[ThinLTO] Revert r325320: Import global variables

This caused some links to fail with ThinLTO due to missing symbols as
well as causing some binaries to have failures at runtime. We're working
with the author to get a test case, but want to get the tree green
again.

Further, it appears to introduce a data race. While the test usage of
threads was disabled in r325361 & r325362, that isn't an acceptable fix.
I've reverted both of these as well. This code needs to be thread safe.
Test cases for this are already on the original commit thread.

llvm-svn: 326638

6 years ago[LegalizeVectorTypes] When scalarizing the operand of a unary op like TRUNC, use...
Craig Topper [Fri, 2 Mar 2018 23:27:50 +0000 (23:27 +0000)]
[LegalizeVectorTypes] When scalarizing the operand of a unary op like TRUNC, use a SCALAR_TO_VECTOR rather than a single element BUILD_VECTOR to convert back to a vector type.

X86 considers v1i1 a legal type under AVX512 and as such a truncate from a v1iX type to v1i1 can be turned into a scalar truncate plus a conversion to v1i1. We would much prefer a v1i1 SCALAR_TO_VECTOR over a one element BUILD_VECTOR.

During lowering we were detecting the v1i1 BUILD_VECTOR as a splat BUILD_VECTOR like we try to do for v2i1/v4i1/etc. In this case we create (select i1 splat_elt, v1i1 all-ones, v1i1 all-zeroes). That goes through some more legalization and we end up with a CMOV choosing between 0 and 1 in scalar and a scalar_to_vector.

Arguably we could detect the v1i1 BUILD_VECTOR and do this better in X86 target code. But just using a SCALAR_TO_VECTOR in legalization is much easier.

llvm-svn: 326637

6 years agoImplementation of MRI "delete" command.
Dmitry Mikulin [Fri, 2 Mar 2018 23:23:48 +0000 (23:23 +0000)]
Implementation of MRI "delete" command.

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

llvm-svn: 326636

6 years ago[AggressiveInstCombine] Use use_empty() instead of !getNumUses(), NFC
Vedant Kumar [Fri, 2 Mar 2018 23:22:49 +0000 (23:22 +0000)]
[AggressiveInstCombine] Use use_empty() instead of !getNumUses(), NFC

use_empty() runs in O(1), whereas getNumUses() runs in O(# uses).

llvm-svn: 326635