platform/upstream/llvm.git
6 years ago[DAGCombiner] Generalize (and (or x, C), D) -> D iff (C & D) == D combine to work...
Simon Pilgrim [Thu, 21 Dec 2017 15:17:29 +0000 (15:17 +0000)]
[DAGCombiner] Generalize (and (or x, C), D) -> D iff (C & D) == D combine to work on non-splat vectors

llvm-svn: 321275

6 years ago[mips] Fix the invalid EVA test
Simon Dardis [Thu, 21 Dec 2017 15:14:07 +0000 (15:14 +0000)]
[mips] Fix the invalid EVA test

During the review of D40362 I spotted that this test wasn't actually
testing the eva instructions due to '-mattr==eva', rather than '-mattr=+eva',
which resulted in test having no effect.

llvm-svn: 321273

6 years ago[clangd] Index symbols share storage within a slab.
Sam McCall [Thu, 21 Dec 2017 14:58:44 +0000 (14:58 +0000)]
[clangd] Index symbols share storage within a slab.

Summary:
Symbols are not self-contained - it's only safe to hand them out if you
guarantee the lifetime of the underlying data.

Before this lands, I'm going to measure the before/after memory usage of the
LLVM index loaded into memory in a single slab.

Reviewers: hokein

Subscribers: klimek, ilya-biryukov, cfe-commits

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

llvm-svn: 321272

6 years agoWork around test failures on red-hat linux
Pavel Labath [Thu, 21 Dec 2017 14:40:03 +0000 (14:40 +0000)]
Work around test failures on red-hat linux

Two tests were failing because the debugger was picking up multiply
defined internal symbols from the system libraries. This is a bug, as
there should be no ambiguity because the tests are defining variables
with should shadow these symbols, but lldb is not smart enough to figure
that out.

I work around the issue by renaming the variables in these tests, and in
exchange I create a self-contained test which reproduces the issue
without depending on the system libraries.

This increases the predictability of our test suite.

llvm-svn: 321271

6 years agoAdd missing test case from D41171 commit
Joachim Protze [Thu, 21 Dec 2017 14:36:36 +0000 (14:36 +0000)]
Add missing test case from D41171 commit

llvm-svn: 321270

6 years ago[OMPT] Add missing ompt_get_num_procs function
Joachim Protze [Thu, 21 Dec 2017 14:36:30 +0000 (14:36 +0000)]
[OMPT] Add missing ompt_get_num_procs function

This function is defined in OpenMP-TR6 section 4.1.5.1.6
The functions was not implemented yet.

Since ompt-functions can only be called after the runtime was initialized and
has loaded a tool, it can assume the runtime to be initialized. In contrast
to omp_get_num_procs which needs to check whether the runtime is initialized.

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

llvm-svn: 321269

6 years ago[X86] Add (and (or x, C), D) -> D iff (C & D) == D non-splat vector test
Simon Pilgrim [Thu, 21 Dec 2017 14:33:40 +0000 (14:33 +0000)]
[X86] Add (and (or x, C), D) -> D iff (C & D) == D non-splat vector test

llvm-svn: 321268

6 years ago[clangd] Log more info about preambles
Ilya Biryukov [Thu, 21 Dec 2017 14:05:28 +0000 (14:05 +0000)]
[clangd] Log more info about preambles

llvm-svn: 321267

6 years agoAdded helper to get size of PrecompiledPreamble
Ilya Biryukov [Thu, 21 Dec 2017 14:04:39 +0000 (14:04 +0000)]
Added helper to get size of PrecompiledPreamble

llvm-svn: 321266

6 years ago[OMPT] Fix return address handling in a few GOMP interface methods
Joachim Protze [Thu, 21 Dec 2017 13:55:39 +0000 (13:55 +0000)]
[OMPT] Fix return address handling in a few GOMP interface methods

This revision fixes failing testcases with parallel for loops and the gomp
interface. The return address needs to be stored at entry to runtime.
The storage is cleared on usage, so we need to update the storage before
calling again internal functions, that will trigger event callbacks.

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

llvm-svn: 321265

6 years ago[OMPT] Handle null pointer in set_callback to improve performance
Joachim Protze [Thu, 21 Dec 2017 13:55:34 +0000 (13:55 +0000)]
[OMPT] Handle null pointer in set_callback to improve performance

We use the bitmap ompt_enabled thoughout the runtime, to avoid loading the
vector of callback functions when testing if specific code should be executed.
Before invoking an event callback function, the pointer is tested for NULL.

This revision resets the corresponding bit in ompt_enabled to 0 if
NULL is passed in set_callback.

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

llvm-svn: 321264

6 years ago[OMPT] Use frames at different level when using clang version 5 or higher with debug...
Joachim Protze [Thu, 21 Dec 2017 13:55:29 +0000 (13:55 +0000)]
[OMPT] Use frames at different level when using clang version 5 or higher with debug flag

Clang 5 or higher adds an intermediate function call in certain cases when
compiling with debug flag. This revision updates the testcases to work
correctly.

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

llvm-svn: 321263

6 years ago[OMPT] Add annotations to testcases that are expected to fail when using certain...
Joachim Protze [Thu, 21 Dec 2017 13:55:16 +0000 (13:55 +0000)]
[OMPT] Add annotations to testcases that are expected to fail when using certain compilers

Reasons for expected failures are mainly bugs when using lables in OpenMP regions
or missing support of some OpenMP features.
For some worksharing clauses, support to distinguish the kind of workshare was
added just recently.

If an issue was fixed in a minor release version of a compiler, we flag the
test as unsupported for this compiler version to avoid false positives.
Same for fixes that where backported to older compiler versions.

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

llvm-svn: 321262

6 years ago[X86] Add v48i8 AVG test case, based on discussion on D41440
Simon Pilgrim [Thu, 21 Dec 2017 13:18:19 +0000 (13:18 +0000)]
[X86] Add v48i8 AVG test case, based on discussion on D41440

