platform/upstream/llvm.git
7 years agoFix for clang_Cursor_getSpellingNameRange()
Kevin Funk [Tue, 20 Dec 2016 09:56:56 +0000 (09:56 +0000)]
Fix for clang_Cursor_getSpellingNameRange()

Summary:
Fixes spelling name ranges for user-defined string literal operators.

Example:
  constexpr int operator""_toint(unsigned long long val)
  { return int(val); }

Before this patch the spelling name range on consisted of 'operator'.

After this patch: 'operator""_toint'.

Related to http://reviews.llvm.org/D5041, which fixes the function for
other cursor kinds.

Reviewers: akyrtzi, craigt, skalinichev, klimek, milianw, bkramer

Subscribers: cfe-commits

Tags: #clang-c

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

llvm-svn: 290172

7 years ago[OpenCL] Enabling the usage of CLK_NULL_QUEUE as compare operand.
Egor Churaev [Tue, 20 Dec 2016 09:15:21 +0000 (09:15 +0000)]
[OpenCL] Enabling the usage of CLK_NULL_QUEUE as compare operand.

Summary: Enabling the compression of CLK_NULL_QUEUE to variable of type queue_t.

Reviewers: Anastasia

Subscribers: cfe-commits, yaxunl, bader

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

llvm-svn: 290171

7 years agoFix build with expensive checks enabled
Serge Pavlov [Tue, 20 Dec 2016 08:48:51 +0000 (08:48 +0000)]
Fix build with expensive checks enabled

Include of llvm/IR/Verifier.h was removed from HexagonCommonGEP.cpp in r289604
as unused. In fact it is required when expensive checks are enabled, because
it declared function `verifyFunction`, which is called in conditionally compiled
part of the file.

llvm-svn: 290170

7 years agoRevert r290149: Add the alloc_size attribute to clang.
Chandler Carruth [Tue, 20 Dec 2016 08:28:19 +0000 (08:28 +0000)]
Revert r290149: Add the alloc_size attribute to clang.

This commit fails MSan when running test/CodeGen/object-size.c in
a confusing way. After some discussion with George, it isn't really
clear what is going on here. We can make the MSan failure go away by
testing for the invalid bit, but *why* things are invalid isn't clear.
And yet, other code in the surrounding area is doing precisely this and
testing for invalid.

George is going to take a closer look at this to better understand the
nature of the failure and recommit it, for now backing it out to clean
up MSan builds.

llvm-svn: 290169

7 years agoBug 30863 - Step doesn't stop with coditional breakpoint on the next line
Boris Ulasevich [Tue, 20 Dec 2016 08:09:50 +0000 (08:09 +0000)]
Bug 30863 - Step doesn't stop with coditional breakpoint on the next line
Fixed by additional completed plans detection, and applying them on breakpoint condition fail.
Thread::GetStopInfo reworked. New test added.
Review https://reviews.llvm.org/D26497
Many thanks to Jim

llvm-svn: 290168

7 years agoFix build breakage on FreeBSD after rL289878/rL289881
Dimitry Andric [Tue, 20 Dec 2016 07:58:49 +0000 (07:58 +0000)]
Fix build breakage on FreeBSD after rL289878/rL289881

Summary:
After rL289878/rL289881, the build on FreeBSD is broken, because
sanitizer_platform_limits_posix.cc attempts to include <utmp.h> and use
`struct utmp`, neither of which are supported anymore on FreeBSD.

Fix this by adding `&& !SANITIZER_FREEBSD` in a few places, and stop
intercepting utmp functions altogether for FreeBSD.

Reviewers: kubabrecka, emaste, eugenis, ed

Subscribers: ed, llvm-commits

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

llvm-svn: 290167

7 years agoAdd test for DR692.
Richard Smith [Tue, 20 Dec 2016 07:24:53 +0000 (07:24 +0000)]
Add test for DR692.

llvm-svn: 290166

7 years agoRemove extraneous space.
Rui Ueyama [Tue, 20 Dec 2016 05:49:56 +0000 (05:49 +0000)]
Remove extraneous space.

llvm-svn: 290165

7 years agoRemove `Compressed` member from InputSectionData.
Rui Ueyama [Tue, 20 Dec 2016 05:47:55 +0000 (05:47 +0000)]
Remove `Compressed` member from InputSectionData.

This value is used only once, and we can compute a value.
So we don't need to save it.

llvm-svn: 290164

7 years agoChange the timeout in CallBoardSystemServiceOpenApplication to
Jason Molenda [Tue, 20 Dec 2016 04:54:04 +0000 (04:54 +0000)]
Change the timeout in CallBoardSystemServiceOpenApplication to
30 seconds to match the old springboard timeout; the launcher
should time out before that and we will hopefully get back
an informative error message instead of timing out ourselves.

llvm-svn: 290163

7 years ago[PM] Rework a loop in the CGSCC update logic to be more conservative and
Chandler Carruth [Tue, 20 Dec 2016 03:32:17 +0000 (03:32 +0000)]
[PM] Rework a loop in the CGSCC update logic to be more conservative and
clear. The current RefSCC can occur in exactly one position so we should
just enforce that and leverage the property rather than checking for it
anywhere.

This addresses review comments made on another patch.

llvm-svn: 290162

7 years ago[PM] Provide an initial, minimal port of the inliner to the new pass manager.
Chandler Carruth [Tue, 20 Dec 2016 03:15:32 +0000 (03:15 +0000)]
[PM] Provide an initial, minimal port of the inliner to the new pass manager.

This doesn't implement *every* feature of the existing inliner, but
tries to implement the most important ones for building a functional
optimization pipeline and beginning to sort out bugs, regressions, and
other problems.

Notable, but intentional omissions:
- No alloca merging support. Why? Because it isn't clear we want to do
  this at all. Active discussion and investigation is going on to remove
  it, so for simplicity I omitted it.
- No support for trying to iterate on "internally" devirtualized calls.
  Why? Because it adds what I suspect is inappropriate coupling for
  little or no benefit. We will have an outer iteration system that
  tracks devirtualization including that from function passes and
  iterates already. We should improve that rather than approximate it
  here.
