platform/upstream/llvm.git
7 years ago[MVT] fix typo in size of v1i8 MVT.
Guy Blank [Sun, 30 Apr 2017 12:47:57 +0000 (12:47 +0000)]
[MVT] fix typo in size of v1i8 MVT.

Ths issue was found in the review of another patch https://reviews.llvm.org/D32540

llvm-svn: 301770

7 years ago[APInt] Remove support for wrapping from APInt::setBits.
Craig Topper [Sun, 30 Apr 2017 07:45:01 +0000 (07:45 +0000)]
[APInt] Remove support for wrapping from APInt::setBits.

This features isn't used anywhere in tree. It's existence seems to be preventing selfhost builds from inlining any of the setBits methods including setLowBits, setHighBits, and setBitsFrom. This is because the code makes the method recursive.

If anyone needs this feature in the future we could consider adding a setBitsWithWrap method. This way only the calls that need it would pay for it.

llvm-svn: 301769

7 years ago[APInt] Replace calls to setBits with more specific calls to setBitsFrom and setLowBi...
Craig Topper [Sun, 30 Apr 2017 07:44:58 +0000 (07:44 +0000)]
[APInt] Replace calls to setBits with more specific calls to setBitsFrom and setLowBits where possible.

llvm-svn: 301768

7 years ago[X86] Clear KnownBits instead of reconstructing it. NFC
Craig Topper [Sun, 30 Apr 2017 07:44:55 +0000 (07:44 +0000)]
[X86] Clear KnownBits instead of reconstructing it. NFC

llvm-svn: 301767

7 years agoInstructionSimplify: Canonicalize shuffle operands. NFC-ish.
Zvi Rackover [Sun, 30 Apr 2017 06:25:04 +0000 (06:25 +0000)]
InstructionSimplify: Canonicalize shuffle operands. NFC-ish.

Summary:
 Apply canonicalization rules:
    1. Input vectors with no elements selected from can be replaced with undef.
    2. If only one input vector is constant it shall be the second one.

This allows constant-folding to cover more ad-hoc simplifications that
were in place and avoid duplication for RHS and LHS checks.

There are more rules we may want to add in the future when we see a
justification. e.g. mask elements that select undef elements can be
replaced with undef.

Reviewers: spatel, RKSimon, andreadb, davide

Reviewed By: spatel, RKSimon

Subscribers: llvm-commits

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

llvm-svn: 301766

7 years agoInstructionSimplify: One getShuffleMask() replacing multiple getMaskValue(). NFC.
Zvi Rackover [Sun, 30 Apr 2017 06:10:54 +0000 (06:10 +0000)]
InstructionSimplify: One getShuffleMask() replacing multiple getMaskValue(). NFC.

Summary: This is a preparatory step for D32338.

Reviewers: RKSimon, spatel

Reviewed By: RKSimon, spatel

Subscribers: spatel, llvm-commits

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

llvm-svn: 301765

7 years agoInstructionSimplify: Simplify a shuffle with a undef mask to undef
Zvi Rackover [Sun, 30 Apr 2017 06:06:26 +0000 (06:06 +0000)]
InstructionSimplify: Simplify a shuffle with a undef mask to undef

Summary:
Following the discussion in pr32486, adding the simplification:
 shuffle %x, %y, undef -> undef

Reviewers: spatel, RKSimon, andreadb, davide

Reviewed By: spatel

Subscribers: jroelofs, davide, llvm-commits

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

llvm-svn: 301764

7 years ago[mips] Emit R_MICROMIPS_TLS_GOTTPREL relocation for %gottprel in case of microMIPS
Simon Atanasyan [Sun, 30 Apr 2017 04:27:23 +0000 (04:27 +0000)]
[mips] Emit R_MICROMIPS_TLS_GOTTPREL relocation for %gottprel in case of microMIPS

In case of microMIPS mode %gottprel operator should emit microMIPS
relocation R_MICROMIPS_TLS_GOTTPREL, not R_MIPS_TLS_GOTTPREL.

Differential Revision: http://reviews.llvm.org/D32617

llvm-svn: 301763

7 years agoclang-tools-extra/test/CMakeLists.txt: Rework r297806 (D29851) to make sure test...
NAKAMURA Takumi [Sun, 30 Apr 2017 03:19:04 +0000 (03:19 +0000)]
clang-tools-extra/test/CMakeLists.txt: Rework r297806 (D29851) to make sure test utils should be built.

FIXME: This may be moved to llvm's add_lit_target().
llvm-svn: 301762

7 years ago[ConstantRange] Fix a couple cases where we were possibly throwing away an APInt...
Craig Topper [Sun, 30 Apr 2017 00:44:05 +0000 (00:44 +0000)]
[ConstantRange] Fix a couple cases where we were possibly throwing away an APInt allocation we could reuse. NFC

This uses setAllBits to replace getMaxValue and operator=(uint64_t) instead of constructing an APInt from uint64_t.

llvm-svn: 301761

7 years agoInclude <cstdio> in PrettyStackTrace.cpp, since it uses vsnprintf(3).
Dimitry Andric [Sat, 29 Apr 2017 23:45:30 +0000 (23:45 +0000)]
Include <cstdio> in PrettyStackTrace.cpp, since it uses vsnprintf(3).

llvm-svn: 301760

7 years agoRename RPath Rpath for consistency. NFC.
Rui Ueyama [Sat, 29 Apr 2017 23:06:43 +0000 (23:06 +0000)]
Rename RPath Rpath for consistency. NFC.

For an option -foo-bar-baz, we have Config->FooBarBaz. Since -rpath is
-rpath and not -r-path, it should be Config->Rpath instead Config->RPath.

