platform/upstream/llvm.git
6 years ago[ThinLTO] Implement summary visualizer
Eugene Leviant [Sun, 21 Jan 2018 07:27:32 +0000 (07:27 +0000)]
[ThinLTO] Implement summary visualizer

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

llvm-svn: 323062

6 years ago[sanitizer] Pass the CMake compiler to custom libc++ build
Petr Hosek [Sun, 21 Jan 2018 03:22:22 +0000 (03:22 +0000)]
[sanitizer] Pass the CMake compiler to custom libc++ build

This addresses the error introduced in r323054 on some bots.

llvm-svn: 323061

6 years ago[ORC] Add a lookupFlags method to VSO.
Lang Hames [Sun, 21 Jan 2018 03:20:39 +0000 (03:20 +0000)]
[ORC] Add a lookupFlags method to VSO.

lookupFlags returns a SymbolFlagsMap for the requested symbols, along with a
set containing the SymbolStringPtr for any symbol not found in the VSO.

The JITSymbolFlags for each symbol will have been stripped of its transient
JIT-state flags (i.e. NotMaterialized, Materializing).

Calling lookupFlags does not trigger symbol materialization.

llvm-svn: 323060

6 years ago[ORC] More cleanup. NFC.
Lang Hames [Sun, 21 Jan 2018 03:20:36 +0000 (03:20 +0000)]
[ORC] More cleanup. NFC.

llvm-svn: 323059

6 years ago[Dominators] Remove misleading double-deletion test
Jakub Kuderski [Sun, 21 Jan 2018 03:07:16 +0000 (03:07 +0000)]
[Dominators] Remove misleading double-deletion test

Summary:
It's generally not safe to perform multiple DomTree updates without using the incremental API.

Although it is supposed to work in this particular case, the testcase is misleading/confusing, and it's better to remove it.

Reviewers: dberlin, brzycki, davide, grosser

Reviewed By: davide

Subscribers: llvm-commits

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

llvm-svn: 323058

6 years ago[ORC] Cleanup. NFC.
Lang Hames [Sun, 21 Jan 2018 02:24:45 +0000 (02:24 +0000)]
[ORC] Cleanup. NFC.

llvm-svn: 323057

6 years ago[DSE] Factor out common code [NFC]
Philip Reames [Sun, 21 Jan 2018 02:10:54 +0000 (02:10 +0000)]
[DSE] Factor out common code [NFC]

We already had the pointer being stored to in the MemLoc, reuse that code.  In merging cases, it turned out the interface of the getLocForWrite had become inconsitent with other related utilities.  Fix that by making sure the input passes hasAnalyzableWrite as well.

llvm-svn: 323056

6 years ago[DSE] Minor rename for clarity sake [NFC]
Philip Reames [Sun, 21 Jan 2018 01:44:33 +0000 (01:44 +0000)]
[DSE] Minor rename for clarity sake [NFC]

llvm-svn: 323055

6 years agoReland "[Fuzzer] Parametrize add_custom_libcxx"
Petr Hosek [Sun, 21 Jan 2018 01:01:53 +0000 (01:01 +0000)]
Reland "[Fuzzer] Parametrize add_custom_libcxx"

add_custom_libcxx uses the just built compiler and installs the
built libc++, e.g. for testing, neither of which is desirable in
case of Fuzzer where the libc++ should be built using the host
compiler and it's only linked into the libFuzzer and should never
be installed. This change introduces additional arguments to
add_custom_libcxx to allow parametrizing its behavior.

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

llvm-svn: 323054

6 years ago[cmake] Don't build Native llvm-config when cross compiling if passed by user.
Don Hinton [Sun, 21 Jan 2018 00:29:00 +0000 (00:29 +0000)]
[cmake] Don't build Native llvm-config when cross compiling if passed by user.

Summary:
Rename LLVM_CONFIG_EXE to LLVM_CONFIG_PATH, and avoid building it if
passed in by user.  This is the same way CLANG_TABLEGEN and
LLVM_TABLEGEN are handled, e.g., when -DLLVM_OPTIMIZED_TABLEGEN=ON is
passed.

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

llvm-svn: 323053

6 years ago[analyzer] Provide a check name when MallocChecker enables CStringChecker
Devin Coughlin [Sat, 20 Jan 2018 23:11:17 +0000 (23:11 +0000)]
[analyzer] Provide a check name when MallocChecker enables CStringChecker

Fix an assertion failure caused by a missing CheckName. The malloc checker
enables "basic" support in the CStringChecker, which causes some CString
bounds checks to be enabled. In this case, make sure that we have a
valid CheckName for the BugType.

llvm-svn: 323052

6 years ago[cmake] Use CLANG_BINARY_DIR to determine the build directory.
Vassil Vassilev [Sat, 20 Jan 2018 21:43:35 +0000 (21:43 +0000)]
[cmake] Use CLANG_BINARY_DIR to determine the build directory.

The patch puts the ClangConfig.cmake in the expected location  when clang is
embedded into a framework.

llvm-svn: 323051

6 years agoMore P0202 constexpr work. This commit adds fill/fill_n/generate/generate_n/unique...
Marshall Clow [Sat, 20 Jan 2018 20:14:32 +0000 (20:14 +0000)]
More P0202 constexpr work. This commit adds fill/fill_n/generate/generate_n/unique/unique_copy. I removed a specialization of fill_n that recognized when we were dealing with raw pointers and 1 byte trivially-assignable types and did a memset, because the compiler will do that optimization for us.

llvm-svn: 323050

6 years ago[ValueLattice] Use union to shave off ptr size bytes from elements.
Florian Hahn [Sat, 20 Jan 2018 19:52:16 +0000 (19:52 +0000)]
[ValueLattice] Use union to shave off ptr size bytes from elements.

By using a union for Constant* and ConstantRange we can shave off ptr
size bytes off lattice elements. On 64 bit systems, it brings down the
size to 40 bytes from 48 bytes.

Initialization of Range happens on-demand using placement new, if the
state changes to constantrange from non-constantrange. Similarly, the
Range object is destroyed if the state changes from constantrange to
non-constantrange.

Reviewers: reames, anna, davide

Reviewed By: reames, davide

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

llvm-svn: 323049

6 years ago[X86] Add an override of targetShrinkDemandedConstant to limit the damage that shrink...
Craig Topper [Sat, 20 Jan 2018 18:50:09 +0000 (18:50 +0000)]
[X86] Add an override of targetShrinkDemandedConstant to limit the damage that shrinkdemandedbits can do to zext_in_reg operations

Summary:
This patch adds an implementation of targetShrinkDemandedConstant that tries to keep shrinkdemandedbits from removing bits that would otherwise have been recognized as a movzx.

We still need a follow patch to stop moving ands across srl if the and could be represented as a movzx before the shift but not after. I think this should help with some of the cases that D42088 ended up removing during isel.

Reviewers: spatel, RKSimon

Reviewed By: spatel

Subscribers: llvm-commits

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

llvm-svn: 323048

6 years ago[X86] Add rdpid command line option and intrinsics.
Craig Topper [Sat, 20 Jan 2018 18:36:52 +0000 (18:36 +0000)]
[X86] Add rdpid command line option and intrinsics.

Summary: This patch adds -mrdpid/-mno-rdpid and the rdpid intrinsic. The corresponding LLVM commit has already been made.

Reviewers: RKSimon, spatel, zvi, AndreiGrischenko

Reviewed By: RKSimon

Subscribers: cfe-commits

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

llvm-svn: 323047

