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

7 years agoRemove lock from ConstString::GetLength
Pavel Labath [Fri, 28 Apr 2017 12:08:28 +0000 (12:08 +0000)]
Remove lock from ConstString::GetLength

Summary: ConstStrings are immutable, so there is no need to grab even a reader lock in order to read the length field.

Reviewers: #lldb, labath

Reviewed By: labath

Subscribers: zturner, labath, lldb-commits

Differential Revision: https://reviews.llvm.org/D32306
Patch by Scott Smith <scott.smith@purestorage.com>

llvm-svn: 301642

7 years ago[X86][SSE] Added new tests from D32416 to show codegen delta
Simon Pilgrim [Fri, 28 Apr 2017 11:53:08 +0000 (11:53 +0000)]
[X86][SSE] Added new tests from D32416 to show codegen delta

llvm-svn: 301641

7 years ago[Polly] [PPCGCodeGeneration] Add managed memory support to GPU code
Siddharth Bhat [Fri, 28 Apr 2017 11:16:30 +0000 (11:16 +0000)]
[Polly] [PPCGCodeGeneration] Add managed memory support to GPU code
generation.

This needs changes to GPURuntime to expose synchronization between host
and device.

1. Needs better function naming, I want a better name than
"getOrCreateManagedDeviceArray"

2. DeviceAllocations is used by both the managed memory and the
non-managed memory path. This exploits the fact that the two code paths
are never run together. I'm not sure if this is the best design decision

Reviewed by: PhilippSchaad

Tags: #polly

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

llvm-svn: 301640

7 years ago[X86][SSE] Renames all ones test to better match type.
Simon Pilgrim [Fri, 28 Apr 2017 11:12:30 +0000 (11:12 +0000)]
[X86][SSE] Renames all ones test to better match type.

Added 8f32/4f64 optsize tests discussed on D32416

llvm-svn: 301639

7 years ago[X86][SSE] Add codegen test for _mm_set_pd1 (PR32827)
Simon Pilgrim [Fri, 28 Apr 2017 10:31:42 +0000 (10:31 +0000)]
[X86][SSE] Add codegen test for _mm_set_pd1 (PR32827)

llvm-svn: 301638

7 years ago[X86][SSE] Add _mm_set_pd1 (PR32827)
Simon Pilgrim [Fri, 28 Apr 2017 10:28:32 +0000 (10:28 +0000)]
[X86][SSE] Add _mm_set_pd1 (PR32827)

Matches _mm_set_ps1 implementation

llvm-svn: 301637

7 years agoResurrect pselect MainLoop implementation
Pavel Labath [Fri, 28 Apr 2017 10:26:06 +0000 (10:26 +0000)]
Resurrect pselect MainLoop implementation

Summary:
It turns out that even though ppoll is available on all the android
devices we support, it does not seem to be working properly on all of
them -- MainLoop just does a busy loop with ppoll returning EINTR and
not making any progress.

This brings back the pselect implementation and makes it available on
android. I could not do any cmake checks for this as the ppoll symbol is
actually avaiable -- it just does not work.

Reviewers: beanz, eugene

Subscribers: srhines, lldb-commits

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

llvm-svn: 301636

7 years ago[index] Handle vector types in USR generator
Alex Lorenz [Fri, 28 Apr 2017 09:46:36 +0000 (09:46 +0000)]
[index] Handle vector types in USR generator

rdar://25339187

llvm-svn: 301635

7 years ago[ARM] GlobalISel: fixup r301632
Diana Picus [Fri, 28 Apr 2017 09:20:31 +0000 (09:20 +0000)]
[ARM] GlobalISel: fixup r301632

Actually remove ARMInstructionSelector.h... Forgot to stage the removal
in the previous commit.

llvm-svn: 301633

7 years ago[ARM] GlobalISel: Get rid of ARMInstructionSelector.h. NFC.
Diana Picus [Fri, 28 Apr 2017 09:10:38 +0000 (09:10 +0000)]
[ARM] GlobalISel: Get rid of ARMInstructionSelector.h. NFC.

Declare the ARMInstructionSelector in an anonymous namespace, to make it
more in line with the other targets which were migrated to this in
r299637 in order to avoid TableGen'erated headers being included in
non-GlobalISel builds.

