4 years ago[clang-reorder-fields] Switch to add_clang_tool
Shoaib Meenai [Thu, 2 Nov 2017 01:10:05 +0000 (01:10 +0000)]
[clang-reorder-fields] Switch to add_clang_tool

`add_clang_tool` invokes `add_clang_executable` internally, but it also
takes care of setting up the install rule. It also adds an `install-*`
build target, which is required for `LLVM_DISTRIBUTION_COMPONENTS`.

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

llvm-svn: 317149

4 years ago[cmake] Switch FATAL_ERROR to SEND_ERROR
Shoaib Meenai [Thu, 2 Nov 2017 01:07:37 +0000 (01:07 +0000)]
[cmake] Switch FATAL_ERROR to SEND_ERROR

It's possible for multiple distribution components to have missing
targets, and it's a lot more convenient to get all those errors in one
shot rather than having to fix them individually.

llvm-svn: 317148

4 years agoPR33746: Store the 'inline'ness of a static data member with the update record
Richard Smith [Thu, 2 Nov 2017 01:06:00 +0000 (01:06 +0000)]
PR33746: Store the 'inline'ness of a static data member with the update record
for instantiating its definition.

We model the 'inline'ness as being instantiated with the static data member in
order to track whether the declaration has become a definition yet.

llvm-svn: 317147

4 years agoCodeGen: simplify EH personality selection (NFC)
Saleem Abdulrasool [Thu, 2 Nov 2017 00:25:40 +0000 (00:25 +0000)]
CodeGen: simplify EH personality selection (NFC)

Fix a typo in the comment, reorder to ensure that the ordering matches
across the ObjC/ObjC++ cases.  NFCI.

llvm-svn: 317146

4 years ago[Core] Comparison for unsigned >= 0 is redundant. NFCI.
Davide Italiano [Wed, 1 Nov 2017 23:49:23 +0000 (23:49 +0000)]
[Core] Comparison for unsigned >= 0 is redundant. NFCI.

llvm-svn: 317145

4 years ago[XML] Simplify lambda removing unused capture. NFCI.
Davide Italiano [Wed, 1 Nov 2017 23:48:07 +0000 (23:48 +0000)]
[XML] Simplify lambda removing unused capture. NFCI.

llvm-svn: 317144

4 years ago[Interpreter] Remove unused variable usage. NFCI.
Davide Italiano [Wed, 1 Nov 2017 23:46:21 +0000 (23:46 +0000)]
[Interpreter] Remove unused variable usage. NFCI.

llvm-svn: 317143

4 years agoRevert "[libc++] Don't alias quick_exit if __ANDROID_API__ < 21"
Dan Albert [Wed, 1 Nov 2017 23:43:07 +0000 (23:43 +0000)]
Revert "[libc++] Don't alias quick_exit if __ANDROID_API__ < 21"

Broke the Darwin build bots.

This reverts commit f56f1bba1ade4a408d403ff050d50e837bae47df.

llvm-svn: 317142

4 years agoUpdate cl::opt<uint64_t> instances to cl::opt<unsigned long long>
Mitch Phillips [Wed, 1 Nov 2017 23:39:41 +0000 (23:39 +0000)]
Update cl::opt<uint64_t> instances to cl::opt<unsigned long long>

cl::opt<uint64_t> fails when parsing command line arguments.

See https://bugs.llvm.org/show_bug.cgi?id=19665.

Reviewers: pcc

Subscribers: mgorny, llvm-commits, kcc

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

llvm-svn: 317141

4 years agoFix missing -Wregister warning when 'register' is applied to a function parameter.
Richard Smith [Wed, 1 Nov 2017 23:38:37 +0000 (23:38 +0000)]
Fix missing -Wregister warning when 'register' is applied to a function parameter.

llvm-svn: 317140

4 years ago[yaml2obj][ELF] Add support for setting alignment in program headers
Jake Ehrlich [Wed, 1 Nov 2017 23:14:48 +0000 (23:14 +0000)]
[yaml2obj][ELF] Add support for setting alignment in program headers

Sometimes program headers have larger alignments than any of the
sections they contain. Currently yaml2obj can't produce such files. A
bug recently appeared in llvm-objcopy that failed in such a case. I'd
like to be able to add tests to llvm-objcopy for such cases.

This change adds an optional alignment parameter to program headers that
will be used instead of calculating the alignment.

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

llvm-svn: 317139

4 years agoloop-unroll: teach remapInstruction to update dbg.value intrinsics.
Adrian Prantl [Wed, 1 Nov 2017 23:12:35 +0000 (23:12 +0000)]
loop-unroll: teach remapInstruction to update dbg.value intrinsics.

Fixes PR35112.


llvm-svn: 317138

4 years ago[ASTMatchers] Fix some Clang-tidy modernize and Include What You Use warnings; other...
Eugene Zelenko [Wed, 1 Nov 2017 23:09:49 +0000 (23:09 +0000)]
[ASTMatchers] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).

llvm-svn: 317137

4 years agoRevert "Correct dwarf unwind information in function epilogue for X86"
Petar Jovanovic [Wed, 1 Nov 2017 23:05:52 +0000 (23:05 +0000)]
Revert "Correct dwarf unwind information in function epilogue for X86"