6 years ago[X86] Put the code that defines __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 for the preproces...
Craig Topper [Sat, 20 Jan 2018 18:36:06 +0000 (18:36 +0000)]
[X86] Put the code that defines __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 for the preprocessor with the other __GCC_HAVE_SYNC_COMPARE_AND_SWAP_* defines. NFC

llvm-svn: 323046

6 years ago[X86][SSE] Check for out of bounds PEXTR/PINSR indices during faux shuffle combining.
Simon Pilgrim [Sat, 20 Jan 2018 17:16:01 +0000 (17:16 +0000)]
[X86][SSE] Check for out of bounds PEXTR/PINSR indices during faux shuffle combining.

llvm-svn: 323045

6 years agoMove new test from Generic to SystemZ.
Jonas Paulsson [Sat, 20 Jan 2018 16:57:06 +0000 (16:57 +0000)]
Move new test from Generic to SystemZ.

A few build bots failed with r323042 because they are not configured to
build the SystemZ target.

llvm-svn: 323044

6 years ago[InstCombine] add baseline tests for (X << Y) / X -> 1 << Y; NFC
Sanjay Patel [Sat, 20 Jan 2018 16:13:40 +0000 (16:13 +0000)]
[InstCombine] add baseline tests for (X << Y) / X -> 1 << Y; NFC

This fold is proposed in D42032.

llvm-svn: 323043

6 years ago[SelectionDAG] Fix codegen of vector stores with non byte-sized elements.
Jonas Paulsson [Sat, 20 Jan 2018 16:05:10 +0000 (16:05 +0000)]
[SelectionDAG] Fix codegen of vector stores with non byte-sized elements.

This was completely broken, but hopefully fixed by this patch.

In cases where it is needed, a vector with non byte-sized elements is stored
by extracting, zero-extending, shift:ing and or:ing the elements into an
integer of the same width as the vector, which is then stored.

Review: Eli Friedman, Ulrich Weigand
https://reviews.llvm.org/D42100#inline-369520
https://bugs.llvm.org/show_bug.cgi?id=35520

llvm-svn: 323042

6 years agoAssume the shared library path variable is LD_LIBRARY_PATH on systems
Dimitry Andric [Sat, 20 Jan 2018 14:35:05 +0000 (14:35 +0000)]
Assume the shared library path variable is LD_LIBRARY_PATH on systems
except Darwin and Windows.  This prevents inserting an environment
variable with an empty name (which is illegal and leads to a Python
exception) on any of the BSDs.

llvm-svn: 323041

6 years agoAssume the shared library path variable is LD_LIBRARY_PATH on systems
Dimitry Andric [Sat, 20 Jan 2018 14:34:33 +0000 (14:34 +0000)]
Assume the shared library path variable is LD_LIBRARY_PATH on systems
except Darwin and Windows.  This prevents inserting an environment
variable with an empty name (which is illegal and leads to a Python
exception) on any of the BSDs.

llvm-svn: 323040

6 years ago[compiler-rt] Implement __clear_cache() on OpenBSD/mips64
Kamil Rytarowski [Sat, 20 Jan 2018 14:16:16 +0000 (14:16 +0000)]
[compiler-rt] Implement __clear_cache() on OpenBSD/mips64

Summary:
Make __clear_cache() invoke the platform's cache flush function
on OpenBSD/mips64.

Reviewers: krytarowski

Reviewed By: krytarowski

Subscribers: sdardis, dberris, arichardson, krytarowski, llvm-commits, #sanitizers

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

llvm-svn: 323039

6 years ago[COFF] Keep the underscore on exported decorated stdcall functions in MSVC mode
Martin Storsjo [Sat, 20 Jan 2018 11:44:42 +0000 (11:44 +0000)]
[COFF] Keep the underscore on exported decorated stdcall functions in MSVC mode

This fixes PR35733.

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

llvm-svn: 323036

6 years ago[COFF] Keep the underscore on exported decorated stdcall functions in MSVC mode
Martin Storsjo [Sat, 20 Jan 2018 11:44:32 +0000 (11:44 +0000)]
[COFF] Keep the underscore on exported decorated stdcall functions in MSVC mode

This (together with the corresponding LLD commit, that contains the
testcase updates) fixes PR35733.

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

llvm-svn: 323035

6 years ago[Dominators] Fix some edge cases for PostDomTree updating
David Green [Sat, 20 Jan 2018 10:29:37 +0000 (10:29 +0000)]
[Dominators] Fix some edge cases for PostDomTree updating

These fix some odd cfg cases where batch-updating the post
dom tree fails. Usually around infinite loops and roots
ending up being different.

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

llvm-svn: 323034

6 years agoRevert "[Fuzzer] Parametrize add_custom_libcxx"
Petr Hosek [Sat, 20 Jan 2018 09:21:00 +0000 (09:21 +0000)]
Revert "[Fuzzer] Parametrize add_custom_libcxx"

This reverts commit r323032: failing on the sanitizer-x86_64-linux-autoconf bot.

llvm-svn: 323033

6 years ago[Fuzzer] Parametrize add_custom_libcxx
Petr Hosek [Sat, 20 Jan 2018 09:03:16 +0000 (09:03 +0000)]
[Fuzzer] Parametrize add_custom_libcxx

add_custom_libcxx uses the just built compiler and installs the
built libc++, e.g. for testing, neither of which is desirable in
case of Fuzzer where the libc++ should be built using the host
compiler and it's only linked into the libFuzzer and should never
be installed. This change introduces additional arguments to
add_custom_libcxx to allow parametrizing its behavior.

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

llvm-svn: 323032

6 years ago[X86] Add some more v32i1 shuffle tests with shuffles between mask creation and mask...
Craig Topper [Sat, 20 Jan 2018 08:13:35 +0000 (08:13 +0000)]
[X86] Add some more v32i1 shuffle tests with shuffles between mask creation and mask usage rather than being just shuffling input arguments.

The existing tests just tested shuffles of v32i1 inputs, but arguments are promoted to v32i8. So it wasn't a good demonstration of v32i1 shuffle handling.

The new test cases use compares and selects to get k-register operations around the shuffle.

This is prep work for demonstrating changes from D42031.

llvm-svn: 323031

6 years ago[X86] Add test cases for failures to use movzx due to various issues with demanded...
Craig Topper [Sat, 20 Jan 2018 07:50:57 +0000 (07:50 +0000)]
[X86] Add test cases for failures to use movzx due to various issues with demanded bits.

D42265 and D42313 should help with some of these.

llvm-svn: 323030

6 years agoReland "Fix syntax error introduced in r322991"
Petr Hosek [Sat, 20 Jan 2018 03:37:47 +0000 (03:37 +0000)]
Reland "Fix syntax error introduced in r322991"

This triggers compiler error when building sanitizers for Fuchsia.

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

llvm-svn: 323029

6 years agoRevert "[sanitizer] Fix syntax error introduced in r322991"
Petr Hosek [Sat, 20 Jan 2018 03:23:45 +0000 (03:23 +0000)]
Revert "[sanitizer] Fix syntax error introduced in r322991"

This reverts commit r323027: it breaks the SanitizerLintCheck.

llvm-svn: 323028

6 years ago[sanitizer] Fix syntax error introduced in r322991
Petr Hosek [Sat, 20 Jan 2018 02:34:33 +0000 (02:34 +0000)]
[sanitizer] Fix syntax error introduced in r322991

This triggers compiler error when building sanitizers for Fuchsia.

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

llvm-svn: 323027

6 years agoForce lit to execute the ASan and TSan tests on iOS devices
Dan Liew [Sat, 20 Jan 2018 02:07:30 +0000 (02:07 +0000)]
Force lit to execute the ASan and TSan tests on iOS devices
sequentially.

