platform/upstream/llvm.git
5 years ago[ARM] Add patterns for BSWAP intrinsic on MVE
Oliver Cruickshank [Mon, 16 Sep 2019 15:20:10 +0000 (15:20 +0000)]
[ARM] Add patterns for BSWAP intrinsic on MVE

BSWAP can use the VREV instruction on MVE to produce better results than
expanding.

llvm-svn: 372002

5 years ago[ARM] Add patterns for bitreverse intrinsic on MVE
Oliver Cruickshank [Mon, 16 Sep 2019 15:20:03 +0000 (15:20 +0000)]
[ARM] Add patterns for bitreverse intrinsic on MVE

BITREVERSE can use the VBRSR which will reverse and right shift.
Shifting right by 0 will just reverse the bits.

llvm-svn: 372001

5 years ago[ARM] Lower CTTZ on MVE
Oliver Cruickshank [Mon, 16 Sep 2019 15:19:56 +0000 (15:19 +0000)]
[ARM] Lower CTTZ on MVE

Lower CTTZ on MVE using VBRSR and VCLS which will reverse the bits and
count the leading zeros, equivalent to a count trailing zeros (CTTZ).

llvm-svn: 372000

5 years ago[ARM] Add patterns for CTLZ on MVE
Oliver Cruickshank [Mon, 16 Sep 2019 15:19:49 +0000 (15:19 +0000)]
[ARM] Add patterns for CTLZ on MVE

CTLZ intrinsic can use the VCLS instruction on MVE, which produces
better results than expanding.

llvm-svn: 371999

5 years ago[ExecutionEngine] Don't dereference a dyn_cast result. NFCI.
Simon Pilgrim [Mon, 16 Sep 2019 15:19:11 +0000 (15:19 +0000)]
[ExecutionEngine] Don't dereference a dyn_cast result. NFCI.

The static analyzer is warning about potential null dereferences of dyn_cast<> results - in these cases we can safely use cast<> directly as we know that these cases should all be the correct type, which is why its working atm and anyway cast<> will assert if they aren't.

llvm-svn: 371998

5 years ago[libFuzzer] Remove unused version of FuzzedDataProvider.h.
Max Moroz [Mon, 16 Sep 2019 15:00:21 +0000 (15:00 +0000)]
[libFuzzer] Remove unused version of FuzzedDataProvider.h.

Summary: The actual version lives in compiler-rt/include/fuzzer/.

Reviewers: Dor1s

Reviewed By: Dor1s

Subscribers: delcypher, #sanitizers, llvm-commits

Tags: #llvm, #sanitizers

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

llvm-svn: 371997

5 years ago[LV] Add ARM MVE tail-folding tests
Sjoerd Meijer [Mon, 16 Sep 2019 14:56:26 +0000 (14:56 +0000)]
[LV] Add ARM MVE tail-folding tests

Now that the vectorizer can do tail-folding (rL367592), and the ARM backend
understands MVE masked loads/stores (rL371932), it's time to add the MVE
tail-folding equivalent of the X86 tests that I added.

llvm-svn: 371996

5 years ago[SystemZ] Call erase() on the right MBB in SystemZTargetLowering::emitSelect()
Jonas Paulsson [Mon, 16 Sep 2019 14:49:36 +0000 (14:49 +0000)]
[SystemZ]  Call erase() on the right MBB in SystemZTargetLowering::emitSelect()

Since MBB was split *before* MI, the MI(s) will reside in JoinMBB (MBB) at
the point of erasing them, so calling StartMBB->erase() is actually wrong,
although it is "working" by all appearances.

Review: Ulrich Weigand
llvm-svn: 371995

5 years ago[NFC] remove unused functions
Guillaume Chatelet [Mon, 16 Sep 2019 14:48:58 +0000 (14:48 +0000)]
[NFC] remove unused functions

Reviewers: courbet

Subscribers: hiraditya, llvm-commits

Tags: #llvm

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

llvm-svn: 371994

5 years agoAMDGPU/GlobalISel: Fail select of G_INSERT non-32-bit source
Matt Arsenault [Mon, 16 Sep 2019 14:26:14 +0000 (14:26 +0000)]
AMDGPU/GlobalISel: Fail select of G_INSERT non-32-bit source

This was producing an illegal copy which would hit an assert
later. Error on selection for now until this is implemented.

llvm-svn: 371993

5 years agoAMDGPU/GlobalISel: Fix some broken run lines
Matt Arsenault [Mon, 16 Sep 2019 14:14:40 +0000 (14:14 +0000)]
AMDGPU/GlobalISel: Fix some broken run lines

llvm-svn: 371992

5 years agoAMDGPU/GlobalISel: Fix RegBankSelect for G_FRINT and G_FCEIL
Matt Arsenault [Mon, 16 Sep 2019 14:14:37 +0000 (14:14 +0000)]
AMDGPU/GlobalISel: Fix RegBankSelect for G_FRINT and G_FCEIL

llvm-svn: 371991

5 years agoAMDGPU/GlobalISel: Remove another illegal select test
Matt Arsenault [Mon, 16 Sep 2019 14:14:31 +0000 (14:14 +0000)]
AMDGPU/GlobalISel: Remove another illegal select test

llvm-svn: 371990

5 years ago[X86][NFC] Add a `use-aa` feature.
Clement Courbet [Mon, 16 Sep 2019 14:05:28 +0000 (14:05 +0000)]
[X86][NFC] Add a `use-aa` feature.

Summary:
This allows enabling useaa on the command-line and will allow enabling the
feature on a per-CPU basis where benchmarking shows improvements.

This is modelled after the ARM/AArch64 target.

Reviewers: RKSimon, andreadb, craig.topper

Subscribers: javed.absar, kristof.beyls, hiraditya, ychen, llvm-commits

Tags: #llvm

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

llvm-svn: 371989

5 years ago[InstCombine] add/move tests for icmp with add operand; NFC
Sanjay Patel [Mon, 16 Sep 2019 14:05:19 +0000 (14:05 +0000)]
[InstCombine] add/move tests for icmp with add operand; NFC