This reverts r317100 as it introduced sanitizer-x86_64-linux-autoconf
buildbot failure (build #15606).

llvm-svn: 317136

4 years ago[LLVM-C] Expose functions to create debug locations via DIBuilder.
whitequark [Wed, 1 Nov 2017 22:18:52 +0000 (22:18 +0000)]
[LLVM-C] Expose functions to create debug locations via DIBuilder.

These include:
  * Several functions for creating an LLVMDIBuilder,
  * LLVMDIBuilderCreateCompileUnit,
  * LLVMDIBuilderCreateFile,
  * LLVMDIBuilderCreateDebugLocation.

Patch by Harlan Haskins.

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

llvm-svn: 317135

4 years ago[X86] Use foreach in X86.td to combine some of the CPU names that are obviously alias...
Craig Topper [Wed, 1 Nov 2017 22:15:49 +0000 (22:15 +0000)]
[X86] Use foreach in X86.td to combine some of the CPU names that are obviously aliases. NFC

llvm-svn: 317134

4 years ago[X86] Add CMOV feature to 'i686' processor, making it a proper alias of pentiumpro...
Craig Topper [Wed, 1 Nov 2017 22:15:40 +0000 (22:15 +0000)]
[X86] Add CMOV feature to 'i686' processor, making it a proper alias of pentiumpro which I believe it should be.

This is consistent with current gcc behavior.

llvm-svn: 317133

4 years ago[globalisel][regbank] Warn about MIR ambiguities when register bank/class names clash.
Daniel Sanders [Wed, 1 Nov 2017 22:13:05 +0000 (22:13 +0000)]
[globalisel][regbank] Warn about MIR ambiguities when register bank/class names clash.

llvm-svn: 317132

4 years agodotest: consistently call finalize_build_dictionary in debug info variants
Pavel Labath [Wed, 1 Nov 2017 22:01:03 +0000 (22:01 +0000)]
dotest: consistently call finalize_build_dictionary in debug info variants

dwarf&dwo versions were doing it, but gmodules and dsym weren't. All
this function does right now is pass OS=Android to make when targeting
android. This enables us to run dotest without manually passing --env

llvm-svn: 317130

4 years agoadd LibCxxTuple.cpp, LibCxxQueue.cpp to xcode project file.
Jason Molenda [Wed, 1 Nov 2017 21:55:35 +0000 (21:55 +0000)]
add LibCxxTuple.cpp, LibCxxQueue.cpp to xcode project file.

llvm-svn: 317129

4 years ago[X86][SSE] Add PACKUS support to LowerTruncate
Simon Pilgrim [Wed, 1 Nov 2017 21:52:29 +0000 (21:52 +0000)]
[X86][SSE] Add PACKUS support to LowerTruncate

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: 317128

4 years agoRewrite FileOutputBuffer as two separate classes.
Rui Ueyama [Wed, 1 Nov 2017 21:38:14 +0000 (21:38 +0000)]
Rewrite FileOutputBuffer as two separate classes.

This patch is to rewrite FileOutputBuffer as two separate classes;
one for file-backed output buffer and the other for memory-backed
output buffer. I think the new code is easier to follow because two
different implementations are now actually separated as different

Unlike the previous implementation, the class that does not replace the
final output file using rename(2) does not create a temporary file at
all. Instead, it allocates memory using mmap(2) and use it. I think
this is an improvement because it is now guaranteed that the temporary
memory region doesn't trigger any I/O and there's now zero chance to
leave a temporary file behind. Also, it shouldn't impose new restrictions
because were using mmap IO too.

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

llvm-svn: 317127

4 years ago[libunwind] Don't use dl_iterate_phdr if __ANDROID_API__ < 21
Dan Albert [Wed, 1 Nov 2017 21:26:06 +0000 (21:26 +0000)]
[libunwind] Don't use dl_iterate_phdr if __ANDROID_API__ < 21

On ARM, dl_iterate_phdr is only implemented in the Android NDK version 21 or later:

Reviewers: thakis, danalbert

Reviewed By: danalbert

Subscribers: dtzWill, aemerson, srhines, kristof.beyls

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

llvm-svn: 317125

4 years ago[libc++] Don't alias quick_exit if __ANDROID_API__ < 21
Dan Albert [Wed, 1 Nov 2017 21:17:56 +0000 (21:17 +0000)]
[libc++] Don't alias quick_exit if __ANDROID_API__ < 21

quick_exit() and at_quick_exit() were introduced in android NDK 21:

This CL conditions `_LIBCPP_HAS_QUICK_EXIT` on `__ANDROID_API__ >= 21`.  The only place this macro is used is in some using declarations: `using ::quick_exit`, `using ::at_quick_exit`.

Also, add a missing include to sys/cdefs.h which is what defines `__BIONIC__`.

Reviewers: thakis, danalbert, EricWF

Reviewed By: danalbert

Subscribers: srhines, krytarowski

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

llvm-svn: 317124

4 years ago[dsymutil, llvm-objcopy] Fix some Clang-tidy modernize and Include What You Use warni...
Eugene Zelenko [Wed, 1 Nov 2017 21:16:06 +0000 (21:16 +0000)]
[dsymutil, llvm-objcopy] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).

llvm-svn: 317123

4 years ago[X86] Add custom code to EVEX to VEX pass to turn unmasked 128-bit VPALIGND/Q into...
Craig Topper [Wed, 1 Nov 2017 21:00:59 +0000 (21:00 +0000)]
[X86] Add custom code to EVEX to VEX pass to turn unmasked 128-bit VPALIGND/Q into VPALIGNR if the extended registers aren't being used.

This will enable us to prefer VALIGND/Q during shuffle lowering in order to get the extended register encoding space when BWI isn't available. But if we end up not using the extended registers we can switch VPALIGNR for the shorter VEX encoding.

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

llvm-svn: 317122

