platform/upstream/llvm.git
6 years agoMove the clang-tblgen project into the Clang tablegenning folder on IDEs like Visual...
Aaron Ballman [Sat, 4 Nov 2017 20:06:22 +0000 (20:06 +0000)]
Move the clang-tblgen project into the Clang tablegenning folder on IDEs like Visual Studio rather than leave it in the root directory. NFC.

llvm-svn: 317418

6 years agoMove the libclang-headers project into the Misc folder on IDEs like Visual Studio...
Aaron Ballman [Sat, 4 Nov 2017 20:00:21 +0000 (20:00 +0000)]
Move the libclang-headers project into the Misc folder on IDEs like Visual Studio rather than leave it in the root directory. NFC.

llvm-svn: 317417

6 years agoMove the srpm, ocaml_make_directory, llvm_vcsrevision_h, and llvm-headers projects...
Aaron Ballman [Sat, 4 Nov 2017 19:59:14 +0000 (19:59 +0000)]
Move the srpm, ocaml_make_directory, llvm_vcsrevision_h, and llvm-headers projects into the Misc folder on IDEs like Visual Studio rather than leave them in the root directory. NFC.

llvm-svn: 317416

6 years agoMove the LLVMCFIVerify project into the Libraries folder on IDEs like Visual Studio...
Aaron Ballman [Sat, 4 Nov 2017 19:48:17 +0000 (19:48 +0000)]
Move the LLVMCFIVerify project into the Libraries folder on IDEs like Visual Studio rather than leave it in the root directory. NFC.

llvm-svn: 317415

6 years agoMove these CMake projects into the Tests folder on IDEs like Visual Studio rather...
Aaron Ballman [Sat, 4 Nov 2017 19:39:14 +0000 (19:39 +0000)]
Move these CMake projects into the Tests folder on IDEs like Visual Studio rather than leave it in the root directory. NFC.

llvm-svn: 317414

6 years ago[X86] Don't use RCP14 and RSQRT14 for reciprocal estimations or for legacy SSE rcp...
Craig Topper [Sat, 4 Nov 2017 18:26:41 +0000 (18:26 +0000)]
[X86] Don't use RCP14 and RSQRT14 for reciprocal estimations or for legacy SSE rcp/rsqrt intrinsics when AVX512 features are enabled.

Summary:
AVX512 added RCP14 and RSQRT instructions which improve accuracy over the legacy RCP and RSQRT instruction, but not enough accuracy to remove the need for a Newton Raphson refinement.

Currently we use these new instructions for the legacy packed SSE instrinics, but not the scalar instrinsics. And we use it for fast math optimization of division and reciprocal sqrt.

I think switching the legacy instrinsics maybe surprising to the user since it changes the answer based on which processor you're using regardless of any fastmath settings. It's also weird that we did something different between scalar and packed.

As far at the reciprocal estimation, I think it creates unnecessary deltas in our output behavior (and prevents EVEX->VEX). A little playing around with gcc and icc and godbolt suggest they don't change which instructions they use here.

This patch adds new X86ISD nodes for the RCP14/RSQRT14 and uses those for the new intrinsics. Leaving the old intrinsics to use the old instructions.

Going forward I think our focus should be on
-Supporting 512-bit vectors, which will have to use the RCP14/RSQRT14.
-Using RSQRT28/RCP28 to remove the Newton Raphson step on processors with AVX512ER
-Supporting double precision.

Reviewers: zvi, DavidKreitzer, RKSimon

Reviewed By: RKSimon

Subscribers: llvm-commits

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

llvm-svn: 317413

6 years ago[X86] Regenerate a couple more tests that I missed in r317410.
Craig Topper [Sat, 4 Nov 2017 18:26:39 +0000 (18:26 +0000)]
[X86] Regenerate a couple more tests that I missed in r317410.

llvm-svn: 317412

6 years agoImprove the posix core file triple detection
Tamas Berghammer [Sat, 4 Nov 2017 18:25:51 +0000 (18:25 +0000)]
Improve the posix core file triple detection

Summary:
Posix core files sometime don't contain enough information to correctly
detect the OS. If that is the case we should use the OS from the target
instead as it will contain usable information in more cases and if the
target and the core contain different OS-es then we are already in a
pretty bad state so moving from an unknown OS to a known (but possibly
incorrect) OS will do no harm.

We already had similar code in place for MIPS. This change tries to make
it more generic by using ArchSpec::MergeFrom and extends it to all
architectures but some MIPS specific issue prevent us from getting rid
of special casing MIPS.

Reviewers: clayborg, nitesh.jain

Subscribers: aemerson, sdardis, arichardson, kristof.beyls, lldb-commits

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

llvm-svn: 317411

6 years ago[X86] Teach EVEX->VEX pass to turn SHUFI32X4/SHUFF32X4/SHUFI64X/SHUFF64X2 into VPERM2...
Craig Topper [Sat, 4 Nov 2017 18:10:03 +0000 (18:10 +0000)]
[X86] Teach EVEX->VEX pass to turn SHUFI32X4/SHUFF32X4/SHUFI64X/SHUFF64X2 into VPERM2F128/VPERM2I128.

This recovers some of the tests that were changed by r317403.

llvm-svn: 317410

6 years ago[AMDGPU] Remove hardcoded address space value from AMDGPULibFunc
Yaxun Liu [Sat, 4 Nov 2017 17:37:43 +0000 (17:37 +0000)]
[AMDGPU] Remove hardcoded address space value from AMDGPULibFunc

AMDGPULibFunc hardcodes address space values of the old address space mapping,
which causes invalid addrspacecast instructions and undefined functions in
APPSDK sample MonteCarloAsianDP.

This patch fixes that.

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

llvm-svn: 317409

6 years ago[LTO][ThinLTO] Use the linker resolutions to mark global values as dso_local.
Sean Fertile [Sat, 4 Nov 2017 17:04:39 +0000 (17:04 +0000)]
[LTO][ThinLTO] Use the linker resolutions to mark global values as dso_local.

Now that we have a way to mark GlobalValues as local we can use the symbol
resolutions that the linker plugin provides as part of lto/thinlto link
step to refine the compilers view on what symbols will end up being local.

