platform/upstream/llvm.git
6 years ago[libclang] Allow skipping function bodies in preamble only
Ivan Donchevskii [Thu, 17 May 2018 07:31:29 +0000 (07:31 +0000)]
[libclang] Allow skipping function bodies in preamble only

As an addition to CXTranslationUnit_SkipFunctionBodies, provide the
new option CXTranslationUnit_LimitSkipFunctionBodiesToPreamble,
which constraints the skipping of functions bodies to the preamble
only. Function bodies in the main file are not affected if this
option is set.

Skipping function bodies only in the preamble is what clangd already
does and the introduced flag implements it for libclang clients.

Patch by Nikolai Kosjar.

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

llvm-svn: 332578

6 years ago[SROA] Handle PHI with multiple duplicate predecessors
Bjorn Pettersson [Thu, 17 May 2018 07:21:41 +0000 (07:21 +0000)]
[SROA] Handle PHI with multiple duplicate predecessors

Summary:
The verifier accepts PHI nodes with multiple entries for the
same basic block, as long as the value is the same.

As seen in PR37203, SROA did not handle such PHI nodes properly
when speculating loads over the PHI, since it inserted multiple
loads in the predecessor block and changed the PHI into having
multiple entries for the same basic block, but with different
values.

This patch teaches SROA to reuse the same speculated load for
each PHI duplicate entry in such situations.

Resolves: https://bugs.llvm.org/show_bug.cgi?id=37203

Reviewers: uabelho, chandlerc, hfinkel, bkramer, efriedma

Reviewed By: efriedma

Subscribers: dberlin, efriedma, llvm-commits

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

llvm-svn: 332577

6 years agoFix rL332458: [AST] Added a helper to extract a user-friendly text of a comment.
Clement Courbet [Thu, 17 May 2018 06:46:15 +0000 (06:46 +0000)]
Fix rL332458: [AST] Added a helper to extract a user-friendly text of a comment.

Older gcc versions do not support raw string literals within macros.

llvm-svn: 332576

6 years ago[SROA] pr37267: fix assertion failure in integer widening
Hiroshi Inoue [Thu, 17 May 2018 06:32:17 +0000 (06:32 +0000)]
[SROA] pr37267: fix assertion failure in integer widening

The current integer widening does not support rewriting partial split slices in rewriteIntegerStore (and rewriteIntegerLoad).
This patch adds explicit checks for this case in isIntegerWideningViableForSlice.
Before r322533, splitting is allowed only for the whole-alloca slice and hence the above case is implicitly rejected by another check `if (DL.getTypeStoreSize(ValueTy) > Size)` because whole-alloca slice is larger than the partition.

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

llvm-svn: 332575

6 years ago[RISCV] Add support for .half, .hword, .word, .dword directives
Alex Bradbury [Thu, 17 May 2018 05:58:08 +0000 (05:58 +0000)]
[RISCV] Add support for .half, .hword, .word, .dword directives

These directives are recognised by gas. Support is added through the use of
addAliasForDirective.

Also match RISC-V gcc in preferring .half and .word for 16-bit and 32-bit data
directives.

llvm-svn: 332574

6 years ago[X86] Add OptForSize to a couple load folding patterns. Remove some bad FIXME comments.
Craig Topper [Thu, 17 May 2018 05:41:11 +0000 (05:41 +0000)]
[X86] Add OptForSize to a couple load folding patterns. Remove some bad FIXME comments.

The FIXME comments were about preventing load folding to avoid a partial xmm update. But these instructions use GPR as input when the load isn't folded. This won't help prevent a partial xmm update.

llvm-svn: 332573

6 years ago[ELF] PowerOpen ABI -> Power Architecture 64-bit v2 ABI. NFC
Fangrui Song [Thu, 17 May 2018 05:34:29 +0000 (05:34 +0000)]
[ELF] PowerOpen ABI -> Power Architecture 64-bit v2 ABI. NFC

Reviewers: sfertile, espindola

Subscribers: emaste, arichardson, llvm-commits

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

llvm-svn: 332572

6 years ago[libcxx] [test] Remove unused local typedef in test/std/numerics/rand/rand.eng/rand...
Billy Robert O'Neal III [Thu, 17 May 2018 04:59:34 +0000 (04:59 +0000)]
[libcxx] [test] Remove unused local typedef in test/std/numerics/rand/rand.eng/rand.eng.lcong/default.pass.cpp

llvm-svn: 332571

6 years ago[CMake] Support building shared library for Fuchsia
Petr Hosek [Thu, 17 May 2018 03:39:03 +0000 (03:39 +0000)]
[CMake] Support building shared library for Fuchsia

Fuchsia uses ELF as a file format and LLD as the linker so we can
use the same implementation as other ELF based platforms.

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

llvm-svn: 332570

6 years ago[Thumb2] fix typo in test from r332548
Sanjay Patel [Thu, 17 May 2018 03:24:25 +0000 (03:24 +0000)]
[Thumb2] fix typo in test from r332548

llvm-svn: 332569

6 years agoAdd void casts to suppress nodiscard on linear_congruential_engine.
Billy Robert O'Neal III [Thu, 17 May 2018 02:58:26 +0000 (02:58 +0000)]
Add void casts to suppress nodiscard on linear_congruential_engine.

llvm-svn: 332567

6 years agoMark test with "REQUIRES: shell" since it directly invokes "sh" and was failing on...
Douglas Yung [Thu, 17 May 2018 01:36:25 +0000 (01:36 +0000)]
Mark test with "REQUIRES: shell" since it directly invokes "sh" and was failing on Windows.

llvm-svn: 332563

6 years ago[AMDGPU] Move lsr test. NFC.
Stanislav Mekhanoshin [Thu, 17 May 2018 01:30:51 +0000 (01:30 +0000)]
[AMDGPU] Move lsr test. NFC.

llvm-svn: 332562

6 years ago[WebAssembly] Fix the opcode number for i64.load16_u.
Dan Gohman [Thu, 17 May 2018 00:14:13 +0000 (00:14 +0000)]
[WebAssembly] Fix the opcode number for i64.load16_u.

