platform/upstream/llvm.git
6 years agoRevert "[libFuzzer] Mutation tracking and logging implemented"
Matt Morehouse [Mon, 9 Jul 2018 22:31:26 +0000 (22:31 +0000)]
Revert "[libFuzzer] Mutation tracking and logging implemented"

This reverts r336597 due to bot breakage.

llvm-svn: 336616

6 years ago[WebAssembly] Support for binary atomic RMW instructions
Heejin Ahn [Mon, 9 Jul 2018 22:30:51 +0000 (22:30 +0000)]
[WebAssembly] Support for binary atomic RMW instructions

Summary:
This adds support for binary atomic read-modify-write instructions:
add, sub, and, or, xor, and xchg.

This does not yet support translations of some of LLVM IR atomicrmw
instructions (nand, max, min, umax, and umin) that do not have a direct
counterpart in wasm instructions.

Reviewers: dschuff

Subscribers: sbc100, jgravelle-google, sunfish, llvm-commits

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

llvm-svn: 336615

6 years agoSimplify RelrSection<ELFT>::updateAllocSize.
Rui Ueyama [Mon, 9 Jul 2018 22:29:57 +0000 (22:29 +0000)]
Simplify RelrSection<ELFT>::updateAllocSize.

This patch also speeds it up by making some constants compile-time
constants. Other than that, NFC.

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

llvm-svn: 336614

6 years agollvm: Add support for "-fno-delete-null-pointer-checks"
Manoj Gupta [Mon, 9 Jul 2018 22:27:23 +0000 (22:27 +0000)]
llvm: Add support for "-fno-delete-null-pointer-checks"

Summary:
Support for this option is needed for building Linux kernel.
This is a very frequently requested feature by kernel developers.

More details : https://lkml.org/lkml/2018/4/4/601

GCC option description for -fdelete-null-pointer-checks:
This Assume that programs cannot safely dereference null pointers,
and that no code or data element resides at address zero.

-fno-delete-null-pointer-checks is the inverse of this implying that
null pointer dereferencing is not undefined.

This feature is implemented in LLVM IR in this CL as the function attribute
"null-pointer-is-valid"="true" in IR (Under review at D47894).
The CL updates several passes that assumed null pointer dereferencing is
undefined to not optimize when the "null-pointer-is-valid"="true"
attribute is present.

Reviewers: t.p.northover, efriedma, jyknight, chandlerc, rnk, srhines, void, george.burgess.iv

Reviewed By: efriedma, george.burgess.iv

Subscribers: eraman, haicheng, george.burgess.iv, drinkcat, theraven, reames, sanjoy, xbolva00, llvm-commits

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

llvm-svn: 336613

6 years agoUse StringRef instead of `const char *`.
Rui Ueyama [Mon, 9 Jul 2018 22:26:49 +0000 (22:26 +0000)]
Use StringRef instead of `const char *`.

I don't think there's a need to use `const char *`. In most (probably all?)
cases, we need a length of a name later, so discarding a length will
lead to a wasted effort.

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

llvm-svn: 336612

6 years agoMake llvm.objectsize more conservative with null
George Burgess IV [Mon, 9 Jul 2018 22:21:16 +0000 (22:21 +0000)]
Make llvm.objectsize more conservative with null

In non-zero address spaces, we were reporting that an object at `null`
always occupies zero bytes. This is incorrect in many cases, so just
return `unknown` in those cases for now.

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

llvm-svn: 336611

6 years agoRename function calls missed in r336605
Richard Trieu [Mon, 9 Jul 2018 22:09:33 +0000 (22:09 +0000)]
Rename function calls missed in r336605

NextIsLatest -> isFirst

llvm-svn: 336610

6 years agoFix direct calls to __wrap_sym when it is relocated.
Rui Ueyama [Mon, 9 Jul 2018 22:03:05 +0000 (22:03 +0000)]
Fix direct calls to __wrap_sym when it is relocated.

Patch by Matthew Koontz!

Before, direct calls to __wrap_sym would not map to valid PLT entries,
so they would crash at runtime. This change maps such calls to the same
PLT entry as calls to sym that are then wrapped.

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

llvm-svn: 336609

6 years agoRollback [test-suite] Add a decorator for the lack of libstdcxx on the system.
Davide Italiano [Mon, 9 Jul 2018 21:56:28 +0000 (21:56 +0000)]
Rollback [test-suite] Add a decorator for the lack of libstdcxx on the system.

Pavel suggested an alternative approach that I'll try to implement.

llvm-svn: 336608

6 years ago[ObjCRuntime] Add support for obfuscation in tagged pointers.
Davide Italiano [Mon, 9 Jul 2018 21:53:43 +0000 (21:53 +0000)]
[ObjCRuntime] Add support for obfuscation in tagged pointers.

This is the default in MacOS Mojave. No testcases, as basically
we have a lot of coverage (and the testsuite fails quite a bit
without this change in Beta 3).

Thanks to Fred Riss for helping me with this patch (fixing
bugs/nondeterminism).

<rdar://problem/38305553>

llvm-svn: 336607

6 years ago[Index] Add index::IndexingOptions::IndexImplicitInstantiation
Fangrui Song [Mon, 9 Jul 2018 21:49:06 +0000 (21:49 +0000)]
[Index] Add index::IndexingOptions::IndexImplicitInstantiation

Summary:
With IndexImplicitInstantiation=true, the following case records an occurrence of B::bar in A::foo, which will benefit cross reference tools.

template <class T> struct B { void bar() {}};
template <class T> struct A { void foo(B<T> *x) { x->bar(); }};
int main() { A<int> a; a.foo(0); }

Reviewers: akyrtzi, arphaman, rsmith

Subscribers: cfe-commits

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

llvm-svn: 336606

6 years ago[AST] Rename some Redeclarable functions to reduce confusion
Fangrui Song [Mon, 9 Jul 2018 21:31:20 +0000 (21:31 +0000)]
[AST] Rename some Redeclarable functions to reduce confusion

Reviewers: rsmith, akyrtzi

Subscribers: cfe-commits

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

llvm-svn: 336605

6 years agoAdded -fcrash-diagnostics-dir flag
Bob Haarman [Mon, 9 Jul 2018 21:07:20 +0000 (21:07 +0000)]
Added -fcrash-diagnostics-dir flag

Summary:
New flag causes crash reports to be written in the specified directory
rather than the temp directory.

Patch by Chijioke Kamanu.

Reviewers: hans, inglorion, rnk

Reviewed By: hans

Subscribers: zturner, hiraditya, llvm-commits, cfe-commits

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

llvm-svn: 336604

6 years ago[ORC] Rename MaterializationResponsibility::delegate to replace and add a new
Lang Hames [Mon, 9 Jul 2018 20:54:36 +0000 (20:54 +0000)]
[ORC] Rename MaterializationResponsibility::delegate to replace and add a new
delegate method (and unit test).

The name 'replace' better captures what the old delegate method did: it
returned materialization responsibility for a set of symbols to the VSO.

The new delegate method delegates responsibility for a set of symbols to a new
MaterializationResponsibility instance. This can be used to split responsibility
between multiple threads, or multiple materialization methods.

llvm-svn: 336603

6 years agoFix line endings. NFCI.
Simon Pilgrim [Mon, 9 Jul 2018 20:52:07 +0000 (20:52 +0000)]
Fix line endings. NFCI.

llvm-svn: 336602

6 years ago[Power9] Add __float128 builtins for Rounding Operations
Stefan Pintilie [Mon, 9 Jul 2018 20:38:40 +0000 (20:38 +0000)]
[Power9] Add __float128 builtins for Rounding Operations

Added __float128 support for a number of rounding operations:

trunc
rint
nearbyint
round
floor
ceil

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

llvm-svn: 336601

