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

6 years agoPrevent double release of mach ports
Frederic Riss [Thu, 29 Mar 2018 03:49:41 +0000 (03:49 +0000)]
Prevent double release of mach ports

Summary:
When a MIG routine returns KERN_FAILURE, the demux function will release any OOL resources like ports. In this case, task_port and thread_port will be released twice, potentially resulting in use after free of the ports.

I don't think we can test this in any useful way
rdar://problem/37331387

Reviewers: jasonmolenda

Subscribers: lldb-commits

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

llvm-svn: 328761

6 years agofix typo in align_const_pair_U_V.pass.cpp
Eric Fiselier [Thu, 29 Mar 2018 03:44:01 +0000 (03:44 +0000)]
fix typo in align_const_pair_U_V.pass.cpp

llvm-svn: 328760

6 years ago[LLVM-C] Finish exception instruction bindings
Robert Widmann [Thu, 29 Mar 2018 03:43:15 +0000 (03:43 +0000)]
[LLVM-C] Finish exception instruction bindings

Summary:
Add support for cleanupret, catchret, catchpad, cleanuppad and catchswitch and their associated accessors.

Test is modified from SimplifyCFG because it contains many diverse usages of these instructions.

Reviewers: whitequark, deadalnix, echristo

Reviewed By: echristo

Subscribers: llvm-commits, harlanhaskins

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

llvm-svn: 328759

6 years agoMove libc++ pair/tuple assign test to libcxx/ test directory.
Eric Fiselier [Thu, 29 Mar 2018 03:30:00 +0000 (03:30 +0000)]
Move libc++ pair/tuple assign test to libcxx/ test directory.

Libc++ implements the pair& operator=(pair<U, V>) assignment operator
using a single template that handles assignment from all tuple-like types.

This patch moves the test for that to the libcxx test directory since
it's non-standard. It also adds additional tests to the std/.../pair
directory to test the standard behavior this template implements.

llvm-svn: 328758

6 years ago[X86] Rename RIi64_NOREX tblgen class to just Ii64. Make RIi64 inherit from it. NFC
Craig Topper [Thu, 29 Mar 2018 03:14:57 +0000 (03:14 +0000)]
[X86] Rename RIi64_NOREX tblgen class to just Ii64. Make RIi64 inherit from it. NFC

This feels more consistent with the other classes. We don't need to say _NOREX if we didn't start it with an R in the first place.

llvm-svn: 328757

6 years ago[X86] Cleanup inheritance of the X86InstrFormats.td classes. NFC
Craig Topper [Thu, 29 Mar 2018 03:14:56 +0000 (03:14 +0000)]
[X86] Cleanup inheritance of the X86InstrFormats.td classes. NFC

EVEX shouldn't inherit from VEX and EVEX_4V shouldn't inherit from VEX_4V.

llvm-svn: 328756

6 years ago[MemorySSA] Turn an assert into a condition
George Burgess IV [Thu, 29 Mar 2018 03:12:03 +0000 (03:12 +0000)]
[MemorySSA] Turn an assert into a condition

Eli pointed out that variadic functions are totally a thing, so this
assert is incorrect.

No test-case is provided, since the only way this assert fires is if a
specific DenseMap falls back to doing `isEqual` checks, and that seems
fairly brittle (and requires a pyramid of growing
`call void (i8, ...) @varargs(i8 0)`).

llvm-svn: 328755

6 years ago[astmatchers] Fix linking issue
George Karpenkov [Thu, 29 Mar 2018 02:47:28 +0000 (02:47 +0000)]
[astmatchers] Fix linking issue

llvm-svn: 328754

6 years ago[ASan] Disable aligned_alloc-alignment.cc on PPC64.
Alex Shlyapnikov [Thu, 29 Mar 2018 02:18:57 +0000 (02:18 +0000)]
[ASan] Disable aligned_alloc-alignment.cc on PPC64.

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

llvm-svn: 328753

6 years ago[analyzer] [testing] Be less verbose by default in integration testing.
George Karpenkov [Thu, 29 Mar 2018 01:23:54 +0000 (01:23 +0000)]
[analyzer] [testing] Be less verbose by default in integration testing.

llvm-svn: 328752