The current implementation of commands in
`test/sanitizer_common/ios_commands/` for iOS devices cannot be executed
in parallel which results in the ASan and TSan tests failing when
executed in parallel by lit which was the default behaviour.

We now force the ASan and TSan tests to be a new parallelism group named
`darwin-ios-device-sanitizer` which allows only one test to be run at a
time.  We also emit a warning informing the user that tests are being
run sequentially.

This only applies if the target is an iOS device.

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

llvm-svn: 323026

6 years ago[WebAssembly] Remove special handling of entry point export.
Sam Clegg [Sat, 20 Jan 2018 01:44:45 +0000 (01:44 +0000)]
[WebAssembly] Remove special handling of entry point export.

Its much easier to export it via setHidden(false), now that
that is a thing.

As a side effect the start function is not longer always exports first
(becuase its being exported just like all the other function).

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

llvm-svn: 323025

6 years ago[WebAssembly] Remove redundant function: addSyntheticUndefinedFunction. NFC.
Sam Clegg [Sat, 20 Jan 2018 01:40:17 +0000 (01:40 +0000)]
[WebAssembly] Remove redundant function: addSyntheticUndefinedFunction.  NFC.

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

llvm-svn: 323024

6 years agotest: fix ARM tests harder
Saleem Abdulrasool [Sat, 20 Jan 2018 01:26:46 +0000 (01:26 +0000)]
test: fix ARM tests harder

Remove the missed check update for the removal of the x86 specific
vector call on ARM.

llvm-svn: 323023

6 years agoLink sanitized programs on NetBSD with -lkvm
Kamil Rytarowski [Sat, 20 Jan 2018 01:03:45 +0000 (01:03 +0000)]
Link sanitized programs on NetBSD with -lkvm

Summary:
kvm - kernel memory interface

The kvm(3) functions like kvm_open(), kvm_getargv() or kvm_getenvv()
are used in programs that can request information about a kernel and
its processes. The LLVM sanitizers will make use of them on NetBSD.

Sponsored by <The NetBSD Foundation>

Reviewers: joerg, vitalybuka, dvyukov

Reviewed By: vitalybuka

Subscribers: llvm-commits, cfe-commits, #sanitizers

Tags: #sanitizers

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

llvm-svn: 323022

6 years agotest: move ARM test from x86
Saleem Abdulrasool [Sat, 20 Jan 2018 01:03:11 +0000 (01:03 +0000)]
test: move ARM test from x86

The ARM backend is not guaranteed to be present on x86, move the test to
the ARM tests.

llvm-svn: 323021

6 years ago[WebAssembly] Remove custom handling for undefined entry
Sam Clegg [Sat, 20 Jan 2018 00:52:51 +0000 (00:52 +0000)]
[WebAssembly] Remove custom handling for undefined entry

This code was needed back when we were not able to write
out the synthetic symbol for main.

Add tests to make sure we can handle this now.

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

llvm-svn: 323020

6 years agoSupport the localtime interceptor for NetBSD
Kamil Rytarowski [Sat, 20 Jan 2018 00:40:29 +0000 (00:40 +0000)]
Support the localtime interceptor for NetBSD

Summary:
The localtime symbol is mangled to __locatime50
on NetBSD.

Sponsored by <The NetBSD Foundation>

Reviewers: joerg, vitalybuka

Reviewed By: vitalybuka

Subscribers: kubamracek, llvm-commits, #sanitizers

Tags: #sanitizers

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

llvm-svn: 323019

6 years agoIntercept accept4() on NetBSD
Kamil Rytarowski [Sat, 20 Jan 2018 00:37:27 +0000 (00:37 +0000)]
Intercept accept4() on NetBSD

Summary:
The accept4() function first appeared in NetBSD 8.0.

Sponsored by <The NetBSD Foundation>

Reviewers: joerg, vitalybuka

Reviewed By: vitalybuka

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

Tags: #sanitizers

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

llvm-svn: 323018

6 years agoCodeGen: handle llvm.used properly for COFF
Saleem Abdulrasool [Sat, 20 Jan 2018 00:28:02 +0000 (00:28 +0000)]
CodeGen: handle llvm.used properly for COFF

`llvm.used` contains a list of pointers to named values which the
compiler, assembler, and linker are required to treat as if there is a
reference that they cannot see.  Ensure that the symbols are preserved
by adding an explicit `-include` reference to the linker command.

llvm-svn: 323017

6 years ago[X86] Teach X86 codegen to use vector width preference to avoid promoting to 512...
Craig Topper [Sat, 20 Jan 2018 00:26:12 +0000 (00:26 +0000)]
[X86] Teach X86 codegen to use vector width preference to avoid promoting to 512-bit types when VLX is enabled and the preference is for a smaller size.

This change applies to places where we would turn 128/256-bit code into 512-bit in order to get a wider element type through sext/zext. Any 512-bit types that already existed in the IR/DAG will be left that way.

The width preference has no effect on codegen behavior when the target does not have AVX512 enabled. So AVX/AVX2 codegen cannot be limited via this mechanism yet.

If the preference is lower than 256 we may still use a 256 bit type to do the operation. Constraining to 128 bits makes it much more difficult to support some operations. For many of these cases we need to change element width while keeping element count constant which is easiest done by switching between 256 and 128 bit.

The preference is only obeyed when AVX512 and VLX are available. This means the preference is not obeyed for KNL, but is obeyed for SKX, Cannonlake, and Icelake. For KNL, the only way to do masked operation is on 512-bit registers so we would have to completely disable masking to obey the preference. We would also lose support for gather, scatter, ctlz, vXi64 multiplies, etc. This may change in the future, but this simplifies the initial implementation.

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

llvm-svn: 323016

6 years ago[X86] Add support for passing 'prefer-vector-width' function attribute into X86Subtar...
Craig Topper [Sat, 20 Jan 2018 00:26:08 +0000 (00:26 +0000)]
[X86] Add support for passing 'prefer-vector-width' function attribute into X86Subtarget and exposing via X86's getRegisterWidth TTI interface.

This will cause the vectorizers to do some limiting of the vector widths they create. This is not a strict limit. There are reasons I know of that the loop vectorizer will generate larger vectors for.

I've written this in such a way that the interface will only return a properly supported width(0/128/256/512) even if the attribute says something funny like 384 or 10.

This has been split from D41895 with the remainder in a follow up commit.

llvm-svn: 323015

6 years agoAvoid divisions.
Rui Ueyama [Sat, 20 Jan 2018 00:14:16 +0000 (00:14 +0000)]
Avoid divisions.

Compiler doesn't know the fact that Config->WordSize * 8 is always a
power of two, so it had to use the div instruction to divide some
number with C.

llvm-svn: 323014

6 years ago[TSan][MIPS] Expand sanitizer memory space to lower addresses
Petar Jovanovic [Sat, 20 Jan 2018 00:06:07 +0000 (00:06 +0000)]
[TSan][MIPS] Expand sanitizer memory space to lower addresses

MemToShadowImpl() maps lower addresses to a memory space out of sanitizers
range. The simplest example is address 0 which is mapped to 0x2000000000

static const uptr kShadowBeg     = 0x2400000000ull;

but accessing the address during tsan execution will lead to a segmentation
fault.

This patch expands the range used by the sanitizer and ensures that 1/8 of
the maximum valid address in the virtual address spaces is used for shadow
memory.

Patch by Milos Stojanovic.

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

llvm-svn: 323013

6 years ago[WebAssembly] Fix MSVC build
Derek Schuff [Sat, 20 Jan 2018 00:01:18 +0000 (00:01 +0000)]
[WebAssembly] Fix MSVC build