6 years ago[Docs] Fix generation of manpages.
Michael Kruse [Mon, 9 Jul 2018 20:26:11 +0000 (20:26 +0000)]
[Docs] Fix generation of manpages.

Fix the following error when Sphinx generates the Polly manpage:

    Warning, treated as error:
    docs/Performance.rst:: WARNING: "table cell spanning" not supported

llvm-svn: 336600

6 years agoFactor out code to parse -pack-dyn-relocs. NFC.
Rui Ueyama [Mon, 9 Jul 2018 20:22:28 +0000 (20:22 +0000)]
Factor out code to parse -pack-dyn-relocs. NFC.

llvm-svn: 336599

6 years ago[WebAssembly] Improve readability of load/stores and tests. NFC.
Heejin Ahn [Mon, 9 Jul 2018 20:18:21 +0000 (20:18 +0000)]
[WebAssembly] Improve readability of load/stores and tests. NFC.

Summary:
- Changed variable/function names to be more consistent
- Improved comments in test files
- Added more tests
- Fixed a few typos
- Misc. cosmetic changes

Reviewers: dschuff

Subscribers: sbc100, jgravelle-google, sunfish, llvm-commits

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

llvm-svn: 336598

6 years ago[libFuzzer] Mutation tracking and logging implemented
Matt Morehouse [Mon, 9 Jul 2018 20:17:52 +0000 (20:17 +0000)]
[libFuzzer] Mutation tracking and logging implemented

Code now exists to track number of mutations that are used in fuzzing in
total and ones that produce new coverage. The stats are currently being
dumped to the command line.

Patch By: Kode Williams

Differntial Revision: https://reviews.llvm.org/D48054

llvm-svn: 336597

6 years ago[Power9] [CLANG] Add __float128 support for trunc to double round to odd
Stefan Pintilie [Mon, 9 Jul 2018 20:09:52 +0000 (20:09 +0000)]
[Power9] [CLANG] Add __float128 support for trunc to double round to odd

Add support for this builtin:
double builtin_truncf128_round_to_odd(float128)

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

llvm-svn: 336596

6 years ago[Power9] [LLVM] Add __float128 support for trunc to double round to odd
Stefan Pintilie [Mon, 9 Jul 2018 20:09:22 +0000 (20:09 +0000)]
[Power9] [LLVM] Add __float128 support for trunc to double round to odd

Add support for this builtin:
double builtin_truncf128_round_to_odd(float128)

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

llvm-svn: 336595

6 years agolld: add experimental support for SHT_RELR sections.
Rui Ueyama [Mon, 9 Jul 2018 20:08:55 +0000 (20:08 +0000)]
lld: add experimental support for SHT_RELR sections.

Patch by Rahul Chaudhry!

This change adds experimental support for SHT_RELR sections, proposed
here: https://groups.google.com/forum/#!topic/generic-abi/bX460iggiKg

Pass '--pack-dyn-relocs=relr' to enable generation of SHT_RELR section
and DT_RELR, DT_RELRSZ, and DT_RELRENT dynamic tags.

Definitions for the new ELF section type and dynamic array tags, as well
as the encoding used in the new section are all under discussion and are
subject to change. Use with caution!

Pass '--use-android-relr-tags' with '--pack-dyn-relocs=relr' to use
SHT_ANDROID_RELR section type instead of SHT_RELR, as well as
DT_ANDROID_RELR* dynamic tags instead of DT_RELR*. The generated
section contents are identical.

'--pack-dyn-relocs=android+relr --use-android-relr-tags' enables both
'--pack-dyn-relocs=android' and '--pack-dyn-relocs=relr': lld will
encode the relative relocations in a SHT_ANDROID_RELR section, and pack
the rest of the dynamic relocations in a SHT_ANDROID_REL(A) section.

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

llvm-svn: 336594

6 years agoRenameIndependentSubregs: Fix handling of undef tied operands
Mark Searles [Mon, 9 Jul 2018 20:07:03 +0000 (20:07 +0000)]
RenameIndependentSubregs: Fix handling of undef tied operands

Ensure that, if updating a tied operand pair, to only update
that pair.

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

llvm-svn: 336593

6 years ago[OPENMP] Do not mark local variables as declare target.
Alexey Bataev [Mon, 9 Jul 2018 19:58:08 +0000 (19:58 +0000)]
[OPENMP] Do not mark local variables as declare target.

When the parsing of the functions happens inside of the declare target
region, we may erroneously mark local variables as declare target
thought they are not. This attribute can be applied only to global
variables.

llvm-svn: 336592

6 years ago[libclang] NFC, simplify clang_Cursor_Evaluate
Alex Lorenz [Mon, 9 Jul 2018 19:56:45 +0000 (19:56 +0000)]
[libclang] NFC, simplify clang_Cursor_Evaluate

Take advantage of early returns as suggested by Duncan in
https://reviews.llvm.org/D49051

llvm-svn: 336591

6 years ago[libclang] evalute compound statement cursors before trying to evaluate
Alex Lorenz [Mon, 9 Jul 2018 19:41:28 +0000 (19:41 +0000)]
[libclang] evalute compound statement cursors before trying to evaluate
the cursor like a declaration

This change fixes a bug in libclang in which it tries to evaluate a statement
cursor as a declaration cursor, because that statement still has a pointer to
the declaration parent.

rdar://38888477

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

llvm-svn: 336590

6 years ago[globalisel][irtranslator] Add support for atomicrmw and (strong) cmpxchg
Daniel Sanders [Mon, 9 Jul 2018 19:33:40 +0000 (19:33 +0000)]
[globalisel][irtranslator] Add support for atomicrmw and (strong) cmpxchg

Summary:
This patch adds support for the atomicrmw instructions and the strong
cmpxchg instruction to the IRTranslator.

I've left out weak cmpxchg because LangRef.rst isn't entirely clear on what
difference it makes to the backend. As far as I can tell from the code, it
only matters to AtomicExpandPass which is run at the LLVM-IR level.

Reviewers: ab, t.p.northover, qcolombet, rovka, aditya_nandakumar, volkan, javed.absar

Reviewed By: qcolombet

Subscribers: kristof.beyls, javed.absar, igorb, llvm-commits

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

llvm-svn: 336589

6 years ago[AMDGPU][Waitcnt] fix "comparison of integers of different signs" build error
Mark Searles [Mon, 9 Jul 2018 19:28:14 +0000 (19:28 +0000)]
[AMDGPU][Waitcnt] fix "comparison of integers of different signs" build error

Build error on Android; reported by and fix provided by (thanks) by Mauro Rossi <issor.oruam@gmail.com>

Fixes the following building error:

