platform/upstream/llvm.git
8 years agoFix bitcode auto-upgrade when using bitcode lazy loading
Mehdi Amini [Sat, 13 Aug 2016 23:31:53 +0000 (23:31 +0000)]
Fix bitcode auto-upgrade when using bitcode lazy loading

The auto-upgrade path could be called before the VST (global
names) was fully parsed, and thus intrinsic names were not
available and the autoupgrade logic could not operate.

Fix link failures with ThinLTO.

llvm-svn: 278610

8 years agoRevert "Revert "Invariant start/end intrinsics overloaded for address space""
Mehdi Amini [Sat, 13 Aug 2016 23:31:24 +0000 (23:31 +0000)]
Revert "Revert "Invariant start/end intrinsics overloaded for address space""

This reverts commit 32fc6488e48eafc0ca1bac1bd9cbf0008224d530.

llvm-svn: 278609

8 years agoRevert "Invariant start/end intrinsics overloaded for address space"
Mehdi Amini [Sat, 13 Aug 2016 23:27:32 +0000 (23:27 +0000)]
Revert "Invariant start/end intrinsics overloaded for address space"

This reverts commit r276447.

llvm-svn: 278608

8 years ago[IRCE] Use dyn_cast instead of explicit isa/cast; NFC
Sanjoy Das [Sat, 13 Aug 2016 22:00:12 +0000 (22:00 +0000)]
[IRCE] Use dyn_cast instead of explicit isa/cast; NFC

llvm-svn: 278607

8 years ago[IRCE] Use range-for; NFC
Sanjoy Das [Sat, 13 Aug 2016 22:00:09 +0000 (22:00 +0000)]
[IRCE] Use range-for; NFC

llvm-svn: 278606

8 years ago[ADT] Add a reserve() method to DenseSet as well as an insert() for R-value
Mehdi Amini [Sat, 13 Aug 2016 20:42:19 +0000 (20:42 +0000)]
[ADT] Add a reserve() method to DenseSet as well as an insert() for R-value

Recommit 278600 with some fixes to make the test more robust.

llvm-svn: 278604

8 years agoRevert "[ADT] Add a reserve method to DenseSet as well as an insert() for R-value"
Mehdi Amini [Sat, 13 Aug 2016 20:14:39 +0000 (20:14 +0000)]
Revert "[ADT] Add a reserve method to DenseSet as well as an insert() for R-value"

This reverts commit r278600. The unittest does not pass on MSVC, there is
an extra move. Investigating how to make it more robust.

llvm-svn: 278603

8 years agoLimit DenseMap::setNumEntries input to 1<<31, in accordance with the 31 bits allocate...
Yaron Keren [Sat, 13 Aug 2016 19:46:31 +0000 (19:46 +0000)]
Limit DenseMap::setNumEntries input to 1<<31, in accordance with the 31 bits allocated to NumEntries.
std::numeric_limits<int>::max() may be something else than 1<<31.

llvm-svn: 278602

8 years agoAdd missing REQUIRES in sancov/print_coverage_pcs.test: it requires aarch64 as well now
Mehdi Amini [Sat, 13 Aug 2016 19:44:02 +0000 (19:44 +0000)]
Add missing REQUIRES in sancov/print_coverage_pcs.test: it requires aarch64 as well now

llvm-svn: 278601

8 years ago[ADT] Add a reserve method to DenseSet as well as an insert() for R-value
Mehdi Amini [Sat, 13 Aug 2016 19:40:13 +0000 (19:40 +0000)]
[ADT] Add a reserve method to DenseSet as well as an insert() for R-value

llvm-svn: 278600

8 years ago[x86] add tests to show missed 64-bit immediate merging
Sanjay Patel [Sat, 13 Aug 2016 18:42:14 +0000 (18:42 +0000)]
[x86] add tests to show missed 64-bit immediate merging

Tests are slightly modified versions of those written by
Sunita Marathe in D23391.

llvm-svn: 278599

8 years agoTest commit
Aditya Kumar [Sat, 13 Aug 2016 11:56:50 +0000 (11:56 +0000)]
Test commit

llvm-svn: 278598

8 years ago[X86] Add a check of isCommutable at the top of X86InstrInfo::findCommutedOpIndices...
Craig Topper [Sat, 13 Aug 2016 06:48:44 +0000 (06:48 +0000)]
[X86] Add a check of isCommutable at the top of X86InstrInfo::findCommutedOpIndices. Most callers don't check if the instruction is commutable before calling.

This saves us the trouble of ending up in the default of the switch and having to determine if this is an FMA or not.

llvm-svn: 278597

8 years ago[AVX-512] Add isCommutable to scalar FMA3 instructions.
Craig Topper [Sat, 13 Aug 2016 06:48:41 +0000 (06:48 +0000)]
[AVX-512] Add isCommutable to scalar FMA3 instructions.

llvm-svn: 278596

8 years ago[AVX-512] Add commutable flags to 132 form FMA3 instructions.
Craig Topper [Sat, 13 Aug 2016 06:48:39 +0000 (06:48 +0000)]
[AVX-512] Add commutable flags to 132 form FMA3 instructions.

llvm-svn: 278595

8 years ago[X86] Remove patterns for (vzmovl (insert_subvector undef, (scalar_to_vector))) as...
Craig Topper [Sat, 13 Aug 2016 06:02:19 +0000 (06:02 +0000)]
[X86] Remove patterns for (vzmovl (insert_subvector undef, (scalar_to_vector))) as the (vzmovl VR256) pattern has higher priority. NFC

llvm-svn: 278594

8 years ago[AVX-512] Remove an AddedComplexity that was prioritizing basic vzmovl patterns over...
Craig Topper [Sat, 13 Aug 2016 05:43:20 +0000 (05:43 +0000)]
[AVX-512] Remove an AddedComplexity that was prioritizing basic vzmovl patterns over more complex ones that produce better code.

llvm-svn: 278593