Fixes PR37488.

llvm-svn: 332561

6 years ago[CodeGen] Use MachineInstr::getOperand(0) instead of gets the defs iterator_range...
Craig Topper [Wed, 16 May 2018 23:39:27 +0000 (23:39 +0000)]
[CodeGen] Use MachineInstr::getOperand(0) instead of gets the defs iterator_range and calling begin. NFC

Defs are well defined to come first in MachineInstr operand list. No need for a more complex indirection.

llvm-svn: 332559

6 years ago[libFuzzer] rename a test from .c to .cpp
Kostya Serebryany [Wed, 16 May 2018 23:38:53 +0000 (23:38 +0000)]
[libFuzzer] rename a test from .c to .cpp

llvm-svn: 332558

6 years ago[asan] Add a magic shadow value for shadw gap
Walter Lee [Wed, 16 May 2018 23:36:01 +0000 (23:36 +0000)]
[asan] Add a magic shadow value for shadw gap

This gives us something to insert into the shadow gap for systems that
don't have memory protection turned on there (i.e. on Myriad).

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

llvm-svn: 332557

6 years agoRevert 332511 after reverting llvm revision 332508.
Greg Clayton [Wed, 16 May 2018 23:32:45 +0000 (23:32 +0000)]
Revert 332511 after reverting llvm revision 332508.

llvm-svn: 332556

6 years agoRevert 332508 as it caused problems in the clang test suite.
Greg Clayton [Wed, 16 May 2018 23:29:36 +0000 (23:29 +0000)]
Revert 332508 as it caused problems in the clang test suite.

llvm-svn: 332555

6 years ago[libFuzzer] add an experimental flag -focus_function: libFuzzer will try to focus...
Kostya Serebryany [Wed, 16 May 2018 23:26:37 +0000 (23:26 +0000)]
[libFuzzer] add an experimental flag -focus_function: libFuzzer will try to focus on inputs that trigger that function

llvm-svn: 332554

6 years ago[asan] Restore check removed by r332033
Walter Lee [Wed, 16 May 2018 23:23:56 +0000 (23:23 +0000)]
[asan] Restore check removed by r332033

Needed by fiber handling code, and possibly other code paths.

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

llvm-svn: 332553

6 years ago[STLExtras] Add size() for ranges, and remove distance()
Vedant Kumar [Wed, 16 May 2018 23:20:42 +0000 (23:20 +0000)]
[STLExtras] Add size() for ranges, and remove distance()

r332057 introduced distance() for ranges. Based on post-commit feedback,
this renames distance() to size(). The new size() is also only enabled
when the operation is O(1).

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

llvm-svn: 332551

6 years ago[Hexagon] preserve test intent by removing undef
Sanjay Patel [Wed, 16 May 2018 22:49:08 +0000 (22:49 +0000)]
[Hexagon] preserve test intent by removing undef

We need to clean up the DAG floating-point undef logic.
This process is similar to how we handled integer undef
logic in D43141.

And as we did there, I'm trying to reduce the patch by
changing tests that would probably become meaningless
once we correct FP undef folding.

llvm-svn: 332550

6 years ago[PowerPC] preserve test intent by removing undef
Sanjay Patel [Wed, 16 May 2018 22:48:48 +0000 (22:48 +0000)]
[PowerPC] preserve test intent by removing undef

We need to clean up the DAG floating-point undef logic.
This process is similar to how we handled integer undef
logic in D43141.

And as we did there, I'm trying to reduce the patch by
changing tests that would probably become meaningless
once we correct FP undef folding.

llvm-svn: 332549

6 years ago[Thumb] preserve test intent by removing undef
Sanjay Patel [Wed, 16 May 2018 22:47:51 +0000 (22:47 +0000)]
[Thumb] preserve test intent by removing undef

We need to clean up the DAG floating-point undef logic.
This process is similar to how we handled integer undef
logic in D43141.

And as we did there, I'm trying to reduce the patch by
changing tests that would probably become meaningless
once we correct FP undef folding.

llvm-svn: 332548

6 years ago[Thumb] preserve test intent by removing undef
Sanjay Patel [Wed, 16 May 2018 22:47:42 +0000 (22:47 +0000)]
[Thumb] preserve test intent by removing undef

We need to clean up the DAG floating-point undef logic.
This process is similar to how we handled integer undef
logic in D43141.

And as we did there, I'm trying to reduce the patch by
changing tests that would probably become meaningless
once we correct FP undef folding.

llvm-svn: 332547

6 years ago[analyzer] Extend ObjCAutoreleaseWriteChecker to catch block declarations with autore...
George Karpenkov [Wed, 16 May 2018 22:47:05 +0000 (22:47 +0000)]
[analyzer] Extend ObjCAutoreleaseWriteChecker to catch block declarations with autoreleasing variables

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

llvm-svn: 332546

6 years ago[ASTMatchers] Introduce a blockDecl matcher for matching block declarations
George Karpenkov [Wed, 16 May 2018 22:47:03 +0000 (22:47 +0000)]
[ASTMatchers] Introduce a blockDecl matcher for matching block declarations

Blocks can be matched just as well as functions or Objective-C methods.

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

llvm-svn: 332545

6 years ago[analyzer] Change the warning message for GCD antipattern checker
George Karpenkov [Wed, 16 May 2018 22:46:47 +0000 (22:46 +0000)]
[analyzer] Change the warning message for GCD antipattern checker

llvm-svn: 332544

6 years agoCondition usage of locale stdlib functions on Android API version
Peter Collingbourne [Wed, 16 May 2018 22:40:12 +0000 (22:40 +0000)]
Condition usage of locale stdlib functions on Android API version

Some *_l functions were not available in some versions of Bionic. This CL
checks that the NDK version supports the functions, and if not, falls back
on the corresponding functions that don't take a locale.

Patch by Tom Anderson!

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

llvm-svn: 332543

6 years ago[NFC] WebAssembly build break #2
JF Bastien [Wed, 16 May 2018 22:31:42 +0000 (22:31 +0000)]
[NFC] WebAssembly build break #2