llvm-svn: 371988

5 years ago[clangd][vscode] update the development doc.
Haojian Wu [Mon, 16 Sep 2019 14:03:06 +0000 (14:03 +0000)]
[clangd][vscode] update the development doc.

llvm-svn: 371986

5 years agoMove some definitions from Sema to Basic to fix shared libs build
Erich Keane [Mon, 16 Sep 2019 13:58:59 +0000 (13:58 +0000)]
Move some definitions from Sema to Basic to fix shared libs build

r371875 moved some functionality around to a Basic header file, but
didn't move its definitions as well.  This patch moves some things
around so that shared library building can work.

llvm-svn: 371985

5 years ago[docs][llvm-strings] Write llvm-strings documentation
James Henderson [Mon, 16 Sep 2019 13:56:12 +0000 (13:56 +0000)]
[docs][llvm-strings] Write llvm-strings documentation

Previously we only had a stub document.

Reviewed by: MaskRay

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

llvm-svn: 371984

5 years ago[docs][llvm-size] Write llvm-size documentation
James Henderson [Mon, 16 Sep 2019 13:20:37 +0000 (13:20 +0000)]
[docs][llvm-size] Write llvm-size documentation

Previously we only had a stub document.

Reviewed by: serge-sans-paille, MaskRay

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

llvm-svn: 371983

5 years ago[ARM] Fold VCMP into VPT
David Green [Mon, 16 Sep 2019 13:02:41 +0000 (13:02 +0000)]
[ARM] Fold VCMP into VPT

MVE has VPT instructions, which perform the duties of both a VCMP and a VPST in
a single instruction, performing the compare and starting the VPT block in one.
This teaches the MVEVPTBlockPass to fold them, searching back through the
basicblock for a valid VCMP and creating the VPT from its operands.

There are some changes to the VPT instructions to accommodate this, altering
the order of the operands to match the VCMP better, and changing P0 register
defs to be VPR defs, as is used in other places.

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

llvm-svn: 371982

5 years ago[InstCombine] remove unneeded one-use checks for icmp fold
Sanjay Patel [Mon, 16 Sep 2019 12:54:34 +0000 (12:54 +0000)]
[InstCombine] remove unneeded one-use checks for icmp fold

This fold and several others were added in:
rL125734 <https://reviews.llvm.org/rL125734>
...with no explanation for the one-use checks other than the code
comments about register pressure.

Given that this is IR canonicalization, we shouldn't be worried
about register pressure though; the backend should be able to
adjust for that as needed.

This is part of solving PR43310 the theoretically right way:
https://bugs.llvm.org/show_bug.cgi?id=43310
...ie, if we don't cripple basic transforms, then we won't
need to add special-case code to detect larger patterns.

rL371940 is a related patch in this series.

llvm-svn: 371981

5 years ago[clangd] Bump vscode-clangd v0.0.17
Haojian Wu [Mon, 16 Sep 2019 12:51:07 +0000 (12:51 +0000)]
[clangd] Bump vscode-clangd v0.0.17

CHANGELOG:
- added semantic highlighting support (under the clangd.semanticHighlighting
  flag);
- better error message when clangd fails to execute refactoring-like
  actions;
- improved the readme doc;

llvm-svn: 371980

5 years ago[InstCombine] add icmp tests with extra uses; NFC
Sanjay Patel [Mon, 16 Sep 2019 12:19:18 +0000 (12:19 +0000)]
[InstCombine] add icmp tests with extra uses; NFC

llvm-svn: 371979

5 years ago[InstCombine] fix comments to match code; NFC
Sanjay Patel [Mon, 16 Sep 2019 12:12:05 +0000 (12:12 +0000)]
[InstCombine] fix comments to match code; NFC

This blob was written before match() existed, so it
could probably be reduced significantly.

But I suspect it isn't well tested, so tests would have
to be added to reduce risk from logic changes.

llvm-svn: 371978

5 years agogn build: Merge r371976
Nico Weber [Mon, 16 Sep 2019 11:33:54 +0000 (11:33 +0000)]
gn build: Merge r371976

llvm-svn: 371977

5 years agoImplement semantic selections.
Utkarsh Saxena [Mon, 16 Sep 2019 11:29:35 +0000 (11:29 +0000)]
Implement semantic selections.

Summary:
For a given cursor position, it returns ranges that are interesting to the user.
Currently the semantic ranges correspond to the nodes of the syntax trees.

Subscribers: mgorny, jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

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

llvm-svn: 371976

5 years ago[VPlanSLP] Don't dereference a cast_or_null<VPInstruction> result. NFCI.
Simon Pilgrim [Mon, 16 Sep 2019 11:22:44 +0000 (11:22 +0000)]
[VPlanSLP] Don't dereference a cast_or_null<VPInstruction> result. NFCI.

The static analyzer is warning about a potential null dereference of the cast_or_null result, I've split the cast_or_null check from the ->getUnderlyingInstr() call to avoid this, but it appears that we weren't seeing any null pointers in the dumped bundles in the first place.

llvm-svn: 371975

5 years ago[SLPVectorizer] Assert that we find a LastInst to silence analyzer null dereference...
Simon Pilgrim [Mon, 16 Sep 2019 10:48:16 +0000 (10:48 +0000)]
[SLPVectorizer] Assert that we find a LastInst to silence analyzer null dereference warning. NFCI.

llvm-svn: 371974

5 years ago[SLPVectorizer] Don't dereference a dyn_cast result. NFCI.
Simon Pilgrim [Mon, 16 Sep 2019 10:35:09 +0000 (10:35 +0000)]
[SLPVectorizer] Don't dereference a dyn_cast result. NFCI.

The static analyzer is warning about potential null dereferences of dyn_cast<> results - in these cases we can safely use cast<> directly as we know that these cases should all be the correct type, which is why its working atm and anyway cast<> will assert if they aren't.

llvm-svn: 371973