nullptr_t can't be used left of boolean &&

llvm-svn: 323012

6 years ago[clang-tidy] Adding Fuchsia checker for multiple inheritance
Julie Hockett [Fri, 19 Jan 2018 23:59:59 +0000 (23:59 +0000)]
[clang-tidy] Adding Fuchsia checker for multiple inheritance

Adds a check to the Fuchsia module to warn when a class
inherits from multiple classes that are not pure virtual.

See https://fuchsia.googlesource.com/zircon/+/master/docs/cxx.md
for reference.

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

llvm-svn: 323011

6 years agoMake the bloom filter a bit larger.
Rui Ueyama [Fri, 19 Jan 2018 23:54:31 +0000 (23:54 +0000)]
Make the bloom filter a bit larger.

I created https://reviews.llvm.org/D42202 to see how large the bloom
filter should be. With that patch, I tested various bloom filter sizes
with the following commands:

  $ cmake -GNinja -DCMAKE_BUILD_TYPE=Debug -DLLVM_ENABLE_LLD=true \
    -DLLVM_ENABLE_PROJECTS='clang;lld' -DBUILD_SHARED_LIBS=ON \
    -DCMAKE_SHARED_LINKER_FLAGS=-Wl,-bloom-filter-bits=<some integer> \
    ../llvm-project/llvm
  $ rm -f $(find . -name \*.so.7.0.0svn)
  $ ninja lld
  $ LD_BIND_NOW=1 perf stat bin/ld.lld

Here is the result:

  -bloom-filter-bits=8   0.220351609 seconds
  -bloom-filter-bits=10  0.217146597 seconds
  -bloom-filter-bits=12  0.206870826 seconds
  -bloom-filter-bits=16  0.209456312 seconds
  -bloom-filter-bits=32  0.195092075 seconds

Currently we allocate 8 bits for a symbol, but according to the above
result, that number is not optimal. Even though the numbers follow the
diminishing return rule, the point where a marginal improvement becomes
too small is not -bloom-filter-bits=8 but 12. So this patch sets it to 12.

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

llvm-svn: 323010

6 years ago[ObjCARC] Do not turn a call to @objc_autoreleaseReturnValue into a call
Akira Hatanaka [Fri, 19 Jan 2018 23:51:13 +0000 (23:51 +0000)]
[ObjCARC] Do not turn a call to @objc_autoreleaseReturnValue into a call
to @objc_autorelease if its operand is a PHI and the PHI has an
equivalent value that is used by a return instruction.

For example, ARC optimizer shouldn't replace the call in the following
example, as doing so breaks the AutoreleaseRV/RetainRV optimization:

  %v1 = bitcast i32* %v0 to i8*
  br label %bb3
bb2:
  %v3 = bitcast i32* %v2 to i8*
  br label %bb3
bb3:
  %p = phi i8* [ %v1, %bb1 ], [ %v3, %bb2 ]
  %retval = phi i32* [ %v0, %bb1 ], [ %v2, %bb2 ] ; equivalent to %p
  %v4 = tail call i8* @objc_autoreleaseReturnValue(i8* %p)
  ret i32* %retval

Also, make sure ObjCARCContract replaces @objc_autoreleaseReturnValue's
operand uses with its value so that the call gets tail-called.

rdar://problem/15894705

llvm-svn: 323009

6 years ago[Lex] Fix crash on code completion in comment in included file.
Volodymyr Sapsai [Fri, 19 Jan 2018 23:41:47 +0000 (23:41 +0000)]
[Lex] Fix crash on code completion in comment in included file.

This fixes PR32732 by updating CurLexerKind to reflect available lexers.
We were hitting null pointer in Preprocessor::Lex because CurLexerKind
was CLK_Lexer but CurLexer was null. And we set it to null in
Preprocessor::HandleEndOfFile when exiting a file with code completion
point.

To reproduce the crash it is important for a comment to be inside a
class specifier. In this case in Parser::ParseClassSpecifier we improve
error recovery by pushing a semicolon token back into the preprocessor
and later on try to lex a token because we haven't reached the end of
file.

Also clang crashes only on code completion in included file, i.e. when
IncludeMacroStack is not empty. Though we reset CurLexer even if include
stack is empty. The difference is that during pushing back a semicolon
token, preprocessor calls EnterCachingLexMode which decides it is
already in caching mode because various lexers are null and
IncludeMacroStack is not empty. As the result, CurLexerKind remains
CLK_Lexer instead of updating to CLK_CachingLexer.

rdar://problem/34787685

Reviewers: akyrtzi, doug.gregor, arphaman

Reviewed By: arphaman

Subscribers: cfe-commits, kfunk, arphaman, nemanjai, kbarton

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

llvm-svn: 323008

6 years agoWrap all references to build artifacts in the LLDB testsuite (NFC)
Adrian Prantl [Fri, 19 Jan 2018 23:24:35 +0000 (23:24 +0000)]
Wrap all references to build artifacts in the LLDB testsuite (NFC)

in TestBase::getBuildArtifact(). This NFC commit is in preparation for
https://reviews.llvm.org/D42281 (compile the LLDB tests out-of-tree).

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

llvm-svn: 323007

6 years ago[AArch64] Add ARMv8.2-A FP16 scalar intrinsics
Abderrazek Zaafrani [Fri, 19 Jan 2018 23:11:18 +0000 (23:11 +0000)]
[AArch64] Add ARMv8.2-A FP16 scalar intrinsics

https://reviews.llvm.org/D41792

llvm-svn: 323006

6 years ago[AArch64] Add ARMv8.2-A FP16 scalar intrinsics
Abderrazek Zaafrani [Fri, 19 Jan 2018 23:10:56 +0000 (23:10 +0000)]
[AArch64] Add ARMv8.2-A FP16 scalar intrinsics

https://reviews.llvm.org/D41792

llvm-svn: 323005

6 years agoFix -Wunused-variable.
Rui Ueyama [Fri, 19 Jan 2018 22:56:04 +0000 (22:56 +0000)]
Fix -Wunused-variable.

llvm-svn: 323004

6 years ago[x86] add tests for sqrt estimate that should respect denorms; NFC (PR34994)
Sanjay Patel [Fri, 19 Jan 2018 22:47:49 +0000 (22:47 +0000)]
[x86] add tests for sqrt estimate that should respect denorms; NFC (PR34994)

llvm-svn: 323003

6 years ago[sanitizer] Allow Fuchsia to use getauxval
Kostya Kortchinsky [Fri, 19 Jan 2018 22:33:30 +0000 (22:33 +0000)]
[sanitizer] Allow Fuchsia to use getauxval