6 years agoFix PR36914 - num_get::get(unsigned) incorrectly handles negative numbers.
Eric Fiselier [Thu, 29 Mar 2018 01:18:53 +0000 (01:18 +0000)]
Fix PR36914 - num_get::get(unsigned) incorrectly handles negative numbers.

This patch corrects num_get for unsigned types to support strings
with a leading `-` character. According to the standard the
number should be parsed as an unsigned integer and then
negated.

llvm-svn: 328751

6 years ago[astmatchers] Move a matcher out of internal namespace: blind debugging of MSVC issues
George Karpenkov [Thu, 29 Mar 2018 01:15:05 +0000 (01:15 +0000)]
[astmatchers] Move a matcher out of internal namespace: blind debugging of MSVC issues

llvm-svn: 328750

6 years ago[ast] Do not auto-initialize Objective-C for-loop variables in Objective-C++ in templ...
George Karpenkov [Thu, 29 Mar 2018 00:56:24 +0000 (00:56 +0000)]
[ast] Do not auto-initialize Objective-C for-loop variables in Objective-C++ in templatized code under ARC

The AST for the fragment

```
@interface I
@end

template <typename>
void decode(I *p) {
  for (I *k in p) {}
}

void decode(I *p) {
  decode<int>(p);
}
```

differs heavily when templatized and non-templatized:

```
|-FunctionTemplateDecl 0x7fbfe0863940 <line:4:1, line:7:1> line:5:6 decode
| |-TemplateTypeParmDecl 0x7fbfe0863690 <line:4:11> col:11 typename depth 0 index 0
| |-FunctionDecl 0x7fbfe08638a0 <line:5:1, line:7:1> line:5:6 decode 'void (I *__strong)'
| | |-ParmVarDecl 0x7fbfe08637a0 <col:13, col:16> col:16 referenced p 'I *__strong'
| | `-CompoundStmt 0x7fbfe0863b88 <col:19, line:7:1>
| |   `-ObjCForCollectionStmt 0x7fbfe0863b50 <line:6:3, col:20>
| |     |-DeclStmt 0x7fbfe0863a50 <col:8, col:13>
| |     | `-VarDecl 0x7fbfe08639f0 <col:8, col:11> col:11 k 'I *const __strong'
| |     |-ImplicitCastExpr 0x7fbfe0863a90 <col:16> 'I *' <LValueToRValue>
| |     | `-DeclRefExpr 0x7fbfe0863a68 <col:16> 'I *__strong' lvalue ParmVar 0x7fbfe08637a0 'p' 'I *__strong'
| |     `-CompoundStmt 0x7fbfe0863b78 <col:19, col:20>
| `-FunctionDecl 0x7fbfe0863f80 <line:5:1, line:7:1> line:5:6 used decode 'void (I *__strong)'
|   |-TemplateArgument type 'int'
|   |-ParmVarDecl 0x7fbfe0863ef8 <col:13, col:16> col:16 used p 'I *__strong'
|   `-CompoundStmt 0x7fbfe0890cf0 <col:19, line:7:1>
|     `-ObjCForCollectionStmt 0x7fbfe0890cc8 <line:6:3, col:20>
|       |-DeclStmt 0x7fbfe0890c70 <col:8, col:13>
|       | `-VarDecl 0x7fbfe0890c00 <col:8, col:11> col:11 k 'I *__strong' callinit
|       |   `-ImplicitValueInitExpr 0x7fbfe0890c60 <<invalid sloc>> 'I *__strong'
|       |-ImplicitCastExpr 0x7fbfe0890cb0 <col:16> 'I *' <LValueToRValue>
|       | `-DeclRefExpr 0x7fbfe0890c88 <col:16> 'I *__strong' lvalue ParmVar 0x7fbfe0863ef8 'p' 'I *__strong'
|       `-CompoundStmt 0x7fbfe0863b78 <col:19, col:20>
```

Note how in the instantiated version ImplicitValueInitExpr unexpectedly appears.

While objects are auto-initialized under ARC, it does not make sense to
have an initializer for a for-loop variable, and it makes even less
sense to have such a different AST for instantiated and non-instantiated
version.

Digging deeper, I have found that there are two separate Sema* files for
dealing with templates and for dealing with non-templatized code.
In a non-templatized version, an initialization was performed only for
variables which are not loop variables for an Objective-C loop and not
variables for a C++ for-in loop:

```
  if (FRI && (Tok.is(tok::colon) || isTokIdentifier_in())) {
    bool IsForRangeLoop = false;
    if (TryConsumeToken(tok::colon, FRI->ColonLoc)) {
      IsForRangeLoop = true;
      if (Tok.is(tok::l_brace))
        FRI->RangeExpr = ParseBraceInitializer();
      else
        FRI->RangeExpr = ParseExpression();
    }

    Decl *ThisDecl = Actions.ActOnDeclarator(getCurScope(), D);
    if (IsForRangeLoop)
      Actions.ActOnCXXForRangeDecl(ThisDecl);
    Actions.FinalizeDeclaration(ThisDecl);
    D.complete(ThisDecl);
    return Actions.FinalizeDeclaratorGroup(getCurScope(), DS, ThisDecl);
  }

  SmallVector<Decl *, 8> DeclsInGroup;
  Decl *FirstDecl = ParseDeclarationAfterDeclaratorAndAttributes(
      D, ParsedTemplateInfo(), FRI);
```

However the code in SemaTemplateInstantiateDecl was inconsistent,
guarding only against C++ for-in loops.

rdar://38391075

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

llvm-svn: 328749

6 years ago[MemorySSA] Consider callsite args for hashing and equality.
George Burgess IV [Thu, 29 Mar 2018 00:54:39 +0000 (00:54 +0000)]
[MemorySSA] Consider callsite args for hashing and equality.

We use a `DenseMap<MemoryLocOrCall, MemlocStackInfo>` to keep track of
prior work when optimizing uses in MemorySSA. Because we weren't
accounting for callsite arguments in either the hash code or equality
tests for `MemoryLocOrCall`s, we optimized uses too aggressively in
some rare cases.

Fix by Daniel Berlin.

Should fix PR36883.

llvm-svn: 328748

6 years ago[ASTMatchers] Introduce a matcher for matching any given Objective-C selector
George Karpenkov [Thu, 29 Mar 2018 00:51:12 +0000 (00:51 +0000)]
[ASTMatchers] Introduce a matcher for matching any given Objective-C selector

Incudes a tiny related refactoring.

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

llvm-svn: 328747

6 years ago[ASTMatchers] Extend hasParameter and hasAnyParameter matches to handle Objective...
George Karpenkov [Thu, 29 Mar 2018 00:51:11 +0000 (00:51 +0000)]
[ASTMatchers] Extend hasParameter and hasAnyParameter matches to handle Objective-C methods

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

llvm-svn: 328746

6 years agoRemove some unused includes to fix layering.
David Blaikie [Thu, 29 Mar 2018 00:29:45 +0000 (00:29 +0000)]
Remove some unused includes to fix layering.

llvm-svn: 328745

6 years agoSplit Disassembler.h in two to fix dependencies
David Blaikie [Thu, 29 Mar 2018 00:29:44 +0000 (00:29 +0000)]
Split Disassembler.h in two to fix dependencies

Support includes this header for the typedefs - but logically it's part
of the MC/Disassembler library that implements the functions. Split the
header so as not to create a circular dependency.

This is another case where probably inverting the llvm-c implementation
might be best (rather than core llvm libraries implementing the parts of
llvm-c - instead llvm-c could be its own library, depending on all the
parts of LLVM's core libraries to then implement llvm-c on top of
them... if that makes sense)

llvm-svn: 328744

