platform/upstream/llvm.git
6 years ago[WebAssembly] Factor out settings common to wasm32 and wasm64. NFC.
Dan Gohman [Tue, 23 Jan 2018 20:22:12 +0000 (20:22 +0000)]
[WebAssembly] Factor out settings common to wasm32 and wasm64. NFC.

MaxAtomicPromoteWidth and MaxAtomicInlineWidth are 64 on both
wasm32 and wasm64, so they can be set in shared code.

llvm-svn: 323253

6 years agoRevert "[SLP] Fix for PR32086: Count InsertElementInstr of the same elements as shuffle."
Alexey Bataev [Tue, 23 Jan 2018 20:11:27 +0000 (20:11 +0000)]
Revert "[SLP] Fix for PR32086: Count InsertElementInstr of the same elements as shuffle."

This reverts commit r323246 because of the broken buildbots.

llvm-svn: 323252

6 years ago[analyzer] Mark lines as relevant even if they weren't executed but have a label...
George Karpenkov [Tue, 23 Jan 2018 20:01:31 +0000 (20:01 +0000)]
[analyzer] Mark lines as relevant even if they weren't executed but have a label attached

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

llvm-svn: 323251

6 years ago[Hexagon] Add patterns for sext_inreg of HVX vector types
Krzysztof Parzyszek [Tue, 23 Jan 2018 19:56:16 +0000 (19:56 +0000)]
[Hexagon] Add patterns for sext_inreg of HVX vector types

llvm-svn: 323250

6 years ago[ubsan] Add preinit initializer for ubsan
Francis Ricci [Tue, 23 Jan 2018 19:54:02 +0000 (19:54 +0000)]
[ubsan] Add preinit initializer for ubsan

Summary:
Now that ubsan does function interception (for signals), we
need to ensure that ubsan is initialized before any library
constructors are called. Otherwise, if a constructor calls
sigaction, ubsan will intercept in an unitialized state, which
will cause a crash.

This patch is a partial revert of r317757, which removed
preinit arrays for ubsan.

Reviewers: vitalybuka, eugenis, pcc

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

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

llvm-svn: 323249

6 years agoAdd a utility to reduce GlobalISel tests
Volkan Keles [Tue, 23 Jan 2018 19:47:10 +0000 (19:47 +0000)]
Add a utility to reduce GlobalISel tests

Summary: This patch adds a script to reduce GlobalISel failures using bugpoint.

Reviewers: bogner

Reviewed By: bogner

Subscribers: MatzeB, qcolombet, rovka, kristof.beyls, llvm-commits

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

llvm-svn: 323248

6 years agoCodeGen: use `llvm.used` for ObjC protocols
Saleem Abdulrasool [Tue, 23 Jan 2018 19:35:51 +0000 (19:35 +0000)]
CodeGen: use `llvm.used` for ObjC protocols

These symbols are supposed to be preserved even by the linker.  Use the
`llvm.used` to ensure that the symbols are not removed by DCE in the
linker.  This should be a no-op change on MachO since the symbols are
annotated as `no_dead_strip`.

llvm-svn: 323247

6 years ago[SLP] Fix for PR32086: Count InsertElementInstr of the same elements as shuffle.
Alexey Bataev [Tue, 23 Jan 2018 19:30:26 +0000 (19:30 +0000)]
[SLP] Fix for PR32086: Count InsertElementInstr of the same elements as shuffle.

Summary:
If the same value is going to be vectorized several times in the same
tree entry, this entry is considered to be a gather entry and cost of
this gather is counter as cost of InsertElementInstrs for each gathered
value. But we can consider these elements as ShuffleInstr with
SK_PermuteSingle shuffle kind.

Reviewers: spatel, RKSimon, mkuper, hfinkel

Subscribers: llvm-commits

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

llvm-svn: 323246

6 years ago[analyzer] Show full analyzer invocation for reproducibility in HTML reports
George Karpenkov [Tue, 23 Jan 2018 19:28:52 +0000 (19:28 +0000)]
[analyzer] Show full analyzer invocation for reproducibility in HTML reports

Analyzing problems which appear in scan-build results can be very
difficult, as after the launch no exact invocation is stored, and it's
super-hard to launch the debugger.
With this patch, the exact analyzer invocation appears in the footer,
and can be copied to debug/check reproducibility/etc.

rdar://35980230

llvm-svn: 323245

6 years ago[html] [NFC] Use raw strings to dump the style table.
George Karpenkov [Tue, 23 Jan 2018 19:28:43 +0000 (19:28 +0000)]
[html] [NFC] Use raw strings to dump the style table.

llvm-svn: 323244

6 years ago[ELF] Make --fix-cortex-a53-843419 work on big endian hosts
Peter Smith [Tue, 23 Jan 2018 19:26:52 +0000 (19:26 +0000)]
[ELF] Make --fix-cortex-a53-843419 work on big endian hosts

The reinterpret cast to uint32_t to read the little-endian instructions
will only work on a little endian system. Use ulittle32_t to always read
little-endian (AArch64 instructions are always little endian).

Fixes PR36056

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

llvm-svn: 323243

6 years agoX86 Tests: Add AVX512BW config to CodeGenPrepare test. NFC
Zvi Rackover [Tue, 23 Jan 2018 19:20:39 +0000 (19:20 +0000)]
X86 Tests: Add AVX512BW config to CodeGenPrepare test. NFC

Case points out that we don't consider shifts supported by AVX512BW
in isVectorShiftByScalarCheap()

llvm-svn: 323242

6 years agoAST: adjust ObjC MS mangling to work with typedefs
Saleem Abdulrasool [Tue, 23 Jan 2018 19:17:25 +0000 (19:17 +0000)]
AST: adjust ObjC MS mangling to work with typedefs

Rather than hardcode the pointerness of the `id` and `class` types,
handle them generically.  This allows for the template type
specialization of `remove_pointer<id>` which would look through the `id`
type and deal with the `objc_object` structure without the pointer.

llvm-svn: 323241

6 years ago[Hexagon] Implement hasLoadFromStackSlot and hasStoreToStackSlot
Krzysztof Parzyszek [Tue, 23 Jan 2018 19:08:40 +0000 (19:08 +0000)]
[Hexagon] Implement hasLoadFromStackSlot and hasStoreToStackSlot

If the instruction is a bundle, check the instructions inside of it.

Patch by Suyog Sarda.

llvm-svn: 323240

6 years ago[CUDA] CUDA has no device-side library builtins.
Artem Belevich [Tue, 23 Jan 2018 19:08:18 +0000 (19:08 +0000)]
[CUDA] CUDA has no device-side library builtins.

We should (almost) never consider a device-side declaration to match a
library builtin functio.  Otherwise clang may ignore the implementation
provided by the CUDA headers and emit clang's idea of the builtin.

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