llvm-svn: 321261

6 years ago[mips][compiler-rt] Provide 64bit atomic add and sub
Simon Dardis [Thu, 21 Dec 2017 13:05:41 +0000 (13:05 +0000)]
[mips][compiler-rt] Provide 64bit atomic add and sub

r318733 introduced a build failure for native MIPS32 systems for xray due
to the lack of __sync_fetch_and_add / __syn_fetch_and_sub support. This patch
extends the existing support providing atomics so that xray can be
successfully built.

Reviewers: atanasyan, dberris

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

llvm-svn: 321260

6 years ago[DAGCombine] Improve ReduceLoadWidth for SRL
Sam Parker [Thu, 21 Dec 2017 12:55:04 +0000 (12:55 +0000)]
[DAGCombine] Improve ReduceLoadWidth for SRL

If the SRL node is only used by an AND, we may be able to set the
ExtVT to the width of the mask, making the AND redundant. To support
this, another check has been added in isLegalNarrowLoad which queries
whether the load is valid.

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

llvm-svn: 321259

6 years ago[AArch64] add required arch specific code for running OMPT test cases
Paul Osmialowski [Thu, 21 Dec 2017 12:33:31 +0000 (12:33 +0000)]
[AArch64] add required arch specific code for running OMPT test cases

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

llvm-svn: 321258

6 years ago[Support] Remove MemoryBuffer::getNewUninitMemBuffer
Pavel Labath [Thu, 21 Dec 2017 11:27:21 +0000 (11:27 +0000)]
[Support] Remove MemoryBuffer::getNewUninitMemBuffer

There is nothing useful that can be done with a read-only uninitialized
buffer without const_casting its contents to initialize it. A better
solution is to obtain a writable buffer
(WritableMemoryBuffer::getNewUninitMemBuffer), and then convert it to a
read-only buffer after initialization. All callers of this function have
already been updated to do this, so this function is now unused.

llvm-svn: 321257

6 years ago[ARM] Armv8-R DFB instruction
Sam Parker [Thu, 21 Dec 2017 11:17:49 +0000 (11:17 +0000)]
[ARM] Armv8-R DFB instruction

Implement MC support for the Armv8-R 'Data Full Barrier' instruction.

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

llvm-svn: 321256

6 years agoMake sure DataBufferLLVM contents are writable
Pavel Labath [Thu, 21 Dec 2017 10:54:30 +0000 (10:54 +0000)]
Make sure DataBufferLLVM contents are writable

Summary:
We sometimes need to write to the object file we've mapped into memory,
generally to apply relocations to debug info sections. We've had that
ability before, but with the introduction of DataBufferLLVM, we have
lost it, as the underlying llvm class (MemoryBuffer) only supports
read-only mappings.

This switches DataBufferLLVM to use the new llvm::WritableMemoryBuffer
class as a back-end, as this one guarantees to return a writable buffer.

This removes the need for the "Private" flag to the DataBufferLLVM
creation functions, as it was really used to mean "writable". The LLVM
function also does not have the NullTerminate flag, so I've modified our
clients to not require this feature and removed that flag as well.

Reviewers: zturner, clayborg, jingham

Subscribers: emaste, aprantl, arichardson, krytarowski, lldb-commits

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

llvm-svn: 321255

6 years ago[llvm-readobj] Fix ambiguous call to the `printNumber`
Simon Atanasyan [Thu, 21 Dec 2017 10:46:20 +0000 (10:46 +0000)]
[llvm-readobj] Fix ambiguous call to the `printNumber`

llvm-svn: 321254

6 years ago[llvm-readobj] Support 'GNU' style for MIPS GOT/PLT dumping
Simon Atanasyan [Thu, 21 Dec 2017 10:26:02 +0000 (10:26 +0000)]
[llvm-readobj] Support 'GNU' style for MIPS GOT/PLT dumping

This change adds `printMipsGOT` and `printMipsPLT` methods to the
`DumpStyle` class and overrides them in the `GNUStyle` and `LLVMStyle`
descendants. To pass information about GOT/PLT layout into these
methods, the `MipsGOTParser` class has been extended to hold all
necessary data.

llvm-svn: 321253

6 years ago[clangd] Use the clang-tools-extra as the official repo for `vscode-clangd` extension.
Haojian Wu [Thu, 21 Dec 2017 08:45:18 +0000 (08:45 +0000)]
[clangd] Use the clang-tools-extra as the official repo for `vscode-clangd` extension.