external/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp:1903:61:
error: comparison of integers of different signs:
'typename iterator_traits<__wrap_iter<MachineBasicBlock **> >::difference_type'
(aka 'int') and 'unsigned int' [-Werror,-Wsign-compare]
                      BlockWaitcntProcessedSet.end(), &MBB) < Count)) {
                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~
1 error generated.

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

llvm-svn: 336588

6 years agoAMDGPU: Force inlining if LDS global address is used
Matt Arsenault [Mon, 9 Jul 2018 19:22:22 +0000 (19:22 +0000)]
AMDGPU: Force inlining if LDS global address is used

These won't work for the forseeable future. These aren't allowed
from OpenCL, but IPO optimizations can make them appear.

Also directly set the attributes on functions, regardless
of the linkage rather than cloning functions like before.

llvm-svn: 336587

6 years agoFix const cast problem introduced in r336563
Jonathan Peyton [Mon, 9 Jul 2018 19:09:31 +0000 (19:09 +0000)]
Fix const cast problem introduced in r336563

336563 eliminated CCAST() macros caused build failures

llvm-svn: 336586

6 years ago[X86][TLI] DAGCombine: Unfold variable bit-clearing mask to two shifts.
Roman Lebedev [Mon, 9 Jul 2018 19:06:42 +0000 (19:06 +0000)]
[X86][TLI] DAGCombine: Unfold variable bit-clearing mask to two shifts.

Summary:
This adds a reverse transform for the instcombine canonicalizations
that were added in D47980, D47981.

As discussed later, that was worse at least for the code size,
and potentially for the performance, too.

https://rise4fun.com/Alive/Zmpl

Reviewers: craig.topper, RKSimon, spatel

Reviewed By: spatel

Subscribers: reames, llvm-commits

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

llvm-svn: 336585

6 years ago[Index] Ignore noop #undef's when handling macro occurrences.
Eric Liu [Mon, 9 Jul 2018 19:02:41 +0000 (19:02 +0000)]
[Index] Ignore noop #undef's when handling macro occurrences.

llvm-svn: 336584

6 years ago[Builtins][Attributes][X86] Tag all X86 builtins with their required vector width...
Craig Topper [Mon, 9 Jul 2018 19:00:16 +0000 (19:00 +0000)]
[Builtins][Attributes][X86] Tag all X86 builtins with their required vector width. Add a min_vector_width function attribute and tag all x86 instrinsics with it

This is part of an ongoing attempt at making 512 bit vectors illegal in the X86 backend type legalizer due to CPU frequency penalties associated with wide vectors on Skylake Server CPUs. We want the loop vectorizer to be able to emit IR containing wide vectors as intermediate operations in vectorized code and allow these wide vectors to be legalized to 256 bits by the X86 backend even though we are targetting a CPU that supports 512 bit vectors. This is similar to what happens with an AVX2 CPU, the vectorizer can emit wide vectors and the backend will split them. We want this splitting behavior, but still be able to use new Skylake instructions that work on 256-bit vectors and support things like masking and gather/scatter.

Of course if the user uses explicit vector code in their source code we need to not split those operations. Especially if they have used any of the 512-bit vector intrinsics from immintrin.h. And we need to make it so that merely using the intrinsics produces the expected code in order to be backwards compatible.

To support this goal, this patch adds a new IR function attribute "min-legal-vector-width" that can indicate the need for a minimum vector width to be legal in the backend. We need to ensure this attribute is set to the largest vector width needed by any intrinsics from immintrin.h that the function uses. The inliner will be reponsible for merging this attribute when a function is inlined. We may also need a way to limit inlining in the future as well, but we can discuss that in the future.

To make things more complicated, there are two different ways intrinsics are implemented in immintrin.h. Either as an always_inline function containing calls to builtins(can be target specific or target independent) or vector extension code. Or as a macro wrapper around a taget specific builtin. I believe I've removed all cases where the macro was around a target independent builtin.

To support the always_inline function case this patch adds attribute((min_vector_width(128))) that can be used to tag these functions with their vector width. All x86 intrinsic functions that operate on vectors have been tagged with this attribute.

To support the macro case, all x86 specific builtins have also been tagged with the vector width that they require. Use of any builtin with this property will implicitly increase the min_vector_width of the function that calls it. I've done this as a new property in the attribute string for the builtin rather than basing it on the type string so that we can opt into it on a per builtin basis and avoid any impact to target independent builtins.

There will be future work to support vectors passed as function arguments and supporting inline assembly. And whatever else we can find that isn't covered by this patch.

Special thanks to Chandler who suggested this direction and reviewed a preview version of this patch. And thanks to Eric Christopher who has had many conversations with me about this issue.

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

llvm-svn: 336583

6 years agoDon't take the address of an xvalue when printing an expr result
Raphael Isemann [Mon, 9 Jul 2018 18:57:11 +0000 (18:57 +0000)]
Don't take the address of an xvalue when printing an expr result

Summary:
If we have an xvalue here, we will always hit the `err_typecheck_invalid_lvalue_addrof` error
in 'Sema::CheckAddressOfOperand' when trying to take the address of the result. This patch
uses the fallback code path where we store the result in a local variable instead when we hit
this case.

Fixes rdar://problem/40613277

Reviewers: jingham, vsk

Reviewed By: vsk

Subscribers: vsk, friss, lldb-commits

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

llvm-svn: 336582

6 years ago[clangd] Make sure macro information exists before increasing usage count.
Eric Liu [Mon, 9 Jul 2018 18:54:51 +0000 (18:54 +0000)]
[clangd] Make sure macro information exists before increasing usage count.

llvm-svn: 336581

6 years ago[Utils] Fix gdb pretty printers to work with Python 3.
Philip Pfaffe [Mon, 9 Jul 2018 18:51:50 +0000 (18:51 +0000)]
[Utils] Fix gdb pretty printers to work with Python 3.

Reiterate D23202 for container printers added after the change landed.

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

llvm-svn: 336580

6 years ago[Power9] Add __float128 builtins for Round To Odd
Stefan Pintilie [Mon, 9 Jul 2018 18:50:40 +0000 (18:50 +0000)]
[Power9] Add __float128 builtins for Round To Odd

Add a number of builtins for __float128 Round To Odd.
This is the Clang portion of the builtins work.

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

llvm-svn: 336579

6 years ago[Power9] Add __float128 builtins for Round To Odd
Stefan Pintilie [Mon, 9 Jul 2018 18:50:06 +0000 (18:50 +0000)]
[Power9] Add __float128 builtins for Round To Odd

GCC has builtins for these round to odd instructions:

__float128 __builtin_sqrtf128_round_to_odd (__float128)
__float128 __builtin_{add,sub,mul,div}f128_round_to_odd (__float128, __float128)
__float128 __builtin_fmaf128_round_to_odd (__float128, __float128, __float128)

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

llvm-svn: 336578

6 years ago[DebugInfo] Change default value of FDEPointerEncoding
Maksim Panchenko [Mon, 9 Jul 2018 18:45:38 +0000 (18:45 +0000)]
[DebugInfo] Change default value of FDEPointerEncoding

Summary:
If the encoding is not specified in CIE augmentation string, then it
should be DW_EH_PE_absptr instead of DW_EH_PE_omit.

Reviewers: ruiu, MaskRay, plotfi, rafauler

Reviewed By: MaskRay

Subscribers: rafauler, JDevlieghere, llvm-commits

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

llvm-svn: 336577

6 years ago[SelectionDAG] Add VT consistency checks to the creation of ISD::FMA.
Craig Topper [Mon, 9 Jul 2018 18:23:55 +0000 (18:23 +0000)]
[SelectionDAG] Add VT consistency checks to the creation of ISD::FMA.

This is similar to what is done for binops. I don't know if this would have helped us catch the bug fixed in r336566 earlier or not, but I figured it couldn't hurt.

llvm-svn: 336576

6 years ago[OpenMP] Fix a few formatting issues
Jonathan Peyton [Mon, 9 Jul 2018 18:09:25 +0000 (18:09 +0000)]
[OpenMP] Fix a few formatting issues

llvm-svn: 336575

6 years agoAdd bitcode compatibility test for 6.0
Steven Wu [Mon, 9 Jul 2018 17:57:48 +0000 (17:57 +0000)]
Add bitcode compatibility test for 6.0

Summary:
Add bitcode compatibility test for 6.0. On top of the normal disassemble
test, also runs the verifier to make sure simple 6.0 bitcode can pass
the current IR verifier.

Reviewers: vsk

Reviewed By: vsk

Subscribers: dexonsmith, llvm-commits

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

llvm-svn: 336574

6 years ago[ASan] Minor ASan error reporting cleanup
Alex Shlyapnikov [Mon, 9 Jul 2018 17:54:55 +0000 (17:54 +0000)]
[ASan] Minor ASan error reporting cleanup

Summary:
- use proper Error() decorator for error messages
- refactor ASan thread id and name reporting

Reviewers: eugenis

Subscribers: kubamracek, delcypher, #sanitizers, llvm-commits

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

llvm-svn: 336573

6 years ago[LoopInfo] Port loop exit interfaces from Loop to LoopBase
Diego Caballero [Mon, 9 Jul 2018 17:52:49 +0000 (17:52 +0000)]
[LoopInfo] Port loop exit interfaces from Loop to LoopBase

This patch ports hasDedicatedExits, getUniqueExitBlocks and
getUniqueExitBlock in Loop to LoopBase so that they can be used
from other LoopBase sub-classes.

Reviewers: chandlerc, sanjoy, hfinkel, fhahn

Reviewed By: chandlerc

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

llvm-svn: 336572

6 years ago[OpenMP] Introduce hierarchical scheduling
Jonathan Peyton [Mon, 9 Jul 2018 17:51:13 +0000 (17:51 +0000)]
[OpenMP] Introduce hierarchical scheduling

This patch introduces the logic implementing hierarchical scheduling.
First and foremost, hierarchical scheduling is off by default
To enable, use -DLIBOMP_USE_HIER_SCHED=On during CMake's configure stage.
This work is based off if the IWOMP paper:
"Workstealing and Nested Parallelism in SMP Systems"

Hierarchical scheduling is the layering of OpenMP schedules for different layers
of the memory hierarchy. One can have multiple layers between the threads and
the global iterations space. The threads will go up the hierarchy to grab
iterations, using possibly a different schedule & chunk for each layer.

[ Global iteration space (0-999) ]

(use static)
[ L1 | L1 | L1 | L1 ]

(use dynamic,1)
[ T0 T1 | T2 T3 | T4 T5 | T6 T7 ]

In the example shown above, there are 8 threads and 4 L1 caches begin targeted.
If the topology indicates that there are two threads per core, then two
consecutive threads will share the data of one L1 cache unit. This example
would have the iteration space (0-999) split statically across the four L1
caches (so the first L1 would get (0-249), the second would get (250-499), etc).
Then the threads will use a dynamic,1 schedule to grab iterations from the L1
cache units. There are currently four supported layers: L1, L2, L3, NUMA

OMP_SCHEDULE can now read a hierarchical schedule with this syntax:
OMP_SCHEDULE='EXPERIMENTAL LAYER,SCHED[,CHUNK][:LAYER,SCHED[,CHUNK]...]:SCHED,CHUNK
And OMP_SCHEDULE can still read the normal SCHED,CHUNK syntax from before

I've kept most of the hierarchical scheduling logic inside kmp_dispatch_hier.h
to try to keep it separate from the rest of the code.

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

llvm-svn: 336571

6 years ago[InstCombine] correct test comments; NFC
Sanjay Patel [Mon, 9 Jul 2018 17:48:08 +0000 (17:48 +0000)]
[InstCombine] correct test comments; NFC

llvm-svn: 336570

6 years ago[OPENMP, NVPTX] Support several images in the executable.
Alexey Bataev [Mon, 9 Jul 2018 17:46:55 +0000 (17:46 +0000)]
[OPENMP, NVPTX] Support several images in the executable.

Summary:
Currently Cuda plugin supports loading of the single image, though we
may have the executable with the several images, if it has target
regions inside of the dynamically loaded library. Patch allows to load
multiple images.

Reviewers: grokos

Subscribers: guansong, openmp-commits, kkwli0

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

llvm-svn: 336569

6 years ago[OpenMP] Restructure loop code for hierarchical scheduling
Jonathan Peyton [Mon, 9 Jul 2018 17:45:33 +0000 (17:45 +0000)]
[OpenMP] Restructure loop code for hierarchical scheduling

This patch reorganizes the loop scheduling code in order to allow hierarchical
scheduling to use it more effectively. In particular, the goal of this patch
is to separate the algorithmic parts of the scheduling from the thread
logistics code.

Moves declarations & structures to kmp_dispatch.h for easier access in
other files.  Extracts the algorithmic part of __kmp_dispatch_init() and
__kmp_dispatch_next() into __kmp_dispatch_init_algorithm() and
__kmp_dispatch_next_algorithm(). The thread bookkeeping logic is still kept in
__kmp_dispatch_init() and __kmp_dispatch_next(). This is done because the
hierarchical scheduler needs to access the scheduling logic without the
bookkeeping logic.  To prepare for new pointer in dispatch_private_info_t, a
new flags variable is created which stores the ordered and nomerge flags instead
of them being in two separate variables. This will keep the
dispatch_private_info_t structure the same size.

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

llvm-svn: 336568

6 years ago[OPENMP, NVPTX] Do not globalize local variables in parallel regions.
Alexey Bataev [Mon, 9 Jul 2018 17:43:58 +0000 (17:43 +0000)]
[OPENMP, NVPTX] Do not globalize local variables in parallel regions.

In generic data-sharing mode we are allowed to not globalize local
variables that escape their declaration context iff they are declared
inside of the parallel region. We can do this because L2 parallel
regions are executed sequentially and, thus, we do not need to put
shared local variables in the global memory.

llvm-svn: 336567

6 years ago[X86] In combineFMA, make sure we bitcast the result of isFNEG back the expected...
Craig Topper [Mon, 9 Jul 2018 17:43:24 +0000 (17:43 +0000)]
[X86] In combineFMA, make sure we bitcast the result of isFNEG back the expected type before creating the new FMA node.

Previously, we were creating malformed SDNodes, but nothing noticed because the type constraints prevented isel from noticing.

llvm-svn: 336566

6 years ago[X86][AVX] Regenerate AVX1 fast-isel tests.
Simon Pilgrim [Mon, 9 Jul 2018 17:38:00 +0000 (17:38 +0000)]
[X86][AVX] Regenerate AVX1 fast-isel tests.

Let the update script merge 32/64 tests where possible

llvm-svn: 336565

6 years agoRetrieve a function PDB symbol correctly from nested blocks
Stella Stamenova [Mon, 9 Jul 2018 17:36:33 +0000 (17:36 +0000)]
Retrieve a function PDB symbol correctly from nested blocks

Summary:
This patch fixes a problem with retrieving a function symbol by an address in a nested block. In the current implementation of ResolveSymbolContext function it retrieves a symbol with PDB_SymType::None and then checks if found symbol's tag equals to PDB_SymType::Function. So, if nested block's symbol was found, ResolveSymbolContext does not resolve a function.

It is very simple to reproduce this. For example, in the next program

```
int main() {
  auto r = 0;
  for (auto i = 1; i <= 10; i++) {
    r += i & 1 + (i - 1) & 1 - 1;
  }

  return r;
}
```

if we will stop inside the cycle and will do a backtrace, the top element will be broken. But how we can test this? I thought to add an option to lldb-test to allow search a function by address, but the address may change when the compiler will be changed.

Patch by: Aleksandr Urakov

Reviewers: asmith, labath, zturner

Reviewed By: asmith, labath

Subscribers: stella.stamenova, llvm-commits

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

llvm-svn: 336564

6 years ago[OpenMP] Use C++11 Atomics - barrier, tasking, and lock code
Jonathan Peyton [Mon, 9 Jul 2018 17:36:22 +0000 (17:36 +0000)]
[OpenMP] Use C++11 Atomics - barrier, tasking, and lock code

These are preliminary changes that attempt to use C++11 Atomics in the runtime.
We are expecting better portability with this change across architectures/OSes.
Here is the summary of the changes.

Most variables that need synchronization operation were converted to generic
atomic variables (std::atomic<T>). Variables that are updated with combined CAS
are packed into a single atomic variable, and partial read/write is done
through unpacking/packing

Patch by Hansang Bae

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

llvm-svn: 336563

6 years ago[InstCombine] avoid extra poison when moving shift above shuffle
Sanjay Patel [Mon, 9 Jul 2018 17:20:20 +0000 (17:20 +0000)]
[InstCombine] avoid extra poison when moving shift above shuffle

As discussed in D49047 / D48987, shift-by-undef produces poison,
so we can't use undef vector elements in that case..

Note that we need to extend this for poison-generating flags,
and there's a proposal to create poison from FMF in D47963,

llvm-svn: 336562

6 years ago[dsymutil] Add support for outputting assembly
Jonas Devlieghere [Mon, 9 Jul 2018 16:58:48 +0000 (16:58 +0000)]
[dsymutil] Add support for outputting assembly

When implementing the DWARF accelerator tables in dsymutil I ran into an
assertion in the assembler. Debugging these kind of issues is a lot
easier when looking at the assembly instead of debugging the assembler
itself. Since it's only a matter of creating an AsmStreamer instead of a
MCObjectStreamer it made sense to turn this into a (hidden) dsymutil
feature.

Differential revision: https://reviews.llvm.org/D49079

llvm-svn: 336561

6 years ago[BitcodeReader] Infer the correct runtime preemption for GlobalValue
Steven Wu [Mon, 9 Jul 2018 16:52:05 +0000 (16:52 +0000)]
[BitcodeReader] Infer the correct runtime preemption for GlobalValue

Summary:
To allow bitcode built by old compiler to pass the current verifer,
BitcodeReader needs to auto infer the correct runtime preemption from
linkage and visibility for GlobalValues.

Since llvm-6.0 bitcode already contains the new field but can be
incorrect in some cases, the attribute needs to be recomputed all the
time in BitcodeReader. This will make all the GVs has dso_local marked
correctly if read from bitcode, and it should still allow the verifier
to catch mistakes in optimization passes.

This should fix PR38009.

Reviewers: sfertile, vsk

Reviewed By: vsk

Subscribers: dexonsmith, llvm-commits

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

llvm-svn: 336560

6 years ago[PPC64] Add TLS local dynamic to local exec relaxation
Zaara Syeda [Mon, 9 Jul 2018 16:35:51 +0000 (16:35 +0000)]
[PPC64] Add TLS local dynamic to local exec relaxation

This patch adds the target call back relaxTlsLdToLe to support TLS relaxation
from local dynamic to local exec model.

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

llvm-svn: 336559

6 years ago[InstCombine] generalize safe vector constant utility
Sanjay Patel [Mon, 9 Jul 2018 16:16:51 +0000 (16:16 +0000)]
[InstCombine] generalize safe vector constant utility

This is almost NFC, but there could be some case where the original
code had undefs in the constants (rather than just the shuffle mask),
and we'll use safe constants rather than undefs now.

The FIXME noted in foldShuffledBinop() is already visible in existing
tests, so correcting that is the next step.

llvm-svn: 336558

6 years ago[X86] Remove some patterns that include a bitcast of a floating point load to an...
Craig Topper [Mon, 9 Jul 2018 16:03:02 +0000 (16:03 +0000)]
[X86] Remove some patterns that include a bitcast of a floating point load to an integer type.

DAG combine should have converted the type of the load.

llvm-svn: 336557

6 years ago[X86] Remove some patterns that seems to be unreachable.
Craig Topper [Mon, 9 Jul 2018 16:03:01 +0000 (16:03 +0000)]
[X86] Remove some patterns that seems to be unreachable.

These patterns mapped (v2f64 (X86vzmovl (v2f64 (scalar_to_vector FR64:$src)))) to a MOVSD and an zeroing XOR. But the complexity of a pattern for (v2f64 (X86vzmovl (v2f64))) that selects MOVQ is artificially and hides this MOVSD pattern.

Weirder still, the SSE version of the pattern was explicitly blocked on SSE41, but yet we had copied it to AVX and AVX512.

llvm-svn: 336556

6 years ago[X86] Remove some seemingly unnecessary AddedComplexity lines.
Craig Topper [Mon, 9 Jul 2018 16:02:59 +0000 (16:02 +0000)]
[X86] Remove some seemingly unnecessary AddedComplexity lines.

Looking at the generated tables this didn't seem to make an obvious difference in pattern priority.

llvm-svn: 336555

6 years ago[VPlan][LV] Introduce condition bit in VPBlockBase
Diego Caballero [Mon, 9 Jul 2018 15:57:09 +0000 (15:57 +0000)]
[VPlan][LV] Introduce condition bit in VPBlockBase

This patch introduces a VPValue in VPBlockBase to represent the condition
bit that is used as successor selector when a block has multiple successors.
This information wasn't necessary until now, when we are about to introduce
outer loop vectorization support in VPlan code gen.

Reviewers: fhahn, rengolin, mkuper, hfinkel, mssimpso

Reviewed By: fhahn

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

llvm-svn: 336554

6 years ago[clangd] Support indexing MACROs.
Eric Liu [Mon, 9 Jul 2018 15:31:07 +0000 (15:31 +0000)]
[clangd] Support indexing MACROs.

Summary: This is not enabled in the global-symbol-builder or dynamic index yet.

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, cfe-commits

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

llvm-svn: 336553

6 years ago[AArch64][SVE] Asm: Support for CNT(B|H|W|D) and CNTP instructions.
Sander de Smalen [Mon, 9 Jul 2018 15:22:08 +0000 (15:22 +0000)]
[AArch64][SVE] Asm: Support for CNT(B|H|W|D) and CNTP instructions.

This patch adds support for the following instructions:

  CNTB CNTH - Determine the number of active elements implied by
  CNTW CNTD   the named predicate constant, multiplied by an
              immediate, e.g.

                cnth x0, vl8, #16

  CNTP      - Count active predicate elements, e.g.
                cntp  x0, p0, p1.b

              counts the number of active elements in p1, predicated
              by p0, and stores the result in x0.

llvm-svn: 336552

6 years ago[CVP] Handle calls with void return value. No need to create CVPLattice state for it.
Xin Tong [Mon, 9 Jul 2018 14:53:37 +0000 (14:53 +0000)]
[CVP] Handle calls with void return value. No need to create CVPLattice state for it.

Summary:
Tests: 10
Metric: compile_time

Program                                         unpatch-result  patch-result diff

Bullet/bullet                                  32.39           30.54        -5.7%
SPASS/SPASS                                    18.14           17.25        -4.9%
mafft/pairlocalalign                           12.10           11.64        -3.8%
ClamAV/clamscan                                19.21           19.63         2.2%
7zip/7zip-benchmark                            49.55           48.85        -1.4%
kimwitu++/kc                                   15.68           15.87         1.2%
lencod/lencod                                  21.13           21.34         1.0%
consumer-typeset/consumer-typeset              13.65           13.62        -0.2%
tramp3d-v4/tramp3d-v4                          29.88           29.92         0.1%
sqlite3/sqlite3                                18.48           18.46        -0.1%
       unpatch-result  patch-result       diff
count  10.000000       10.000000     10.000000
mean   23.022000       22.712400    -0.011671
std    11.362831       11.094183     0.027338
min    12.104000       11.640000    -0.057298
25%    16.299000       16.214000    -0.032282
50%    18.844000       19.048000    -0.001350
75%    27.689000       27.774000     0.007752
max    49.552000       48.852000     0.021861

I also tested only this pass by concatenating all the code from the
llvm/lib/Analysis/ folder and do clang -g followed by opt. I get close to 20% speedup
for the pass. I expect a majority of the gain come from skipping the dbg intrinsics.

Before patch (opt -time-passes -called-value-propagation):
============
===-------------------------------------------------------------------------===
 ... Pass execution timing report ...
===-------------------------------------------------------------------------===
 Total Execution Time: 3.8303 seconds (3.8279 wall clock)

 ---User Time--- --System Time-- --User+System-- ---Wall Time--- ---
Name ---
 2.0768 ( 57.3%) 0.0990 ( 48.0%) 2.1757 ( 56.8%) 2.1757 ( 56.8%) Bitcode
Writer
 0.8444 ( 23.3%) 0.0600 ( 29.1%) 0.9044 ( 23.6%) 0.9044 ( 23.6%) Called
Value Propagation
 0.7031 ( 19.4%) 0.0472 ( 22.9%) 0.7502 ( 19.6%) 0.7478 ( 19.5%) Module
Verifier
 3.6242 (100.0%) 0.2062 (100.0%) 3.8303 (100.0%) 3.8279 (100.0%) Total

After patch (opt -time-passes -called-value-propagation):
============
===-------------------------------------------------------------------------===
 ... Pass execution timing report ...
===-------------------------------------------------------------------------===
 Total Execution Time: 3.6605 seconds (3.6579 wall clock)

 ---User Time--- --System Time-- --User+System-- ---Wall Time--- ---
Name ---
 2.0716 ( 59.7%) 0.0990 ( 52.5%) 2.1705 ( 59.3%) 2.1706 ( 59.3%) Bitcode
Writer
 0.7144 ( 20.6%) 0.0300 ( 15.9%) 0.7444 ( 20.3%) 0.7444 ( 20.4%) Called
Value Propagation
 0.6859 ( 19.8%) 0.0596 ( 31.6%) 0.7455 ( 20.4%) 0.7429 ( 20.3%) Module
Verifier
 3.4719 (100.0%) 0.1886 (100.0%) 3.6605 (100.0%) 3.6579 (100.0%) Total

Reviewers: davide, mssimpso

Subscribers: llvm-commits

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

llvm-svn: 336551

6 years ago[clangd] Mark "Document Symbols" as implemented in the docs
Marc-Andre Laperle [Mon, 9 Jul 2018 14:34:07 +0000 (14:34 +0000)]
[clangd] Mark "Document Symbols" as implemented in the docs

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

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

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

llvm-svn: 336550

6 years ago[clangd] Remove JSON library in favor of llvm/Support/JSON
Sam McCall [Mon, 9 Jul 2018 14:25:59 +0000 (14:25 +0000)]
[clangd] Remove JSON library in favor of llvm/Support/JSON

Summary:
The library has graduated from clangd to llvm/Support.
This is a mechanical change to move to the new API and remove the old one.

Main API changes:
 - namespace clang::clangd::json --> llvm::json
 - json::Expr --> json::Value
 - Expr::asString() etc --> Value::getAsString() etc
 - unsigned longs need a cast (due to r336541 adding lossless integer support)

Reviewers: ilya-biryukov

Subscribers: mgorny, ioeric, MaskRay, jkorous, omtcyfz, cfe-commits

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

llvm-svn: 336549

6 years ago[Power9] Add __float128 support for compare operations
Stefan Pintilie [Mon, 9 Jul 2018 13:36:14 +0000 (13:36 +0000)]
[Power9] Add __float128 support for compare operations

Added handling for the select f128.

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

llvm-svn: 336548

6 years ago[AArch64][SVE] Asm: Support for remaining shift instructions.
Sander de Smalen [Mon, 9 Jul 2018 13:23:41 +0000 (13:23 +0000)]
[AArch64][SVE] Asm: Support for remaining shift instructions.

This patch completes support for shifts, which include:
- LSL   - Logical Shift Left
- LSLR  - Logical Shift Left, Reversed form
- LSR   - Logical Shift Right
- LSRR  - Logical Shift Right, Reversed form
- ASR   - Arithmetic Shift Right
- ASRR  - Arithmetic Shift Right, Reversed form
- ASRD  - Arithmetic Shift Right for Divide

In the following variants:

- Predicated shift by immediate - ASR, LSL, LSR, ASRD
  e.g.
    asr z0.h, p0/m, z0.h, #1

  (active lanes of z0 shifted by #1)

- Unpredicated shift by immediate - ASR, LSL*, LSR*
  e.g.
    asr z0.h, z1.h, #1

  (all lanes of z1 shifted by #1, stored in z0)

- Predicated shift by vector - ASR, LSL*, LSR*
  e.g.
    asr z0.h, p0/m, z0.h, z1.h

  (active lanes of z0 shifted by z1, stored in z0)

- Predicated shift by vector, reversed form - ASRR, LSLR, LSRR
  e.g.
    lslr z0.h, p0/m, z0.h, z1.h

  (active lanes of z1 shifted by z0, stored in z0)

- Predicated shift left/right by wide vector - ASR, LSL, LSR
  e.g.
    lsl z0.h, p0/m, z0.h, z1.d

  (active lanes of z0 shifted by wide elements of vector z1)

- Unpredicated shift left/right by wide vector - ASR, LSL, LSR
  e.g.
    lsl z0.h, z1.h, z2.d

  (all lanes of z1 shifted by wide elements of z2, stored in z0)

*Variants added in previous patches.

llvm-svn: 336547

6 years ago[InstCombine] fix shuffle-of-binops transform to avoid poison/undef
Sanjay Patel [Mon, 9 Jul 2018 13:21:46 +0000 (13:21 +0000)]
[InstCombine] fix shuffle-of-binops transform to avoid poison/undef

As noted in D48987, there are many different ways for this transform to go wrong.
In particular, the poison potential for shifts means we have to more careful with those ops.
I added tests to make that behavior visible for all of the different cases that I could find.

This is a partial fix. To make this review easier, I did not make changes for the single binop
pattern (handled in foldSelectShuffleWith1Binop()). I also left out some potential optimizations
noted with TODO comments. I'll follow-up once we're confident that things are correct here.

The goal is to correct all marked FIXME tests to either avoid the shuffle transform or do it safely.

Note that distinguishing when the shuffle mask contains undefs and using getBinOpIdentity() allows
for some improvements to div/rem patterns, so there are wins along with the missed opportunities
and fixes.

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

llvm-svn: 336546

6 years ago[mips] Addition of the [d]rem and [d]remu instructions
Stefan Maksimovic [Mon, 9 Jul 2018 13:06:44 +0000 (13:06 +0000)]
[mips] Addition of the [d]rem and [d]remu instructions

Related to http://reviews.llvm.org/D15772
Depends on http://reviews.llvm.org/D16889
Adds [D]REM[U] instructions.

Patch By: Srdjan Obucina
Contributions from: Simon Dardis

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

llvm-svn: 336545

6 years ago[AArch64][SVE] Asm: Support for TBL instruction.
Sander de Smalen [Mon, 9 Jul 2018 12:32:56 +0000 (12:32 +0000)]
[AArch64][SVE] Asm: Support for TBL instruction.

Support for SVE's TBL instruction for programmable table
lookup/permute using vector of element indices, e.g.

  tbl  z0.d, { z1.d }, z2.d

stores elements from z1, indexed by elements from z2, into z0.

llvm-svn: 336544

6 years ago[llvm-mca] report an error if the assembly sequence contains an unsupported instruction.
Andrea Di Biagio [Mon, 9 Jul 2018 12:30:55 +0000 (12:30 +0000)]
[llvm-mca] report an error if the assembly sequence contains an unsupported instruction.

This is a short-term fix for PR38093.
For now, we llvm::report_fatal_error if the instruction builder finds an
unsupported instruction in the instruction stream.

We need to revisit this fix once we start addressing PR38101.
Essentially, we need a better framework for error handling.

llvm-svn: 336543

6 years ago[Support] Allow JSON serialization of Optional<T> for supported T.
Sam McCall [Mon, 9 Jul 2018 12:26:09 +0000 (12:26 +0000)]
[Support] Allow JSON serialization of Optional<T> for supported T.

This is ported from r333881 to JSON's new home.

llvm-svn: 336542

6 years ago[Support] Make JSON handle doubles and int64s losslessly
Sam McCall [Mon, 9 Jul 2018 12:16:40 +0000 (12:16 +0000)]
[Support] Make JSON handle doubles and int64s losslessly

Summary:
This patch adds a new "integer" ValueType, and renames Number -> Double.
This allows us to preserve the full precision of int64_t when parsing integers
from the wire, or constructing from an integer.
The API is unchanged, other than giving asInteger() a clearer contract.

In addition, always output doubles with enough precision that parsing will
reconstruct the same double.

Reviewers: simon_tatham

Subscribers: llvm-commits

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

llvm-svn: 336541

6 years ago[clangd] Do not write comments into Preamble PCH
Ilya Biryukov [Mon, 9 Jul 2018 11:33:31 +0000 (11:33 +0000)]
[clangd] Do not write comments into Preamble PCH

Summary:
To avoid wasting time deserializing them on code completion and
further reparses.

We do not use the comments anyway, because we cannot rely on the file
contents staying the same for reparses that reuse the prebuilt
preamble PCH.

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: ioeric, MaskRay, jkorous, cfe-commits

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

llvm-svn: 336540

6 years ago[PCH] Add an option to not write comments into PCH
Ilya Biryukov [Mon, 9 Jul 2018 11:33:23 +0000 (11:33 +0000)]
[PCH] Add an option to not write comments into PCH

Summary:
Will be used in clangd, see the follow-up change.
Clangd does not use comments read from PCH to avoid crashes due to
changed contents of the file. However, reading them considerably slows
down code completion on files with large preambles.

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: ioeric, cfe-commits

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

llvm-svn: 336539

6 years ago[clangd] Wait for first preamble before code completion
Ilya Biryukov [Mon, 9 Jul 2018 10:45:33 +0000 (10:45 +0000)]
[clangd] Wait for first preamble before code completion

Summary:
To avoid doing extra work of processing headers in the preamble
mutilple times in parallel.

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: javed.absar, ioeric, MaskRay, jkorous, cfe-commits

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

llvm-svn: 336538

6 years ago[Support] Fix GCC compile after r336534
Sam McCall [Mon, 9 Jul 2018 10:43:32 +0000 (10:43 +0000)]
[Support] Fix GCC compile after r336534

llvm-svn: 336537

6 years ago[PM/Unswitch] Fix a nasty bug in the new PM's unswitch introduced in
Chandler Carruth [Mon, 9 Jul 2018 10:30:48 +0000 (10:30 +0000)]
[PM/Unswitch] Fix a nasty bug in the new PM's unswitch introduced in
r335553 with the non-trivial unswitching of switches.

The code correctly updated most aspects of the CFG and analyses, but
missed some crucial aspects:
1) When multiple cases have the same successor, we unswitch that
   a single time and replace the switch with a direct branch. The CFG
   here is correct, but the target of this direct branch may have had
   a PHI node with multiple entries in it.
2) When we still have to clone a successor of the switch into an
   unswitched copy of the loop, we'll delete potentially multiple edges
   entering this successor, not just one.
3) We also have to delete multiple edges entering the successors in the
   original loop when they have to be retained.