llvm-svn: 323239

6 years agoIntroduce errorToBool() helper and use it.
Nico Weber [Tue, 23 Jan 2018 19:03:13 +0000 (19:03 +0000)]
Introduce errorToBool() helper and use it.

errorToBool() converts an Error to a bool and puts the Error in a checked
state.  No behavior change.

https://reviews.llvm.org/D42422

llvm-svn: 323238

6 years agolibcxx: Rename vasprintf function to __libcpp_vasprintf.
Peter Collingbourne [Tue, 23 Jan 2018 18:53:33 +0000 (18:53 +0000)]
libcxx: Rename vasprintf function to __libcpp_vasprintf.

The language standard does not define a function with this name,
so it is part of the user's namespace. This change fixes a duplicate
symbol error that occurs when a user attempts to define a function
with this name.

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

llvm-svn: 323237

6 years ago[OPENMP] Replace call of EmitLoadOfLValue() by EmitLoadOfScalar(), NFC.
Alexey Bataev [Tue, 23 Jan 2018 18:44:14 +0000 (18:44 +0000)]
[OPENMP] Replace call of EmitLoadOfLValue() by EmitLoadOfScalar(), NFC.

Replace calls of EmitLoadOfLValue() by EmitLoadOfScalar() functions if
it is known that the value is scalar.

llvm-svn: 323236

6 years ago[Docs] Re-generate command line documentation.
Craig Topper [Tue, 23 Jan 2018 18:40:15 +0000 (18:40 +0000)]
[Docs] Re-generate command line documentation.

llvm-svn: 323235

6 years ago[WebAssembly] Remove "name" section of object wasm object files
Sam Clegg [Tue, 23 Jan 2018 18:30:04 +0000 (18:30 +0000)]
[WebAssembly] Remove "name" section of object wasm object files

LLD is unaffected, no changes needed there. LLD continues to
write out a name section, using the symbol names.

Fixes: https://github.com/WebAssembly/tool-conventions/issues/37

Patch by Nicholas Wilson!

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

llvm-svn: 323234

6 years ago[Hexagon] Fix unused variable warning in release build
Krzysztof Parzyszek [Tue, 23 Jan 2018 18:16:52 +0000 (18:16 +0000)]
[Hexagon] Fix unused variable warning in release build

llvm-svn: 323233

6 years ago[OPENMP] Remove more empty SourceLocations() from the code.
Alexey Bataev [Tue, 23 Jan 2018 18:12:38 +0000 (18:12 +0000)]
[OPENMP] Remove more empty SourceLocations() from the code.

Removed more empty SourceLocations() from the OpenMP code and replaced
with the correct locations for better debug info emission.

llvm-svn: 323232

6 years agotest/Driver: Add some --stdlib=platform, NFC.
Jonas Hahnfeld [Tue, 23 Jan 2018 18:12:12 +0000 (18:12 +0000)]
test/Driver: Add some --stdlib=platform, NFC.

This fixes the failing test when building with CLANG_DEFAULT_CXX_STDLIB.

llvm-svn: 323231

6 years agotest: simplify the matching logic a bit (NFC)
Saleem Abdulrasool [Tue, 23 Jan 2018 17:57:04 +0000 (17:57 +0000)]
test: simplify the matching logic a bit (NFC)

Use CHECK-SAME directives to simplify the test conditions a bit.  This
makes it easier to see what is being checked.  NFC.

llvm-svn: 323230

6 years ago[Hexagon] Implement basic vector operations on vectors vNi1
Krzysztof Parzyszek [Tue, 23 Jan 2018 17:53:59 +0000 (17:53 +0000)]
[Hexagon] Implement basic vector operations on vectors vNi1

In addition to that, make sure that there are no boolean vector types that
are associated with multiple register classes. Specifically, remove v32i1
and v64i1 from integer register classes. These types will correspond to
results of vector comparisons, and as such should belong to the vector
predicate class. Having them in scalar registers as well makes legalization
ambiguous.

llvm-svn: 323229

6 years agoName two bool parameters. No behavior change.
Nico Weber [Tue, 23 Jan 2018 17:29:41 +0000 (17:29 +0000)]
Name two bool parameters. No behavior change.

llvm-svn: 323228

6 years ago[clang-tidy] Handle bitfields in cppcoreguidelines-pro-type-member-init if using...
Malcolm Parsons [Tue, 23 Jan 2018 17:13:57 +0000 (17:13 +0000)]
[clang-tidy] Handle bitfields in cppcoreguidelines-pro-type-member-init if using C++2a

Summary:
C++2a allows bitfields to have default member initializers.
Add support for this to clang-tidy's cppcoreguidelines-pro-type-member-init check.

Reviewers: aaron.ballman, alexfh

Reviewed By: aaron.ballman

Subscribers: klimek, nemanjai, xazax.hun, kbarton, cfe-commits

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

llvm-svn: 323227

6 years agoclang-format: Support macros in front of @interface / @protocol for ObjC code.
Nico Weber [Tue, 23 Jan 2018 17:10:25 +0000 (17:10 +0000)]
clang-format: Support macros in front of @interface / @protocol for ObjC code.

llvm-svn: 323226

6 years agotest: adjust the target for some Windows tests
Saleem Abdulrasool [Tue, 23 Jan 2018 17:05:57 +0000 (17:05 +0000)]
test: adjust the target for some Windows tests

The tests are targeting Windows but do not specify an environment.  When
executed on Linux, they would use an ELF output rather than the COFF
output.  Explicitly provide an environment.

llvm-svn: 323225

6 years ago[WebAssembly] Add mem.* builtin functions.
Dan Gohman [Tue, 23 Jan 2018 17:04:04 +0000 (17:04 +0000)]
[WebAssembly] Add mem.* builtin functions.

This corresponds to r323222 in LLVM. The new names are not yet
finalized, so use them at your own risk.

llvm-svn: 323224

6 years ago[X86][SSE] LowerBUILD_VECTORAsVariablePermute - extract subvector from oversized...
Simon Pilgrim [Tue, 23 Jan 2018 17:02:15 +0000 (17:02 +0000)]
[X86][SSE] LowerBUILD_VECTORAsVariablePermute - extract subvector from oversized index vectors

llvm-svn: 323223

6 years ago[WebAssembly] Add mem.* intrinsics.
Dan Gohman [Tue, 23 Jan 2018 17:02:02 +0000 (17:02 +0000)]
[WebAssembly] Add mem.* intrinsics.

The grow_memory and current_memory instructions are expected to be
officially renamed to mem.grow and mem.size. Introduce new intrinsics
with the new names. These new names aren't yet official, so for now,
use them at your own risk.