4 years agoloop-rotate: avoid duplicating dbg.value intrinsics in the entry block.
Adrian Prantl [Wed, 1 Nov 2017 20:53:22 +0000 (20:53 +0000)]
loop-rotate: avoid duplicating dbg.value intrinsics in the entry block.

This fixes the second half of PR35113.

This reapplies r317106 without modifications.

llvm-svn: 317121

4 years agoloop-rotate: eliminate duplicate debug intrinsics after splicing.
Adrian Prantl [Wed, 1 Nov 2017 20:43:30 +0000 (20:43 +0000)]
loop-rotate: eliminate duplicate debug intrinsics after splicing.

Fixes part of PR35113.

This reapplies r317105 with an additional check for isa<Instruction>
as found by the bots.

llvm-svn: 317120

4 years ago[fuzzer] Script to detect unbalanced allocation in -trace_malloc output
Vitaly Buka [Wed, 1 Nov 2017 20:27:06 +0000 (20:27 +0000)]
[fuzzer] Script to detect unbalanced allocation in -trace_malloc output

Reviewers: kcc

Subscribers: llvm-commits

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

llvm-svn: 317119

4 years agoInclude GUIDs from the same module when computing GUIDs that needs to be imported.
Dehao Chen [Wed, 1 Nov 2017 20:26:47 +0000 (20:26 +0000)]
Include GUIDs from the same module when computing GUIDs that needs to be imported.

Summary: In the compile phase of SamplePGO+ThinLTO, ICP is not invoked. Instead, indirect call targets will be included as function metadata for ThinIndex to buidl the call graph. This should not only include functions defined in other modules, but also functions defined in the same module, otherwise ThinIndex may find the callee dead and eliminate it, while ICP in backend will revive the symbol, which leads to undefined symbol.

Reviewers: tejohnson

Reviewed By: tejohnson

Subscribers: sanjoy, llvm-commits, mehdi_amini

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

llvm-svn: 317118

4 years ago[globalisel][tablegen] Add support for multi-insn emission
Daniel Sanders [Wed, 1 Nov 2017 19:57:57 +0000 (19:57 +0000)]
[globalisel][tablegen] Add support for multi-insn emission

The importer will now accept nested instructions in the result pattern such as
(ADDWrr $a, (SUBWrr $b, $c)). This is only valid when the nested instruction
def's a single vreg and the parent instruction consumes a single vreg where a
nested instruction is specified. The importer will automatically create a vreg
to connect the two using the type information from the pattern. This vreg will
be constrained to the register classes given in the instruction definitions*.

* REG_SEQUENCE is explicitly rejected because of this. The definition doesn't
  constrain to a register class and it therefore needs special handling.

llvm-svn: 317117

4 years agoRevert 317016 and 317048
Philip Reames [Wed, 1 Nov 2017 19:49:20 +0000 (19:49 +0000)]
Revert 317016 and 317048

The former appears to have introduced a miscompile in a stage2 clang build.  Revert so I can investigate offline.

llvm-svn: 317116

4 years ago[OpenMP] Fix race condition in omp_init_lock
Jonathan Peyton [Wed, 1 Nov 2017 19:44:42 +0000 (19:44 +0000)]
[OpenMP] Fix race condition in omp_init_lock

This is a partial fix for bug 34050.

This prevents callers of omp_set_lock (which does not hold __kmp_global_lock)
from ever seeing an uninitialized version of __kmp_i_lock_table.table.

It does not solve a use-after-free race condition if omp_set_lock obtains a
pointer to __kmp_i_lock_table.table before it is updated and then attempts to
dereference afterwards. That race is far less likely and can be handled in a
separate patch.

The unit test usually segfaults on the current trunk revision. It passes with
the patch.

Patch by Adam Azarchs

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

llvm-svn: 317115

4 years agoAMDGPU: Fix set but not used warnings related to AMDGPUAS
Konstantin Zhuravlyov [Wed, 1 Nov 2017 19:12:38 +0000 (19:12 +0000)]
AMDGPU: Fix set but not used warnings related to AMDGPUAS

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

llvm-svn: 317114

4 years ago[clang-format] Make parseUnaryOperator non-recursive, NFCI
Krasimir Georgiev [Wed, 1 Nov 2017 18:20:41 +0000 (18:20 +0000)]
[clang-format] Make parseUnaryOperator non-recursive, NFCI

This patch makes the implementation of parseUnaryOperator non-recursive. We had
a problem with a file starting with tens of thousands of +'es and -'es which
caused clang-format to stack overflow.

Reviewers: bkramer

Reviewed By: bkramer

Subscribers: cfe-commits, klimek

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

llvm-svn: 317113

4 years ago[X86] Prevent fast isel from folding loads into the instructions listed in hasPartial...
Craig Topper [Wed, 1 Nov 2017 18:10:06 +0000 (18:10 +0000)]
[X86] Prevent fast isel from folding loads into the instructions listed in hasPartialRegUpdate.

This patch moves the check for opt size and hasPartialRegUpdate into the lower level implementation of foldMemoryOperandImpl to catch the entry point that fast isel uses.

We're still folding undef register instructions in AVX that we should also probably disable, but that's a problem for another patch.

Unfortunately, this requires reordering a bunch of functions which is why the diff is so large. I can do the function reordering separately if we want.

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

llvm-svn: 317112

4 years agoAdds code to PPC ISEL lowering to recognize half-word inserts from vector_shuffles...
Graham Yiu [Wed, 1 Nov 2017 18:06:56 +0000 (18:06 +0000)]
Adds code to PPC ISEL lowering to recognize half-word inserts from vector_shuffles, and use P9 shift and vector insert instructions instead of vperm.

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