Summary:
Fuchsia has `getauxval` (https://fuchsia.googlesource.com/zircon/+/master/third_party/ulib/musl/include/sys/auxv.h,
https://fuchsia.googlesource.com/zircon/+/master/third_party/ulib/musl/src/misc/getauxval.c)
so set SANITIZER_USE_GETAUXVAL to 1 for this platform.

Reviewers: alekseyshl, flowerhack

Reviewed By: flowerhack

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

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

llvm-svn: 323002

6 years ago[ORC] Re-apply r322913 with a fix for a read-after-free error.
Lang Hames [Fri, 19 Jan 2018 22:24:13 +0000 (22:24 +0000)]
[ORC] Re-apply r322913 with a fix for a read-after-free error.

ExternalSymbolMap now stores the string key (rather than using a StringRef),
as the object file backing the key may be removed at any time.

llvm-svn: 323001

6 years ago[clangd] Change index scope convention from "outer::inner" to "outer::inner::"
Sam McCall [Fri, 19 Jan 2018 22:18:21 +0000 (22:18 +0000)]
[clangd] Change index scope convention from "outer::inner" to "outer::inner::"

Global scope is "" (was "")
Top-level namespace scope is "ns::" (was "ns")
Nested namespace scope is "ns::ns::" (was "ns::ns")

This composes more naturally:
- qname = scope + name
- full scope = resolved scope + unresolved scope (D42073 was the trigger)
It removes a wart from the old way: "foo::" has one more separator than "".

Another alternative that has these properties is "::ns", but that lacks
the property that both the scope and the name are substrings of the
qname as produced by clang.

This is re-landing r322996 which didn't build.

llvm-svn: 323000

6 years ago[scudo] Pass SANITIZER_COMMON_LINK_FLAGS to the shared library LINK_FLAGS
Kostya Kortchinsky [Fri, 19 Jan 2018 22:17:39 +0000 (22:17 +0000)]
[scudo] Pass SANITIZER_COMMON_LINK_FLAGS to the shared library LINK_FLAGS

Summary:
We somehow never did it, and it raised no issue until now, when trying to
enable Fuchsia as a supported Scudo platform in the cmake config.

So propagate SANITIZER_COMMON_LINK_FLAGS for now.

Reviewers: alekseyshl, flowerhack

Reviewed By: flowerhack

Subscribers: mgorny, #sanitizers, llvm-commits

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

llvm-svn: 322999

6 years agoRevert "[clangd] Change index scope convention from "outer::inner" to "outer::inner::""
Sam McCall [Fri, 19 Jan 2018 22:09:34 +0000 (22:09 +0000)]
Revert "[clangd] Change index scope convention from "outer::inner" to "outer::inner::""

This reverts commit r322996.

llvm-svn: 322998

6 years ago[X86] Autogenerate complete checks on a couple tests. NFC
Craig Topper [Fri, 19 Jan 2018 22:04:20 +0000 (22:04 +0000)]
[X86] Autogenerate complete checks on a couple tests. NFC

llvm-svn: 322997

6 years ago[clangd] Change index scope convention from "outer::inner" to "outer::inner::"
Sam McCall [Fri, 19 Jan 2018 21:58:58 +0000 (21:58 +0000)]
[clangd] Change index scope convention from "outer::inner" to "outer::inner::"

Global scope is "" (was "")
Top-level namespace scope is "ns::" (was "ns")
Nested namespace scope is "ns::ns::" (was "ns::ns")

This composes more naturally:
 - qname = scope + name
 - full scope = resolved scope + unresolved scope (D42073 was the trigger)
It removes a wart from the old way: "foo::" has one more separator than "".

Another alternative that has these properties is "::ns", but that lacks
the property that both the scope and the name are substrings of the
qname as produced by clang.

llvm-svn: 322996

6 years ago[SymbolFilePDB] Fix null array access when parsing the type of a function without...
Aaron Smith [Fri, 19 Jan 2018 21:55:44 +0000 (21:55 +0000)]
[SymbolFilePDB] Fix null array access when parsing the type of a function without any arguments, i.e. 'int main()' and add support to test it

Summary:
- Fix a null array access bug. This happens when creating the lldb type for a function that has no argument.
- Implement SymbolFilePDB::ParseTypes method. Using `lldb-test symbols` will show all supported types in the target.
- Create lldb types for variadic function, PDBSymbolTypePointer, PDBSymbolTypeBuiltin
- The underlying builtin type for PDBSymbolTypeEnum is always `Int`, correct it with the very first enumerator's encoding if any. This is more accurate when the underlying type is not signed or another integer type.
- Fix a bug when the compiler type is not created based on PDB_BuiltinType. For example, basic type `long` is of same width as `int` in a 32-bit target, and the compiler type of former one will be represented by the one generated for latter if using the default method. Introduce a static function GetBuiltinTypeForPDBEncodingAndBitSize to correct this issue.
- Basic type `long double` and `double` have the same bit size in MSVC and there is no information in a PDB to distinguish them. The compiler type of the former one is represented by the latter's.
- There is no line informaton about typedef, enum etc in a PDB and the source and line information for them are not shown.
- There is no information about scoped enumeration. The compiler type is represented as an unscoped one.

Reviewers: zturner, lldb-commits, davide, asmith

Reviewed By: zturner, asmith

Subscribers: llvm-commits, davide

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

llvm-svn: 322995

6 years ago[WebAssembly] Include SYMBOL_INFO for imports as well as exports
Sam Clegg [Fri, 19 Jan 2018 21:49:41 +0000 (21:49 +0000)]
[WebAssembly] Include SYMBOL_INFO for imports as well as exports

Only effects --emit-relocs/--relocatable

Patch by Nicholas Wilson!

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

llvm-svn: 322994

6 years ago[Dominators] Visit affected node candidates found at different root levels
Jakub Kuderski [Fri, 19 Jan 2018 21:27:24 +0000 (21:27 +0000)]
[Dominators] Visit affected node candidates found at different root levels

Summary:
This patch attempts to fix the DomTree incremental insertion bug found here [[ https://bugs.llvm.org/show_bug.cgi?id=35969 | PR35969 ]] .

When performing an insertion into a piece of unreachable CFG, we may find the same not at different levels. When this happens, the node can turn out to be affected when we find it starting from a node with a lower level in the tree. The level at which we start visitation affects if we consider a node affected or not.

This patch tracks the lowest level at which each node was visited during insertion and allows it to be visited multiple times, if it can cause it to be considered affected.

Reviewers: brzycki, davide, dberlin, grosser

Reviewed By: brzycki

Subscribers: llvm-commits

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

llvm-svn: 322993

6 years agoAdd optional DICompileUnit to DIBuilder + make outliner debug info use it
Jessica Paquette [Fri, 19 Jan 2018 21:21:49 +0000 (21:21 +0000)]
Add optional DICompileUnit to DIBuilder + make outliner debug info use it

Previously, the DIBuilder didn't expose functionality to set its compile unit
in any other way than calling createCompileUnit. This meant that the outliner,
which creates new functions, had to create a new compile unit for its debug
info.

This commit adds an optional parameter in the DIBuilder's constructor which
lets you set its CU at construction.

It also changes the MachineOutliner so that it keeps track of the DISubprograms
for each outlined sequence. If debugging information is requested, then it
uses one of the outlined sequence's DISubprograms to grab a CU. It then uses
that CU to construct the DISubprogram for the new outlined function.

The test has also been updated to reflect this change.

See https://reviews.llvm.org/D42254 for more information. Also see the e-mail
discussion on D42254 in llvm-commits for more context.

llvm-svn: 322992

6 years agoReland "Make TracePcGuardController linker-initialized"
Petr Hosek [Fri, 19 Jan 2018 21:14:53 +0000 (21:14 +0000)]
Reland "Make TracePcGuardController linker-initialized"

It was always intended to be.

Patch By: mcgrathr

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

llvm-svn: 322991

6 years ago[WebAssembly] Include weak imports when linking with --relocatable
Sam Clegg [Fri, 19 Jan 2018 20:56:20 +0000 (20:56 +0000)]
[WebAssembly] Include weak imports when linking with --relocatable

We need these import since relocations are generated against them.

Patch by Nicholas Wilson!

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

llvm-svn: 322990

6 years ago[SystemZ] Prefer LOCHI over generating IPM sequences
Ulrich Weigand [Fri, 19 Jan 2018 20:56:04 +0000 (20:56 +0000)]
[SystemZ] Prefer LOCHI over generating IPM sequences

On current machines we have load-on-condition instructions that can be
used to directly implement the SETCC semantics.  If we have those, it is
always preferable to use them instead of generating the IPM sequence.

llvm-svn: 322989

6 years ago[SystemZ] Directly use CC result of compare-and-swap
Ulrich Weigand [Fri, 19 Jan 2018 20:54:18 +0000 (20:54 +0000)]
[SystemZ] Directly use CC result of compare-and-swap

In order to implement a test whether a compare-and-swap succeeded, the
SystemZ back-end currently emits a rather inefficient sequence of first
converting the CC result into an integer, and then testing that integer
against zero.  This commit changes the back-end to simply directly test
the CC value set by the compare-and-swap instruction.

llvm-svn: 322988

6 years ago[SystemZ] Rework IPM sequence generation
Ulrich Weigand [Fri, 19 Jan 2018 20:52:04 +0000 (20:52 +0000)]
[SystemZ] Rework IPM sequence generation

The SystemZ back-end uses a sequence of IPM followed by arithmetic
operations to implement the SETCC primitive.  This is currently done
early during SelectionDAG.  This patch moves generating those sequences
to much later in SelectionDAG (during PreprocessISelDAG).

This doesn't change much in generated code by itself, but it allows
further enhancements that will be checked-in as follow-on commits.

llvm-svn: 322987

6 years ago[SystemZ] Implement computeKnownBitsForTargetNode
Ulrich Weigand [Fri, 19 Jan 2018 20:49:05 +0000 (20:49 +0000)]
[SystemZ] Implement computeKnownBitsForTargetNode

This provides a computeKnownBits implementation for SystemZ target
nodes.  Currently only SystemZISD::SELECT_CCMASK is supported.

llvm-svn: 322986

6 years ago[SelectionDAG] Teach computeKnownBits about ATOMIC_CMP_SWAP_WITH_SUCCESS boolean...
Ulrich Weigand [Fri, 19 Jan 2018 20:47:14 +0000 (20:47 +0000)]
[SelectionDAG] Teach computeKnownBits about ATOMIC_CMP_SWAP_WITH_SUCCESS boolean return value

The second return value of ATOMIC_CMP_SWAP_WITH_SUCCESS is known to be a
boolean, and should therefore be treated by computeKnownBits just like
the second return values of SMULO / UMULO.

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

llvm-svn: 322985

6 years agoAllow BlockDecl in CXXRecord scope to have no access specifier.
Richard Trieu [Fri, 19 Jan 2018 20:46:19 +0000 (20:46 +0000)]
Allow BlockDecl in CXXRecord scope to have no access specifier.

Using a BlockDecl in a default member initializer causes it to be attached to
CXXMethodDecl without its access specifier being set.  This prevents a crash
where getAccess is called on this BlockDecl, since that method expects any
Decl in CXXRecord scope to have an access specifier.

llvm-svn: 322984

6 years ago[SystemZ] Run branch-12.ll test only if long tests enabled
Ulrich Weigand [Fri, 19 Jan 2018 19:51:38 +0000 (19:51 +0000)]
[SystemZ] Run branch-12.ll test only if long tests enabled

This avoids excessive test run times e.g. with expensive checks enabled.

llvm-svn: 322983

6 years ago[X86] Add goldmont to test/Driver/x86-march.c
Craig Topper [Fri, 19 Jan 2018 19:43:36 +0000 (19:43 +0000)]
[X86] Add goldmont to test/Driver/x86-march.c

llvm-svn: 322982

6 years agotanpi: Port from amd_builtins
Jan Vesely [Fri, 19 Jan 2018 18:57:22 +0000 (18:57 +0000)]
tanpi: Port from amd_builtins

Passes piglit on turks and carrizo.
Passes CTS on carrizo.

Acked-By: Aaron Watry <awatry@gmail.com>
Tested-By: Aaron Watry <awatry@gmail.com>
Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
llvm-svn: 322980

6 years agotan: Port from amd_builtins
Jan Vesely [Fri, 19 Jan 2018 18:57:19 +0000 (18:57 +0000)]
tan: Port from amd_builtins

v2: fixup constant precision
Passes piglit on turks and carrizo.
Passes CTS on carrizo
Fixes half_tan to pass CTS on carrizo

Acked-By: Aaron Watry <awatry@gmail.com>
Tested-By: Aaron Watry <awatry@gmail.com>
Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
llvm-svn: 322979

6 years ago[WebAssembly] MC: Start table at offset 1 rather than 0
Sam Clegg [Fri, 19 Jan 2018 18:57:01 +0000 (18:57 +0000)]
[WebAssembly] MC: Start table at offset 1 rather than 0

Summary:
For consistency with the output of lld.

This is useful in runnable binaries as can them be sure the
null function pointer will never be a valid argument
call_indirect.

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

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

llvm-svn: 322978

6 years ago[cmake] Also pass CMAKE_ASM_COMPILER_ID to next stage when bootstrapping
Don Hinton [Fri, 19 Jan 2018 18:31:12 +0000 (18:31 +0000)]
[cmake] Also pass CMAKE_ASM_COMPILER_ID to next stage when bootstrapping

Summary:
When setting CMAKE_ASM_COMPILER=clang, we also need to set
CMAKE_ASM_COMPILER_ID=Clang.

This is needed because cmake won't set CMAKE_ASM_COMPILER_ID if
CMAKE_ASM_COMPILER is already set.

Without CMAKE_ASM_COMPILER_ID, cmake can't set
CMAKE_ASM_COMPILER_OPTIONS_TARGET either, which means
CMAKE_ASM_COMPILER_TARGET is ignored, causing cross compiling to fail,
i.e., `--target=${CMAKE_ASM_COMPILER_TARGET}` isn't passed.

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

llvm-svn: 322977

6 years ago[WebAssembly] Allow non-zero table offset in input object
Sam Clegg [Fri, 19 Jan 2018 18:21:42 +0000 (18:21 +0000)]
[WebAssembly] Allow non-zero table offset in input object

Summary: This change enables D42284 to land without breaking lld

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

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

llvm-svn: 322976

6 years agoMore P0202 constexpr-ifying in <algorithm>. This commit handles replace/replace_if...
Marshall Clow [Fri, 19 Jan 2018 18:07:29 +0000 (18:07 +0000)]
More P0202 constexpr-ifying in <algorithm>. This commit handles replace/replace_if/replace_copy/replace_copy_if.

llvm-svn: 322975

6 years ago[X86][SSE] Add SSE2 gather tests
Simon Pilgrim [Fri, 19 Jan 2018 17:50:25 +0000 (17:50 +0000)]
[X86][SSE] Add SSE2 gather tests

Check codegen without PEXTRD

llvm-svn: 322974

6 years ago[cmake] Include LLVM_LIBXML2_ENABLED in LLVMConfig.cmake, PR36006
Michal Gorny [Fri, 19 Jan 2018 17:47:03 +0000 (17:47 +0000)]
[cmake] Include LLVM_LIBXML2_ENABLED in LLVMConfig.cmake, PR36006

Include the LLVM_LIBXML2_ENABLED cache variable in LLVMConfig.cmake
in order to make it available for other LLVM packages to query. This
is necessary to fix stand-alone testing of LLD.

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

llvm-svn: 322973

6 years ago[ARM] Fix perf regression in compare optimization.
Joel Galenson [Fri, 19 Jan 2018 17:46:27 +0000 (17:46 +0000)]
[ARM] Fix perf regression in compare optimization.

Fix a performance regression caused by r322737.

While trying to make it easier to replace compares with existing adds and
subtracts, I accidentally stopped it from doing so in some cases.  This should
fix that.  I'm also fixing another potential bug in that commit.

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

llvm-svn: 322972

6 years ago[WebAssembly] Fix libcall signature lookup
Derek Schuff [Fri, 19 Jan 2018 17:45:54 +0000 (17:45 +0000)]
[WebAssembly] Fix libcall signature lookup

RuntimeLibcallSignatures previously manually initialized all the libcall
names into an array and searched it linearly for the first match to lookup
the corresponding index.
r322802 switched that to initializing a map keyed by the libcall name.
Neither of these approaches works correctly because some libcall numbers use
the same name on different platforms (e.g. the "l" suffixed functions
use f80 or f128 or ppcf128).

This change fixes that by ensuring that each name only goes into the map
once. It also adds tests.

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

llvm-svn: 322971

6 years agoMore P0202 constexpr-ifying in <algorithm>. This commit handles 'transform'.
Marshall Clow [Fri, 19 Jan 2018 17:45:39 +0000 (17:45 +0000)]
More P0202 constexpr-ifying in <algorithm>. This commit handles 'transform'.

llvm-svn: 322970

6 years agoAdditional fixes for docs in addition to r322968.
Daniel Neilson [Fri, 19 Jan 2018 17:32:33 +0000 (17:32 +0000)]
Additional fixes for docs in addition to r322968.

llvm-svn: 322969

6 years agoFix docs build break caused by r322965
Daniel Neilson [Fri, 19 Jan 2018 17:24:21 +0000 (17:24 +0000)]
Fix docs build break caused by r322965

llvm-svn: 322968

6 years ago[WebAssembly] Add target flags for sign-ext opcodes.
Dan Gohman [Fri, 19 Jan 2018 17:16:32 +0000 (17:16 +0000)]
[WebAssembly] Add target flags for sign-ext opcodes.

Add -msign-ext and -mno-sign-ext to control the new sign-ext target
feature.

llvm-svn: 322967

6 years ago[WebAssembly] Make sign-extension opcodes a distinct feature.
Dan Gohman [Fri, 19 Jan 2018 17:16:24 +0000 (17:16 +0000)]
[WebAssembly] Make sign-extension opcodes a distinct feature.

Sign-extension opcodes have been split into a separate proposal from
the main threads proposal, so switch them to their own target
feature. See:

https://github.com/WebAssembly/sign-extension-ops

llvm-svn: 322966

6 years agoRemove alignment argument from memcpy/memmove/memset in favour of alignment attribute...
Daniel Neilson [Fri, 19 Jan 2018 17:13:12 +0000 (17:13 +0000)]
Remove alignment argument from memcpy/memmove/memset in favour of alignment attributes (Step 1)

Summary:
 This is a resurrection of work first proposed and discussed in Aug 2015:
   http://lists.llvm.org/pipermail/llvm-dev/2015-August/089384.html
and initially landed (but then backed out) in Nov 2015:
   http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20151109/312083.html

 The @llvm.memcpy/memmove/memset intrinsics currently have an explicit argument
which is required to be a constant integer. It represents the alignment of the
dest (and source), and so must be the minimum of the actual alignment of the
two.

 This change is the first in a series that allows source and dest to each
have their own alignments by using the alignment attribute on their arguments.

 In this change we:
1) Remove the alignment argument.
2) Add alignment attributes to the source & dest arguments. We, temporarily,
   require that the alignments for source & dest be equal.

 For example, code which used to read:
  call void @llvm.memcpy.p0i8.p0i8.i32(i8* %dest, i8* %src, i32 100, i32 4, i1 false)
will now read
  call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %dest, i8* align 4 %src, i32 100, i1 false)

 Downstream users may have to update their lit tests that check for