8 years ago[AVX-512] Add patterns to support VZEXT_MOVL from 512-bit vectors with 64-bit and...
Craig Topper [Sat, 13 Aug 2016 05:33:12 +0000 (05:33 +0000)]
[AVX-512] Add patterns to support VZEXT_MOVL from 512-bit vectors with 64-bit and 32-bit elements.

Fixes PR28961.

llvm-svn: 278592

8 years ago[PM] Port LoopDataPrefetch to new pass manager
Teresa Johnson [Sat, 13 Aug 2016 04:11:27 +0000 (04:11 +0000)]
[PM] Port LoopDataPrefetch to new pass manager

Summary:
Refactor the existing support into a LoopDataPrefetch implementation
class and a LoopDataPrefetchLegacyPass class that invokes it.
Add a new LoopDataPrefetchPass for the new pass manager that utilizes
the LoopDataPrefetch implementation class.

Reviewers: mehdi_amini

Subscribers: sanjoy, mzolotukhin, nemanjai, llvm-commits

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

llvm-svn: 278591

8 years agoAMDGPU: Fix not estimating MBB operand sizes correctly
Matt Arsenault [Sat, 13 Aug 2016 01:43:54 +0000 (01:43 +0000)]
AMDGPU: Fix not estimating MBB operand sizes correctly

llvm-svn: 278590

8 years agoAMDGPU: Fix missing test for addressing mode with odd offsets
Matt Arsenault [Sat, 13 Aug 2016 01:43:51 +0000 (01:43 +0000)]
AMDGPU: Fix missing test for addressing mode with odd offsets

Add test if the constant offset looks unaligned.

llvm-svn: 278589

8 years agoAMDGPU/R600: Remove macros
Matt Arsenault [Sat, 13 Aug 2016 01:43:46 +0000 (01:43 +0000)]
AMDGPU/R600: Remove macros

llvm-svn: 278588

8 years agoFix more dereferenced end() iterators after r278532
Hans Wennborg [Sat, 13 Aug 2016 01:12:49 +0000 (01:12 +0000)]
Fix more dereferenced end() iterators after r278532

llvm-svn: 278587

8 years agoFix build broken after llvm/ADT/DenseMap.h replacement of climits with limits.
Eugene Zelenko [Sat, 13 Aug 2016 01:05:35 +0000 (01:05 +0000)]
Fix build broken after llvm/ADT/DenseMap.h replacement of climits with limits.

llvm-svn: 278586

8 years agoConstify ValueTracking. NFC.
Pete Cooper [Sat, 13 Aug 2016 01:05:32 +0000 (01:05 +0000)]
Constify ValueTracking.  NFC.

Almost all of the method here are only analysing Value's as opposed to
mutating them.  Mark all of the easy ones as const.

llvm-svn: 278585

8 years ago[IndVars] Ignore (s|z)exts that don't extend the induction variable
Sanjoy Das [Sat, 13 Aug 2016 00:58:31 +0000 (00:58 +0000)]
[IndVars] Ignore (s|z)exts that don't extend the induction variable

`IVVisitor::visitCast` used to have the invariant that if the
instruction it was passed was a sext or zext instruction, the result of
the instruction would be wider than the induction variable.  This is no
longer true after rL275037, so this change teaches `IndVarSimplify` s
implementation of `IVVisitor::visitCast` to work with the relaxed
invariant.

A corresponding change to SimplifyIndVar to preserve the said invariant
after rL275037 would also work, but given how `IVVisitor::visitCast` is
spelled (no indication of said invariant), I figured the current fix is
cleaner.

Fixes PR28935.

llvm-svn: 278584

8 years agoFix some Clang-tidy modernize-use-using and Include What You Use warnings.
Eugene Zelenko [Sat, 13 Aug 2016 00:50:41 +0000 (00:50 +0000)]
Fix some Clang-tidy modernize-use-using and Include What You Use warnings.

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

llvm-svn: 278583

8 years ago[libFuzzer] mention one more trophie in LLVM
Kostya Serebryany [Sat, 13 Aug 2016 00:12:32 +0000 (00:12 +0000)]
[libFuzzer] mention one more trophie in LLVM

llvm-svn: 278582

8 years ago[LSV] Use a set rather than an ArraySlice at the end of getVectorizablePrefix. NFC
Justin Lebar [Sat, 13 Aug 2016 00:04:12 +0000 (00:04 +0000)]
[LSV] Use a set rather than an ArraySlice at the end of getVectorizablePrefix. NFC

Summary: This avoids a small O(n^2) loop.

Reviewers: asbirlea

Subscribers: mzolotukhin, llvm-commits, arsenm

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

llvm-svn: 278581

8 years ago[LSV] Use OrderedBasicBlock instead of rolling it ourselves. NFC
Justin Lebar [Sat, 13 Aug 2016 00:04:08 +0000 (00:04 +0000)]
[LSV] Use OrderedBasicBlock instead of rolling it ourselves. NFC

Summary:
In getVectorizablePrefix, this is less efficient (because we have to
iterate over the BB twice), but boy is it simpler.  Given how much
trouble we've had here, I think the simplicity gain is worthwhile.

In reorder(), this is actually more efficient, as
DominatorTree::dominates iterates over the BB from the beginning when
the two instructions are in the same BB.

Reviewers: asbirlea

Subscribers: arsenm, llvm-commits, mzolotukhin

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

llvm-svn: 278580

8 years agoFix ASAN failures in the demangler
Mehdi Amini [Sat, 13 Aug 2016 00:02:33 +0000 (00:02 +0000)]
Fix ASAN failures in the demangler

These were found fuzzing with ASAN.

llvm-svn: 278579

8 years agoMinor comment fix ("generate" --> "generates").
Justin Lebar [Fri, 12 Aug 2016 23:58:19 +0000 (23:58 +0000)]
Minor comment fix ("generate" --> "generates").

llvm-svn: 278578