Summary:
Same as r332530, move WasmSymbol::dump to an implementation file to avoid linker
issues when the dump function is seen in the header, doesn't get eliminated, and
then linking fails because of the missing dependency.

<rdar://problem/40258137>

Reviewers: sbc100, ncw, paquette, vsk, dschuff

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

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

llvm-svn: 332542

6 years ago[ORC] Rewrite the VSO symbol table yet again. Update related utilities.
Lang Hames [Wed, 16 May 2018 22:24:30 +0000 (22:24 +0000)]
[ORC] Rewrite the VSO symbol table yet again. Update related utilities.

VSOs now track dependencies for materializing symbols. Each symbol must have its
dependencies registered with the VSO prior to finalization. Usually this will
involve registering the dependencies returned in
AsynchronousSymbolQuery::ResolutionResults for queries made while linking the
symbols being materialized.

Queries against symbols are notified that a symbol is ready once it and all of
its transitive dependencies are finalized, allowing compilation work to be
broken up and moved between threads without queries returning until their
symbols fully safe to access / execute.

Related utilities (VSO, MaterializationUnit, MaterializationResponsibility) are
updated to support dependence tracking and more explicitly track responsibility
for symbols from the point of definition until they are finalized.

llvm-svn: 332541

6 years ago[X86] Update SNB/generic scheduler tests missed from rL332536
Simon Pilgrim [Wed, 16 May 2018 22:24:22 +0000 (22:24 +0000)]
[X86] Update SNB/generic scheduler tests missed from rL332536

llvm-svn: 332540

6 years ago[ARM] preserve test intent by removing undef
Sanjay Patel [Wed, 16 May 2018 22:20:33 +0000 (22:20 +0000)]
[ARM] preserve test intent by removing undef

We need to clean up the DAG floating-point undef logic.
This process is similar to how we handled integer undef
logic in D43141.

And as we did there, I'm trying to reduce the patch by
changing tests that would probably become meaningless
once we correct FP undef folding.

llvm-svn: 332539

6 years ago[ARM] preserve test intent by removing undef
Sanjay Patel [Wed, 16 May 2018 22:20:26 +0000 (22:20 +0000)]
[ARM] preserve test intent by removing undef

We need to clean up the DAG floating-point undef logic.
This process is similar to how we handled integer undef
logic in D43141.

And as we did there, I'm trying to reduce the patch by
changing tests that would probably become meaningless
once we correct FP undef folding.

llvm-svn: 332538

6 years ago[ARM] preserve test intent by removing undef
Sanjay Patel [Wed, 16 May 2018 22:20:11 +0000 (22:20 +0000)]
[ARM] preserve test intent by removing undef

We need to clean up the DAG floating-point undef logic.
This process is similar to how we handled integer undef
logic in D43141.

And as we did there, I'm trying to reduce the patch by
changing tests that would probably become meaningless
once we correct FP undef folding.

llvm-svn: 332537

6 years ago[X86][SNB] Remove unnecessary CVT InstRW overrides
Simon Pilgrim [Wed, 16 May 2018 22:14:29 +0000 (22:14 +0000)]
[X86][SNB] Remove unnecessary CVT InstRW overrides

llvm-svn: 332536

6 years ago[WebAssembly] Remove unused headers in MCWasmObjectWriter
Sam Clegg [Wed, 16 May 2018 22:13:18 +0000 (22:13 +0000)]
[WebAssembly] Remove unused headers in MCWasmObjectWriter

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

llvm-svn: 332535

6 years ago[AArch64] preserve test intent by removing undef
Sanjay Patel [Wed, 16 May 2018 21:57:57 +0000 (21:57 +0000)]
[AArch64] preserve test intent by removing undef

We need to clean up the DAG floating-point undef logic.
This process is similar to how we handled integer undef
logic in D43141.

And as we did there, I'm trying to reduce the patch by
changing tests that would probably become meaningless
once we correct FP undef folding.

llvm-svn: 332534

6 years ago[ARM] preserve test intent by removing undef
Sanjay Patel [Wed, 16 May 2018 21:57:19 +0000 (21:57 +0000)]
[ARM] preserve test intent by removing undef

We need to clean up the DAG floating-point undef logic.
This process is similar to how we handled integer undef
logic in D43141.

And as we did there, I'm trying to reduce the patch by
changing tests that would probably become meaningless
once we correct FP undef folding.

llvm-svn: 332533

6 years ago[ARM] preserve test intent by removing undef
Sanjay Patel [Wed, 16 May 2018 21:57:00 +0000 (21:57 +0000)]
[ARM] preserve test intent by removing undef

We need to clean up the DAG floating-point undef logic.
This process is similar to how we handled integer undef
logic in D43141.

And as we did there, I'm trying to reduce the patch by
changing tests that would probably become meaningless
once we correct FP undef folding.

llvm-svn: 332532

6 years ago[InstCombine] Fix the signature of fgets_unlocked.
Benjamin Kramer [Wed, 16 May 2018 21:45:39 +0000 (21:45 +0000)]
[InstCombine] Fix the signature of fgets_unlocked.

It returns a pointer, not an int. This miscompiles all code that uses
the return value of fgets.

llvm-svn: 332531

6 years ago[NFC] WebAssembly build fix
JF Bastien [Wed, 16 May 2018 21:24:03 +0000 (21:24 +0000)]
[NFC] WebAssembly build fix

Summary:
r332305 added a use of llvm::wasm::toString in llvm::object::WasmSymbol::print,
which is in a header file. It also moves toString to BinaryFormat. This has the
unintended side-effect that any inclusion of Object/Wasm.h now relies on
toString, and needs to required_libraries = BinaryFormat. Thankfully most builds
don't fail with this because print just isn't used and gets eliminated, dropping
the required dependency in the process. Not all builds are so lucky.

Fix this issue by moving print to the corresponding .cpp file.

<rdar://problem/40258137>

Reviewers: sbc100, ncw, paquette

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

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

llvm-svn: 332530