@llvm.memcpy/memmove/memset call/declaration patterns. The following extended sed script
may help with updating the majority of your tests, but it does not catch all possible
patterns so some manual checking and updating will be required.

s~declare void @llvm\.mem(set|cpy|move)\.p([^(]*)\((.*), i32, i1\)~declare void @llvm.mem\1.p\2(\3, i1)~g
s~call void @llvm\.memset\.p([^(]*)i8\(i8([^*]*)\* (.*), i8 (.*), i8 (.*), i32 [01], i1 ([^)]*)\)~call void @llvm.memset.p\1i8(i8\2* \3, i8 \4, i8 \5, i1 \6)~g
s~call void @llvm\.memset\.p([^(]*)i16\(i8([^*]*)\* (.*), i8 (.*), i16 (.*), i32 [01], i1 ([^)]*)\)~call void @llvm.memset.p\1i16(i8\2* \3, i8 \4, i16 \5, i1 \6)~g
s~call void @llvm\.memset\.p([^(]*)i32\(i8([^*]*)\* (.*), i8 (.*), i32 (.*), i32 [01], i1 ([^)]*)\)~call void @llvm.memset.p\1i32(i8\2* \3, i8 \4, i32 \5, i1 \6)~g
s~call void @llvm\.memset\.p([^(]*)i64\(i8([^*]*)\* (.*), i8 (.*), i64 (.*), i32 [01], i1 ([^)]*)\)~call void @llvm.memset.p\1i64(i8\2* \3, i8 \4, i64 \5, i1 \6)~g
s~call void @llvm\.memset\.p([^(]*)i128\(i8([^*]*)\* (.*), i8 (.*), i128 (.*), i32 [01], i1 ([^)]*)\)~call void @llvm.memset.p\1i128(i8\2* \3, i8 \4, i128 \5, i1 \6)~g
s~call void @llvm\.memset\.p([^(]*)i8\(i8([^*]*)\* (.*), i8 (.*), i8 (.*), i32 ([0-9]*), i1 ([^)]*)\)~call void @llvm.memset.p\1i8(i8\2* align \6 \3, i8 \4, i8 \5, i1 \7)~g
s~call void @llvm\.memset\.p([^(]*)i16\(i8([^*]*)\* (.*), i8 (.*), i16 (.*), i32 ([0-9]*), i1 ([^)]*)\)~call void @llvm.memset.p\1i16(i8\2* align \6 \3, i8 \4, i16 \5, i1 \7)~g
s~call void @llvm\.memset\.p([^(]*)i32\(i8([^*]*)\* (.*), i8 (.*), i32 (.*), i32 ([0-9]*), i1 ([^)]*)\)~call void @llvm.memset.p\1i32(i8\2* align \6 \3, i8 \4, i32 \5, i1 \7)~g
s~call void @llvm\.memset\.p([^(]*)i64\(i8([^*]*)\* (.*), i8 (.*), i64 (.*), i32 ([0-9]*), i1 ([^)]*)\)~call void @llvm.memset.p\1i64(i8\2* align \6 \3, i8 \4, i64 \5, i1 \7)~g
s~call void @llvm\.memset\.p([^(]*)i128\(i8([^*]*)\* (.*), i8 (.*), i128 (.*), i32 ([0-9]*), i1 ([^)]*)\)~call void @llvm.memset.p\1i128(i8\2* align \6 \3, i8 \4, i128 \5, i1 \7)~g
s~call void @llvm\.mem(cpy|move)\.p([^(]*)i8\(i8([^*]*)\* (.*), i8([^*]*)\* (.*), i8 (.*), i32 [01], i1 ([^)]*)\)~call void @llvm.mem\1.p\2i8(i8\3* \4, i8\5* \6, i8 \7, i1 \8)~g
s~call void @llvm\.mem(cpy|move)\.p([^(]*)i16\(i8([^*]*)\* (.*), i8([^*]*)\* (.*), i16 (.*), i32 [01], i1 ([^)]*)\)~call void @llvm.mem\1.p\2i16(i8\3* \4, i8\5* \6, i16 \7, i1 \8)~g
s~call void @llvm\.mem(cpy|move)\.p([^(]*)i32\(i8([^*]*)\* (.*), i8([^*]*)\* (.*), i32 (.*), i32 [01], i1 ([^)]*)\)~call void @llvm.mem\1.p\2i32(i8\3* \4, i8\5* \6, i32 \7, i1 \8)~g
s~call void @llvm\.mem(cpy|move)\.p([^(]*)i64\(i8([^*]*)\* (.*), i8([^*]*)\* (.*), i64 (.*), i32 [01], i1 ([^)]*)\)~call void @llvm.mem\1.p\2i64(i8\3* \4, i8\5* \6, i64 \7, i1 \8)~g
s~call void @llvm\.mem(cpy|move)\.p([^(]*)i128\(i8([^*]*)\* (.*), i8([^*]*)\* (.*), i128 (.*), i32 [01], i1 ([^)]*)\)~call void @llvm.mem\1.p\2i128(i8\3* \4, i8\5* \6, i128 \7, i1 \8)~g
s~call void @llvm\.mem(cpy|move)\.p([^(]*)i8\(i8([^*]*)\* (.*), i8([^*]*)\* (.*), i8 (.*), i32 ([0-9]*), i1 ([^)]*)\)~call void @llvm.mem\1.p\2i8(i8\3* align \8 \4, i8\5* align \8 \6, i8 \7, i1 \9)~g
s~call void @llvm\.mem(cpy|move)\.p([^(]*)i16\(i8([^*]*)\* (.*), i8([^*]*)\* (.*), i16 (.*), i32 ([0-9]*), i1 ([^)]*)\)~call void @llvm.mem\1.p\2i16(i8\3* align \8 \4, i8\5* align \8 \6, i16 \7, i1 \9)~g
s~call void @llvm\.mem(cpy|move)\.p([^(]*)i32\(i8([^*]*)\* (.*), i8([^*]*)\* (.*), i32 (.*), i32 ([0-9]*), i1 ([^)]*)\)~call void @llvm.mem\1.p\2i32(i8\3* align \8 \4, i8\5* align \8 \6, i32 \7, i1 \9)~g
s~call void @llvm\.mem(cpy|move)\.p([^(]*)i64\(i8([^*]*)\* (.*), i8([^*]*)\* (.*), i64 (.*), i32 ([0-9]*), i1 ([^)]*)\)~call void @llvm.mem\1.p\2i64(i8\3* align \8 \4, i8\5* align \8 \6, i64 \7, i1 \9)~g
s~call void @llvm\.mem(cpy|move)\.p([^(]*)i128\(i8([^*]*)\* (.*), i8([^*]*)\* (.*), i128 (.*), i32 ([0-9]*), i1 ([^)]*)\)~call void @llvm.mem\1.p\2i128(i8\3* align \8 \4, i8\5* align \8 \6, i128 \7, i1 \9)~g

 The remaining changes in the series will:
Step 2) Expand the IRBuilder API to allow creation of memcpy/memmove with differing
   source and dest alignments.