llvm-svn: 317111

4 years agoRevert r317105 to investigate bot breakage.
Adrian Prantl [Wed, 1 Nov 2017 18:06:38 +0000 (18:06 +0000)]
Revert r317105 to investigate bot breakage.

llvm-svn: 317110

4 years agoRevert r317106 to facilitate reverting r317105.
Adrian Prantl [Wed, 1 Nov 2017 18:06:35 +0000 (18:06 +0000)]
Revert r317106 to facilitate reverting r317105.

llvm-svn: 317109

4 years agoLTO: Apply global DCE to ThinLTO modules at LTO opt level 0.
Peter Collingbourne [Wed, 1 Nov 2017 17:58:39 +0000 (17:58 +0000)]
LTO: Apply global DCE to ThinLTO modules at LTO opt level 0.

This is necessary because DCE is applied to full LTO modules. Without
this change, a reference from a dead ThinLTO global to a dead full
LTO global will result in an undefined reference at link time.

This problem is only observable when --gc-sections is disabled, or
when targeting COFF, as the COFF port of lld requires all symbols to
have a definition even if all references are dead (this is consistent
with link.exe).

This change also adds an EliminateAvailableExternally pass at -O0. This
is necessary to handle the situation on Windows where a non-prevailing
copy of a linkonce_odr function has an SEH filter function; any
such filters must be DCE'd because they will contain a call to the
llvm.localrecover intrinsic, passing as an argument the address of the
function that the filter belongs to, and llvm.localrecover requires
this function to be defined locally.

Fixes PR35142.

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

llvm-svn: 317108

4 years ago[X86] Regnerate test to attempt to fix build bot failure.
Craig Topper [Wed, 1 Nov 2017 17:44:12 +0000 (17:44 +0000)]
[X86] Regnerate test to attempt to fix build bot failure.

llvm-svn: 317107

4 years agoloop-rotate: avoid duplicating dbg.value intrinsics in the entry block.
Adrian Prantl [Wed, 1 Nov 2017 17:28:50 +0000 (17:28 +0000)]
loop-rotate: avoid duplicating dbg.value intrinsics in the entry block.

This fixes the second half of PR35113.

llvm-svn: 317106

4 years agoloop-rotate: eliminate duplicate debug intrinsics after splicing.
Adrian Prantl [Wed, 1 Nov 2017 17:28:47 +0000 (17:28 +0000)]
loop-rotate: eliminate duplicate debug intrinsics after splicing.

Fixes part of PR35113.

llvm-svn: 317105

4 years ago[dsymutil][NFC} Rename thread related command line options
Jonas Devlieghere [Wed, 1 Nov 2017 17:15:29 +0000 (17:15 +0000)]
[dsymutil][NFC} Rename thread related command line options

This makes the command line options consistent with llvm-cov and
llvm-profdata, which both use `-num-threads` and `-j`.

This also addresses the conflict reported after landing D39355.

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

llvm-svn: 317104

4 years ago[scudo] Fix standlone build -lrt requirement
Kostya Kortchinsky [Wed, 1 Nov 2017 17:00:26 +0000 (17:00 +0000)]
[scudo] Fix standlone build -lrt requirement

The split in D39461 introduced separate C++ flags, but `cxx_flags` needs `-lrt` as well for the standalone build.

Reviewers: alekseyshl

Reviewed By: alekseyshl

Subscribers: llvm-commits

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

llvm-svn: 317103

4 years ago[X86] Add 64-bit int to float/double conversion with AVX to X86FastISel::X86SelectSIToFP
Craig Topper [Wed, 1 Nov 2017 16:23:06 +0000 (16:23 +0000)]
[X86] Add 64-bit int to float/double conversion with AVX  to X86FastISel::X86SelectSIToFP

[X86] Teach fast isel to handle i64 sitofp with AVX.

For some reason we only handled i32 sitofp with AVX. But with SSE only we support i64 so we should do the same with AVX.

Also add i686 command lines for the 32-bit tests. 64-bit tests are in a separate file to avoid a fast-isel abort failure in 32-bit mode.

Reviewers: RKSimon, zvi

Reviewed By: RKSimon

Subscribers: llvm-commits

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

llvm-svn: 317102

4 years agoUpdate VCVTx, VMOVNTPx and VROUNDYPx instructions scheduling on btver2.
Andrew V. Tischenko [Wed, 1 Nov 2017 16:10:20 +0000 (16:10 +0000)]
Update VCVTx, VMOVNTPx and VROUNDYPx instructions scheduling on btver2.
Differential Revision: https://reviews.llvm.org/D39059

llvm-svn: 317101

4 years agoCorrect dwarf unwind information in function epilogue for X86
Petar Jovanovic [Wed, 1 Nov 2017 16:04:11 +0000 (16:04 +0000)]
Correct dwarf unwind information in function epilogue for X86

This patch aims to provide correct dwarf unwind information in function
epilogue for X86.

It consists of two parts. The first part inserts CFI instructions that set
appropriate cfa offset and cfa register in emitEpilogue() in
X86FrameLowering. This part is X86 specific.

The second part is platform independent and ensures that:

- CFI instructions do not affect code generation
- Unwind information remains correct when a function is modified by
  different passes. This is done in a late pass by analyzing information
  about cfa offset and cfa register in BBs and inserting additional CFI
  directives where necessary.

Changed CFI instructions so that they:

- are duplicable
- are not counted as instructions when tail duplicating or tail merging
- can be compared as equal