5 years agoAdded return statement to fix compile and build warning:
Sjoerd Meijer [Mon, 16 Sep 2019 10:30:37 +0000 (10:30 +0000)]
Added return statement to fix compile and build warning:

llvm-rtdyld.cpp:966:7: warning: variable â€˜Result’ set but not used

llvm-svn: 371972

5 years ago[clangd] Fix a crash when renaming operator.
Haojian Wu [Mon, 16 Sep 2019 10:16:56 +0000 (10:16 +0000)]
[clangd] Fix a crash when renaming operator.

Summary:
The renamelib uses a tricky way to calculate the end location by relying
on decl name, this is incorrect for the overloaded operator (the name is
"operator++" instead of "++"), which will cause out-of-file offset.

We also disable renaming operator symbol, this case is tricky, and
renamelib doesnt handle it properly.

Reviewers: ilya-biryukov

Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

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

llvm-svn: 371971

5 years ago[ELF][ARM] Fix -Werror buildbots NFC.
Peter Smith [Mon, 16 Sep 2019 10:07:53 +0000 (10:07 +0000)]
[ELF][ARM] Fix -Werror buildbots NFC.

Provide a missing initializer to get rid of warning provoking buildbot
failures.

error: missing field 'rel' initializer
[-Werror,-Wmissing-field-initializers]

llvm-svn: 371970

5 years agoChange signature of __builtin_rotateright64 back to unsigned
Karl-Johan Karlsson [Mon, 16 Sep 2019 09:52:23 +0000 (09:52 +0000)]
Change signature of __builtin_rotateright64 back to unsigned

The signature of __builtin_rotateright64 was by misstake changed from
unsigned to signed in r360863, this patch will change it back to
unsigned as intended.

This fixes pr43309

Reviewers: efriedma, hans

Reviewed By: hans

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

llvm-svn: 371969

5 years agoFix the rst doc, unbreak buildbot.
Haojian Wu [Mon, 16 Sep 2019 09:46:53 +0000 (09:46 +0000)]
Fix the rst doc, unbreak buildbot.

llvm-svn: 371968

5 years ago[SVE][Inline-Asm] Add constraints for SVE predicate registers
Kerry McLaughlin [Mon, 16 Sep 2019 09:45:27 +0000 (09:45 +0000)]
[SVE][Inline-Asm] Add constraints for SVE predicate registers

Summary:
Adds the following inline asm constraints for SVE:
  - Upl: One of the low eight SVE predicate registers, P0 to P7 inclusive
  - Upa: SVE predicate register with full range, P0 to P15

Reviewers: t.p.northover, sdesmalen, rovka, momchil.velikov, cameron.mcinally, greened, rengolin

Reviewed By: rovka

Subscribers: javed.absar, tschuett, rkruppe, psnobl, cfe-commits, llvm-commits

Tags: #llvm

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

llvm-svn: 371967

5 years agogn build: Merge r371965
Nico Weber [Mon, 16 Sep 2019 09:43:26 +0000 (09:43 +0000)]
gn build: Merge r371965

llvm-svn: 371966

5 years ago[ELF][ARM] Implement --fix-cortex-a8 to fix erratum 657417
Peter Smith [Mon, 16 Sep 2019 09:38:38 +0000 (09:38 +0000)]
[ELF][ARM] Implement --fix-cortex-a8 to fix erratum 657417

The --fix-cortex-a8 option implements a linker workaround for the
coretex-a8 erratum 657417. A summary of the erratum conditions is:
- A 32-bit Thumb-2 branch instruction B.w, Bcc.w, BL, BLX spans two
4KiB regions.
- The destination of the branch is to the first 4KiB region.
- The instruction before the branch is a 32-bit Thumb-2 non-branch
instruction.

The linker fix is to redirect the branch to a patch not in the first
4KiB region. The patch forwards the branch on to its target.

The cortex-a8, is an old CPU, with the first implementation of this
workaround in ld.bfd appearing in 2009. The cortex-a8 has been used in
early Android Phones and there are some critical applications that still
need to run on a cortex-a8 that have the erratum. The patch is applied
roughly 10 times on LLD and 20 on Clang when they are built with
--fix-cortex-a8 on an Arm system.

The formal erratum description is avaliable in the ARM Core Cortex-A8
(AT400/AT401) Errata Notice document. This is available from Arm on
request but it seems to be findable via a web search.

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

llvm-svn: 371965

5 years ago[clang-tidy] performance-inefficient-vector-operation: Support proto repeated field
Haojian Wu [Mon, 16 Sep 2019 08:54:10 +0000 (08:54 +0000)]
[clang-tidy] performance-inefficient-vector-operation: Support proto repeated field

Summary:
Finds calls that add element to protobuf repeated field in a loop
without calling Reserve() before the loop. Calling Reserve() first can avoid
unnecessary memory reallocations.

A new option EnableProto is added to guard this feature.

Patch by Cong Liu!

Reviewers: gribozavr, alexfh, hokein, aaron.ballman

Reviewed By: hokein

Subscribers: lebedev.ri, xazax.hun, Eugene.Zelenko, cfe-commits

Tags: #clang, #clang-tools-extra

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

llvm-svn: 371963

5 years ago[test] Add -z separate-code to fix tests that ae sensitive to exact addresses after...
Fangrui Song [Mon, 16 Sep 2019 07:52:30 +0000 (07:52 +0000)]
[test] Add -z separate-code to fix tests that ae sensitive to exact addresses after r371958

llvm-svn: 371962

5 years agogn build: Merge r371959
Nico Weber [Mon, 16 Sep 2019 07:34:23 +0000 (07:34 +0000)]
gn build: Merge r371959

llvm-svn: 371961

5 years ago[AArch64] Some more FP16 FMA pattern matching
Sjoerd Meijer [Mon, 16 Sep 2019 07:32:13 +0000 (07:32 +0000)]
[AArch64] Some more FP16 FMA pattern matching

