platform/upstream/llvm.git
6 years ago[WebAssembly] Error if both --export-table and --import-table are specified.
Rui Ueyama [Fri, 30 Mar 2018 16:06:14 +0000 (16:06 +0000)]
[WebAssembly] Error if both --export-table and --import-table are specified.

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

llvm-svn: 328873

6 years ago[SelectionDAG] Removing FABS folding from DAGCombiner
Sanjay Patel [Fri, 30 Mar 2018 15:42:52 +0000 (15:42 +0000)]
[SelectionDAG] Removing FABS folding from DAGCombiner

The code has bugs dealing with -0.0.

Since D44550 introduced FABS pattern folding in InstCombine,
this patch removes the now-redundant code that causes
https://bugs.llvm.org/show_bug.cgi?id=36600.

Patch by Mikhail Dvoretckii!

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

llvm-svn: 328872

6 years ago[clang-format] Ensure wrapped ObjC selectors with 1 arg obey IndentWrappedFunctionNames
Ben Hamilton [Fri, 30 Mar 2018 15:38:45 +0000 (15:38 +0000)]
[clang-format] Ensure wrapped ObjC selectors with 1 arg obey IndentWrappedFunctionNames

Summary:
In D43121, @Typz introduced logic to avoid indenting 2-or-more
argument ObjC selectors too far to the right if the first component
of the selector was longer than the others.

This had a small side effect of causing wrapped ObjC selectors with
exactly 1 argument to not obey IndentWrappedFunctionNames:

```
- (aaaaaaaaaa)
aaaaaaaaaa;
```

This diff fixes the issue by ensuring we align wrapped 1-argument
ObjC selectors correctly:

```
- (aaaaaaaaaa)
    aaaaaaaaaa;
```

Test Plan: New tests added. Test failed before change, passed
  after change. Ran tests with:
  % make -j12 FormatTests && ./tools/clang/unittests/Format/FormatTests

Reviewers: djasper, klimek, Typz, jolesiak

Reviewed By: djasper, jolesiak

Subscribers: cfe-commits, Typz

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

llvm-svn: 328871

6 years ago[Hexagon] Recognize and handle :endloop01
Krzysztof Parzyszek [Fri, 30 Mar 2018 15:29:47 +0000 (15:29 +0000)]
[Hexagon] Recognize and handle :endloop01

llvm-svn: 328870

6 years ago[Hexagon] Fix printing :mem_noshuf on compiler-generated packets
Krzysztof Parzyszek [Fri, 30 Mar 2018 15:09:05 +0000 (15:09 +0000)]
[Hexagon] Fix printing :mem_noshuf on compiler-generated packets

llvm-svn: 328869

6 years ago[Hexagon] Fix flags for store-related intrinsics
Krzysztof Parzyszek [Fri, 30 Mar 2018 14:57:01 +0000 (14:57 +0000)]
[Hexagon] Fix flags for store-related intrinsics

llvm-svn: 328868

6 years ago[X86][BtVer2] Add missing ReadAfterLd to RM variants of AVX horizontal adds and
Andrea Di Biagio [Fri, 30 Mar 2018 14:48:08 +0000 (14:48 +0000)]
[X86][BtVer2] Add missing ReadAfterLd to RM variants of AVX horizontal adds and
most vector logic instructions.

Fixed a few InstRW that forgot to specify a ReadAfterLd for the register input
operand.

llvm-svn: 328867

6 years ago[Hexagon] Remove unused scheduling classes
Krzysztof Parzyszek [Fri, 30 Mar 2018 14:34:32 +0000 (14:34 +0000)]
[Hexagon] Remove unused scheduling classes

llvm-svn: 328866

6 years ago[X86][BtVer2] Add tests that show how ReadAfterLd is missing for some
Andrea Di Biagio [Fri, 30 Mar 2018 14:29:33 +0000 (14:29 +0000)]
[X86][BtVer2] Add tests that show how ReadAfterLd is missing for some
instructions.

In the Btver2 model, there are a few InstRW overrides that don't specify a
ReadAfterLd for the register input operand.

As a result, a few AVX variants of horizontal operations and most vector logic
operations with a folded memory operand don't have a ReadAdvance info associated
to their input register operands.

llvm-svn: 328865

6 years ago[Hexagon] Pass pointer to SelectionDAG to dump functions
Krzysztof Parzyszek [Fri, 30 Mar 2018 14:29:15 +0000 (14:29 +0000)]
[Hexagon] Pass pointer to SelectionDAG to dump functions

llvm-svn: 328864

6 years agoSimplify test more.
Nico Weber [Fri, 30 Mar 2018 13:48:11 +0000 (13:48 +0000)]
Simplify test more.

llvm-svn: 328863

6 years agoSimplify test.
Nico Weber [Fri, 30 Mar 2018 13:44:15 +0000 (13:44 +0000)]
Simplify test.

As of rL215127, FileCheck has an -allow-empty flag,
so this could be used instead of writing a dummy line.
But it looks like the log is never empty now, so not
even that is needed.

llvm-svn: 328862

6 years ago[X86] Add llvm-mca tests for r328834.
Andrea Di Biagio [Fri, 30 Mar 2018 13:38:37 +0000 (13:38 +0000)]
[X86] Add llvm-mca tests for r328834.

Verify that the ReadAfterLd is correctly applied to FMA and 4-ops variable blend
instructions.

As Craig pointed out in D44726, some Intel models still have to be fixed.

llvm-svn: 328861

6 years ago[analyzer] Remove the unused method declaration in `ValistChecker.cpp`.
Henry Wong [Fri, 30 Mar 2018 13:37:50 +0000 (13:37 +0000)]
[analyzer] Remove the unused method declaration in `ValistChecker.cpp`.