Originally commited as r317374, but reverted in r317395 to update some missed
tests.

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

llvm-svn: 317408

6 years ago[CodeGen] add remquo to list of recognized library calls
Sanjay Patel [Sat, 4 Nov 2017 15:03:11 +0000 (15:03 +0000)]
[CodeGen] add remquo to list of recognized library calls

This is just an oversight because we already do recognize __builtin_remquo()
with the same signature.

http://en.cppreference.com/w/c/numeric/math/remquo
http://pubs.opengroup.org/onlinepubs/9699919799/functions/remquo.html

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

llvm-svn: 317407

6 years ago[ELF] - Stop using SectionKey for creating output sections.
George Rimar [Sat, 4 Nov 2017 09:11:27 +0000 (09:11 +0000)]
[ELF] - Stop using SectionKey for creating output sections.

Stop using SectionKey for creating output sections.

Initially SectionKey was designed because we merged section with
use of Flags and Alignment fields. Currently LLD merges them by name only,
except the case when -relocatable output is produced. In that case
we still merge sections only with the same flags and alignment.
There is probably no issue at all to stop using Flags and Alignment for -r and
just disable the merging in that case.

After doing that change we can get rid of using SectionKey. That is not only
simplifies the code, but also gives some perfomance boost.

I tried to link chrome and mozilla, results are next:
* chrome link time goes from 1,666750355s to 1,551585364s, that is about 7%.
* mozilla time changes from 3,210261947 to 3,153782940, or about 2%.

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

llvm-svn: 317406

6 years ago[ELF] - Fix error reporting with --strip-debug/--strip-all.
George Rimar [Sat, 4 Nov 2017 08:20:30 +0000 (08:20 +0000)]
[ELF] - Fix error reporting with --strip-debug/--strip-all.

Currently LLD tries to use information about functions and variables location
taking it from debug sections. When --strip-* is given we discard such sections
and that breaks error reporting.
Patch stops discarding such sections and just removes them from InputSections list.

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

llvm-svn: 317405

6 years agollvm/test/lit.cfg.py: Don't set the feature "llvm-64-bits" if -m32 is specified.
NAKAMURA Takumi [Sat, 4 Nov 2017 06:55:55 +0000 (06:55 +0000)]
llvm/test/lit.cfg.py: Don't set the feature "llvm-64-bits" if -m32 is specified.

FIXME: LLVM_BUILD_32_BITS should modify host_triple.
llvm-svn: 317404

6 years ago[X86] Teach shuffle lowering to use 256-bit SHUF128 when possible.
Craig Topper [Sat, 4 Nov 2017 06:44:47 +0000 (06:44 +0000)]
[X86] Teach shuffle lowering to use 256-bit SHUF128 when possible.

This allows masked operations to be used and allows the register allocator to use YMM16-31 if necessary.

As a follow up I'll look into teaching EVEX->VEX how to turn this back into PERM2X128 if any of the additional features don't work out.

llvm-svn: 317403

6 years agoCMake: Let LLVM_BUILD_32_BITS aware of large file.
NAKAMURA Takumi [Sat, 4 Nov 2017 06:03:29 +0000 (06:03 +0000)]
CMake: Let LLVM_BUILD_32_BITS aware of large file.

llvm-svn: 317402

6 years agollvm/test/Object/archive-SYM64-write.test: Delete large temp files. They are 8GiB...
NAKAMURA Takumi [Sat, 4 Nov 2017 06:00:11 +0000 (06:00 +0000)]
llvm/test/Object/archive-SYM64-write.test: Delete large temp files. They are 8GiB total.

llvm-svn: 317401

6 years agoCodeGenCXX: no default dllimport storage for mingw
Martell Malone [Sat, 4 Nov 2017 02:15:49 +0000 (02:15 +0000)]
CodeGenCXX: no default dllimport storage for mingw

GNU frontends don't have options like /MT, /MD
This fixes a few link error regressions with libc++ and libc++abi

Reviewers: rnk, mstorsjo, compnerd

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

llvm-svn: 317398

6 years ago[Driver] MinGW: Remove custom linker detection
Martell Malone [Sat, 4 Nov 2017 02:07:59 +0000 (02:07 +0000)]
[Driver] MinGW: Remove custom linker detection

This is a re-apply of rL313082 which was reverted in rL313088

In rL289668 the ability to specify the default linker at compile time
was added but because the MinGW driver used custom detection we could
not take advantage of this new CMAKE flag CLANG_DEFAULT_LINKER.

rL289668 added no test cases and the mingw driver was either overlooked
or purposefully skipped because it has some custom linker tests
Removing them here because they are covered by the generic case.

Reviewers: rnk

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

llvm-svn: 317397

6 years ago[ELF] Support expressions with -defsym option
Petr Hosek [Sat, 4 Nov 2017 02:03:58 +0000 (02:03 +0000)]
[ELF] Support expressions with -defsym option

Fixes PR34948.

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

llvm-svn: 317396

6 years agoRevert "[LTO][ThinLTO] Use the linker resolutions to mark global values ..."
Sean Fertile [Sat, 4 Nov 2017 01:54:20 +0000 (01:54 +0000)]
Revert "[LTO][ThinLTO] Use the linker resolutions to mark global values ..."

Changes more tests then expected on one of the build bots.
reverting to investigate.

This reverts https://llvm.org/svn/llvm-project/llvm/trunk@317374

llvm-svn: 317395

6 years agoUpdate ODR hashing tests
Richard Trieu [Sat, 4 Nov 2017 01:20:50 +0000 (01:20 +0000)]
Update ODR hashing tests

Add a mix of postive and negative tests to check that wrong Decls won't be
flagged in the diagnostic.  Split the check everything test and moved the
pieces closer to where the related tests are.

llvm-svn: 317394

6 years ago[CallSiteSplitting] clang-format my last commit. NFCI.
Davide Italiano [Sat, 4 Nov 2017 00:44:01 +0000 (00:44 +0000)]
[CallSiteSplitting] clang-format my last commit. NFCI.

Thanks to Rui for pointing out.