8 years agoX86: Fix another dereferenced end() iterator after r278532
Hans Wennborg [Fri, 12 Aug 2016 23:35:59 +0000 (23:35 +0000)]
X86: Fix another dereferenced end() iterator after r278532

llvm-svn: 278577

8 years ago[WebAssembly] Re-enable disabled debug value test
Dominic Chen [Fri, 12 Aug 2016 23:14:18 +0000 (23:14 +0000)]
[WebAssembly] Re-enable disabled debug value test

Summary:
This test was resulting in asan/valgrind failures due to undefined
DWARF register mappings for WebAssembly, and was disabled in r278495.
These have been resolved.

Reviewers: sunfish, dschuff

Subscribers: bkramer, llvm-commits, jfb

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

llvm-svn: 278576

8 years agoReapply [BranchFolding] Restrict tail merging loop blocks after MBP
Haicheng Wu [Fri, 12 Aug 2016 23:13:38 +0000 (23:13 +0000)]
Reapply [BranchFolding] Restrict tail merging loop blocks after MBP

Fixed a bug in the test case.

To fix PR28104, this patch restricts tail merging to blocks that belong to the
same loop after MBP.

llvm-svn: 278575

8 years agoAvoid accessing LLVM/DWARF register mappings if undefined
Dominic Chen [Fri, 12 Aug 2016 23:12:59 +0000 (23:12 +0000)]
Avoid accessing LLVM/DWARF register mappings if undefined

Summary:
If the backend does not define LLVM/DWARF register mappings, the associated
variables are undefined since the map initializer is called by auto-generated
TableGen routines. This patch initializes the pointers and sizes to nullptr
and zero, respectively, and checks that they are valid before searching
for a mapping.

Reviewers: grosbach, dschuff

Subscribers: llvm-commits

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

llvm-svn: 278574

8 years ago[LoopVectorize] Detect loops in the innermost loop before creating InnerLoopVectorizer
Tim Shen [Fri, 12 Aug 2016 22:47:13 +0000 (22:47 +0000)]
[LoopVectorize] Detect loops in the innermost loop before creating InnerLoopVectorizer

InnerLoopVectorizer shouldn't handle a loop with cycles inside the loop
body, even if that cycle isn't a natural loop.

Fixes PR28541.

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

llvm-svn: 278573

8 years agoX86: Stop dereferencing end() in X86FrameLowering::emitEpilogue
Duncan P. N. Exon Smith [Fri, 12 Aug 2016 22:43:33 +0000 (22:43 +0000)]
X86: Stop dereferencing end() in X86FrameLowering::emitEpilogue

On a Windows build of Chromium, r278532 (up to r278539)
X86FrameLowering::emitEpilogue because it wasn't wary enough of the
return of MachineBasicBlock::getFirstTerminator.  Guard all the uses
here.

Note that r278532 *looks* like an NFC commit (just an API change), but
it removes a couple of layers of abstraction and is probably causing
optimization differences in MSVC.

llvm-svn: 278572

8 years ago[Inliner] Don't treat inalloca allocas as static
Reid Kleckner [Fri, 12 Aug 2016 22:23:04 +0000 (22:23 +0000)]
[Inliner] Don't treat inalloca allocas as static

They aren't static, and moving them to the entry block across something
else will only result in tears.

Root cause of http://crbug.com/636558.

llvm-svn: 278571

8 years agoAdd support to paternmatch for simple const Value cases.
Pete Cooper [Fri, 12 Aug 2016 22:16:05 +0000 (22:16 +0000)]
Add support to paternmatch for simple const Value cases.

Pattern match has some paths which can operate on constant instructions,
but not all.  This adds a version of m_value() to return const Value* and
changes ICmp matching to use auto so that it can match both constant and
mutable instructions.

Tests also included for both mutable and constant ICmpInst matching.

This will be used in a future commit to constify ValueTracking.cpp.

llvm-svn: 278570

8 years ago[ADT] Add filter_iterator for filtering elements
Tim Shen [Fri, 12 Aug 2016 22:03:28 +0000 (22:03 +0000)]
[ADT] Add filter_iterator for filtering elements

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

llvm-svn: 278569

8 years ago[NVPTX] Use untyped (.b) integer registers in PTX.
Artem Belevich [Fri, 12 Aug 2016 22:02:19 +0000 (22:02 +0000)]
[NVPTX] Use untyped (.b) integer registers in PTX.

This bring LLVM-generated PTX closer to what nvcc generates and avoids
triggering issues in ptxas.

For instance, ptxas does not accept .s16 (or .u16) registers as operands
for .fp16 instructions.

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

llvm-svn: 278568

8 years agogold: add a cast to appease std::max NFC
Saleem Abdulrasool [Fri, 12 Aug 2016 21:56:12 +0000 (21:56 +0000)]
gold: add a cast to appease std::max NFC

llvm-svn: 278567

8 years ago[PM] BitcodeWriterPass should derive from PassInfoMixin
Teresa Johnson [Fri, 12 Aug 2016 21:33:36 +0000 (21:33 +0000)]
[PM] BitcodeWriterPass should derive from PassInfoMixin

Summary:
The BitcodeWriterPass was ported a couple years ago, and predates the
PassInfoMixin. Make BitcodeWriterPass from that base class.

Should BitcodeWriterPass be added to the PassRegistry.def file? It seems
like that is only for passes that can be added arbitrarily, e.g. via the
-passes flag to the opt tool. Whereas the bitcode writer is added
specially based on the output type (and requires an output stream and
other parameters). For now I have left it out of the PassRegistry, but
let me know if it should go there.

Finally, I was considering an NFC change of the legacy WriteBitcodePass
to BitcodeWriterLegacyPass to make its usage clearer and more consistent
with other legacy passes. WDYT?

Reviewers: mehdi_amini

Subscribers: llvm-commits

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

llvm-svn: 278566

8 years agoFixed typo.
David L Kreitzer [Fri, 12 Aug 2016 21:06:53 +0000 (21:06 +0000)]
Fixed typo.