Summary: `getVariableNameFromRegion()` seems useless.

Reviewers: xazax.hun, george.karpenkov

Reviewed By: xazax.hun

Subscribers: szepet, rnkovacs, a.sidorin, cfe-commits, MTC

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

llvm-svn: 328860

6 years ago[X86] Add tests to verify the presence of "ReadAfterLd" after r328823.
Andrea Di Biagio [Fri, 30 Mar 2018 11:44:48 +0000 (11:44 +0000)]
[X86] Add tests to verify the presence of "ReadAfterLd" after r328823.

This change adds a couple of tests to verify the change introduced by revision
328823 ([X86] Correct the placement of ReadAfterLd in BEXTR and BZHI).

llvm-svn: 328859

6 years agoRevert "[LLVM-C] Finish exception instruction bindings"
Vlad Tsyrklevich [Fri, 30 Mar 2018 06:21:28 +0000 (06:21 +0000)]
Revert "[LLVM-C] Finish exception instruction bindings"

This reverts commit r328759. It was causing LSan failures on sanitizer-x86_64-linux-bootstrap

llvm-svn: 328858

6 years ago[Modules] Improve fixit for framework private module maps
Bruno Cardoso Lopes [Fri, 30 Mar 2018 05:17:58 +0000 (05:17 +0000)]
[Modules] Improve fixit for framework private module maps

The wrong source range was being provided in some case, fix that to get
a better fixit.

rdar://problem/38520199

llvm-svn: 328857

6 years ago[AMDGPU] Fix the SDWA Peephole phase to handle src for dst:UNUSED_PRESERVE.
Michael Bedy [Fri, 30 Mar 2018 05:03:36 +0000 (05:03 +0000)]
[AMDGPU] Fix the SDWA Peephole phase to handle src for dst:UNUSED_PRESERVE.

Summary:
The phase attempts to transform operations that extract a portion of a value
into an SDWA src operand in cases where that value is used only once. It
was not prepared for this use to be the preserved portion of a value for
dst:UNUSED_PRESERVE, resulting in a crash or assert.

This change either rejects the illegal SDWA attempt, or in the case where
dst:WORD_1 and the src_sel would be WORD_0, removes the unneeded
extract instruction.

Reviewers: arsenm, #amdgpu

Reviewed By: arsenm, #amdgpu

Subscribers: arsenm, kzhuravl, wdng, nhaehnle, yaxunl, dstuttard, tpr, t-tye, llvm-commits

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

llvm-svn: 328856

6 years ago[Hexagon] add missing lit config file
Ikhlas Ajbar [Fri, 30 Mar 2018 03:32:24 +0000 (03:32 +0000)]
[Hexagon] add missing lit config file

llvm-svn: 328855

6 years agopeel loops with runtime small trip counts
Ikhlas Ajbar [Fri, 30 Mar 2018 03:05:34 +0000 (03:05 +0000)]
peel loops with runtime small trip counts

For Hexagon, peeling loops with small runtime trip count is beneficial for our
benchmarks. We set PeelCount in HexagonTargetInfo.cpp and we use PeelCount set
by the target for computing the desired peel count.

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

llvm-svn: 328854

6 years agoAdding UNSUPPORTED: system-windows at George's request until the problem can be debugged.
Douglas Yung [Fri, 30 Mar 2018 01:29:07 +0000 (01:29 +0000)]
Adding UNSUPPORTED: system-windows at George's request until the problem can be debugged.

llvm-svn: 328853

6 years agoRe-implement --just-symbols as a regular object file.
Rui Ueyama [Fri, 30 Mar 2018 01:15:36 +0000 (01:15 +0000)]
Re-implement --just-symbols as a regular object file.

I tried a few different designs to find a way to implement it without
too much hassle and settled down with this. Unlike before, object files
given as arguments for --just-symbols are handled as object files, with
an exception that their section tables are handled as if they were all
null.

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

llvm-svn: 328852

6 years ago[MachineCopyPropagation] Handle COPY with overlapping source/dest.
Eli Friedman [Fri, 30 Mar 2018 00:56:03 +0000 (00:56 +0000)]
[MachineCopyPropagation] Handle COPY with overlapping source/dest.

MachineCopyPropagation::CopyPropagateBlock has a bunch of special
handling for COPY instructions. This handling assumes that COPY
instructions do not modify the source of the copy; this is wrong if
the COPY destination overlaps the source.

To fix the bug, check explicitly for this situation, and fall back to
the generic instruction handling.

This bug can't happen for most register classes because they don't
have this sort of overlap, but there are a few register classes
where this is possible. The testcase uses the AArch64 QQQQ register
class.

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

llvm-svn: 328851

6 years ago[IR] Fix some Clang-tidy modernize-use-auto warnings; other minor fixes (NFC).
Eugene Zelenko [Fri, 30 Mar 2018 00:47:31 +0000 (00:47 +0000)]
[IR] Fix some Clang-tidy modernize-use-auto warnings; other minor fixes (NFC).

llvm-svn: 328850

6 years ago[ASan] Disable new ASan error reporting tests on various ARMs.
Alex Shlyapnikov [Fri, 30 Mar 2018 00:03:36 +0000 (00:03 +0000)]
[ASan] Disable new ASan error reporting tests on various ARMs.

As many other ASan tests already, has to disable these failing tests on
arm, armhf and aarch64 configs.

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

llvm-svn: 328849

6 years agoStyle update. NFC.
Rafael Espindola [Thu, 29 Mar 2018 23:32:54 +0000 (23:32 +0000)]
Style update. NFC.

