platform/upstream/llvm.git
4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 years ago[Support] Add overload writeFileAtomically(std::function Writer)
Jan Korous [Fri, 13 Sep 2019 20:08:27 +0000 (20:08 +0000)]
[Support] Add overload writeFileAtomically(std::function Writer)

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

llvm-svn: 371890

4 years ago[Docs] Bug fix for reference to nonexistent document
DeForest Richards [Fri, 13 Sep 2019 20:05:57 +0000 (20:05 +0000)]
[Docs] Bug fix for reference to nonexistent document

This commit fixes a bug in which the toctree contained a reference to a non-existent document.

llvm-svn: 371889

4 years ago[FPEnv] Document that constrained FP intrinsics cannot be mixed with non-constrained
Kevin P. Neal [Fri, 13 Sep 2019 19:36:19 +0000 (19:36 +0000)]
[FPEnv] Document that constrained FP intrinsics cannot be mixed with non-constrained

Reviewed by: andrew.w.kaylor, cameron.mcinally, uweigand
Approved by: andrew.w.kaylor
Differential Revision: https://reviews.llvm.org/D67360

llvm-svn: 371888

4 years ago[aarch64] move custom isel of extract_vector_elt to td file - NFC
Sebastian Pop [Fri, 13 Sep 2019 19:28:30 +0000 (19:28 +0000)]
[aarch64] move custom isel of extract_vector_elt to td file - NFC

In preparation for def-pat selection of dot product instructions,
this patch moves the custom instruction selection of extract_vector_elt
to the td file. Without this change it is impossible to catch a pattern that
starts with an extract_vector_elt: the custom cpp code is executed first
ahead of the patterns in the td files that are only executed at the end of
the switch statement in SelectCode(Node).

With this patch applied, it becomes possible to select a different pattern
that starts with extract_vector_elt by selecting a higher complexity than
this pattern.

The patch has been tested on aarch64-linux with make check-all.

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

llvm-svn: 371887

4 years agoMark [[nodiscard]] test as unsupported with GCC 5
Eric Fiselier [Fri, 13 Sep 2019 19:09:29 +0000 (19:09 +0000)]
Mark [[nodiscard]] test as unsupported with GCC 5

llvm-svn: 371886

4 years ago[Reproducer] Include the this pointer in the API log.
Jonas Devlieghere [Fri, 13 Sep 2019 19:08:10 +0000 (19:08 +0000)]
[Reproducer] Include the this pointer in the API log.

The new centralized way of doing API logging through the reproducer
macros is lacking a way to easily correlate instances of API objects.
Logging the this pointer makes that significantly easier. For methods
this is now always passed as the first argument, similar to the self
argument in Python.

This patch also adds a test case for API logging, which uncovered that
we were not quoting strings.

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

llvm-svn: 371885

4 years agoFix pretty printer test with GCC
Eric Fiselier [Fri, 13 Sep 2019 19:04:33 +0000 (19:04 +0000)]
Fix pretty printer test with GCC

llvm-svn: 371884

4 years agoAArch64: fix EXPENSIVE_CHECKS for arm64_32.
Tim Northover [Fri, 13 Sep 2019 18:55:38 +0000 (18:55 +0000)]
AArch64: fix EXPENSIVE_CHECKS for arm64_32.

For some reason I'd decided to mark the end-result of a GOT load as
dead. It's clearly not (necessarily).

llvm-svn: 371883

4 years agoFix error in ProcessLauncherWindows.cpp
Adrian McCarthy [Fri, 13 Sep 2019 18:50:39 +0000 (18:50 +0000)]
Fix error in ProcessLauncherWindows.cpp

Restored missing parens on a function call.

llvm-svn: 371882

4 years agoUpdate XFAIL list for new GCC versions
Eric Fiselier [Fri, 13 Sep 2019 18:43:29 +0000 (18:43 +0000)]
Update XFAIL list for new GCC versions

llvm-svn: 371881

4 years agoFix various test failures with GCC
Eric Fiselier [Fri, 13 Sep 2019 18:40:46 +0000 (18:40 +0000)]
Fix various test failures with GCC

llvm-svn: 371880

4 years ago[SLP] add test for vectorization of constant expressions; NFC
Sanjay Patel [Fri, 13 Sep 2019 18:33:02 +0000 (18:33 +0000)]
[SLP] add test for vectorization of constant expressions; NFC

Goes with D67362.

llvm-svn: 371879

4 years agoReland r371785: Add -Wpoison-system-directories warning
Manoj Gupta [Fri, 13 Sep 2019 18:00:51 +0000 (18:00 +0000)]
Reland r371785: Add -Wpoison-system-directories warning

When using clang as a cross-compiler, we should not use system
headers to do the compilation.
This CL adds support of a new warning flag -Wpoison-system-directories which
emits warnings if --sysroot is set and headers from common host system location
are used.
By default the warning is disabled.

The intention of the warning is to catch bad includes which are usually
generated by third party build system not targeting cross-compilation.
Such cases happen in Chrome OS when someone imports a new package or upgrade
one to a newer version from upstream.

This is reland of r371785 with a fix to test file.

Patch by: denik (Denis Nikitin)

llvm-svn: 371878