- Optimization remarks. Why? Purely to make the patch smaller, no other
  reason at all.

The last one I'll probably work on almost immediately. But I wanted to
skip it in the initial patch to try to focus the change as much as
possible as there is already a lot of code moving around and both of
these *could* be skipped without really disrupting the core logic.

A summary of the different things happening here:

1) Adding the usual new PM class and rigging.

2) Fixing minor underlying assumptions in the inline cost analysis or
   inline logic that don't generally hold in the new PM world.

3) Adding the core pass logic which is in essence a loop over the calls
   in the nodes in the call graph. This is a bit duplicated from the old
   inliner, but only a handful of lines could realistically be shared.
   (I tried at first, and it really didn't help anything.) All told,
   this is only about 100 lines of code, and most of that is the
   mechanics of wiring up analyses from the new PM world.

4) Updating the LazyCallGraph (in the new PM) based on the *newly
   inlined* calls and references. This is very minimal because we cannot
   form cycles.

5) When inlining removes the last use of a function, eagerly nuking the
   body of the function so that any "one use remaining" inline cost
   heuristics are immediately refined, and queuing these functions to be
   completely deleted once inlining is complete and the call graph
   updated to reflect that they have become dead.

6) After all the inlining for a particular function, updating the
   LazyCallGraph and the CGSCC pass manager to reflect the
   function-local simplifications that are done immediately and
   internally by the inline utilties. These are the exact same
   fundamental set of CG updates done by arbitrary function passes.

7) Adding a bunch of test cases to specifically target CGSCC and other
   subtle aspects in the new PM world.

Many thanks to the careful review from Easwaran and Sanjoy and others!

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

llvm-svn: 290161

7 years agoFix a bug that the glob pattern parser falls in an infinite loop for invalid patterns.
Rui Ueyama [Tue, 20 Dec 2016 03:12:28 +0000 (03:12 +0000)]
Fix a bug that the glob pattern parser falls in an infinite loop for invalid patterns.

llvm-svn: 290160

7 years agoFix the spelling of 'bitfield' in diagnostics to be consistently 'bit-field'.
Chandler Carruth [Tue, 20 Dec 2016 02:43:58 +0000 (02:43 +0000)]
Fix the spelling of 'bitfield' in diagnostics to be consistently 'bit-field'.

The latter agrees with most existing diagnostics and the C and C++ standards.

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

llvm-svn: 290159

7 years agoReapply r289926: attempt to fix windows build
Adrian Prantl [Tue, 20 Dec 2016 02:33:30 +0000 (02:33 +0000)]
Reapply r289926: attempt to fix windows build

llvm-svn: 290158

7 years agoSet Config->ColorDiagnostics early so that all error messages are colored.
Rui Ueyama [Tue, 20 Dec 2016 02:17:24 +0000 (02:17 +0000)]
Set Config->ColorDiagnostics early so that all error messages are colored.

Previously, some errors that were checked before we set to
Config->ColorDiagnostics weren't colored. This patch moves the code
to set the variable so that such error messages are colored just like
other error messages.

llvm-svn: 290157

7 years ago[Parser] Correct typo after lambda capture initializer is parsed.
Akira Hatanaka [Tue, 20 Dec 2016 02:11:29 +0000 (02:11 +0000)]
[Parser] Correct typo after lambda capture initializer is parsed.

This patch fixes an assertion that is triggered when RecordLayoutBuilder
tries to compute the size of a field (for capture "name" in the test
case) whose type hasn't been deduced. The patch fixes the bug by
correcting the typo of the capture initializer after the initializer is
parsed and before setting the expression for the annotation token.

Fixes PR30566.

rdar://problem/23380132

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

llvm-svn: 290156

7 years agoUpdate for LLVM global variable debug info API change.
Adrian Prantl [Tue, 20 Dec 2016 02:10:02 +0000 (02:10 +0000)]
Update for LLVM global variable debug info API change.

This reapplies r289921.

llvm-svn: 290155

7 years agoFix debug info metadata for upstream change in LLVM.
Adrian Prantl [Tue, 20 Dec 2016 02:09:59 +0000 (02:09 +0000)]
Fix debug info metadata for upstream change in LLVM.

llvm-svn: 290154

7 years ago[IR] Remove the DIExpression field from DIGlobalVariable.
Adrian Prantl [Tue, 20 Dec 2016 02:09:43 +0000 (02:09 +0000)]
[IR] Remove the DIExpression field from DIGlobalVariable.

This patch implements PR31013 by introducing a
DIGlobalVariableExpression that holds a pair of DIGlobalVariable and
DIExpression.

Currently, DIGlobalVariables holds a DIExpression. This is not the
best way to model this:

(1) The DIGlobalVariable should describe the source level variable,
    not how to get to its location.

(2) It makes it unsafe/hard to update the expressions when we call
    replaceExpression on the DIGLobalVariable.

(3) It makes it impossible to represent a global variable that is in
    more than one location (e.g., a variable with multiple
    DW_OP_LLVM_fragment-s).  We also moved away from attaching the
    DIExpression to DILocalVariable for the same reasons.

This reapplies r289902 with additional testcase upgrades and a change
to the Bitcode record for DIGlobalVariable, that makes upgrading the
old format unambiguous also for variables without DIExpressions.

<rdar://problem/29250149>
https://llvm.org/bugs/show_bug.cgi?id=31013
Differential Revision: https://reviews.llvm.org/D26769

llvm-svn: 290153

7 years agoMake this REQUIRES match the other REQUIRES lines that mention requiring
Chandler Carruth [Tue, 20 Dec 2016 01:57:31 +0000 (01:57 +0000)]
Make this REQUIRES match the other REQUIRES lines that mention requiring
a darwin system.

llvm-svn: 290152

7 years agoSimplify type of Config->SymbolOrderingFile.
Rui Ueyama [Tue, 20 Dec 2016 01:51:08 +0000 (01:51 +0000)]
Simplify type of Config->SymbolOrderingFile.

That variable was of type DenseMap<StringRef, unsigned>, but the
unsigned numbers needed to be monotonicly increasing numbers because
the implementation that used the variable depended on that fact.
That was an implementation detail and shouldn't have leaked into Config.