Rename 3 functions to start with lowercase letters. Don't repeat the
name in the comments.

llvm-svn: 328848

6 years agoAdd missing REQUIRES: arm.
Peter Collingbourne [Thu, 29 Mar 2018 23:08:32 +0000 (23:08 +0000)]
Add missing REQUIRES: arm.

llvm-svn: 328847

6 years agoELF: Add support for short thunks on ARM.
Peter Collingbourne [Thu, 29 Mar 2018 22:43:52 +0000 (22:43 +0000)]
ELF: Add support for short thunks on ARM.

A short thunk uses a direct branch (b or b.w) instruction, and is used
when the target has the same thumbness as the thunk and is within
direct branch range (32MB for ARM, 16MB for Thumb-2). Reduces the
size of Chromium for Android's .text section by around 160KB.

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

llvm-svn: 328846

6 years agoHoist MethodVFTableLocation out of MicrosoftVTableContext, NFC
Reid Kleckner [Thu, 29 Mar 2018 22:42:24 +0000 (22:42 +0000)]
Hoist MethodVFTableLocation out of MicrosoftVTableContext, NFC

This allows forward declaring it so that we can add it to
MicrosoftMangleContext::mangleVirtualMemPtrThunk without including
VTableBuilder.h. That saves a hashtable lookup when emitting virtual
member pointer functions.

It also shortens a really long type name. This struct has "VFtable" in
the name, so it seems pretty unlikely that someone will assume it is
generally useful for non-MS C++ ABI stuff.

llvm-svn: 328845

6 years agoFix some layering in StripNonLineTableDebugInfo, moving its declaration from IPO...
David Blaikie [Thu, 29 Mar 2018 22:42:08 +0000 (22:42 +0000)]
Fix some layering in StripNonLineTableDebugInfo, moving its declaration from IPO.h to Utils.h to match its implementation

llvm-svn: 328844

6 years agoDo not use template for check{Int,UInt,IntUInt,Alignment}.
Rui Ueyama [Thu, 29 Mar 2018 22:40:52 +0000 (22:40 +0000)]
Do not use template for check{Int,UInt,IntUInt,Alignment}.

Template is just unnecessary.

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

llvm-svn: 328843

6 years agoRemove unused header to fix layering.
David Blaikie [Thu, 29 Mar 2018 22:35:59 +0000 (22:35 +0000)]
Remove unused header to fix layering.

llvm-svn: 328842

6 years agoELF: Allow thunks to change size. NFCI.
Peter Collingbourne [Thu, 29 Mar 2018 22:32:13 +0000 (22:32 +0000)]
ELF: Allow thunks to change size. NFCI.

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

llvm-svn: 328841

6 years agoRemove unused headers to fix layering
David Blaikie [Thu, 29 Mar 2018 22:31:39 +0000 (22:31 +0000)]
Remove unused headers to fix layering

llvm-svn: 328840

6 years agollvm-c: Split Utils out of Scalar.h
David Blaikie [Thu, 29 Mar 2018 22:31:38 +0000 (22:31 +0000)]
llvm-c: Split Utils out of Scalar.h

To fix layering (so that Scalar.h, a libScalarOpts header, isn't
included from Utils - which libScalarOpts depends on).

llvm-svn: 328839

6 years agoRemove some unneeded #includes to fix layering
David Blaikie [Thu, 29 Mar 2018 22:31:36 +0000 (22:31 +0000)]
Remove some unneeded #includes to fix layering

llvm-svn: 328838

6 years ago[analyzer] Fix target triple for autorelease-write-checker test
George Karpenkov [Thu, 29 Mar 2018 22:28:04 +0000 (22:28 +0000)]
[analyzer] Fix target triple for autorelease-write-checker test

llvm-svn: 328837

6 years agoSet dso_local on cfi_slowpath.
Rafael Espindola [Thu, 29 Mar 2018 22:08:01 +0000 (22:08 +0000)]
Set dso_local on cfi_slowpath.

llvm-svn: 328836

6 years ago[analyzer] Better pretty-printing of regions in exploded graph
George Karpenkov [Thu, 29 Mar 2018 22:07:58 +0000 (22:07 +0000)]
[analyzer] Better pretty-printing of regions in exploded graph

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

llvm-svn: 328835

6 years ago[X86] Add ReadAfterLds to some 3 src instructions
Craig Topper [Thu, 29 Mar 2018 22:03:05 +0000 (22:03 +0000)]
[X86] Add ReadAfterLds to some 3 src instructions

Sometimes the operand comes after the memory operand so we need 5 ReadDefaults first.

I suspect we also need to do something for the mask operand for masked avx512 instructions? I'm not sure if the mask should be ReadAfterLd or not since it can mask faults. If it shouldn't be ReadAfterLd then we're probably wrong for zero masking instructions already.

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

llvm-svn: 328834

6 years agoTypo fix: epilouge->epilogue. NFC.
Eric Christopher [Thu, 29 Mar 2018 21:59:04 +0000 (21:59 +0000)]
Typo fix: epilouge->epilogue. NFC.

llvm-svn: 328833

6 years agoAMDGPU: Fix build warning in release
Matt Arsenault [Thu, 29 Mar 2018 21:44:44 +0000 (21:44 +0000)]
AMDGPU: Fix build warning in release

llvm-svn: 328832

6 years agoAMDGPU: Support realigning stack
Matt Arsenault [Thu, 29 Mar 2018 21:30:06 +0000 (21:30 +0000)]
AMDGPU: Support realigning stack

