platform/upstream/llvm.git
6 years ago[NFC] Fixed unused function warning
David Bolvansky [Mon, 6 Aug 2018 04:45:46 +0000 (04:45 +0000)]
[NFC] Fixed unused function warning

llvm-svn: 338986

6 years ago[DebugInfo] Use DbgVariableIntrinsic as the base class of variables.
Hsiangkai Wang [Mon, 6 Aug 2018 04:00:08 +0000 (04:00 +0000)]
[DebugInfo] Use DbgVariableIntrinsic as the base class of variables.

After refactoring DbgInfoIntrinsic class hierarchy, we use
DbgVariableIntrinsic as the base class of variable debug info.

In resolveTopLevelMetadata() in CGVTables.cpp, we only care about
dbg.value, so we try to cast the instructions to DbgVariableIntrinsic
before resolving variables.

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

llvm-svn: 338985

6 years ago[DebugInfo] Refactor DbgInfoIntrinsic class hierarchy.
Hsiangkai Wang [Mon, 6 Aug 2018 03:59:47 +0000 (03:59 +0000)]
[DebugInfo] Refactor DbgInfoIntrinsic class hierarchy.

In the past, DbgInfoIntrinsic has a strong assumption that these
intrinsics all have variables and expressions attached to them.
However, it is too strong to derive the class for other debug entities.
Now, it has problems for debug labels.

In order to make DbgInfoIntrinsic as a base class for 'debug info', I
create a class for 'variable debug info', DbgVariableIntrinsic.

DbgDeclareInst, DbgAddrIntrinsic, and DbgValueInst will be derived from it.

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

llvm-svn: 338984

6 years ago[docs] Switch debug info metadata blocks to use `text` instead of `llvm`
Chandler Carruth [Mon, 6 Aug 2018 03:35:36 +0000 (03:35 +0000)]
[docs] Switch debug info metadata blocks to use `text` instead of `llvm`
highlighting syntax.

Most of them already were like this, and the Sphinx runs on the docs
build bot seems to be substantially more picky and/or not have support
for a bunch of the syntax here. Hopefully this will let it progress past
this.

My previous attempt to fix the syntax made the `opt` tool happy, but no
idea what the Sphinx stuff is really looking for, and the fact that
other blocks already just use `text` led me to this solution.

llvm-svn: 338983

6 years ago[docs] Correct the basic syntax structure of the DISubrange example.
Chandler Carruth [Mon, 6 Aug 2018 02:30:01 +0000 (02:30 +0000)]
[docs] Correct the basic syntax structure of the DISubrange example.

Notably, just close two of the debug info metadata nodes early rather
than leaving them open with `...` which won't ever lex correctly. And
add the missing `:` on the count labels.

Slowly progressing through all of the warnings on the documentation
build bot. Sorry to do this one commit at a time, but despite my best
efforts I can't trigger these errors locally.

llvm-svn: 338982

6 years ago[docs] Remove an example that isn't well formed LLVM IR and trips up the
Chandler Carruth [Mon, 6 Aug 2018 02:02:09 +0000 (02:02 +0000)]
[docs] Remove an example that isn't well formed LLVM IR and trips up the
Sphinx syntax highlighter.

This example also doesn't really make sense. There is no control flow or
clarification of what the `Safe:` block exists to do... If we want
examples here, we should make them much more clear in addition to making
them well formed IR sequences.

llvm-svn: 338981

6 years ago[docs] Fix an LLVM-syntax code block to actually be valid LLVM synatx.
Chandler Carruth [Mon, 6 Aug 2018 01:41:25 +0000 (01:41 +0000)]
[docs] Fix an LLVM-syntax code block to actually be valid LLVM synatx.

Hopefully fixes an issue on the docs build bot.

llvm-svn: 338980

6 years ago[docs] Don't use the `asm` syntax highlighting (which our docs builder
Chandler Carruth [Mon, 6 Aug 2018 01:28:42 +0000 (01:28 +0000)]
[docs] Don't use the `asm` syntax highlighting (which our docs builder
errors on) and clean up the formattting.

This isn't actualy assembly anyways, so dropping the highlighting is
probably for the best.

llvm-svn: 338979

6 years ago[docs] Turn of `nasm` highlighting for a code block.
Chandler Carruth [Mon, 6 Aug 2018 01:19:43 +0000 (01:19 +0000)]
[docs] Turn of `nasm` highlighting for a code block.

This appears to produce a warning on the docs build bot. It doesn't
reproduce for me, likely because I have a newer (or more full featured)
pygments install.

llvm-svn: 338978

6 years ago[docs] Reinstate r337730 - Add support for Markdown documentation in
Chandler Carruth [Mon, 6 Aug 2018 00:38:31 +0000 (00:38 +0000)]
[docs] Reinstate r337730 - Add support for Markdown documentation in
Sphinx.

We think the bot is updated now, so trying this again. I'm landing it
(with permission) as Michael is at a con at the moment.

Actual patch largely by Michael Spencer.

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

llvm-svn: 338977

6 years agoRemove duplicated code in CommandObjectQuit
Raphael Isemann [Mon, 6 Aug 2018 00:04:51 +0000 (00:04 +0000)]
Remove duplicated code in CommandObjectQuit

Summary:
We already have the same check directly before, so this code can never be
reached (as seen in the test coverage).

Subscribers: lldb-commits

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

llvm-svn: 338976

6 years ago[ORC] Remove an incorrect use of 'cantFail'.
Lang Hames [Sun, 5 Aug 2018 23:55:35 +0000 (23:55 +0000)]
[ORC] Remove an incorrect use of 'cantFail'.

This code was moved out from BasicObjectLayerMaterializationUnit, which required
the supplied object to be well formed. The getObjectSymbolFlags function does
not require a well-formed object, so we have to propagate the error here.

llvm-svn: 338975