Also, take this opportunity to add arguments for the currently unused
immediate field in those instructions.

llvm-svn: 323222

6 years agoDon't mark a shared library as needed because of a lazy symbol.
Rafael Espindola [Tue, 23 Jan 2018 16:59:20 +0000 (16:59 +0000)]
Don't mark a shared library as needed because of a lazy symbol.

Fixes PR36029.

llvm-svn: 323221

6 years ago[WebAssembly] Switch to *-wasm as the default target triple.
Dan Gohman [Tue, 23 Jan 2018 16:55:44 +0000 (16:55 +0000)]
[WebAssembly] Switch to *-wasm as the default target triple.

This makes wasm32-unknown-unknown-wasm the default, which supports
the .o file writer and the new linking ABI. To enable s2wasm-compatible
output, use the wasm32-unknown-unknown-elf triple.

llvm-svn: 323220

6 years agoMove getBuildArtifact() from TestBase to Base and derive MiTestCaseBase from it
Adrian Prantl [Tue, 23 Jan 2018 16:43:01 +0000 (16:43 +0000)]
Move getBuildArtifact() from TestBase to Base and derive MiTestCaseBase from it

Thanks to Pavel Labath for pointing this out!

llvm-svn: 323219

6 years agoclang-format: Support formatting Java 8 interface default methods.
Nico Weber [Tue, 23 Jan 2018 16:30:56 +0000 (16:30 +0000)]
clang-format: Support formatting Java 8 interface default methods.

llvm-svn: 323218

6 years ago[PowerPC][asan] Fix asan tests to handle changed memory layouts
Bill Seurer [Tue, 23 Jan 2018 16:28:17 +0000 (16:28 +0000)]
[PowerPC][asan] Fix asan tests to handle changed memory layouts

In more recent Linux kernels with 47 bit VMAs the layout of virtual memory
for powerpc64 changed causing the address sanitizer to not work properly. This
patch fixes up a test case that was found to fail on some newer Fedora
releases that use different address ranges.

ref: https://reviews.llvm.org/D40907
llvm-svn: 323217

6 years agoVerifier: fix bug treating debug info issue as non-debug info issue
Yaxun Liu [Tue, 23 Jan 2018 16:11:15 +0000 (16:11 +0000)]
Verifier: fix bug treating debug info issue as non-debug info issue

Normally when llvm-as sees only debug info errors in LLVM assembly, it simply
drops the debug info and outputs a valid LLVM bitcode and returns 0.

There is a bug in LLVM verifier which incorrectly treats a debug info error
as non-debug info error, which causes llvm-as returns 1 even though llvm-as
can drop the invalid debug info and outputs a valid LLVM bitcode.

This patch fixes that.

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

llvm-svn: 323216

6 years ago[x86] Reautogenerate a bunch of tests for D42287. NFC
Alexander Ivchenko [Tue, 23 Jan 2018 16:08:15 +0000 (16:08 +0000)]
[x86] Reautogenerate a bunch of tests for D42287. NFC

llvm-svn: 323215

6 years agoCodeGen: Fix assertion in ScheduleDAGMILive::scheduleMI due to llvm.dbg.value
Yaxun Liu [Tue, 23 Jan 2018 16:04:53 +0000 (16:04 +0000)]
CodeGen: Fix assertion in ScheduleDAGMILive::scheduleMI due to llvm.dbg.value

Fix a bug in ScheduleDAGMILive::scheduleMI which causes BotRPTracker not tracking CurrentBottom in some rare cases involving llvm.dbg.value.

This issues causes amdgcn target to assert when compiling some user codes with -g.

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

llvm-svn: 323214

6 years ago[X86] Rewrite vXi1 element insertion by using a vXi1 scalar_to_vector and inserting...
Craig Topper [Tue, 23 Jan 2018 15:56:36 +0000 (15:56 +0000)]
[X86] Rewrite vXi1 element insertion by using a vXi1 scalar_to_vector and inserting into a vXi1 vector.

The existing code was already doing something very similar to subvector insertion so this allows us to remove the nearly duplicate code.

This patch is a little larger than it should be due to differences between the DQI handling between the two today.

llvm-svn: 323212

6 years ago[X86][SSE] LowerBUILD_VECTORAsVariablePermute - ensure that the source vector is...
Simon Pilgrim [Tue, 23 Jan 2018 15:51:03 +0000 (15:51 +0000)]
[X86][SSE] LowerBUILD_VECTORAsVariablePermute - ensure that the source vector is not larger than the destination

We might be able to support this in the future with VPERMV3, OR(PSHUFB, PSHUFB) etc.

llvm-svn: 323210

6 years ago[x86] Mostly reautogenerate a bunch of tests that affect D37775. NFC
Alexander Ivchenko [Tue, 23 Jan 2018 15:48:50 +0000 (15:48 +0000)]
[x86] Mostly reautogenerate a bunch of tests that affect D37775. NFC

Tests required minor manual tweaks:
CodeGen/MIR/X86/generic-instr-type.mir
CodeGen/X86/GlobalISel/select-copy.mir
CodeGen/X86/GlobalISel/select-ext.mir
CodeGen/X86/GlobalISel/select-intrinsic-x86-flags-read-u32.mir
CodeGen/X86/GlobalISel/select-phi.mir
CodeGen/X86/GlobalISel/select-trunc.mir
CodeGen/X86/GlobalISel/select-frameIndex.mir

And following tests are split into 32/64 versions:
CodeGen/X86/GlobalISel/legalize-GV.mir
CodeGen/X86/GlobalISel/select-frameIndex.mir

llvm-svn: 323209

6 years ago[clang-tidy] Handle bitfields in modernize-use-default-member-init if using C++2a
Malcolm Parsons [Tue, 23 Jan 2018 15:32:42 +0000 (15:32 +0000)]
[clang-tidy] Handle bitfields in modernize-use-default-member-init if using C++2a

Summary:
C++2a allows bitfields to have default member initializers.
Add support for this to clang-tidy's modernize-use-default-member-init check.

Reviewers: aaron.ballman, alexfh

Reviewed By: aaron.ballman

Subscribers: klimek, xazax.hun, cfe-commits

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

llvm-svn: 323208

6 years agoUse EVT::changeVectorElementTypeToInteger() to convert index type to integer
Simon Pilgrim [Tue, 23 Jan 2018 15:30:07 +0000 (15:30 +0000)]
Use EVT::changeVectorElementTypeToInteger() to convert index type to integer

llvm-svn: 323207

6 years ago[X86][SSE] LowerBUILD_VECTORAsVariablePermute - ensure that the index vector has...
Simon Pilgrim [Tue, 23 Jan 2018 15:13:37 +0000 (15:13 +0000)]
[X86][SSE] LowerBUILD_VECTORAsVariablePermute - ensure that the index vector has the correct number of elements