After our previous machinecombiner exercises (rL371321, rL371818, rL371833), we
were still missing a few FP16 FMA patterns.

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

llvm-svn: 371960

5 years ago[SystemZ] Merge the SystemZExpandPseudo pass into SystemZPostRewrite.
Jonas Paulsson [Mon, 16 Sep 2019 07:29:37 +0000 (07:29 +0000)]
[SystemZ]  Merge the SystemZExpandPseudo pass into SystemZPostRewrite.

SystemZExpandPseudo:s only job was to expand LOCRMux instructions into jump
sequences. This needs to be done if expandLOCRPseudo() or expandSELRPseudo()
fails to find a legal opcode (all registers "high" or "low"). This task has
now been moved to SystemZPostRewrite while removing the SystemZExpandPseudo
pass.

It is in fact preferred to expand these pseudos directly after register
allocation in SystemZPostRewrite since the hinted register combinations are
then not subject to later optimizations.

Review: Ulrich Weigand
https://reviews.llvm.org/D67432

llvm-svn: 371959

5 years ago[ELF][X86] Allow PT_LOAD to have overlapping p_offset ranges on EM_X86_64
Fangrui Song [Mon, 16 Sep 2019 07:05:34 +0000 (07:05 +0000)]
[ELF][X86] Allow PT_LOAD to have overlapping p_offset ranges on EM_X86_64

Port the D64906 technique to EM_X86_64.

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

llvm-svn: 371958

5 years ago[ELF] Map the ELF header at imageBase
Fangrui Song [Mon, 16 Sep 2019 07:04:16 +0000 (07:04 +0000)]
[ELF] Map the ELF header at imageBase

If there is no readonly section, we map:

* The ELF header at imageBase+maxPageSize
* Program headers at imageBase+maxPageSize+sizeof(Ehdr)
* The first section .text at imageBase+maxPageSize+sizeof(Ehdr)+sizeof(program headers)

Due to the interaction between Writer<ELFT>::fixSectionAlignments and
LinkerScript::allocateHeaders,
`alignDown(p_vaddr(R PT_LOAD)) = alignDown(p_vaddr(RX PT_LOAD))`.
The RX PT_LOAD will override the R PT_LOAD at runtime, which is not ideal:

```
// PHDR at 0x401034, should be 0x400034
  PHDR           0x000034 0x00401034 0x00401034 0x000a0 0x000a0 R   0x4
// R PT_LOAD contains just Ehdr and program headers.
// At 0x401000, should be 0x400000
  LOAD           0x000000 0x00401000 0x00401000 0x000d4 0x000d4 R   0x1000
  LOAD           0x0000d4 0x004010d4 0x004010d4 0x00001 0x00001 R E 0x1000
```

* createPhdrs allocates the headers to the R PT_LOAD.
* fixSectionAlignments assigns `imageBase+maxPageSize+sizeof(Ehdr)+sizeof(program headers)` (formula: `alignTo(dot, maxPageSize) + dot % config->maxPageSize`) to addrExpr of .text
* allocateHeaders computes the minimum address among SHF_ALLOC sections, i.e. addr(.text)
* allocateHeaders sets address of ELF header to `addr(.text)-sizeof(Ehdr)-sizeof(program headers) = imageBase+maxPageSize`

The main observation is that when the SECTIONS command is not used, we
don't have to call allocateHeaders. This requires an assumption that
the presence of PT_PHDR and addresses of headers can be decided
regardless of address information.

This may seem natural because dot is not manipulated by a linker script.
The other thing is that we have to drop the special rule for -T<section>
in `getInitialDot`. If -Ttext is smaller than the image base, the headers
will not be allocated with the old behavior (allocateHeaders is called)
but always allocated with the new behavior.

The behavior change is not a problem. Whether and where headers are
allocated can vary among linkers, or ld.bfd across different versions
(--enable-separate-code or not). It is thus advised to use a linker
script with the PHDRS command to have a consistent behavior across
linkers. If PT_PHDR is needed, an explicit --image-base can be a simpler
alternative.

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

llvm-svn: 371957

5 years agoAMDGPU/GlobalISel: Remove illegal select tests
Matt Arsenault [Mon, 16 Sep 2019 04:21:10 +0000 (04:21 +0000)]
AMDGPU/GlobalISel: Remove illegal select tests

These fail in a release build.

llvm-svn: 371955

5 years agoAMDGPU/GlobalISel: Select SMRD loads for more types
Matt Arsenault [Mon, 16 Sep 2019 00:54:07 +0000 (00:54 +0000)]
AMDGPU/GlobalISel: Select SMRD loads for more types

llvm-svn: 371954

5 years agoAMDGPU/GlobalISel: RegBankSelect for kill
Matt Arsenault [Mon, 16 Sep 2019 00:48:37 +0000 (00:48 +0000)]
AMDGPU/GlobalISel: RegBankSelect for kill

llvm-svn: 371953

5 years agoAMDGPU/GlobalISel: Legalize s1 source G_[SU]ITOFP
Matt Arsenault [Mon, 16 Sep 2019 00:37:10 +0000 (00:37 +0000)]
AMDGPU/GlobalISel: Legalize s1 source G_[SU]ITOFP

llvm-svn: 371952

5 years agoAMDGPU/GlobalISel: Set type on vgpr live in special arguments
Matt Arsenault [Mon, 16 Sep 2019 00:33:00 +0000 (00:33 +0000)]
AMDGPU/GlobalISel: Set type on vgpr live in special arguments

Fixes assertion with workitem ID intrinsics used in non-kernel
functions.

llvm-svn: 371951

5 years agoAMDGPU/GlobalISel: Select S16->S32 fptoint
Matt Arsenault [Mon, 16 Sep 2019 00:32:56 +0000 (00:32 +0000)]
AMDGPU/GlobalISel: Select S16->S32 fptoint

llvm-svn: 371950

5 years agoAMDGPU/GlobalISel: Select s32->s16 G_[US]ITOFP
Matt Arsenault [Mon, 16 Sep 2019 00:29:12 +0000 (00:29 +0000)]
AMDGPU/GlobalISel: Select s32->s16 G_[US]ITOFP

