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

7 years agoCleanup: Use DIExpression::prepend in buildDbgValueForSpill(). (NFC)
Adrian Prantl [Fri, 28 Apr 2017 18:30:36 +0000 (18:30 +0000)]
Cleanup: Use DIExpression::prepend in buildDbgValueForSpill(). (NFC)

llvm-svn: 301665

7 years agoAdd remaining SBTrace headers to LLDB framework
Tim Hammerquist [Fri, 28 Apr 2017 18:10:53 +0000 (18:10 +0000)]
Add remaining SBTrace headers to LLDB framework

llvm-svn: 301664

7 years ago[IR] Delete unused Argument::removeAttr overload
Reid Kleckner [Fri, 28 Apr 2017 17:58:18 +0000 (17:58 +0000)]
[IR] Delete unused Argument::removeAttr overload

It doesn't make sense to remove an AttributeList from an argument.

llvm-svn: 301663

7 years agoClean up DIExpression::prependDIExpr a little. (NFC)
Adrian Prantl [Fri, 28 Apr 2017 17:51:05 +0000 (17:51 +0000)]
Clean up DIExpression::prependDIExpr a little. (NFC)

llvm-svn: 301662

7 years agoRemove a redundant local variable.
Rui Ueyama [Fri, 28 Apr 2017 17:50:23 +0000 (17:50 +0000)]
Remove a redundant local variable.

llvm-svn: 301661

7 years agoBitcode: Do not remove empty summary entries when reading a per-module summary.
Peter Collingbourne [Fri, 28 Apr 2017 17:41:43 +0000 (17:41 +0000)]
Bitcode: Do not remove empty summary entries when reading a per-module summary.

This became no longer necessary after D19462 landed, and will be incompatible
with an upcoming change to the summary data structures that changes how we
represent references.

llvm-svn: 301660

7 years agoSpeed up the -Map option.
Rui Ueyama [Fri, 28 Apr 2017 17:19:13 +0000 (17:19 +0000)]
Speed up the -Map option.

We found that some part of code for the -Map option takes O(m*n)
where m is the number of input sections in some file and n is
the number of symbols in the same file. If you do LTO, we usually
have only a few object files as inputs for the -Map option
feature, so this performance characteristic was worse than I
expected.

This patch rewrites the -Map option feature to speed it up.
I eliminated the O(m*n) bottleneck and also used multi-threading.

As a result, clang link time with the -Map option improved from
18.7 seconds to 11.2 seconds. Without -Map, it takes 7.7 seconds,
so the -Map option is now about 3x faster than before for this
test case (from 11.0 seconds to 3.5 seconds.) The generated output
file size was 223 MiB, and the file contains 1.2M lines.

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

llvm-svn: 301659

7 years agoIR: fix some doxygen grammar (NFC)
Saleem Abdulrasool [Fri, 28 Apr 2017 17:18:28 +0000 (17:18 +0000)]
IR: fix some doxygen grammar (NFC)

Fix a bit of the doxygen grammar that was off that I noticed while
looking at this file for another issue.

llvm-svn: 301658

7 years agoCOFF: actually synthesize CONST imports properly
Saleem Abdulrasool [Fri, 28 Apr 2017 17:06:40 +0000 (17:06 +0000)]
COFF: actually synthesize CONST imports properly

CONSTANT imports expect both the `_imp_` prefixed and non-prefixed
symbols should be added to the symbol table.  This allows for linking
symbols like _NSConcreteGlobalBlock in WinObjC.  The previous change
would generate the import library properly by handling the option but
would not consume the generated entry properly.

llvm-svn: 301657

7 years ago[APInt] Add clearSignBit method. Use it and setSignBit in a few places. NFCI
Craig Topper [Fri, 28 Apr 2017 16:58:05 +0000 (16:58 +0000)]
[APInt] Add clearSignBit method. Use it and setSignBit in a few places. NFCI

llvm-svn: 301656

7 years ago[LazyValueInfo] Fix typo in comment. NFC
Craig Topper [Fri, 28 Apr 2017 16:57:59 +0000 (16:57 +0000)]
[LazyValueInfo] Fix typo in comment. NFC

llvm-svn: 301655

7 years ago[ValueTracking] Use APInt::isSubsetOf and APInt::intersects. NFC
Craig Topper [Fri, 28 Apr 2017 16:57:55 +0000 (16:57 +0000)]
[ValueTracking] Use APInt::isSubsetOf and APInt::intersects. NFC