4) When the "retained successor" *also* occurs as a case successor, we
   just assert failed everywhere. This doesn't happen very easily
   because its always valid to simply drop the case -- the retained
   successor for switches is always the default successor. However, it
   is likely possible through some contrivance of different loop passes,
   unrolling, and simplifying for this to occur in practice and
   certainly there is nothing "invalid" about the IR so this pass needs
   to handle it.
5) In the case of #4, we also will replace these multiple edges with
   a direct branch much like in #1 and need to collapse the entries in
   any PHI nodes to a single enrty.

All of this stems from the delightful fact that the same successor can
show up in multiple parts of the switch terminator, and each of these
are considered a distinct edge for the purpose of PHI nodes (and
iterating the successors and predecessors) but not for unswitching
itself, the dominator tree, or many other things. For the record,
I intensely dislike this "feature" of the IR in large part because of
the complexity it causes in passes like this. We already have a ton of
logic building sets and handling duplicates, and we just had to add
a bunch more.

I've added a complex test case that covers all five of the above failure
modes. I've also added a variation on it where #4 and #5 occur in loop
exit, adding fun where we have an LCSSA PHI node with "multiple entries"
despite have dedicated exits. There were no additional issues found by
this, but it seems a useful corner case to cover with testing.

One thing that working on all of this code has made painfully clear for
me as well is how amazingly inefficient our PHI node representation is
(in terms of the in-memory data structures and the APIs used to update
them). This code has truly marvelous complexity bounds because every
time we remove an entry from a PHI node we do a linear scan to find it
and then a linear update to the data structure to remove it. We could in
theory batch all of the PHI node updates into a single linear walk of
the operands making this much more efficient, but the APIs fight hard
against this and the fact that we have to handle duplicates in the
peculiar manner we do (removing all but one in some cases) makes even
implementing that very tedious and annoying. Anyways, none of this is
new here or specific to loop unswitching. All code in LLVM that updates
PHI node operands suffers from these problems.

