platform/upstream/llvm.git
6 years agollvm-xray: Broken chrome trace event format output
Dean Michael Berris [Tue, 24 Jul 2018 01:45:34 +0000 (01:45 +0000)]
llvm-xray: Broken chrome trace event format output

Summary:
Missing comma separator for EXIT and TAIL_EXIT RecordTypes emit invalid
JSON output for Chrome Trace Event Format.

Reviewers: dberris

Reviewed By: dberris

Subscribers: sammccall, kpw, llvm-commits

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

llvm-svn: 337795

6 years agoAMDGPU/GlobalISel: Remove unnecessary legality constraint for G_EXTRACT
Tom Stellard [Tue, 24 Jul 2018 01:43:49 +0000 (01:43 +0000)]
AMDGPU/GlobalISel: Remove unnecessary legality constraint for G_EXTRACT

Summary:
We were marking G_EXTRACT operations unsupported if the output type
was larger than the input type.  I don't see how this could ever actually
happen, so I dropped the constraint.  Doing this makes it possible to
reuse the same legality code for G_INSERT.

Reviewers: arsenm

Reviewed By: arsenm

Subscribers: kzhuravl, wdng, nhaehnle, yaxunl, rovka, kristof.beyls, dstuttard, tpr, t-tye, llvm-commits

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

llvm-svn: 337794

6 years ago[HIP] pass -target-cpu when running the device-mode compiler
Yaxun Liu [Tue, 24 Jul 2018 01:40:44 +0000 (01:40 +0000)]
[HIP] pass -target-cpu when running the device-mode compiler

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

llvm-svn: 337793

6 years agoAdd missing testcase update for r337790.
Richard Smith [Tue, 24 Jul 2018 01:23:36 +0000 (01:23 +0000)]
Add missing testcase update for r337790.

llvm-svn: 337792

6 years agoEnable .hip files for test/Driver
Yaxun Liu [Tue, 24 Jul 2018 01:03:44 +0000 (01:03 +0000)]
Enable .hip files for test/Driver

Partially revert r334128 due to regressions.

llvm-svn: 337791

6 years agoWarn if a local variable's initializer retains a pointer/reference to a
Richard Smith [Tue, 24 Jul 2018 00:55:08 +0000 (00:55 +0000)]
Warn if a local variable's initializer retains a pointer/reference to a
non-lifetime-extended temporary object.

llvm-svn: 337790

6 years agoAdd PerfJITEventListener for perf profiling support.
Andres Freund [Tue, 24 Jul 2018 00:54:06 +0000 (00:54 +0000)]
Add PerfJITEventListener for perf profiling support.

This new JIT event listener supports generating profiling data for
the linux 'perf' profiling tool, allowing it to generate function and
instruction level profiles.

Currently this functionality is not enabled by default, but must be
enabled with LLVM_USE_PERF=yes.  Given that the listener has no
dependencies, it might be sensible to enable by default once the
initial issues have been shaken out.

I followed existing precedent in registering the listener by default
in lli. Should there be a decision to enable this by default on linux,
that should probably be changed.

Please note that until https://reviews.llvm.org/D47343 is resolved,
using this functionality with mcjit rather than orcjit will not
reliably work.

Disregarding the previous comment, here's an example:

$ cat /tmp/expensive_loop.c

bool stupid_isprime(uint64_t num)
{
        if (num == 2)
                return true;
        if (num < 1 || num % 2 == 0)
                return false;
        for(uint64_t i = 3; i < num / 2; i+= 2) {
                if (num % i == 0)
                        return false;
        }
        return true;
}

int main(int argc, char **argv)
{
        int numprimes = 0;

        for (uint64_t num = argc; num < 100000; num++)
        {
                if (stupid_isprime(num))
                        numprimes++;
        }

        return numprimes;
}

$ clang -ggdb -S -c -emit-llvm /tmp/expensive_loop.c -o
/tmp/expensive_loop.ll

$ perf record -o perf.data -g -k 1 ./bin/lli -jit-kind=mcjit /tmp/expensive_loop.ll 1

$ perf inject --jit -i perf.data -o perf.jit.data

$ perf report -i perf.jit.data
-   92.59%  lli      jitted-5881-2.so                   [.] stupid_isprime
     stupid_isprime
     main
     llvm::MCJIT::runFunction
     llvm::ExecutionEngine::runFunctionAsMain
     main
     __libc_start_main
     0x4bf6258d4c544155
+    0.85%  lli      ld-2.27.so                         [.] do_lookup_x