llvm-svn: 301759

7 years agoSimplify by using getString instead of getLastArg. NFC.
Rui Ueyama [Sat, 29 Apr 2017 22:56:38 +0000 (22:56 +0000)]
Simplify by using getString instead of getLastArg. NFC.

llvm-svn: 301758

7 years agoReport an error if --compress-debug-sections is given while zlib is not availble.
Rui Ueyama [Sat, 29 Apr 2017 22:56:24 +0000 (22:56 +0000)]
Report an error if --compress-debug-sections is given while zlib is not availble.

llvm-svn: 301757

7 years ago[globalisel][tablegen] Fix the test after silencing the unused variable warning in...
Daniel Sanders [Sat, 29 Apr 2017 19:46:27 +0000 (19:46 +0000)]
[globalisel][tablegen] Fix the test after silencing the unused variable warning in r301755.

llvm-svn: 301756

7 years ago[globalisel][tablegen] Silence unused variable warning.
Daniel Sanders [Sat, 29 Apr 2017 19:10:19 +0000 (19:10 +0000)]
[globalisel][tablegen] Silence unused variable warning.

llvm-svn: 301755

7 years agoPort recent changes to ELF/MapFile.cpp to COFF.
Rui Ueyama [Sat, 29 Apr 2017 18:50:39 +0000 (18:50 +0000)]
Port recent changes to ELF/MapFile.cpp to COFF.

llvm-svn: 301754

7 years ago[ConstantRange] Use APInt::getOneBitSet to shorten some code. NFC
Craig Topper [Sat, 29 Apr 2017 17:59:41 +0000 (17:59 +0000)]
[ConstantRange] Use APInt::getOneBitSet to shorten some code. NFC

llvm-svn: 301753

7 years ago[ConstantRange] Replace getMaxValue+zext with getLowBitsSet. Replace zero-init+setBit...
Craig Topper [Sat, 29 Apr 2017 17:46:13 +0000 (17:46 +0000)]
[ConstantRange] Replace getMaxValue+zext with getLowBitsSet. Replace zero-init+setBit with getOneBitSet. NFC

llvm-svn: 301752

7 years ago[ConstantRange] Use APInt::operator-= to remove temporary APInts.
Craig Topper [Sat, 29 Apr 2017 17:46:11 +0000 (17:46 +0000)]
[ConstantRange] Use APInt::operator-= to remove temporary APInts.

llvm-svn: 301751

7 years ago[globalisel][tablegen] Compute available feature bits correctly.
Daniel Sanders [Sat, 29 Apr 2017 17:30:09 +0000 (17:30 +0000)]
[globalisel][tablegen] Compute available feature bits correctly.

Summary:
Predicate<> now has a field to indicate how often it must be recomputed.
Currently, there are two frequencies, per-module (RecomputePerFunction==0)
and per-function (RecomputePerFunction==1). Per-function predicates are
currently recomputed more frequently than necessary since the only predicate
in this category is cheap to test. Per-module predicates are now computed in
getSubtargetImpl() while per-function predicates are computed in selectImpl().

Tablegen now manages the PredicateBitset internally. It should only be
necessary to add the required includes.

Also fixed a problem revealed by the test case where
constrainSelectedInstRegOperands() would attempt to tie operands that
BuildMI had already tied.

Reviewers: ab, qcolombet, t.p.northover, rovka, aditya_nandakumar

Reviewed By: rovka

Subscribers: kristof.beyls, igorb, llvm-commits

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

llvm-svn: 301750

7 years ago[X86][AVX] Added support for _mm256_zext* helper intrinsics (PR32839)
Simon Pilgrim [Sat, 29 Apr 2017 17:17:06 +0000 (17:17 +0000)]
[X86][AVX] Added support for _mm256_zext* helper intrinsics (PR32839)

llvm-svn: 301749

7 years ago[X86][AVX] Added codegen tests for _mm256_zext* helper intrinsics (PR32839)
Simon Pilgrim [Sat, 29 Apr 2017 17:15:12 +0000 (17:15 +0000)]
[X86][AVX] Added codegen tests for _mm256_zext* helper intrinsics (PR32839)

Not great codegen, especially as VEX moves support implicit zeroing of upper bits....

llvm-svn: 301748

7 years ago[KnownBits] Add methods for determining if the known bits represent a negative/nonneg...
Craig Topper [Sat, 29 Apr 2017 16:43:11 +0000 (16:43 +0000)]
[KnownBits] Add methods for determining if the known bits represent a negative/nonnegative number and add methods for changing the negative/nonnegative state

Summary: This patch adds isNegative, isNonNegative for querying whether the sign bit is known. It also adds makeNegative and makeNonNegative for controlling the sign bit.

Reviewers: RKSimon, spatel, davide

Reviewed By: RKSimon

Subscribers: llvm-commits

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

llvm-svn: 301747

7 years ago[mips][FastISel] Fix a nullptr deference.
Simon Dardis [Sat, 29 Apr 2017 16:31:40 +0000 (16:31 +0000)]
[mips][FastISel] Fix a nullptr deference.

r301392 introduced a potential nullptr deference causing compilation
failures.

llvm-svn: 301746

7 years agoBring back r301678.
Rafael Espindola [Sat, 29 Apr 2017 15:44:03 +0000 (15:44 +0000)]
Bring back r301678.

This version uses a set to speed up the synchronize method.