llvm-svn: 301632

7 years ago[DWARF] - Fix mistype in dump output of pub* tables. NFC.
George Rimar [Fri, 28 Apr 2017 08:54:10 +0000 (08:54 +0000)]
[DWARF] - Fix mistype in dump output of pub* tables. NFC.

There was a garbage character in output introduced by myself in
r290040 "[DWARF] - Introduce DWARFDebugPubTable class for dumping pub* sections."

llvm-svn: 301631

7 years ago[DebugInfo][X86] Improve X86 Optimize LEAs handling of debug values.
Andrew Ng [Fri, 28 Apr 2017 08:44:30 +0000 (08:44 +0000)]
[DebugInfo][X86] Improve X86 Optimize LEAs handling of debug values.

This is a follow up to the fix in r298360 to improve the handling of debug
values when redundant LEAs are removed. The fix in r298360 effectively
discarded the debug values. This patch now attempts to preserve the debug
values by using the DWARF DW_OP_stack_value operation via prependDIExpr.

Moved functions appendOffset and prependDIExpr from Local.cpp to
DebugInfoMetadata.cpp and made them available as static member functions of
DIExpression.

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

llvm-svn: 301630

7 years ago[WebAssembly] Update calls to computeKnownBits after the changes from r301620.
Craig Topper [Fri, 28 Apr 2017 08:15:33 +0000 (08:15 +0000)]
[WebAssembly] Update calls to computeKnownBits after the changes from r301620.

I didn't realize WebAssembly wasn't a default build target so I missed that changes were needed.

llvm-svn: 301629

7 years ago[X86][NFC] Refactor RepMovsRepeats in preparation for D32481.
Clement Courbet [Fri, 28 Apr 2017 07:56:31 +0000 (07:56 +0000)]
[X86][NFC] Refactor RepMovsRepeats in preparation for D32481.

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

llvm-svn: 301628

7 years ago[ARM] GlobalISel: Tighten test. NFC
Diana Picus [Fri, 28 Apr 2017 07:50:47 +0000 (07:50 +0000)]
[ARM] GlobalISel: Tighten test. NFC

Explicitly check types and load sizes in the IRTranslator test.

llvm-svn: 301627

7 years ago[ValueTracking] Convert computeKnownBitsFromRangeMetadata to use KnownBits struct.
Craig Topper [Fri, 28 Apr 2017 06:28:56 +0000 (06:28 +0000)]
[ValueTracking] Convert computeKnownBitsFromRangeMetadata to use KnownBits struct.

llvm-svn: 301626

7 years ago[EarlyCSE] Mark the condition of assume intrinsic as true
Max Kazantsev [Fri, 28 Apr 2017 06:25:39 +0000 (06:25 +0000)]
[EarlyCSE] Mark the condition of assume intrinsic as true

EarlyCSE should not just ignore assumes. It should use the fact that its condition is true for all dominated instructions.

Reviewers: sanjoy, reames, apilipenko, anna, skatkov

Reviewed By: reames, sanjoy

Subscribers: llvm-commits

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

llvm-svn: 301625

7 years agoUpdate to isl-0.18-592-gb50ad59
Tobias Grosser [Fri, 28 Apr 2017 06:11:17 +0000 (06:11 +0000)]
Update to isl-0.18-592-gb50ad59

This is just a general maintenance update.

llvm-svn: 301624

7 years ago[EarlyCSE] Remove guards with conditions known to be true
Max Kazantsev [Fri, 28 Apr 2017 06:05:48 +0000 (06:05 +0000)]
[EarlyCSE] Remove guards with conditions known to be true

If a condition is calculated only once, and there are multiple guards on this condition, we should be able
to remove all guards dominated by the first of them. This patch allows EarlyCSE to try to find the condition
of a guard among the known values, and if it is true, remove the guard. Otherwise we keep the guard and
mark its condition as 'true' for future consideration.

Reviewers: sanjoy, reames, apilipenko, skatkov, anna, dberlin

Reviewed By: reames, sanjoy

Subscribers: llvm-commits

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

llvm-svn: 301623