llvm-svn: 323206

6 years agoAArch64: get type from correct result when forming BFX
Tim Northover [Tue, 23 Jan 2018 15:11:27 +0000 (15:11 +0000)]
AArch64: get type from correct result when forming BFX

Some nodes produce multiple values so when obtaining the type of an ISD::OR we
need to make sure we ask for the correct one. Hopefully that's all of them.

llvm-svn: 323205

6 years ago[clangd] Simplify code handling compile commands
Ilya Biryukov [Tue, 23 Jan 2018 15:07:52 +0000 (15:07 +0000)]
[clangd] Simplify code handling compile commands

Summary:
CppFile can now change compilation arguments during rebuild. This allows
simplifying code that manages CppFiles.

Reviewers: sammccall, bkramer, jkorous-apple

Reviewed By: sammccall

Subscribers: ioeric, jkorous-apple, klimek, cfe-commits

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

llvm-svn: 323204

6 years agoAccept iso date format in COFF/unchanged-importlib.test
Hans Wennborg [Tue, 23 Jan 2018 14:41:39 +0000 (14:41 +0000)]
Accept iso date format in COFF/unchanged-importlib.test

llvm-svn: 323203

6 years agoAArch64: get type from correct result when forming BFI/BFM
Tim Northover [Tue, 23 Jan 2018 14:37:03 +0000 (14:37 +0000)]
AArch64: get type from correct result when forming BFI/BFM

Some nodes produce multiple values so when obtaining the type of an ISD::OR we
need to make sure we ask for the correct one.

llvm-svn: 323202

6 years ago[X86] Legalize v32i1 without BWI via splitting to v16i1 rather than the default of...
Craig Topper [Tue, 23 Jan 2018 14:25:39 +0000 (14:25 +0000)]
[X86] Legalize v32i1 without BWI via splitting to v16i1 rather than the default of promoting to v32i8.

Summary:
For the most part its better to keep v32i1 as a mask type of a narrower width than trying to promote it to a ymm register.

I had to add some overrides to the methods that get the types for the calling convention so that we still use v32i8 for argument/return purposes.

There are still some regressions in here. I definitely saw some around shuffles. I think we probably should move vXi1 shuffle from lowering to a DAG combine where I think the extend and truncate we have to emit would be better combined.

I think we also need a DAG combine to remove trunc from (extract_vector_elt (trunc))

Overall this removes something like 13000 CHECK lines from lit tests.

Reviewers: zvi, RKSimon, delena, spatel

Reviewed By: RKSimon

Subscribers: llvm-commits

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

llvm-svn: 323201

6 years ago[X86] Add missing MOVSX/MOVZX instructions to load folding tables.
Craig Topper [Tue, 23 Jan 2018 14:09:22 +0000 (14:09 +0000)]
[X86] Add missing MOVSX/MOVZX instructions to load folding tables.

I'm not sure there's any way to generate these folding cases especially the movzx ones since even the register form is never emitted by codegen.

I'm just adding them to remove the difference with the autogenerated version of the folding table.

llvm-svn: 323200

6 years agoFix Driver/solaris-ld.c test on Windows
Fedor Sergeev [Tue, 23 Jan 2018 13:59:11 +0000 (13:59 +0000)]
Fix Driver/solaris-ld.c test on Windows

Fixing failure introduced with r323193.

llvm-svn: 323199

6 years agollvm-objdump: prevent out of bounds accesses during unwind dumping.
Tim Northover [Tue, 23 Jan 2018 13:51:57 +0000 (13:51 +0000)]
llvm-objdump: prevent out of bounds accesses during unwind dumping.

We were a bit too trusting about the offsets encoded in MachO compact unwind
sections, so this passes every access through a bounds check just in case. It
prevents a few segfaults on malformed object files, if one should ever come
along.

Mostly to silence fuzzers in the vague hope they might be able to produce
something useful without the noise.

llvm-svn: 323198

6 years agoFix memory leaks in GoParser
Raphael Isemann [Tue, 23 Jan 2018 13:50:46 +0000 (13:50 +0000)]
Fix memory leaks in GoParser

Summary: The GoParser is leaking memory in the tests due to not freeing allocated nodes when encountering some parsing errors. With this patch all GoParser tests are passing with enabled memory sanitizers/ubsan.

Reviewers: labath, davide

Reviewed By: labath

Subscribers: lldb-commits

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

llvm-svn: 323197

6 years ago[clang-tidy] Add -vfsoverlay flag
Ilya Biryukov [Tue, 23 Jan 2018 12:31:06 +0000 (12:31 +0000)]
[clang-tidy] Add -vfsoverlay flag

Summary:
It allows to remap and override files and directories on disk when
running clang-tidy. The intended use case for the flag is running
standalone clang-tidy binary for IDE and editor integration.

Patch by Vladimir Plyashkun.

Reviewers: alexfh, benlangmuir, ilya-biryukov

Reviewed By: ilya-biryukov

Subscribers: ilya-biryukov, cfe-commits

Tags: #clang-tools-extra

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

llvm-svn: 323196

6 years ago[Tooling] Added a VFS parameter to ClangTool
Ilya Biryukov [Tue, 23 Jan 2018 12:30:02 +0000 (12:30 +0000)]
[Tooling] Added a VFS parameter to ClangTool

Summary:
The parameter overrides the underlying vfs used by ClangTool for
filesystem operations.

Patch by Vladimir Plyashkun.

Reviewers: alexfh, ilya-biryukov

Reviewed By: ilya-biryukov

Subscribers: klimek, cfe-commits

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

llvm-svn: 323195

6 years ago[Solaris] Make RHEL devtoolsets handling Linux-specific
Fedor Sergeev [Tue, 23 Jan 2018 12:24:01 +0000 (12:24 +0000)]
[Solaris] Make RHEL devtoolsets handling Linux-specific

Summary:
This patch is meant to address the last outstanding review comment on the already approved
(but not yet commited) https://reviews.llvm.org/D35755, namely making the handling of the RHEL
devtoolsets Linux-specific.

Don't know if it's best integrated into the former or applied subsequently.

Tested on i386-pc-solaris2.11 and x86_64-pc-linux-gnu.

Reviewers: fedor.sergeev, tstellar, jyknight

Reviewed By: fedor.sergeev

Subscribers: cfe-commits

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

llvm-svn: 323194

6 years ago[Solaris] gcc toolchain handling revamp
Fedor Sergeev [Tue, 23 Jan 2018 12:23:52 +0000 (12:23 +0000)]
[Solaris] gcc toolchain handling revamp

Summary:
General idea is to utilize generic (mostly Generic_GCC) code
and get rid of Solaris-specific handling as much as possible.