Summary:
Previously, we use a separate GitHub repository (https://github.com/llvm-vs-code-extensions/vscode-clangd)
for publishing `vscode-clangd` extension to marketplace.

To reduce the maintain burden, we will use the vscode extension in the
clang-tools-extra, and deprecate the one on GitHub.

Test in https://marketplace.visualstudio.com/items?itemName=llvm-vs-code-extensions.clangd-vscode-test

Reviewers: sammccall, krasimir

Reviewed By: sammccall

Subscribers: klimek, ilya-biryukov, cfe-commits

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

llvm-svn: 321252

6 years ago[X86] Use PSHUFB for v32i16 shuffles before falling back to VPERMW/VPERMI2W.
Craig Topper [Thu, 21 Dec 2017 08:22:51 +0000 (08:22 +0000)]
[X86] Use PSHUFB for v32i16 shuffles before falling back to VPERMW/VPERMI2W.

PSHUFB has the ability to implicitly 0 elements which VPERMI2W can't do. So give a chance to use it first.

llvm-svn: 321251

6 years ago[CodeGen] Fix access sizes in new-format TBAA tags
Ivan A. Kosarev [Thu, 21 Dec 2017 08:14:16 +0000 (08:14 +0000)]
[CodeGen] Fix access sizes in new-format TBAA tags

The new format requires to specify both the type of the access
and its size. This patch fixes setting access sizes for TBAA tags
that denote accesses to structure members. This fix affects all
future TBAA metadata tests for the new format, so I guess we
don't need any special tests for this fix.

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

llvm-svn: 321250

6 years ago[X86] Use VPERMI2B for v16i8 shuffles if we have VBMI+VLX and would have otherwise...
Craig Topper [Thu, 21 Dec 2017 07:31:30 +0000 (07:31 +0000)]
[X86] Use VPERMI2B for v16i8 shuffles if we have VBMI+VLX and would have otherwise used two PSHUFBs ORed together.

llvm-svn: 321249

6 years ago[X86] Use VPERMB/VPERMI2B for v32i8 shuffle lowering if VBMI and VLX are supported.
Craig Topper [Thu, 21 Dec 2017 05:58:31 +0000 (05:58 +0000)]
[X86] Use VPERMB/VPERMI2B for v32i8 shuffle lowering if VBMI and VLX are supported.

llvm-svn: 321248

6 years ago[X86] Add avx512vbmi command lines to vector-shuffle-256-v32.ll
Craig Topper [Thu, 21 Dec 2017 03:58:31 +0000 (03:58 +0000)]
[X86] Add avx512vbmi command lines to vector-shuffle-256-v32.ll

llvm-svn: 321247

6 years ago[WebAssembly] Remove unneeded sub-directory
Sam Clegg [Thu, 21 Dec 2017 03:16:34 +0000 (03:16 +0000)]
[WebAssembly] Remove unneeded sub-directory

This is the only wasm def (and likely likely will be
for the foreseeable) file so no need for a sub-directory

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

llvm-svn: 321246

6 years ago[WebAssmebly] Fix references to weak aliases
Sam Clegg [Thu, 21 Dec 2017 02:43:39 +0000 (02:43 +0000)]
[WebAssmebly] Fix references to weak aliases

Corresponding LLVM change: https://reviews.llvm.org/D41472

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

llvm-svn: 321244

6 years agoRevert "Expose a TargetMachine::getTargetTransformInfo function"
Sanjoy Das [Thu, 21 Dec 2017 02:34:39 +0000 (02:34 +0000)]
Revert "Expose a TargetMachine::getTargetTransformInfo function"

This reverts commit r321234.  It breaks the -DBUILD_SHARED_LIBS=ON build.

llvm-svn: 321243

6 years ago[WebAssembly] Fix local references to weak aliases
Sam Clegg [Thu, 21 Dec 2017 02:30:38 +0000 (02:30 +0000)]
[WebAssembly] Fix local references to weak aliases

When weak aliases are used with in same translation
unit we need to be able to directly reference to alias
and not just the thing it is aliases.  We do this by
defining both a wasm import and a wasm export in this
case that result in a single Symbol.  This change is
a partial revert of rL314245.  A corresponding lld
change address the previous issues we had with this.

See: https://github.com/WebAssembly/tool-conventions/issues/34

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

llvm-svn: 321242

6 years ago[WebAssembly] Improve weak alias tests cases
Sam Clegg [Thu, 21 Dec 2017 02:30:09 +0000 (02:30 +0000)]
[WebAssembly] Improve weak alias tests cases

Based on: https://github.com/WebAssembly/tool-conventions/issues/34

Currently weak-alias-overide.ll exhibits incorrect
behaviour in that call_direct() calls the wrong function.

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

llvm-svn: 321241

6 years agoPass an InputFile to the InputSection constructor.
Rafael Espindola [Thu, 21 Dec 2017 02:11:51 +0000 (02:11 +0000)]
Pass an InputFile to the InputSection constructor.

This simplifies toRegularSection and reduces the noise in a followup
patch.

llvm-svn: 321240

6 years agoFix for PR32990
Erich Keane [Thu, 21 Dec 2017 02:07:46 +0000 (02:07 +0000)]
Fix for PR32990

This fixes the bug in https://bugs.llvm.org/show_bug.cgi?id=32990.

Patch By: zahiraam
Differential Revision: https://reviews.llvm.org/D39063

llvm-svn: 321239

6 years agoConvert a few more InputFiles to references.
Rafael Espindola [Thu, 21 Dec 2017 02:03:39 +0000 (02:03 +0000)]
Convert a few more InputFiles to references.

We use null files in sections to represent linker created sections,
so ObjFile<ELFT> is never null.

llvm-svn: 321238

6 years agoReverting a file that snuck in with r321229 by accident.
Aaron Ballman [Thu, 21 Dec 2017 01:34:46 +0000 (01:34 +0000)]
Reverting a file that snuck in with r321229 by accident.

llvm-svn: 321237

6 years ago[SimplifyCFG] Avoid quadratic on a predecessors number behavior in instruction sinking.
Michael Zolotukhin [Thu, 21 Dec 2017 01:22:13 +0000 (01:22 +0000)]
[SimplifyCFG] Avoid quadratic on a predecessors number behavior in instruction sinking.

If a block has N predecessors, then the current algorithm will try to
sink common code to this block N times (whenever we visit a
predecessor). Every attempt to sink the common code includes going
through all predecessors, so the complexity of the algorithm becomes
O(N^2).
With this patch we try to sink common code only when we visit the block
itself. With this, the complexity goes down to O(N).
As a side effect, the moment the code is sunk is slightly different than
before (the order of simplifications has been changed), that's why I had
to adjust two tests (note that neither of the tests is supposed to test
SimplifyCFG):
* test/CodeGen/AArch64/arm64-jumptable.ll - changes in this test mimic
the changes that previous implementation of SimplifyCFG would do.
* test/CodeGen/ARM/avoid-cpsr-rmw.ll - in this test I disabled common
code sinking by a command line flag.

llvm-svn: 321236

6 years agoDetemplate createCommentSection.
Rafael Espindola [Thu, 21 Dec 2017 01:21:59 +0000 (01:21 +0000)]
Detemplate createCommentSection.

It was only templated so it could create a dummy section header that
was immediately parsed back.

llvm-svn: 321235

6 years agoExpose a TargetMachine::getTargetTransformInfo function
Sanjoy Das [Thu, 21 Dec 2017 01:06:58 +0000 (01:06 +0000)]
Expose a TargetMachine::getTargetTransformInfo function

Summary:
This makes the TargetMachine interface a bit simpler.  We still need
the std::function in TargetIRAnalysis to avoid having to add a
dependency from Analysis to Target.

See discussion:
http://lists.llvm.org/pipermail/llvm-dev/2017-December/119749.html

I avoided adding all of the backend owners to this review since the
change is simple, but let me know if you feel differently about this.

Reviewers: echristo, MatzeB, hfinkel

Reviewed By: hfinkel

Subscribers: jholewinski, jfb, arsenm, dschuff, mcrosier, sdardis, nemanjai, nhaehnle, javed.absar, sbc100, jgravelle-google, aheejin, kbarton, llvm-commits

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

llvm-svn: 321234

6 years agoAttempt to pacify 4.8.5 with makeArrayRef
Reid Kleckner [Thu, 21 Dec 2017 00:28:34 +0000 (00:28 +0000)]
Attempt to pacify 4.8.5 with makeArrayRef

llvm-svn: 321233

6 years ago[ubsan] Diagnose noreturn functions which return (compiler-rt)
Vedant Kumar [Thu, 21 Dec 2017 00:10:36 +0000 (00:10 +0000)]
[ubsan] Diagnose noreturn functions which return (compiler-rt)

This is paired with the clang change: https://reviews.llvm.org/D40698

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

llvm-svn: 321232

6 years ago[ubsan] Diagnose noreturn functions which return
Vedant Kumar [Thu, 21 Dec 2017 00:10:25 +0000 (00:10 +0000)]
[ubsan] Diagnose noreturn functions which return

Diagnose 'unreachable' UB when a noreturn function returns.

  1. Insert a check at the end of functions marked noreturn.

  2. A decl may be marked noreturn in the caller TU, but not marked in
     the TU where it's defined. To diagnose this scenario, strip away the
     noreturn attribute on the callee and insert check after calls to it.

Testing: check-clang, check-ubsan, check-ubsan-minimal, D40700

rdar://33660464

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

llvm-svn: 321231

6 years ago[Driver] Ensure no overlap between trapping & recoverable sanitizers. NFC.
Vedant Kumar [Thu, 21 Dec 2017 00:10:24 +0000 (00:10 +0000)]
[Driver] Ensure no overlap between trapping & recoverable sanitizers. NFC.

This is NFC because in EmitCheck(), -fsanitize-trap=X overrides
-fsanitize-recover=X.

llvm-svn: 321230

6 years agoReverting r321223 and its follow-up commit because of failing bots due to Misc/ast...
Aaron Ballman [Wed, 20 Dec 2017 23:17:29 +0000 (23:17 +0000)]
Reverting r321223 and its follow-up commit because of failing bots due to Misc/ast-dump-color.cpp.

llvm-svn: 321229

6 years agoSilence a -Wreorder warning from r321223.
Aaron Ballman [Wed, 20 Dec 2017 23:11:05 +0000 (23:11 +0000)]
Silence a -Wreorder warning from r321223.

llvm-svn: 321228

6 years ago[clangd-fuzzer] Update ClangdLSPServer constructor call.
Matt Morehouse [Wed, 20 Dec 2017 22:29:23 +0000 (22:29 +0000)]
[clangd-fuzzer] Update ClangdLSPServer constructor call.

Build was broken by r321092.

llvm-svn: 321226

6 years ago[orc][cmake] Check if 8 byte atomics require libatomic for unittest
Simon Dardis [Wed, 20 Dec 2017 22:26:41 +0000 (22:26 +0000)]
[orc][cmake] Check if 8 byte atomics require libatomic for unittest

rL319838 introduced SymbolStringPool which uses 8 byte atomics for
reference counters. On systems which do not support such atomics
natively such as MIPS32, explicitly add libatomic as one of the
libraries for SymbolStringPool's unittest.

Reviewers: lhames, beanz

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

llvm-svn: 321225

6 years ago[ARM] Optimize {s,u}{add,sub}.with.overflow.
Joel Galenson [Wed, 20 Dec 2017 22:25:39 +0000 (22:25 +0000)]
[ARM] Optimize {s,u}{add,sub}.with.overflow.

The AArch64 backend contains code to optimize {s,u}{add,sub}.with.overflow during SelectionDAG.  This commit ports that code to the ARM backend.

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

llvm-svn: 321224

6 years agoAdd a printing policy to the ASTDumper.
Aaron Ballman [Wed, 20 Dec 2017 22:04:54 +0000 (22:04 +0000)]
Add a printing policy to the ASTDumper.

This allows you to dump C++ code that spells bool instead of _Bool, leaves off the elaborated type specifiers when printing struct or class names, and other C-isms.

llvm-svn: 321223

6 years agoFix an assertion failure regression in isDesignatorAtObjectEnd for
Alex Lorenz [Wed, 20 Dec 2017 21:03:38 +0000 (21:03 +0000)]
Fix an assertion failure regression in isDesignatorAtObjectEnd for
__builtin_object_size with incomplete array type in struct

The commit r316245 introduced a regression that causes an assertion failure when
Clang tries to cast an IncompleteArrayType to a PointerType when evaluating
__builtin_object_size.

rdar://36094951

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

llvm-svn: 321222

6 years ago[Hexagon] Use ArrayRef member functions instead of custom ones
Krzysztof Parzyszek [Wed, 20 Dec 2017 20:54:13 +0000 (20:54 +0000)]
[Hexagon] Use ArrayRef member functions instead of custom ones

llvm-svn: 321221

6 years ago[Hexagon] Allow construction of HVX vector predicates
Krzysztof Parzyszek [Wed, 20 Dec 2017 20:49:43 +0000 (20:49 +0000)]
[Hexagon] Allow construction of HVX vector predicates

Handle BUILD_VECTOR of boolean values.

llvm-svn: 321220

6 years agoUse dyn_cast instead of dyn_cast_or_null.
Rafael Espindola [Wed, 20 Dec 2017 20:46:08 +0000 (20:46 +0000)]
Use dyn_cast instead of dyn_cast_or_null.

There should be no null sections in InputSections.

llvm-svn: 321219

6 years ago[Hexagon] Legalize vector elements to i32 in buildVector32/64
Krzysztof Parzyszek [Wed, 20 Dec 2017 20:33:49 +0000 (20:33 +0000)]
[Hexagon] Legalize vector elements to i32 in buildVector32/64

llvm-svn: 321218

6 years agoDo not generate an empty switch statement as it causes MSVC to issue diagnostics...
Aaron Ballman [Wed, 20 Dec 2017 20:09:30 +0000 (20:09 +0000)]
Do not generate an empty switch statement as it causes MSVC to issue diagnostics about switch statements without case or default labels.

llvm-svn: 321217

6 years agoclang-format. NFC.
Rafael Espindola [Wed, 20 Dec 2017 19:59:47 +0000 (19:59 +0000)]
clang-format. NFC.

llvm-svn: 321216

6 years agobpf: add support for objdump -print-imm-hex
Yonghong Song [Wed, 20 Dec 2017 19:39:58 +0000 (19:39 +0000)]
bpf: add support for objdump -print-imm-hex

Add support for 'objdump -print-imm-hex' for imm64, operand imm
and branch target. If user programs encode immediate values
as hex numbers, such an option will make it easy to correlate
asm insns with source code. This option also makes it easy
to correlate imm values with insn encoding.

There is one changed behavior in this patch. In old way, we
print the 64bit imm as u64:
  O << (uint64_t)Op.getImm();
and the new way is:
  O << formatImm(Op.getImm());

The formatImm is defined in llvm/MC/MCInstPrinter.h as
  format_object<int64_t> formatImm(int64_t Value)

So the new way to print 64bit imm is i64 type.
If a 64bit value has the highest bit set, the old way
will print the value as a positive value and the
new way will print as a negative value. The new way
is consistent with x86_64.
For the code (see the test program):
 ...
 if (a == 0xABCDABCDabcdabcdULL)
 ...
x86_64 objdump, with and without -print-imm-hex, looks like:
 48 b8 cd ab cd ab cd ab cd ab   movabsq $-6067004223159161907, %rax
 48 b8 cd ab cd ab cd ab cd ab   movabsq $-0x5432543254325433, %rax

Signed-off-by: Yonghong Song <yhs@fb.com>
llvm-svn: 321215

6 years agoPR35705: Fix Chapter 9 example code for API changes to DIBuilder
David Blaikie [Wed, 20 Dec 2017 19:36:54 +0000 (19:36 +0000)]
PR35705: Fix Chapter 9 example code for API changes to DIBuilder

llvm-svn: 321214

6 years ago[X86] Refactor DomainReassignment pass to make the Closure class not stores reference...
Craig Topper [Wed, 20 Dec 2017 19:36:43 +0000 (19:36 +0000)]
[X86] Refactor DomainReassignment pass to make the Closure class not stores references to the main data structures of the pass itself

Multiple Closure objects can be created and stored for a single function. It's not a good idea to devote so many fields of it to storing pointers and references to global data structures of the pass. The closure class should only store the things needed to represent the closure itself.

This patch refactors many of the methods of Closure to belong to the pass object and to pass around a reference to the current Closure. The Closure class gains a few simple methods to add instructions and edges, and to return iterators to edges and instructions

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

llvm-svn: 321213

6 years agoTableGen: Allow setting SDNodeProperties on intrinsics
Matt Arsenault [Wed, 20 Dec 2017 19:36:28 +0000 (19:36 +0000)]
TableGen: Allow setting SDNodeProperties on intrinsics

Allows preserving MachineMemOperands on intrinsics
through selection. For reasons I don't understand, this
is a static property of the pattern and the selector
deliberately goes out of its way to drop if not present.

Intrinsics already inherit from SDPatternOperator allowing
them to be used directly in instruction patterns. SDPatternOperator
has a list of SDNodeProperty, but you currently can't set them on
the intrinsic. Without SDNPMemOperand, when the node is selected
any memory operands are always dropped. Allowing setting this
on the intrinsics avoids needing to introduce another equivalent
target node just to have SDNPMemOperand set.

llvm-svn: 321212

6 years ago[libfuzzer] Fix UB when calculating Log(0) in StackDepthStepFunction().
Max Moroz [Wed, 20 Dec 2017 19:31:51 +0000 (19:31 +0000)]
[libfuzzer] Fix UB when calculating Log(0) in StackDepthStepFunction().

Summary:
__builtin_clz used for Log calculation returns an undefined result
when argument is 0. I noticed that issue when was testing some fuzzers:

```
/src/libfuzzer/FuzzerTracePC.h:282:33: runtime error: shift exponent 450349 is too large for 32-bit type 'uint32_t' (aka 'unsigned int')
  #0 0x43d83f in operator() /src/libfuzzer/FuzzerTracePC.h:283:33
  #1 0x43d83f in void fuzzer::TracePC::CollectFeatures<fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool*)::$_1>(fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool*)::$_1) const /src/libfuzzer/FuzzerTracePC.h:290
  #2 0x43cbd4 in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool*) /src/libfuzzer/FuzzerLoop.cpp:445:7
  #3 0x43e5f1 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, fuzzer::fuzzer_allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&) /src/libfuzzer/FuzzerLoop.cpp:706:5
  #4 0x43e9e1 in fuzzer::Fuzzer::Loop(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, fuzzer::fuzzer_allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&) /src/libfuzzer/FuzzerLoop.cpp:739:3
  #5 0x432f8c in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/libfuzzer/FuzzerDriver.cpp:754:6
  #6 0x42ee18 in main /src/libfuzzer/FuzzerMain.cpp:20:10
  #7 0x7f17ffeb182f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
  #8 0x407838 in _start (/out/rotate_fuzzer+0x407838)

Reviewers: kcc

Reviewed By: kcc

Subscribers: llvm-commits, #sanitizers

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

llvm-svn: 321211

6 years ago[ICP] Expose unconditional call promotion interface
Matthew Simpson [Wed, 20 Dec 2017 19:26:37 +0000 (19:26 +0000)]
[ICP] Expose unconditional call promotion interface

This patch modifies the indirect call promotion utilities by exposing and using
an unconditional call promotion interface. The unconditional promotion
interface (i.e., call promotion without creating an if-then-else) can be used
if it's known that an indirect call has only one possible callee. The existing
conditional promotion interface uses this unconditional interface to promote an
indirect call after it has been versioned and placed within the "then" block.

A consequence of unconditional promotion is that the fix-up operations for phi
nodes in the normal destination of invoke instructions are changed. This is
necessary because the existing implementation assumed that an invoke had been
versioned, creating a "merge" block where a return value bitcast could be
placed. In the new implementation, the edge between a promoted invoke's parent
block and its normal destination is split if needed to add a bitcast for the
return value. If the invoke is also versioned, the phi node merging the return
value of the promoted and original invoke instructions is placed in the "merge"
block.

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

llvm-svn: 321210

6 years ago[X86] Remove zext from vXi32 to vXi64 on indices of gather/scatter instructions if...
Craig Topper [Wed, 20 Dec 2017 19:25:33 +0000 (19:25 +0000)]
[X86] Remove zext from vXi32 to vXi64 on indices of gather/scatter instructions if we can prove the pre-extended value is positive.

Gather/scatter can implicitly sign extend from i32->i64 on indices. So if we know the sign bit of the input to a zext is 0 we can use the implicit extension.

llvm-svn: 321209

6 years agoDAG: Tolerate non-MemSDNodes for OPC_RecordMemRef
Matt Arsenault [Wed, 20 Dec 2017 19:11:59 +0000 (19:11 +0000)]
DAG: Tolerate non-MemSDNodes for OPC_RecordMemRef

When intrinsics are allowed to have mem operands, there
are two ways this can happen. First is an intrinsic
that is marked has having a mem operand, but is not handled
by getTgtMemIntrinsic.

The second way can occur even for intrinsics which do not
have a mem operand. It seems the selector table does
some kind of sorting based on the opcode, and the
mem ref recording can happen in the same scope for
intrinsics that both do and do not have mem refs.
I haven't been able to figure out exactly why this happens
(although it happens even with the matcher optimizations disabled).
I'm not sure if it's worth trying to avoid hitting this for
these nodes since I think it's still reasonable to handle
this in case getTgtMemIntrinic is not implemented.

llvm-svn: 321208

6 years agoImprove the test for r320216. NFC.
Warren Ristow [Wed, 20 Dec 2017 19:11:31 +0000 (19:11 +0000)]
Improve the test for r320216.  NFC.

Patch by Matthew Voss!

llvm-svn: 321207

6 years ago[opt-viewer] Also demangle indirect-call promotion targets
Adam Nemet [Wed, 20 Dec 2017 19:08:12 +0000 (19:08 +0000)]
[opt-viewer] Also demangle indirect-call promotion targets

llvm-svn: 321206

6 years ago[PowerPC] Added an assert to make sure that the MBBI iterator is valid.
Stefan Pintilie [Wed, 20 Dec 2017 19:07:44 +0000 (19:07 +0000)]
[PowerPC] Added an assert to make sure that the MBBI iterator is valid.

The function createTailCallBranchInstr assumes that the iterator MBBI is valid.
However, only one use of MBBI is guarded in the function.
Fix this by adding an assert.

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

llvm-svn: 321205

6 years ago[DAG] Fix condition on overlapping store check.
Nirav Dave [Wed, 20 Dec 2017 19:06:47 +0000 (19:06 +0000)]
[DAG] Fix condition on overlapping store check.

Prevent overlapping store elision when overlapping store is
pre-inc/dec as analysis is wrong in these cases.

llvm-svn: 321204

6 years ago[hwasan] Implement -fsanitize-recover=hwaddress.
Evgeniy Stepanov [Wed, 20 Dec 2017 19:05:44 +0000 (19:05 +0000)]
[hwasan] Implement -fsanitize-recover=hwaddress.

Summary: Very similar to AddressSanitizer, with the exception of the error type encoding.

Reviewers: kcc, alekseyshl

Subscribers: cfe-commits, kubamracek, llvm-commits, hiraditya

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

llvm-svn: 321203

6 years ago[AMDGPU, AsmParser] Enable the mnemonic spell corrector.
Matt Arsenault [Wed, 20 Dec 2017 18:52:57 +0000 (18:52 +0000)]
[AMDGPU, AsmParser] Enable the mnemonic spell corrector.

Patch by Dmitry Venikov

llvm-svn: 321202

6 years agoAdd support for ObjectFormat to TargetSpecificAttr
Erich Keane [Wed, 20 Dec 2017 18:51:08 +0000 (18:51 +0000)]
Add support for ObjectFormat to TargetSpecificAttr

Looking through the code, I saw a FIXME on IFunc to switch it
to a target specific attribute. In looking through it, i saw that
the no-longer-appropriately-named TargetArch didn't support ObjectFormat
checking.

This patch changes the name of TargetArch to TargetSpecific
(since it checks much more than just Arch), makes "Arch" optional, adds
support for ObjectFormat, better documents the TargetSpecific type, and
changes IFunc over to a TargetSpecificAttr.

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

llvm-svn: 321201

6 years ago[X86] Implement the fusing of MUL+SUBADD to FMSUBADD
Craig Topper [Wed, 20 Dec 2017 18:05:15 +0000 (18:05 +0000)]
[X86] Implement the fusing of MUL+SUBADD to FMSUBADD

This patch turns shuffles of fadd/fsub with fmul into fmsubadd.

Patch by Dmitry Venikov

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

llvm-svn: 321200

6 years agoPass a InputFile reference to the Lazy constructor. NFC.
Rafael Espindola [Wed, 20 Dec 2017 18:01:32 +0000 (18:01 +0000)]
Pass a InputFile reference to the Lazy constructor. NFC.

llvm-svn: 321199

6 years agoUse a reference to a file in the LazyArchive symbol.
Rafael Espindola [Wed, 20 Dec 2017 17:59:43 +0000 (17:59 +0000)]
Use a reference to a file in the LazyArchive symbol.

It is never null.

llvm-svn: 321198

6 years ago[PGO] Function section hotness prefix should look at all blocks
Teresa Johnson [Wed, 20 Dec 2017 17:53:10 +0000 (17:53 +0000)]
[PGO] Function section hotness prefix should look at all blocks

Summary:
The function section prefix for PGO based layout (e.g. hot/unlikely)
should look at the hotness of all blocks not just the entry BB.
A function with a cold entry but a very hot loop should be placed in the
hot section, for example, so that it is located close to other hot
functions it may call. For SamplePGO it was already looking at the
branch weights on calls, and I made that code conditional on whether
this is SamplePGO since it was essentially a noop for instrumentation
PGO anyway.

Reviewers: davidxl

Subscribers: eraman, llvm-commits

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

llvm-svn: 321197

6 years agoLazyObject's file is never null, use a reference.
Rafael Espindola [Wed, 20 Dec 2017 17:52:36 +0000 (17:52 +0000)]
LazyObject's file is never null, use a reference.

llvm-svn: 321196

6 years agoUse a reference in addLazyArchive. NFC.
Rafael Espindola [Wed, 20 Dec 2017 17:48:28 +0000 (17:48 +0000)]
Use a reference in addLazyArchive. NFC.

llvm-svn: 321194

6 years ago[clangd] Pull CodeCompletionString handling logic into its own file and add unit...
Eric Liu [Wed, 20 Dec 2017 17:24:31 +0000 (17:24 +0000)]
[clangd] Pull CodeCompletionString handling logic into its own file and add unit test.

Reviewers: sammccall

Subscribers: klimek, mgorny, ilya-biryukov, cfe-commits

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

llvm-svn: 321193

6 years ago[clangd] Remove an unused lambda capture.
Eric Liu [Wed, 20 Dec 2017 17:22:56 +0000 (17:22 +0000)]
[clangd] Remove an unused lambda capture.

llvm-svn: 321192

6 years ago[InstCombine] Add debug location to new caller.
Florian Hahn [Wed, 20 Dec 2017 17:16:59 +0000 (17:16 +0000)]
[InstCombine] Add debug location to new caller.

Reviewers: rnk, aprantl, majnemer

Reviewed By: aprantl

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

llvm-svn: 321191

6 years agoMake DiagnosticIDs::getAllDiagnostics use std::vector. NFC.
Gabor Horvath [Wed, 20 Dec 2017 16:55:41 +0000 (16:55 +0000)]
Make DiagnosticIDs::getAllDiagnostics use std::vector. NFC.

The size of the result vector is currently around 4600 with
Flavor::WarningOrError, which makes std::vector a better candidate than
llvm::SmallVector.

Patch by: Andras Leitereg!

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

llvm-svn: 321190

6 years ago[clang] Add BeforeExecute method to PrecompiledPreamble
Ilya Biryukov [Wed, 20 Dec 2017 16:48:56 +0000 (16:48 +0000)]
[clang] Add BeforeExecute method to PrecompiledPreamble

Summary: Adds BeforeExecute method to PrecompiledPreamble to be called
before Execute(). This method can be overriden.

Patch by William Enright.

Reviewers: malaperle, ilya-biryukov

Reviewed By: ilya-biryukov

Subscribers: arphaman, cfe-commits, ilya-biryukov

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

llvm-svn: 321189

6 years agoFix the definitions of 'reference' and 'pointer' in string_view that no one uses...
Marshall Clow [Wed, 20 Dec 2017 16:31:40 +0000 (16:31 +0000)]
Fix the definitions of 'reference' and 'pointer' in string_view that no one uses :-). Thanks to K-ballo for the catch.

llvm-svn: 321188

6 years agoUse a reference for the shared symbol file.
Rafael Espindola [Wed, 20 Dec 2017 16:28:19 +0000 (16:28 +0000)]
Use a reference for the shared symbol file.

Every shared symbol has a file, so we can use a reference.

llvm-svn: 321187

6 years agoUse a reference for a value that is never null. NFC.
Rafael Espindola [Wed, 20 Dec 2017 16:19:48 +0000 (16:19 +0000)]
Use a reference for a value that is never null. NFC.

llvm-svn: 321186

6 years agoUse a reference for a value that is never null. NFC.
Rafael Espindola [Wed, 20 Dec 2017 16:16:40 +0000 (16:16 +0000)]
Use a reference for a value that is never null. NFC.

llvm-svn: 321185

6 years ago[clangd] Switch xrefs and documenthighlight to annotated-code unit tests. NFC
Sam McCall [Wed, 20 Dec 2017 16:06:05 +0000 (16:06 +0000)]
[clangd] Switch xrefs and documenthighlight to annotated-code unit tests. NFC

Summary:
The goal here is again to make it easier to read and write the tests.

I've extracted `parseTextMarker` from CodeCompleteTests into an `Annotations`
class, adding features to it:
  - as well as points `^s` it allows ranges `[[...]]`
  - multiple points and ranges are supported
  - points and ranges may be named: `$name^` and `$name[[...]]`

These features are used for the xrefs tests. This also paves the way for
replacing the lit diagnostics.test with more readable unit tests, using named
ranges.

Alternative considered: `TestSelectionRange` in clang-refactor/TestSupport
Main problems were:
 - delimiting the end of ranges is awkward, requiring counting
 - comment syntax is long and at least as cryptic for most cases
 - no separate syntax for point vs range, which keeps xrefs tests concise
 - Still need to convert to Position everywhere
 - Still need helpers for common case of expecting exactly one point/range

(I'll probably promote the extra `PrintTo`s from some of the core Protocol types
into `operator<<` in `Protocol.h` itself in a separate, prior patch...)

Reviewers: ioeric

Subscribers: klimek, mgorny, ilya-biryukov, cfe-commits

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

llvm-svn: 321184

6 years ago[Complex] Don't use __div?c3 when building with fast-math.
Florian Hahn [Wed, 20 Dec 2017 15:50:52 +0000 (15:50 +0000)]
[Complex] Don't use __div?c3 when building with fast-math.

Summary: Plant an inline version of "((ac+bd)/(cc+dd)) + i((bc-ad)/(cc+dd))" instead.

Patch by Paul Walker.

Reviewed By: hfinkel

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

llvm-svn: 321183

6 years ago[JumpTables] Let targets decide which switch instructions are suitable
Nemanja Ivanovic [Wed, 20 Dec 2017 15:44:32 +0000 (15:44 +0000)]
[JumpTables] Let targets decide which switch instructions are suitable

This commits the non-controversial part of https://reviews.llvm.org/D41029
(making the queries virtual). The PPC-specific portion of this will be
committed in a subsequent patch once some of the finer points are ironed out.

llvm-svn: 321182

6 years agoRevert r320548:[SLP] Vectorize jumbled memory loads
Mohammad Shahid [Wed, 20 Dec 2017 15:26:59 +0000 (15:26 +0000)]
Revert r320548:[SLP] Vectorize jumbled memory loads

llvm-svn: 321181

6 years agoAdd optional SelectionDAG* parameter to SValue::dump and SDValue::dumpr
Krzysztof Parzyszek [Wed, 20 Dec 2017 15:15:04 +0000 (15:15 +0000)]
Add optional SelectionDAG* parameter to SValue::dump and SDValue::dumpr

These functions simply call their counterparts in the associated SDNode,
which do take an optional SelectionDAG. This change makes the legalization
debug trace a little easier to read, since target-specific nodes will
now have their names shown instead of "Unknown node #123".

llvm-svn: 321180

6 years ago[SCEV] Fix Typo. NFC.
Javed Absar [Wed, 20 Dec 2017 15:06:26 +0000 (15:06 +0000)]
[SCEV] Fix Typo. NFC.

llvm-svn: 321179

6 years ago[NVPTX] Initial adaptation of MCAsmStreamer/MCTargetStreamer for debug info in Cuda.
Alexey Bataev [Wed, 20 Dec 2017 14:55:10 +0000 (14:55 +0000)]
[NVPTX] Initial adaptation of MCAsmStreamer/MCTargetStreamer for debug info in Cuda.

Summary:
Initial changes in interfaces of MCAsmStreamer/MCTargetStreamer for
correct debug info emission for Cuda.
1. PTX foramt does not support `.ascii` directives. Added the ability to
nullify it.
2. The initial function label must follow the first debug `.loc`
directive, not be followed by.
3. DWARF sections must be enclosed in braces.

Reviewers: hfinkel, probinson, jlebar, rafael, echristo

Subscribers: sdardis, nemanjai, llvm-commits, aprantl

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

llvm-svn: 321178

6 years ago[Hexagon] Adjust the value type for BCvt in LowerFormalArguments
Krzysztof Parzyszek [Wed, 20 Dec 2017 14:44:05 +0000 (14:44 +0000)]
[Hexagon] Adjust the value type for BCvt in LowerFormalArguments

llvm-svn: 321177

6 years ago[globalisel][tablegen] Allow ImmLeaf predicates to use InstructionSelector members
Daniel Sanders [Wed, 20 Dec 2017 14:41:51 +0000 (14:41 +0000)]
[globalisel][tablegen] Allow ImmLeaf predicates to use InstructionSelector members

NFC for currently supported targets. This resolves a problem encountered by
targets such as RISCV that reference `Subtarget` in ImmLeaf predicates.

llvm-svn: 321176

6 years agoAllow to apply cherry-picks when building Docker images.
Ilya Biryukov [Wed, 20 Dec 2017 14:39:07 +0000 (14:39 +0000)]
Allow to apply cherry-picks when building Docker images.

Reviewers: mehdi_amini, ioeric, klimek

Reviewed By: ioeric

Subscribers: llvm-commits

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

llvm-svn: 321175

6 years ago[Frontend] Handle skipped bodies in template instantiations
Ilya Biryukov [Wed, 20 Dec 2017 14:32:38 +0000 (14:32 +0000)]
[Frontend] Handle skipped bodies in template instantiations

Summary:
- Fixed an assert in Sema::InstantiateFunctionDefinition and added
  support for instantiating a function template with skipped body.
- Properly call setHasSkippedBody for FunctionTemplateDecl passed to
  Sema::ActOnSkippedFunctionBody.

Reviewers: sepavloff, bkramer

Reviewed By: sepavloff

Subscribers: klimek, cfe-commits

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

llvm-svn: 321174

6 years ago[clangd] Made UniqueFunction's bool conversion explicit
Ilya Biryukov [Wed, 20 Dec 2017 14:06:05 +0000 (14:06 +0000)]
[clangd] Made UniqueFunction's bool conversion explicit

llvm-svn: 321173

6 years ago[LV] Remove unnecessary DoExtraAnalysis guard (silent bug)
Florian Hahn [Wed, 20 Dec 2017 13:28:38 +0000 (13:28 +0000)]
[LV] Remove unnecessary DoExtraAnalysis guard (silent bug)

canVectorize is only checking if the loop has a normalized pre-header if DoExtraAnalysis is true.
This doesn't make sense to me because reporting analysis information shouldn't alter legality
checks. This is probably the result of a last minute minor change before committing (?).

Patch by Diego Caballero.

Reviewed By: fhahn

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

llvm-svn: 321172