7 years agoFix unset-insert-libraries-on-exec.cc to use "%env" to make it work in iOS simulator.
Kuba Mracek [Fri, 28 Apr 2017 05:50:46 +0000 (05:50 +0000)]
Fix unset-insert-libraries-on-exec.cc to use "%env" to make it work in iOS simulator.

llvm-svn: 301622

7 years agoFix the reexec-insert-libraries-env.cc testcase to use %env to make it work on iOS...
Kuba Mracek [Fri, 28 Apr 2017 05:48:27 +0000 (05:48 +0000)]
Fix the reexec-insert-libraries-env.cc testcase to use %env to make it work on iOS simulator.

llvm-svn: 301621

7 years ago[SelectionDAG] Use KnownBits struct in DAG's computeKnownBits and simplifyDemandedBits
Craig Topper [Fri, 28 Apr 2017 05:31:46 +0000 (05:31 +0000)]
[SelectionDAG] Use KnownBits struct in DAG's computeKnownBits and simplifyDemandedBits

This patch replaces the separate APInts for KnownZero/KnownOne with a single KnownBits struct. This is similar to what was done to ValueTracking's version recently.

This is largely a mechanical transformation from KnownZero to Known.Zero.

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

llvm-svn: 301620

7 years agoclang/test/ARCMT/remap-applying.c: Use %/s on the command line of echo(1).
NAKAMURA Takumi [Fri, 28 Apr 2017 05:02:52 +0000 (05:02 +0000)]
clang/test/ARCMT/remap-applying.c: Use %/s on the command line of echo(1).

llvm-svn: 301619

7 years ago[SelectionDAG] Use various APInt methods to reduce temporary APInt creation
Craig Topper [Fri, 28 Apr 2017 04:57:59 +0000 (04:57 +0000)]
[SelectionDAG] Use various APInt methods to reduce temporary APInt creation

This patch uses various APInt methods to reduce the number of temporary APInts. These were all found while working through converting SelectionDAG's computeKnownBits to also use the KnownBits struct recently added to the ValueTracking version.

llvm-svn: 301618

7 years ago[asan] Add a compilation wrapper that codesigns shared libraries to support iOS simul...
Kuba Mracek [Fri, 28 Apr 2017 04:55:35 +0000 (04:55 +0000)]
[asan] Add a compilation wrapper that codesigns shared libraries to support iOS simulator testing

Tests that run on the iOS simulator require the dlopen'd dylibs are codesigned. This patch adds the "iossim_compile.py" wrapper that codesigns any produces dylib.

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

llvm-svn: 301617

7 years agoRemove unnecessary semicolon
Sanjoy Das [Fri, 28 Apr 2017 04:49:32 +0000 (04:49 +0000)]
Remove unnecessary semicolon

This shows up as a -Wpendatic error on GCC.

llvm-svn: 301616

7 years ago[StackMaps] Increase the size of the "location size" field
Sanjoy Das [Fri, 28 Apr 2017 04:48:42 +0000 (04:48 +0000)]
[StackMaps] Increase the size of the "location size" field

Summary:
In some cases LLVM (especially the SLP vectorizer) will create vectors
that are 256 bytes (or larger).  Given that this is intentional[0] is
likely to get more common, this patch updates the StackMap binary
format to deal with the spill locations for said vectors.

This change also bumps the stack map version from 2 to 3.

[0]: https://reviews.llvm.org/D32533#738350

Reviewers: reames, kavon, skatkov, javed.absar

Subscribers: mcrosier, nemanjai, llvm-commits

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

llvm-svn: 301615

7 years agoCOFF Import: expose both symbols
Saleem Abdulrasool [Fri, 28 Apr 2017 04:29:43 +0000 (04:29 +0000)]
COFF Import: expose both symbols

COFF Import libraries which use the obsolete CONSTANT export are
supposed to get two symbols, one with the `_imp_` prefix and one
without.  Ensure that we expose both for iteration.  This is necessary
to fix the librarian with COFF CONSTANT exports.

llvm-svn: 301614

7 years agoclang/test/Index/index-module.m: Relax expressions to satisfy DOSish path separator...
NAKAMURA Takumi [Fri, 28 Apr 2017 04:17:31 +0000 (04:17 +0000)]
clang/test/Index/index-module.m: Relax expressions to satisfy DOSish path separator \\, since r301597.

llvm-svn: 301613