In particular:
- scanLibDirForGCCTripleSolaris was removed, relying on generic
  CollectLibDirsAndTriples

- findBiarchMultilibs is now properly utilized to switch between
   m32 and m64 include & lib paths on Solaris

- C system include handling copied from Linux (bar multilib hacks)

Fixes PR24606.

Reviewers: dlj, rafael, jyknight, theraven, tstellar

Reviewed By: jyknight

Subscribers: aaron.ballman, mgorny, krytarowski, ro, joerg, cfe-commits

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

llvm-svn: 323193

6 years ago[CGP] Fix the GV handling in complex addressing mode
Serguei Katkov [Tue, 23 Jan 2018 12:07:49 +0000 (12:07 +0000)]
[CGP] Fix the GV handling in complex addressing mode

If in complex addressing mode the difference is in GV then
base reg should not be installed because we plan to use
base reg as a merge point of different GVs.

This is a fix for PR35980.

Reviewers: reames, john.brawn, santosh
Reviewed By: john.brawn
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D42230

llvm-svn: 323192

6 years ago[clang-tidy] Don't generate fixes for invalid new expr location in modernize-make...
Haojian Wu [Tue, 23 Jan 2018 11:43:18 +0000 (11:43 +0000)]
[clang-tidy] Don't generate fixes for invalid new expr location in modernize-make-unique.

Reviewers: ilya-biryukov

Reviewed By: ilya-biryukov

Subscribers: klimek, xazax.hun, cfe-commits

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

llvm-svn: 323191

6 years ago[X86][SSE] LowerBUILD_VECTORAsVariablePermute - fix PSHUFB source/index operand ordering
Simon Pilgrim [Tue, 23 Jan 2018 11:39:06 +0000 (11:39 +0000)]
[X86][SSE] LowerBUILD_VECTORAsVariablePermute - fix PSHUFB source/index operand ordering

As detailed in rL317463, PSHUFB (like most variable shuffle instructions) uses Op[0] for the source vector and Op[1] for the shuffle index vector, VPERMV works in reverse which is probably where the confusion comes from.

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

llvm-svn: 323190

6 years ago[clangd] Use accessible scopes to query indexes for global code completion.
Haojian Wu [Tue, 23 Jan 2018 11:37:26 +0000 (11:37 +0000)]
[clangd] Use accessible scopes to query indexes for global code completion.

Summary:
 * For qualified completion (foo::a^)
       * unresolved qualifier - use global namespace ("::")
       * resolved qualifier - use all accessible namespaces inside the resolved qualifier.
 * For unqualified completion (vec^), use scopes that are accessible from the
      scope from which code completion occurs.

Reviewers: sammccall, ilya-biryukov

Reviewed By: sammccall

Subscribers: jkorous-apple, ioeric, klimek, cfe-commits

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

llvm-svn: 323189

6 years ago[clang-format] Ignore UnbreakableTailLength sometimes during breaking
Krasimir Georgiev [Tue, 23 Jan 2018 11:26:19 +0000 (11:26 +0000)]
[clang-format] Ignore UnbreakableTailLength sometimes during breaking

Summary:
This patch fixes an issue where the UnbreakableTailLength would be counted towards
the length of a token during breaking, even though we can break after the token.

For example, this proto text with column limit 20
```
# ColumnLimit: 20  V
foo: {
  bar: {
    bazoo: "aaaaaaa"
  }
}
```
was broken:
```
# ColumnLimit: 20  V
foo: {
  bar: {
    bazoo:
        "aaaaaaa"
  }
}
```
because the 2 closing `}` were counted towards the string literal's `UnbreakableTailLength`.

Reviewers: djasper

Reviewed By: djasper

Subscribers: klimek, cfe-commits

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

llvm-svn: 323188

6 years ago[Analysis] Disable exp/exp2/pow finite lib calls on Android with -ffast-math.
MinSeong Kim [Tue, 23 Jan 2018 11:11:36 +0000 (11:11 +0000)]
[Analysis] Disable exp/exp2/pow finite lib calls on Android with -ffast-math.

Summary:
Since r322087, glibc's finite lib calls are generated when possible.
However, glibc is not supported on Android. Therefore this change
enables llvm to finely distinguish between linux and Android for
unsupported library calls. The change also include some regression
tests.

Reviewers: srhines, pirama

Reviewed By: srhines

Subscribers: kongyi, chh, javed.absar, llvm-commits

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

llvm-svn: 323187

6 years ago[ARM] Pass _Float16 as int or float
Sjoerd Meijer [Tue, 23 Jan 2018 10:13:49 +0000 (10:13 +0000)]
[ARM] Pass _Float16 as int or float

Pass and return _Float16 as if it were an int or float for ARM, but with the
top 16 bits unspecified, similarly like we already do for __fp16.

We will implement proper half-precision function argument lowering in the ARM
backend soon, but want to use this workaround in the mean time.

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

llvm-svn: 323185

6 years ago[mips] Properly select abs and sqrt instructions
Stefan Maksimovic [Tue, 23 Jan 2018 10:09:39 +0000 (10:09 +0000)]
[mips] Properly select abs and sqrt instructions

- Alter abs for micromips to have both AFGR64 and FGR64
  variants, same as sqrt
- Remove sqrt and abs from MicroMips32r6InstrInfo.td,
  use micromips FGR64 variants
- Restrict non-micromips abs/sqrt with NotInMicroMips
  predicate

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

llvm-svn: 323184

6 years agoThis change add's optimization remark in LoopVersioning LICM pass.
Ashutosh Nema [Tue, 23 Jan 2018 09:47:28 +0000 (09:47 +0000)]
This change add's optimization remark in LoopVersioning LICM pass.

Summary:
This patch is adding remark messages to the LoopVersioning LICM pass,
which will be useful for optimization remark emitter (ORE) infrastructure.

Patch by: Deepak Porwal

Reviewers: anemet, ashutosh.nema, eastig

Subscribers: eastig, vivekvpandya, fhahn, llvm-commits
llvm-svn: 323183

6 years ago[InstSimplify] (X << Y) % X -> 0
Anton Bikineev [Tue, 23 Jan 2018 09:27:47 +0000 (09:27 +0000)]
[InstSimplify] (X << Y) % X -> 0

llvm-svn: 323182

6 years agoPrevent unaligned memory read in parseMinidumpString
Raphael Isemann [Tue, 23 Jan 2018 08:04:27 +0000 (08:04 +0000)]
Prevent unaligned memory read in parseMinidumpString

Summary:
It's possible to hit an unaligned memory read when reading `source_length` as the `data` array is only aligned with 2 bytes (it's actually a UTF16 array). This patch memcpy's `source_length` into a local variable to prevent this:

```
MinidumpTypes.cpp:49:23: runtime error: load of misaligned address 0x7f0f4792692a for type 'const uint32_t' (aka 'const unsigned int'), which requires 4 byte alignment
```

Reviewers: dvlahovski, zturner, davide

Reviewed By: davide

Subscribers: davide, lldb-commits

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

llvm-svn: 323181

6 years agoFix name of 'macOS' and add asteriks to brands, NFC.
Jonas Hahnfeld [Tue, 23 Jan 2018 07:54:10 +0000 (07:54 +0000)]
Fix name of 'macOS' and add asteriks to brands, NFC.

llvm-svn: 323180

6 years agoupdate_mir_test_checks: Improve the check for LLVM IR in MIR files
Justin Bogner [Tue, 23 Jan 2018 06:39:04 +0000 (06:39 +0000)]
update_mir_test_checks: Improve the check for LLVM IR in MIR files

The LLVM IR section of a MIR document can start with "--- |" rather
than just "---", because "|" is a sigil for a freeform document in
YAML. We need to handle this so that we don't try to add check lines
to the LLVM IR functions in a MIR file.

llvm-svn: 323178

6 years ago[NFC] fix trivial typos in comments
Hiroshi Inoue [Tue, 23 Jan 2018 05:50:06 +0000 (05:50 +0000)]
[NFC] fix trivial typos in comments

"the the" -> "the"

llvm-svn: 323177

6 years ago[NFC] fix trivial typos in comments
Hiroshi Inoue [Tue, 23 Jan 2018 05:49:30 +0000 (05:49 +0000)]
[NFC] fix trivial typos in comments

"the the" -> "the"

llvm-svn: 323176

6 years ago[X86] Don't reorder (srl (and X, C1), C2) if (and X, C1) can be matched as a movzx
Craig Topper [Tue, 23 Jan 2018 05:45:52 +0000 (05:45 +0000)]
[X86] Don't reorder (srl (and X, C1), C2) if (and X, C1) can be matched as a movzx

Summary:
If we can match as a zero extend there's no need to flip the order to get an encoding benefit. As movzx is 3 bytes with independent source/dest registers. The shortest 'and' we could make is also 3 bytes unless we get lucky in the register allocator and its on AL/AX/EAX which have a 2 byte encoding.

This patch was more impressive before r322957 went in. It removed some of the same Ands that got deleted by that patch.

Reviewers: spatel, RKSimon

Reviewed By: spatel

Subscribers: llvm-commits

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

llvm-svn: 323175

6 years ago[X86] Remove 'NOREX' comment from the printing of _NOREX instructions.
Craig Topper [Tue, 23 Jan 2018 05:37:00 +0000 (05:37 +0000)]
[X86] Remove 'NOREX' comment from the printing of _NOREX instructions.

Some of the NOREX instructions are used in 32-bit mode making this printing confusing. It also doesn't provide a lot of value since you can see the h-register being used by the instruction.

llvm-svn: 323174

6 years ago[X86] Various vXi1 insertion improvements.
Craig Topper [Tue, 23 Jan 2018 05:36:53 +0000 (05:36 +0000)]
[X86] Various vXi1 insertion improvements.

Add missing patterns for inserting v1i1 into a zero vector. Use insert_subvector to zero upper bits before inserting an element into a vXi1 vector. Replace kshift based isel pattern with insert_subvector based pattern now that code that caused the pattern has been fixed to emit insert_subvector.

llvm-svn: 323173

6 years agoUse 4 as the alignment of .eh_frame_hdr.
Rafael Espindola [Tue, 23 Jan 2018 05:23:23 +0000 (05:23 +0000)]
Use 4 as the alignment of .eh_frame_hdr.

It includes 32 bit values and this matches both gold and bfd.

llvm-svn: 323172

6 years ago[cmake] Always respect existing CMAKE_REQUIRED_FLAGS when adding additional ones.
Don Hinton [Tue, 23 Jan 2018 03:30:23 +0000 (03:30 +0000)]
[cmake] Always respect existing CMAKE_REQUIRED_FLAGS when adding additional ones.

* Previously part of https://reviews.llvm.org/D41622.

llvm-svn: 323171

6 years agolibcxx: Provide overloads for basic_filebuf::open() et al that take wchar_t* filename...
Peter Collingbourne [Tue, 23 Jan 2018 02:07:27 +0000 (02:07 +0000)]
libcxx: Provide overloads for basic_filebuf::open() et al that take wchar_t* filenames on Windows.

This is an MSVC standard library extension. It seems like a reasonable
enough extension to me because wchar_t* is the native format for
filenames on that platform.

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

llvm-svn: 323170

6 years agolibcxx: Move Windows threading support into a .cpp file.
Peter Collingbourne [Tue, 23 Jan 2018 01:59:43 +0000 (01:59 +0000)]
libcxx: Move Windows threading support into a .cpp file.

This allows us to avoid polluting the namespace of users of <thread>
with the definitions in windows.h.

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

llvm-svn: 323169

6 years ago[WebAssembly] Update to match llvm changes to TABLE relocations
Sam Clegg [Tue, 23 Jan 2018 01:25:56 +0000 (01:25 +0000)]
[WebAssembly] Update to match llvm changes to TABLE relocations

TABLE relocations now store the function that is being refered
to indirectly.

See rL323165.

Also extend the call-indirect.ll a little.

Based on a patch by Nicholas Wilson!

llvm-svn: 323168

6 years agoNewPM: Improve/fix GCOV - which needs to run early in the pass pipeline.
David Blaikie [Tue, 23 Jan 2018 01:25:24 +0000 (01:25 +0000)]
NewPM: Improve/fix GCOV - which needs to run early in the pass pipeline.

Using a new extension point in the new PM, register GCOV at the start of
the pipeline rather than the end.

llvm-svn: 323167

6 years agoNewPM: Add an extension point for the start of the pipeline.
David Blaikie [Tue, 23 Jan 2018 01:25:20 +0000 (01:25 +0000)]
NewPM: Add an extension point for the start of the pipeline.

This applies to most pipelines except the LTO and ThinLTO backend
actions - it is for use at the beginning of the overall pipeline.

This extension point will be used to add the GCOV pass when enabled in
Clang.

llvm-svn: 323166

6 years ago[WebAssembly] Store function index rather than table index in TABLE_INDEX relocations
Sam Clegg [Tue, 23 Jan 2018 01:23:17 +0000 (01:23 +0000)]
[WebAssembly] Store function index rather than table index in TABLE_INDEX relocations

Relocations of type R_WEBASSEMBLY_TABLE_INDEX represent places
where the table index for a given function is needed.  While the
value stored in this location is a table index, the index in
the relocation entry itself is a function index (the index of
the function which is to be called indirectly).