Added CFIInstrInserter pass:

- analyzes each basic block to determine cfa offset and register valid at
  its entry and exit
- verifies that outgoing cfa offset and register of predecessor blocks match
  incoming values of their successors
- inserts additional CFI directives at basic block beginning to correct the
  rule for calculating CFA

Having CFI instructions in function epilogue can cause incorrect CFA
calculation rule for some basic blocks. This can happen if, due to basic
block reordering, or the existence of multiple epilogue blocks, some of the
blocks have wrong cfa offset and register values set by the epilogue block
above them.

CFIInstrInserter is currently run only on X86, but can be used by any target
that implements support for adding CFI instructions in epilogue.

Patch by Violeta Vukobrat.

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

llvm-svn: 317100

4 years agoAdd data formatter for libc++ std::queue
Pavel Labath [Wed, 1 Nov 2017 15:52:08 +0000 (15:52 +0000)]
Add data formatter for libc++ std::queue

std::queue is just a fancy wrapper around another container, so all we
need to do is to delegate to the it.

Reviewers: jingham, EricWF

Subscribers: srhines, mgorny, lldb-commits, eugene

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

llvm-svn: 317099

4 years ago[X86][SSE] Begun generalizing truncateVectorWithPACKSS to work with PACKSS/PACKUS...
Simon Pilgrim [Wed, 1 Nov 2017 15:31:51 +0000 (15:31 +0000)]
[X86][SSE] Begun generalizing truncateVectorWithPACKSS to work with PACKSS/PACKUS functions

Renamed to truncateVectorWithPACK

llvm-svn: 317098

4 years ago[scudo] Implement stricter separation of C vs C++
Kostya Kortchinsky [Wed, 1 Nov 2017 15:28:20 +0000 (15:28 +0000)]
[scudo] Implement stricter separation of C vs C++

Initially, Scudo had a monolithic design where both C and C++ functions were
living in the same library. This was not necessarily ideal, and with the work
on -fsanitize=scudo, it became more apparent that this needed to change.

We are splitting the new/delete interceptor in their own C++ library. This
allows more flexibility, notably with regard to std::bad_alloc when the work is
done. This also allows us to not link new & delete when using pure C.

Additionally, we add the UBSan runtimes with Scudo, in order to be able to have
a -fsanitize=scudo,undefined in Clang (see work in D39334).

The changes in this patch:
- split the cxx specific code in the scudo cmake file into a new library;
  (remove the spurious foreach loop, that was not necessary)
- add the UBSan runtimes (both C and C++);
- change the test cmake file to allow for specific C & C++ tests;
- make C tests pure C, rename their extension accordingly.

Reviewers: alekseyshl

Reviewed By: alekseyshl

Subscribers: srhines, mgorny, llvm-commits

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

llvm-svn: 317097

4 years agoRegenerate PACKUS/TRUNCS test (PR31773)
Simon Pilgrim [Wed, 1 Nov 2017 15:27:23 +0000 (15:27 +0000)]
Regenerate PACKUS/TRUNCS test (PR31773)

llvm-svn: 317096

4 years agoAdd data formatter for libc++ std::tuple
Pavel Labath [Wed, 1 Nov 2017 15:19:52 +0000 (15:19 +0000)]
Add data formatter for libc++ std::tuple

Reviewers: jingham, EricWF

Subscribers: srhines, eugene, lldb-commits, mgorny

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

llvm-svn: 317095

4 years ago[BranchProbabilityInfo] Handle irreducible loops.
Geoff Berry [Wed, 1 Nov 2017 15:16:50 +0000 (15:16 +0000)]
[BranchProbabilityInfo] Handle irreducible loops.

Compute the strongly connected components of the CFG and fall back to
use these for blocks that are in loops that are not detected by
LoopInfo when computing loop back-edge and exit branch probabilities.

Reviewers: dexonsmith, davidxl

Subscribers: mcrosier, llvm-commits

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

llvm-svn: 317094

4 years agoRemove uint32_t assignment operator from Status
Pavel Labath [Wed, 1 Nov 2017 15:00:58 +0000 (15:00 +0000)]
Remove uint32_t assignment operator from Status

It is not presently used, and it's quite dangerous to use -- it assumes the
integer is an osx kern_return_t, but very few of the integers we have lying
around are mach kernel error codes. The error can still be used to a
mach error using a slightly longer (but more explicit) syntax.

Reviewers: jingham

Subscribers: lldb-commits

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

llvm-svn: 317093

4 years agoRevert r313618 "[ARM] Use ADDCARRY / SUBCARRY"
Roger Ferrer Ibanez [Wed, 1 Nov 2017 14:06:57 +0000 (14:06 +0000)]
Revert r313618 "[ARM] Use ADDCARRY / SUBCARRY"

That change causes PR35103, so reverting until I figure it out.

llvm-svn: 317092

4 years agoFix warnings discovered by rL317076. [-Wunused-private-field]
NAKAMURA Takumi [Wed, 1 Nov 2017 13:47:55 +0000 (13:47 +0000)]
Fix warnings discovered by rL317076. [-Wunused-private-field]

llvm-svn: 317091

4 years agoSuppress a warning discovered by rL317076. [-Wunused-private-field]
NAKAMURA Takumi [Wed, 1 Nov 2017 13:47:51 +0000 (13:47 +0000)]
Suppress a warning discovered by rL317076. [-Wunused-private-field]

llvm-svn: 317090

4 years agoReformat.
NAKAMURA Takumi [Wed, 1 Nov 2017 13:47:48 +0000 (13:47 +0000)]