This patch simplifies its type to std::vector<StringRef>.

llvm-svn: 290151

7 years agoInline a small function.
Rui Ueyama [Tue, 20 Dec 2016 01:34:31 +0000 (01:34 +0000)]
Inline a small function.

llvm-svn: 290150

7 years agoAdd the alloc_size attribute to clang.
George Burgess IV [Tue, 20 Dec 2016 01:05:42 +0000 (01:05 +0000)]
Add the alloc_size attribute to clang.

This patch does three things:

- Gives us the alloc_size attribute in clang, which lets us infer the
  number of bytes handed back to us by malloc/realloc/calloc/any user
  functions that act in a similar manner.
- Teaches our constexpr evaluator that evaluating some `const` variables
  is OK sometimes. This is why we have a change in
  test/SemaCXX/constant-expression-cxx11.cpp and other seemingly
  unrelated tests. Richard Smith okay'ed this idea some time ago in
  person.
- Uniques some Blocks in CodeGen, which was reviewed separately at
  D26410. Lack of uniquing only really shows up as a problem when
  combined with our new eagerness in the face of const.

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

llvm-svn: 290149

7 years agoRevert "[ObjectYAML] Support for DWARF debug_info section"
Chris Bieneman [Tue, 20 Dec 2016 00:42:06 +0000 (00:42 +0000)]
Revert "[ObjectYAML] Support for DWARF debug_info section"

This reverts commit r290147.