This is how is was spec'd originally but the LLVM implementation
didn't do this.  This makes things a little simpler in the linker
since the table in the input file can essentially be ignored that
the output table can be created purely based on these relocations.

Patch by Nicholas Wilson!

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

llvm-svn: 323165

6 years ago[COFF] don't replace import library if contents are unchanged
Bob Haarman [Tue, 23 Jan 2018 00:36:42 +0000 (00:36 +0000)]
[COFF] don't replace import library if contents are unchanged

Summary:
This detects when an import library is about to be overwritten with a
newly built one with the same contents, and keeps the old library
instead. The use case for this is to avoid needlessly rebuilding
targets that depend on the import library in build systems that rely
on timestamps to determine whether a target requires rebuilding.

This feature was requested in PR35917.

Reviewers: rnk, ruiu, zturner, pcc

Reviewed By: ruiu

Subscribers: llvm-commits

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

llvm-svn: 323164

6 years ago[lldb] Fix some C++ virtual method call bugs in LLDB expression evaluation by
Lang Hames [Mon, 22 Jan 2018 23:53:56 +0000 (23:53 +0000)]
[lldb] Fix some C++ virtual method call bugs in LLDB expression evaluation by
building method override tables for CXXMethodDecls in
DWARFASTParserClang::CompleteTypeFromDWARF.

C++ virtual method calls in LLDB expressions may fail if the override table for
the method being called is not correct as IRGen will produce references to the
wrong (or a missing) vtable entry.

This patch does not fix calls to virtual methods with covariant return types as
it mistakenly treats these as overloads, rather than overrides. This will be
addressed in a future patch.

Review: https://reviews.llvm.org/D41997

Partially fixes <rdar://problem/14205774>

llvm-svn: 323163

6 years agoSmall fixes for detect_invalid_pointer_pairs.
Alex Shlyapnikov [Mon, 22 Jan 2018 23:28:52 +0000 (23:28 +0000)]
Small fixes for detect_invalid_pointer_pairs.

Summary:
One test-case uses a wrong operation (should be subtraction).
Second test-case should declare a global variables before a tested one
in order to guarantee we will find a red-zone.

Reviewers: kcc, jakubjelinek, alekseyshl

Reviewed By: alekseyshl

Subscribers: kubamracek

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

llvm-svn: 323162

6 years agoRevert r322595: Specify inline for isWhitespace in CommandLine.cpp
Rui Ueyama [Mon, 22 Jan 2018 23:27:50 +0000 (23:27 +0000)]
Revert r322595: Specify inline for isWhitespace in CommandLine.cpp

The original change was made based on a misunderstanding that
-DCMAKE_BUILD_TYPE=RelWithDebugInfo would produce the same executable
as -DCMAKE_BUILD_TYPE=Release modulo debug info. Turned out that's not
true -- it at least disables some optimizations such as function inlining.

llvm-svn: 323161

6 years agoUpdate cxx2a status
Marshall Clow [Mon, 22 Jan 2018 23:17:20 +0000 (23:17 +0000)]
Update cxx2a status

llvm-svn: 323160

6 years agoLast batch of P0202 constexpr additions: includes/set_intersection/exchange
Marshall Clow [Mon, 22 Jan 2018 23:10:40 +0000 (23:10 +0000)]
Last batch of P0202 constexpr additions: includes/set_intersection/exchange

llvm-svn: 323159

6 years agoAdd hasTrailingReturn AST matcher
Julie Hockett [Mon, 22 Jan 2018 22:45:23 +0000 (22:45 +0000)]
Add hasTrailingReturn AST matcher

Adds AST matcher for a FunctionDecl that has a trailing return type.

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

llvm-svn: 323158

6 years ago[ASTMatchers] [NFC] Fix code examples
Fangrui Song [Mon, 22 Jan 2018 22:34:15 +0000 (22:34 +0000)]
[ASTMatchers] [NFC] Fix code examples

Subscribers: klimek, cfe-commits

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

llvm-svn: 323157

6 years agoReland "[CodeGen] Fix crash when a function taking transparent union is redeclared."
Volodymyr Sapsai [Mon, 22 Jan 2018 22:29:24 +0000 (22:29 +0000)]
Reland "[CodeGen] Fix crash when a function taking transparent union is redeclared."

When a function taking transparent union is declared as taking one of
union members earlier in the translation unit, clang would hit an
"Invalid cast" assertion during EmitFunctionProlog. This case
corresponds to function f1 in test/CodeGen/transparent-union-redecl.c.
We decided to cast i32 to union because after merging function
declarations function parameter type becomes int,
CGFunctionInfo::ArgInfo type matches with ABIArgInfo type, so we decide
it is a trivial case. But these types should also be castable to
parameter declaration type which is not the case here.

Now the fix is in converting from ABIArgInfo type to VarDecl type and using
argument demotion when necessary.

Additional tests in Sema/transparent-union.c capture current behavior and make
sure there are no regressions.

rdar://problem/34949329

Reviewers: rjmccall, rafael

Reviewed By: rjmccall

Subscribers: aemerson, cfe-commits, kristof.beyls, ahatanak

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

llvm-svn: 323156

6 years agoIntroduce the "retpoline" x86 mitigation technique for variant #2 of the speculative...
Chandler Carruth [Mon, 22 Jan 2018 22:05:25 +0000 (22:05 +0000)]
Introduce the "retpoline" x86 mitigation technique for variant #2 of the speculative execution vulnerabilities disclosed today, specifically identified by CVE-2017-5715, "Branch Target Injection", and is one of the two halves to Spectre..

Summary:
First, we need to explain the core of the vulnerability. Note that this
is a very incomplete description, please see the Project Zero blog post
for details:
https://googleprojectzero.blogspot.com/2018/01/reading-privileged-memory-with-side.html

The basis for branch target injection is to direct speculative execution
of the processor to some "gadget" of executable code by poisoning the
prediction of indirect branches with the address of that gadget. The
gadget in turn contains an operation that provides a side channel for
reading data. Most commonly, this will look like a load of secret data
followed by a branch on the loaded value and then a load of some
predictable cache line. The attacker then uses timing of the processors
cache to determine which direction the branch took *in the speculative
execution*, and in turn what one bit of the loaded value was. Due to the
nature of these timing side channels and the branch predictor on Intel
processors, this allows an attacker to leak data only accessible to
a privileged domain (like the kernel) back into an unprivileged domain.

The goal is simple: avoid generating code which contains an indirect
branch that could have its prediction poisoned by an attacker. In many
cases, the compiler can simply use directed conditional branches and
a small search tree. LLVM already has support for lowering switches in
this way and the first step of this patch is to disable jump-table
lowering of switches and introduce a pass to rewrite explicit indirectbr
sequences into a switch over integers.