6 years ago[ORC] Change JITSymbolFlags debug output, add a function for getting a symbol
Lang Hames [Sun, 5 Aug 2018 22:35:37 +0000 (22:35 +0000)]
[ORC] Change JITSymbolFlags debug output, add a function for getting a symbol
flags map from a buffer representing an object file.

llvm-svn: 338974

6 years ago[NFC] Fixed inliner tests - 2
David Bolvansky [Sun, 5 Aug 2018 16:53:36 +0000 (16:53 +0000)]
[NFC] Fixed inliner tests - 2

llvm-svn: 338973

6 years ago[NFC] Fixed inliner tests
David Bolvansky [Sun, 5 Aug 2018 16:30:46 +0000 (16:30 +0000)]
[NFC] Fixed inliner tests

llvm-svn: 338972

6 years agoFix tests for changed opt remarks format
David Bolvansky [Sun, 5 Aug 2018 14:53:34 +0000 (14:53 +0000)]
Fix tests for changed opt remarks format

Summary:
Optimization remark format is slightly changed by LLVM patch D49412.
Two tests are fixed with expected messages changed.
Frankly speaking I have not tested this change yet. I will test when manage to setup the project.

Reviewers: xbolva00

Reviewed By: xbolva00

Subscribers: mehdi_amini, eraman, steven_wu, dexonsmith

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

llvm-svn: 338971

6 years agoFix one test for changed opt remarks format
David Bolvansky [Sun, 5 Aug 2018 14:53:14 +0000 (14:53 +0000)]
Fix one test for changed opt remarks format

Summary:
Optimization remark format is slightly changed by LLVM patch D49412.
One test is fixed with expected messages changed.
Frankly speaking I have not tested this change yet. I will test when manage to setup the project.

Reviewers: xbolva00, espindola

Reviewed By: xbolva00

Subscribers: emaste, arichardson, steven_wu, dexonsmith

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

llvm-svn: 338970

6 years agoEnrich inline messages
David Bolvansky [Sun, 5 Aug 2018 14:53:08 +0000 (14:53 +0000)]
Enrich inline messages

Summary:
This patch improves Inliner to provide causes/reasons for negative inline decisions.
1. It adds one new message field to InlineCost to report causes for Always and Never instances. All Never and Always instantiations must provide a simple message.
2. Several functions that used to return the inlining results as boolean are changed to return InlineResult which carries the cause for negative decision.
3. Changed remark priniting and debug output messages to provide the additional messages and related inline cost.
4. Adjusted tests for changed printing.

Patch by: yrouban (Yevgeny Rouban)

Reviewers: craig.topper, sammccall, sgraenitz, NutshellySima, shchenz, chandlerc, apilipenko, javed.absar, tejohnson, dblaikie, sanjoy, eraman, xbolva00

Reviewed By: tejohnson, xbolva00

Subscribers: xbolva00, llvm-commits, arsenm, mehdi_amini, eraman, haicheng, steven_wu, dexonsmith

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

llvm-svn: 338969

6 years agoRevert "Add a warning if someone attempts to add extra section flags to sections"
Eric Christopher [Sun, 5 Aug 2018 14:23:37 +0000 (14:23 +0000)]
Revert "Add a warning if someone attempts to add extra section flags to sections"

There are a bunch of edge cases and inconsistencies in how we're emitting sections
cause this warning to fire and it needs more work.

This reverts commit r335558.

llvm-svn: 338968

6 years ago[NFC][InstCombine] Add tests for sinking 'not' into 'xor' (PR38446)
Roman Lebedev [Sun, 5 Aug 2018 10:15:04 +0000 (10:15 +0000)]
[NFC][InstCombine] Add tests for sinking 'not' into 'xor' (PR38446)

https://rise4fun.com/Alive/IT3