llvm-svn: 278565

8 years ago[Hexagon] Cleanup and standardize vector load/store pseudo instructions
Krzysztof Parzyszek [Fri, 12 Aug 2016 21:05:05 +0000 (21:05 +0000)]
[Hexagon] Cleanup and standardize vector load/store pseudo instructions

Remove the following single-vector load/store pseudo instructions, use real
instructions instead:
  LDriv_pseudo_V6         STriv_pseudo_V6
  LDriv_pseudo_V6_128B    STriv_pseudo_V6_128B
  LDrivv_indexed          STrivv_indexed
  LDrivv_indexed_128B     STrivv_indexed_128B

Rename the double-vector load/store pseudo instructions, add unaligned
counterparts:

  -- old --               -- new --            -- unaligned --
  LDrivv_pseudo_V6        PS_vloadrw_io        PS_vloadrwu_io
  LDrivv_pseudo_V6_128B   PS_vloadrw_io_128B   PS_vloadrwu_io_128B
  STrivv_pseudo_V6        PS_vstorerw_io       PS_vstorerwu_io
  STrivv_pseudo_V6_128B   PS_vstorerw_io_128   PS_vstorerwu_io_128

llvm-svn: 278564

8 years ago[libFuzzer] fix typo in docs
Kostya Serebryany [Fri, 12 Aug 2016 20:42:24 +0000 (20:42 +0000)]
[libFuzzer] fix typo in docs

llvm-svn: 278563

8 years ago[AArch64LoadStoreOptimizer] Check aliasing correctly when creating paired loads/stores.
Eli Friedman [Fri, 12 Aug 2016 20:39:51 +0000 (20:39 +0000)]
[AArch64LoadStoreOptimizer] Check aliasing correctly when creating paired loads/stores.

The existing code accidentally skipped the aliasing check in edge cases.

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

llvm-svn: 278562

8 years ago[ELF] - Linkerscript: fix VA value assigned to sections when using constraints.
George Rimar [Fri, 12 Aug 2016 20:38:20 +0000 (20:38 +0000)]
[ELF] - Linkerscript: fix VA value assigned to sections when using constraints.

Previously we searched output section by name to assign VA. That did not
work in the case when multiple output sections with different constraints were defined in script.
Testcase shows the possible issue scenario, patch fixes the issue.

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

llvm-svn: 278561

8 years ago[AArch64] Registering default MCInstrAnalysis
Mike Aizatsky [Fri, 12 Aug 2016 20:28:05 +0000 (20:28 +0000)]
[AArch64] Registering default MCInstrAnalysis

Even in this form it is useful: it can detect branch instructions.

https://github.com/google/sanitizers/issues/706

Subscribers: aemerson, rengolin

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

llvm-svn: 278560

8 years ago[AArch64LoadStoreOpt] Handle offsets correctly for post-indexed paired loads.
Eli Friedman [Fri, 12 Aug 2016 20:28:02 +0000 (20:28 +0000)]
[AArch64LoadStoreOpt] Handle offsets correctly for post-indexed paired loads.

Trunk would try to create something like "stp x9, x8, [x0], #512", which isn't actually a valid instruction.

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

llvm-svn: 278559

8 years agoRemove autoconf references from LICENSE.TXT
Chris Bieneman [Fri, 12 Aug 2016 20:11:03 +0000 (20:11 +0000)]
Remove autoconf references from LICENSE.TXT

Since we don't actually have the autoconf subdirectories anymore, we don't need this reference here.

llvm-svn: 278558

8 years agoNext set of additional error checks for invalid Mach-O files.
Kevin Enderby [Fri, 12 Aug 2016 20:10:25 +0000 (20:10 +0000)]
Next set of additional error checks for invalid Mach-O files.

This contains the two missing checks for LC_SEGMENT load command fields.
And checks for the Mach-O sections fields that would make them invalid.

With the new checks, some of the existing malformed file checks now trips one
of these instead of the issue it was having before so those tests were adjusted.

llvm-svn: 278557

8 years ago[sancov] test file cleanup
Mike Aizatsky [Fri, 12 Aug 2016 20:06:32 +0000 (20:06 +0000)]
[sancov] test file cleanup

llvm-svn: 278556

8 years ago[ELF] - Do not use mergeable sections when LS is used.
George Rimar [Fri, 12 Aug 2016 19:56:57 +0000 (19:56 +0000)]
[ELF] - Do not use mergeable sections when LS is used.

After latest changes we combine input sections with
different attributes into single output section.
Problem here is that regular output sections does not
support adding mergeable input sections (and vise versa).
Patch just temporarily disables merging for now at
the same way we do for -O0 for example.

This change helps for linking FreeBSD kernel.

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

llvm-svn: 278555

8 years ago[ELF] - Remove excessive loop in LinkerScript<ELFT>::assignAddresses()
George Rimar [Fri, 12 Aug 2016 19:32:45 +0000 (19:32 +0000)]
[ELF] - Remove excessive loop in LinkerScript<ELFT>::assignAddresses()

After 278461 "Create only one section for a name in LinkerScript."
this loop is excessive.
Patch also reorders code slightly to use early return.

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

llvm-svn: 278554

8 years ago[clang-tidy] MPIBufferDerefCheck
Alexander Droste [Fri, 12 Aug 2016 19:30:31 +0000 (19:30 +0000)]
[clang-tidy] MPIBufferDerefCheck
...
This check verifies if a buffer passed to an MPI (Message Passing Interface)
function is sufficiently dereferenced. Buffers should be passed as a single
pointer or array. As MPI function signatures specify void * for their buffer
types, insufficiently dereferenced buffers can be passed, like for example
as double pointers or multidimensional arrays, without a compiler warning
emitted.

Instructions on how to apply the check can be found at:
https://github.com/0ax1/MPI-Checker/tree/master/examples

Reviewers: Haojian Wu
Differential revision: https://reviews.llvm.org/D22729