llvm-svn: 371949

5 years agoAMDGPU/GlobalISel: Fix VALU s16 fneg
Matt Arsenault [Mon, 16 Sep 2019 00:20:54 +0000 (00:20 +0000)]
AMDGPU/GlobalISel: Fix VALU s16 fneg

llvm-svn: 371948

5 years ago[Attributor] Heap-To-Stack Conversion
Stefan Stipanovic [Sun, 15 Sep 2019 21:47:41 +0000 (21:47 +0000)]
[Attributor] Heap-To-Stack Conversion

D53362 gives a prototype heap-to-stack conversion pass. With addition of new attributes in the attributor, this can now be revisted and improved. This will place it in the Attributor to make it easier to use new attributes (eg. nofree, nosync, willreturn, etc.) and other attributor features.

Reviewers: jdoerfert, uenoku, hfinkel, efriedma

Subscribers: lebedev.ri, xbolva00, hiraditya, llvm-commits

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

llvm-svn: 371942

5 years agoCommit missing part of "Split many_tls_keys.cpp into two tests"
Kamil Rytarowski [Sun, 15 Sep 2019 21:04:50 +0000 (21:04 +0000)]
Commit missing part of "Split many_tls_keys.cpp into two tests"

https://reviews.llvm.org/D67428

This change was lost due to a file rename and modification.

llvm-svn: 371941

5 years ago[InstCombine] remove unneeded one-use checks for icmp fold
Sanjay Patel [Sun, 15 Sep 2019 20:56:34 +0000 (20:56 +0000)]
[InstCombine] remove unneeded one-use checks for icmp fold

This fold and several others were added in:
rL125734
...with no explanation for the one-use checks other than the code
comments about register pressure.

Given that this is IR canonicalization, we shouldn't be worried
about register pressure though; the backend should be able to
adjust for that as needed.

There are similar checks as noted with the TODO comments. I'm
hoping to remove those restrictions too, but if any of these
does cause a regression, it should be easier to correct by making
small, individual commits.

This is part of solving PR43310 the theoretically right way:
https://bugs.llvm.org/show_bug.cgi?id=43310
...ie, if we don't cripple basic transforms, then we won't
need to add special-case code to detect larger patterns.

llvm-svn: 371940

5 years ago[InstCombine] add icmp tests with extra uses; NFC
Sanjay Patel [Sun, 15 Sep 2019 20:13:27 +0000 (20:13 +0000)]
[InstCombine] add icmp tests with extra uses; NFC

llvm-svn: 371939

5 years ago[PowerPC][NFC] Add a testcase for fdiv expansion.
Jinsong Ji [Sun, 15 Sep 2019 20:02:25 +0000 (20:02 +0000)]
[PowerPC][NFC] Add a testcase for fdiv expansion.

Pre-commit for following patch.

llvm-svn: 371938

5 years ago[GlobalISel] findGISelOptimalMemOpLowering - remove dead initalization. NFCI.
Simon Pilgrim [Sun, 15 Sep 2019 16:56:06 +0000 (16:56 +0000)]
[GlobalISel] findGISelOptimalMemOpLowering - remove dead initalization. NFCI.

Fixes static analyzer warning that "Value stored to 'NewTySize' during its initialization is never read".

llvm-svn: 371937

5 years ago[LoadStoreVectorizer] vectorizeLoadChain - ensure we find a valid Type down the load...
Simon Pilgrim [Sun, 15 Sep 2019 16:44:35 +0000 (16:44 +0000)]
[LoadStoreVectorizer] vectorizeLoadChain - ensure we find a valid Type down the load chain. NFCI.

Silence static analyzer uninitialized variable warning by setting the LoadTy to null and then asserting we find a real value.

llvm-svn: 371936

5 years agoInterleavedLoadCombine - merge isa<> and dyn_cast<> duplicates. NFCI.
Simon Pilgrim [Sun, 15 Sep 2019 16:20:12 +0000 (16:20 +0000)]
InterleavedLoadCombine - merge isa<> and dyn_cast<> duplicates. NFCI.

Silence static analyzer null dereference warning of *dyn_cast<BinaryOperator> by merging with the isa<BinaryOperator> above.

llvm-svn: 371935

5 years ago[OpenMP] Fix OMPClauseReader::readClause() uninitialized variable warning. NFCI.
Simon Pilgrim [Sun, 15 Sep 2019 16:05:20 +0000 (16:05 +0000)]
[OpenMP] Fix OMPClauseReader::readClause() uninitialized variable warning. NFCI.

Fixes static analyzer uninitialized variable warning for the OMPClause - the function appears to cover all cases, but I've added an assertion to make sure.

llvm-svn: 371934

5 years ago[DebugInfo] Don't dereference a dyn_cast<PDBSymbolData> result. NFCI.
Simon Pilgrim [Sun, 15 Sep 2019 15:38:26 +0000 (15:38 +0000)]
[DebugInfo] Don't dereference a dyn_cast<PDBSymbolData> result. NFCI.

The static analyzer is warning about a potential null dereference - but as we're in DataMemberLayoutItem we should be able to guarantee that the Symbol is a PDBSymbolData type, allowing us to use cast<PDBSymbolData> - and if not assert will fire for us.

llvm-svn: 371933

5 years ago[ARM] Masked loads and stores
David Green [Sun, 15 Sep 2019 14:14:47 +0000 (14:14 +0000)]
[ARM] Masked loads and stores

Masked loads and store fit naturally with MVE, the instructions being easily
predicated. This adds lowering for the simple cases of masked loads and stores.
It does not yet deal with widening/narrowing or pre/post inc, and so is
currently behind an option.

The llvm masked load intrinsic will accept a "passthru" value, dictating the
values used for the zero masked lanes. In MVE the instructions write 0 to the
zero predicated lanes, so we need to match a passthru that isn't 0 (or undef)
with a select instruction to pull in the correct data after the load.

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