llvm-svn: 301654

7 years ago[bpf] add bigendian support to disassembler
Alexei Starovoitov [Fri, 28 Apr 2017 16:51:01 +0000 (16:51 +0000)]
[bpf] add bigendian support to disassembler

. swap 4-bit register encoding, 16-bit offset and 32-bit imm to support big endian archs
. add a test

Reported-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
llvm-svn: 301653

7 years ago[DOXYGEN] Minor improvements in doxygen comments.
Ekaterina Romanova [Fri, 28 Apr 2017 16:45:39 +0000 (16:45 +0000)]
[DOXYGEN] Minor improvements in doxygen comments.

- I removed doxygen comments for the intrinsics that "alias" the other existing documented intrinsics and that only sligtly differ in spelling (single underscores vs. double underscores).
 #define _tzcnt_u16(a)     (__tzcnt_u16((a)))

It will be very hard to keep the documentation for these "aliases" in sync with the documentation for the intrinsics they alias to. Out of sync documentation will be more confusing than no documentation.

I got an OK from Eric Christopher to commit doxygen comments without prior code
review upstream.

llvm-svn: 301652

7 years ago[clang-tidy] modernize-use-emplace: remove unnecessary make_pair calls
Jakub Kuderski [Fri, 28 Apr 2017 16:25:45 +0000 (16:25 +0000)]
[clang-tidy] modernize-use-emplace: remove unnecessary make_pair calls

Summary:
When there is a push_back with a call to make_pair, turn it into emplace_back and remove the unnecessary make_pair call.

Eg.

```
std::vector<std::pair<int, int>> v;
v.push_back(std::make_pair(1, 2)); // --> v.emplace_back(1, 2);
```

make_pair doesn't get removed when explicit template parameters are provided, because of potential problems with type conversions.

Reviewers: Prazek, aaron.ballman, hokein, alexfh

Reviewed By: Prazek, alexfh

Subscribers: JDevlieghere, JonasToth, cfe-commits

Tags: #clang-tools-extra

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

llvm-svn: 301651

7 years agoCMake: ignore git stderr when trying to sort out revision. NFC.
Tim Northover [Fri, 28 Apr 2017 16:06:00 +0000 (16:06 +0000)]
CMake: ignore git stderr when trying to sort out revision. NFC.

llvm-svn: 301650

7 years ago[InlineCost] Improve the cost heuristic for Switch
Jun Bum Lim [Fri, 28 Apr 2017 16:04:03 +0000 (16:04 +0000)]
[InlineCost] Improve the cost heuristic for Switch

Summary:
The motivation example is like below which has 13 cases but only 2 distinct targets

```
lor.lhs.false2:                                   ; preds = %if.then
  switch i32 %Status, label %if.then27 [
    i32 -7012, label %if.end35
    i32 -10008, label %if.end35
    i32 -10016, label %if.end35
    i32 15000, label %if.end35
    i32 14013, label %if.end35
    i32 10114, label %if.end35
    i32 10107, label %if.end35
    i32 10105, label %if.end35
    i32 10013, label %if.end35
    i32 10011, label %if.end35
    i32 7008, label %if.end35
    i32 7007, label %if.end35
    i32 5002, label %if.end35
  ]
```
which is compiled into a balanced binary tree like this on AArch64 (similar on X86)