Original message:

    Remove LinkerScript::flush.

    This patch replaces flush with a last ditch attempt at synchronizing
    the section list with the linker script "AST".

    The synchronization is a bit of a hack and should in time be avoided
    by creating the AST earlier so that modifications can be made directly
    to it instead of modifying the section list and synchronizing it back.

    This is the main step for fixing
    https://bugs.llvm.org/show_bug.cgi?id=32816. With this in place I
    think the only missing thing would be to have processCommands assign
    section indexes as dummy offsets so that the sort in
    OutputSection::finalize works.

    With this LinkerScript::assignAddresses becomes much simpler, which
    should help with the thunk work.

llvm-svn: 301745

7 years ago[X86][SSE] Add initial <2 x half> tests for PR31088
Simon Pilgrim [Sat, 29 Apr 2017 14:29:06 +0000 (14:29 +0000)]
[X86][SSE] Add initial <2 x half> tests for PR31088

As discussed on D32391, test X86/X64 SSE2 and X64 F16C.

llvm-svn: 301744

7 years ago[clang-tidy] Expand AllowConditional*Casts to binary logical operators
Alexander Kornienko [Sat, 29 Apr 2017 12:06:45 +0000 (12:06 +0000)]
[clang-tidy] Expand AllowConditional*Casts to binary logical operators

llvm-svn: 301743

7 years agoRemove Sema::CheckForIntOverflow, and instead check all full-expressions.
Nick Lewycky [Sat, 29 Apr 2017 09:33:46 +0000 (09:33 +0000)]
Remove Sema::CheckForIntOverflow, and instead check all full-expressions.

CheckForIntOverflow used to implement a whitelist of top-level expressions to
send to the constant expression evaluator, which handled many more expressions
than the CheckForIntOverflow whitelist did.

llvm-svn: 301742

7 years ago[ConstantRange] Use ternary operator instead of 'if' to avoid copying an APInt and...
Craig Topper [Sat, 29 Apr 2017 07:24:13 +0000 (07:24 +0000)]
[ConstantRange] Use ternary operator instead of 'if' to avoid copying an APInt and then possibly copying over it.

llvm-svn: 301741

7 years ago[ConstantRange] Add std::move to a bunch of places that pass local APInts to Constant...
Craig Topper [Sat, 29 Apr 2017 06:40:47 +0000 (06:40 +0000)]
[ConstantRange] Add std::move to a bunch of places that pass local APInts to ConstantRange constructor.

The ConstantRange constructor takes APInt by value so without these moves we are making copies.

llvm-svn: 301740

7 years agoRemove unused private field.
Zachary Turner [Sat, 29 Apr 2017 05:30:19 +0000 (05:30 +0000)]
Remove unused private field.

llvm-svn: 301738

7 years ago[ConstantRange] Remove a temporary APInt I meant to delete in r300621. NFC
Craig Topper [Sat, 29 Apr 2017 05:24:34 +0000 (05:24 +0000)]
[ConstantRange] Remove a temporary APInt I meant to delete in r300621. NFC

llvm-svn: 301737

7 years ago[ConstantRange] Improve the efficiency of one of the ConstantRange constructors.
Craig Topper [Sat, 29 Apr 2017 05:08:52 +0000 (05:08 +0000)]
[ConstantRange] Improve the efficiency of one of the ConstantRange constructors.

We were default constructing the Lower/Upper APInts. Then creating min or max value, then doing a move assignment to Lower and copy assignment to upper. The copy assignment operator in particular has an out of line function call that has to examine whether or not a previous allocation exists that can be reused which of course it can't in this case.

The new code creates the min/max value first, move constructs Lower from it then copy constructs Upper from Lower.

This also seems to have convinced a self host build that this constructor can be inlined more readily into other methods in ConstantRange.

llvm-svn: 301736

7 years agoFix PR32831: 'this capture while instantiating generic lambda call operator specializ...
Faisal Vali [Sat, 29 Apr 2017 03:49:17 +0000 (03:49 +0000)]
Fix PR32831: 'this capture while instantiating generic lambda call operator specialization

When computing the appropriate cv-qualifiers for the 'this' capture, we have to examine each enclosing lambda - but when using the FunctionScopeInfo stack we have to ensure that the lambda below (outer) is the decl-context of the closure-class of the current lambda.

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

llvm-svn: 301735

7 years ago[Polly] Make PollyCore depends on intrinsics_gen
Hongbin Zheng [Sat, 29 Apr 2017 03:12:17 +0000 (03:12 +0000)]
[Polly] Make PollyCore depends on intrinsics_gen

llvm-svn: 301734

7 years agoRemove some apparently-unnecessary 'REQUIRES: system-darwin' from tests.
Richard Smith [Sat, 29 Apr 2017 01:38:29 +0000 (01:38 +0000)]
Remove some apparently-unnecessary 'REQUIRES: system-darwin' from tests.

Let's see if any buildbots actually have trouble with these. (They at least pass on Linux.)

llvm-svn: 301732

7 years agoFix "REQUIRES: system-darwin" failing tests after r301725.
Richard Smith [Sat, 29 Apr 2017 01:29:44 +0000 (01:29 +0000)]
Fix "REQUIRES: system-darwin" failing tests after r301725.