llvm-svn: 278553

8 years agofix lldb-gtest target of Xcode build
Todd Fiala [Fri, 12 Aug 2016 19:27:05 +0000 (19:27 +0000)]
fix lldb-gtest target of Xcode build

Change r278527 was filtering out too many libraries.
The Xcode lldb-gtest target depends on linking libgtest*.a,
but those were not being included.  This caused the lldb-gtest
linkage step to fail to find a main entry point that is present
in the filtered out libs.

This change restores the libgtest* libraries to the link list
by whitelisting them in the filter.

llvm-svn: 278552

8 years ago[sancov] MachO indirect symbols support.
Mike Aizatsky [Fri, 12 Aug 2016 19:25:59 +0000 (19:25 +0000)]
[sancov] MachO indirect symbols support.

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

llvm-svn: 278551

8 years ago[ELF] - Fix for: error "invalid section index: xxx" when linking FreeBSD kernel.
George Rimar [Fri, 12 Aug 2016 19:25:54 +0000 (19:25 +0000)]
[ELF] - Fix for: error "invalid section index: xxx" when linking FreeBSD kernel.

We found that GNU assembler 2.17.50 [FreeBSD] 2007-07-03
could generate broken objects. STT_SECTION symbols can be
associated with SHT_REL[A]/SHT_SYMTAB/SHT_STRTAB sections.

This is PR28868, patch fixes handling of such files.

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

llvm-svn: 278550

8 years ago[CUDA] Place GPU binary into .nv_fatbin section and align it by 8.
Artem Belevich [Fri, 12 Aug 2016 18:44:01 +0000 (18:44 +0000)]
[CUDA] Place GPU binary into .nv_fatbin section and align it by 8.

This matches the way nvcc encapsulates GPU binaries into host object file.
Now cuobjdump can deal with clang-compiled object files.

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

llvm-svn: 278549

8 years ago[PPC] Memoize getValueBits. NFC.
Tim Shen [Fri, 12 Aug 2016 18:40:04 +0000 (18:40 +0000)]
[PPC] Memoize getValueBits. NFC.

Summary: It triggers exponential behavior when the DAG has many branches.

Reviewers: hfinkel, kbarton

Subscribers: iteratee, nemanjai, echristo

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

llvm-svn: 278548

8 years agoRemove accidentally committed file.
Zachary Turner [Fri, 12 Aug 2016 18:39:05 +0000 (18:39 +0000)]
Remove accidentally committed file.

llvm-svn: 278547

8 years agoAnalyze include order on a per-file basis.
Zachary Turner [Fri, 12 Aug 2016 18:38:26 +0000 (18:38 +0000)]
Analyze include order on a per-file basis.

The include order check would get notified of all include
directives in a depth-first manner.  This created the
possibility of an include directive from a header file
interfering with the sort order of a set of two distinct
blocks from the top level cpp file, if that include directive
was on just the right line.

With this patch we bucket the include directives by the file
in which they appear in and process one bucket at a time,
so that directives from different files do not get mixed
together into the same list.

Reviewed By: alexfh
Differential Revision: https://reviews.llvm.org/D23434

llvm-svn: 278546

8 years ago[WebAssembly] Plug MachineMemOperand leaks.
Benjamin Kramer [Fri, 12 Aug 2016 18:33:50 +0000 (18:33 +0000)]
[WebAssembly] Plug MachineMemOperand leaks.

llvm-svn: 278545

8 years ago[LibFuzzer] Fix `-jobs=<N>` where <N> > 1 and the number of workers is > 1 on macOS.
Dan Liew [Fri, 12 Aug 2016 18:29:36 +0000 (18:29 +0000)]
[LibFuzzer] Fix `-jobs=<N>` where <N> > 1 and the number of workers is > 1 on macOS.

The original `ExecuteCommand()` called `system()` from the C library.
The C library implementation of this on macOS contains a mutex which
serializes calls to `system()`. This prevented the `-jobs=` flag
from running copies of the fuzzing binary in parallel which is
the opposite of what is intended.

To fix this on macOS an alternative implementation of `ExecuteCommand()`
is provided that can be used concurrently. This is provided in
`FuzzerUtilDarwin.cpp` which is guarded to only compile code on Apple
platforms. The existing implementation has been moved to a new file
`FuzzerUtilLinux.cpp` which is guarded to only compile code on Linux.

This commit includes a simple test to check that LibFuzzer is being
executed in parallel when requested.

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

llvm-svn: 278544

8 years agoReapply [VFS] Skip non existent files from the VFS tree
Bruno Cardoso Lopes [Fri, 12 Aug 2016 18:18:24 +0000 (18:18 +0000)]
Reapply [VFS] Skip non existent files from the VFS tree

Reapply r278457 with test fixed to not abouse fs case sensitivity.

When the VFS uses a YAML file, the real file path for a
virtual file is described in the "external-contents" field. Example:

  ...
  {
     'type': 'file',
     'name': 'a.h',
     'external-contents': '/a/b/c/a.h'
  }

Currently, when parsing umbrella directories, we use
vfs::recursive_directory_iterator to gather the header files to generate the
equivalent modules for. If the external contents for a header does not exist,
we currently are unable to build a module, since the VFS
vfs::recursive_directory_iterator will fail when it finds an entry without a
reliable real path.

Since the YAML file could be prepared ahead of time and shared among
different compiler invocations, an entry might not yet have a reliable
path in 'external-contents', breaking the iteration.

Give the VFS the capability to skip such entries whenever
'ignore-non-existent-contents' property is set in the YAML file.

rdar://problem/27531549

llvm-svn: 278543

8 years agoADT: Remove stale header comments about next/prev after r278532
Duncan P. N. Exon Smith [Fri, 12 Aug 2016 18:14:42 +0000 (18:14 +0000)]
ADT: Remove stale header comments about next/prev after r278532

Thanks to Mehdi for noticing.

llvm-svn: 278542