4 years ago[NFC][InstSimplify] Add some more tests for D67498/D67502
Roman Lebedev [Fri, 13 Sep 2019 17:58:24 +0000 (17:58 +0000)]
[NFC][InstSimplify] Add some more tests for D67498/D67502

llvm-svn: 371877

4 years agoFix build error in 371875
Erich Keane [Fri, 13 Sep 2019 17:56:38 +0000 (17:56 +0000)]
Fix build error in 371875

Apparently Clang complains about the name hiding here in a way that my
GCC build does not, so a shocking number of buildbots decided to tell me
about it.  Change the name of the variable to prevent the name hiding
and hope we don't have to fix this again.

llvm-svn: 371876

4 years ago[NFCI]Create CommonAttributeInfo Type as base type of *Attr and ParsedAttr.
Erich Keane [Fri, 13 Sep 2019 17:39:31 +0000 (17:39 +0000)]
[NFCI]Create CommonAttributeInfo Type as base type of *Attr and ParsedAttr.

In order to enable future improvements to our attribute diagnostics,
this moves info from ParsedAttr into CommonAttributeInfo, then makes
this type the base of the *Attr and ParsedAttr types. Quite a bit of
refactoring took place, including removing a bunch of redundant Spelling
Index propogation.

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

llvm-svn: 371875

4 years agoFix failing negative compilation test for some versions of Clang
Eric Fiselier [Fri, 13 Sep 2019 17:39:06 +0000 (17:39 +0000)]
Fix failing negative compilation test for some versions of Clang

llvm-svn: 371874

4 years agoRevert for: [AMDGPU]: PHI Elimination hooks added for custom COPY insertion.
Alexander Timofeev [Fri, 13 Sep 2019 17:37:30 +0000 (17:37 +0000)]
Revert for: [AMDGPU]: PHI Elimination hooks added for custom COPY insertion.

llvm-svn: 371873

4 years agoFix bug in `darwin_test_archs()` when the cache variable is set but empty.
Dan Liew [Fri, 13 Sep 2019 17:31:24 +0000 (17:31 +0000)]
Fix bug in `darwin_test_archs()` when the cache variable is set but empty.

Summary:
If the cache variable named in `${valid_archs}` (e.g. `DARWIN_osx_BUILTIN_ARCHS`)
is set in the cache but is empty then the cache check
`if(${valid_archs})` will be false so the function will probe the
compiler but the `set(...)` command at the end of the function to update
the cache variable will be a no-op. This is because `set(...)` will not
update an existing cache variable unless the `FORCE` argument is
provided.

To fix this this patch adds `FORCE` so the cache is always updated.

rdar://problem/55323665

Reviewers: vsk, kubamracek

Subscribers: mgorny, #sanitizers, llvm-commits

Tags: #llvm, #sanitizers

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

llvm-svn: 371872

4 years ago[CMake] Separate the detection Darwin platforms architectures for the
Dan Liew [Fri, 13 Sep 2019 17:31:22 +0000 (17:31 +0000)]
[CMake] Separate the detection Darwin platforms architectures for the
built-ins from the rest of compiler-rt.

The detection of supported platform (os) architectures for Darwin relies
on the `darwin_test_archs()` CMake function. This is used both for
building the builtins (`builtin-config-ix.cmake`) and for the rest of
the compiler-rt (`config-ix.cmake`).

`darwin_test_archs()`  implements a cache, presumably to speed up CMake
re-configures.  Unfortunately this caching is buggy because it depends
on external global state (i.e. the `TEST_COMPILE_ONLY` variable) and
this is not taken into account. For `config-ix.cmake`
`TEST_COMPILE_ONLY` is not set and for `builtin-config-ix.cmake`
`TEST_COMPILE_ONLY` is set to `On`.  This makes the
`darwin_test_archs()` function racey in the sense that a call from one
calling context will poison the cache for the other calling context.

This is actually an issue George Karpenkov discovered a while back
and had an incomplete patch for (https://reviews.llvm.org/D45337)
but this was never merged.

To workaround this, this patch switches to using a different set of
variables for the platform architecture builtins, i.e.
`DARWIN_<OS>_ARCHS` -> `DARWIN_<OS>_BUILTIN_ARCHS`. This avoids the
cache poisoning problem because the cached variable names are different.
This also has the advantage that the the configured architectures for
builtins and the rest of the compiler-rt are now independent and
can be set differently if necessary.

Note in `darwin_test_archs()` we also now pass `-w` to the compiler
because `try_compile_only()` treats compiler warnings as errors.  This
was extremely fragile because compiler warnings (can easily appear due
to a buggy compiler or SDK headers) would cause compiler-rt to think an
architecture on Darwin wasn't supported.

rdar://problem/48637491

llvm-svn: 371871

4 years ago[Remarks][NFC] Forward declare ParsedStringTable
Francis Visoiu Mistrih [Fri, 13 Sep 2019 17:27:28 +0000 (17:27 +0000)]
[Remarks][NFC] Forward declare ParsedStringTable

llvm-svn: 371870

4 years ago[Remarks][NFC] Use StringLiteral for magic numbers
Francis Visoiu Mistrih [Fri, 13 Sep 2019 16:46:23 +0000 (16:46 +0000)]
[Remarks][NFC] Use StringLiteral for magic numbers

llvm-svn: 371869