llvm-svn: 317089

4 years agoRevert rL311205 "[IRCE] Fix buggy behavior in Clamp"
Max Kazantsev [Wed, 1 Nov 2017 13:21:56 +0000 (13:21 +0000)]
Revert rL311205 "[IRCE] Fix buggy behavior in Clamp"

This patch reverts rL311205 that was initially a wrong fix. The real problem
was in intersection of signed and unsigned ranges (see rL316552), and the
patch being reverted masked the problem instead of fixing it.

By now, the test against which rL311205 was made works OK even without this
code. This revert patch also contains a test case that demonstrates incorrect
behavior caused by rL311205: it is caused by incorrect choise of signed max
instead of unsigned.

llvm-svn: 317088

4 years ago[SelectionDAG] computeKnownBits - use ashrInPlace on known bits of ISD::SRA input...
Simon Pilgrim [Wed, 1 Nov 2017 13:16:48 +0000 (13:16 +0000)]
[SelectionDAG] computeKnownBits - use ashrInPlace on known bits of ISD::SRA input. NFCI.

llvm-svn: 317087

4 years ago[X86][SSE] Truncate with PACKSS any input with sufficient sign-bits
Simon Pilgrim [Wed, 1 Nov 2017 11:47:44 +0000 (11:47 +0000)]
[X86][SSE] Truncate with PACKSS any input with sufficient sign-bits

So far we've only been using PACKSS truncations with 'all-bits or zero-bits' patterns (vector comparison results etc.). When really we can safely use it for any case as long as the number of sign bits reach down to the last 16-bits (or 8-bits if we're truncating to bytes).

The next steps after this is add the equivalent support for PACKUS and to support packing to sub-128 bit vectors for truncating stores etc.

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

llvm-svn: 317086

4 years agoUpdate implementation of OMPT to the specification OpenMP 5.0 Preview 1 (TR4).
Joachim Protze [Wed, 1 Nov 2017 10:08:30 +0000 (10:08 +0000)]
Update implementation of OMPT to the specification OpenMP 5.0 Preview 1 (TR4).

The code is tested to work with latest clang, GNU and Intel compiler. The implementation
is optimized for low overhead when no tool is attached shifting the cost to execution with
tool attached.

This patch does not implement OMPT for libomptarget.

Patch by Simon Convent and Joachim Protze

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

llvm-svn: 317085

4 years ago[CodeExtractor] Fix iterator invalidation in findOrCreateBlockForHoisting.
Florian Hahn [Wed, 1 Nov 2017 09:48:12 +0000 (09:48 +0000)]
[CodeExtractor] Fix iterator invalidation in findOrCreateBlockForHoisting.

By replacing branches to CommonExitBlock, we remove the node from
CommonExitBlock's predecessors, invalidating the iterator. The problem
is exposed when the common exit block has multiple predecessors and
needs to sink lifetime info. The modification in the test case trigger
the issue.

Reviewers: davidxl, davide, wmi

Reviewed By: davidxl

Subscribers: llvm-commits

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

llvm-svn: 317084

4 years agoAdd LLVM_FALLTHROUGH to silence warning. NFCI.
Simon Pilgrim [Wed, 1 Nov 2017 09:22:03 +0000 (09:22 +0000)]
Add LLVM_FALLTHROUGH to silence warning. NFCI.

llvm-svn: 317083

4 years ago[ELF] - Cleanup of processSectionCommands().
George Rimar [Wed, 1 Nov 2017 08:40:28 +0000 (08:40 +0000)]
[ELF] - Cleanup of processSectionCommands().

The way we handle ONLY_IF_RO/ONLY_IF_RW constraints in
processSectionCommands is a bit tricky. If input sections
does no satisfy given constraint we remove command from
commands list. It seems too complex, what we can do instead
is to make the OutputCommand empty. So that at later steps
LLD will remove it just like it deal with other empty output commands.
That allows to simplify the loop a bit.

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

llvm-svn: 317082

4 years agoFix APFloat mod sign
Serguei Katkov [Wed, 1 Nov 2017 07:56:55 +0000 (07:56 +0000)]
Fix APFloat mod sign

fmod specification requires the sign of the remainder is
the same as numerator in case remainder is zero.

Reviewers: gottesmm, scanon, arsenm, davide, craig.topper
Reviewed By: scanon
Subscribers: wdng, llvm-commits
Differential Revision: https://reviews.llvm.org/D39225

llvm-svn: 317081

4 years ago[ELF] - Teach LLD to report line numbers for data symbols.
George Rimar [Wed, 1 Nov 2017 07:42:38 +0000 (07:42 +0000)]
[ELF] - Teach LLD to report line numbers for data symbols.

This is PR34826.

Currently LLD is unable to report line number when reporting
duplicate declaration of some variable.

That happens because for extracting line information we always use
.debug_line section content which describes mapping from machine
instructions to source file locations, what does not help for
variables as does not describe them.

In this patch I am taking the approproate information about
variables locations from the .debug_info section.

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

llvm-svn: 317080

4 years ago[X86] Add more type qualifiers to INSERT_SUBREG operations in rotate patterns so...
Craig Topper [Wed, 1 Nov 2017 07:11:32 +0000 (07:11 +0000)]
[X86] Add more type qualifiers to INSERT_SUBREG operations in rotate patterns so they don't get created with a v64i8 type.

Not sure why tablegen didn't error on this.

Fixes PR35158.

llvm-svn: 317079