llvm-svn: 371932

5 years ago[SLP] limit vectorization of Constant subclasses (PR33958)
Sanjay Patel [Sun, 15 Sep 2019 13:03:24 +0000 (13:03 +0000)]
[SLP] limit vectorization of Constant subclasses (PR33958)

This is a fix for:
https://bugs.llvm.org/show_bug.cgi?id=33958

It seems universally true that we would not want to transform this kind of
sequence on any target, but if that's not correct, then we could view this
as a target-specific cost model problem. We could also white-list ConstantInt,
ConstantFP, etc. rather than blacklist Global and ConstantExpr.

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

llvm-svn: 371931

5 years ago[ARM] Simplify and update vmla test. NFC
David Green [Sun, 15 Sep 2019 11:53:05 +0000 (11:53 +0000)]
[ARM] Simplify and update vmla test. NFC

llvm-svn: 371930

5 years ago[CodeEmitter] Improve testing for APInt encoding
James Molloy [Sun, 15 Sep 2019 08:44:40 +0000 (08:44 +0000)]
[CodeEmitter] Improve testing for APInt encoding

I missed Artem's comment in D67487 before committing.

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

llvm-svn: 371929

5 years ago[CodeEmitter] Support instruction widths > 64 bits
James Molloy [Sun, 15 Sep 2019 08:35:08 +0000 (08:35 +0000)]
[CodeEmitter] Support instruction widths > 64 bits

Some VLIW instruction sets are Very Long Indeed. Using uint64_t constricts the Inst encoding to 64 bits (naturally).

This change switches CodeEmitter to a mode that uses APInts when Inst's bitwidth is > 64 bits (NFC for existing targets).

When Inst.BitWidth > 64 the prototype changes to:

  void TargetMCCodeEmitter::getBinaryCodeForInstr(const MCInst &MI,
                                                  SmallVectorImpl<MCFixup> &Fixups,
                                                  APInt &Inst,
                                                  APInt &Scratch,
                                                  const MCSubtargetInfo &STI);

The Inst parameter returns the encoded instruction, the Scratch parameter is used internally for manipulating operands and is exposed so that the underlying storage can be reused between calls to getBinaryCodeForInstr. The goal is to elide any APInt constructions that we can.

Similarly the operand encoding prototype changes to:

  getMachineOpValue(const MCInst &MI, const MCOperand &MO, APInt &op, SmallVectorImpl<MCFixup> &Fixups, const MCSubtargetInfo &STI);

That is, the operand is passed by reference as APInt rather than returned as uint64_t.

To reiterate, this APInt mode is enabled only when Inst.BitWidth > 64, so this change is NFC for existing targets.

llvm-svn: 371928

5 years agolld-link: Make Options.td formatting more self-consistent.
Nico Weber [Sat, 14 Sep 2019 23:41:42 +0000 (23:41 +0000)]
lld-link: Make Options.td formatting more self-consistent.

Also tighten up help strings for /force, --start-lib, and --end-lib.

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

llvm-svn: 371927

5 years agocompiler-rt/builtins: Make check-builtins run tests on macOS.
Nico Weber [Sat, 14 Sep 2019 22:22:47 +0000 (22:22 +0000)]
compiler-rt/builtins: Make check-builtins run tests on macOS.

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

llvm-svn: 371926

5 years agoAdd debug check for null pointers passed to <string_view>
Eric Fiselier [Sat, 14 Sep 2019 19:55:28 +0000 (19:55 +0000)]
Add debug check for null pointers passed to <string_view>

llvm-svn: 371925

5 years ago[Diagnostics] Added silence note for -Wsizeof-array-div; suggest extra parens
David Bolvansky [Sat, 14 Sep 2019 19:38:55 +0000 (19:38 +0000)]
[Diagnostics] Added silence note for -Wsizeof-array-div; suggest extra parens

llvm-svn: 371924

5 years ago[TargetLowering] SimplifyDemandedBits - add EXTRACT_SUBVECTOR support.
Simon Pilgrim [Sat, 14 Sep 2019 16:38:26 +0000 (16:38 +0000)]
[TargetLowering] SimplifyDemandedBits - add EXTRACT_SUBVECTOR support.

Call SimplifyDemandedBits on the source vector.

llvm-svn: 371923

5 years ago[lldb] Code cleanup: FormattersContainer.h: Use range-based for loops.
Jan Kratochvil [Sat, 14 Sep 2019 15:46:51 +0000 (15:46 +0000)]
[lldb] Code cleanup: FormattersContainer.h: Use range-based for loops.

Suggested for an other loop by Pavel Labath in:
https://reviews.llvm.org/D66654#inline-605808

llvm-svn: 371922

5 years ago[InstSimplify] simplifyUnsignedRangeCheck(): handle few tautological cases (PR43251)
Roman Lebedev [Sat, 14 Sep 2019 13:47:27 +0000 (13:47 +0000)]
[InstSimplify] simplifyUnsignedRangeCheck(): handle few tautological cases (PR43251)

Summary:
This is split off from D67356, since these cases produce a constant,
no real need to keep them in instcombine.

Alive proofs:
https://rise4fun.com/Alive/u7Fk
https://rise4fun.com/Alive/4lV

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

Reviewers: spatel, nikic, xbolva00

Reviewed By: spatel

Subscribers: hiraditya, llvm-commits

Tags: #llvm

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

llvm-svn: 371921

5 years ago[clang-scan-deps] Add -M to work around -MT issue after r371918
Fangrui Song [Sat, 14 Sep 2019 07:25:27 +0000 (07:25 +0000)]
[clang-scan-deps] Add -M to work around -MT issue after r371918

gcc will complain if -MT is used but neither -M nor -MM is specified:

> cc1: error: to generate dependencies you must specify either -M or -MM

r371918 changed our behavior to match GCC, but apparently
clang-scan-deps is not happy.

llvm-svn: 371920