llvm-svn: 336536

6 years agoLift JSON library from clang-tools-extra/clangd to llvm/Support.
Sam McCall [Mon, 9 Jul 2018 10:05:41 +0000 (10:05 +0000)]
Lift JSON library from clang-tools-extra/clangd to llvm/Support.

Summary:
This consists of four main parts:
 - an type json::Expr representing JSON values of dynamic kind, which can be
   composed, inspected, and modified
 - a JSON parser from string -> json::Expr
 - a JSON printer from json::Expr -> string, with optional pretty-printing
 - a convention for mapping json::Expr <=> native types (fromJSON/toJSON)
   Mapping functions are provided for primitives (e.g. int, vector) and the
   ObjectMapper helper helps implement fromJSON for struct/object types.

Based on clangd's usage, a couple of places I'd appreciate review attention:
 - fromJSON returns only bool. A richer error-signaling mechanism may be useful
   to provide useful messages, or let recursive fromJSONs (containers/structs)
   do careful error recovery.
 - should json::obj be always explicitly written (like json::ary)
 - there's no streaming parse API. I suspect there are some simple wins like
   a callback API where the document is a long array, and each element is small.
   But this can probably be bolted on easily when we see the need.

Reviewers: bkramer, labath

Subscribers: mgorny, ilya-biryukov, ioeric, MaskRay, llvm-commits

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