While the stack access instructions don't care about
alignment > 4, some transformations on the pointer calculation
do make assumptions based on knowing the low bits of a pointer
are 0. If a stack object ends up being accessed through its
absolute address (relative to the kernel scratch wave offset),
the addressing expression may depend on the stack frame being
properly aligned. This was breaking in a testcase due to the
add->or combine.

I think some of the SP/FP handling logic is still backwards,
and overly simplistic to support all of the stack features.
Code which tries to modify the SP with inline asm for example
or variable sized objects will probably require redoing this.

llvm-svn: 328831

6 years agoAdd msan custom mapping options.
Evgeniy Stepanov [Thu, 29 Mar 2018 21:18:17 +0000 (21:18 +0000)]
Add msan custom mapping options.

Similarly to https://reviews.llvm.org/D18865 this adds options to provide custom mapping for msan.
As discussed in http://lists.llvm.org/pipermail/llvm-dev/2018-February/121339.html

Patch by vit9696(at)avp.su.

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

llvm-svn: 328830

6 years ago[AArch64]: Add support for parsing rN registers.
Manoj Gupta [Thu, 29 Mar 2018 21:11:15 +0000 (21:11 +0000)]
[AArch64]: Add support for parsing rN registers.

Summary:
Allow rN registers to be simply parsed as correspoing xN registers.
The "register ... asm("rN")" is an command to the
compiler's register allocator, not an operand to any individual assembly
instruction. GCC documents this syntax as "...the name of the register
that should be used."