Comes up in the [most ugliest]  signed int -> signed char  case of
-fsanitize=implicit-conversion (https://reviews.llvm.org/D50250)

Not sure if we want to do it always, or only when it is free to invert.

llvm-svn: 338967

6 years ago[AST][NFC] Remove unneeded forward declarations in Type.h
Bruno Ricci [Sun, 5 Aug 2018 09:48:59 +0000 (09:48 +0000)]
[AST][NFC] Remove unneeded forward declarations in Type.h

These forward declarations for various classes in the Type
hierarchy are not needed since they are all forward declared
systematically a few lines below.

llvm-svn: 338966

6 years ago[NFC][InstCombine] Regenerate set.ll test
Roman Lebedev [Sun, 5 Aug 2018 08:53:40 +0000 (08:53 +0000)]
[NFC][InstCombine] Regenerate set.ll test

llvm-svn: 338965

6 years ago[X86] Remove stale comments from a test. NFC
Craig Topper [Sun, 5 Aug 2018 06:25:01 +0000 (06:25 +0000)]
[X86] Remove stale comments from a test. NFC

The 16-bit case was recently fixed so this comment no longer applies.

llvm-svn: 338964

6 years ago[InstCombine] [NFC] Tests for strcmp to memcmp transformation
David Bolvansky [Sun, 5 Aug 2018 05:46:56 +0000 (05:46 +0000)]
[InstCombine] [NFC] Tests for strcmp to memcmp transformation

llvm-svn: 338963

6 years agoUse Optional instead of unique_ptr; NFC
George Burgess IV [Sun, 5 Aug 2018 01:37:07 +0000 (01:37 +0000)]
Use Optional instead of unique_ptr; NFC

Looks like the only reason we use a unique_ptr here is so that we can
conditionally construct a LogicalErrorHandler. It's a small type, and
Optional can do the same thing with 100% fewer heap allocations.

llvm-svn: 338962

6 years agoAdded unit test for StringList
Raphael Isemann [Sat, 4 Aug 2018 17:28:21 +0000 (17:28 +0000)]
Added unit test for StringList

Reviewers: labath

Reviewed By: labath

Subscribers: mgorny, lldb-commits

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

llvm-svn: 338961

6 years ago[LLD][ELD] - Revert r338959 "[LLD][ELF] - Added file name and a test for case when...
George Rimar [Sat, 4 Aug 2018 13:41:12 +0000 (13:41 +0000)]
[LLD][ELD] - Revert r338959 "[LLD][ELF] - Added file name and a test for case when we fail to write the output."

It broke BB:
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/34382/steps/test/logs/stdio
http://lab.llvm.org:8011/builders/lld-x86_64-freebsd/builds/21932/steps/test_lld/logs/stdio

llvm-svn: 338960

6 years ago[LLD][ELF] - Added file name and a test for case when we fail to write the output.
George Rimar [Sat, 4 Aug 2018 12:48:38 +0000 (12:48 +0000)]
[LLD][ELF] - Added file name and a test for case when we fail to write the output.

We did not report the file name and had no test for that case.

llvm-svn: 338959

6 years ago[LLD][ELF] - Remove excessive requirement from the test.
George Rimar [Sat, 4 Aug 2018 11:33:38 +0000 (11:33 +0000)]
[LLD][ELF] - Remove excessive requirement from the test.

It feels "shell" is excessive. Lets try without it.

llvm-svn: 338958

6 years ago[LLD][ELF] - Removed dead code from rangeToString(). NFC.
George Rimar [Sat, 4 Aug 2018 10:56:26 +0000 (10:56 +0000)]
[LLD][ELF] - Removed dead code from rangeToString(). NFC.

This change removes the dead code and makes cosmetic change
showing why it was dead.

llvm-svn: 338957

6 years ago[LLD][ELF] - Fix bug when reporting memory intersections.
George Rimar [Sat, 4 Aug 2018 10:34:52 +0000 (10:34 +0000)]
[LLD][ELF] - Fix bug when reporting memory intersections.

rangeToString() takes addres and length,
previously it was called incorrectly.

llvm-svn: 338956

6 years ago[ADT] Add an early-increment iterator-like type and range adaptor.
Chandler Carruth [Sat, 4 Aug 2018 08:17:26 +0000 (08:17 +0000)]
[ADT] Add an early-increment iterator-like type and range adaptor.

This allows us to model the common LLVM idiom of incrementing
immediately after dereferencing so that we can remove or update the
entity w/o losing our ability to reach the "next".

However, these are not real or proper iterators. They are just enough to
allow range based for loops and very simple range algorithms to work,
but should not be considered full general.

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

llvm-svn: 338955

6 years ago[TailCallElim] Preserve DT and PDT
Chijun Sima [Sat, 4 Aug 2018 08:13:47 +0000 (08:13 +0000)]
[TailCallElim] Preserve DT and PDT

Summary:
Previously, in the NewPM pipeline, TailCallElim recalculates the DomTree when it modifies any instruction in the Function.
For example,
```
CallInst *CI = dyn_cast<CallInst>(&I);
...
CI->setTailCall();
Modified = true;
...
if (!Modified || ...)
  return PreservedAnalyses::all();
```
After applying this patch, the DomTree only recalculates if needed (plus an extra insertEdge() + an extra deleteEdge() call).

When optimizing SQLite with `-passes="default<O3>"` pipeline of the newPM, the number of DomTree recalculation decreases by 6.2%, the number of nodes visited by DFS decreases by 2.9%. The time used by DomTree will decrease approximately 1%~2.5% after applying the patch.

Statistics:
```
Before the patch:
 23010 dom-tree-stats               - Number of DomTree recalculations
489264 dom-tree-stats               - Number of nodes visited by DFS -- DomTree
After the patch:
 21581 dom-tree-stats               - Number of DomTree recalculations
475088 dom-tree-stats               - Number of nodes visited by DFS -- DomTree
```

Reviewers: kuhar, dmgreen, brzycki, grosser, davide

Reviewed By: kuhar, brzycki

Subscribers: llvm-commits

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

llvm-svn: 338954

6 years ago[ELF] - Refactor readCallGraph().
George Rimar [Sat, 4 Aug 2018 07:31:19 +0000 (07:31 +0000)]
[ELF] - Refactor readCallGraph().

This simplifies the code a bit.

It is NFC except that it removes early exit for Count == 0
which does not seem to be useful (we have no such tests either).

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

llvm-svn: 338953

6 years agoFixed header of StringLexer.h
Raphael Isemann [Sat, 4 Aug 2018 05:53:07 +0000 (05:53 +0000)]
Fixed header of StringLexer.h

llvm-svn: 338952

6 years ago[llvm-objdump] Remove continue after report_error which is unreachable
Fangrui Song [Sat, 4 Aug 2018 05:19:00 +0000 (05:19 +0000)]
[llvm-objdump] Remove continue after report_error which is unreachable

llvm-svn: 338951

6 years ago[ADCE] Remove the need of DomTree
Chijun Sima [Sat, 4 Aug 2018 02:50:12 +0000 (02:50 +0000)]
[ADCE] Remove the need of DomTree

Summary: ADCE doesn't need to query domtree.

Reviewers: kuhar, brzycki, dmgreen, davide, grosser

Reviewed By: kuhar

Subscribers: llvm-commits

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

llvm-svn: 338950

6 years agoFix a bug in VMRange
Leonard Mosescu [Sat, 4 Aug 2018 02:15:26 +0000 (02:15 +0000)]
Fix a bug in VMRange

I noticed a suspicious failure:

[ RUN ] VMRange.CollectionContains
llvm/src/tools/lldb/unittests/Utility/VMRangeTest.cpp:146: Failure
Value of: VMRange::ContainsRange(collection, VMRange(0x100, 0x104))

Actual: false
Expected: true

Looking at the code, it is a very real bug:

class RangeInRangeUnaryPredicate {
public:
  RangeInRangeUnaryPredicate(VMRange range) : _range(range) {} // note that _range binds to a temporary!
  bool operator()(const VMRange &range) const {
    return range.Contains(_range);
  }
  const VMRange &_range;
};

This change fixes the bug.

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

llvm-svn: 338949

6 years agoReverted r338825 and all the following tries to fix issues introduced by that commit...
Galina Kistanova [Sat, 4 Aug 2018 01:59:12 +0000 (01:59 +0000)]
Reverted r338825 and all the following tries to fix issues introduced by that commit (r338826, r338827, r338829, r338880).

This commit has broken build bots and has been left unattended for too long.

llvm-svn: 338948

6 years ago[clangd] Fix fuzzer build.
Matt Morehouse [Sat, 4 Aug 2018 01:51:10 +0000 (01:51 +0000)]
[clangd] Fix fuzzer build.

llvm-svn: 338947

6 years ago[clang-fuzzer] Remove unused typedef.
Matt Morehouse [Sat, 4 Aug 2018 01:42:47 +0000 (01:42 +0000)]
[clang-fuzzer] Remove unused typedef.

llvm-svn: 338946

6 years agoAvoid creating conditional cleanup blocks that contain only @llvm.lifetime.end calls
Richard Smith [Sat, 4 Aug 2018 01:25:06 +0000 (01:25 +0000)]
Avoid creating conditional cleanup blocks that contain only @llvm.lifetime.end calls

When a non-extended temporary object is created in a conditional branch, the
lifetime of that temporary ends outside the conditional (at the end of the
full-expression). If we're inserting lifetime markers, this means we could end
up generating

  if (some_cond) {
    lifetime.start(&tmp);
    Tmp::Tmp(&tmp);
  }
  // ...
  if (some_cond) {
    lifetime.end(&tmp);
  }

... for a full-expression containing a subexpression of the form `some_cond ?
Tmp().x : 0`. This patch moves the lifetime start for such a temporary out of
the conditional branch so that we don't need to generate an additional basic
block to hold the lifetime end marker.

This is disabled if we want precise lifetime markers (for asan's
stack-use-after-scope checks) or of the temporary has a non-trivial destructor
(in which case we'd generate an extra basic block anyway to hold the destructor
call).

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

llvm-svn: 338945

6 years ago[GISel]: Add Opcodes for CTLZ/CTTZ/CTPOP
Aditya Nandakumar [Sat, 4 Aug 2018 01:22:12 +0000 (01:22 +0000)]
[GISel]: Add Opcodes for CTLZ/CTTZ/CTPOP

https://reviews.llvm.org/D48600

Added IRTranslator support to translate these known intrinsics into GISel opcodes.

llvm-svn: 338944

6 years agoLLVM Proto Fuzzer - Run Functions on Suite of Inputs
Emmett Neyman [Sat, 4 Aug 2018 01:18:37 +0000 (01:18 +0000)]
LLVM Proto Fuzzer - Run Functions on Suite of Inputs

Summary:
Added corpus of arrays to use as inputs for the functions. Check that the two
functions modify the inputted arrays in the same way.

Reviewers: kcc, morehouse

Reviewed By: morehouse

Subscribers: mgorny, cfe-commits, llvm-commits

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

llvm-svn: 338943

6 years ago[www] Update cxx_status and cxx_dr_status now that Clang 7 has branched.
Richard Smith [Sat, 4 Aug 2018 01:02:00 +0000 (01:02 +0000)]
[www] Update cxx_status and cxx_dr_status now that Clang 7 has branched.

llvm-svn: 338942

6 years ago[constexpr] Support for constant evaluation of __builtin_memcpy and
Richard Smith [Sat, 4 Aug 2018 00:57:17 +0000 (00:57 +0000)]
[constexpr] Support for constant evaluation of __builtin_memcpy and
__builtin_memmove (in non-type-punning cases).

This is intended to permit libc++ to make std::copy etc constexpr
without sacrificing the optimization that uses memcpy on
trivially-copyable types.

__builtin_strcpy and __builtin_wcscpy are not handled by this change.
They'd be straightforward to add, but we haven't encountered a need for
them just yet.

This reinstates r338455, reverted in r338602, with a fix to avoid trying
to constant-evaluate a memcpy call if either pointer operand has an
invalid designator.

llvm-svn: 338941

6 years agoFix buildbot breakage.
Rui Ueyama [Sat, 4 Aug 2018 00:23:37 +0000 (00:23 +0000)]
Fix buildbot breakage.

llvm-svn: 338940

6 years agoUse the same constants as zlib to represent compression level.
Rui Ueyama [Sat, 4 Aug 2018 00:13:13 +0000 (00:13 +0000)]
Use the same constants as zlib to represent compression level.

This change allows users pass compression level that was not listed
in the enum. Also, I think using different values than zlib's
compression levels was just confusing.

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

llvm-svn: 338939

6 years ago[WebAssembly] Don't error when --undefined symbols are not found
Sam Clegg [Sat, 4 Aug 2018 00:04:06 +0000 (00:04 +0000)]
[WebAssembly] Don't error when --undefined symbols are not found

This matches the behavior of the ELF linker where -u/--undefined
means symbols will get pulled in from archives but won't result
in link error if they are missing.

Also, don't actually great symbol table entries for the undefined
symbols, again matching more closely the ELF linker.

This also results in simplification of the code.

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

llvm-svn: 338938

6 years agoDisable the asan-deque.cpp integration test for AppleLLDB < v1000
Vedant Kumar [Sat, 4 Aug 2018 00:02:48 +0000 (00:02 +0000)]
Disable the asan-deque.cpp integration test for AppleLLDB < v1000

Some of Apple's public CI nodes ship an lldb which has trouble debugging
the asan-deque.cpp test. Specifically, that lldb appears to either parse
location lists in the test program incorrectly or to have a broken
std::deque data formatter.

We don't want to work around this by weakening the integration test, and
we're unable to update the lldb version on the CI node at the moment.

The compromise is to require AppleLLDB >= 1000 when AppleLLDB is being
used to debug this test.

Reviewed (in person) by Adrian Prantl.

Bot failure:
http://lab.llvm.org:8080/green/job/clang-stage1-configure-RA/48074

rdar://42892721

llvm-svn: 338937

6 years agoMark LWG#2260 as complete. We already did the right thing, so I just added tests...
Marshall Clow [Fri, 3 Aug 2018 23:28:48 +0000 (23:28 +0000)]
Mark LWG#2260 as complete. We already did the right thing, so I just added tests to ensure that we continue to DTRT.

llvm-svn: 338936

6 years ago[analyzer] Do not crash in NoStoreFuncVisitor notes if an unexpected region is found.
George Karpenkov [Fri, 3 Aug 2018 23:19:07 +0000 (23:19 +0000)]
[analyzer] Do not crash in NoStoreFuncVisitor notes if an unexpected region is found.

Just do not generate the note at all in that case.

llvm-svn: 338935

6 years ago[Preprocessor] Allow libc++ to detect when aligned allocation is unavailable.
Volodymyr Sapsai [Fri, 3 Aug 2018 23:12:37 +0000 (23:12 +0000)]
[Preprocessor] Allow libc++ to detect when aligned allocation is unavailable.

Libc++ needs to know when aligned allocation is supported by clang, but is
otherwise unavailable at link time. Otherwise, libc++ will incorrectly end up
generating calls to `__builtin_operator_new`/`__builtin_operator_delete` with
alignment arguments.

This patch implements the following changes:

* The `__cpp_aligned_new` feature test macro to no longer be defined when
  aligned allocation is otherwise enabled but unavailable.

* The Darwin driver no longer passes `-faligned-alloc-unavailable` when the
  user manually specifies `-faligned-allocation` or `-fno-aligned-allocation`.

* Instead of a warning Clang now generates a hard error when an aligned
  allocation or deallocation function is referenced but unavailable.

Patch by Eric Fiselier.

Reviewers: rsmith, vsapsai, erik.pilkington, ahatanak, dexonsmith

Reviewed By: rsmith

Subscribers: Quuxplusone, cfe-commits

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

llvm-svn: 338934

6 years ago[NFC][libc++] Consistently use spaces to indent
Louis Dionne [Fri, 3 Aug 2018 22:36:53 +0000 (22:36 +0000)]
[NFC][libc++] Consistently use spaces to indent

rdar://problem/19988944

llvm-svn: 338933

6 years ago[clang-tidy] Sequence init statements, declarations, and conditions correctly in...
Martin Bohme [Fri, 3 Aug 2018 22:20:04 +0000 (22:20 +0000)]
[clang-tidy] Sequence init statements, declarations, and conditions correctly in if, switch, and while

Summary: Fixes https://bugs.llvm.org/show_bug.cgi?id=36516.

Reviewers: ilya-biryukov, alexfh, aaron.ballman, hokein

Reviewed By: alexfh

Subscribers: xazax.hun, cfe-commits

Tags: #clang-tools-extra

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

llvm-svn: 338932

6 years agoDiagnose invalid cv-qualifiers for friend decls.
Eli Friedman [Fri, 3 Aug 2018 22:09:44 +0000 (22:09 +0000)]
Diagnose invalid cv-qualifiers for friend decls.

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

llvm-svn: 338931

6 years ago[X86] Add isel patterns for atomic_load+sub+atomic_sub.
Craig Topper [Fri, 3 Aug 2018 22:08:30 +0000 (22:08 +0000)]
[X86] Add isel patterns for atomic_load+sub+atomic_sub.

Despite the comment removed in this patch, this is beneficial when the RHS of the sub is a register.

llvm-svn: 338930

6 years ago[X86] Add test cases to show missed opportunity to use RMW for atomic_load+sub+atomic...
Craig Topper [Fri, 3 Aug 2018 22:08:28 +0000 (22:08 +0000)]
[X86] Add test cases to show missed opportunity to use RMW for atomic_load+sub+atomic_store.

llvm-svn: 338929

6 years ago[X86] Re-generate abi-isel.ll checks with update_llc_test_checks.py
Reid Kleckner [Fri, 3 Aug 2018 21:58:25 +0000 (21:58 +0000)]
[X86] Re-generate abi-isel.ll checks with update_llc_test_checks.py

These tests were clearly auto-generated when they were converted to
FileCheck back in r80019 (2009), but we didn't have a fancy script to
keep them up to date then. I've reviewed the diff, and we should be
generating the exact same code sequences we used to.

After this, I plan to commit a change that changes our output slightly,
but in a way that is still correct. It will generate a large diff, and I
want it to be clearly correct, so I am regenerating these checks in
preparation for that.

llvm-svn: 338928

6 years ago[X86] Make abi-isel.ll like update_llc_test_checks.py output
Reid Kleckner [Fri, 3 Aug 2018 21:58:12 +0000 (21:58 +0000)]
[X86] Make abi-isel.ll like update_llc_test_checks.py output

- Remove -asm-verbose=0 from every llc command. The tests still pass.
- Reorder the RUN lines to match CHECKs.
- Use -LABEL like update_llc_test_checks.py does.

llvm-svn: 338927

6 years ago[X86] Layout tests exactly as update_llc_test_checks.py would
Reid Kleckner [Fri, 3 Aug 2018 21:57:59 +0000 (21:57 +0000)]
[X86] Layout tests exactly as update_llc_test_checks.py would

Put the LLVM IR at the bottom of the function instead of the top.  In my
next patch, I will run update_llc_test_checks.py on this file, and I
want to only highlight the diffs in the CHECK lines. Hopefully by doing
this change first, the patch will be more understandable.

llvm-svn: 338926

6 years ago[X86] Remove RELEASE_ and ACQUIRE_ pseudo instructions. Use isel patterns and the...
Craig Topper [Fri, 3 Aug 2018 21:40:44 +0000 (21:40 +0000)]
[X86] Remove RELEASE_ and ACQUIRE_ pseudo instructions. Use isel patterns and the normal instructions instead

At one point in time acquire implied mayLoad and mayStore as did release. Thus we needed separate pseudos that also carried that property. This appears to no longer be the case. I believe it was changed in 2012 with a comment saying that atomic memory accesses are marked volatile which preserves the ordering.

So from what I can tell we shouldn't need additional pseudos since they aren't carry any flags that are different from the normal instructions. The only thing I can think of is that we may consider them for load folding candidates in the peephole pass now where we didn't before. If that's important hopefully there's something in the memory operand we can check to prevent the folding without relying on pseudo instructions.

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

llvm-svn: 338925

6 years agoModify lldb_suite.py to enable python debugging
Alex Langford [Fri, 3 Aug 2018 21:37:01 +0000 (21:37 +0000)]
Modify lldb_suite.py to enable python debugging

Summary:
pudb and pdb interfere with the behavior of the inspect module. calling
`inspect.getfile(inspect.currentframe())` returns a different result
depending on whether or not you're in a debugger. Calling
`os.path.abspath` on the result of `inspect.getfile(...)` normalizes the
result between the two environments.

Patch by Nathan Lanza <lanza@fb.com>

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

llvm-svn: 338923

6 years ago[X86] Autogenerate complete checks. NFC
Craig Topper [Fri, 3 Aug 2018 20:58:14 +0000 (20:58 +0000)]
[X86] Autogenerate complete checks. NFC

llvm-svn: 338921

6 years agoReplace LLDB's LEB128 implementation with the one from LLVM
Raphael Isemann [Fri, 3 Aug 2018 20:51:31 +0000 (20:51 +0000)]
Replace LLDB's LEB128 implementation with the one from LLVM

Reviewers: davide, labath

Reviewed By: labath

Subscribers: lldb-commits

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

llvm-svn: 338920

6 years ago[clangd] capitalize diagnostic messages
Alex Lorenz [Fri, 3 Aug 2018 20:43:28 +0000 (20:43 +0000)]
[clangd] capitalize diagnostic messages

The diagnostic messages that are sent to the client from Clangd are now always
capitalized.

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

llvm-svn: 338919

6 years ago[analyzer] Add test for a crash fixed in r338775.
Reka Kovacs [Fri, 3 Aug 2018 20:42:02 +0000 (20:42 +0000)]
[analyzer] Add test for a crash fixed in r338775.

Do not crash if a CXXRecordDecl cannot be obtained for an object.

Special thanks for the reproduction to Alexander Kornienko.

llvm-svn: 338918

6 years ago[TRE][DebugInfo] Preserve Debug Location in new branch instruction
Anastasis Grammenos [Fri, 3 Aug 2018 20:27:13 +0000 (20:27 +0000)]
[TRE][DebugInfo] Preserve Debug Location in new branch instruction

There are two branch instructions created
so the new test covers them both.

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

llvm-svn: 338917

6 years ago[OpenMP] Encode offload target triples into comdat key for offload initialization...
Sergey Dmitriev [Fri, 3 Aug 2018 20:19:28 +0000 (20:19 +0000)]
[OpenMP] Encode offload target triples into comdat key for offload initialization code

Encoding offload target triples onto comdat group key for offload initialization
code guarantees that it will be executed once per each unique combination of
offload targets.

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

llvm-svn: 338916

6 years ago[SelectionDAG] Teach LegalizeVectorTypes to widen the mask input to a masked store.
Craig Topper [Fri, 3 Aug 2018 20:14:18 +0000 (20:14 +0000)]
[SelectionDAG] Teach LegalizeVectorTypes to widen the mask input to a masked store.

The mask operand is visited before the data operand so we need to be able to widen it.

Fixes PR38436.

llvm-svn: 338915

6 years ago[clangd] Add test for changing build configuration
Simon Marchi [Fri, 3 Aug 2018 19:40:19 +0000 (19:40 +0000)]
[clangd] Add test for changing build configuration

Summary:
This patch adds tests for the two ways of changing build configuration
(pointing to a particular compile_commands.json):

- Through the workspace/didChangeConfiguration notification.
- Through the initialize request.

Subscribers: ilya-biryukov, ioeric, jkorous, arphaman, cfe-commits

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

llvm-svn: 338914

6 years ago[Support] Don't initialize compressed buffer allocated by zlib::compress
Fangrui Song [Fri, 3 Aug 2018 19:37:49 +0000 (19:37 +0000)]
[Support] Don't initialize compressed buffer allocated by zlib::compress

resize() (zeroing) makes every allocated page resident. The actual size of the compressed buffer is usually much
smaller. Making every page resident is wasteful.

When linking a test binary with ~1.9GiB uncompressed debug info with LLD, this optimization decreases max RSS by ~1.5GiB.

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

llvm-svn: 338913

6 years agoProperly add shared locks to the initial list of locks being tracked, instead of...
Aaron Ballman [Fri, 3 Aug 2018 19:37:45 +0000 (19:37 +0000)]
Properly add shared locks to the initial list of locks being tracked, instead of assuming unlock functions always use exclusive locks.

Patch by Aaron Puchert.

llvm-svn: 338912

6 years agolld-link: Simplify LinkerDriver::findDefaultEntry()
Nico Weber [Fri, 3 Aug 2018 18:32:44 +0000 (18:32 +0000)]
lld-link: Simplify LinkerDriver::findDefaultEntry()

No intended behavior change. Not repeating the CRTStartup names makes fixing
PR36523 simpler.

https://reviews.llvm.org/D50253

llvm-svn: 338911

6 years agoDAG: Enhance isKnownNeverNaN
Matt Arsenault [Fri, 3 Aug 2018 18:27:52 +0000 (18:27 +0000)]
DAG: Enhance isKnownNeverNaN

Add a parameter for testing specifically for
sNaNs - at least one instruction pattern on AMDGPU
needs to check specifically for this.

Also handle more cases, and add a target hook
for custom nodes, similar to the hooks for known
bits.

llvm-svn: 338910

6 years ago[NFC] Initialize a variable to prevent future invalid deref.
Erich Keane [Fri, 3 Aug 2018 18:08:36 +0000 (18:08 +0000)]
[NFC] Initialize a variable to prevent future invalid deref.

Found by KlockWorks, this variable is properly protected, however
the conditions in the test that initializes it and the one that uses
it could diverge, it seems to me that this is a 'free' init that will
prevent issues if one of the conditions is ever modified without the other.

llvm-svn: 338909

6 years ago[NVPTX] Handle __nvvm_reflect("__CUDA_ARCH").
Artem Belevich [Fri, 3 Aug 2018 18:05:24 +0000 (18:05 +0000)]
[NVPTX] Handle __nvvm_reflect("__CUDA_ARCH").

Summary:
libdevice in recent CUDA versions relies on __nvvm_reflect() to select
GPU-specific bitcode. This patch addresses the requirement.

Reviewers: jlebar

Subscribers: jholewinski, sanjoy, hiraditya, bixia, llvm-commits

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

llvm-svn: 338908

6 years ago[X86] Add a DAG combine for the __builtin_parity idiom used by clang to enable better...
Craig Topper [Fri, 3 Aug 2018 18:00:29 +0000 (18:00 +0000)]
[X86] Add a DAG combine for the __builtin_parity idiom used by clang to enable better codegen

Clang uses "ctpop & 1" to implement __builtin_parity. If the popcnt instruction isn't supported this generates a large amount of code to calculate the population count. Instead we can bisect the data down to a single byte using xor and then check the parity flag.

Even when popcnt is supported, its still a good idea to split 64-bit data on 32-bit targets using an xor in front of a single popcnt. Otherwise we get two popcnts and an add before the and.

I've specifically targeted this at the sizes supported by clang builtins, but we could generalize this if we think that's useful.

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

llvm-svn: 338907

6 years ago[X86] Add test cases for the current codegen of __builtin_parity.
Craig Topper [Fri, 3 Aug 2018 18:00:23 +0000 (18:00 +0000)]
[X86] Add test cases for the current codegen of __builtin_parity.

Will be improved in a follow commit

llvm-svn: 338906

6 years ago[SLC] Refactor shrinking of functions (NFC)
Evandro Menezes [Fri, 3 Aug 2018 17:50:16 +0000 (17:50 +0000)]
[SLC] Refactor shrinking of functions (NFC)

Merge the helper functions for shrinking unary and binary functions into a
single one, while keeping all their functionality.  Otherwise, NFC.

llvm-svn: 338905

6 years agoRevert "[OpenCL] Always emit alloca in entry block for enqueue_kernel builtin"
Vlad Tsyrklevich [Fri, 3 Aug 2018 17:47:58 +0000 (17:47 +0000)]
Revert "[OpenCL] Always emit alloca in entry block for enqueue_kernel builtin"

This reverts commit r338899, it was causing ASan test failures on sanitizer-x86_64-linux-fast.

llvm-svn: 338904

6 years agoUse ExprMutationAnalyzer in performance-unnecessary-value-param
Shuai Wang [Fri, 3 Aug 2018 17:23:37 +0000 (17:23 +0000)]
Use ExprMutationAnalyzer in performance-unnecessary-value-param

Summary:
This yields better recall as ExprMutationAnalyzer is more accurate.

One common pattern this check is now able to catch is:
```
void foo(std::vector<X> v) {
  for (const auto& elm : v) {
    // ...
  }
}
```

Reviewers: george.karpenkov

Subscribers: a.sidorin, cfe-commits

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

llvm-svn: 338903

6 years agoFix crash in bounds checking.
Joel Galenson [Fri, 3 Aug 2018 17:12:23 +0000 (17:12 +0000)]
Fix crash in bounds checking.

In r337830 I added SCEV checks to enable us to insert fewer bounds checks.  Unfortunately, this sometimes crashes when multiple bounds checks are added due to SCEV caching issues.  This patch splits the bounds checking pass into two phases, one that computes all the conditions (using SCEV checks) and the other that adds the new instructions.

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

llvm-svn: 338902

6 years agoAdd raw_ostream wrapper to the Stream class
Raphael Isemann [Fri, 3 Aug 2018 16:56:33 +0000 (16:56 +0000)]
Add raw_ostream wrapper to the Stream class

Summary:
This wrapper will allow us in the future to reuse LLVM methods from within the
Stream class.

Currently no test as this is intended to be an internal class that shouldn't have any
NFC. The test for this change will be the follow up patch that migrates LLDB's
LEB128 implementation to the one from LLVM.

This change also adds custom move/assignment methods to Stream, as LLVM
raw_ostream doesn't support these. As our internal stream has anyway no state,
we can just keep the same stream object around.

Reviewers: davide, labath

Reviewed By: labath

Subscribers: xiaobai, labath, lldb-commits

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

llvm-svn: 338901

6 years ago[llvm-mca][docs] Move the code marker text into its own subsection. NFC.
Matt Davis [Fri, 3 Aug 2018 15:56:07 +0000 (15:56 +0000)]
[llvm-mca][docs] Move the code marker text into its own subsection. NFC.

Also fixed a few undecorated 'llvm-mca' references to be highlighted
with the 'program' emphasis.

llvm-svn: 338900

6 years ago[OpenCL] Always emit alloca in entry block for enqueue_kernel builtin
Scott Linder [Fri, 3 Aug 2018 15:50:52 +0000 (15:50 +0000)]
[OpenCL] Always emit alloca in entry block for enqueue_kernel builtin

Ensures the statically sized alloca is not converted to DYNAMIC_STACKALLOC
later because it is not in the entry block.

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

llvm-svn: 338899

6 years agoamdgcn: Use __constant AS for amdgcn builtins.
Jan Vesely [Fri, 3 Aug 2018 15:14:08 +0000 (15:14 +0000)]
amdgcn: Use __constant AS for amdgcn builtins.

Fixes build after clang r338707.
Reviewer: Matthew.Arsenault@amd.com
Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
llvm-svn: 338898

6 years ago[X86] Fix line endings.
Simon Pilgrim [Fri, 3 Aug 2018 15:09:56 +0000 (15:09 +0000)]
[X86] Fix line endings.

llvm-svn: 338897

6 years ago[Partial Inlining] Fix small bug in detecting if we did something
Graham Yiu [Fri, 3 Aug 2018 14:42:53 +0000 (14:42 +0000)]
[Partial Inlining] Fix small bug in detecting if we did something

- It's possible for 'Changed' to return as false even if we did
  partial inline something.  Fixed to accumulate return values

llvm-svn: 338896

6 years agoFix asm label testcase flaw
Graham Yiu [Fri, 3 Aug 2018 14:36:44 +0000 (14:36 +0000)]
Fix asm label testcase flaw

- Testcase attempts to (not) grep 'g0' in output to ensure asm symbol is
  properly renamed, but g0 is too generic and can be part of the
  module's path in LLVM IR output.
- Changed to grep '@g0', which is what the proper global symbol name
  would be if not using asm.

llvm-svn: 338895

6 years ago[WebAssembly] Cleanup of the way globals and global flags are handled
Nicholas Wilson [Fri, 3 Aug 2018 14:33:37 +0000 (14:33 +0000)]
[WebAssembly] Cleanup of the way globals and global flags are handled

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

llvm-svn: 338894

6 years agorevert r338831 - Fix unused variable warning in tablegen generated code
Erich Keane [Fri, 3 Aug 2018 14:24:34 +0000 (14:24 +0000)]
revert r338831 - Fix unused variable warning in tablegen generated code

No longer necessary thanks to r338889 (and friends).

llvm-svn: 338893

6 years agoclang-format: [JS] don't break comments before any '{'
Martin Probst [Fri, 3 Aug 2018 13:58:33 +0000 (13:58 +0000)]
clang-format: [JS] don't break comments before any '{'

Summary:
Previously, clang-format would avoid breaking before the first `{`
found, but then happily break before subsequent '{'s on the line. This
change fixes that by looking for the first location that has no opening
curly, if any.

This fixes the original commit by correcting the loop condition.

This reverts commit 66dc646e09b795b943668179c33d09da71a3b6bc.

Reviewers: krasimir

Subscribers: cfe-commits

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

llvm-svn: 338890

6 years ago[NFCI] My attempt to fix a warning in r338886 broke the build! Fix it.
Erich Keane [Fri, 3 Aug 2018 13:51:35 +0000 (13:51 +0000)]
[NFCI] My attempt to fix a warning in r338886 broke the build! Fix it.

Clang format got the best of me... it introduced spaces around something
in a table-genned file, so it was interpreted as an array and not a
code block.

llvm-svn: 338889

6 years ago[AST][NFC] Add missing doc for ObjCMethodDecl and ObjCContainerDecl
Bruno Ricci [Fri, 3 Aug 2018 13:47:12 +0000 (13:47 +0000)]
[AST][NFC] Add missing doc for ObjCMethodDecl and ObjCContainerDecl

Add a comment in ObjCMethodDecl and ObjCContainerDecl stating that
we store some bits in ObjCMethodDeclBits and ObjCContainerDeclBits.

This was missed by the recent move in
r338641 : [AST][4/4] Move the bit-fields from ObjCMethodDecl
          and ObCContainerDecl into DeclContext

llvm-svn: 338888

6 years ago[AST][NFC] Small doc update for DeclContext
Bruno Ricci [Fri, 3 Aug 2018 13:31:20 +0000 (13:31 +0000)]
[AST][NFC] Small doc update for DeclContext

Factored out from https://reviews.llvm.org/D49729
following @erichkeane comments.

* Add missing classes in the list of classes
  deriving directly from DeclContext.
* Move the friend declarations together and
  add a comment for why they are required.

Reviewed By: erichkeane

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

llvm-svn: 338887

6 years ago[NFC] Fix unused expression warning introduced in r338884
Erich Keane [Fri, 3 Aug 2018 13:23:04 +0000 (13:23 +0000)]
[NFC] Fix unused expression warning introduced in r338884

llvm-svn: 338886

6 years agoTest commit
Bruno Ricci [Fri, 3 Aug 2018 13:13:05 +0000 (13:13 +0000)]
Test commit

llvm-svn: 338885

6 years ago[NFC] Silence unused variable warning in Attr.td/AttrParsedAttrImpl.inc
Erich Keane [Fri, 3 Aug 2018 13:01:32 +0000 (13:01 +0000)]
[NFC] Silence unused variable warning in Attr.td/AttrParsedAttrImpl.inc

llvm-svn: 338884

6 years ago[llvm-mca] Speed up the computation of the wait/ready/issued sets in the Scheduler.
Andrea Di Biagio [Fri, 3 Aug 2018 12:55:28 +0000 (12:55 +0000)]
[llvm-mca] Speed up the computation of the wait/ready/issued sets in the Scheduler.

This patch is a follow-up to r338702.

We don't need to use a map to model the wait/ready/issued sets. It is much more
efficient to use a vector instead.

This patch gives us an average 7.5% speedup (on top of the ~12% speedup obtained
after r338702).

llvm-svn: 338883