8 years agoCodeGen: Replace ThinLTO backend implementation with a client of LTO/Resolution.
Teresa Johnson [Fri, 12 Aug 2016 18:12:08 +0000 (18:12 +0000)]
CodeGen: Replace ThinLTO backend implementation with a client of LTO/Resolution.

Summary:
This changes clang to use the llvm::lto::thinBackend function instead of
its own less comprehensive ThinLTO backend implementation.

Patch by Peter Collingbourne

Reviewers: tejohnson, mehdi_amini

Subscribers: cfe-commits, mehdi_amini

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

llvm-svn: 278541

8 years agoHide type trait from r278532 from MSVC
Duncan P. N. Exon Smith [Fri, 12 Aug 2016 18:10:29 +0000 (18:10 +0000)]
Hide type trait from r278532 from MSVC

The fixup from r278537 was insufficient.  Just #ifdef it out for MSVC.

llvm-svn: 278539

8 years agoTry to appease win7 bots after r278532 by cleaning up type trait
Duncan P. N. Exon Smith [Fri, 12 Aug 2016 17:54:54 +0000 (17:54 +0000)]
Try to appease win7 bots after r278532 by cleaning up type trait

The HasGetNext type trait was cluttered with a few things it didn't
need.  Try to clean it up, hoping to fix windows bots:
  http://lab.llvm.org:8011/builders/lld-x86_64-win7/builds/38063

I may just have to delete the trait...

llvm-svn: 278537

8 years agoRemove whitespace
David Majnemer [Fri, 12 Aug 2016 17:53:06 +0000 (17:53 +0000)]
Remove whitespace

llvm-svn: 278536

8 years ago[Driver] Set the default driver mode based on the executable.
Zachary Turner [Fri, 12 Aug 2016 17:47:52 +0000 (17:47 +0000)]
[Driver] Set the default driver mode based on the executable.

Currently, if --driver-mode is not passed at all, it will default
to GCC style driver.  This is never an issue for clang because
it manually constructs a --driver-mode option and passes it.

However, we should still try to do as good as we can even if no
--driver-mode is passed.  LibTooling, for example, does not pass
a --driver-mode option and while it could, it seems like we should
still fallback to the best possible default we can.

This is one of two steps necessary to get clang-tidy working on Windows.

Reviewed By: rnk
Differential Revision: https://reviews.llvm.org/D23454

llvm-svn: 278535

8 years agoRevert test commit
Alexander Droste [Fri, 12 Aug 2016 17:46:23 +0000 (17:46 +0000)]
Revert test commit

llvm-svn: 278534

8 years agoTest commit - first LLVM repo commit
Alexander Droste [Fri, 12 Aug 2016 17:43:58 +0000 (17:43 +0000)]
Test commit - first LLVM repo commit

llvm-svn: 278533

8 years agoADT: Remove the ilist_nextprev_traits customization point
Duncan P. N. Exon Smith [Fri, 12 Aug 2016 17:32:34 +0000 (17:32 +0000)]
ADT: Remove the ilist_nextprev_traits customization point

No one is using the capability to implement next and prev another way
(since lld stopped doing it in r278468).  Remove the customization point
by moving the API from ilist_nextprev_traits<T> to ilist_node_access.

The old traits class is still useful/necessary API as a target for
friends of node types that inherit privately from ilist_node.
Eventually I plan to either remove it entirely or move the template
parameters to the methods.

(Note: if there's desire to bring back customization of next/prev
pointers in the future (e.g., to pack some bits in there), I think a
traits class like this is an awkward way to accomplish it.  Instead, we
should change ilist<T> to be ilist<ilist_node<T>>, and give an extra
template parameter to ilist_node.)

llvm-svn: 278532

8 years ago[PM] Port LowerInvoke to the new pass manager
Michael Kuperstein [Fri, 12 Aug 2016 17:28:27 +0000 (17:28 +0000)]
[PM] Port LowerInvoke to the new pass manager

llvm-svn: 278531

8 years agoAdd compiler-rt side test for no_sanitize("cfi") attribute
Ivan Krasin [Fri, 12 Aug 2016 17:26:37 +0000 (17:26 +0000)]
Add compiler-rt side test for no_sanitize("cfi") attribute

Summary: Add a test case for __attribute__((no_sanitize("cfi"))) being effective.

Reviewers: kcc

Subscribers: dberris

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

llvm-svn: 278530

8 years agoDisable TestThreadSpecificBpPlusCondition on Windows.
Zachary Turner [Fri, 12 Aug 2016 17:15:38 +0000 (17:15 +0000)]
Disable TestThreadSpecificBpPlusCondition on Windows.

Test frequently times out stalling the test runner.

llvm-svn: 278529

8 years agoconstify InstCombine::foldAllocaCmp. NFC.
Pete Cooper [Fri, 12 Aug 2016 17:13:28 +0000 (17:13 +0000)]
constify InstCombine::foldAllocaCmp.  NFC.

This is part of an effort to constify ValueTracking.cpp.  This change is
to methods which need const Value* instead of Value* to go with the upcoming
changes to ValueTracking.

llvm-svn: 278528

8 years agoLink LLDB only against libclang and libLLVM .a files to fix macOS build
Todd Fiala [Fri, 12 Aug 2016 17:01:19 +0000 (17:01 +0000)]
Link LLDB only against libclang and libLLVM .a files to fix macOS build

The Xcode macOS build of LLDB is currently broken after
https://reviews.llvm.org/D23232 landed, see
http://lab.llvm.org:8080/green/job/lldb_build_test/20014/console,
because we’re trying to link against all .a files found in the
llvm-build/lib directory. Let’s be more specific in what we link
against. This patch applies a regexp to only use “libclang.*”,
“libLLVM.*” and not “libclang_rt.*” static archives.

Change by Kuba Mracek (formerly Kuba Brecka)

See review here:
https://reviews.llvm.org/D23444

Reviewers: tfiala, compnerd
llvm-svn: 278527