Also remove the apparently-unneeded REQUIRES (the tests also pass on at least
Linux, and don't appear to have anything Darwin-specific in them).

llvm-svn: 301731

7 years agoAMDGPU: Fix copies from physical registers in SIFixSGPRCopies
Matt Arsenault [Sat, 29 Apr 2017 01:26:34 +0000 (01:26 +0000)]
AMDGPU: Fix copies from physical registers in SIFixSGPRCopies

This would assert when there were multiple defs of
a physical register.

We just need to move all of the users of it.

llvm-svn: 301730

7 years ago[ELF] When a rel points to a SHF_MERGE section, don't merge the sec.
Davide Italiano [Sat, 29 Apr 2017 01:24:34 +0000 (01:24 +0000)]
[ELF] When a rel points to a SHF_MERGE section, don't merge the sec.

Fixes PR32785. Thanks to Piotr Padlewski for the report and
Rafael for the fix.

llvm-svn: 301729

7 years ago[llvm-pdbdump] Abstract some of the YAML/Raw printing code.
Zachary Turner [Sat, 29 Apr 2017 01:13:21 +0000 (01:13 +0000)]
[llvm-pdbdump] Abstract some of the YAML/Raw printing code.

There is a lot of duplicate code for printing line info between
YAML and the raw output printer.  This introduces a base class
that can be shared between the two, and makes some minor
cleanups in the process.

llvm-svn: 301728

7 years agoPR26771: don't forget the " 2" (returning from #included file) linemarker after inclu...
Richard Smith [Sat, 29 Apr 2017 00:54:03 +0000 (00:54 +0000)]
PR26771: don't forget the " 2" (returning from #included file) linemarker after including an empty file with -frewrite-includes.

llvm-svn: 301727

7 years agoRemove unused, empty test directories.
Richard Smith [Sat, 29 Apr 2017 00:46:27 +0000 (00:46 +0000)]
Remove unused, empty test directories.

llvm-svn: 301726

7 years agoAdd pragma to perform module import and use it in -E output.
Richard Smith [Sat, 29 Apr 2017 00:34:47 +0000 (00:34 +0000)]
Add pragma to perform module import and use it in -E output.

Many of our supported configurations support modules but do not have any
first-class syntax to perform a module import. This leaves us with a problem:
there is no way to represent the expansion of a #include that imports a module
in the -E output for such languages. (We don't want to just leave it as a
#include because that requires the consumer of the preprocessed source to have
the same file system layout and include paths as the creator.)

This patch adds a new pragma:

  #pragma clang module import MODULE.NAME.HERE

that imports a module, and changes -E and -frewrite-includes to use it when
rewriting a #include that maps to a module import. We don't make any attempt
to use a native language syntax import if one exists, to get more consistent
output. (If in the future, @import and #include have different semantics in
some way, the pragma will track the #include semantics.)

llvm-svn: 301725

7 years ago[ObjCARC] Do not move a release between a call and a
Akira Hatanaka [Sat, 29 Apr 2017 00:23:11 +0000 (00:23 +0000)]
[ObjCARC] Do not move a release between a call and a
retainAutoreleasedReturnValue that retains the returned value.

This commit fixes a bug in ARC optimizer where it moves a release
between a call and a retainAutoreleasedReturnValue, causing the returned
object to be released before the retainAutoreleasedReturnValue can
retain it.

This commit accomplishes that by doing a lookahead and checking whether
the call prevents the release from moving upwards. In the long term, we
should treat the region between the retainAutoreleasedReturnValue and
the call as a critical section and disallow moving anything there
(possibly using operand bundles).

rdar://problem/20449878

llvm-svn: 301724

7 years ago[LoopUnswitch] Make DEBUG output more readable (part 2).
Davide Italiano [Sat, 29 Apr 2017 00:18:26 +0000 (00:18 +0000)]
[LoopUnswitch] Make DEBUG output more readable (part 2).

I fixed my miscompile in r301722 and I hope I don't have to take
a look at this code again now that Chandler has a new LoopUnswitch
pass, but maybe this could be of use for somebody else in the
meanwhile.

llvm-svn: 301723

7 years ago[LoopUnswitch] Don't remove instructions with side effects.
Davide Italiano [Sat, 29 Apr 2017 00:12:18 +0000 (00:12 +0000)]
[LoopUnswitch] Don't remove instructions with side effects.

This fixes PR32818.

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

llvm-svn: 301722

7 years agoObjCBoxedExpr can't be evaluated by the constant expression evaluator.
Nick Lewycky [Sat, 29 Apr 2017 00:07:27 +0000 (00:07 +0000)]
ObjCBoxedExpr can't be evaluated by the constant expression evaluator.

A boxed expression evaluates its subexpr and then calls an objc method to transform it into another value with pointer type. The objc method can never be constexpr and therefore this expression can never be evaluated. Fixes a miscompile boxing expressions with side-effects.

Also make ObjCBoxedExpr handling a normal part of the expression evaluator instead of being the only case besides full-expression where we check for integer overflow.

llvm-svn: 301721

7 years ago[llvm-readobj] Fix incorrect printing of CV column info.
Zachary Turner [Sat, 29 Apr 2017 00:03:32 +0000 (00:03 +0000)]
[llvm-readobj] Fix incorrect printing of CV column info.

llvm-svn: 301720

7 years agoFuzzer: Mark test/cxxstring.test UNSUPPORTED: windows
Duncan P. N. Exon Smith [Fri, 28 Apr 2017 23:59:53 +0000 (23:59 +0000)]
Fuzzer: Mark test/cxxstring.test UNSUPPORTED: windows

This has been mysteriously failing since r301593, which cleaned up the
types of things like size_t and SIZE_MAX for freestanding targets.  Reid
and Kostya suggested marking it as UNSUPPORTED on windows, given that no
one has been able to reproduce locally.

llvm-svn: 301719

7 years ago[llvm-readobj] Use LLVMDebugInfoCodeView to parse line tables.
Zachary Turner [Fri, 28 Apr 2017 23:41:36 +0000 (23:41 +0000)]
[llvm-readobj] Use LLVMDebugInfoCodeView to parse line tables.

The llvm-readobj parsing code currently exists in our CodeView
library, so we use that to parse instead of re-writing the logic
in the tool.

llvm-svn: 301718

7 years ago[Support] Provide unsafe random access for VarStreamArray.
Zachary Turner [Fri, 28 Apr 2017 23:29:33 +0000 (23:29 +0000)]
[Support] Provide unsafe random access for VarStreamArray.

llvm-svn: 301716

7 years agoReplace PrettyPrinter class in MapFile.cpp with a few non-member functions.
Rui Ueyama [Fri, 28 Apr 2017 23:29:15 +0000 (23:29 +0000)]
Replace PrettyPrinter class in MapFile.cpp with a few non-member functions.

Since the output format has been simplified, the class to print
out a map file doesn't seem to be needed anymore. We can replace
it with a few non-member functions.

llvm-svn: 301715

7 years ago[InstCombine] add tests to show potentially bogus application of DeMorgan (NFC)
Sanjay Patel [Fri, 28 Apr 2017 23:14:33 +0000 (23:14 +0000)]
[InstCombine] add tests to show potentially bogus application of DeMorgan (NFC)

llvm-svn: 301714

7 years agoRemove set but unused variable in BitcodeReader.cpp. NFC.
Hans Wennborg [Fri, 28 Apr 2017 23:11:16 +0000 (23:11 +0000)]
Remove set but unused variable in BitcodeReader.cpp. NFC.

llvm-svn: 301713

7 years agoRevert r301697 "[IR] Make add/remove Attributes use AttrBuilder instead of AttributeList"
Hans Wennborg [Fri, 28 Apr 2017 23:01:32 +0000 (23:01 +0000)]
Revert r301697 "[IR] Make add/remove Attributes use AttrBuilder instead of AttributeList"

This broke the Clang build. (Clang-side patch missing?)

Original commit message:

> [IR] Make add/remove Attributes use AttrBuilder instead of
> AttributeList
>
> This change cleans up call sites and avoids creating temporary
> AttributeList objects.
>
> NFC

llvm-svn: 301712

7 years agoInferAddressSpaces: Search constant expressions for addrspacecasts
Matt Arsenault [Fri, 28 Apr 2017 22:52:41 +0000 (22:52 +0000)]
InferAddressSpaces: Search constant expressions for addrspacecasts

These are pretty common when using local memory, and the 64-bit generic
addressing is much more expensive to compute.

llvm-svn: 301711

7 years agoEliminate .debug_gnu_pub{names,types} if -gdb-index is given.
Rui Ueyama [Fri, 28 Apr 2017 22:46:55 +0000 (22:46 +0000)]
Eliminate .debug_gnu_pub{names,types} if -gdb-index is given.

This patch is to ignore .debug_gnu_pub{names,types} sections if the
-gdb-index option was given.

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

llvm-svn: 301710

7 years agoRevert r301678: Remove LinkerScript::flush.
Rui Ueyama [Fri, 28 Apr 2017 22:40:58 +0000 (22:40 +0000)]
Revert r301678: Remove LinkerScript::flush.

This reverts commit r301678 since that change significantly slowed
down the linker. Before this patch, LLD could link clang in 8 seconds,
but with this patch it took 40 seconds.

llvm-svn: 301709

7 years agoAdapt to LLVM API change (DINamespace no longer takes line/file info).
Adrian Prantl [Fri, 28 Apr 2017 22:25:53 +0000 (22:25 +0000)]
Adapt to LLVM API change (DINamespace no longer takes line/file info).

rdar://problem/17484998
https://reviews.llvm.org/D32648

llvm-svn: 301707

7 years agoRemove line and file from DINamespace.
Adrian Prantl [Fri, 28 Apr 2017 22:25:46 +0000 (22:25 +0000)]
Remove line and file from DINamespace.

Fixes the issue highlighted in
http://lists.llvm.org/pipermail/cfe-dev/2014-June/037500.html.

The DW_AT_decl_file and DW_AT_decl_line attributes on namespaces can
prevent LLVM from uniquing types that are in the same namespace. They
also don't carry any meaningful information.

rdar://problem/17484998
Differential Revision: https://reviews.llvm.org/D32648

llvm-svn: 301706

7 years agoInferAddressSpaces: Avoid looking up deleted values
Matt Arsenault [Fri, 28 Apr 2017 22:18:19 +0000 (22:18 +0000)]
InferAddressSpaces: Avoid looking up deleted values

While looking at pure addressing expressions, it's possible
for the value to appear later in Postorder.

I haven't been able to come up with a testcase where this
exhibits an actual issue, but if you insert a dump before
the value map lookup, a few testcases crash.

llvm-svn: 301705

7 years agoInferAddressSpaces: Infer from just addrspacecasts
Matt Arsenault [Fri, 28 Apr 2017 22:18:08 +0000 (22:18 +0000)]
InferAddressSpaces: Infer from just addrspacecasts

Eliminates some more cases where some subset of the addressing
computation remains flat. Some cases with addrspacecasts
in nested constant expressions are still left behind however.

llvm-svn: 301704

7 years ago[SCEV] Use early exit in createAddRecFromPHI. NFC.
Michael Zolotukhin [Fri, 28 Apr 2017 22:14:27 +0000 (22:14 +0000)]
[SCEV] Use early exit in createAddRecFromPHI. NFC.

llvm-svn: 301703

7 years agoLoopRotate: Fix use after scope bug
Daniel Berlin [Fri, 28 Apr 2017 22:05:55 +0000 (22:05 +0000)]
LoopRotate: Fix use after scope bug

llvm-svn: 301702

7 years ago[ODRHash] Add testcase with different paramter names. NFC
Richard Trieu [Fri, 28 Apr 2017 22:03:28 +0000 (22:03 +0000)]
[ODRHash] Add testcase with different paramter names.  NFC

llvm-svn: 301701

7 years ago[RDF] Correctly calculate lane masks for defs
Krzysztof Parzyszek [Fri, 28 Apr 2017 21:57:53 +0000 (21:57 +0000)]
[RDF] Correctly calculate lane masks for defs

llvm-svn: 301700

7 years agoProperly handle PHIs with subregisters in UnreachableBlockElim
Krzysztof Parzyszek [Fri, 28 Apr 2017 21:56:33 +0000 (21:56 +0000)]
Properly handle PHIs with subregisters in UnreachableBlockElim

When a PHI operand has a subregister, create a COPY instead of simply
replacing the PHI output with the input it.

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

llvm-svn: 301699

7 years ago[Hexagon] Do not move a block if it is on a fall-through path
Krzysztof Parzyszek [Fri, 28 Apr 2017 21:54:11 +0000 (21:54 +0000)]
[Hexagon] Do not move a block if it is on a fall-through path

llvm-svn: 301698

7 years ago[IR] Make add/remove Attributes use AttrBuilder instead of AttributeList
Reid Kleckner [Fri, 28 Apr 2017 21:48:28 +0000 (21:48 +0000)]
[IR] Make add/remove Attributes use AttrBuilder instead of AttributeList

This change cleans up call sites and avoids creating temporary
AttributeList objects.

NFC

llvm-svn: 301697

7 years ago[ConstantRange] Use APInt::isNullValue rather than APInt::isMinValue where it would...
Craig Topper [Fri, 28 Apr 2017 21:48:09 +0000 (21:48 +0000)]
[ConstantRange] Use APInt::isNullValue rather than APInt::isMinValue where it would make more sense to thing of 0 as 0 rather than the minimum unsigned value. NFC

llvm-svn: 301696

7 years ago[APInt] Add an isNullValue method to check for all bits being zero. Use it in a coupl...
Craig Topper [Fri, 28 Apr 2017 21:48:06 +0000 (21:48 +0000)]
[APInt] Add an isNullValue method to check for all bits being zero. Use it in a couple internal methods where it makes more sense than isMinValue or !getBoolValue. NFC

I used Null rather than Zero to match the getNullValue method name.

There are some other places outside APInt where isNullValue would be more readable than isMinValue even though they do the same thing. I'll update those in future patches.

llvm-svn: 301695

7 years ago[ConstantRange] Use const references to prevent a couple APInt copies. NFC
Craig Topper [Fri, 28 Apr 2017 21:48:03 +0000 (21:48 +0000)]
[ConstantRange] Use const references to prevent a couple APInt copies. NFC

llvm-svn: 301694

7 years agoFlush output in log()
Hans Wennborg [Fri, 28 Apr 2017 21:35:02 +0000 (21:35 +0000)]
Flush output in log()

This change was motivated by output from lld-link.exe and link.exe
getting intermixed. There's already a flush() call in message(), so
there's precedence.

llvm-svn: 301693

7 years ago[LoopUnswitch] Make DEBUG output more readable.
Davide Italiano [Fri, 28 Apr 2017 21:30:50 +0000 (21:30 +0000)]
[LoopUnswitch] Make DEBUG output more readable.

While debugging a miscompile I realized loopunswitch doesn't
put newlines when printing the instruction being replacement.
Ending up with a single line with many instruction replaced isn't
the best for readability and/or mental sanity.

llvm-svn: 301692

7 years agoRename one of the variables to avoid confusion.
Rafael Espindola [Fri, 28 Apr 2017 21:23:43 +0000 (21:23 +0000)]
Rename one of the variables to avoid confusion.

llvm-svn: 301691

7 years ago[WebAssembly] Add size of section header to data relocation offsets.
Sam Clegg [Fri, 28 Apr 2017 21:22:38 +0000 (21:22 +0000)]
[WebAssembly] Add size of section header to data relocation offsets.

Also, add test for data relocations and fix addend to
be signed.

Subscribers: jfb, dschuff

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

llvm-svn: 301690

7 years ago[tests] Ensure all test cases use named variables
Tobias Grosser [Fri, 28 Apr 2017 21:16:29 +0000 (21:16 +0000)]
[tests] Ensure all test cases use named variables

This makes it easier to read and possibly even modify the test cases, as there
is no need to keep the variable increment in steps of one. More importantly, by
using explicit variable names we do not need to rely on the implicit numbering
of statements when dumping the scop information.

This makes it easier to read and possibly even modify the test cases.
Furthermore, by using explicit variables we do not need to rely on the implicit
numbering of statements when dumping the scop information. In a future commit,
this implicit numbering will likely not be used any more to refer to LLVM-IR
values as it is very expensive to construct.

llvm-svn: 301689

7 years ago[ValueTracking] Teach isSafeToSpeculativelyExecute() about the speculatable attribute
Matt Arsenault [Fri, 28 Apr 2017 21:13:09 +0000 (21:13 +0000)]
[ValueTracking] Teach isSafeToSpeculativelyExecute() about the speculatable attribute

Patch by Tom Stellard

llvm-svn: 301688

7 years ago[WebAssembly] Write initial memory in pages not bytes
Sam Clegg [Fri, 28 Apr 2017 21:12:09 +0000 (21:12 +0000)]
[WebAssembly] Write initial memory in pages not bytes

Subscribers: jfb, dschuff

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

llvm-svn: 301687

7 years agoPublic headers need to be public.
Tim Hammerquist [Fri, 28 Apr 2017 21:03:18 +0000 (21:03 +0000)]
Public headers need to be public.

llvm-svn: 301686

7 years agoTableGen: Add IntrHasSideEffects property for intrinsics
Matt Arsenault [Fri, 28 Apr 2017 21:01:46 +0000 (21:01 +0000)]
TableGen: Add IntrHasSideEffects property for intrinsics

The IntrNoMem, IntrReadMem, IntrWriteMem, and IntrArgMemOnly intrinsic
properties differ from their corresponding LLVM IR attributes by specifying
that the intrinsic, in addition to its memory properties, has no other side
effects.

The IntrHasSideEffects flag used in combination with one of the memory flags
listed above, makes it possible to define an intrinsic such that its
properties at the CodeGen layer match its properties at the IR layer.

Patch by Tom Stellard

llvm-svn: 301685

7 years agoEnable -fno-split-dwarf-inlining even when -gsplit-dwarf isn't specified.
David Blaikie [Fri, 28 Apr 2017 20:50:25 +0000 (20:50 +0000)]
Enable -fno-split-dwarf-inlining even when -gsplit-dwarf isn't specified.

Since -gsplit-dwarf is specified on a backend compile (in ThinLTO
parlance) it isn't passed during the frontend compile (because no ELF
object/dwo file is produced then), yet the -fno-split-dwarf-inlining
value needs to be encoded in the LLVM DebugInfo metadata to have
effect...

So let it be specified & it'll be silently ignored if -gsplit-dwarf
isn't used in the end, otherwise it'll be used on a per-cu basis
depending on where it's specified in the frontend compile actions.

llvm-svn: 301684

7 years agoChange the format of the map file.
Rui Ueyama [Fri, 28 Apr 2017 20:38:27 +0000 (20:38 +0000)]
Change the format of the map file.

Previously, we printed out input sections and input files in
separate columns as shown below.

  Address          Size             Align Out     In      File    Symbol
  0000000000201000 0000000000000015     4 .text
  0000000000201000 000000000000000e     4         .text
  0000000000201000 000000000000000e     4                 foo.o
  0000000000201000 0000000000000000     0                         _start
  0000000000201005 0000000000000000     0                         f(int)
  000000000020100e 0000000000000000     0                         local
  0000000000201010 0000000000000002     4                 bar.o
  0000000000201010 0000000000000000     0                         foo
  0000000000201011 0000000000000000     0                         bar

This format doesn't make much sense because for each input section,
there's always exactly one input file. This patch changes the format
to this.

  Address          Size             Align Out     In      Symbol
  0000000000201000 0000000000000015     4 .text
  0000000000201000 000000000000000e     4         foo.o:(.text)
  0000000000201000 0000000000000000     0                 _start
  0000000000201005 0000000000000000     0                 f(int)
  000000000020100e 0000000000000000     0                 local
  0000000000201010 0000000000000002     4         bar.o:(.text)
  0000000000201010 0000000000000000     0                 foo
  0000000000201011 0000000000000000     0                 bar

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

llvm-svn: 301683

7 years agoMake getParamAlignment use argument numbers
Reid Kleckner [Fri, 28 Apr 2017 20:34:27 +0000 (20:34 +0000)]
Make getParamAlignment use argument numbers

The method is called "get *Param* Alignment", and is only used for
return values exactly once, so it should take argument indices, not
attribute indices.

Avoids confusing code like:
  IsSwiftError = CS->paramHasAttr(ArgIdx, Attribute::SwiftError);
  Alignment  = CS->getParamAlignment(ArgIdx + 1);

Add getRetAlignment to handle the one case in Value.cpp that wants the
return value alignment.

This is a potentially breaking change for out-of-tree backends that do
their own call lowering.

llvm-svn: 301682

7 years agoGlobalISel: Followup for r301679
Matthias Braun [Fri, 28 Apr 2017 20:31:49 +0000 (20:31 +0000)]
GlobalISel: Followup for r301679

llvm-svn: 301681

7 years agoAdd speculatable function attribute
Matt Arsenault [Fri, 28 Apr 2017 20:25:27 +0000 (20:25 +0000)]
Add speculatable function attribute

This attribute tells the optimizer that the function may be speculated.

Patch by Tom Stellard

llvm-svn: 301680

7 years agoTargetLowering: Add finalizeLowering() function; NFC
Matthias Braun [Fri, 28 Apr 2017 20:25:05 +0000 (20:25 +0000)]
TargetLowering: Add finalizeLowering() function; NFC

Adds a new method finalizeLowering to TargetLoweringBase. This is in
preparation for an upcoming commit.

This function is meant for target specific adjustments to
MachineFrameInfo or register reservations.

Move the freezeRegisters() and the hasCopyImplyingStackAdjustment()
handling into the new function to prove the concept. As an added bonus
GlobalISel no longer missed the hasCopyImplyingStackAdjustment()
handling with this.

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

llvm-svn: 301679

7 years agoRemove LinkerScript::flush.
Rafael Espindola [Fri, 28 Apr 2017 20:22:47 +0000 (20:22 +0000)]
Remove LinkerScript::flush.

This patch replaces flush with a last ditch attempt at synchronizing
the section list with the linker script "AST".

The synchronization is a bit of a hack and should in time be avoided
by creating the AST earlier so that modifications can be made directly
to it instead of modifying the section list and synchronizing it back.

This is the main step for fixing
https://bugs.llvm.org/show_bug.cgi?id=32816. With this in place I
think the only missing thing would be to have processCommands assign
section indexes as dummy offsets so that the sort in
OutputSection::finalize works.

With this LinkerScript::assignAddresses becomes much simpler, which
should help with the thunk work.

llvm-svn: 301678

7 years agoAMDGPU: Add new amdgcn.init.exec intrinsics
Marek Olsak [Fri, 28 Apr 2017 20:21:58 +0000 (20:21 +0000)]
AMDGPU: Add new amdgcn.init.exec intrinsics

v2: More tests, bug fixes, cosmetic changes.

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

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

llvm-svn: 301677

7 years agolimit to 2 parallel links when using thinlto
Bob Haarman [Fri, 28 Apr 2017 20:17:15 +0000 (20:17 +0000)]
limit to 2 parallel links when using thinlto

Summary:
When using ThinLTO, the linker performs its own parallelism. This
change limits the number of parallel link jobs that Ninja will issue
to keep the total number of threads reasonable when linking with
ThinLTO.

Reviewers: hans, ruiu

Subscribers: mgorny, mehdi_amini, Prazek

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

llvm-svn: 301676

7 years agoUse toString(Inputfile*) to format a file object.
Rui Ueyama [Fri, 28 Apr 2017 20:00:09 +0000 (20:00 +0000)]
Use toString(Inputfile*) to format a file object.

llvm-svn: 301674

7 years agoKill off the old SimplifyInstruction API by converting remaining users.
Daniel Berlin [Fri, 28 Apr 2017 19:55:38 +0000 (19:55 +0000)]
Kill off the old SimplifyInstruction API by converting remaining users.

llvm-svn: 301673

7 years ago[IPO/MergeFunctions] This function is used only under DEBUG().
Davide Italiano [Fri, 28 Apr 2017 19:39:45 +0000 (19:39 +0000)]
[IPO/MergeFunctions] This function is used only under DEBUG().

llvm-svn: 301672

7 years ago[RS4GC] Simplify attribute handling code NFC
Reid Kleckner [Fri, 28 Apr 2017 19:22:40 +0000 (19:22 +0000)]
[RS4GC] Simplify attribute handling code NFC

Avoids use of AttributeList::getNumSlots, making it easier to change the
underlying implementation.

llvm-svn: 301671

7 years ago[Codegen] Disable Polly's codegen verification by default
Tobias Grosser [Fri, 28 Apr 2017 19:15:28 +0000 (19:15 +0000)]
[Codegen] Disable Polly's codegen verification by default

As has been reported in the previous commit, codegen verification can result in
quadratic compile time increases for large functions with many scops. This is
certainly not something we would like to have in the Polly default
configuration. Hence, we disable codegen verification by default -- also to see
if this resolves some of the compilation timeouts we currently see on the AOSP
buildbots. We still leave this feature in Polly as it has shown _very_ useful
for debugging. In fact, we may want to have a discussion if we can bring this
feature back in a way that does not impact compilation time so much.

Thanks to Eli Friedman <efriedma@codeaurora.org> for reporting this issue and
for providing the test case in the previous commit (where I forgot to
acknowledge him).

llvm-svn: 301670

7 years ago[CodeGen] Skip verify if -polly-codegen-verify is set to false
Tobias Grosser [Fri, 28 Apr 2017 19:08:20 +0000 (19:08 +0000)]
[CodeGen] Skip verify if -polly-codegen-verify is set to false

Before this change, we always tried to verify the function and printed
verification errors, but just did not abort in case -polly-codegen-verify=false
was set and verification failed. As verification can become very cosly -- for
large functions with many scops we may verify the very same function very often
-- this can affect compile time very negatively. Hence, we respect the
-polly-codegen-verify flag with this check, ensuring that no verification is run
if -polly-codegen-verify=false.

This reduces code generation time from 26 seconds to 4 seconds on the test
case below with -polly-codegen-verify=false:

  struct X { int x; };
  void a();
  #define SIG (int x, X **y, X **z)
  typedef void (*fn)SIG;
  #define FN { for (int i = 0; i < x; ++i) { (*y)[i].x += (*z)[i].x; } a(); }
  #define FN5 FN FN FN FN FN
  #define FN25 FN5 FN5 FN5 FN5
  #define FN125 FN25 FN25 FN25 FN25 FN25
  #define FN250 FN125 FN125
  #define FN1250 FN250 FN250 FN250 FN250 FN250
  void x SIG { FN1250 }

llvm-svn: 301669

7 years agoRemove trailing whitespace from the -Map output.
Rui Ueyama [Fri, 28 Apr 2017 18:54:08 +0000 (18:54 +0000)]
Remove trailing whitespace from the -Map output.

If a string is shorter than 7 characters, we used to print out
trailing whitespace characters.

llvm-svn: 301668

7 years ago[CodeGen][ObjC] Don't retain captured Objective-C pointers at block
Akira Hatanaka [Fri, 28 Apr 2017 18:50:57 +0000 (18:50 +0000)]
[CodeGen][ObjC] Don't retain captured Objective-C pointers at block
creation that are const-qualified.

When a block captures an ObjC object pointer, clang retains the pointer
to prevent prematurely destroying the object the pointer points to
before the block is called or copied.

When the captured object pointer is const-qualified, we can avoid
emitting the retain/release pair since the pointer variable cannot be
modified in the scope in which the block literal is introduced.

For example:

void test(const id x) {
    callee(^{ (void)x; });
}

This patch implements that optimization.

rdar://problem/28894510

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

llvm-svn: 301667

7 years agoUse Argument::hasAttribute and AttributeList::ReturnIndex more
Reid Kleckner [Fri, 28 Apr 2017 18:37:16 +0000 (18:37 +0000)]
Use Argument::hasAttribute and AttributeList::ReturnIndex more

This eliminates many extra 'Idx' induction variables in loops over
arguments in CodeGen/ and Target/. It also reduces the number of places
where we assume that ReturnIndex is 0 and that we should add one to
argument numbers to get the corresponding attribute list index.

NFC

llvm-svn: 301666