This commit is breaking a bot (http://lab.llvm.org:8011/builders/clang-atom-d525-fedora-rel/builds/621). I don't have time to investigate at the moment, so I'll revert for now.

llvm-svn: 290148

7 years ago[ObjectYAML] Support for DWARF debug_info section
Chris Bieneman [Tue, 20 Dec 2016 00:26:24 +0000 (00:26 +0000)]
[ObjectYAML] Support for DWARF debug_info section

This patch adds support for YAML<->DWARF for debug_info sections.

llvm-svn: 290147

7 years agoFix completely bogus types for some builtins:
Richard Smith [Mon, 19 Dec 2016 23:59:34 +0000 (23:59 +0000)]
Fix completely bogus types for some builtins:

 * In C++, never create a FunctionNoProtoType for a builtin (fixes C++1z
   crasher from r289754).

 * Fix type of __sync_synchronize to be a no-parameter function rather than a
   varargs function. This matches GCC.

 * Fix type of vfprintf to match its actual type. We gave it a wrong type due
   to PR4290 (apparently autoconf generates invalid code and expects compilers
   to choke it down or it miscompiles the program; the relevant error in clang
   was downgraded to a warning in r122744 to fix other occurrences of this
   autoconf brokenness, so we don't need this workaround any more).

 * Turn off vararg argument checking for __noop, since it's not *really* a
   varargs function. Alternatively we could add custom type checking for it
   and synthesize parameter types matching the actual arguments in each call,
   but that seemed like overkill.

llvm-svn: 290146

7 years agoMake another test insensitive to the default C++ dialect.
Paul Robinson [Mon, 19 Dec 2016 23:32:10 +0000 (23:32 +0000)]
Make another test insensitive to the default C++ dialect.

Differential Revision: http://reviews.llvm.org/D27955

llvm-svn: 290145

7 years agoAdd ARM support to update_llc_test_checks.py
Eli Friedman [Mon, 19 Dec 2016 23:09:51 +0000 (23:09 +0000)]
Add ARM support to update_llc_test_checks.py

Just the minimal support to get it working at the moment.

Includes checks for test/CodeGen/ARM/vzip.ll as an example.

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

llvm-svn: 290144

7 years ago[analyzer] Add checker modeling gtest APIs.
Devin Coughlin [Mon, 19 Dec 2016 22:50:31 +0000 (22:50 +0000)]
[analyzer] Add checker modeling gtest APIs.

gtest is a widely-used unit-testing API. It provides macros for unit test
assertions:

  ASSERT_TRUE(p != nullptr);

that expand into an if statement that constructs an object representing
the result of the assertion and returns when the assertion is false:

  if (AssertionResult gtest_ar_ = AssertionResult(p == nullptr))
      ;
  else
    return ...;

Unfortunately, the analyzer does not model the effect of the constructor
precisely because (1) the copy constructor implementation is missing from the
the header (so it can't be inlined) and (2) the boolean-argument constructor
is constructed into a temporary (so the analyzer decides not to inline it since
it doesn't reliably call temporary destructors right now).

This results in false positives because the analyzer does not realize that the
the assertion must hold along the non-return path.

This commit addresses the false positives by explicitly modeling the effects
of the two un-inlined constructors on the AssertionResult state.

I've added a new package, "apiModeling", for these kinds of checkers that
model APIs but don't emit any diagnostics. I envision all the checkers in
this package always being on by default.

This addresses the false positives reported in PR30936.

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

rdar://problem/22705813

llvm-svn: 290143

7 years ago[LV] Sink tripcount query to where it's actually used. NFC.
Michael Kuperstein [Mon, 19 Dec 2016 22:47:52 +0000 (22:47 +0000)]
[LV] Sink tripcount query to where it's actually used. NFC.

llvm-svn: 290142

7 years agoDon't try to emit nullability fix-its within/around macros.
Jordan Rose [Mon, 19 Dec 2016 22:35:24 +0000 (22:35 +0000)]
Don't try to emit nullability fix-its within/around macros.

The newly-added notes from r290132 are too noisy even when the fix-it
is valid. For the existing warning from r286521, it's probably the
right decision 95% of the time to put the change outside the macro if
the array is outside the macro and inside otherwise, but I don't want
to overthink it right now.

Caught by the ASan bot!

More rdar://problem/29524992

llvm-svn: 290141

7 years ago[analyzer] Add sink after construction of temporary with no-return destructor.
Devin Coughlin [Mon, 19 Dec 2016 22:23:22 +0000 (22:23 +0000)]
[analyzer] Add sink after construction of temporary with no-return destructor.

The analyzer's CFG currently doesn't have nodes for calls to temporary
destructors. This causes the analyzer to explore infeasible paths in which
a no-return destructor would have stopped exploration and so results in false
positives when no-return destructors are used to implement assertions.

To mitigate these false positives, this patch stops generates a sink after
evaluating a constructor on a temporary object that has a no-return destructor.
This results in a loss of coverage because the time at which the destructor is
called may be after the time of construction (especially for lifetime-extended
temporaries).

This addresses PR15599.

rdar://problem/29131566

llvm-svn: 290140

7 years ago[ObjectYAML] Support for DWARF Pub Sections
Chris Bieneman [Mon, 19 Dec 2016 22:22:12 +0000 (22:22 +0000)]
[ObjectYAML] Support for DWARF Pub Sections

This patch adds support for YAML<->DWARF round tripping for pub* section data. The patch supports both GNU and non-GNU style entries.

llvm-svn: 290139

7 years ago[libfuzzer] dump_coverage command line flag
Mike Aizatsky [Mon, 19 Dec 2016 22:18:08 +0000 (22:18 +0000)]
[libfuzzer] dump_coverage command line flag

Reviewers: kcc, vitalybuka

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

llvm-svn: 290138

7 years ago[Axccel] Remove -Wno-missing-braces in build
Jason Henline [Mon, 19 Dec 2016 21:34:07 +0000 (21:34 +0000)]
[Axccel] Remove -Wno-missing-braces in build

Summary:
I originally added the -Wno-missing-braces flag because I thought it was
erroneously flagging std::array initializations. Now I realize the extra
braces really are desired for these initializations, so I'm turning the
warning flag back on.

Reviewers: jlebar

Subscribers: mgorny, parallel_libs-commits

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

llvm-svn: 290137

7 years agoFix corner cases of setting the section address.
Rafael Espindola [Mon, 19 Dec 2016 21:21:07 +0000 (21:21 +0000)]
Fix corner cases of setting the section address.

This handles all the corner cases if setting a section address:

- If the address is too low, we cannot allocate the program headers.
- If the load address is lowered, we have to do that before finalize

This also shares some code with the linker script since it was already
hitting similar cases.

This is used by the freebsd boot loader. It is not clear if we need to
support this with a non binary output, but it is not as bad as I was
expecting.

llvm-svn: 290136

7 years ago[Format] Remove dead code.
Benjamin Kramer [Mon, 19 Dec 2016 21:10:50 +0000 (21:10 +0000)]
[Format] Remove dead code.

No functionality change.

llvm-svn: 290135

7 years ago[ASTReader] Sort RawComments before merging
Bruno Cardoso Lopes [Mon, 19 Dec 2016 21:06:06 +0000 (21:06 +0000)]
[ASTReader] Sort RawComments before merging

`RawComments` are sorted by comparing underlying `SourceLocation`'s. This is
done by comparing `FileID` and `Offset`; when the `FileID` is the same it means
the locations are within the same TU and the `Offset` is used.

FileID, from the source code: "A mostly-opaque identifier, where 0 is
"invalid", >0 is this module, and <-1 is something loaded from another
module.". That said, when de-serializing SourceLocations, FileID's from
RawComments loaded from other modules get negative IDs where previously they
were positive. This makes imported RawComments unsorted, leading to a wrong
merge with other comments from the current TU. Fix that by sorting RawComments
properly after de-serialization and before merge.

This fixes an assertion in `ASTContext::getRawCommentForDeclNoCache`,
which fires only in a debug build of clang.

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

rdar://problem/29287314

llvm-svn: 290134

7 years ago[TargetInstrInfo] replace redundant expression in getMemOpBaseRegImmOfs
Michael LeMay [Mon, 19 Dec 2016 21:02:41 +0000 (21:02 +0000)]
[TargetInstrInfo] replace redundant expression in getMemOpBaseRegImmOfs

Summary:
The expression for computing the return value of getMemOpBaseRegImmOfs has only
one possible value. The other value would result in a return earlier in the
function. This patch replaces the expression with its only possible value.

Reviewers: sanjoy

Subscribers: llvm-commits

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

llvm-svn: 290133

7 years agoAdd fix-it notes to the nullability consistency warning.
Jordan Rose [Mon, 19 Dec 2016 20:58:20 +0000 (20:58 +0000)]
Add fix-it notes to the nullability consistency warning.

This is especially important for arrays, since no one knows the proper
syntax for putting qualifiers in arrays.

    nullability.h:3:26: warning: array parameter is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified)
    void arrayParameter(int x[]);
                             ^
    nullability.h:3:26: note: insert '_Nullable' if the array parameter may be null
    void arrayParameter(int x[]);
                             ^
                              _Nullable
    nullability.h:3:26: note: insert '_Nonnull' if the array parameter should never be null
    void arrayParameter(int x[]);
                             ^
                              _Nonnull

rdar://problem/29524992

llvm-svn: 290132

7 years agoMake a function to correctly extract the DW_AT_high_pc given the low pc value.
Greg Clayton [Mon, 19 Dec 2016 20:36:41 +0000 (20:36 +0000)]
Make a function to correctly extract the DW_AT_high_pc given the low pc value.

DWARF 4 and later supports encoding the PC as an address or as as offset from the low PC. Clients using DWARFDie should be insulated from how to extract the high PC value. This function takes care of extracting the form value and looking for the correct form.

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

llvm-svn: 290131

7 years agoReverting r290004, r290006, r290010 pending review.
Sean Callanan [Mon, 19 Dec 2016 19:15:43 +0000 (19:15 +0000)]
Reverting r290004, r290006, r290010 pending review.

llvm-svn: 290130

7 years agoFixup for r290119: Only run debug_alloc_stack.cc on Darwin until I figure out how...
Kuba Mracek [Mon, 19 Dec 2016 18:54:34 +0000 (18:54 +0000)]
Fixup for r290119: Only run debug_alloc_stack.cc on Darwin until I figure out how to make it work on Linux.

llvm-svn: 290129

7 years agoMake a few OpenMP tests "C++11 clean."
Paul Robinson [Mon, 19 Dec 2016 18:43:26 +0000 (18:43 +0000)]
Make a few OpenMP tests "C++11 clean."

This time trying to commit just the relevant 3 tests!
Reviewed by abataev (in D27794)

llvm-svn: 290128

7 years ago[InstCombine] use commutative matcher for pattern with commutative operators
Sanjay Patel [Mon, 19 Dec 2016 18:35:37 +0000 (18:35 +0000)]
[InstCombine] use commutative matcher for pattern with commutative operators

This is a case that was missed in:
https://reviews.llvm.org/rL290067
...and it would regress if we fix operand complexity (PR28296).

llvm-svn: 290127

7 years agoMore fixup for r290119: Make the ifdef work.
Kuba Mracek [Mon, 19 Dec 2016 18:27:26 +0000 (18:27 +0000)]
More fixup for r290119: Make the ifdef work.

llvm-svn: 290126

7 years agoRevert another accidental bit
Paul Robinson [Mon, 19 Dec 2016 18:20:19 +0000 (18:20 +0000)]
Revert another accidental bit

llvm-svn: 290125

7 years agoAnother fix-up for r290119: Include stdint.h so we have uint64_t on Linux.
Kuba Mracek [Mon, 19 Dec 2016 18:09:18 +0000 (18:09 +0000)]
Another fix-up for r290119: Include stdint.h so we have uint64_t on Linux.

llvm-svn: 290124

7 years agoFix-up for r290119 - don't check global size, it might not be available when using...
Kuba Mracek [Mon, 19 Dec 2016 18:06:49 +0000 (18:06 +0000)]
Fix-up for r290119 - don't check global size, it might not be available when using atos

llvm-svn: 290123

7 years ago[ELF] - Implemented --retain-symbols-file option
George Rimar [Mon, 19 Dec 2016 18:00:52 +0000 (18:00 +0000)]
[ELF] - Implemented --retain-symbols-file option

--retain-symbols-file=filename
Retain only the symbols listed in the file filename, discarding all others.
filename is simply a flat file, with one symbol name per line. This option
is especially useful in environments (such as VxWorks) where a large global
symbol table is accumulated gradually, to conserve run-time memory.

Note: though documentation says "--retain-symbols-file does not discard
undefined symbols, or symbols needed for relocations.", both bfd and gold
do that, and this patch too, like testcase show.

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

llvm-svn: 290122

7 years agoUndo accidental comit
Paul Robinson [Mon, 19 Dec 2016 18:00:45 +0000 (18:00 +0000)]
Undo accidental comit

llvm-svn: 290121

7 years agoMake a few OpenMP tests "C++11 clean."
Paul Robinson [Mon, 19 Dec 2016 17:58:09 +0000 (17:58 +0000)]
Make a few OpenMP tests "C++11 clean."

Reviewed by abataev (in D27794)

llvm-svn: 290120

7 years ago[tsan] Implement __tsan_get_alloc_stack and __tsan_locate_address to query pointer...
Kuba Mracek [Mon, 19 Dec 2016 17:52:20 +0000 (17:52 +0000)]
[tsan] Implement __tsan_get_alloc_stack and __tsan_locate_address to query pointer types and allocation stacks of heap pointers

In ASan, we have __asan_locate_address and __asan_get_alloc_stack, which is used in LLDB/Xcode to show the allocation backtrace for a heap memory object. This patch implements the same for TSan.

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

llvm-svn: 290119

7 years ago[InstCombine] add folds for icmp (umin|umax X, Y), X
Sanjay Patel [Mon, 19 Dec 2016 17:32:37 +0000 (17:32 +0000)]
[InstCombine] add folds for icmp (umin|umax X, Y), X

This is a follow-up to:
https://reviews.llvm.org/rL289855 (https://reviews.llvm.org/D27531)
https://reviews.llvm.org/rL290111

llvm-svn: 290118

7 years agoExpression evaluation for overloaded C functions (redux)
Luke Drummond [Mon, 19 Dec 2016 17:22:44 +0000 (17:22 +0000)]
Expression evaluation for overloaded C functions (redux)

This is a redux of [Ewan's patch](https://reviews.llvm.org/D17957) , refactored
to properly substitute primitive  types using a hook in the itanium demangler,
and updated after the previous patch went stale

The new `SubsPrimitiveParmItanium` function takes a symbol name and replacement
primitive type parameter as before but parses it using the FastDemangler, which
has been modified to be able to notify clients of parse events (primitive types
at this point).

Additionally, we now use a `set` of `ConstStrings` instead of a `vector` so
that we don't try and resolve the same invalid candidate multiple times.

Differential Revision: https://reviews.llvm.org/D27223
Subscribers: lldb-commits

llvm-svn: 290117

7 years ago [LoopVersioning] Require loop-simplify form for loop versioning.
Florian Hahn [Mon, 19 Dec 2016 17:13:37 +0000 (17:13 +0000)]
 [LoopVersioning] Require loop-simplify form for loop versioning.

Summary:
Requiring loop-simplify form for loop versioning ensures that the
runtime check block always dominates the exit block.

This patch closes #30958 (https://llvm.org/bugs/show_bug.cgi?id=30958).

Reviewers: silviu.baranga, hfinkel, anemet, ashutosh.nema

Subscribers: ashutosh.nema, mzolotukhin, efriedma, hfinkel, llvm-commits

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

llvm-svn: 290116

7 years agoDetemplate PhdrEntry. NFC.
Rafael Espindola [Mon, 19 Dec 2016 17:01:01 +0000 (17:01 +0000)]
Detemplate PhdrEntry. NFC.

llvm-svn: 290115

7 years ago[AMDGPU] When unifying metadata, add operands to named metadata individually
Konstantin Zhuravlyov [Mon, 19 Dec 2016 16:54:24 +0000 (16:54 +0000)]
[AMDGPU] When unifying metadata, add operands to named metadata individually

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

llvm-svn: 290114

7 years ago[libclang] Revert part of r290025, "Remove the 'extern "C"' blocks from the implement...
NAKAMURA Takumi [Mon, 19 Dec 2016 16:50:43 +0000 (16:50 +0000)]
[libclang] Revert part of r290025, "Remove the 'extern "C"' blocks from the implementation files."

mingw32-ld complains missing symbols in exports,

  Cannot export clang_findIncludesInFileWithBlock: symbol not defined
  Cannot export clang_findReferencesInFileWithBlock: symbol not defined
  Cannot export clang_visitChildrenWithBlock: symbol not defined

They are excluded conditionally in header along has_blocks.

We should do either;

  1. Exclude also function bodies conditionally, and introduce "optional" exporter.
  2. Give dummy function bodies for them.
  3. Implement functions w/o blocks.

llvm-svn: 290113

7 years agoUse existing variable. NFC.
Rafael Espindola [Mon, 19 Dec 2016 16:50:20 +0000 (16:50 +0000)]
Use existing variable. NFC.

llvm-svn: 290112

7 years ago[InstCombine] add folds for icmp (smax X, Y), X
Sanjay Patel [Mon, 19 Dec 2016 16:28:53 +0000 (16:28 +0000)]
[InstCombine] add folds for icmp (smax X, Y), X

This is a follow-up to:
https://reviews.llvm.org/rL289855 (D27531)

llvm-svn: 290111

7 years ago[ARM] Add missing -backend-option for -arm-execute-only
Prakhar Bahuguna [Mon, 19 Dec 2016 15:43:33 +0000 (15:43 +0000)]
[ARM] Add missing -backend-option for -arm-execute-only

llvm-svn: 290110

7 years agoSilence unused warning.
Daniel Jasper [Mon, 19 Dec 2016 14:24:22 +0000 (14:24 +0000)]
Silence unused warning.

llvm-svn: 290109

7 years ago[ARM] GlobalISel: Add more checks to test
Diana Picus [Mon, 19 Dec 2016 14:08:11 +0000 (14:08 +0000)]
[ARM] GlobalISel: Add more checks to test

llvm-svn: 290108

7 years ago[ARM] GlobalISel: Minor style fixup in test
Diana Picus [Mon, 19 Dec 2016 14:08:06 +0000 (14:08 +0000)]
[ARM] GlobalISel: Minor style fixup in test

llvm-svn: 290107

7 years ago[ARM] GlobalISel: Lower i8 and i16 register args
Diana Picus [Mon, 19 Dec 2016 14:08:02 +0000 (14:08 +0000)]
[ARM] GlobalISel: Lower i8 and i16 register args

This allows lowering i8 and i16 arguments if they can fit in the registers. Note
that the lowering is incomplete - ABI extensions are handled in a subsequent
patch.

(Last part of)
Differential Revision: https://reviews.llvm.org/D27704

llvm-svn: 290106

7 years ago[ARM] GlobalISel: Allow i8 and i16 adds
Diana Picus [Mon, 19 Dec 2016 14:07:56 +0000 (14:07 +0000)]
[ARM] GlobalISel: Allow i8 and i16 adds

Teach the instruction selector and legalizer that it's ok to have adds with 8 or
16-bit integers.

This is the second part of https://reviews.llvm.org/D27704

llvm-svn: 290105

7 years ago[ARM] GlobalISel: Select i8 and i16 copies
Diana Picus [Mon, 19 Dec 2016 14:07:50 +0000 (14:07 +0000)]
[ARM] GlobalISel: Select i8 and i16 copies

Teach the instruction selector that it's ok to copy small values from physical
registers.

First part of https://reviews.llvm.org/D27704

llvm-svn: 290104

7 years agoFix clang-format
Tobias Grosser [Mon, 19 Dec 2016 14:06:40 +0000 (14:06 +0000)]
Fix clang-format

llvm-svn: 290103

7 years ago[Power9] Processor Model for Scheduling
Ehsan Amiri [Mon, 19 Dec 2016 13:35:45 +0000 (13:35 +0000)]
[Power9] Processor Model for Scheduling

PWR9 processor model for instruction scheduling. A subsequent patch will migrate
PWR9 to Post RA MIScheduler.
https://reviews.llvm.org/D24525

llvm-svn: 290102

7 years agoRevert "[XRay] [compiler-rt] Move machine-dependent code into machine-dependent files."
Diana Picus [Mon, 19 Dec 2016 12:43:08 +0000 (12:43 +0000)]
Revert "[XRay] [compiler-rt] Move machine-dependent code into machine-dependent files."

This reverts commit r290077, 78, 79 and 83.

llvm-svn: 290101

7 years ago[Hexagon] Restore minimum profit check accidentally changed in r290024
Malcolm Parsons [Mon, 19 Dec 2016 12:37:26 +0000 (12:37 +0000)]
[Hexagon] Restore minimum profit check accidentally changed in r290024

llvm-svn: 290100

7 years agoELF/AArch64: Fix dynamic relocation against local symbol in shared objects
Adhemerval Zanella [Mon, 19 Dec 2016 11:58:01 +0000 (11:58 +0000)]
ELF/AArch64: Fix dynamic relocation against local symbol in shared objects

AArch64 TLSDESC for local symbol in shared objects are implemented in a
arch specific manner where the TLSDESC dynamic relocation addend is the
symbol VM inside the TLS block. For instance, with a shared library
created from the code:

--
static __thread int32_t x1;
static __thread int64_t x2;

int32_t foo1 (int32_t x)
{
  x1 += x;
  return x;
}

int64_t foo2 (int64_t x)
{
  x2 += x;
  return x;
}
--

The dynamic relocation should be create as:

Relocations [
  Section (N) .rela.dyn {
    <Address1> R_AARCH64_TLSDESC - 0x0
    <Address2> R_AARCH64_TLSDESC - 0x8
  }
]

Where 0x0 addend in first dynamic relocation is the address of 'x1'
in TLS block and '0x8' is the address of 'x2'.

Checked against test-suite on aarch64-linux-gnu.

llvm-svn: 290099

7 years ago[ARM] GlobalISel: Lower more than 4 arguments
Diana Picus [Mon, 19 Dec 2016 11:55:41 +0000 (11:55 +0000)]
[ARM] GlobalISel: Lower more than 4 arguments

This adds support for lowering more than 4 arguments (although still i32 only).
It uses the handleAssignments / ValueHandler infrastructure extracted from
the AArch64 backend in r288658.

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

llvm-svn: 290098

7 years agoAMDGPU: [AMDGPU] Assembler: add .hsa_code_object_metadata directive for functime...
Sam Kolton [Mon, 19 Dec 2016 11:43:15 +0000 (11:43 +0000)]
AMDGPU: [AMDGPU] Assembler: add .hsa_code_object_metadata directive for functime metadata V2.0

Summary:
Added pair of directives .hsa_code_object_metadata/.end_hsa_code_object_metadata.
Between them user can put YAML string that would be directly put to the generated note. E.g.:
'''
.hsa_code_object_metadata
    {
        amd.MDVersion: [ 2, 0 ]
    }
.end_hsa_code_object_metadata
'''
Based on D25046

Reviewers: vpykhtin, nhaustov, yaxunl, tstellarAMD

Subscribers: arsenm, kzhuravl, wdng, nhaehnle, mgorny, tony-tye

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

llvm-svn: 290097

7 years ago[ARM] GlobalISel: Support loading from the stack
Diana Picus [Mon, 19 Dec 2016 11:26:31 +0000 (11:26 +0000)]
[ARM] GlobalISel: Support loading from the stack

Add support for selecting simple G_LOAD and G_FRAME_INDEX instructions (32-bit
scalars only). This will be useful for functions that need to pass arguments on
the stack.

First part of https://reviews.llvm.org/D27195.

llvm-svn: 290096

7 years ago[CodeGen] Make MachineInstr::isIdenticalTo() symmetric.
Bjorn Pettersson [Mon, 19 Dec 2016 11:20:57 +0000 (11:20 +0000)]
[CodeGen] Make MachineInstr::isIdenticalTo() symmetric.

Summary:
MachineInstr::isIdenticalTo() is for some reason not
symmetric when comparing bundles, which gives us the
property:

  I1->isIdenticalTo(*I2) != I2->isIdenticalTo(*I1)

when comparing bundles where one bundle is longer than
the other.

This patch makes sure that bundles of different length
always are considered as not being identical. Thus, the
result of the comparison will be the same regardless of
which side that happens to be to the left.

Reviewers: dexonsmith, jonpa, andrew.w.kaylor

Subscribers: llvm-commits, mehdi_amini

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

llvm-svn: 290095

7 years agoclang-format: Slightly tweak the behavior of <<-wrapping.
Daniel Jasper [Mon, 19 Dec 2016 11:14:23 +0000 (11:14 +0000)]
clang-format: Slightly tweak the behavior of <<-wrapping.

Before:
  SomeLongLoggingStatementOrMacro() << "Some long text "
                                    << some_variable << "\n";

Before:
  SomeLongLoggingStatementOrMacro()
      << "Some long text " << some_variable << "\n";

Short logging statements are already special cased in a different part
of the code.

llvm-svn: 290094

7 years ago[clang-format] revert an unintended change in r288493 and add a test case.
Eric Liu [Mon, 19 Dec 2016 10:41:05 +0000 (10:41 +0000)]
[clang-format] revert an unintended change in r288493 and add a test case.

llvm-svn: 290093

7 years agoRevert "[c++1z] P0195R2: Support pack-expansion of using-declarations."
Daniel Jasper [Mon, 19 Dec 2016 10:09:25 +0000 (10:09 +0000)]
Revert "[c++1z] P0195R2: Support pack-expansion of using-declarations."

This reverts commit r290080 as it leads to many Clang crashes, e.g.:
http://lab.llvm.org:8011/builders/clang-cmake-aarch64-quick/builds/1814

llvm-svn: 290092

7 years ago[XRay] Fix assertion failure on empty machine basic blocks (PR 31424)
Dean Michael Berris [Mon, 19 Dec 2016 09:20:38 +0000 (09:20 +0000)]
[XRay] Fix assertion failure on empty machine basic blocks (PR 31424)

The original version of the code in XRayInstrumentation.cpp assumed that
functions may not have empty machine basic blocks (or that the first one
couldn't be). This change addresses that by special-casing that specific
situation.

We provide two .mir test-cases to make sure we're handling this
appropriately.

Fixes llvm.org/PR31424.

Reviewers: chandlerc

Subscribers: varno, llvm-commits

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

llvm-svn: 290091

7 years agoclang-format: Fix regression introduced in r290084.
Daniel Jasper [Mon, 19 Dec 2016 08:40:56 +0000 (08:40 +0000)]
clang-format: Fix regression introduced in r290084.

We still want to try in linewrap within single elements of a 1-column
list.

After:
  Type *Params[] = {PointerType::getUnqual(FunctionType::get(
Builder.getVoidTy(), Builder.getInt8PtrTy(), false)),
    Builder.getInt8PtrTy(),
    Builder.getInt32Ty(),
    LongType,
    LongType,
    LongType};

Before:
  No line break in the first element, so column limit violation.

llvm-svn: 290090

7 years ago[X86] When recognizing vector loads or VZEXT_LOAD in selectScalarSSELoad make sure...
Craig Topper [Mon, 19 Dec 2016 08:35:56 +0000 (08:35 +0000)]
[X86] When recognizing vector loads or VZEXT_LOAD in selectScalarSSELoad make sure we pass the load's user rather than load itself to the second operand of IsLegalToFold.

llvm-svn: 290089

7 years ago[TableGen] Use 'unsigned' instead of 'bool' in a place where the code conditionally...
Craig Topper [Mon, 19 Dec 2016 08:35:08 +0000 (08:35 +0000)]
[TableGen] Use 'unsigned' instead of 'bool' in a place where the code conditionally assigns numeric values. They happen to be 0 and 1 so this is NFC.

llvm-svn: 290088

7 years agoAdd files I seem to have dropped in my revert (r290086).
Daniel Jasper [Mon, 19 Dec 2016 08:32:13 +0000 (08:32 +0000)]
Add files I seem to have dropped in my revert (r290086).

Sorry!

llvm-svn: 290087

7 years agoRevert @llvm.assume with operator bundles (r289755-r289757)
Daniel Jasper [Mon, 19 Dec 2016 08:22:17 +0000 (08:22 +0000)]
Revert @llvm.assume with operator bundles (r289755-r289757)

This creates non-linear behavior in the inliner (see more details in
r289755's commit thread).

llvm-svn: 290086

7 years agoFix format after recent clang-format change.
Daniel Jasper [Mon, 19 Dec 2016 07:54:15 +0000 (07:54 +0000)]
Fix format after recent clang-format change.

llvm-svn: 290085

7 years agoclang-format: Allow "single column" list layout even if that violates the
Daniel Jasper [Mon, 19 Dec 2016 07:26:11 +0000 (07:26 +0000)]
clang-format: Allow "single column" list layout even if that violates the
column limit.

Single-column layout basically means that we format the list with one
element per line. Not doing that when there is a column limit violation
doesn't change the fact that there is an item that doesn't fit within
the column limit.

Before (with a column limit of 30):
  std::vector<int> a = {
      aaaaaaaaaaaaaaaa,
      aaaaaaaaaaaaaaaa,
      aaaaaaaaaaaaaaaaaa,
      aaaaaaaaaaaaaaaaaaaaaaaaaaa};

After:
  std::vector<int> a = {
      aaaaaaaa,
      aaaaaaaa,
      aaaaaaaa,
      aaaaaaaa,
      aaaaaaaaaa,
      aaaaaaaa,
      aaaaaaaaaaaaaaaaaaaaaaaaaaa};

(and previously we would have formatted like "After" it wasn't for the one
item that is too long)

llvm-svn: 290084

7 years ago[XRay][compiler-rt] Fix missing include of <cerrno>
Dean Michael Berris [Mon, 19 Dec 2016 05:26:14 +0000 (05:26 +0000)]
[XRay][compiler-rt] Fix missing include of <cerrno>

Futher attempt to un-break ARM and AArch64 build.

Follow-up on D25360.

llvm-svn: 290083

7 years agoAdd __cpp_structured_bindings feature test macro for structured bindings, per
Richard Smith [Mon, 19 Dec 2016 04:21:36 +0000 (04:21 +0000)]
Add __cpp_structured_bindings feature test macro for structured bindings, per
latest (provisional) draft of SD-6.

llvm-svn: 290082

7 years ago[c++1z] cxx_status: mark p0195r2 as done.
Richard Smith [Mon, 19 Dec 2016 04:16:03 +0000 (04:16 +0000)]
[c++1z] cxx_status: mark p0195r2 as done.

llvm-svn: 290081

7 years ago[c++1z] P0195R2: Support pack-expansion of using-declarations.
Richard Smith [Mon, 19 Dec 2016 04:08:53 +0000 (04:08 +0000)]
[c++1z] P0195R2: Support pack-expansion of using-declarations.

This change introduces UsingPackDecl as a marker for the set of UsingDecls
produced by pack expansion of a single (unresolved) using declaration. This is
not strictly necessary (we just need to be able to map from the original using
declaration to its expansions somehow), but it's useful to maintain the
invariant that each declaration reference instantiates to refer to one
declaration.

llvm-svn: 290080

7 years ago[XRay][compiler-rt] Post-commit review fixup of XRay refactoring.
Dean Michael Berris [Mon, 19 Dec 2016 03:59:20 +0000 (03:59 +0000)]
[XRay][compiler-rt] Post-commit review fixup of XRay refactoring.

Missed a couple of files:

- Using #pragma once
- Missing top-matter for headers
- Missing an include for <cstdint>

Follow-up on D25360.

llvm-svn: 290079

7 years ago[XRay][compiler-rt] Explicitly include <cstdint> for types
Dean Michael Berris [Mon, 19 Dec 2016 03:47:35 +0000 (03:47 +0000)]
[XRay][compiler-rt] Explicitly include <cstdint> for types

This is an attempt to un-break the ARM7, AArch64 builds.

Follow-up on D25360.

llvm-svn: 290078

7 years ago[XRay] [compiler-rt] Move machine-dependent code into machine-dependent files.
Dean Michael Berris [Mon, 19 Dec 2016 03:21:26 +0000 (03:21 +0000)]
[XRay] [compiler-rt] Move machine-dependent code into machine-dependent files.

Summary: Include the necessary headers while there.

Reviewers: dberris

Subscribers: llvm-commits

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

llvm-svn: 290077

7 years agoRemove inappropriate use of CachedHashStringRef.
Rui Ueyama [Mon, 19 Dec 2016 03:14:16 +0000 (03:14 +0000)]
Remove inappropriate use of CachedHashStringRef.

Use of CachedHashStringRef makes sense only when we reuse hash values.
Sprinkling it to all DenseMap has no benefits and just complicates data types.
Basically we shouldn't use CachedHashStringRef unless there is a strong
reason to to do so.

llvm-svn: 290076

7 years agoAdd a lit test for PR31374
Yaxun Liu [Mon, 19 Dec 2016 02:55:53 +0000 (02:55 +0000)]
Add a lit test for PR31374

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

llvm-svn: 290075

7 years ago[XRay] [compiler-rt] Fix format string; sanitizers' internal printf() doesn't support...
Dean Michael Berris [Mon, 19 Dec 2016 00:47:40 +0000 (00:47 +0000)]
[XRay] [compiler-rt] Fix format string; sanitizers' internal printf() doesn't support %ld.

Summary:
Getting rid of the distance number altogether because:
- a person knowledgeable enough to know what the message means will also
  know how to do hexadecimal math (with the help of a calculator)
- numbers outside INT_MIN - INT_MAX are hard to comprehend anyway

This unbreaks the case when you dynamically link a library with XRay and
it exits pre-main() with a not very informative static string.

Author: pelikan

Reviewers: dberris

Subscribers: llvm-commits, mehdi_amini

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

llvm-svn: 290074

7 years ago[X86] Remove all of the patterns that use X86ISD:FAND/FXOR/FOR/FANDN except for the...
Craig Topper [Mon, 19 Dec 2016 00:42:28 +0000 (00:42 +0000)]
[X86] Remove all of the patterns that use X86ISD:FAND/FXOR/FOR/FANDN except for the ones needed for SSE1. Anything SSE2 or above uses the integer ISD opcode.

This removes 11721 bytes from the DAG isel table or 2.2%

llvm-svn: 290073