8 years agoFix build on Windows.
Zachary Turner [Fri, 12 Aug 2016 16:52:31 +0000 (16:52 +0000)]
Fix build on Windows.

llvm-svn: 278526

8 years agoBugReporter: Use ilist_half_embedded_sentinel_traits, NFC
Duncan P. N. Exon Smith [Fri, 12 Aug 2016 16:46:25 +0000 (16:46 +0000)]
BugReporter: Use ilist_half_embedded_sentinel_traits, NFC

This avoids duplicated code with llvm/ADT/ilist.h.  No functionality
change.

llvm-svn: 278525

8 years agoSwitch over to using socketpair for local debugserver connections as they are twice...
Greg Clayton [Fri, 12 Aug 2016 16:46:18 +0000 (16:46 +0000)]
Switch over to using socketpair for local debugserver connections as they are twice as fast as TCP sockets (on macOS at least).

This change opens a socket pair and passes the second socket pair file descriptor down to the debugserver binary using a new option: "--fd=N" where N is the file descriptor. This file descriptor gets passed via posix_spawn() so that there is no need to do any bind/listen or bind/accept calls and eliminates the hanshake unix socket that is used to pass the result of the actual port that ends up being used so it can save time on launch as well as being faster.

This is currently only enabled on __APPLE__ builds. Other OSs should try modifying the #define from ProcessGDBRemote.cpp but the first person will need to port the --fd option over to lldb-server. Any OSs that enable USE_SOCKETPAIR_FOR_LOCAL_CONNECTION in their native builds can use the socket pair stuff. The #define is Apple only right now, but looks like:

#if defined (__APPLE__)
#define USE_SOCKETPAIR_FOR_LOCAL_CONNECTION 1
#endif

<rdar://problem/27814880>

llvm-svn: 278524

8 years agoMachO: Use ilist_half_embedded_sentinel_traits, NFC
Duncan P. N. Exon Smith [Fri, 12 Aug 2016 16:25:04 +0000 (16:25 +0000)]
MachO: Use ilist_half_embedded_sentinel_traits, NFC

Use ilist_half_embedded_sentinel_traits for the list of
lld::mach_o::normalized::TrieEdge, rather than duplicating the code.

llvm-svn: 278523

8 years agoFine tuning of sample profile propagation algorithm.
Dehao Chen [Fri, 12 Aug 2016 16:22:12 +0000 (16:22 +0000)]
Fine tuning of sample profile propagation algorithm.

Summary: The refined propagation algorithm is more accurate and robust.

Reviewers: davidxl, dnovillo

Subscribers: llvm-commits

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

llvm-svn: 278522

8 years agoCore: Use ilist_full_embedded_sentinel_traits for SimpleReference
Duncan P. N. Exon Smith [Fri, 12 Aug 2016 16:19:34 +0000 (16:19 +0000)]
Core: Use ilist_full_embedded_sentinel_traits for SimpleReference

Avoid custom code for sentinel traits in SimpleReference (the ilist node
for references to a SimpleDefinedAtom), since they'll soon/eventually
disappear from ilist entirely.

Rather than using a BumpPtrAllocator, this drops the lazy sentinel
characteristics and stores the sentinel directly in the ilist.  This
unconditionally allocates the sentinel.

At first glance, this looks like it might increase memory usage
slightly, since an unreferenced SimpleDefinedAtom pays for a
6-pointer-sized sentinel even when its list of references is empty.  In
practice, the sentinel was being lazily allocated at the first call to
DefinedAtom::begin/end anyway.  I don't expect any real memory effects
here.

Moreover, this is an intermediate state.  The ilist_*sentinel_traits are
being phased out.

As a preview of the final state: in lieu of a NodeTy sentinel, the ilist
will have a single, untemplated list_node_base that has next/prev
pointers.  This base node will serve both as a sentinel and as a pointer
to the head of the list (the same memory layout as
ilist_half_embedded_sentinel_traits, but without the UB).

llvm-svn: 278521

8 years ago[x86] X86ISelLowering zext(add_nuw(x, C)) --> add(zext(x), C_zext)
Artur Pilipenko [Fri, 12 Aug 2016 16:08:30 +0000 (16:08 +0000)]
[x86] X86ISelLowering zext(add_nuw(x, C)) --> add(zext(x), C_zext)

Currently X86ISelLowering has a similar transformation for sexts:
sext(add_nsw(x, C)) --> add(sext(x), C_sext)

In this change I extend this code to handle zexts as well.

Reviewed By: spatel

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

llvm-svn: 278520

8 years ago[BasicAA] Avoid calling GetUnderlyingObject, when the result of a previous call can...
Ehsan Amiri [Fri, 12 Aug 2016 16:05:03 +0000 (16:05 +0000)]
[BasicAA] Avoid calling GetUnderlyingObject, when the result of a previous call can be reused.

Recursive calls to aliasCheck from alias[GEP|Select|PHI] may result in a second call to GetUnderlyingObject for a Value, whose underlying object is already computed. This patch ensures that in this situations, the underlying object is not computed again, and the result of the previous call is resued.

https://reviews.llvm.org/D22305

llvm-svn: 278519

8 years ago[LVI] Take guards into account
Artur Pilipenko [Fri, 12 Aug 2016 15:52:23 +0000 (15:52 +0000)]
[LVI] Take guards into account

Teach LVI to gather control dependant constraints from guards.

Reviewed By: sanjoy

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

llvm-svn: 278518

8 years agoAdd move ops to satisfy MSVC.
Teresa Johnson [Fri, 12 Aug 2016 15:39:26 +0000 (15:39 +0000)]
Add move ops to satisfy MSVC.

Try to appease Windows bots after r278508:
http://lab.llvm.org:8011/builders/sanitizer-windows/builds/27250
http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/builds/14776

llvm-svn: 278517