However, there is no fully general alternative to indirect calls. We
introduce a new construct we call a "retpoline" to implement indirect
calls in a non-speculatable way. It can be thought of loosely as
a trampoline for indirect calls which uses the RET instruction on x86.
Further, we arrange for a specific call->ret sequence which ensures the
processor predicts the return to go to a controlled, known location. The
retpoline then "smashes" the return address pushed onto the stack by the
call with the desired target of the original indirect call. The result
is a predicted return to the next instruction after a call (which can be
used to trap speculative execution within an infinite loop) and an
actual indirect branch to an arbitrary address.

On 64-bit x86 ABIs, this is especially easily done in the compiler by
using a guaranteed scratch register to pass the target into this device.
For 32-bit ABIs there isn't a guaranteed scratch register and so several
different retpoline variants are introduced to use a scratch register if
one is available in the calling convention and to otherwise use direct
stack push/pop sequences to pass the target address.

This "retpoline" mitigation is fully described in the following blog
post: https://support.google.com/faqs/answer/7625886

We also support a target feature that disables emission of the retpoline
thunk by the compiler to allow for custom thunks if users want them.
These are particularly useful in environments like kernels that
routinely do hot-patching on boot and want to hot-patch their thunk to
different code sequences. They can write this custom thunk and use
`-mretpoline-external-thunk` *in addition* to `-mretpoline`. In this
case, on x86-64 thu thunk names must be:
```
  __llvm_external_retpoline_r11
```
or on 32-bit:
```
  __llvm_external_retpoline_eax
  __llvm_external_retpoline_ecx
  __llvm_external_retpoline_edx
  __llvm_external_retpoline_push
```
And the target of the retpoline is passed in the named register, or in
the case of the `push` suffix on the top of the stack via a `pushl`
instruction.

There is one other important source of indirect branches in x86 ELF
binaries: the PLT. These patches also include support for LLD to
generate PLT entries that perform a retpoline-style indirection.

The only other indirect branches remaining that we are aware of are from
precompiled runtimes (such as crt0.o and similar). The ones we have
found are not really attackable, and so we have not focused on them
here, but eventually these runtimes should also be replicated for
retpoline-ed configurations for completeness.

For kernels or other freestanding or fully static executables, the
compiler switch `-mretpoline` is sufficient to fully mitigate this
particular attack. For dynamic executables, you must compile *all*
libraries with `-mretpoline` and additionally link the dynamic
executable and all shared libraries with LLD and pass `-z retpolineplt`
(or use similar functionality from some other linker). We strongly
recommend also using `-z now` as non-lazy binding allows the
retpoline-mitigated PLT to be substantially smaller.

When manually apply similar transformations to `-mretpoline` to the
Linux kernel we observed very small performance hits to applications
running typical workloads, and relatively minor hits (approximately 2%)
even for extremely syscall-heavy applications. This is largely due to
the small number of indirect branches that occur in performance
sensitive paths of the kernel.

When using these patches on statically linked applications, especially
C++ applications, you should expect to see a much more dramatic
performance hit. For microbenchmarks that are switch, indirect-, or
virtual-call heavy we have seen overheads ranging from 10% to 50%.

However, real-world workloads exhibit substantially lower performance
impact. Notably, techniques such as PGO and ThinLTO dramatically reduce
the impact of hot indirect calls (by speculatively promoting them to
direct calls) and allow optimized search trees to be used to lower
switches. If you need to deploy these techniques in C++ applications, we
*strongly* recommend that you ensure all hot call targets are statically
linked (avoiding PLT indirection) and use both PGO and ThinLTO. Well
tuned servers using all of these techniques saw 5% - 10% overhead from
the use of retpoline.

We will add detailed documentation covering these components in
subsequent patches, but wanted to make the core functionality available
as soon as possible. Happy for more code review, but we'd really like to
get these patches landed and backported ASAP for obvious reasons. We're
planning to backport this to both 6.0 and 5.0 release streams and get
a 5.0 release with just this cherry picked ASAP for distros and vendors.

This patch is the work of a number of people over the past month: Eric, Reid,
Rui, and myself. I'm mailing it out as a single commit due to the time
sensitive nature of landing this and the need to backport it. Huge thanks to
everyone who helped out here, and everyone at Intel who helped out in
discussions about how to craft this. Also, credit goes to Paul Turner (at
Google, but not an LLVM contributor) for much of the underlying retpoline
design.

Reviewers: echristo, rnk, ruiu, craig.topper, DavidKreitzer

Subscribers: sanjoy, emaste, mcrosier, mgorny, mehdi_amini, hiraditya, llvm-commits

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

llvm-svn: 323155

6 years ago[WebAssembly] Remove --emit-relocs
Sam Clegg [Mon, 22 Jan 2018 21:55:43 +0000 (21:55 +0000)]
[WebAssembly] Remove --emit-relocs

This was added to mimic ELF, but maintaining it has cost
and we currently don't have any use for it outside of the
test code.

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

llvm-svn: 323154

6 years ago[AMDGPU] SI Load Store Optimizer: When merging with offset, use V_ADD_{I|U}32_e64
Mark Searles [Mon, 22 Jan 2018 21:46:43 +0000 (21:46 +0000)]
[AMDGPU] SI Load Store Optimizer: When merging with offset, use V_ADD_{I|U}32_e64
- Change inserted add ( V_ADD_{I|U}32_e32 ) to _e64 version ( V_ADD_{I|U}32_e64 ) so that the add uses a vreg for the carry; this prevents inserted v_add from killing VCC; the _e64 version doesn't accept a literal in its encoding, so we need to introduce a mov instr as well to get the imm into a register.
- Change pass name to "SI Load Store Optimizer"; this removes the '/', which complicates scripts.

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

llvm-svn: 323153

6 years agoAnother batch of P0202 constepr algirithms. remove/remove_if/remove_copy/remove_copy_...
Marshall Clow [Mon, 22 Jan 2018 21:43:04 +0000 (21:43 +0000)]
Another batch of P0202 constepr algirithms. remove/remove_if/remove_copy/remove_copy_if/reverse_copy, and tests (commented out) for rotate_copy, because that depends on std::copy

llvm-svn: 323152

6 years ago[clangd] Drop ~destructor completions - rarely helpful and work inconsistently
Sam McCall [Mon, 22 Jan 2018 21:05:00 +0000 (21:05 +0000)]
[clangd] Drop ~destructor completions - rarely helpful and work inconsistently

llvm-svn: 323149

6 years ago[CodeComplete] Omit templated constructors from member list too.
Sam McCall [Mon, 22 Jan 2018 20:44:47 +0000 (20:44 +0000)]
[CodeComplete] Omit templated constructors from member list too.

Also avoid printing a 'void' return type for constructor expressions.

llvm-svn: 323148