6 years agoAdd missing dependency (headers are included from MC, so a link dependency could...
David Blaikie [Thu, 29 Mar 2018 00:29:43 +0000 (00:29 +0000)]
Add missing dependency (headers are included from MC, so a link dependency could exist easily enough)

llvm-svn: 328743

6 years ago[ASan] Disable aligned_alloc-alignment.cc on ppc64be
Alex Shlyapnikov [Thu, 29 Mar 2018 00:09:12 +0000 (00:09 +0000)]
[ASan] Disable aligned_alloc-alignment.cc on ppc64be

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

llvm-svn: 328742

6 years ago[ASan] Disable aligned_alloc-alignment.cc test on gcc.
Alex Shlyapnikov [Wed, 28 Mar 2018 23:01:04 +0000 (23:01 +0000)]
[ASan] Disable aligned_alloc-alignment.cc test on gcc.

This check "CHECK: {{#0 0x.* in .*aligned_alloc}}" fails on ppc64be, gcc
build. Disabling the test for gcc for now.

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

llvm-svn: 328741

6 years agoRename NonLocal -> Global.
Rui Ueyama [Wed, 28 Mar 2018 22:55:40 +0000 (22:55 +0000)]
Rename NonLocal -> Global.

NonLocal is technically more accurate, but we already use the term
"Global" to specify the non-local part of the symbol table, and
Local <-> Global is easier to digest.

llvm-svn: 328740

6 years agoMove code so that the code matches with a comment. NFC.
Rui Ueyama [Wed, 28 Mar 2018 22:47:53 +0000 (22:47 +0000)]
Move code so that the code matches with a comment. NFC.

llvm-svn: 328739

6 years agoStrip @VER suffices from the LTO output.
Rafael Espindola [Wed, 28 Mar 2018 22:45:39 +0000 (22:45 +0000)]
Strip @VER suffices from the LTO output.

This fixes pr36623.

The problem is that we have to parse versions out of names before LTO
so that LTO can use that information.

When we get the LTO produced .o files, we replace the previous symbols
with the LTO produced ones, but they still have @ in their names.

We could just trim the name directly, but calling parseSymbolVersion
to do it is simpler.

llvm-svn: 328738

6 years agoPlumb useAA through TargetTransformInfo to remove Transforms->CodeGen header dependency
David Blaikie [Wed, 28 Mar 2018 22:28:50 +0000 (22:28 +0000)]
Plumb useAA through TargetTransformInfo to remove Transforms->CodeGen header dependency

Thanks to echristo for the pointers on direction.

llvm-svn: 328737

6 years agoUnloop a for-loop so that we can comment on each symbol. NFC.
Rui Ueyama [Wed, 28 Mar 2018 22:09:40 +0000 (22:09 +0000)]
Unloop a for-loop so that we can comment on each symbol. NFC.

llvm-svn: 328736

6 years ago[Basic] Fix some Clang-tidy modernize and Include What You Use warnings; other minor...
Eugene Zelenko [Wed, 28 Mar 2018 22:09:09 +0000 (22:09 +0000)]
[Basic] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).

llvm-svn: 328735

6 years ago[ASan] Disable aligned_alloc-alignment.cc on Android.
Alex Shlyapnikov [Wed, 28 Mar 2018 22:00:08 +0000 (22:00 +0000)]
[ASan] Disable aligned_alloc-alignment.cc on Android.

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

llvm-svn: 328734

6 years agoMerge nested "if"s. NFC.
Rui Ueyama [Wed, 28 Mar 2018 21:53:10 +0000 (21:53 +0000)]
Merge nested "if"s. NFC.

llvm-svn: 328733

6 years agoELF: Make required Thunk methods pure virtual and remove an unused argument. NFC.
Peter Collingbourne [Wed, 28 Mar 2018 21:33:31 +0000 (21:33 +0000)]
ELF: Make required Thunk methods pure virtual and remove an unused argument. NFC.

Also make certain Thunk methods non-const as this will be required for
an upcoming change.

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

llvm-svn: 328732

6 years ago[ObjC++] Make parameter passing and function return compatible with ObjC
Akira Hatanaka [Wed, 28 Mar 2018 21:13:14 +0000 (21:13 +0000)]
[ObjC++] Make parameter passing and function return compatible with ObjC

ObjC and ObjC++ pass non-trivial structs in a way that is incompatible
with each other. For example:

typedef struct {
  id f0;
  __weak id f1;
} S;

// this code is compiled in c++.
extern "C" {
  void foo(S s);
}

void caller() {
  // the caller passes the parameter indirectly and destructs it.
  foo(S());
}

// this function is compiled in c.
// 'a' is passed directly and is destructed in the callee.
void foo(S a) {
}

This patch fixes the incompatibility by passing and returning structs
with __strong or weak fields using the C ABI in C++ mode. __strong and
__weak fields in a struct do not cause the struct to be destructed in
the caller and __strong fields do not cause the struct to be passed
indirectly.

Also, this patch fixes the microsoft ABI bug mentioned here:

https://reviews.llvm.org/D41039?id=128767#inline-364710

rdar://problem/38887866

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

llvm-svn: 328731