8 years ago[mips] Remove obstack.cc XFAIL added in r278504 since it broke X86 and PPC somehow.
Daniel Sanders [Fri, 12 Aug 2016 15:34:35 +0000 (15:34 +0000)]
[mips] Remove obstack.cc XFAIL added in r278504 since it broke X86 and PPC somehow.

Adding the XFAIL has caused msan to report a different line number in the call
stack (@LINE-3 rather than @LINE-30). The new line number looks more correct
at first glance since it's the line that uses uninitialized memory rather than
the first non-whitespace line of the file but this needs investigating.

llvm-svn: 278516

8 years ago[AArch64] Re-factor code shared by AArch64LoadStoreOpt and AArch64InstrInfo.
Geoff Berry [Fri, 12 Aug 2016 15:26:00 +0000 (15:26 +0000)]
[AArch64] Re-factor code shared by AArch64LoadStoreOpt and AArch64InstrInfo.

This re-factoring could cause the following slight changes in generated
code, though none were observed during testing:

- MachineScheduler could decide not to cluster some loads/stores if
  there are other load/stores with non-pairable opcodes that have the
  same base register and offset as a pairable set of load/stores.  One
  case of different MachineScheduler pairing did show up in my testing,
  but it wasn't due to this issue, but due
  BaseMemOpClusterMutation::clusterNeighboringMemOps() being unstable
  w.r.t. the order it considers memory operations.  See PR28942.

- The ImplicitNullChecks optimization could be done for more load/store
  opcodes.  This optimization isn't done for C/C++ code, so it didn't
  show up in my testing.

Reviewers: mcrosier, t.p.northover

Subscribers: aemerson, rengolin, mcrosier, llvm-commits

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

llvm-svn: 278515

8 years ago[LVI] Fix potential memory corruption in getValueFromCondition
Artur Pilipenko [Fri, 12 Aug 2016 15:08:15 +0000 (15:08 +0000)]
[LVI] Fix potential memory corruption in getValueFromCondition

Rewrite Visited[Cond] = getValueFromConditionImpl(..., Visited) statement which can lead to a memory corruption since getValueFromConditionImpl changes Visited map and invalidates the iterators.

llvm-svn: 278514

8 years agoADT: Share code for embedded sentinel traits, NFC
Duncan P. N. Exon Smith [Fri, 12 Aug 2016 15:00:55 +0000 (15:00 +0000)]
ADT: Share code for embedded sentinel traits, NFC

Share code for the (mostly problematic) embedded sentinel traits.
- Move the LLVM_NO_SANITIZE("object-size") attribute to
  ilist_half_embedded_sentinel_traits and ilist_embedded_sentinel_traits
  (previously it spread throughout the code duplication).
- Add an ilist_full_embedded_sentinel_traits which has no UB (but has
  the downside of storing the complete node).
- Replace all the custom sentinel traits in LLVM with a declaration of
  ilist_sentinel_traits that inherits from one of the embedded sentinel
  traits classes.

There are still custom sentinel traits in other LLVM subprojects.  I'll
remove those in a follow-up.

Nothing at all should be changing here, this is just rearranging code.
Note that the final goal here is to remove the sentinel traits
altogether, settling on the memory layout of
ilist_half_embedded_sentinel_traits without the UB.  This intermediate
step moves the logic into ilist.h.

llvm-svn: 278513

8 years agoFix type to avoid problems on 32-bit builds
Teresa Johnson [Fri, 12 Aug 2016 14:55:43 +0000 (14:55 +0000)]
Fix type to avoid problems on 32-bit builds

lto::InputFile::Symbol::getCommonSize should return uint64_t instead of
size_t since it is returning the result of DataLayout::getTypeAllocSize
which returns uint64_t, and the result of getCommonSize is assigned to a
uint64_t variable. On 32-bit builds size_t is unsigned int and there are
type errors. This was introduced in r278338.

llvm-svn: 278512

8 years agoRevert "[Sparc] Leon errata fix passes."
James Y Knight [Fri, 12 Aug 2016 14:48:09 +0000 (14:48 +0000)]
Revert "[Sparc] Leon errata fix passes."
...and the two followup commits:
Revert "[Sparc][Leon] Missed resetting option flags from check-in 278489."
Revert "[Sparc][Leon] Errata fixes for various errata in different
versions of the Leon variants of the Sparc 32 bit processor."

This reverts commit r274856, r278489, and r278492.

llvm-svn: 278511

8 years agoSkip 2 android test what is broken because of debuggerd
Tamas Berghammer [Fri, 12 Aug 2016 14:17:05 +0000 (14:17 +0000)]
Skip 2 android test what is broken because of debuggerd

debuggerd is a crash reporting system on android what installs some
signal handler for SEGV to print a backtrace in the log. Its behavior
breaks tests where the test tries to continue after a SEGV so we skip
them as this behavior isn't required on android anyway.

llvm-svn: 278510

8 years ago[PM] Port NameAnonFunction pass to new pass manager
Teresa Johnson [Fri, 12 Aug 2016 14:03:36 +0000 (14:03 +0000)]
[PM] Port NameAnonFunction pass to new pass manager

Summary:
Port the NameAnonFunction pass and add a test.

Depends on D23439.

Reviewers: mehdi_amini

Subscribers: llvm-commits, mehdi_amini

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

llvm-svn: 278509

8 years ago[PM] Port ModuleSummaryIndex analysis to new pass manager
Teresa Johnson [Fri, 12 Aug 2016 13:53:02 +0000 (13:53 +0000)]
[PM] Port ModuleSummaryIndex analysis to new pass manager

Summary:
Port the ModuleSummaryAnalysisWrapperPass to the new pass manager.
Use it in the ported BitcodeWriterPass (similar to how we use the
legacy ModuleSummaryAnalysisWrapperPass in the legacy WriteBitcodePass).

Also, pass the -module-summary opt flag through to the new pass
manager pipeline and through to the bitcode writer pass, and add
a test that uses it.

Reviewers: mehdi_amini

Subscribers: llvm-commits, mehdi_amini

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

llvm-svn: 278508