6 years ago[MachineOutliner] Don't outline instructions that modify SP.
Eli Friedman [Wed, 16 May 2018 21:20:16 +0000 (21:20 +0000)]
[MachineOutliner] Don't outline instructions that modify SP.

This breaks the code which saves and restores LR, so we can't outline
without doing something more complicated for stack adjustment.

Found by inspection; we get lucky in most cases because getMemOpInfo
only handles STRWpost, not any other pre/post-increment forms. But it
hits a couple of artificial testcases in the tree.

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

llvm-svn: 332529

6 years ago_WIN32 straggler I missed in r331127; no-op in practice
Nico Weber [Wed, 16 May 2018 21:13:56 +0000 (21:13 +0000)]
_WIN32 straggler I missed in r331127; no-op in practice

llvm-svn: 332528

6 years agoAdd support for ThinLTO plugin option thinlto-object-suffix-replace
Rumeet Dhindsa [Wed, 16 May 2018 21:04:08 +0000 (21:04 +0000)]
Add support for ThinLTO plugin option thinlto-object-suffix-replace

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

llvm-svn: 332527

6 years ago[Hexagon] Fix the order of operands when selecting QCAT
Krzysztof Parzyszek [Wed, 16 May 2018 21:02:43 +0000 (21:02 +0000)]
[Hexagon] Fix the order of operands when selecting QCAT

llvm-svn: 332526

6 years ago[Hexagon] Mark HVX vector predicate bitwise ops as legal, add patterns
Krzysztof Parzyszek [Wed, 16 May 2018 21:00:24 +0000 (21:00 +0000)]
[Hexagon] Mark HVX vector predicate bitwise ops as legal, add patterns

llvm-svn: 332525

6 years ago[X86][SSE] Reduce instruction/register usages for v4i32 vector shifts (PR37441)
Simon Pilgrim [Wed, 16 May 2018 20:52:52 +0000 (20:52 +0000)]
[X86][SSE] Reduce instruction/register usages for v4i32 vector shifts (PR37441)

As suggested by Fabian on PR37441, use PSHUFLW to extend shift amount types for use with PSRAD/PSRLD to reduce register pressure.

Some of this ideally would be done by combineTargetShuffle but its tricky to do as most of the shuffles are sharing inputs.

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

llvm-svn: 332524

6 years agoAMDGPU : Recalculate SGPRs when trap handler is supported
Konstantin Zhuravlyov [Wed, 16 May 2018 20:47:48 +0000 (20:47 +0000)]
AMDGPU : Recalculate SGPRs when trap handler is supported

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

llvm-svn: 332523

6 years agoFix small grammar-o.
Eric Christopher [Wed, 16 May 2018 20:34:00 +0000 (20:34 +0000)]
Fix small grammar-o.

llvm-svn: 332522

6 years agoFix up a misleading format warning.
Eric Christopher [Wed, 16 May 2018 20:33:59 +0000 (20:33 +0000)]
Fix up a misleading format warning.

llvm-svn: 332521

6 years agoSecond attempt to fix buildbot failure caused by r332363
Eric Liu [Wed, 16 May 2018 20:31:38 +0000 (20:31 +0000)]
Second attempt to fix buildbot failure caused by r332363

http://lab.llvm.org:8011/builders/clang-x86_64-linux-abi-test/builds/26501

llvm-svn: 332520

6 years agoAdd a new check, readability-simplify-subscript-expr, that diagnoses array subscript...
Aaron Ballman [Wed, 16 May 2018 20:12:06 +0000 (20:12 +0000)]
Add a new check, readability-simplify-subscript-expr, that diagnoses array subscript expressions that can be simplified.

Currently, diagnoses code that calls container.data()[some_index] when the container exposes a suitable operator[]() method that can be used directly.

Patch by Shuai Wang.

llvm-svn: 332519

6 years ago[clang-move] Fix a potential bug where realpath doesn't work on VFS.
Eric Liu [Wed, 16 May 2018 20:10:10 +0000 (20:10 +0000)]
[clang-move] Fix a potential bug where realpath doesn't work on VFS.

llvm-svn: 332518

6 years ago[WebAssembly] MC: Ensure that FUNCTION_OFFSET relocations are always against function...
Sam Clegg [Wed, 16 May 2018 20:09:05 +0000 (20:09 +0000)]
[WebAssembly] MC: Ensure that FUNCTION_OFFSET relocations are always against function symbols.

The getAtom() method wasn't doing what we needed in all cases. We want
the symbols for the function which defines that section. We can compute
this easily enough and we know that we have at most one function in each
section.

Once this lands I will revert rL331412 which is no longer needed.

Fixes PR37409

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

llvm-svn: 332517

6 years ago[clang-tidy/google-readability-casting] Disable check for Objective-C++
Ben Hamilton [Wed, 16 May 2018 20:07:19 +0000 (20:07 +0000)]
[clang-tidy/google-readability-casting] Disable check for Objective-C++

Summary:
Previously, `google-readability-casting` was disabled for Objective-C.

The Google Objective-C++ style allows both Objective-C and
C++ style in the same file. Since clang-tidy doesn't have a good
way to allow multiple styles per file, this disables the
check for Objective-C++.

Test Plan: New tests added. Ran tests with:
  % make -j16 check-clang-tools
  Before diff, confirmed tests failed:
  https://reviews.llvm.org/P8081
  After diff, confirrmed tests passed.

Reviewers: alexfh, Wizard, hokein, stephanemoore

Reviewed By: alexfh, Wizard, stephanemoore

Subscribers: stephanemoore, cfe-commits, bkramer, klimek

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

llvm-svn: 332516

6 years agoAttempt to fix buildbot failure caused by r332363
Eric Liu [Wed, 16 May 2018 19:59:49 +0000 (19:59 +0000)]
Attempt to fix buildbot failure caused by r332363

Log: http://lab.llvm.org:8011/builders/clang-x86_64-linux-abi-test/builds/26399
llvm-svn: 332515

6 years ago[MachineOutliner] Don't save/restore LR for tail calls.
Eli Friedman [Wed, 16 May 2018 19:49:01 +0000 (19:49 +0000)]
[MachineOutliner] Don't save/restore LR for tail calls.