4 years agoReformat.
NAKAMURA Takumi [Wed, 1 Nov 2017 05:14:35 +0000 (05:14 +0000)]

llvm-svn: 317078

4 years agoRevert rL317019, "[ADT] Split optional to only include copy mechanics and dtor for...
NAKAMURA Takumi [Wed, 1 Nov 2017 05:14:31 +0000 (05:14 +0000)]
Revert rL317019, "[ADT] Split optional to only include copy mechanics and dtor for non-trivial types."

Seems g++-4.8 (eg. Ubuntu 14.04) doesn't like this.

llvm-svn: 317077

4 years agoFix -Wunused-private-field to fire regardless of which implicit special members have...
Richard Smith [Wed, 1 Nov 2017 04:52:12 +0000 (04:52 +0000)]
Fix -Wunused-private-field to fire regardless of which implicit special members have been implicitly declared.

llvm-svn: 317076

4 years agoclang/lib/Format/Format.cpp: Fix warnings introduced in rL316903. [-Wpedantic]
NAKAMURA Takumi [Wed, 1 Nov 2017 04:43:22 +0000 (04:43 +0000)]
clang/lib/Format/Format.cpp: Fix warnings introduced in rL316903. [-Wpedantic]

llvm-svn: 317075

4 years agoMore statuses, a new patch, too
Marshall Clow [Wed, 1 Nov 2017 04:03:35 +0000 (04:03 +0000)]
More statuses, a new patch, too

llvm-svn: 317074

4 years agoChange assertion to quick exit from checking function.
Richard Trieu [Wed, 1 Nov 2017 03:57:27 +0000 (03:57 +0000)]
Change assertion to quick exit from checking function.

Remove the assertion that could be triggered by invalid code.  Replace it with
an early exit from the checking function.

llvm-svn: 317073

4 years ago[DAGCombiner] Fix typos in comments. NFC
Craig Topper [Wed, 1 Nov 2017 03:30:52 +0000 (03:30 +0000)]
[DAGCombiner] Fix typos in comments. NFC

llvm-svn: 317072

4 years ago[fuzzer] Fix threaded stack printing
Vitaly Buka [Wed, 1 Nov 2017 03:02:59 +0000 (03:02 +0000)]
[fuzzer] Fix threaded stack printing

Reviewers: kcc

Subscribers: llvm-commits

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

llvm-svn: 317071

4 years ago[analyzer] Removing unused stored field.
George Karpenkov [Wed, 1 Nov 2017 02:29:04 +0000 (02:29 +0000)]
[analyzer] Removing unused stored field.

llvm-svn: 317070

4 years ago[X86] Define i586 and pentium preprocessor defines for -march=lakemont to match GCC
Craig Topper [Wed, 1 Nov 2017 02:18:49 +0000 (02:18 +0000)]
[X86] Define i586 and pentium preprocessor defines for -march=lakemont to match GCC

llvm-svn: 317069

4 years agoAdd --no-omagic and --no-print-gc-sections.
Rui Ueyama [Wed, 1 Nov 2017 02:04:43 +0000 (02:04 +0000)]
Add --no-omagic and --no-print-gc-sections.

llvm-svn: 317068

4 years agoRemove Sean Callanan from the CODE_OWNERS, he won't have time
Jason Molenda [Wed, 1 Nov 2017 01:38:42 +0000 (01:38 +0000)]
Remove Sean Callanan from the CODE_OWNERS, he won't have time
to participate in lldb going forward.  Jim Ingham is adopting
the areas he was responsible for.

llvm-svn: 317067

4 years ago[c++17] Refine resolution of constructor / conversion function disambiguation.
Richard Smith [Wed, 1 Nov 2017 01:37:11 +0000 (01:37 +0000)]
[c++17] Refine resolution of constructor / conversion function disambiguation.

Given a choice between a constructor call and a conversion function in C++17,
we prefer the constructor for direct-initialization and the conversion function
for copy-initialization, matching the behavior in C++14 and before. The
guaranteed copy elision rules were not intended to change the meaning of such
code (other than by removing unnecessary copy constructor calls).

This tweak will be raised with CWG.

llvm-svn: 317066

4 years ago[Analyzer] Use value storage for BodyFarm
George Karpenkov [Wed, 1 Nov 2017 01:36:01 +0000 (01:36 +0000)]
[Analyzer] Use value storage for BodyFarm

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

llvm-svn: 317065

4 years agoUpdate the synopsis to match the P/R of 2945. No code changes.
Marshall Clow [Wed, 1 Nov 2017 01:27:25 +0000 (01:27 +0000)]
Update the synopsis to match the P/R of 2945. No code changes.

llvm-svn: 317063

4 years ago[refactor][extract] code extracted from inline method should be placed
Alex Lorenz [Wed, 1 Nov 2017 01:12:56 +0000 (01:12 +0000)]
[refactor][extract] code extracted from inline method should be placed
in a function defined before the outer class

llvm-svn: 317062

4 years agoRevert "[fuzzer] Fix threaded stack printing and nested mallocs"
Vitaly Buka [Wed, 1 Nov 2017 00:55:52 +0000 (00:55 +0000)]
Revert "[fuzzer] Fix threaded stack printing and nested mallocs"
Fails on darwin

Revert "[fuzzer] Script to detect unbalanced allocation in -trace_malloc output"
Needs previous one.

This reverts commit r317034, r317036.

llvm-svn: 317061

4 years agoAdd test dependency on llvm-cfi-verify to fix up the build breakages on sanitizers.
Mitch Phillips [Wed, 1 Nov 2017 00:49:45 +0000 (00:49 +0000)]
Add test dependency on llvm-cfi-verify to fix up the build breakages on sanitizers.