llvm-svn: 336534

6 years ago[AArch64][SVE] Asm: Support for ADR instruction.
Sander de Smalen [Mon, 9 Jul 2018 09:58:24 +0000 (09:58 +0000)]
[AArch64][SVE] Asm: Support for ADR instruction.

Supporting various addressing modes:
- adr z0.s, [z0.s, z0.s]
- adr z0.s, [z0.s, z0.s, lsl #<shift>]
- adr z0.d, [z0.d, z0.d]
- adr z0.d, [z0.d, z0.d, lsl #<shift>]
- adr z0.d, [z0.d, z0.d, uxtw #<shift>]
- adr z0.d, [z0.d, z0.d, sxtw #<shift>]

Reviewers: rengolin, fhahn, SjoerdMeijer, samparker, javed.absar

Reviewed By: SjoerdMeijer

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

llvm-svn: 336533

6 years agoTry to fix build bot after r336524
Eric Liu [Mon, 9 Jul 2018 09:17:25 +0000 (09:17 +0000)]
Try to fix build bot after r336524

llvm-svn: 336532

6 years ago[AArch64][SVE] Asm: Support for UZP and TRN instructions.
Sander de Smalen [Mon, 9 Jul 2018 09:12:17 +0000 (09:12 +0000)]
[AArch64][SVE] Asm: Support for UZP and TRN instructions.

This patch adds support for:
  UZP1  Concatenate even elements from two vectors
  UZP2  Concatenate  odd elements from two vectors
  TRN1  Interleave  even elements from two vectors
  TRN2  Interleave   odd elements from two vectors

With variants for both data and predicate vectors, e.g.
  uzp1    z0.b, z1.b, z2.b
  trn2    p0.s, p1.s, p2.s

llvm-svn: 336531

6 years ago[clangd] Added a test for preambles and -isystem
Ilya Biryukov [Mon, 9 Jul 2018 09:10:22 +0000 (09:10 +0000)]
[clangd] Added a test for preambles and -isystem

Summary:
Checks that preambles are properly invalidated when headers from
-isystem paths change.

Reviewers: sammccall, ioeric

Reviewed By: sammccall

Subscribers: MaskRay, jkorous, cfe-commits

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

llvm-svn: 336530

6 years ago[AccelTable] Provide abstraction for emitting DWARF5 accelerator tables.
Jonas Devlieghere [Mon, 9 Jul 2018 09:08:44 +0000 (09:08 +0000)]
[AccelTable] Provide abstraction for emitting DWARF5 accelerator tables.

When emitting the DWARF accelerator tables from dsymutil, we don't have
a DwarfDebug instance and we use a custom class to represent Dwarf
compile units. This patch adds an interface AccelTableWriterInfo to
abstract these from the Dwarf5AccelTableWriter, so we can have a custom
implementation for this in dsymutil.

Differential revision: https://reviews.llvm.org/D49031

llvm-svn: 336529

6 years ago[Preamble] Check system dependencies in preamble too
Ilya Biryukov [Mon, 9 Jul 2018 09:07:01 +0000 (09:07 +0000)]
[Preamble] Check system dependencies in preamble too

Summary:
PrecompiledPreamble hasn't checked if the system dependencies changed
before. This resulted in invalid preamble not being rebuilt if headers
that changed were found in -isystem include paths.

This pattern is sometimes used to avoid showing warnings in third
party code, so we want to correctly handle those cases.

Tested in clangd, see the follow-up patch.

Reviewers: sammccall, ioeric

Reviewed By: sammccall

Subscribers: omtcyfz, cfe-commits

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

llvm-svn: 336528

6 years ago[ASTImporter] fix test failure corrected by fixed func end locs
Rafael Stahl [Mon, 9 Jul 2018 09:02:53 +0000 (09:02 +0000)]
[ASTImporter] fix test failure corrected by fixed func end locs

fix to rC336523 / D48941

llvm-svn: 336527

6 years ago[Index] Add clangLex to LINK_LIBS
Heejin Ahn [Mon, 9 Jul 2018 08:54:42 +0000 (08:54 +0000)]
[Index] Add clangLex to LINK_LIBS

Without this, builds with `-DSHARED_LIB=ON` fail.

llvm-svn: 336526

6 years ago[AccelTable] Dwarf5AccelTableEmitter -> Writer (NFC)
Jonas Devlieghere [Mon, 9 Jul 2018 08:47:38 +0000 (08:47 +0000)]
[AccelTable] Dwarf5AccelTableEmitter -> Writer (NFC)

Renames Dwarf5AccelTableEmitter to Dwarf5AccelTableWriter as suggested
in D49031.

llvm-svn: 336525

6 years ago[Index] Add indexing support for MACROs.
Eric Liu [Mon, 9 Jul 2018 08:44:05 +0000 (08:44 +0000)]
[Index] Add indexing support for MACROs.

Reviewers: akyrtzi, arphaman, sammccall

Reviewed By: sammccall

Subscribers: malaperle, sammccall, cfe-commits

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

llvm-svn: 336524

6 years ago[ASTImporter] import FunctionDecl end locations
Rafael Stahl [Mon, 9 Jul 2018 08:40:17 +0000 (08:40 +0000)]
[ASTImporter] import FunctionDecl end locations

Summary: On constructors that do not take the end source location, it was not imported. Fixes test from D47698 / rC336269.

Reviewers: martong, a.sidorin, balazske, xazax.hun, a_sidorin

Reviewed By: martong, a_sidorin

Subscribers: a_sidorin, rnkovacs, cfe-commits

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

llvm-svn: 336523

6 years ago[PGOMemOPSize] Preserve the DominatorTree
Chijun Sima [Mon, 9 Jul 2018 08:07:21 +0000 (08:07 +0000)]
[PGOMemOPSize] Preserve the DominatorTree

Summary:
PGOMemOPSize only modifies CFG in a couple of places; thus we can preserve the DominatorTree with little effort.
When optimizing SQLite with -O3, this patch can decrease 3.8% of the numbers of nodes traversed by DFS and 5.7% of the times DominatorTreeBase::recalculation is called.

Reviewers: kuhar, davide, dmgreen

Reviewed By: dmgreen

Subscribers: mzolotukhin, vsk, llvm-commits

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

llvm-svn: 336522

6 years ago[clang-format/ObjC] Put ObjC method arguments into one line when they fit
Jacek Olesiak [Mon, 9 Jul 2018 07:08:45 +0000 (07:08 +0000)]
[clang-format/ObjC] Put ObjC method arguments into one line when they fit

Reapply D47195:
Currently BreakBeforeParameter is set to true everytime message receiver spans multiple lines, e.g.:
```
[[object block:^{
  return 42;
}] aa:42 bb:42];
```
will be formatted:
```
[[object block:^{
  return 42;
}] aa:42
   bb:42];
```
even though arguments could fit into one line. This change fixes this behavior.

llvm-svn: 336521

6 years ago[clang-format/ObjC] Improve split priorities for ObjC methods
Jacek Olesiak [Mon, 9 Jul 2018 06:54:52 +0000 (06:54 +0000)]
[clang-format/ObjC] Improve split priorities for ObjC methods

Reduce penalty for aligning ObjC method arguments using the colon alignment as
this is the canonical way.

Trying to fit a whole expression into one line should not force other line
breaks (e.g. when ObjC method expression is a part of other expression).

llvm-svn: 336520

6 years ago[clang-format/ObjC] Prohibit breaking after a bracket opening ObjC method expression
Jacek Olesiak [Mon, 9 Jul 2018 06:04:58 +0000 (06:04 +0000)]
[clang-format/ObjC] Prohibit breaking after a bracket opening ObjC method expression

Summary:
Don't break after a "[" opening an ObjC method expression.
Tests are added in D48719 where formatting is improved (to avoid adding and changing tests immediately).

Reviewers: benhamilton, klimek

Reviewed By: benhamilton

Subscribers: acoomans, cfe-commits

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

llvm-svn: 336519

6 years ago[clang-format/ObjC] Fix counting selector name parts for ObjC
Jacek Olesiak [Mon, 9 Jul 2018 05:58:51 +0000 (05:58 +0000)]
[clang-format/ObjC] Fix counting selector name parts for ObjC

Summary:
Counts selector parts also for method declarations and counts correctly for methods without arguments.
This is an internal change and doesn't influence formatting on its own (at the current state). Its lack would be visible after applying D48719.

Reviewers: benhamilton, klimek

Reviewed By: benhamilton

Subscribers: acoomans, cfe-commits

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

llvm-svn: 336518

6 years ago[X86] Improve the message for some asserts. Remove an if that is guaranteed true...
Craig Topper [Mon, 9 Jul 2018 01:52:56 +0000 (01:52 +0000)]
[X86] Improve the message for some asserts. Remove an if that is guaranteed true by said asserts.

This replaces some asserts in lowerV2F64VectorShuffle with the similar asserts from lowerVIF64VectorShuffle which are more readable. The original asserts mentioned a blend, but there's no guarantee that it is a blend.

Also remove an if that the asserts prove is always true. Mask[0] is always less than 2 and Mask[1] is always at least 2. Therefore (Mask[0] >= 2) + (Mask[1] >= 2) == 1 must wlays be true.

llvm-svn: 336517

6 years ago[X86] Remove an AddedComplexity line that seems unnecessary.
Craig Topper [Sun, 8 Jul 2018 22:57:33 +0000 (22:57 +0000)]
[X86] Remove an AddedComplexity line that seems unnecessary.

It only existed on SSE and AVX version. AVX512 version didn't have it.

I checked the generated table and this didn't seem necessary to creat a match preference.

llvm-svn: 336516