llvm-svn: 317393

6 years agoRename Body -> Sym.
Rui Ueyama [Sat, 4 Nov 2017 00:31:04 +0000 (00:31 +0000)]
Rename Body -> Sym.

This patch is mechanically created by

  sed -i -e s/Body/Sym/g lld/ELF/*.{cpp,h}

and clang-format-diff.

llvm-svn: 317392

6 years agoFix CMake definitions of tsan runtime to make it installed by "install-compiler-rt"
Mehdi Amini [Sat, 4 Nov 2017 00:07:20 +0000 (00:07 +0000)]
Fix CMake definitions of tsan runtime to make it installed by "install-compiler-rt"

Summary: The PARENT_TARGET was correctly set under APPLE but not under linux.

Reviewers: kubamracek, samsonov

Subscribers: dberris, mgorny, llvm-commits

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

llvm-svn: 317391

6 years ago[scudo] Rearrange #include order
Kostya Kortchinsky [Fri, 3 Nov 2017 23:48:25 +0000 (23:48 +0000)]
[scudo] Rearrange #include order

Summary:
To be compliant with https://llvm.org/docs/CodingStandards.html#include-style,
system headers have to come after local headers.

Reviewers: alekseyshl

Reviewed By: alekseyshl

Subscribers: llvm-commits

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

llvm-svn: 317390

6 years ago[Sanitizers] Call NanoTime() conditionally.
Alex Shlyapnikov [Fri, 3 Nov 2017 23:31:00 +0000 (23:31 +0000)]
[Sanitizers] Call NanoTime() conditionally.

Summary:
Call NanoTime() in primary 64 bit allocator only when necessary,
otherwise the unwarranted syscall causes problems in sandbox environments.
ReleaseToOSIntervalMs() conditional allows them to turn the feature off
with allocator_release_to_os_interval_ms=-1 flag.

Reviewers: eugenis

Subscribers: kubamracek, llvm-commits

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

llvm-svn: 317386

6 years ago[CallSiteSplitting] Silence GCC's -Wparentheses. NFCI.
Davide Italiano [Fri, 3 Nov 2017 23:03:38 +0000 (23:03 +0000)]
[CallSiteSplitting] Silence GCC's -Wparentheses. NFCI.

llvm-svn: 317385

6 years ago[COFF] Avoid "Body" as a local variable name.
Rui Ueyama [Fri, 3 Nov 2017 22:49:02 +0000 (22:49 +0000)]
[COFF] Avoid "Body" as a local variable name.

Since SymbolBody is gone, "Body" is not a good variable name.
This patch renames or eliminates them.

llvm-svn: 317384

6 years agoRename replaceBody -> replaceSymbol.
Rui Ueyama [Fri, 3 Nov 2017 22:48:47 +0000 (22:48 +0000)]
Rename replaceBody -> replaceSymbol.

llvm-svn: 317383

6 years ago[X86] Give unary PERMI priority over SHUF128 in lowerV8I64VectorShuffle to make it...
Craig Topper [Fri, 3 Nov 2017 22:48:13 +0000 (22:48 +0000)]
[X86] Give unary PERMI priority over SHUF128 in lowerV8I64VectorShuffle to make it possible to fold a load.

llvm-svn: 317382

6 years ago[Basic] Fix some Clang-tidy modernize and Include What You Use warnings; other minor...
Eugene Zelenko [Fri, 3 Nov 2017 22:35:27 +0000 (22:35 +0000)]
[Basic] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).

llvm-svn: 317381

6 years agoFix variable name.
Zachary Turner [Fri, 3 Nov 2017 22:33:49 +0000 (22:33 +0000)]
Fix variable name.

A mechanical rename caused an illegal name conflict between
a variable and a type, which was picked up by GCC.

llvm-svn: 317380

6 years agoMove TargetFrameLowering.h to CodeGen where it's implemented
David Blaikie [Fri, 3 Nov 2017 22:32:11 +0000 (22:32 +0000)]
Move TargetFrameLowering.h to CodeGen where it's implemented

This header already includes a CodeGen header and is implemented in
lib/CodeGen, so move the header there to match.

This fixes a link error with modular codegeneration builds - where a
header and its implementation are circularly dependent and so need to be
in the same library, not split between two like this.

llvm-svn: 317379

6 years agoRevert "[ELF] - Teach LLD to use information from .debug_str for error reporting."
Bob Haarman [Fri, 3 Nov 2017 22:23:19 +0000 (22:23 +0000)]
Revert "[ELF] - Teach LLD to use information from .debug_str for error reporting."

This reverts commit 00b7acb8f6c8a4663bb7c8396d217c210209b562.

It was causing some links to execute llvm_unreachable.

llvm-svn: 317378

6 years agoRemove ProcessGdbRemote::m_flags
Pavel Labath [Fri, 3 Nov 2017 22:12:50 +0000 (22:12 +0000)]
Remove ProcessGdbRemote::m_flags

The member is completely unused. Discussed on lldb-dev.

llvm-svn: 317377

6 years ago[MinGW] Output debug info by default, unless the -s parameter is passed
Martin Storsjo [Fri, 3 Nov 2017 22:10:37 +0000 (22:10 +0000)]
[MinGW] Output debug info by default, unless the -s parameter is passed

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

llvm-svn: 317376

6 years agoInvoke salvageDebugInfo from CodeGenPrepare's SinkCast()
Adrian Prantl [Fri, 3 Nov 2017 21:55:03 +0000 (21:55 +0000)]
Invoke salvageDebugInfo from CodeGenPrepare's SinkCast()

This preserves the debug info for the cast operation in the original location.

rdar://problem/33460652

Reapplied r317340 with the test moved into an ARM-specific directory.

llvm-svn: 317375

6 years ago[LTO][ThinLTO] Use the linker resolutions to mark global values as dso_local.
Sean Fertile [Fri, 3 Nov 2017 21:45:55 +0000 (21:45 +0000)]
[LTO][ThinLTO] Use the linker resolutions to mark global values as dso_local.

Now that we have a way to mark GlobalValues as local we can use the symbol
resolutions that the linker plugin provides as part of lto/thinlto link
step to refine the compilers view on what symbols will end up being local.

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

llvm-svn: 317374

6 years agoFix a crash in llvm-objdump when printing a bad x86_64 relocation in a Mach-O
Kevin Enderby [Fri, 3 Nov 2017 21:32:44 +0000 (21:32 +0000)]
Fix a crash in llvm-objdump when printing a bad x86_64 relocation in a Mach-O
file with a bad section number.

rdar://35207539

llvm-svn: 317373

6 years agoAdd -fcxx-exceptions for ExtractionSemicolonPolicy.cpp to appease PS4 bots
Alex Lorenz [Fri, 3 Nov 2017 21:31:10 +0000 (21:31 +0000)]
Add -fcxx-exceptions for ExtractionSemicolonPolicy.cpp to appease PS4 bots

llvm-svn: 317372

6 years agoRevert r317046, "Object: Move some code from ELF.h into ELF.cpp."
Peter Collingbourne [Fri, 3 Nov 2017 21:30:06 +0000 (21:30 +0000)]
Revert r317046, "Object: Move some code from ELF.h into ELF.cpp."

This change resulted in a measured 1.5-2% perf regression linking
chrome.

llvm-svn: 317371

6 years agoRename SymbolBody -> Symbol
Rui Ueyama [Fri, 3 Nov 2017 21:21:47 +0000 (21:21 +0000)]
Rename SymbolBody -> Symbol

Now that we have only SymbolBody as the symbol class. So, "SymbolBody"
is a bit strange name now. This is a mechanical change generated by

  perl -i -pe s/SymbolBody/Symbol/g $(git grep -l SymbolBody lld/ELF lld/COFF)

nd clang-format-diff.

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

llvm-svn: 317370

6 years agoLate fixup in _lwp_exit on TSan/NetBSD
Kamil Rytarowski [Fri, 3 Nov 2017 21:08:52 +0000 (21:08 +0000)]
Late fixup in _lwp_exit on TSan/NetBSD

Call DestroyThreadState() before REAL(_lwp_exit)();

This variation is less racy.

Sponsored by <The NetBSD Foundation>

llvm-svn: 317369

6 years ago[SimplifyCFG] When merging conditional stores, don't count the store we're merging...
Craig Topper [Fri, 3 Nov 2017 21:08:13 +0000 (21:08 +0000)]
[SimplifyCFG] When merging conditional stores, don't count the store we're merging against the PHINodeFoldingThreshold

Merging conditional stores tries to check to see if the code is if convertible after the store is moved. But the store hasn't been moved yet so its being counted against the threshold.

The patch adds 1 to the threshold comparison to make sure we don't count the store. I've adjusted a test to use a lower threshold to ensure we still do that conversion with the lower threshold.

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

llvm-svn: 317368

6 years ago[COFF] Autoexport symbols as data if they don't point to an executable section
Martin Storsjo [Fri, 3 Nov 2017 20:58:20 +0000 (20:58 +0000)]
[COFF] Autoexport symbols as data if they don't point to an executable section

This was already taken care of for the output def file.

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

llvm-svn: 317367

6 years agoGCOV: Move GCOV from IR & Support into ProfileData to fix layering
David Blaikie [Fri, 3 Nov 2017 20:57:10 +0000 (20:57 +0000)]
GCOV: Move GCOV from IR & Support into ProfileData to fix layering

This class was split between libIR and libSupport, which breaks under
modular code generation. Move it into the one library that uses it,
ProfileData, to resolve this issue.

llvm-svn: 317366

6 years agollvm-objdump: Fix unused-lambda-capture warning by removing unused lambda capture
David Blaikie [Fri, 3 Nov 2017 20:57:09 +0000 (20:57 +0000)]
llvm-objdump: Fix unused-lambda-capture warning by removing unused lambda capture

llvm-svn: 317365

6 years ago[cfi-verify] Add blacklist parsing for result filtering.
Mitch Phillips [Fri, 3 Nov 2017 20:54:26 +0000 (20:54 +0000)]
[cfi-verify] Add blacklist parsing for result filtering.

Adds blacklist parsing behaviour for filtering results into four categories:

 - Expected Protected: Things that are not in the blacklist and are protected.
 - Unexpected Protected: Things that are in the blacklist and are protected.
 - Expected Unprotected: Things that are in the blacklist and are unprotected.
 - Unexpected Unprotected: Things that are not in the blacklist and are unprotected.

 now can optionally be invoked with a second command line argument, which specifies the blacklist file that the binary was built with.

Current  statistics for chromium:

Reviewers: vlad.tsyrklevich

Subscribers: mgorny, llvm-commits, pcc, kcc

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

llvm-svn: 317364

6 years agoCorrect detection of a thread termination
Kamil Rytarowski [Fri, 3 Nov 2017 20:48:19 +0000 (20:48 +0000)]
Correct detection of a thread termination

Summary:
Stop using the Linux solution with pthread_key_create(3).
This approach does not work on NetBSD, because calling
the thread destructor is not the latest operation on a POSIX
thread entity. NetBSD's libpthread still calls at least
pthread_mutex_lock and pthread_mutex_unlock.

Detect _lwp_exit(2) call as it is really the latest operation
called from a detaching POSIX thread.

This resolves one set of crashes observed in
the Thread Sanitizer execution.

Sponsored by <The NetBSD Foundation>

Reviewers: joerg, kcc, vitalybuka, dvyukov, eugenis

Reviewed By: vitalybuka

Subscribers: llvm-commits, kubamracek, #sanitizers

Tags: #sanitizers

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

llvm-svn: 317363

6 years agoRecommit r317351 : Add CallSiteSplitting pass
Jun Bum Lim [Fri, 3 Nov 2017 20:41:16 +0000 (20:41 +0000)]
Recommit r317351 : Add CallSiteSplitting pass

This recommit r317351 after fixing a buildbot failure.

Original commit message:

    Summary:
    This change add a pass which tries to split a call-site to pass
    more constrained arguments if its argument is predicated in the control flow
    so that we can expose better context to the later passes (e.g, inliner, jump
    threading, or IPA-CP based function cloning, etc.).
    As of now we support two cases :

    1) If a call site is dominated by an OR condition and if any of its arguments
    are predicated on this OR condition, try to split the condition with more
    constrained arguments. For example, in the code below, we try to split the
    call site since we can predicate the argument (ptr) based on the OR condition.

    Split from :
          if (!ptr || c)
            callee(ptr);
    to :
          if (!ptr)
            callee(null ptr)  // set the known constant value
          else if (c)
            callee(nonnull ptr)  // set non-null attribute in the argument

    2) We can also split a call-site based on constant incoming values of a PHI
    For example,
    from :
          BB0:
           %c = icmp eq i32 %i1, %i2
           br i1 %c, label %BB2, label %BB1
          BB1:
           br label %BB2
          BB2:
           %p = phi i32 [ 0, %BB0 ], [ 1, %BB1 ]
           call void @bar(i32 %p)
    to
          BB0:
           %c = icmp eq i32 %i1, %i2
           br i1 %c, label %BB2-split0, label %BB1
          BB1:
           br label %BB2-split1
          BB2-split0:
           call void @bar(i32 0)
           br label %BB2
          BB2-split1:
           call void @bar(i32 1)
           br label %BB2
          BB2:
           %p = phi i32 [ 0, %BB2-split0 ], [ 1, %BB2-split1 ]

llvm-svn: 317362

6 years agoDisable detection of on_exit()/TSan on NetBSD
Kamil Rytarowski [Fri, 3 Nov 2017 20:39:51 +0000 (20:39 +0000)]
Disable detection of on_exit()/TSan on NetBSD

Summary:
NetBSD does not ship with on_exit() function.

Introduce TSAN_MAYBE_INTERCEPT_ON_EXIT.
It looks like this addition fixes build for Darwin.

Sponsored by <The NetBSD Foundation>

Reviewers: vitalybuka, joerg, eugenis, dvyukov, kcc

Reviewed By: vitalybuka

Subscribers: llvm-commits, kubamracek, #sanitizers

Tags: #sanitizers

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

llvm-svn: 317361

6 years agoModularize: Include some required headers
David Blaikie [Fri, 3 Nov 2017 20:24:19 +0000 (20:24 +0000)]
Modularize: Include some required headers

DenseMaps require the definition of a type to be available when using a
pointer to that type as a key to know how many bits are available for
tombstone/etc.

llvm-svn: 317360

6 years agoReplace a use of std::for_each() with llvm::for_each(); NFC.
Aaron Ballman [Fri, 3 Nov 2017 20:09:17 +0000 (20:09 +0000)]
Replace a use of std::for_each() with llvm::for_each(); NFC.

llvm-svn: 317359

6 years ago[llvm-ar] Support an options string that start with a dash
Martin Storsjo [Fri, 3 Nov 2017 20:09:10 +0000 (20:09 +0000)]
[llvm-ar] Support an options string that start with a dash

Some projects call $AR like "$AR -crs output input1 input2".

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

llvm-svn: 317358

6 years agoCorrecting some CRLFs that snuck in with my previous commit; NFC.
Aaron Ballman [Fri, 3 Nov 2017 20:05:51 +0000 (20:05 +0000)]
Correcting some CRLFs that snuck in with my previous commit; NFC.

llvm-svn: 317357

6 years agoAdd llvm::for_each as a range-based extensions to <algorithm> and make use of it...
Aaron Ballman [Fri, 3 Nov 2017 20:01:25 +0000 (20:01 +0000)]
Add llvm::for_each as a range-based extensions to <algorithm> and make use of it in some cases where it is a more clear alternative to std::for_each.

llvm-svn: 317356

6 years ago[cfi-verify] Add an interesting unit test where undef search length changes result.
Mitch Phillips [Fri, 3 Nov 2017 20:00:05 +0000 (20:00 +0000)]
[cfi-verify] Add an interesting unit test where undef search length changes result.

Add an interesting unit test, found by changing --search-length-undef from the default. Program handles it correctly but good for ensuring correctness on further changes :)

Reviewers: pcc

Subscribers: mgorny, llvm-commits, kcc, vlad.tsyrklevich

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

llvm-svn: 317355

6 years ago[X86] Promote athlon, athlon-xp, k8, and k8-sse3 to types instead of subtypes in...
Craig Topper [Fri, 3 Nov 2017 19:37:41 +0000 (19:37 +0000)]
[X86] Promote athlon, athlon-xp, k8, and k8-sse3 to types instead of subtypes in getHostCPUName. NFCI

This removes the athlon type and simplifies the string decoding. We only really need these type/subtype breaks where we need to match libgcc/compiler-rt and these CPUs aren't part of that.

I'm looking into moving some of this information to a .def file to share with clang's __builtin_cpu_is handling. And while these CPUs aren't part of that the less lines I have to deal with in the .def file the better.

llvm-svn: 317354

6 years agoRevert "Add CallSiteSplitting pass"
Jun Bum Lim [Fri, 3 Nov 2017 19:17:11 +0000 (19:17 +0000)]
Revert "Add CallSiteSplitting pass"

Revert due to Buildbot failure.

This reverts commit r317351.

llvm-svn: 317353

6 years agoReland "Add support for writing 64-bit symbol tables for archives when offsets become...
Jake Ehrlich [Fri, 3 Nov 2017 19:15:06 +0000 (19:15 +0000)]
Reland "Add support for writing 64-bit symbol tables for archives when offsets become too large for 32-bit"

Tests were failing because some bots were running out of address
space and memory. Additionally the test was very slow. These issues
were solved by changing the test to take advantage of sparse filse and
restricting the test to run only on 64-bit systems.

This should fix https://bugs.llvm.org//show_bug.cgi?id=34189

This change makes it so that if writing a K_GNU style archive, you need
to output a > 32-bit offset it should output in K_GNU64 style instead.

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

llvm-svn: 317352

6 years agoAdd CallSiteSplitting pass
Jun Bum Lim [Fri, 3 Nov 2017 19:01:57 +0000 (19:01 +0000)]
Add CallSiteSplitting pass

Summary:
This change add a pass which tries to split a call-site to pass
more constrained arguments if its argument is predicated in the control flow
so that we can expose better context to the later passes (e.g, inliner, jump
threading, or IPA-CP based function cloning, etc.).
As of now we support two cases :

1) If a call site is dominated by an OR condition and if any of its arguments
are predicated on this OR condition, try to split the condition with more
constrained arguments. For example, in the code below, we try to split the
call site since we can predicate the argument (ptr) based on the OR condition.

Split from :
      if (!ptr || c)
        callee(ptr);
to :
      if (!ptr)
        callee(null ptr)  // set the known constant value
      else if (c)
        callee(nonnull ptr)  // set non-null attribute in the argument

2) We can also split a call-site based on constant incoming values of a PHI
For example,
from :
      BB0:
       %c = icmp eq i32 %i1, %i2
       br i1 %c, label %BB2, label %BB1
      BB1:
       br label %BB2
      BB2:
       %p = phi i32 [ 0, %BB0 ], [ 1, %BB1 ]
       call void @bar(i32 %p)
to
      BB0:
       %c = icmp eq i32 %i1, %i2
       br i1 %c, label %BB2-split0, label %BB1
      BB1:
       br label %BB2-split1
      BB2-split0:
       call void @bar(i32 0)
       br label %BB2
      BB2-split1:
       call void @bar(i32 1)
       br label %BB2
      BB2:
       %p = phi i32 [ 0, %BB2-split0 ], [ 1, %BB2-split1 ]

Reviewers: davidxl, huntergr, chandlerc, mcrosier, eraman, davide

Reviewed By: davidxl

Subscribers: sdesmalen, ashutosh.nema, fhahn, mssimpso, aemerson, mgorny, mehdi_amini, kristof.beyls, llvm-commits

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

llvm-svn: 317351

6 years ago[llvm-objcopy] Add support for dwarf fission
Jake Ehrlich [Fri, 3 Nov 2017 18:58:41 +0000 (18:58 +0000)]
[llvm-objcopy] Add support for dwarf fission

This change adds support for dwarf fission.

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

llvm-svn: 317350

6 years ago[AArch64] Fix the number of iterations for the Newton series
Evandro Menezes [Fri, 3 Nov 2017 18:56:36 +0000 (18:56 +0000)]
[AArch64] Fix the number of iterations for the Newton series

The number of iterations was incorrectly determined for DP FP vector types
and the tests were insufficient to flag this issue.

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

llvm-svn: 317349

6 years agoThe patch fixes PR35131
Evgeny Stupachenko [Fri, 3 Nov 2017 18:50:03 +0000 (18:50 +0000)]
The patch fixes PR35131

Summary:

Fix a misprint which led to false CTLZ recognition.

Reviewers: craig.topper

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

From: Evgeny Stupachenko <evstupac@gmail.com>
llvm-svn: 317348

6 years agoRevert "Rename fields of ompt_frame_t"
Jonas Hahnfeld [Fri, 3 Nov 2017 18:28:25 +0000 (18:28 +0000)]
Revert "Rename fields of ompt_frame_t"

This reverts commit r317338 which discarded some recent commits.

llvm-svn: 317347

6 years agoRevert "Updating implementation of OMPT as specified in OpenMP 5.0 Preview 2 (TR6)"
Jonas Hahnfeld [Fri, 3 Nov 2017 18:28:19 +0000 (18:28 +0000)]
Revert "Updating implementation of OMPT as specified in OpenMP 5.0 Preview 2 (TR6)"

This reverts commit r317339 which discarded some recent commits.

llvm-svn: 317346

6 years agoRevert "Invoke salvageDebugInfo from CodeGenPrepare's SinkCast()"
Adrian Prantl [Fri, 3 Nov 2017 18:26:36 +0000 (18:26 +0000)]
Revert "Invoke salvageDebugInfo from CodeGenPrepare's SinkCast()"

This reverts commit 317342 while investigating bot breakage.

llvm-svn: 317345

6 years agoMove Extract.cpp that wasn't moved in r317343
Alex Lorenz [Fri, 3 Nov 2017 18:21:06 +0000 (18:21 +0000)]
Move Extract.cpp that wasn't moved in r317343

llvm-svn: 317344

6 years ago[refactor][extract] insert semicolons into extracted/inserted code
Alex Lorenz [Fri, 3 Nov 2017 18:11:22 +0000 (18:11 +0000)]
[refactor][extract] insert semicolons into extracted/inserted code
when needed

This commit implements the semicolon insertion logic into the extract
refactoring. The following rules are used:

- extracting expression: add terminating ';' to the extracted function.
- extracting statements that don't require terminating ';' (e.g. switch): add
  terminating ';' to the callee.
- extracting statements with ';':  move (if possible) the original ';' from the
  callee and add terminating ';'.
- otherwise, add ';' to both places.

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

llvm-svn: 317343

6 years ago[CodeGen] Remove unnecessary semicolons to fix a warning. NFC
Craig Topper [Fri, 3 Nov 2017 18:02:46 +0000 (18:02 +0000)]
[CodeGen] Remove unnecessary semicolons to fix a warning. NFC

llvm-svn: 317342

6 years ago[X86] Initialize Type and Subtype in getHostCPUName to 0.
Craig Topper [Fri, 3 Nov 2017 18:02:44 +0000 (18:02 +0000)]
[X86] Initialize Type and Subtype in getHostCPUName to 0.

llvm-svn: 317341

6 years agoInvoke salvageDebugInfo from CodeGenPrepare's SinkCast()
Adrian Prantl [Fri, 3 Nov 2017 18:00:02 +0000 (18:00 +0000)]
Invoke salvageDebugInfo from CodeGenPrepare's SinkCast()

This preserves the debug info for the cast operation in the original location.

rdar://problem/33460652

llvm-svn: 317340

6 years agoUpdating implementation of OMPT as specified in OpenMP 5.0 Preview 2 (TR6)
Joachim Protze [Fri, 3 Nov 2017 17:09:00 +0000 (17:09 +0000)]
Updating implementation of OMPT as specified in OpenMP 5.0 Preview 2 (TR6)

The TR6 document is expected to be publically released around November 15.
This patch does not implement OMPT for libomptarget.

Patch by Simon Convent and Joachim Protze

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

llvm-svn: 317339

6 years agoRename fields of ompt_frame_t
Joachim Protze [Fri, 3 Nov 2017 17:08:40 +0000 (17:08 +0000)]
Rename fields of ompt_frame_t

This is part of the renaming of data types from OpenMP TR4 to TR6

Patch by Simon Convent

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

llvm-svn: 317338

6 years ago[Driver] Add Scudo as a possible -fsanitize= option
Kostya Kortchinsky [Fri, 3 Nov 2017 17:04:13 +0000 (17:04 +0000)]
[Driver] Add Scudo as a possible -fsanitize= option

Summary:
This change adds Scudo as a possible Sanitizer option via -fsanitize=.
This allows for easier static & shared linking of the Scudo library, it allows
us to enforce PIE (otherwise the security of the allocator is moot), and check
for incompatible Sanitizers combo.

In its current form, Scudo is not compatible with any other Sanitizer, but the
plan is to make it work in conjunction with UBsan (-fsanitize=scudo,undefined),
which will require additional work outside of the scope of this change.

Reviewers: eugenis, kcc, alekseyshl

Reviewed By: eugenis, alekseyshl

Subscribers: llvm-commits, srhines

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

llvm-svn: 317337

6 years ago[CodeGen] add libcall attr tests to show errno-related diffs; NFC
Sanjay Patel [Fri, 3 Nov 2017 16:27:27 +0000 (16:27 +0000)]
[CodeGen] add libcall attr tests to show errno-related diffs; NFC

See rL317220 for the builtin siblings.

llvm-svn: 317336

6 years ago[LICM] sink through non-trivially replicable PHI
Jun Bum Lim [Fri, 3 Nov 2017 16:24:53 +0000 (16:24 +0000)]
[LICM] sink through non-trivially replicable PHI

Summary:
The current LICM allows sinking an instruction only when it is exposed to exit
blocks through a trivially replacable PHI of which all incoming values are the
same instruction. This change enhance LICM to sink a sinkable instruction
through non-trivially replacable PHIs by spliting predecessors of loop
exits.

Reviewers: hfinkel, majnemer, davidxl, bmakam, mcrosier, danielcdh, efriedma, jtony

Reviewed By: efriedma

Subscribers: nemanjai, dberlin, llvm-commits

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

llvm-svn: 317335

6 years ago[SLP] Test for PR23510, NFC.
Alexey Bataev [Fri, 3 Nov 2017 16:17:13 +0000 (16:17 +0000)]
[SLP] Test for PR23510, NFC.

llvm-svn: 317334

6 years agoUse ToolExecutor framework in the sample tool-template.
Eric Liu [Fri, 3 Nov 2017 16:03:56 +0000 (16:03 +0000)]
Use ToolExecutor framework in the sample tool-template.

llvm-svn: 317333

6 years ago[Tooling] Fix linking of StandaloneToolExecutorPlugin.
Eric Liu [Fri, 3 Nov 2017 15:57:27 +0000 (15:57 +0000)]
[Tooling] Fix linking of StandaloneToolExecutorPlugin.

llvm-svn: 317332

6 years ago[mips] Match 'ins' and its' variants with C++ code
Simon Dardis [Fri, 3 Nov 2017 15:35:13 +0000 (15:35 +0000)]
[mips] Match 'ins' and its' variants with C++ code

Change the ISel matching of 'ins', 'dins[mu]' from tablegen code to
C++ code. This resolves an issue where ISel would select 'dins' instead
of 'dinsm' when the instructions size and position were individually in
range but their sum was out of range according to the ISA specification.

Reviewers: atanasyan

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

llvm-svn: 317331

6 years agoFix for Bug 34475 - LOCK/REP/REPNE prefixes emitted as instruction on their own.
Andrew V. Tischenko [Fri, 3 Nov 2017 15:25:13 +0000 (15:25 +0000)]
Fix for Bug 34475 - LOCK/REP/REPNE prefixes emitted as instruction on their own.
Differential Revision: https://reviews.llvm.org/D39546

llvm-svn: 317330

6 years agoAdd float/vector registers for ppc64le
Pavel Labath [Fri, 3 Nov 2017 15:22:36 +0000 (15:22 +0000)]
Add float/vector registers for ppc64le

Summary: Add read and write functions for VSX, VMX and float registers and fix watchpoint size

Reviewers: clayborg

Reviewed By: clayborg

Subscribers: eugene, labath, clayborg, nemanjai, kbarton, JDevlieghere, anajuliapc, gut, lbianc, lldb-commits

Differential Revision: https://reviews.llvm.org/D39487
Patch by: Alexandre Yukio Yamashita <alexandre.yamashita@eldorado.org.br>

llvm-svn: 317329

6 years ago[Tooling] Put createExecutorFromCommandLineArgs implementation in a wrapper. NFC
Eric Liu [Fri, 3 Nov 2017 15:20:57 +0000 (15:20 +0000)]
[Tooling] Put createExecutorFromCommandLineArgs implementation in a wrapper. NFC

llvm-svn: 317328

6 years agoAdd type to FileSpec::PathSyntax enum.
Don Hinton [Fri, 3 Nov 2017 14:59:36 +0000 (14:59 +0000)]
Add type to FileSpec::PathSyntax enum.

Summary:
Add type to FileSpec::PathSyntax enum to decrease size for
FileSpec on systems with 32 bit pointers.

Thanks to @zturner for pointing this out.

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

llvm-svn: 317327

6 years agoXfail test_stack_info_in_minidump test
Pavel Labath [Fri, 3 Nov 2017 14:42:37 +0000 (14:42 +0000)]
Xfail test_stack_info_in_minidump test

The test has been failing since we enabled the i386 ABI plugin on
windows. See pr35193 for details.

llvm-svn: 317326

6 years ago[clang-format] Sort using-declarations case sensitively with a special case for '_'
Krasimir Georgiev [Fri, 3 Nov 2017 14:38:07 +0000 (14:38 +0000)]
[clang-format] Sort using-declarations case sensitively with a special case for '_'

Summary:
This makes clang-format sort using declarations case-sensitive with the
exception that '_' comes just before 'A'. This is better than the current case
insensitive version, because it groups uppercase names in the same namespace
together.

Reviewers: bkramer

Reviewed By: bkramer

Subscribers: cfe-commits, klimek

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

llvm-svn: 317325

6 years ago[LoopPredication] NFC: Refactored code to separate out functions being reused
Anna Thomas [Fri, 3 Nov 2017 14:25:39 +0000 (14:25 +0000)]
[LoopPredication] NFC: Refactored code to separate out functions being reused

Summary:
Refactored the code to separate out common functions that are being
reused.
This is to reduce the changes for changes coming up wrt loop
predication with reverse loops.

This refactoring is what we have in our downstream code.

llvm-svn: 317324

6 years ago[ADCE] Use MapVector for BlockInfo to make iteration order deterministic
Mikael Holmen [Fri, 3 Nov 2017 14:15:08 +0000 (14:15 +0000)]
[ADCE] Use MapVector for BlockInfo to make iteration order deterministic

Summary:
Also added a reserve() method to MapVector since we want to use that from
ADCE.

DenseMap does not provide deterministic iteration order so with that
we will handle the members of BlockInfo in random order, eventually
leading to random order of the blocks in the predecessor lists.

Without this change, I get the same predecessor order in about 90% of the
time when I compile a certain reproducer and in 10% I get a different one.

No idea how to make a proper test case for this.

Reviewers: kuhar, david2050

Reviewed By: kuhar

Subscribers: llvm-commits

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

llvm-svn: 317323

6 years ago[clangd] Handle clangd.applyFix server-side
Marc-Andre Laperle [Fri, 3 Nov 2017 13:39:15 +0000 (13:39 +0000)]
[clangd] Handle clangd.applyFix server-side

Summary:
When the user selects a fix-it (or any code action with commands), it is
possible to let the client forward the selected command to the server.
When the clangd.applyFix command is handled on the server, it can send a
workspace/applyEdit request to the client. This has the advantage that
the client doesn't explicitly have to know how to handle
clangd.applyFix. Therefore, the code to handle clangd.applyFix in the VS
Code extension (and any other Clangd client) is not required anymore.

Reviewers: ilya-biryukov, sammccall, Nebiroth, hokein

Reviewed By: hokein

Subscribers: ioeric, hokein, rwols, puremourning, bkramer, ilya-biryukov

Tags: #clang-tools-extra

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

llvm-svn: 317322

6 years ago[ELF] - Remove excessive field initialization. NFC.
George Rimar [Fri, 3 Nov 2017 13:19:41 +0000 (13:19 +0000)]
[ELF] - Remove excessive field initialization. NFC.

It is already initialized in header file to same value.

llvm-svn: 317320

6 years agoFix classifications on two concurrent event tests
Pavel Labath [Fri, 3 Nov 2017 12:13:22 +0000 (12:13 +0000)]
Fix classifications on two concurrent event tests

I have classified one as a watchpoint test even though it wasn't and
vice versa. Fix that.

llvm-svn: 317319

6 years agore-land [ExpandMemCmp] Split ExpandMemCmp from CodeGen into its own pass."
Clement Courbet [Fri, 3 Nov 2017 12:12:27 +0000 (12:12 +0000)]
re-land [ExpandMemCmp] Split ExpandMemCmp from CodeGen into its own pass."

Fix undefined references: ExpandMemCmp belongs to CodeGen/, not Scalar/.

llvm-svn: 317318

6 years ago[ELf] - Fix compilation after r317307.
George Rimar [Fri, 3 Nov 2017 11:57:01 +0000 (11:57 +0000)]
[ELf] - Fix compilation after r317307.

Not sure why that seems did not break any llvm bots or
my windows local build, but is was required to fix compilation
breakage of my ubuntu build when using
gcc version 8.0.0 20171019 (experimental)

llvm-svn: 317317

6 years ago[ELF] - Removed unused variable. NFC.
George Rimar [Fri, 3 Nov 2017 11:51:58 +0000 (11:51 +0000)]
[ELF] - Removed unused variable. NFC.

llvm-svn: 317316

6 years ago[X86][SSE] Add PACKUS support to combineVectorTruncation
Simon Pilgrim [Fri, 3 Nov 2017 11:33:48 +0000 (11:33 +0000)]
[X86][SSE] Add PACKUS support to combineVectorTruncation

Similar to the existing code to lower to PACKSS, we can use PACKUS if the input vector's leading zero bits extend all the way to the packed/truncated value.

We have to account for pre-SSE41 targets not supporting PACKUSDW

llvm-svn: 317315

6 years ago[PartialInliner] Skip call sites where inlining fails.
Florian Hahn [Fri, 3 Nov 2017 11:29:00 +0000 (11:29 +0000)]
[PartialInliner] Skip call sites where inlining fails.

Summary:
InlineFunction can fail, for example when trying to inline vararg
fuctions. In those cases, we do not want to bump partial inlining
counters or set AnyInlined to true, because this could leave an unused
function hanging around.

Reviewers: davidxl, davide, gyiu

Reviewed By: davide

Subscribers: llvm-commits, eraman

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

llvm-svn: 317314

6 years ago[globalisel][tablegen] Skip src child predicates
Diana Picus [Fri, 3 Nov 2017 10:30:19 +0000 (10:30 +0000)]
[globalisel][tablegen] Skip src child predicates

The GlobalISel TableGen backend didn't check for predicates on the
source children. This caused it to generate code for ARM patterns such
as SMLABB or similar, but without properly checking for the sext_16_node
part of the operands. This in turn meant that we would select SMLABB
instead of MLA for simple sequences such as s32 + s32 * s32, which is
wrong (we want a MLA on the full operands, not just their bottom 16
bits).

This patch forces TableGen to skip patterns with predicates on the src
children, so it doesn't generate code for SMLABB and other similar ARM
instructions at all anymore. AArch64 and X86 are not affected.

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

llvm-svn: 317313