And line-level annotations also work:
       │              for(uint64_t i = 3; i < num / 2; i+= 2) {
       │1 30:   movq   $0x3,-0x18(%rbp)
  0.03 │1 38:   mov    -0x18(%rbp),%rax
  0.03 │        mov    -0x10(%rbp),%rcx
       │        shr    $0x1,%rcx
  3.63 │     ┌──cmp    %rcx,%rax
       │     ├──jae    6f
       │     │                if (num % i == 0)
  0.03 │     │  mov    -0x10(%rbp),%rax
       │     │  xor    %edx,%edx
 89.00 │     │  divq   -0x18(%rbp)
       │     │  cmp    $0x0,%rdx
  0.22 │     │↓ jne    5f
       │     │                        return false;
       │     │  movb   $0x0,-0x1(%rbp)
       │     │↓ jmp    73
       │     │        }
  3.22 │1 5f:│↓ jmp    61
       │     │        for(uint64_t i = 3; i < num / 2; i+= 2) {

Subscribers: mgorny, llvm-commits

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

llvm-svn: 337789

6 years agoBorrow visibility from __fundamental_type_info for generated fundamental type infos
Thomas Anderson [Tue, 24 Jul 2018 00:43:47 +0000 (00:43 +0000)]
Borrow visibility from __fundamental_type_info for generated fundamental type infos

This is necessary so the clang gives hidden visibility to fundamental types when
-fvisibility=hidden is passed. Fixes
https://bugs.llvm.org/show_bug.cgi?id=35066

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

llvm-svn: 337788

6 years ago[Debugify] Export per-pass debug info loss statistics
Vedant Kumar [Tue, 24 Jul 2018 00:41:29 +0000 (00:41 +0000)]
[Debugify] Export per-pass debug info loss statistics

Add a -debugify-export option to opt. This exports per-pass `debugify`
loss statistics to a file in CSV format.

For some interesting numbers on debug value loss during an -O2 build
of the sqlite3 amalgamation, see the review thread.

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

llvm-svn: 337787

6 years ago[Debugify] Move interface definitions to a header, NFC
Vedant Kumar [Tue, 24 Jul 2018 00:41:28 +0000 (00:41 +0000)]
[Debugify] Move interface definitions to a header, NFC

This is a minor cleanup in preparation for a change to export DI
statistics from -check-debugify. To do that, it would be cleaner to have
a dedicated header for the debugify interface.

llvm-svn: 337786

6 years ago[x86/SLH] Simplify the code for hardening a loaded value. NFC.
Chandler Carruth [Tue, 24 Jul 2018 00:35:36 +0000 (00:35 +0000)]
[x86/SLH] Simplify the code for hardening a loaded value. NFC.

This is in preparation for extracting this into a re-usable utility in
this code.

llvm-svn: 337785

6 years agoRevert "[Fuzzer] Update path to libc++ headers"
Petr Hosek [Tue, 24 Jul 2018 00:34:55 +0000 (00:34 +0000)]
Revert "[Fuzzer] Update path to libc++ headers"

This reverts commit r337775 since r337727 has been reverted in r337782.

llvm-svn: 337784

6 years ago[WebAssembly] Change size_t to `unsigned long`.
Dan Gohman [Tue, 24 Jul 2018 00:29:58 +0000 (00:29 +0000)]
[WebAssembly] Change size_t to `unsigned long`.

Changing it to unsigned long (which is 32-bit on wasm32) makes it the same
type as wasm64 (where unsigned long is 64-bit), which would eliminate the most
common cause for mangled names being different between wasm32 and wasm64. For
example, export lists containing symbol names could now often be the same
between wasm32 and wasm64.

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

llvm-svn: 337783

6 years agoRevert r337727 as it caused Darwin bot failures
Alex Lorenz [Tue, 24 Jul 2018 00:27:31 +0000 (00:27 +0000)]
Revert r337727 as it caused Darwin bot failures

llvm-svn: 337782

6 years ago[x86/SLH] Remove complex SHRX-based post-load hardening.
Chandler Carruth [Tue, 24 Jul 2018 00:21:59 +0000 (00:21 +0000)]
[x86/SLH] Remove complex SHRX-based post-load hardening.

This code was really nasty, had several bugs in it originally, and
wasn't carrying its weight. While on Zen we have all 4 ports available
for SHRX, on all of the Intel parts with Agner's tables, SHRX can only
execute on 2 ports, giving it 1/2 the throughput of OR.

Worse, all too often this pattern required two SHRX instructions in
a chain, hurting the critical path by a lot.

Even if we end up needing to safe/restore EFLAGS, that is no longer so
bad. We pay for a uop to save the flag, but we very likely get fusion
when it is used by forming a test/jCC pair or something similar. In
practice, I don't expect the SHRX to be a significant savings here, so
I'd like to avoid the complex code required. We can always resurrect
this if/when someone has a specific performance issue addressed by it.

llvm-svn: 337781

6 years agoNFC: Add the emacs c++ mode hint "-*- C++ -*-" to the headers that don't have it
Erik Pilkington [Tue, 24 Jul 2018 00:07:49 +0000 (00:07 +0000)]
NFC: Add the emacs c++ mode hint "-*- C++ -*-" to the headers that don't have it

https://llvm.org/docs/CodingStandards.html#file-headers

llvm-svn: 337780

6 years agoAdded unit test for StreamTee
Raphael Isemann [Tue, 24 Jul 2018 00:01:32 +0000 (00:01 +0000)]
Added unit test for StreamTee

Reviewers: davide

Reviewed By: davide

Subscribers: davide, mgorny, lldb-commits

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

llvm-svn: 337778

6 years ago[WebAssembly] Add support for --whole-archive.
Sam Clegg [Mon, 23 Jul 2018 23:51:19 +0000 (23:51 +0000)]
[WebAssembly] Add support for --whole-archive.

Subscribers: dschuff, jgravelle-google, aheejin, sunfish, llvm-commits

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

llvm-svn: 337777

6 years ago[analyzer] Add a no-crash to a recently added test.
Artem Dergachev [Mon, 23 Jul 2018 23:48:13 +0000 (23:48 +0000)]
[analyzer] Add a no-crash to a recently added test.

No functional change intended.

llvm-svn: 337776

6 years ago[Fuzzer] Update path to libc++ headers
Petr Hosek [Mon, 23 Jul 2018 23:38:28 +0000 (23:38 +0000)]
[Fuzzer] Update path to libc++ headers

The path to headers which are installed into libc++ build directory
has changed in r337727 which broke the libFuzzer build.

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

llvm-svn: 337775

6 years agoChange sort-pbxproj.rb to find the project.pbxproj in the
Jason Molenda [Mon, 23 Jul 2018 23:34:50 +0000 (23:34 +0000)]
Change sort-pbxproj.rb to find the project.pbxproj in the
most likely locations.  And have it overwrite the original
file with the sorted output.

llvm-svn: 337774

6 years ago[DWARF] Use deque in place of SmallVector to fix use-after-free issue
Fangrui Song [Mon, 23 Jul 2018 23:27:45 +0000 (23:27 +0000)]
[DWARF] Use deque in place of SmallVector to fix use-after-free issue

Summary: SmallVector's elements are moved when resizing and cause use-after-free.

Reviewers: probinson, dblaikie

Subscribers: JDevlieghere, llvm-commits

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

llvm-svn: 337772

6 years agoFix typo in test/CodeGen/Mips/dins.ll
Thomas Anderson [Mon, 23 Jul 2018 23:19:53 +0000 (23:19 +0000)]
Fix typo in test/CodeGen/Mips/dins.ll

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

llvm-svn: 337771

6 years agoEmbed a template specialization in a namespace to work around a gcc bug.
Wolfgang Pieb [Mon, 23 Jul 2018 23:14:23 +0000 (23:14 +0000)]
Embed a template specialization in a namespace to work around a gcc bug.

llvm-svn: 337770

6 years ago[analyzer] pr38273: Legalize Loc<>NonLoc comparison symbols.
Artem Dergachev [Mon, 23 Jul 2018 23:09:44 +0000 (23:09 +0000)]
[analyzer] pr38273: Legalize Loc<>NonLoc comparison symbols.

Remove an assertion in RangeConstraintManager that expects such symbols to never
appear, while admitting that the constraint manager doesn't yet handle them.

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

llvm-svn: 337769

6 years agoHandle DT_UNKNOWN correctly during directory iteration.
Eric Fiselier [Mon, 23 Jul 2018 22:58:46 +0000 (22:58 +0000)]
Handle DT_UNKNOWN correctly during directory iteration.

Unlike stat and lstat, where unknown really means we know it's something weird,
during directory iteration DT_UNKNOWN simply means that the underlying FS doesn't
support the dirent::dt_type field.

This patch fixes libc++ to correctly set the cache to empty when DT_UNKNOWN is reported.

llvm-svn: 337768

6 years agoSupport lifetime-extension of conditional temporaries.
Richard Smith [Mon, 23 Jul 2018 22:56:45 +0000 (22:56 +0000)]
Support lifetime-extension of conditional temporaries.

llvm-svn: 337767

6 years ago[Sema] Fix crash on BlockExprs in a default member initializers
Erik Pilkington [Mon, 23 Jul 2018 22:47:37 +0000 (22:47 +0000)]
[Sema] Fix crash on BlockExprs in a default member initializers

Clang would crash when instantiating a BlockDecl that appeared in a
default-member-initializer of a class template. Fix this by deferring the
instantiation until we instantate the BlockExpr.

rdar://41200624

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

llvm-svn: 337766

6 years agoRecommit "Use possibly cached directory entry values when performing recursive direct...
Eric Fiselier [Mon, 23 Jul 2018 22:40:41 +0000 (22:40 +0000)]
Recommit "Use possibly cached directory entry values when performing recursive directory iteration."

The initial patch didn't correctly handle systems when the dirent struct
didn't provide the d_type member. Specifically it set the cache to the incorrect state,
and claimed it was partially populated.

The updated version of this change correctly handles setting up the
cache when the file type is not known (aka file_type::none).

llvm-svn: 337765

6 years agoFix accidentally removed test.
Eric Fiselier [Mon, 23 Jul 2018 22:39:56 +0000 (22:39 +0000)]
Fix accidentally removed test.

When adding the new tests for the filesystem_error::what method,
I incorrectly removed a test case and replaced it with something else.

This patch restores that test case

llvm-svn: 337764

6 years ago[DWARF v5] Refactor range lists dumping by using a more generic way of handling table...
Wolfgang Pieb [Mon, 23 Jul 2018 22:37:17 +0000 (22:37 +0000)]
[DWARF v5] Refactor range lists dumping by using a more generic way of handling tables of lists.
The intent is to use it for location list tables as well. Change is almost NFC with the exception
of the spelling of some strings used during dumping (all lowercase now).

Reviewer: JDevlieghere

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

llvm-svn: 337763

6 years ago[LTO] Handle __imp_ (dllimport) symbols consistently with lld
Teresa Johnson [Mon, 23 Jul 2018 22:33:57 +0000 (22:33 +0000)]
[LTO] Handle __imp_ (dllimport) symbols consistently with lld

Summary:
Similar to what lld already does for dllimport symbols which are
prefaced with __imp_ (see lld patch r240620), strip off the __imp_
prefix in LTO. Otherwise we can get 2 separate GlobalResolution for
a single symbol, the dllimport declaration, and the definition, which
leads to incorrect LTO handling.

Fixes PR38105.

Reviewers: pcc

Subscribers: mehdi_amini, inglorion, steven_wu, dexonsmith, llvm-commits

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

llvm-svn: 337762

6 years ago[ASTMatchers] Add an isMain() matcher
George Karpenkov [Mon, 23 Jul 2018 22:29:35 +0000 (22:29 +0000)]
[ASTMatchers] Add an isMain() matcher

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

llvm-svn: 337761

6 years ago[ASTMatchers] [NFC] Regenerate HTML docs.
George Karpenkov [Mon, 23 Jul 2018 22:29:10 +0000 (22:29 +0000)]
[ASTMatchers] [NFC] Regenerate HTML docs.

llvm-svn: 337760

6 years ago[demangler] call terminate() if allocation failed
Erik Pilkington [Mon, 23 Jul 2018 22:23:04 +0000 (22:23 +0000)]
[demangler] call terminate() if allocation failed

We really should set *status to memory_alloc_failure, but we need to refactor
the demangler a bit to properly propagate the failure up the stack. Until then,
its better to explicitly terminate then rely on a null dereference crash.

rdar://31240372

llvm-svn: 337759

6 years agoFix Xcode project for unit tests.
Greg Clayton [Mon, 23 Jul 2018 22:22:46 +0000 (22:22 +0000)]
Fix Xcode project for unit tests.

llvm-svn: 337758

6 years ago[MC] Add a separate flag for skipping comdat constant sections for MinGW. NFC.
Martin Storsjo [Mon, 23 Jul 2018 22:15:25 +0000 (22:15 +0000)]
[MC] Add a separate flag for skipping comdat constant sections for MinGW. NFC.

This actually has nothing to do with the associative comdat sections
that aren't supported by GNU binutils ld.

Clarify the comments from SVN r335918 and use a separate flag for it.

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

llvm-svn: 337757

6 years ago[COFF] Fix assembly output of comdat sections without an attached symbol
Martin Storsjo [Mon, 23 Jul 2018 22:15:19 +0000 (22:15 +0000)]
[COFF] Fix assembly output of comdat sections without an attached symbol

Since SVN r335286, the .xdata sections are produced without an attached
symbol, which requires using a different syntax when printing assembly
output.

Instead of the usual syntax of '.section <name>,"dr",discard,<symbol>',
use '.section <name>,"dr"' + '.linkonce discard' (which is what GCC
uses for all assembly output).

This fixes PR38254.

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

llvm-svn: 337756

6 years ago[AArch64] Use MCAsmInfoMicrosoft and MCAsmInfoGNUCOFF as base classes
Martin Storsjo [Mon, 23 Jul 2018 22:15:14 +0000 (22:15 +0000)]
[AArch64] Use MCAsmInfoMicrosoft and MCAsmInfoGNUCOFF as base classes

This matches the structure used on X86 and ARM. This requires
a little bit of duplication of the parts that are equal in both
AArch64 COFF variants though.

Before SVN r335286, these classes didn't add anything that MCAsmInfoCOFF
didn't, but now they do.

This makes AArch64 match X86 in how comdat is used for float constants
for MinGW.

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

llvm-svn: 337755

6 years agoImplement a GCC compatible SEH unwinding personality, __gxx_personality_seh0
Martin Storsjo [Mon, 23 Jul 2018 22:09:23 +0000 (22:09 +0000)]
Implement a GCC compatible SEH unwinding personality, __gxx_personality_seh0

This allows handling SEH based exceptions, with unwind functions
provided by libgcc.

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

llvm-svn: 337754

6 years ago[utils] Fix the llvm::Optional data formatter
Vedant Kumar [Mon, 23 Jul 2018 21:59:06 +0000 (21:59 +0000)]
[utils] Fix the llvm::Optional data formatter

The llvm::Optional data formatter needs to look through the `Storage`
container if it's present.

Before:

   220    if (Op && Op->getOp() != dwarf::DW_OP_LLVM_fragment)
-> 221      HasComplexExpression = true;
   222
   223    // If the register can only be described by a complex expression (i.e.,
   224    // multiple subregisters) it doesn't safely compose with another complex
Target 0: (llc) stopped.
(lldb) p Op
(llvm::Optional<llvm::DIExpression::ExprOperand>) $0 = None

After:

(lldb) p Op
(llvm::Optional<llvm::DIExpression::ExprOperand>) $0 =
(llvm::DIExpression::ExprOperand) storage = {
  Op = 0x000000010603d460
}

llvm-svn: 337752

6 years ago[SelectionDAG] Reduce DanglingDebugInfo memory traffic, NFC
Vedant Kumar [Mon, 23 Jul 2018 21:59:04 +0000 (21:59 +0000)]
[SelectionDAG] Reduce DanglingDebugInfo memory traffic, NFC

This avoids approx. 2 x 10^5 DenseMap insertions in both non-debug and
debug -O2 builds of the sqlite3 amalgamation.

llvm-svn: 337751

6 years ago[ThinLTO] Ensure the TargetLibraryInfo is constructed early enough
Teresa Johnson [Mon, 23 Jul 2018 21:58:19 +0000 (21:58 +0000)]
[ThinLTO] Ensure the TargetLibraryInfo is constructed early enough

Summary:
Without this change, the WholeProgramDevirt pass, which requires the
TargetLibraryInfo, will construct one from the default triple.

Fixes PR38139.

Reviewers: pcc

Subscribers: mehdi_amini, inglorion, steven_wu, dexonsmith, llvm-commits

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

llvm-svn: 337750

6 years agoRevert "Use possibly cached directory entry values when performing recursive director...
Eric Fiselier [Mon, 23 Jul 2018 21:52:29 +0000 (21:52 +0000)]
Revert "Use possibly cached directory entry values when performing recursive directory iteration."

This reverts commit 04ce4aef00d3ee508327f6cf7bf1b1d200ab6238.

llvm-svn: 337749

6 years ago[DebugCounters] Keep track of total counts
George Burgess IV [Mon, 23 Jul 2018 21:49:36 +0000 (21:49 +0000)]
[DebugCounters] Keep track of total counts

This patch makes debug counters keep track of the total number of times
we've called `shouldExecute` for each counter, so it's easier to build
automated tooling on top of these.

A patch to print these counts is coming soon.

Patch by Zhizhou Yang!

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

llvm-svn: 337748

6 years ago[gdb] Fix SmallVector pretty printer after r337514
Fangrui Song [Mon, 23 Jul 2018 21:33:51 +0000 (21:33 +0000)]
[gdb] Fix SmallVector pretty printer after r337514

llvm-svn: 337747

6 years ago[clang-cl] Expose -fblocks and -fno-builtin as driver flags
Reid Kleckner [Mon, 23 Jul 2018 21:29:43 +0000 (21:29 +0000)]
[clang-cl] Expose -fblocks and -fno-builtin as driver flags

Users have requested them.

Helps with PR36427.

llvm-svn: 337746

6 years agoReapply "[XRay] Remove scheduling dependency in fork_basic_logging.cc"
Matthew Voss [Mon, 23 Jul 2018 21:22:02 +0000 (21:22 +0000)]
Reapply "[XRay] Remove scheduling dependency in fork_basic_logging.cc"

Summary:
Continuation of https://reviews.llvm.org/D49501

Second part of the test has an scheduling order when there shouldn't be.

Reviewers: dberris, ormris

Reviewed By: dberris, ormris

Subscribers: TWeaver

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

llvm-svn: 337745

6 years agoDo not try to perform lifetime-extension through conditional
Richard Smith [Mon, 23 Jul 2018 21:21:24 +0000 (21:21 +0000)]
Do not try to perform lifetime-extension through conditional
expressions.

CodeGen can't cope with that yet. Instead, produce a "not supported"
warning for now and don't extend lifetime.

llvm-svn: 337744

6 years agoFold -Wreturn-stack-address into general initialization lifetime
Richard Smith [Mon, 23 Jul 2018 21:21:22 +0000 (21:21 +0000)]
Fold -Wreturn-stack-address into general initialization lifetime
checking.

llvm-svn: 337743

6 years agoConstantFolding: Avoid a crash.
Manoj Gupta [Mon, 23 Jul 2018 21:20:00 +0000 (21:20 +0000)]
ConstantFolding: Avoid a crash.

Summary:
Check if the parent basic block and caller exists
before calling CS.getCaller when constant folding
strip.invariant.group instrinsic.

This avoids a crash when the function containing the intrinsic
is being inlined. The instruction is checked for any simplifiction
but has not yet been added to a basic block.

Reviewers: Prazek, rsmith, efriedma

Reviewed By: efriedma

Subscribers: eraman, llvm-commits

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

llvm-svn: 337742

6 years ago[cmake] Remove unused ${LLDB_PLUGINS} dependency from our Objective-C++ CMake config
Raphael Isemann [Mon, 23 Jul 2018 21:14:52 +0000 (21:14 +0000)]
[cmake] Remove unused ${LLDB_PLUGINS} dependency from our Objective-C++ CMake config

Summary:
LLDB_PLUGINS doesn't exist as a variable, so this line doesn't add any dependencies and is
just confusing. It seems this slipped in from the gdb-remote CMake I was using as a CMake template.

The gdb-remote CMake itself is using a local LLDB_PLUGINS variable, so that code is fine.

Reviewers: davide

Reviewed By: davide

Subscribers: davide, mgorny, lldb-commits

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

llvm-svn: 337741

6 years agoRe-land r335297 "[X86] Implement more of x86-64 large and medium PIC code models"
Reid Kleckner [Mon, 23 Jul 2018 21:14:35 +0000 (21:14 +0000)]
Re-land r335297 "[X86] Implement more of x86-64 large and medium PIC code models"

Don't try to generate large PIC code for non-ELF targets. Neither COFF
nor MachO have relocations for large position independent code, and
users have been using "large PIC" code models to JIT 64-bit code for a
while now. With this change, if they are generating ELF code, their
JITed code will truly be PIC, but if they target MachO or COFF, it will
contain 64-bit immediates that directly reference external symbols. For
a JIT, that's perfectly fine.

llvm-svn: 337740

6 years ago[llvm-mca][docs] Define IPC where it is first mentioned. NFC.
Matt Davis [Mon, 23 Jul 2018 21:10:50 +0000 (21:10 +0000)]
[llvm-mca][docs] Define IPC where it is first mentioned. NFC.

Expand the abbreviation where it is first used, and use IPC elsewhere.

llvm-svn: 337739

6 years agoUpdate to -r337585, allow scoped enum inits in -pedantic
Erich Keane [Mon, 23 Jul 2018 21:08:13 +0000 (21:08 +0000)]
Update to -r337585, allow scoped enum inits in -pedantic

llvm-svn: 337738

6 years ago[NFC] Minor code refactoring.
Raphael Isemann [Mon, 23 Jul 2018 20:56:49 +0000 (20:56 +0000)]
[NFC] Minor code refactoring.

Subscribers: lldb-commits

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

llvm-svn: 337737

6 years ago[CodeGen] Record if a C++ record is a trivial type
Aaron Smith [Mon, 23 Jul 2018 20:49:07 +0000 (20:49 +0000)]
[CodeGen] Record if a C++ record is a trivial type

Summary: This has a dependence on D45122

Reviewers: rnk, zturner, llvm-commits, aleksandr.urakov

Reviewed By: rnk

Subscribers: cfe-commits

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

llvm-svn: 337736

6 years agoFix RegScavenger::unprocess
David Greene [Mon, 23 Jul 2018 20:23:50 +0000 (20:23 +0000)]
Fix RegScavenger::unprocess

RegScavenger::unprocess walks backward, so it should undo the effects
of defs before undoing effects of kills. Previously it did things in
the opposite order, leaving a register apparently unused (dead) in the
case where an instruction both used (killed) and defined a register.

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

llvm-svn: 337735

6 years agoAdd inline asm aliasing test.
Nirav Dave [Mon, 23 Jul 2018 20:19:10 +0000 (20:19 +0000)]
Add inline asm aliasing test.

llvm-svn: 337734

6 years agoLanded XRay patch (D49559) in incorrect directory. Reverting changes.
Henry Zhu [Mon, 23 Jul 2018 20:07:18 +0000 (20:07 +0000)]
Landed XRay patch (D49559) in incorrect directory. Reverting changes.

llvm-svn: 337733

6 years ago[ms] Fix mangling of vector types in QMM_Result contexts.
Nico Weber [Mon, 23 Jul 2018 20:04:00 +0000 (20:04 +0000)]
[ms] Fix mangling of vector types in QMM_Result contexts.

If QMM_Result is set (which it is for return types, RTTI descriptors, and
exception type descriptors), tag types (structs, enums, classes, unions) get
their qualifiers mangled in.

__m64 and friends is a struct/union thingy in MSVC, but not in clang's headers.
To make mangling work, we call mangleArtificalTagType(TTK_Union/TTK_Struct for
the vector types to mangle them as tag types -- but the isa<TagType> check when
mangling in QMM_Result mode isn't true for these vector types. Add an
isArtificialTagType() function and check for that too. Fixes PR37276 and some
other issues.

I tried to audit all references to TagDecl and TagType in MicrosoftMangle.cpp
to find other places where we need to call mangleArtificalTagType(), but
couldn't find any.

I tried to audit all calls to mangleArtificalTagType() to see if
isArtificialTagType() needs to handle more than just the vector types, but as
far as I can tell all other types we use it for are types that MSVC can't
handle at all (Objective-C types etc).

https://reviews.llvm.org/D49597

llvm-svn: 337732

6 years agoRevert "[docs] Add support for Markdown documentation in Sphinx"
Michael J. Spencer [Mon, 23 Jul 2018 20:00:32 +0000 (20:00 +0000)]
Revert "[docs] Add support for Markdown documentation in Sphinx"

Looks like this bot hasn't been updated yet.

llvm-svn: 337731

6 years ago[docs] Add support for Markdown documentation in Sphinx
Michael J. Spencer [Mon, 23 Jul 2018 19:49:34 +0000 (19:49 +0000)]
[docs] Add support for Markdown documentation in Sphinx

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

llvm-svn: 337730

6 years agoRevert r337638, "ELF: Make sections with KeepUnique bit eligible for ICF."
Peter Collingbourne [Mon, 23 Jul 2018 19:36:55 +0000 (19:36 +0000)]
Revert r337638, "ELF: Make sections with KeepUnique bit eligible for ICF."

The gold behaviour with regard to --keep-unique is arguably a bug.
I also noticed a bug in my patch, which is that we mislink the
following program with --icf=safe by merging f3 and f4:

void f1() {}
void f2() {}

__attribute__((weak)) void* f3() { return f1; }
__attribute__((weak)) void* f4() { return f2; }

int main() {
  printf("%p %p\n", f3(), f4());
}

llvm-svn: 337729

6 years agoSeparate out the initialization kind for a statement expression result
Richard Smith [Mon, 23 Jul 2018 19:19:08 +0000 (19:19 +0000)]
Separate out the initialization kind for a statement expression result
from that for a return value.

No functionality change intended: I don't believe any of the diagnostics
affected by this patch are reachable when initializing the result of
statement expression.

llvm-svn: 337728

6 years ago[CMake] Fix the setting of LIBCXX_HEADER_DIR
Heejin Ahn [Mon, 23 Jul 2018 18:58:12 +0000 (18:58 +0000)]
[CMake] Fix the setting of LIBCXX_HEADER_DIR

Reviewers: phosek

Subscribers: mgorny, christof, ldionne, cfe-commits

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

llvm-svn: 337727

6 years agoFold dangling-field warning into general initialization lifetime checks.
Richard Smith [Mon, 23 Jul 2018 18:50:26 +0000 (18:50 +0000)]
Fold dangling-field warning into general initialization lifetime checks.

This reinstates r337627, reverted in r337671, with a fix to correctly
handle the lvalueness of array subscript expressions on pointers.

llvm-svn: 337726

6 years ago[yaml2obj] Add default sh_entsize for dynamic sections
Paul Semel [Mon, 23 Jul 2018 18:49:04 +0000 (18:49 +0000)]
[yaml2obj] Add default sh_entsize for dynamic sections

Dynamic section holds a table, so the sh_entsize might be set. As the
dynamic section entry size never changes, we can default it to the size
of a dynamic entry.

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

llvm-svn: 337725

6 years ago[XRay] Remove scheduling dependency in fork_basic_logging.cc
Henry Zhu [Mon, 23 Jul 2018 18:42:55 +0000 (18:42 +0000)]
[XRay] Remove scheduling dependency in fork_basic_logging.cc

Summary:
Continuation of https://reviews.llvm.org/D49501

Second part of the test has an scheduling order when there shouldn't be.

Reviewers: dberris, ormris

Reviewed By: dberris, ormris

Subscribers: TWeaver

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

llvm-svn: 337724

6 years ago[Hexagon] Handle unnamed globals in HexagonConstExpr
Krzysztof Parzyszek [Mon, 23 Jul 2018 18:30:17 +0000 (18:30 +0000)]
[Hexagon] Handle unnamed globals in HexagonConstExpr

Instead of comparing names, compare positions in the parent module.

llvm-svn: 337723

6 years agoRevert "[OPENMP] Fix PR38026: Link -latomic when -fopenmp is used."
Jonas Hahnfeld [Mon, 23 Jul 2018 18:27:09 +0000 (18:27 +0000)]
Revert "[OPENMP] Fix PR38026: Link -latomic when -fopenmp is used."

This reverts commit r336467: libatomic is not available on all Linux
systems and this commit completely breaks OpenMP on them, even if there
are no atomic operations or all of them can be lowered to hardware
instructions.

See http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20180716/234816.html
for post-commit discussion.

llvm-svn: 337722

6 years ago[CStringSyntaxChecker] Improvements of strlcpy check
David Carlier [Mon, 23 Jul 2018 18:26:38 +0000 (18:26 +0000)]
[CStringSyntaxChecker] Improvements of strlcpy check

Adding an additional check whenwe offset fro the buffer base address.

Reviewers: george.karpenkov,NoQ

Reviewed By: george.karpenkov

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

llvm-svn: 337721

6 years ago[Demangle] Attempt to fix arena memory leak
Reid Kleckner [Mon, 23 Jul 2018 18:21:43 +0000 (18:21 +0000)]
[Demangle] Attempt to fix arena memory leak

llvm-svn: 337720

6 years agoFixing a typo; NFC.
Aaron Ballman [Mon, 23 Jul 2018 18:09:43 +0000 (18:09 +0000)]
Fixing a typo; NFC.

llvm-svn: 337719

6 years ago[lit] Move the shtest-xunit-output check lines into shtest-format
Justin Bogner [Mon, 23 Jul 2018 18:08:36 +0000 (18:08 +0000)]
[lit] Move the shtest-xunit-output check lines into shtest-format

These two tests are operating on the same test suite, which causes
them to be racy about writing temporary files and can cause spurious
failures. Merge them into one test to avoid the issue.

llvm-svn: 337718

6 years ago[DebugInfo] Error out when enabling -fdebug-types-section on non-ELF target.
Jonas Devlieghere [Mon, 23 Jul 2018 17:50:15 +0000 (17:50 +0000)]
[DebugInfo] Error out when enabling -fdebug-types-section on non-ELF target.

Currently, support for debug_types is only present for ELF and trying to
pass -fdebug-types-section for other targets results in a crash in the
backend. Until this is fixed, we should emit a diagnostic in the front
end when the option is passed for non-linux targets.

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

llvm-svn: 337717

6 years ago[clang-tidy] fix PR36489 - respect deduced pointer types from auto as well
Jonas Toth [Mon, 23 Jul 2018 17:46:17 +0000 (17:46 +0000)]
[clang-tidy] fix PR36489 - respect deduced pointer types from auto as well

Summary:
The cppcoreguidelines-pro-bounds-pointer-arithmetic warns on all occassion where
pointer arithmetic is used, but does not check values where the pointer types
is deduced via `auto`. This patch adjusts this behaviour and solved
PR36489.
I accidentally commited a wrong patch, this Differential is meant to have a
correct revision description and code attached to it.
Because the patch was accepted by aaron.ballman already, i will just commit
it.
See https://reviews.llvm.org/D48717 for the old differntial (contains wrong
code from the mixup)

Subscribers: nemanjai, xazax.hun, kbarton, cfe-commits

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

llvm-svn: 337716

6 years ago[MS] Update _MSVC_LANG values for C++17 and C++2a
Reid Kleckner [Mon, 23 Jul 2018 17:44:00 +0000 (17:44 +0000)]
[MS] Update _MSVC_LANG values for C++17 and C++2a

Fixes PR38262

llvm-svn: 337715

6 years ago[ARM] Use unique_ptr to fix memory leak introduced in r337701
Fangrui Song [Mon, 23 Jul 2018 17:43:21 +0000 (17:43 +0000)]
[ARM] Use unique_ptr to fix memory leak introduced in r337701

llvm-svn: 337714

6 years agoOpChain has subclasses, so add a virtual destructor.
Jordan Rupprecht [Mon, 23 Jul 2018 17:38:05 +0000 (17:38 +0000)]
OpChain has subclasses, so add a virtual destructor.

Summary:
OpChain has subclasses, so add a virtual destructor.

This fixes an issue when deleting subclasses of OpChain (see MatchSMLAD() specifically) in r337701.

Reviewers: javed.absar

Subscribers: llvm-commits, SjoerdMeijer, samparker

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

llvm-svn: 337713

6 years agoRevert "[clang-tidy] fix PR36489 - respect deduced pointer types from auto as well"
Jonas Toth [Mon, 23 Jul 2018 17:34:25 +0000 (17:34 +0000)]
Revert "[clang-tidy] fix PR36489 - respect deduced pointer types from auto as well"

I applied the wrong patch.

llvm-svn: 337712

6 years ago[ARM] Follow-up to r337709.
Matt Morehouse [Mon, 23 Jul 2018 17:22:53 +0000 (17:22 +0000)]
[ARM] Follow-up to r337709.

Fix double-free.

llvm-svn: 337711

6 years ago[clang-tidy] fix PR36489 - respect deduced pointer types from auto as well
Jonas Toth [Mon, 23 Jul 2018 17:13:06 +0000 (17:13 +0000)]
[clang-tidy] fix PR36489 - respect deduced pointer types from auto as well

Summary:
The cppcoreguidelines-pro-bounds-pointer-arithmetic warns on all occassion where
pointer arithmetic is used, but does not check values where the pointer types
is deduced via ``auto``. This patch adjusts this behaviour and solved
PR36489.

Reviewers: alexfh, aaron.ballman, hokein, ilya-biryukov

Reviewed By: alexfh, aaron.ballman

Subscribers: nemanjai, xazax.hun, kbarton, cfe-commits

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

llvm-svn: 337710

6 years ago[ARM] Add doFinalization() to ARMCodeGenPrepare pass.
Matt Morehouse [Mon, 23 Jul 2018 17:00:45 +0000 (17:00 +0000)]
[ARM] Add doFinalization() to ARMCodeGenPrepare pass.

Attempt to fix the leak introduced in r337687 and make sanitizer
buildbots green again.

llvm-svn: 337709

6 years ago[Legalize] Elide MERGE_VALUES created by scalarizeVectorLoad.
Nirav Dave [Mon, 23 Jul 2018 16:43:42 +0000 (16:43 +0000)]
[Legalize] Elide MERGE_VALUES created by scalarizeVectorLoad.

scalarizeVectorLoad creates MERGE_VALUES nodes which are immediately
decomposed in expandLoad. Elide the node in these cases.

llvm-svn: 337708

6 years ago[clang-tidy] remove private decltypeType in TrailingReturnType
Jonas Toth [Mon, 23 Jul 2018 16:30:13 +0000 (16:30 +0000)]
[clang-tidy] remove private decltypeType in TrailingReturnType

Summary:
This patch removes a private matcher in fuchsia/TrailingReturnType check because
the matcher is now in ASTMatchers

Reviewers: aaron.ballman, alexfh, hokein

Reviewed By: aaron.ballman

Subscribers: xazax.hun, cfe-commits

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

llvm-svn: 337707

6 years ago[Sema] Don't emit -Wmemset-transposed-args for memset(p,0,0)
Erik Pilkington [Mon, 23 Jul 2018 16:24:14 +0000 (16:24 +0000)]
[Sema] Don't emit -Wmemset-transposed-args for memset(p,0,0)

Thanks to Arthur O'Dwyer for the suggestion!

llvm-svn: 337706

6 years ago[mips] Add more checks to the tls.ll test case. NFC
Simon Atanasyan [Mon, 23 Jul 2018 16:05:44 +0000 (16:05 +0000)]
[mips] Add more checks to the tls.ll test case. NFC

llvm-svn: 337705

6 years ago[NEON] Define half-precision vmaxnm intrinsics only when available
Ivan A. Kosarev [Mon, 23 Jul 2018 16:01:35 +0000 (16:01 +0000)]
[NEON] Define half-precision vmaxnm intrinsics only when available

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

llvm-svn: 337704

6 years ago[ASTMatchers] add matcher for decltypeType and its underlyingType
Jonas Toth [Mon, 23 Jul 2018 15:59:27 +0000 (15:59 +0000)]
[ASTMatchers] add matcher for decltypeType and its underlyingType

Summary:
This patch introduces a new matcher for `DecltypeType` and its underlying type
in order to fix a bug in clang-tidy, see https://reviews.llvm.org/D48717 for more.

Reviewers: aaron.ballman, alexfh, NoQ, dcoughlin

Reviewed By: aaron.ballman

Subscribers: cfe-commits

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

llvm-svn: 337703

6 years ago[isl] Simplify iterator implementation by building on top of list accessors
Philip Pfaffe [Mon, 23 Jul 2018 15:28:50 +0000 (15:28 +0000)]
[isl] Simplify iterator implementation by building on top of list accessors

Summary:
With the new accessors, it's straightforward to use the templated
iterator instead of subclassing it for all the list types.

Depends on D49019

Reviewers: grosser, Meinersbur, bollu

Reviewed By: grosser

Subscribers: mehdi_amini, steven_wu, dexonsmith, pollydev, llvm-commits

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

llvm-svn: 337702

6 years ago[ARM][NFC] ParallelDSP reorganisation
Sam Parker [Mon, 23 Jul 2018 15:25:59 +0000 (15:25 +0000)]
[ARM][NFC] ParallelDSP reorganisation

In preparing to allow ARMParallelDSP pass to parallelise more than
smlads, I've restructed some elements:

- The ParallelMAC struct has been renamed to BinOpChain.
- The BinOpChain struct holds two value lists: LHS and RHS, as well
  as inheriting from the OpChain base class.
- The OpChain struct holds all the values of the represented chain
  and has had the memory locations functionality inserted into it.
- ParallelMACList becomes OpChainList and it now holds pointers
  instead of objects.

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

llvm-svn: 337701

6 years ago[SystemZ] Fix dumpSU() method in SystemZHazardRecognizer.
Jonas Paulsson [Mon, 23 Jul 2018 15:08:35 +0000 (15:08 +0000)]
[SystemZ]  Fix dumpSU() method in SystemZHazardRecognizer.

Two minor issues: The new MCD SchedWrite name does not contain "Unit" like
all the others, so a check is needed. Also, print "LSU" instead of "LS".

Review: Ulrich Weigand
llvm-svn: 337700

6 years ago[NEON] Define half-precision vrnd intrinsics only when available
Ivan A. Kosarev [Mon, 23 Jul 2018 14:53:44 +0000 (14:53 +0000)]
[NEON] Define half-precision vrnd intrinsics only when available

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

llvm-svn: 337699

6 years ago[FPEnv] Legalize double width StrictFP vector operations
Cameron McInally [Mon, 23 Jul 2018 14:40:17 +0000 (14:40 +0000)]
[FPEnv] Legalize double width StrictFP vector operations

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

llvm-svn: 337698

6 years ago[clangd] Fix category in clangd-vscode's package.json
Simon Marchi [Mon, 23 Jul 2018 14:32:12 +0000 (14:32 +0000)]
[clangd] Fix category in clangd-vscode's package.json

Summary:
When opening package.json, vscode shows:

  Use 'Programming  Languages' instead

Replacing "Languages" with this fixes it.

Reviewers: ilya-biryukov

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

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

llvm-svn: 337697

6 years ago[libFuzzer] Handle unstable edges by using minimum hit counts
Max Moroz [Mon, 23 Jul 2018 14:20:52 +0000 (14:20 +0000)]
[libFuzzer] Handle unstable edges by using minimum hit counts

Summary:
Created unstable_handle flag that takes 1 or 2, depending on the handling type.
Modified RunOne to accommodate the following heuristic:
    Use the first CollectFeatures to count how many features there are.
    If no new features, CollectFeatures like before.
    If there is new feature, we run CB 2 more times,
        Check which edges are unstable per input and we store the least amount of hit counts for each edge.
        Apply these hit counts back to inline8bitcounters so that CollectFeatures can work as intended.
Modified UnstableCounters to 8int_t and created a bitset UnstableSet to tell which edges are unstable.

Patch by Kyungtak Woo (@kevinwkt).

Reviewers: Dor1s, metzman, morehouse

Reviewed By: Dor1s, morehouse

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

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

llvm-svn: 337696

6 years ago[Docs] Fix LLVM_YAML_IS_DOCUMENT_LIST_VECTOR
Jonas Devlieghere [Mon, 23 Jul 2018 14:17:43 +0000 (14:17 +0000)]
[Docs] Fix LLVM_YAML_IS_DOCUMENT_LIST_VECTOR

The docs incorrectly said to repeat std::vector inside
LLVM_YAML_IS_DOCUMENT_LIST_VECTOR.

llvm-svn: 337695

6 years agoAdd support for parsing Breakpad minidump files that can have extra padding in the...
Greg Clayton [Mon, 23 Jul 2018 14:16:08 +0000 (14:16 +0000)]
Add support for parsing Breakpad minidump files that can have extra padding in the module, thread and memory lists.

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

llvm-svn: 337694

6 years ago[LLD] Add llvm-objcopy to test dependencies. NFC.
Andrew Ng [Mon, 23 Jul 2018 14:12:57 +0000 (14:12 +0000)]
[LLD] Add llvm-objcopy to test dependencies. NFC.

Dependency on llvm-objcopy was introduced by r337429.

Also sorted the list of dependencies.

llvm-svn: 337693