```
.LBB853_9:                              // %lor.lhs.false2
        mov     w8, #10012
        cmp             w19, w8
        b.gt    .LBB853_14
// BB#10:                               // %lor.lhs.false2
        mov     w8, #5001
        cmp             w19, w8
        b.gt    .LBB853_18
// BB#11:                               // %lor.lhs.false2
        mov     w8, #-10016
        cmp             w19, w8
        b.eq    .LBB853_23
// BB#12:                               // %lor.lhs.false2
        mov     w8, #-10008
        cmp             w19, w8
        b.eq    .LBB853_23
// BB#13:                               // %lor.lhs.false2
        mov     w8, #-7012
        cmp             w19, w8
        b.eq    .LBB853_23
        b       .LBB853_3
.LBB853_14:                             // %lor.lhs.false2
        mov     w8, #14012
        cmp             w19, w8
        b.gt    .LBB853_21
// BB#15:                               // %lor.lhs.false2
        mov     w8, #-10105
        add             w8, w19, w8
        cmp             w8, #9          // =9
        b.hi    .LBB853_17
// BB#16:                               // %lor.lhs.false2
        orr     w9, wzr, #0x1
        lsl     w8, w9, w8
        mov     w9, #517
        and             w8, w8, w9
        cbnz    w8, .LBB853_23
.LBB853_17:                             // %lor.lhs.false2
        mov     w8, #10013
        cmp             w19, w8
        b.eq    .LBB853_23
        b       .LBB853_3
.LBB853_18:                             // %lor.lhs.false2
        mov     w8, #-7007
        add             w8, w19, w8
        cmp             w8, #2          // =2
        b.lo    .LBB853_23
// BB#19:                               // %lor.lhs.false2
        mov     w8, #5002
        cmp             w19, w8
        b.eq    .LBB853_23
// BB#20:                               // %lor.lhs.false2
        mov     w8, #10011
        cmp             w19, w8
        b.eq    .LBB853_23
        b       .LBB853_3
.LBB853_21:                             // %lor.lhs.false2
        mov     w8, #14013
        cmp             w19, w8
        b.eq    .LBB853_23
// BB#22:                               // %lor.lhs.false2
        mov     w8, #15000
        cmp             w19, w8
        b.ne    .LBB853_3
```
However, the inline cost model estimates the cost to be linear with the number
of distinct targets and the cost of the above switch is just 2 InstrCosts.
The function containing this switch is then inlined about 900 times.

This change use the general way of switch lowering for the inline heuristic. It
etimate the number of case clusters with the suitability check for a jump table
or bit test. Considering the binary search tree built for the clusters, this
change modifies the model to be linear with the size of the balanced binary
tree. The model is off by default for now :
  -inline-generic-switch-cost=false

This change was originally proposed by Haicheng in D29870.

Reviewers: hans, bmakam, chandlerc, eraman, haicheng, mcrosier

Reviewed By: hans

Subscribers: joerg, aemerson, llvm-commits, rengolin

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

llvm-svn: 301649

7 years ago[libclang] Expose some target information via the C API.
Emilio Cobos Alvarez [Fri, 28 Apr 2017 15:56:39 +0000 (15:56 +0000)]
[libclang] Expose some target information via the C API.

This allows users to query the target triple and target pointer width, which
would make me able to fix https://github.com/servo/rust-bindgen/issues/593 and
other related bugs in an elegant way (without having to manually parse the
target triple in the command line arguments).

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

llvm-svn: 301648

7 years agoUse the -Wunknown-warning-option group for the "unknown warning group"
Alex Lorenz [Fri, 28 Apr 2017 14:45:25 +0000 (14:45 +0000)]
Use the -Wunknown-warning-option group for the "unknown warning group"
diagnostic in #pragma diagnostic

This matches the warning group that's specified for the unknown warning options
that are passed-in as command line arguments.

rdar://29526025

llvm-svn: 301647

7 years agoMove variable local to where ita used. NFCI.
Simon Pilgrim [Fri, 28 Apr 2017 14:42:15 +0000 (14:42 +0000)]
Move variable local to where ita used. NFCI.

llvm-svn: 301646

7 years agoMemory intrinsic value profile optimization: Avoid divide by 0
Teresa Johnson [Fri, 28 Apr 2017 14:30:54 +0000 (14:30 +0000)]
Memory intrinsic value profile optimization: Avoid divide by 0

Summary:
Skip memops if the total value profiled count is 0, we can't correctly
scale up the counts and there is no point anyway.

Reviewers: davidxl

Subscribers: llvm-commits

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

llvm-svn: 301645

7 years ago[DAGCombiner] Add ComputeNumSignBits vector demanded elements support to ASHR and...
Simon Pilgrim [Fri, 28 Apr 2017 13:21:18 +0000 (13:21 +0000)]
[DAGCombiner] Add ComputeNumSignBits vector demanded elements support to ASHR and INSERT_VECTOR_ELT (reapplied)

Reapplied r299221 after fix for nondeterminism in ThinLTO builder (rL301599), with extra check for implicit truncation of inserted element.

llvm-svn: 301644

7 years ago[Sema] Avoid an invalid redefinition error that was presented for
Alex Lorenz [Fri, 28 Apr 2017 12:30:05 +0000 (12:30 +0000)]
[Sema] Avoid an invalid redefinition error that was presented for
of a function whose previous definition was typo-corrected

rdar://28550928

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

llvm-svn: 301643