This is needed to support the changes in Linux kernel (see
https://lkml.org/lkml/2018/3/1/268 )

Note: This will add support only for the limited use case of
register ... asm("rN"). Any other uses that make rN leak into assembly
are not supported.

Reviewers: kristof.beyls, rengolin, peter.smith, t.p.northover

Reviewed By: peter.smith

Subscribers: javed.absar, eraman, cfe-commits, srhines

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

llvm-svn: 328829

6 years ago[X86] Remove ReadAfterLd from BMI and TBM instructions that don't have a register...
Craig Topper [Thu, 29 Mar 2018 21:03:53 +0000 (21:03 +0000)]
[X86] Remove ReadAfterLd from BMI and TBM instructions that don't have a register operand in their memory form

The memory form of these instructions only read an input from memory. They don't have any register operands.

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

llvm-svn: 328828

6 years ago[analyzer] Path-insensitive checker for writes into an auto-releasing pointer
George Karpenkov [Thu, 29 Mar 2018 20:55:34 +0000 (20:55 +0000)]
[analyzer] Path-insensitive checker for writes into an auto-releasing pointer

from the wrong auto-releasing pool, as such writes may crash.

rdar://25301111

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

llvm-svn: 328827

6 years ago[AST] Fix some Clang-tidy modernize-use-auto warnings; other minor fixes (NFC).
Eugene Zelenko [Thu, 29 Mar 2018 20:51:59 +0000 (20:51 +0000)]
[AST] Fix some Clang-tidy modernize-use-auto warnings; other minor fixes (NFC).

llvm-svn: 328826

6 years agoMark __cfi_check as dso_local.
Rafael Espindola [Thu, 29 Mar 2018 20:51:30 +0000 (20:51 +0000)]
Mark __cfi_check as dso_local.

llvm-svn: 328825

6 years agoTry to fix sanitizer-x86_64-linux-fast bot due to change in r328820.
Kevin Enderby [Thu, 29 Mar 2018 20:49:24 +0000 (20:49 +0000)]
Try to fix sanitizer-x86_64-linux-fast bot due to change in r328820.

llvm-svn: 328824

6 years ago[X86] Correct the placement of ReadAfterLd in BEXTR and BZHI. Add dedicated SchedRW...
Craig Topper [Thu, 29 Mar 2018 20:41:39 +0000 (20:41 +0000)]
[X86] Correct the placement of ReadAfterLd in BEXTR and BZHI. Add dedicated SchedRW for BEXTR/BZHI.

These instructions have the memory operand before the register operand. So we need to put ReadDefault for all the load ops first. Then the ReadAfterLd

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

llvm-svn: 328823

6 years ago[NFC][LICM] Rearrange checks to have the cheap bail out first
Philip Reames [Thu, 29 Mar 2018 20:32:15 +0000 (20:32 +0000)]
[NFC][LICM] Rearrange checks to have the cheap bail out first

llvm-svn: 328822

6 years agoAMDGPU: Increase default stack alignment
Matt Arsenault [Thu, 29 Mar 2018 20:22:04 +0000 (20:22 +0000)]
AMDGPU: Increase default stack alignment

8 and 16-byte values are common, so increase the default
alignment to avoid realigning the stack in most functions.

llvm-svn: 328821

6 years agoFor llvm-nm and Mach-O files that are fully stripped, special case a redacted LC_MAIN
Kevin Enderby [Thu, 29 Mar 2018 20:04:29 +0000 (20:04 +0000)]
For llvm-nm and Mach-O files that are fully stripped, special case a redacted LC_MAIN

As a further refinement on:

r328274 - For llvm-nm and Mach-O files also use function starts info in some cases when printing symbols

we want to special case a redacted LC_MAIN so it is easier to find.

rdar://38978929

llvm-svn: 328820

6 years ago[clangd] Fix repeated word typo. NFC
Fangrui Song [Thu, 29 Mar 2018 20:03:16 +0000 (20:03 +0000)]
[clangd] Fix repeated word typo. NFC

llvm-svn: 328819

6 years agoAMDGPU: Fix selection error on constant loads with < 4 byte alignment
Matt Arsenault [Thu, 29 Mar 2018 19:59:28 +0000 (19:59 +0000)]
AMDGPU: Fix selection error on constant loads with < 4 byte alignment

llvm-svn: 328818

6 years agoSimplify. NFC.
Rui Ueyama [Thu, 29 Mar 2018 19:51:53 +0000 (19:51 +0000)]
Simplify. NFC.

llvm-svn: 328817

6 years agoFix an accidental circular dependence
Philip Reames [Thu, 29 Mar 2018 19:22:12 +0000 (19:22 +0000)]
Fix an accidental circular dependence

llvm-svn: 328816

6 years ago[Mips] Change std::sort to llvm::sort in response to r327219
Mandeep Singh Grang [Thu, 29 Mar 2018 19:05:26 +0000 (19:05 +0000)]
[Mips] Change std::sort to llvm::sort in response to r327219

Summary:
r327219 added wrappers to std::sort which randomly shuffle the container before sorting.
This will help in uncovering non-determinism caused due to undefined sorting
order of objects having the same key.

To make use of that infrastructure we need to invoke llvm::sort instead of std::sort.

Note: This patch is one of a series of patches to replace *all* std::sort to llvm::sort.
Refer the comments section in D44363 for a list of all the required patches.

Reviewers: sdardis, RKSimon, dsanders, atanasyan

Reviewed By: atanasyan

Subscribers: atanasyan, arichardson, llvm-commits

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

llvm-svn: 328815

6 years agoTry to fix a couple tests for Windows.
Paul Robinson [Thu, 29 Mar 2018 18:59:33 +0000 (18:59 +0000)]
Try to fix a couple tests for Windows.

llvm-svn: 328814

6 years ago[SLPVectorizer] Add tests related to PR30787, NFCI.
Dinar Temirbulatov [Thu, 29 Mar 2018 18:57:03 +0000 (18:57 +0000)]
[SLPVectorizer] Add tests related to PR30787, NFCI.

llvm-svn: 328813

6 years ago[MSF] Default to FPM2, and always mark FPM pages allocated.
Zachary Turner [Thu, 29 Mar 2018 18:34:15 +0000 (18:34 +0000)]
[MSF] Default to FPM2, and always mark FPM pages allocated.

There are two FPMs in an MSF file, the idea being that for
incremental updates you can write to the alternate one and then
atomically swap them on commit.  LLVM defaulted to using FPM1
on the first commit, but this differs from Microsoft's behavior
which is to default to using FPM2 on the first commit.  To
eliminate some byte-level file differences, this patch changes
LLVM's default to also be FPM2.

Additionally, LLVM was trying to be "smart" about marking FPM
pages allocated.  In addition to marking every page belonging
to the alternate FPM as unallocated, LLVM also marked pages at
the end of the main FPM which were not needed as unallocated.

In order to match the behavior of Microsoft-generated PDBs, we
now always mark every FPM block as allocated, regardless of
whether it is in the main FPM or the alt FPM, and regardless of
whether or not it describes blocks which are actually in the file.

This has the side benefit of simplifying our code.

llvm-svn: 328812

6 years agoExit early from a loop. NFC.
Rui Ueyama [Thu, 29 Mar 2018 18:29:12 +0000 (18:29 +0000)]
Exit early from a loop. NFC.

This patch fixes an issue introduced in r328810 which made the algorithm
to always run the loop O(n^2) times, though we can break early. The
output remains the same.

llvm-svn: 328811

6 years agoRefactor Writer::checkNoOverlappingSections. NFC.
Rui Ueyama [Thu, 29 Mar 2018 18:24:01 +0000 (18:24 +0000)]
Refactor Writer::checkNoOverlappingSections. NFC.

This patch rewrites the function to remove lambda callbacks and use
of template. The algorithm is the same as before.

llvm-svn: 328810

6 years agoGeneralize NRVO to cover C structs.
Akira Hatanaka [Thu, 29 Mar 2018 17:56:24 +0000 (17:56 +0000)]
Generalize NRVO to cover C structs.

This commit generalizes NRVO to cover C structs (both trivial and
non-trivial structs).

rdar://problem/33599681

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

llvm-svn: 328809

6 years ago[PDB] Print some more details when explaining MSF fields.
Zachary Turner [Thu, 29 Mar 2018 17:45:34 +0000 (17:45 +0000)]
[PDB] Print some more details when explaining MSF fields.

When we determine that a field belongs to an MSF super block or
the free page map, we wouldn't print any additional information.

With this patch, we now print the value of the field (for super
block fields) or the allocation status of the specified byte (in
the case of offsets in the FPM).

llvm-svn: 328808

6 years ago[Sema] Make deprecation fix-it replace all multi-parameter ObjC method slots.
Volodymyr Sapsai [Thu, 29 Mar 2018 17:34:09 +0000 (17:34 +0000)]
[Sema] Make deprecation fix-it replace all multi-parameter ObjC method slots.

Deprecation replacement can be any text but if it looks like a name of
ObjC method and has the same number of arguments as original method,
replace all slot names so after applying a fix-it you have valid code.

rdar://problem/36660853

Reviewers: aaron.ballman, erik.pilkington, rsmith

Reviewed By: erik.pilkington

Subscribers: cfe-commits, jkorous-apple

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

llvm-svn: 328807

6 years ago[IR][CodeGen] Remove dependency on EVT from IR/Function.cpp. Move EVT to CodeGen...
Craig Topper [Thu, 29 Mar 2018 17:21:10 +0000 (17:21 +0000)]
[IR][CodeGen] Remove dependency on EVT from IR/Function.cpp. Move EVT to CodeGen layer.

Currently EVT is in the IR layer only because of Function.cpp needing a very small piece of the functionality of EVT::getEVTString(). The rest of EVT is used in codegen making CodeGen a better place for it.

The previous code converted a Type* to EVT and then called getEVTString. This was only expected to handle the primitive types from Type*. Since there only a few primitive types, we can just print them as strings directly.

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

llvm-svn: 328806

6 years agoReapply "[DWARFv5] Emit file 0 to the line table."
Paul Robinson [Thu, 29 Mar 2018 17:16:41 +0000 (17:16 +0000)]
Reapply "[DWARFv5] Emit file 0 to the line table."

DWARF v5 specifies that the root file (also given in the DW_AT_name
attribute of the compilation unit DIE) should be emitted explicitly to
the line table's list of files.  This makes the line table more
independent of the .debug_info section.
We emit the new syntax only for DWARF v5 and later.

Fixes the bug found by asan. Also XFAIL the new test for Darwin, which
is stuck on DWARF v2, and fix up other tests so they stop failing on
Windows.  Last but not least, don't break "clang -g" of an assembler
file that has .file directives in it.

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

llvm-svn: 328805

6 years ago[PDB] Fix a bug in the explain subcommand.
Zachary Turner [Thu, 29 Mar 2018 17:11:14 +0000 (17:11 +0000)]
[PDB] Fix a bug in the explain subcommand.

We were trying to dig into the super block fields and print a
description of the field at the specified offset, but we were
printing the wrong field due to an off-by-one-field-error.

llvm-svn: 328804

6 years ago[ADT] NFC: Fix bogus StringSwitch rule-of-five boilerplate
David Zarzycki [Thu, 29 Mar 2018 16:51:28 +0000 (16:51 +0000)]
[ADT] NFC: Fix bogus StringSwitch rule-of-five boilerplate

Now that 'Str' is constant, the rule-of-file logic needs updating.

Reported by: vit9696@avp.su
Reviewed by: jordan_rose@apple.com

llvm-svn: 328803

6 years agoRemove unused function.
Zachary Turner [Thu, 29 Mar 2018 16:46:47 +0000 (16:46 +0000)]
Remove unused function.

llvm-svn: 328802

6 years agoSet dso_local when clearing dllimport.
Rafael Espindola [Thu, 29 Mar 2018 16:45:18 +0000 (16:45 +0000)]
Set dso_local when clearing dllimport.

llvm-svn: 328801

6 years agoAdd a dllimport test.
Rafael Espindola [Thu, 29 Mar 2018 16:35:52 +0000 (16:35 +0000)]
Add a dllimport test.

Thanks to rnk for the suggestion.

llvm-svn: 328800

6 years ago[PDB] Add an explain subcommand.
Zachary Turner [Thu, 29 Mar 2018 16:28:20 +0000 (16:28 +0000)]
[PDB] Add an explain subcommand.

When investigating various things, we often have a file offset
and what to know what's in the PDB at that address.  For example
we may be doing a binary comparison of two LLD-generated PDBs
to look for sources of non-determinism, or we may wish to compare
an LLD-generated PDB with a Microsoft generated PDB for sources
of byte-for-byte incompatibility.  In these cases, we can do a
binary diff of the two files, and once we find a mismatched byte
we can use explain to figure out what that byte is, immediately
honining in on the problem.

This patch implements this by trying to narrow the meaning of
a particular file offset down as much as possible.

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

llvm-svn: 328799

6 years ago[JumpThreading] Don't select an edge that we know we can't thread
Haicheng Wu [Thu, 29 Mar 2018 16:01:26 +0000 (16:01 +0000)]
[JumpThreading] Don't select an edge that we know we can't thread

In r312664 (D36404), JumpThreading stopped threading edges into
loop headers. Unfortunately, I observed a significant performance
regression as a result of this change. Upon further investigation,
the problematic pattern looked something like this (after
many high level optimizations):

while (true) {
    bool cond = ...;
    if (!cond) {
        <body>
    }
    if (cond)
        break;
}

Now, naturally we want jump threading to essentially eliminate the
second if check and hook up the edges appropriately. However, the
above mentioned change, prevented it from doing this because it would
have to thread an edge into the loop header.

Upon further investigation, what is happening is that since both branches
are threadable, JumpThreading picks one of them at arbitrarily. In my
case, because of the way that the IR ended up, it tended to pick
the one to the loop header, bailing out immediately after. However,
if it had picked the one to the exit block, everything would have
worked out fine (because the only remaining branch would then be folded,
not thraded which is acceptable).

Thus, to fix this problem, we can simply eliminate loop headers from
consideration as possible threading targets earlier, to make sure that
if there are multiple eligible branches, we can still thread one of
the ones that don't target a loop header.

Patch by Keno Fischer!
Differential Revision: https://reviews.llvm.org/D42260

llvm-svn: 328798

6 years ago[test] Fix an XRay test on FreeBSD
Zhihao Yuan [Thu, 29 Mar 2018 15:50:44 +0000 (15:50 +0000)]
[test] Fix an XRay test on FreeBSD

Summary: Fixing clang-test on FreeBSD as a follow-up of https://reviews.llvm.org/D43378 to handle the revert happened in r325749.

Reviewers: devnexen, krytarowski, dberris

Subscribers: emaste, dberris, cfe-commits

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

llvm-svn: 328797

6 years ago.debug_names: Correctly align the AugmentationStringSize field
Pavel Labath [Thu, 29 Mar 2018 15:12:45 +0000 (15:12 +0000)]
.debug_names: Correctly align the AugmentationStringSize field

We should align the value of the field, not the overall section offset.

This distinction matters if one of the debug_names contributions is not
of size which is a multiple of four. The dwarf producers may choose to
emit rounded contributions, but they are not required to do so. In the
latter case, without this patch we would corrupt the parsing state, as
we would adjust the offset even if subsequent contributions contained
correctly rounded augmentation strings.

llvm-svn: 328796

6 years agoSet calling convention for CUDA kernel
Yaxun Liu [Thu, 29 Mar 2018 15:02:08 +0000 (15:02 +0000)]
Set calling convention for CUDA kernel

This patch sets target specific calling convention for CUDA kernels in IR.

Patch by Greg Rodgers.
Revised and lit test added by Yaxun Liu.

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

llvm-svn: 328795

6 years ago[ELF] - Add missing check calls to the tests.
George Rimar [Thu, 29 Mar 2018 14:57:29 +0000 (14:57 +0000)]
[ELF] - Add missing check calls to the tests.

llvm-svn: 328794

6 years agoDisable emitting static extern C aliases for amdgcn target for CUDA
Yaxun Liu [Thu, 29 Mar 2018 14:50:00 +0000 (14:50 +0000)]
Disable emitting static extern C aliases for amdgcn target for CUDA

Patch by Greg Rodgers.
Revised and lit test added by Yaxun Liu.

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

llvm-svn: 328793

6 years ago[clangd] Mark "Source Hover" as implemented in the docs
Marc-Andre Laperle [Thu, 29 Mar 2018 14:49:21 +0000 (14:49 +0000)]
[clangd] Mark "Source Hover" as implemented in the docs

Summary: Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>

Reviewers: simark

Reviewed By: simark

Subscribers: klimek, ilya-biryukov, ioeric, MaskRay, cfe-commits

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

llvm-svn: 328792

6 years agoFix typo
Matt Arsenault [Thu, 29 Mar 2018 14:31:59 +0000 (14:31 +0000)]
Fix typo

llvm-svn: 328791

6 years ago[llvm-mca] Correctly set the ReadAdvance information for register use operands.
Andrea Di Biagio [Thu, 29 Mar 2018 14:26:56 +0000 (14:26 +0000)]
[llvm-mca] Correctly set the ReadAdvance information for register use operands.

The tool was passing the wrong operand index to method
MCSubtargetInfo::getReadAdvanceCycles(). That method requires a "UseIdx", and
not the operand index. This was found when testing X86 code where instructions
had a memory folded operand.

This patch fixes the issue and adds test read-advance-1.s to ensure that
the ReadAfterLd (a ReadAdvance of 3cy) information is correctly used.

llvm-svn: 328790

6 years ago[ELF] Fix X86 & X86_64 PLT retpoline padding
Andrew Ng [Thu, 29 Mar 2018 14:03:01 +0000 (14:03 +0000)]
[ELF] Fix X86 & X86_64 PLT retpoline padding

The PLT retpoline support for X86 and X86_64 did not include the padding
when writing the header and entries. This issue was revealed when linker
scripts were used, as this disables the built-in behaviour of filling
the last page of executable segments with trap instructions. This
particular behaviour was hiding the missing padding.

Added retpoline tests with linker scripts.

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

llvm-svn: 328777

6 years ago[Hexagon] Aid bit-reverse load intrinsics lowering with bitcode
Krzysztof Parzyszek [Thu, 29 Mar 2018 13:54:31 +0000 (13:54 +0000)]
[Hexagon] Aid bit-reverse load intrinsics lowering with bitcode

The conversion of operatios to bitcode helps to eliminate an additional
store in certain cases. We used to lower these load intrinsics in DAG to
DAG conversion by which time, the "Dead Store Elimination" pass is
already run. There is an associated LLVM patch.

Patch by Sumanth Gundapaneni.

llvm-svn: 328776

6 years ago[asan] Split the `throw_invoke_test.cc` into a Linux specific variant
Dan Liew [Thu, 29 Mar 2018 13:53:50 +0000 (13:53 +0000)]
[asan] Split the `throw_invoke_test.cc` into a Linux specific variant
and the general version to avoid use of libstdc++ on non-Linux
platforms.

This is motivated by the fact that using `libstdc++` is deprecated on
Darwin and maybe removed some day.

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

llvm-svn: 328775

6 years ago[Hexagon] Add support to handle bit-reverse load intrinsics
Krzysztof Parzyszek [Thu, 29 Mar 2018 13:52:46 +0000 (13:52 +0000)]
[Hexagon] Add support to handle bit-reverse load intrinsics

Patch by Sumanth Gundapaneni.

llvm-svn: 328774

6 years ago.debug_names: Parse DW_IDX_die_offset as a reference
Pavel Labath [Thu, 29 Mar 2018 13:47:57 +0000 (13:47 +0000)]
.debug_names: Parse DW_IDX_die_offset as a reference

Before this patch we were parsing the attributes as section offsets, as
that is what apple_names is doing. However, this is not correct as DWARF
v5 specifies that this attribute should use the Reference form class.

This also updates all the testcases (except the ones that deliberately
pass a different form) to use the correct form class.

llvm-svn: 328773

6 years ago[Kaleidoscope] Tiny typo fixes
Sjoerd Meijer [Thu, 29 Mar 2018 12:31:06 +0000 (12:31 +0000)]
[Kaleidoscope] Tiny typo fixes

Fixes for "lets" references which should be "let's" in the Kaleidoscope
tutorial.

Patch by: Robin Dupret

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

llvm-svn: 328772

6 years ago[X86][SSE] Don't bother re-adding combined target shuffles to the work list
Simon Pilgrim [Thu, 29 Mar 2018 11:18:41 +0000 (11:18 +0000)]
[X86][SSE] Don't bother re-adding combined target shuffles to the work list

We are re-adding all the bitcasts, constant masks and target shuffles to the work list for no apparent gain.

Found while investigating adding SimplifyDemandedVectorElts to target shuffles.

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

llvm-svn: 328771

6 years agoNativeThreadProtocol: delete dead code
Pavel Labath [Thu, 29 Mar 2018 10:09:11 +0000 (10:09 +0000)]
NativeThreadProtocol: delete dead code

These functions were unused as everyone just went straight for the
direct operations on the register context. In fact, the
Save/RestoreAllRegisters actually appear to be wrong (inverted). Thanks
to Tatyana for pointing this out.

These functions are not very useful now that we can guarantee that each
thread always contains a valid register context, so I just delete them.

llvm-svn: 328770

6 years agoRename clang link from clang-X.Y to clang-X
Sylvestre Ledru [Thu, 29 Mar 2018 10:05:46 +0000 (10:05 +0000)]
Rename clang link from clang-X.Y to clang-X

Summary:
As we are only doing X.0.Z releases (not using the minor version), there is no need to keep -X.Y in the version.
So, instead, I propose the following:
Instead of having clang-7.0 in bin/, we will have clang-7

Since also matches was gcc is doing.

Reviewers: tstellar, dlj, dim, hans

Reviewed By: dim, hans

Subscribers: dim, mgorny, cfe-commits

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

llvm-svn: 328769

6 years agoRename llvm library from libLLVM-X.Y to libLLVM-X
Sylvestre Ledru [Thu, 29 Mar 2018 09:44:09 +0000 (09:44 +0000)]
Rename llvm library from libLLVM-X.Y to libLLVM-X

Summary:
As we are only doing X.0.Z releases (not using the minor version), there is no need to keep -X.Y in the version.

Like patch https://reviews.llvm.org/D41808, I propose that we rename libLLVM-7.0svn.so to libLLVM-7svn.so
This patch will also rename downstream libraries like liblldb-7.0 to liblldb-7

Reviewers: axw, beanz, dim, hans

Reviewed By: dim, hans

Subscribers: mgorny, llvm-commits

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

llvm-svn: 328768

6 years ago[Mips] Remove dead code
Simon Dardis [Thu, 29 Mar 2018 09:21:20 +0000 (09:21 +0000)]
[Mips] Remove dead code

I believe the role of ehDataReg has been replaced by MipsABIInfo::GetEhDataReg, thus removing the dead code.

Patch By: Wei-Ren Chen.

Reviewers: ehostunreach, sdardis

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

llvm-svn: 328767

6 years ago[LoopRotate] Restructuring LoopRotation.cpp to create Loop Rotation Pass with Loop...
David Green [Thu, 29 Mar 2018 08:48:15 +0000 (08:48 +0000)]
[LoopRotate] Restructuring LoopRotation.cpp to create Loop Rotation Pass with Loop Rotation Utility Interface

The existing LoopRotation.cpp is implemented as one of loop passes instead of
being a utility. The user cannot easily perform the loop rotation selectively
(or on demand) under different optimization level. For example, the loop
rotation is needed as part of the logic to convert a loop into a loop with
bottom test for a transformation. If the loop rotation is simply added as a
loop pass before the transformation, the pass is skipped if it is compiled at
–O0 or if it is explicitly disabled by the user, causing the compiler to
generate incorrect code. Furthermore, as a loop pass it will rotate all loops
instead of just the relevant loops.

We provide a utility interface for the loop rotation so that the loop rotation
can be called on demand. The changeset is as follows:

- Create a new file lib/Transforms/Utils/LoopRotationUtils.cpp and move the main
  implementation of class LoopRotate into this file.
- Create a new file llvm/include/Transform/Utils/LoopRotationUtils.h with the
  interface LoopRotation(...).
- Original LoopRotation.cpp is changed to use the utility function LoopRotation
  in LoopRotationUtils.cpp. This is done in the same way community did for
  mem-to-reg implementation.

Patch by Jin Lin!

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

llvm-svn: 328766

6 years ago[Transforms] Make sure to include the c binding header when defining c binding functions
Benjamin Kramer [Thu, 29 Mar 2018 07:56:53 +0000 (07:56 +0000)]
[Transforms] Make sure to include the c binding header when defining c binding functions

Otherwise the definitions can't see the extern C declarations and get
name mangled, making it impossible for users to call them. This breaks
the Go bindings.

llvm-svn: 328765

6 years ago[NFC] Fix meaningless assert in SCEV
Max Kazantsev [Thu, 29 Mar 2018 07:54:59 +0000 (07:54 +0000)]
[NFC] Fix meaningless assert in SCEV

llvm-svn: 328764

6 years agoRefactor some code for a warning. NFC.
Richard Trieu [Thu, 29 Mar 2018 05:14:17 +0000 (05:14 +0000)]
Refactor some code for a warning.  NFC.

Use range-based for-loops instead of iterators to walk over vectors.
Switch the key of the DenseMap so a custom key handler is no longer needed.
Remove unncessary adds to the DenseMap.
Use unique_ptr instead of manual memory management.

llvm-svn: 328763

6 years ago[X86] Don't pass getRegisterName from the InstPrinters into EmitAnyX86InstComments...
Craig Topper [Thu, 29 Mar 2018 04:14:04 +0000 (04:14 +0000)]
[X86] Don't pass getRegisterName from the InstPrinters into EmitAnyX86InstComments. Just always use the function from the ATTPrinter. NFC

The IntelPrinter and the ATTPrinter produce the same strings for the same input. We already use the ATTPrinter explicitly in several other places.

llvm-svn: 328762