Step 3) Update Clang to use the new IRBuilder API.
Step 4) Update Polly to use the new IRBuilder API.
Step 5) Update LLVM passes that create memcpy/memmove calls to use the new IRBuilder API,
        and those that use use MemIntrinsicInst::[get|set]Alignment() to use
        getDestAlignment() and getSourceAlignment() instead.
Step 6) Remove the single-alignment IRBuilder API for memcpy/memmove, and the
        MemIntrinsicInst::[get|set]Alignment() methods.

Reviewers: pete, hfinkel, lhames, reames, bollu

Reviewed By: reames

Subscribers: niosHD, reames, jholewinski, qcolombet, jfb, sanjoy, arsenm, dschuff, dylanmckay, mehdi_amini, sdardis, nemanjai, david2050, nhaehnle, javed.absar, sbc100, jgravelle-google, eraman, aheejin, kbarton, JDevlieghere, asb, rbar, johnrusso, simoncook, jordy.potman.lists, apazos, sabuasal, llvm-commits

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

llvm-svn: 322965

6 years agoChange memcpy/memove/memset to have dest and source alignment attributes (Step 1).
Daniel Neilson [Fri, 19 Jan 2018 17:12:54 +0000 (17:12 +0000)]
Change memcpy/memove/memset to have dest and source alignment attributes (Step 1).