5 years ago[Driver] Fix multiple bugs related to dependency file options: -M -MM -MD -MMD -MT -MQ
Fangrui Song [Sat, 14 Sep 2019 06:01:22 +0000 (06:01 +0000)]
[Driver] Fix multiple bugs related to dependency file options: -M -MM -MD -MMD -MT -MQ

-M -o test.i => dependency file is test.d, not test.i
-MM -o test.i => dependency file is test.d, not test.i
-M -MMD => bogus warning -Wunused-command-line-argument
-M MT dummy => -w not rendered

llvm-svn: 371918

5 years ago[Driver] Improve Clang::getDependencyFileName and its tests after rC371853
Fangrui Song [Sat, 14 Sep 2019 04:13:15 +0000 (04:13 +0000)]
[Driver] Improve Clang::getDependencyFileName and its tests after rC371853

The test file name metadata-with-dots.c is confusing because -MD and -MMD
have nothing to do with metadata.

llvm-svn: 371917

5 years ago[ScheduleDAGMILive] Fix typo in comment.
Mingjie Xing [Sat, 14 Sep 2019 03:27:38 +0000 (03:27 +0000)]
[ScheduleDAGMILive] Fix typo in comment.

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

llvm-svn: 371916

5 years ago[Attributor][Fix] Use right type to replace expressions
Johannes Doerfert [Sat, 14 Sep 2019 02:57:50 +0000 (02:57 +0000)]
[Attributor][Fix] Use right type to replace expressions

Summary: This should be obsolete once the functionality in D66967 is integrated.

Reviewers: uenoku, sstefan1

Subscribers: hiraditya, bollu, llvm-commits

Tags: #llvm

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

llvm-svn: 371915

5 years ago[llvm-objcopy] Ignore -B --binary-architecture=
Fangrui Song [Sat, 14 Sep 2019 01:36:31 +0000 (01:36 +0000)]
[llvm-objcopy] Ignore -B --binary-architecture=

GNU objcopy documents that -B is only useful with architecture-less
input (i.e. "binary" or "ihex"). After D67144, -O defaults to -I, and
-B is essentially a NOP.

* If -O is binary/ihex, GNU objcopy ignores -B.
* If -O is elf*, -B provides the e_machine field in GNU objcopy.

So to convert a blob to an ELF, `-I binary -B i386:x86-64 -O elf64-x86-64` has to be specified.

`-I binary -B i386:x86-64 -O elf64-x86-64` creates an ELF with its
e_machine field set to EM_NONE in GNU objcopy, but a regular x86_64 ELF
in elftoolchain elfcopy. Follow the elftoolchain approach (ignoring -B)
to simplify code. Users that expect their command line portable should
specify -B.

Reviewed By: jhenderson

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

llvm-svn: 371914

5 years ago[llvm-objcopy] Default --output-target to --input-target when unspecified
Fangrui Song [Sat, 14 Sep 2019 01:36:16 +0000 (01:36 +0000)]
[llvm-objcopy] Default --output-target to --input-target when unspecified

Fixes PR42171.

In GNU objcopy, if -O (--output-target) is not specified, the value is
copied from -I (--input-target).

```
objcopy -I binary -B i386:x86-64 a.txt b       # b is copied from a.txt
llvm-objcopy -I binary -B i386:x86-64 a.txt b  # b is an x86-64 object file
```

This patch changes our behavior to match GNU. With this change, we can
delete code related to -B handling (D67215).

Reviewed By: jakehehrlich

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

llvm-svn: 371913

5 years ago[llvm-ar] Uncapitalize error messages and delete full stop
Fangrui Song [Sat, 14 Sep 2019 01:18:47 +0000 (01:18 +0000)]
[llvm-ar] Uncapitalize error messages and delete full stop

Most GNU binutils don't append full stops in error messages. This
convention has been adopted by a bunch of LLVM binary utilities. Make
llvm-ar follow the convention as well.

Reviewed By: grimar

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

llvm-svn: 371912

5 years ago[llvm-objcopy] Add support for response files in llvm-strip and llvm-objcopy
Michael Pozulp [Sat, 14 Sep 2019 01:14:43 +0000 (01:14 +0000)]
[llvm-objcopy] Add support for response files in llvm-strip and llvm-objcopy

Summary: Addresses https://bugs.llvm.org/show_bug.cgi?id=42671

Reviewers: jhenderson, espindola, alexshap, rupprecht

Reviewed By: jhenderson

Subscribers: seiya, emaste, arichardson, jakehehrlich, MaskRay, abrachet, llvm-commits

Tags: #llvm

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

llvm-svn: 371911

5 years agoBugpoint: Remove some unnecessary c_str conversions on the journey to StringRef
David Blaikie [Sat, 14 Sep 2019 00:32:13 +0000 (00:32 +0000)]
Bugpoint: Remove some unnecessary c_str conversions on the journey to StringRef

llvm-svn: 371910

5 years ago[Reproducer] Add reproducer dump command.
Jonas Devlieghere [Fri, 13 Sep 2019 23:27:31 +0000 (23:27 +0000)]
[Reproducer] Add reproducer dump command.

This adds a reproducer dump commands which makes it possible to inspect
a reproducer from inside LLDB. Currently it supports the Files, Commands
and Version providers. I'm planning to add support for the GDB Remote
provider in a follow-up patch.

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

llvm-svn: 371909

5 years ago[Reproducer] Move GDB Remote Packet into Utility. (NFC)
Jonas Devlieghere [Fri, 13 Sep 2019 23:14:10 +0000 (23:14 +0000)]
[Reproducer] Move GDB Remote Packet into Utility. (NFC)

To support dumping the reproducer's GDB remote packets, we need the
(de)serialization logic to live in Utility rather than the GDB remote
plugin. This patch renames StreamGDBRemote to GDBRemote and moves the
relevant packet code there.

Its uses in the GDBRemoteCommunicationHistory and the
GDBRemoteCommunicationReplayServer are updated as well.

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

llvm-svn: 371907