The cost computation assumes we do this correctly, but the actual
lowering was wrong.

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

llvm-svn: 332514

6 years ago[OR1K] Add the EPCR special-purpose register to register state.
whitequark [Wed, 16 May 2018 19:09:48 +0000 (19:09 +0000)]
[OR1K] Add the EPCR special-purpose register to register state.

This makes it possible to unwind hardware exception stack frames,
which necessarily save every register and so need an extra column
for storing the return address. CFI for the exception handler could
then look as follows:

.globl exception_vector
exception_vector:
    .cfi_startproc
    .cfi_signal_frame
    .cfi_return_column 32
    l.addi  r1, r1, -0x100
    .cfi_def_cfa_offset 0x100
    l.sw    0x00(r1), r2
    .cfi_offset 2, 0x00-0x100
    l.sw    0x04(r1), r3
    .cfi_offset 3, 0x04-0x100
    l.sw    0x08(r1), r4
    .cfi_offset 4, 0x08-0x100
    l.mfspr r3, r0, SPR_EPCR_BASE
    l.sw    0x78(r1), r3
    .cfi_offset 32, 0x78-0x100
    l.jal   exception_handler
     l.nop
    l.lwz   r2, 0x00(r1)
    l.lwz   r3, 0x04(r1)
    l.lwz   r4, 0x08(r1)
    l.jr    r9
     l.nop
    .cfi_endproc

This register could, of course, also be accessed by the trace
callback or personality function, if so desired.

llvm-svn: 332513

6 years ago[OR1K] Add a dedicated PC register to register state.
whitequark [Wed, 16 May 2018 19:09:41 +0000 (19:09 +0000)]
[OR1K] Add a dedicated PC register to register state.

Before this commit, R9, the link register, was used as PC register.
However, a stack frame may have R9 not set to PC on entry, either
because it uses a custom calling convention, or, more likely,
because this is a signal or exception stack frame. Using R9 as
PC register made it impossible to unwind such frames.

All other architectures similarly use a dedicated PC register.

llvm-svn: 332512