Summary:
  Upstream LLVM is changing the the prototypes of the @llvm.memcpy/memmove/memset
intrinsics. This change updates the Clang tests for this change.

  The @llvm.memcpy/memmove/memset intrinsics currently have an explicit argument
which is required to be a constant integer. It represents the alignment of the
dest (and source), and so must be the minimum of the actual alignment of the
two.

 This change removes the alignment argument in favour of placing the alignment
attribute on the source and destination pointers of the memory intrinsic call.

 For example, code which used to read:
   call void @llvm.memcpy.p0i8.p0i8.i32(i8* %dest, i8* %src, i32 100, i32 4, i1 false)
will now read
   call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %dest, i8* align 4 %src, i32 100, i1 false)

 At this time the source and destination alignments must be the same (Step 1).
Step 2 of the change, to be landed shortly, will relax that contraint and allow
the source and destination to have different alignments.

llvm-svn: 322964

6 years agoChange memcpy/memove/memset to have dest and source alignment attributes (Step 1).
Daniel Neilson [Fri, 19 Jan 2018 17:12:48 +0000 (17:12 +0000)]
Change memcpy/memove/memset to have dest and source alignment attributes (Step 1).

Summary:
 Upstream LLVM is changing the the prototypes of the @llvm.memcpy/memmove/memset
intrinsics. This change updates the polly tests for this change.

 The @llvm.memcpy/memmove/memset intrinsics currently have an explicit argument
which is required to be a constant integer. It represents the alignment of the
dest (and source), and so must be the minimum of the actual alignment of the
two.

 This change removes the alignment argument in favour of placing the alignment
attribute on the source and destination pointers of the memory intrinsic call.

 For example, code which used to read:
  call void @llvm.memcpy.p0i8.p0i8.i32(i8* %dest, i8* %src, i32 100, i32 4, i1 false)
will now read
  call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %dest, i8* align 4 %src, i32 100, i1 false)

 At this time the source and destination alignments must be the same (Step 1).
Step 2 of the change, to be landed shortly, will relax that contraint and allow
the source and destination to have different alignments.

llvm-svn: 322963

6 years agoFallback option for colorized output when terminfo isn't available
Petr Hosek [Fri, 19 Jan 2018 17:10:55 +0000 (17:10 +0000)]
Fallback option for colorized output when terminfo isn't available

Try to detect the terminal color support by checking the value of the
TERM environment variable. This is not great, but it's better than
nothing when terminfo library isn't available, which may still be the
case on some Linux distributions.

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

llvm-svn: 322962

6 years ago[x86] add RUN line and auto-generate checks
Sanjay Patel [Fri, 19 Jan 2018 17:09:28 +0000 (17:09 +0000)]
[x86] add RUN line and auto-generate checks

There were checks for a 32-bit target here, but no RUN line
corresponding to that prefix. I don't know what the intent
of these tests is, but at least now we can see what happens
for both targets.

llvm-svn: 322961

6 years ago[x86] regenerate complete checks; NFC
Sanjay Patel [Fri, 19 Jan 2018 17:05:16 +0000 (17:05 +0000)]
[x86] regenerate complete checks; NFC

D42265 will improve something here, but it's not obvious how without more checks.

llvm-svn: 322960