5 years ago[WebAssembly] Narrowing and widening SIMD ops
Thomas Lively [Fri, 13 Sep 2019 22:54:41 +0000 (22:54 +0000)]
[WebAssembly] Narrowing and widening SIMD ops

Summary:
Implements target-specific LLVM intrinsics and clang builtins for
these new SIMD operations, as described at https://github.com/WebAssembly/simd/blob/master/proposals/simd/SIMD.md#integer-to-integer-narrowing.

Reviewers: aheejin

Subscribers: dschuff, sbc100, jgravelle-google, hiraditya, sunfish, cfe-commits, llvm-commits

Tags: #clang, #llvm

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

llvm-svn: 371906

5 years ago[test] Update TestAPILog to pass on Windows.
Jonas Devlieghere [Fri, 13 Sep 2019 22:14:59 +0000 (22:14 +0000)]
[test] Update TestAPILog to pass on Windows.

The pretty function macro is including __cdecl on Windows, which was
causing the pattern matching to fail. This should fix that.

llvm-svn: 371905

5 years agoMake test check position independent as they sometimes come out reversed. NFCI.
Douglas Yung [Fri, 13 Sep 2019 22:12:27 +0000 (22:12 +0000)]
Make test check position independent as they sometimes come out reversed. NFCI.

llvm-svn: 371904

5 years ago[clang-scan-deps] Fix for headers having the same name as a directory
Alex Lorenz [Fri, 13 Sep 2019 22:12:02 +0000 (22:12 +0000)]
[clang-scan-deps] Fix for headers having the same name as a directory

Scan deps tool crashes when called on a C++ file, containing an include
that has the same name as a directory.
The tool crashes since it finds foo/dir and tries to read that as a file and fails.

Patch by: kousikk (Kousik Kumar)

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

llvm-svn: 371903

5 years ago[LLDB] Add missing breaks for switch statement
Tim Shen [Fri, 13 Sep 2019 22:00:03 +0000 (22:00 +0000)]
[LLDB] Add missing breaks for switch statement

llvm-svn: 371902

5 years ago[GlobalISel] Fix insertion point of new instructions to be after PHIs.
Amara Emerson [Fri, 13 Sep 2019 21:49:24 +0000 (21:49 +0000)]
[GlobalISel] Fix insertion point of new instructions to be after PHIs.

For some reason we sometimes insert new instructions one instruction before
the first non-PHI when legalizing. This can result in having non-PHI
instructions before PHIs, which mean that PHI elimination doesn't catch them.

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

llvm-svn: 371901

5 years ago[NFC][libLTO] Rearrange declaration in lto.h
Steven Wu [Fri, 13 Sep 2019 21:19:12 +0000 (21:19 +0000)]
[NFC][libLTO] Rearrange declaration in lto.h

Summary:
Rearrange the function declaration in lto.h so they falls in the correct
doxygen group.

Reviewers: tejohnson, bd1976llvm, deadalnix

Reviewed By: tejohnson

Subscribers: mehdi_amini, inglorion, jkorous, dexonsmith, ributzka, llvm-commits

Tags: #llvm

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

llvm-svn: 371900

5 years ago[test] Print the log output on failure.
Jonas Devlieghere [Fri, 13 Sep 2019 21:15:03 +0000 (21:15 +0000)]
[test] Print the log output on failure.

This ensures that if the assertion fails we dump the log content. This
should help me investigate what the output looks like on Windows, where
the test is failing.

llvm-svn: 371899

5 years agoAdd dependency from Orc to Passes
Sanjoy Das [Fri, 13 Sep 2019 21:07:56 +0000 (21:07 +0000)]
Add dependency from Orc to Passes

Summary: Orc uses registerFunctionAnalyses that's defined in Passes.

Reviewers: dblaikie

Subscribers: mcrosier, bixia, llvm-commits

Tags: #llvm

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

llvm-svn: 371898

5 years agoFix test to use %t for newly created files.
Tim Shen [Fri, 13 Sep 2019 21:06:47 +0000 (21:06 +0000)]
Fix test to use %t for newly created files.

This is both for consistency with other `mkdir`s in tests, and
fixing permission issues with the non-temporary cwd during testing (they
are not always writable).

llvm-svn: 371897

5 years ago[llvm-opt-report] Improve error handling
Francis Visoiu Mistrih [Fri, 13 Sep 2019 20:52:04 +0000 (20:52 +0000)]
[llvm-opt-report] Improve error handling

* std::move the error extracted from the parsing creation to avoid asserts
* print a newline after the error message
* create the parser from the metadata

llvm-svn: 371895

5 years agoFix C++03 build failures due to >>
Eric Fiselier [Fri, 13 Sep 2019 20:30:45 +0000 (20:30 +0000)]
Fix C++03 build failures due to >>

llvm-svn: 371894

5 years ago[AArch64][GlobalISel] Tail call memory intrinsics
Jessica Paquette [Fri, 13 Sep 2019 20:25:58 +0000 (20:25 +0000)]
[AArch64][GlobalISel] Tail call memory intrinsics

Because memory intrinsics are handled differently than other calls, we need to
check them for tail call eligiblity in the legalizer. This allows us to still
inline them when it's beneficial to do so, but also tail call when possible.

This adds simple tail calling support for when the intrinsic is followed by a
return.

It ports the attribute checks from `TargetLowering::isInTailCallPosition` into
a similarly-named function in LegalizerHelper.cpp. The target-specific
`isUsedByReturnOnly` hook is not ported here.

Update tailcall-mem-intrinsics.ll to show that GlobalISel can now tail call
memory intrinsics.

Update legalize-memcpy-et-al.mir to have a case where we don't tail call.

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

llvm-svn: 371893

5 years ago[OPENMP5.0]Add basic support for declare variant directive.
Alexey Bataev [Fri, 13 Sep 2019 20:18:17 +0000 (20:18 +0000)]
[OPENMP5.0]Add basic support for declare variant directive.

Added basic support for declare variant directive and its match clause
with user context selector.

llvm-svn: 371892