llvm-svn: 317060

4 years ago[X86] Add AVX512 support to X86FastISel::fastMaterializeFloatZero.
Craig Topper [Wed, 1 Nov 2017 00:47:45 +0000 (00:47 +0000)]
[X86] Add AVX512 support to X86FastISel::fastMaterializeFloatZero.

llvm-svn: 317059

4 years ago[globalisel][tablegen] Stop hard-coding the emitted instruction ID to 0. NFC
Daniel Sanders [Wed, 1 Nov 2017 00:29:47 +0000 (00:29 +0000)]
[globalisel][tablegen] Stop hard-coding the emitted instruction ID to 0. NFC

The next commit will add support for multi-instruction emission so we need to
start allocating instruction ID's instead of hard-coding them to 0.

llvm-svn: 317057

4 years ago[refactor][extract] prohibit extraction of ObjC property setters
Alex Lorenz [Wed, 1 Nov 2017 00:20:55 +0000 (00:20 +0000)]
[refactor][extract] prohibit extraction of ObjC property setters

llvm-svn: 317056

4 years agoAdd system-linux to allow tests run with llvm-lit to restrict themselves to linux
Jake Ehrlich [Wed, 1 Nov 2017 00:18:51 +0000 (00:18 +0000)]
Add system-linux to allow tests run with llvm-lit to restrict themselves to linux

I need a test that only runs in a reasonable amount of time on systems
that have sparse files. The broadest class of systems that support
sparse files are linux systems. So restricting my test to linux systems
should suffice. This change adds the system-linux feature to llvm-lit so
that it can be required.

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

llvm-svn: 317055

4 years ago[refactor][selection] code ranges can be selected in objc methods
Alex Lorenz [Wed, 1 Nov 2017 00:07:12 +0000 (00:07 +0000)]
[refactor][selection] code ranges can be selected in objc methods

llvm-svn: 317054

4 years agoMaking a couple of tests a bit more flexible wrt thunk mangling. Fixes checkin for...
Wolfgang Pieb [Wed, 1 Nov 2017 00:01:20 +0000 (00:01 +0000)]
Making a couple of tests a bit more flexible wrt thunk mangling. Fixes checkin for r317047.

llvm-svn: 317053

4 years agoMake helper function static. NFC.
Benjamin Kramer [Tue, 31 Oct 2017 23:23:36 +0000 (23:23 +0000)]
Make helper function static. NFC.

llvm-svn: 317052

4 years ago[AMDGPU] Clean up symbols in the global namespace.
Benjamin Kramer [Tue, 31 Oct 2017 23:21:30 +0000 (23:21 +0000)]
[AMDGPU] Clean up symbols in the global namespace.

llvm-svn: 317051

4 years agoParse DWARF information to reduce false positives.
Mitch Phillips [Tue, 31 Oct 2017 23:20:05 +0000 (23:20 +0000)]
Parse DWARF information to reduce false positives.

Summary: Help differentiate code and data by parsing DWARF information. This will reduce false positive rates where data is placed in executable sections and is mistakenly parsed as code, resulting in an inflation in the number of indirect CF instructions (and hence an inflation of the number of unprotected).

Also prints the DWARF line data around the region of each indirect CF instruction.

Reviewers: pcc

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

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

llvm-svn: 317050

4 years agoRe-commit: [globalisel][tablegen] Keep track of the insertion point while adding...
Daniel Sanders [Tue, 31 Oct 2017 23:03:18 +0000 (23:03 +0000)]
Re-commit: [globalisel][tablegen] Keep track of the insertion point while adding BuildMIAction's. NFC

Multi-instruction emission needs to ensure the the instructions are generated
a depth-first fashion. For example:
(ADDWrr (SUBWrr a, b), c)
needs to emit the SUBWrr before the ADDWrr. However, our walk over
TreePatternNode's is highly context sensitive which makes it difficult to append
BuildMIActions in the order we want. To fix this, we now keep track of the
insertion point as we add actions. This will allow multi-insn emission to insert
BuildMI's in the correct place.

The previous commit failed on the Ubuntu bots using GCC 4.8. These bots lack the
const_iterator forms of insert() and emplace() that were added in C++11. As a
result I've switched the const_iterators to iterators.

llvm-svn: 317049

4 years ago[SimplifyIndVar] Inline makIVComparisonInvariant to eleminate code duplication [NFC]
Philip Reames [Tue, 31 Oct 2017 22:56:16 +0000 (22:56 +0000)]
[SimplifyIndVar] Inline makIVComparisonInvariant to eleminate code duplication [NFC]

This formulation might be slightly slower since I eagerly compute the cheap replacements.  If anyone sees this having a compile time impact, let me know and I'll use lazy population instead.

llvm-svn: 317048

4 years agoFix for PR33930. Short-circuit metadata mapping when cloning a varargs thunk.
Wolfgang Pieb [Tue, 31 Oct 2017 22:49:48 +0000 (22:49 +0000)]
Fix for PR33930. Short-circuit metadata mapping when cloning a varargs thunk.
The cloning happens before all metadata nodes are resolved. Prevent the value
mapper from running into unresolved or temporary MD nodes.

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

llvm-svn: 317047

4 years agoObject: Move some code from ELF.h into ELF.cpp.
Peter Collingbourne [Tue, 31 Oct 2017 22:49:23 +0000 (22:49 +0000)]
Object: Move some code from ELF.h into ELF.cpp.

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

llvm-svn: 317046