6 years agoFix FileSpecTest after LLVM changes to remove_dots (https://reviews.llvm.org/D46887)
Greg Clayton [Wed, 16 May 2018 18:37:00 +0000 (18:37 +0000)]
Fix FileSpecTest after LLVM changes to remove_dots (https://reviews.llvm.org/D46887)

llvm-svn: 332511

6 years ago[X86] Fix typo in instregex for CVTSI642SDrr
Simon Pilgrim [Wed, 16 May 2018 18:31:17 +0000 (18:31 +0000)]
[X86] Fix typo in instregex for CVTSI642SDrr

llvm-svn: 332510

6 years ago[Sema] Fix assertion when constructor is disabled with partially specialized template.
Volodymyr Sapsai [Wed, 16 May 2018 18:28:58 +0000 (18:28 +0000)]
[Sema] Fix assertion when constructor is disabled with partially specialized template.

The added test case was triggering assertion

> Assertion failed: (!SpecializedTemplate.is<SpecializedPartialSpecialization*>() && "Already set to a class template partial specialization!"), function setInstantiationOf, file clang/include/clang/AST/DeclTemplate.h, line 1825.

It was happening with ClassTemplateSpecializationDecl
`enable_if_not_same<int, int>`. Because this template is specialized for
equal types not to have a definition, it wasn't instantiated and its
specialization kind remained TSK_Undeclared. And because it was implicit
instantiation, we didn't mark the decl as invalid. So when we try to
find the best matching partial specialization the second time, we hit
the assertion as partial specialization is already set.

Fix by reusing stored partial specialization when available, instead of
looking for the best match every time.

rdar://problem/39524996

Reviewers: rsmith, arphaman

Reviewed By: rsmith

Subscribers: cfe-commits

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

llvm-svn: 332509

6 years agoFix llvm::sys::path::remove_dots() to return "." instead of an empty path.
Greg Clayton [Wed, 16 May 2018 18:25:51 +0000 (18:25 +0000)]
Fix llvm::sys::path::remove_dots() to return "." instead of an empty path.

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

llvm-svn: 332508

6 years ago[libFuzzer] add a symbolic execution puzzle (difficult for today's libFuzzer).
Max Moroz [Wed, 16 May 2018 18:19:30 +0000 (18:19 +0000)]
[libFuzzer] add a symbolic execution puzzle (difficult for today's libFuzzer).

Summary:
This can be solved just in seconds with KLEE. Current libFuzzer
is able to satistfy 101 constraints out of 410 constraints presented during
the first hour of running with -use_value_profile=1 and -max_len=20.
During the next 3 hours, libFuzzer is able to generate ~50 NEW inputs,
bot none of those solve any new constraint.
During the next 20 hours, it didn't find any NEW inputs.

This test might be interesting for experimenting with the data flow tracing
approach started in https://reviews.llvm.org/D46666.

For the solution with KLEE and other information, see
https://github.com/Dor1s/codegate2017-quals-angrybird

Reviewers: kcc

Reviewed By: kcc

Subscribers: delcypher, llvm-commits, #sanitizers

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

llvm-svn: 332507

6 years ago[Timers] TimerGroup: add constructor from StringMap<TimeRecord>
Roman Lebedev [Wed, 16 May 2018 18:16:01 +0000 (18:16 +0000)]
[Timers] TimerGroup: add constructor from StringMap<TimeRecord>

Summary:
This is needed for the continuation of D46504,
to be able to store the timings.

Reviewers: george.karpenkov, NoQ, alexfh, sbenza

Reviewed By: alexfh

Subscribers: llvm-commits, cfe-commits

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

llvm-svn: 332506

6 years ago[Timers] TimerGroup: make printJSONValues() method public
Roman Lebedev [Wed, 16 May 2018 18:15:56 +0000 (18:15 +0000)]
[Timers] TimerGroup: make printJSONValues() method public

Summary:
This is needed for the continuation of D46504,
to be able to store the timings.

Reviewers: george.karpenkov, NoQ, alexfh, sbenza

Reviewed By: alexfh

Subscribers: llvm-commits, cfe-commits

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

llvm-svn: 332505

6 years ago[Timers] TimerGroup::printJSONValue(): print doubles with no precision loss
Roman Lebedev [Wed, 16 May 2018 18:15:51 +0000 (18:15 +0000)]
[Timers] TimerGroup::printJSONValue(): print doubles with no precision loss

Summary:
Although this is not stricly required, i would very much prefer
not to have known random precision losses along the way.

Reviewers: george.karpenkov, NoQ, alexfh, sbenza

Reviewed By: george.karpenkov

Subscribers: llvm-commits, cfe-commits

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

llvm-svn: 332504

6 years ago[Timers] TimerGroup::printJSONValues(): print mem timer with .mem suffix
Roman Lebedev [Wed, 16 May 2018 18:15:47 +0000 (18:15 +0000)]
[Timers] TimerGroup::printJSONValues(): print mem timer with .mem suffix

Summary: We have just used `.sys` suffix for the previous timer, this is clearly a typo

Reviewers: george.karpenkov, NoQ, alexfh, sbenza

Reviewed By: alexfh

Subscribers: llvm-commits, cfe-commits

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

llvm-svn: 332503

6 years ago[scudo] Quarantine optimization
Kostya Kortchinsky [Wed, 16 May 2018 18:12:31 +0000 (18:12 +0000)]
[scudo] Quarantine optimization

Summary:
It turns out that the previous code construct was not optimizing the allocation
and deallocation of batches. The class id was read as a class member (even
though a precomputed one) and nothing else was optimized. By changing the
construct this way, the compiler actually optimizes most of the allocation and
deallocation away to only work with a single class id, which not only saves some
CPU but also some code footprint.

Reviewers: alekseyshl, dvyukov

Reviewed By: dvyukov

Subscribers: dvyukov, delcypher, llvm-commits, #sanitizers

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

llvm-svn: 332502

6 years ago[x86] preserve test intent by removing undef
Sanjay Patel [Wed, 16 May 2018 17:58:50 +0000 (17:58 +0000)]
[x86] preserve test intent by removing undef

We need to clean up the DAG floating-point undef logic.
This process is similar to how we handled integer undef
logic in D43141.

And as we did there, I'm trying to reduce the patch by
changing tests that would probably become meaningless
once we make those fixes.

llvm-svn: 332501

6 years ago[x86] preserve test intent by removing undef
Sanjay Patel [Wed, 16 May 2018 17:58:08 +0000 (17:58 +0000)]
[x86] preserve test intent by removing undef

We need to clean up the DAG floating-point undef logic.
This process is similar to how we handled integer undef
logic in D43141.

And as we did there, I'm trying to reduce the patch by
changing tests that would probably become meaningless
once we make those fixes.

llvm-svn: 332500

6 years ago[x86] preserve test intent by removing undef
Sanjay Patel [Wed, 16 May 2018 17:57:35 +0000 (17:57 +0000)]
[x86] preserve test intent by removing undef

We need to clean up the DAG floating-point undef logic.
This process is similar to how we handled integer undef
logic in D43141.

And as we did there, I'm trying to reduce the patch by
changing tests that would probably become meaningless
once we make those fixes.

llvm-svn: 332499

6 years ago[X86][AVX512DQ] Use packed instructions for scalar FP<->i64 conversions on 32-bit...
Craig Topper [Wed, 16 May 2018 17:40:07 +0000 (17:40 +0000)]
[X86][AVX512DQ] Use packed instructions for scalar FP<->i64 conversions on 32-bit targets

As i64 types are not legal on 32-bit targets, insert these into a suitable zero vector and use the packed vXi64<->FP conversion instructions instead.

Fixes PR3163.

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

llvm-svn: 332498

6 years ago[Debugify] Tighten up the test for -debugify-each, NFC
Vedant Kumar [Wed, 16 May 2018 17:30:58 +0000 (17:30 +0000)]
[Debugify] Tighten up the test for -debugify-each, NFC

In post-commit review for r332416, Paul Robinson pointed out that the
test for -debugify-each is not checking what it needs to.

This commit tightens up the test.

llvm-svn: 332497

6 years agoSignal handling should be signal-safe
JF Bastien [Wed, 16 May 2018 17:25:35 +0000 (17:25 +0000)]
Signal handling should be signal-safe

Summary:
Before this patch, signal handling wasn't signal safe. This leads to real-world
crashes. It used ManagedStatic inside of signals, this can allocate and can lead
to unexpected state when a signal occurs during llvm_shutdown (because
llvm_shutdown destroys the ManagedStatic). It also used cl::opt without custom
backing storage. Some de-allocation was performed as well. Acquiring a lock in a
signal handler is also a great way to deadlock.

We can't just disable signals on llvm_shutdown because the signals might do
useful work during that shutdown. We also can't just disable llvm_shutdown for
programs (instead of library uses of clang) because we'd have to then mark the
pointers as not leaked and make sure all the ManagedStatic uses are OK to leak
and remain so.

Move all of the code to lock-free datastructures instead, and avoid having any
of them in an inconsistent state. I'm not trying to be fancy, I'm not using any
explicit memory order because this code isn't hot. The only purpose of the
atomics is to guarantee that a signal firing on the same or a different thread
doesn't see an inconsistent state and crash. In some cases we might miss some
state (for example, we might fail to delete a temporary file), but that's fine.

Note that I haven't touched any of the backtrace support despite it not
technically being totally signal-safe. When that code is called we know
something bad is up and we don't expect to continue execution, so calling
something that e.g. sets errno is the least of our problems.

A similar patch should be applied to lib/Support/Windows/Signals.inc, but that
can be done separately.

Fix r332428 which I reverted in r332429. I originally used double-wide CAS
because I was lazy, but some platforms use a runtime function for that which
thankfully failed to link (it would have been bad for signal handlers
otherwise). I use a separate flag to guard the data instead.

<rdar://problem/28010281>

Reviewers: dexonsmith

Subscribers: steven_wu, llvm-commits
llvm-svn: 332496

6 years ago[libomptarget-nvptx-bc] Pass found CUDA installations
Jonas Hahnfeld [Wed, 16 May 2018 17:20:27 +0000 (17:20 +0000)]
[libomptarget-nvptx-bc] Pass found CUDA installations

We already know where the CUDA SDK is, so there is no point in
letting Clang search for it again and possibly finding no or
a different installation.

--cuda-path is supported since the beginning of CUDA support in
Clang, so making this required doesn't impose additional restrictions.

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

llvm-svn: 332495

6 years ago[libomptarget-nvptx] Test bitcode compiler flags and enable by default
Jonas Hahnfeld [Wed, 16 May 2018 17:20:21 +0000 (17:20 +0000)]
[libomptarget-nvptx] Test bitcode compiler flags and enable by default

Move all logic related to selecting the bitcode compiler and linker
into a new file and dynamically test required compiler flags. This
also adds -fcuda-rdc for Clang trunk as previously attempted in D44992
which fixes the build.

As a result this change also enables building the library by default
if all prerequisites are met.

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

llvm-svn: 332494

6 years ago[llvm-mca] Move the RegisterFile class into its own translation unit. NFC
Matt Davis [Wed, 16 May 2018 17:07:08 +0000 (17:07 +0000)]
[llvm-mca] Move the RegisterFile class into its own translation unit. NFC

Summary: This change will help us turn the DispatchUnit into its own stage.

Reviewers: andreadb, RKSimon, courbet

Reviewed By: andreadb, courbet

Subscribers: mgorny, tschuett, gbedwell, llvm-commits

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

llvm-svn: 332493

6 years agoAdd lit tests forgotten for R332470
Erich Keane [Wed, 16 May 2018 17:04:47 +0000 (17:04 +0000)]
Add lit tests forgotten for R332470

I forgot to svn-add the lit tests for R332470.
Added here!

llvm-svn: 332492

6 years ago[Modules] Do not diagnose missing import in recovery mode if there isn't a decl to...
Bruno Cardoso Lopes [Wed, 16 May 2018 17:00:24 +0000 (17:00 +0000)]
[Modules] Do not diagnose missing import in recovery mode if there isn't a decl to lookup

Clang often tries to create implicit module import for error recovery,
which does a great job helping out with diagnostics. However, sometimes
clang does not have enough information given that it's using an invalid
context to move on. Be more strict in those cases to avoid crashes.

We hit crash on invalids because of this but unfortunately there are no
testcases and I couldn't manage to create one. The crashtrace however
indicates pretty clear why it's happening.

rdar://problem/39313933

llvm-svn: 332491

6 years ago[DAG] Prune cycle check in store merge.
Nirav Dave [Wed, 16 May 2018 16:48:20 +0000 (16:48 +0000)]
[DAG] Prune cycle check in store merge.

As part of merging stores we check that fusing the nodes does not
cause a cycle due to one candidate store being indirectly dependent on
another store (this may happen via chained memory copies). This is
done by searching if a store is a predecessor to another store's
value.

Prune the search at the candidate search's root node which is a
predecessor to all candidate stores. This reduces the
size of the subgraph searched in large basic blocks.

Reviewers: jyknight

Subscribers: llvm-commits, hiraditya

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

llvm-svn: 332490

6 years ago[DAG] Defer merge store cycle checking to just before merge. NFCI.
Nirav Dave [Wed, 16 May 2018 16:47:54 +0000 (16:47 +0000)]
[DAG] Defer merge store cycle checking to just before merge. NFCI.

llvm-svn: 332489

6 years ago[DeLICM] Avoid assertion on out-of-quota.
Michael Kruse [Wed, 16 May 2018 16:39:51 +0000 (16:39 +0000)]
[DeLICM] Avoid assertion on out-of-quota.

An assertion was not prepared to be passed a nullptr because the
out-of-quota limit was exceeded.  Bail-out before the assertion
since the assertion does not apply on out-of-quote.

This fixes llvm.org/PR37477.

llvm-svn: 332488

6 years agoGive shared modules in unittests the platform-native extension, make PipSqueak a...
Nico Weber [Wed, 16 May 2018 16:29:05 +0000 (16:29 +0000)]
Give shared modules in unittests the platform-native extension, make PipSqueak a MODULE

As far as I can tell from revision history, there's no good reason to call
these files .so instead of .dll in Windows, so use the normal extension.

Also change PipSquak from SHARED to MODULE -- it's never passed to
target_link_libraries() and only loaded via dlopen(), so MODULE is more
appropriate. This makes it possible to delete a workaround for SHARED ldflags
being not quite right as well.

No intended behavior change.
https://reviews.llvm.org/D46898

llvm-svn: 332487

6 years ago[x86] add run with unsafe global param; NFC
Sanjay Patel [Wed, 16 May 2018 16:23:41 +0000 (16:23 +0000)]
[x86] add run with unsafe global param; NFC

llvm-svn: 332486

6 years ago[AMDGPU] Change llvm.debugtrap to be a debug breakpoint that can resume execution.
Tony Tye [Wed, 16 May 2018 16:19:34 +0000 (16:19 +0000)]
[AMDGPU] Change llvm.debugtrap to be a debug breakpoint that can resume execution.

No longer require the queue pointer to be passed in in fixed SGPRs.

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

llvm-svn: 332485

6 years ago[x86] add tests for DAG FP undef operands; NFC
Sanjay Patel [Wed, 16 May 2018 16:16:48 +0000 (16:16 +0000)]
[x86] add tests for DAG FP undef operands; NFC

llvm-svn: 332484

6 years ago[AArch64][SVE] Improve diagnostics for vectors with incorrect element-size.
Sander de Smalen [Wed, 16 May 2018 15:45:17 +0000 (15:45 +0000)]
[AArch64][SVE] Improve diagnostics for vectors with incorrect element-size.

For regular SVE vector operands, this patch introduces a more
sensible diagnostic when the vector has a wrong suffix (e.g. z0.s vs z0.b).

For example:
  add z0.s, z1.s, z2.b      -> invalid element width
               ^_____^
               mismatch

For the vector-with-shift/extend (e.g. z0.s, uxtw #2) this patch takes
a slightly different approach and instead returns a 'invalid operand'
if the element size is not as expected. This is because the diagnostics
are more specificied to suggest using the right shift/extend suffix. This
is a trade-off not to introduce more operand classes and still provide
useful diagnostics for LD1 and PRF instructions.

For example:
  ld1w z1.s, p0/z, [x0, z0.s] -> invalid shift/extend specified, expected 'z[0..31].s, (uxtw|sxtw)'
  ld1w z1.d, p0/z, [x0, z0.s] -> invalid operand
          ^________________^
               mismatch

For gather prefetches, both 'z0.s' and 'z0.d' would be allowed:
  prfw #0, p0, [x0, z0.s]   -> invalid shift/extend specified, expected 'z[0..31].s, (uxtw|sxtw) #2'
  prfw #0, p0, [x0, z0.d]   -> invalid shift/extend specified, expected 'z[0..31].d, (lsl|uxtw|sxtw) #2'

Without this change, the diagnostic would unnecessarily suggest a
different element size:
  prfw #0, p0, [x0, z0.s]   -> invalid shift/extend specified, expected 'z[0..31].d, (lsl|uxtw|sxtw) #2'

Reviewers: SjoerdMeijer, aemerson, fhahn, samparker, javed.absar

Reviewed By: SjoerdMeijer

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

llvm-svn: 332483

6 years ago[AArch64] Gangup loads and stores for pairing.
Sirish Pande [Wed, 16 May 2018 15:36:52 +0000 (15:36 +0000)]
[AArch64] Gangup loads and stores for pairing.

Keep loads and stores together (target defines how many loads
and stores to gang up), such that it will help in pairing
and vectorization.

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

llvm-svn: 332482

6 years ago[Attr] Don't print fake MSInheritance argument
Joel E. Denny [Wed, 16 May 2018 15:18:30 +0000 (15:18 +0000)]
[Attr] Don't print fake MSInheritance argument

This was discovered at:

http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20180514/228390.html

Reviewed by: aaron.ballman

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

llvm-svn: 332481

6 years agoRevert r332474: [Attr] Don't print fake MSInheritance argument
Joel E. Denny [Wed, 16 May 2018 15:18:27 +0000 (15:18 +0000)]
Revert r332474: [Attr] Don't print fake MSInheritance argument

I botched the commit log attributes.

llvm-svn: 332480

6 years ago[InstCombine] allow more binop (shuffle X), C transforms
Sanjay Patel [Wed, 16 May 2018 15:15:22 +0000 (15:15 +0000)]
[InstCombine] allow more binop (shuffle X), C transforms

The canonicalization was restricted to shuffle masks with
a 1-to-1 mapping to the constant vector, but that disqualifies
the common splat pattern. This is part of solving PR37463:
https://bugs.llvm.org/show_bug.cgi?id=37463

llvm-svn: 332479

6 years ago[sanitizer] Minor 32-bit primary improvements
Kostya Kortchinsky [Wed, 16 May 2018 15:13:26 +0000 (15:13 +0000)]
[sanitizer] Minor 32-bit primary improvements

Summary:
For the 32-bit TransferBatch:
- `SetFromArray` callers have bounds `count`, so relax the `CHECK` to `DCHECK`;
- same for `Add`;
- mark `CopyToArray` as `const`;
For the 32-bit Primary:
- `{Dea,A}llocateBatch` are only called from places that check `class_id`,
  relax the `CHECK` to `DCHECK`;
- same for `AllocateRegion`;
- remove `GetRegionBeginBySizeClass` that is not used;
- use a local variable for the random shuffle state, so that the compiler can
  use a register instead of reading and writing to the `SizeClassInfo` at every
  iteration;
For the 32-bit local cache:
- pass the count to drain instead of doing a `Min` everytime which is at times
  superfluous.

Reviewers: alekseyshl

Reviewed By: alekseyshl

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

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

llvm-svn: 332478

6 years ago[OPENMP] DO not crash on combined constructs in declare target
Alexey Bataev [Wed, 16 May 2018 15:08:32 +0000 (15:08 +0000)]
[OPENMP] DO not crash on combined constructs in declare target
functions.

If the combined construct is specified in the declare target function
and the device code is emitted, the compiler crashes because of the
incorrectly chosen captured stmt. We should choose the innermost
captured statement, not the outermost.

llvm-svn: 332477

6 years ago[ThinLTO] Make llvm-lto module ID numbering consistent with linkers
Teresa Johnson [Wed, 16 May 2018 14:58:14 +0000 (14:58 +0000)]
[ThinLTO] Make llvm-lto module ID numbering consistent with linkers

The module ID numbering typically starts at 0 (in both the new and old
LTO APIs, used by linkers). Make llvm-lto consistent with that.

Split out of D46699.

llvm-svn: 332476

6 years ago[ThinLTO] Add const qualifier to a couple of flag getter methods
Teresa Johnson [Wed, 16 May 2018 14:56:02 +0000 (14:56 +0000)]
[ThinLTO] Add const qualifier to a couple of flag getter methods

Split these minor fixes out of D46699.

llvm-svn: 332475

6 years ago[Attr] Don't print fake MSInheritance argument
Joel E. Denny [Wed, 16 May 2018 14:51:18 +0000 (14:51 +0000)]
[Attr] Don't print fake MSInheritance argument

This was discovered at:

http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20180514/228390.html

Reviewed by: aaron.ballman

https://reviews.llvm.org/D46905

llvm-svn: 332474

6 years ago[OpenCL] make test independent of optimizer
Sanjay Patel [Wed, 16 May 2018 14:38:07 +0000 (14:38 +0000)]
[OpenCL] make test independent of optimizer

There shouldn't be any tests that run the entire optimizer here,
but the last test in this file is definitely going to break with
a change in LLVM IR canonicalization. Change that part to check
the unoptimized IR because that's the real intent of this file.

llvm-svn: 332473