platform/upstream/llvm.git
6 years ago[MC] fix documentation comments; NFC
Sanjay Patel [Thu, 22 Mar 2018 15:23:21 +0000 (15:23 +0000)]
[MC] fix documentation comments; NFC

llvm-svn: 328205

6 years ago[sanitizer] Split coverage into separate RT in sanitizer_common
Kostya Kortchinsky [Thu, 22 Mar 2018 15:04:31 +0000 (15:04 +0000)]
[sanitizer] Split coverage into separate RT in sanitizer_common

Summary:
`sanitizer_common`'s coverage support is fairly well separated, and libcdep by
default. Several sanitizers don't make use of coverage, and as far as I can
tell do no benefit from the extra dependencies pulled in by the coverage public
interface functions.

The following sanitizers call `InitializeCoverage` explicitely: MSan, ASan,
LSan, HWAsan, UBSan. On top of this, any sanitizer bundling RTUBSan should
add the coverage RT as well: ASan, Scudo, UBSan, CFI (diag), TSan, MSan, HWAsan.

So in the end the following have no need: DFSan, ESan, CFI, SafeStack (nolibc
anyway), XRay, and the upcoming Scudo minimal runtime.

I tested this with all the sanitizers check-* with gcc & clang, and in
standalone on Linux & Android, and there was no issue. I couldn't test this on
Mac, Fuchsia, BSDs, & Windows for lack of an environment, so adding a bunch of
people for additional scrunity. I couldn't test HWAsan either.

Reviewers: eugenis, vitalybuka, alekseyshl, flowerhack, kubamracek, dberris, rnk, krytarowski

Reviewed By: vitalybuka, alekseyshl, flowerhack, dberris

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

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

llvm-svn: 328204

6 years ago[X86][SSE42] Use the default PCMPEST/PCMPIST scheduler classes directly. NFCI.
Simon Pilgrim [Thu, 22 Mar 2018 14:56:18 +0000 (14:56 +0000)]
[X86][SSE42] Use the default PCMPEST/PCMPIST scheduler classes directly. NFCI.

Models were completely overriding all SSE42 strins instructions when the default classes could be used for exactly the same coverage.

llvm-svn: 328203

6 years agoDWARFVerifier: verify debug_names abbreviation table
Pavel Labath [Thu, 22 Mar 2018 14:50:44 +0000 (14:50 +0000)]
DWARFVerifier: verify debug_names abbreviation table

Summary:
This commit adds checks of the abbreviation table in a DWARF v5 Name
Index. The most interesting/useful check is the one which checks that
each index attributes is encoded using the correct form class, but it
also checks for the more obvious errors like unknown
forms/tags/attributes and duplicated attributes.

Reviewers: JDevlieghere, aprantl, dblaikie

Subscribers: llvm-commits

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

llvm-svn: 328202

6 years agoclang-format: Narrow down raw string literal line break exception.
Daniel Jasper [Thu, 22 Mar 2018 14:43:54 +0000 (14:43 +0000)]
clang-format: Narrow down raw string literal line break exception.

For multiline raw string literals, we generally want to respect the
author's choice of linebreak before the 'R"(' as the rest of the raw
string might be aligned to it and we cannot (commonly) modify the
content.

For single-line raw string literals, this doesn't make any sense and so
we should just treat them as regular string literals in this regard.

llvm-svn: 328201

6 years agoclang-format: Fix SpacesInParentheses with fully qualified names.
Daniel Jasper [Thu, 22 Mar 2018 14:30:28 +0000 (14:30 +0000)]
clang-format: Fix SpacesInParentheses with fully qualified names.

When SpacesInParentheses is set to true clang-format does not add a
space before fully qualified names. For example:

  do_something(::globalVar );

Fix by Darby Payne. Thank you!

llvm-svn: 328200

6 years agoclang-tidy, modularize: return non-zero exit code on errors
Alexander Kornienko [Thu, 22 Mar 2018 14:18:20 +0000 (14:18 +0000)]
clang-tidy, modularize: return non-zero exit code on errors

When no inputs given, the tools should not only produce the help message, but
also return a non-zero exit code. Fixed tests accordingly.

llvm-svn: 328199

6 years ago[llvm-mca] Minor refactoring. NFCI
Andrea Di Biagio [Thu, 22 Mar 2018 14:14:49 +0000 (14:14 +0000)]
[llvm-mca] Minor refactoring. NFCI

Also, removed a couple of unused methods from class Instruction.

llvm-svn: 328198

6 years ago[InstCombine] add folds for xor-of-icmp signbit tests (PR36682)
Sanjay Patel [Thu, 22 Mar 2018 14:08:16 +0000 (14:08 +0000)]
[InstCombine] add folds for xor-of-icmp signbit tests (PR36682)

This is a retry of r328119 which was reverted at r328145 because
it could crash by trying to combine icmps with different operand
types. This version has a check for that and additional tests.

Original commit message:

This is part of solving:
https://bugs.llvm.org/show_bug.cgi?id=36682

There's also a leftover improvement from the long-ago-closed:
https://bugs.llvm.org/show_bug.cgi?id=5438

https://rise4fun.com/Alive/dC1

llvm-svn: 328197

6 years ago[CodeGen] Emit DWARF "constructor" calling convention
Jonas Devlieghere [Thu, 22 Mar 2018 13:53:30 +0000 (13:53 +0000)]
[CodeGen] Emit DWARF "constructor" calling convention

Now that LLVM has support for emitting calling conventions in DWARF (see
r328191) have clang emit them.

Patch by: Adrien Guinet

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

llvm-svn: 328196

6 years ago[ELF] - Apply clang-format. NFC.
George Rimar [Thu, 22 Mar 2018 13:47:56 +0000 (13:47 +0000)]
[ELF] - Apply clang-format. NFC.

llvm-svn: 328195

6 years ago[X86][CLMUL] Use the default CLMUL scheduler classes directly. NFCI.
Simon Pilgrim [Thu, 22 Mar 2018 13:37:30 +0000 (13:37 +0000)]
[X86][CLMUL] Use the default CLMUL scheduler classes directly. NFCI.

Models were completely overriding all CLMUL instructions when the WriteCLMUL default classes could be used for exactly the same coverage.

llvm-svn: 328194

6 years ago[X86][CLMUL] Fix/add missing itinerary tags to (V)PCLMULQDQ instructions
Simon Pilgrim [Thu, 22 Mar 2018 13:36:06 +0000 (13:36 +0000)]
[X86][CLMUL] Fix/add missing itinerary tags to (V)PCLMULQDQ instructions

PCLMULQDQrm was using the rr itinerary.

Difference in itineraries between PCLMULQDQ/VPCLMULQDQ variants was causing an unnecessary duplication of scheduler class entries.

llvm-svn: 328193

6 years ago[X86] Use the default AES scheduler classes directly. NFCI.
Simon Pilgrim [Thu, 22 Mar 2018 13:18:08 +0000 (13:18 +0000)]
[X86] Use the default AES scheduler classes directly. NFCI.

Models were completely overriding all AES instructions when the WriteAES default classes could be used for exactly the same coverage.

Removes 6 unnecessary scheduler classes from every model.

Note: Still looking for a way for tblgen to warn when this is happening - often the override is more complete than the default.
llvm-svn: 328192

6 years agoAdd vendor specific calling convention to DWARF
Jonas Devlieghere [Thu, 22 Mar 2018 12:24:07 +0000 (12:24 +0000)]
Add vendor specific calling convention to DWARF

This patch adds LLVM's and GCC's calling conventions so they can be
emitted in the DWARF debug info.

Patch by: Adrien Guinet

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

llvm-svn: 328191

6 years ago[llvm-mca] Simplify (and better standardize) the Instruction interface.
Andrea Di Biagio [Thu, 22 Mar 2018 11:39:34 +0000 (11:39 +0000)]
[llvm-mca] Simplify (and better standardize) the Instruction interface.

llvm-svn: 328190

6 years ago[CloneFunction] Preserve DT in DuplicateInstructionsInSplitBetween.
Florian Hahn [Thu, 22 Mar 2018 11:38:53 +0000 (11:38 +0000)]
[CloneFunction] Preserve DT in DuplicateInstructionsInSplitBetween.

DuplicateInstructionsInSplitBetween can preserve the DT by passing
through DT to SplitEdge.

Reviewers: sanjoy, junbuml, anna, kuhar

Reviewed By: kuhar

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

llvm-svn: 328189

6 years agoRevert "[test] Add tests for llc passes pipelines."
Jonas Devlieghere [Thu, 22 Mar 2018 10:34:06 +0000 (10:34 +0000)]
Revert "[test] Add tests for llc passes pipelines."

This reverts r328159 because the two AArch64 tests fail on GreenDragon:
http://green.lab.llvm.org/green/job/clang-stage1-cmake-RA-expensive/11030/

llvm-svn: 328188

6 years ago[llvm-mca] Simplify code. NFC
Andrea Di Biagio [Thu, 22 Mar 2018 10:19:20 +0000 (10:19 +0000)]
[llvm-mca] Simplify code. NFC

llvm-svn: 328187

6 years agocommit temporary workaround for new Clang exception warning
Eric Fiselier [Thu, 22 Mar 2018 07:53:47 +0000 (07:53 +0000)]
commit temporary workaround for new Clang exception warning

llvm-svn: 328186

6 years agoCorrect TEST_HAS_NO_ALIGNED_ALLOCATION macro definition
Eric Fiselier [Thu, 22 Mar 2018 06:21:07 +0000 (06:21 +0000)]
Correct TEST_HAS_NO_ALIGNED_ALLOCATION macro definition

llvm-svn: 328185

6 years ago[TableGen] Use empty emplace_back to add defaulted constructed objects to vectors...
Craig Topper [Thu, 22 Mar 2018 06:15:10 +0000 (06:15 +0000)]
[TableGen] Use empty emplace_back to add defaulted constructed objects to vectors to avoid using resize(size()+1). NFC

llvm-svn: 328184

6 years ago[TableGen] Add a non-default constructor to CodeGenSchedClass and use it via emplace_...
Craig Topper [Thu, 22 Mar 2018 06:15:08 +0000 (06:15 +0000)]
[TableGen] Add a non-default constructor to CodeGenSchedClass and use it via emplace_back to create new SchedClasses instead of using resize(size+1)

llvm-svn: 328183

6 years agoFix dynarray test failures after changing __libcpp_allocate/deallocate
Eric Fiselier [Thu, 22 Mar 2018 05:44:48 +0000 (05:44 +0000)]
Fix dynarray test failures after changing __libcpp_allocate/deallocate

llvm-svn: 328182

6 years ago[X86] Remove unused SchedWriteRes classes. NFC
Craig Topper [Thu, 22 Mar 2018 04:52:08 +0000 (04:52 +0000)]
[X86] Remove unused SchedWriteRes classes. NFC

llvm-svn: 328181

6 years agoFix PR22634 - std::allocator doesn't respect over-aligned types.
Eric Fiselier [Thu, 22 Mar 2018 04:42:56 +0000 (04:42 +0000)]
Fix PR22634 - std::allocator doesn't respect over-aligned types.

This patch fixes std::allocator, and more specifically, all users
of __libcpp_allocate and __libcpp_deallocate, to support over-aligned
types.

__libcpp_allocate/deallocate now take an alignment parameter, and when
the specified alignment is greater than that supported by malloc/new,
the aligned version of operator new is called (assuming it's available).

When aligned new isn't available, the old behavior has been kept, and the
alignment parameter is ignored.

This patch depends on recent changes to __builtin_operator_new/delete which
allow them to be used to call any regular new/delete operator. By using
__builtin_operator_new/delete when possible, the new/delete erasure optimization
is maintained.

llvm-svn: 328180

6 years ago[X86][Skylake] Merge multiple InstrRW entries that map to the same SchedWriteRes...
Craig Topper [Thu, 22 Mar 2018 04:23:41 +0000 (04:23 +0000)]
[X86][Skylake] Merge multiple InstrRW entries that map to the same SchedWriteRes group (NFCI) (PR35955)

I've also merged some VEX/non-VEX instregex strings with a (V?) prefix or (Y?) ymm variant - there are still a lot more of these to do.

This reduces the size of the optimized llc binary on my computer by 400K. Presumably because we went from 5000+ scheduler classes per CPU to ~2000.

llvm-svn: 328179

6 years ago[DIA] Add IPDBSectionContrib interfaces and DIA implementation
Aaron Smith [Thu, 22 Mar 2018 04:08:15 +0000 (04:08 +0000)]
[DIA] Add IPDBSectionContrib interfaces and DIA implementation

To resolve symbol context at a particular address, we need to
determine the compiland for the address. We are able to determine
the parent compiland of PDBSymbolFunc, PDBSymbolTypeUDT,
PDBSymbolTypeEnum symbols indirectly through line information.
However no such information is availabile for PDBSymbolData,
i.e. variables.

The Section Contribution table from PDBs has information about
each compiland's contribution to sections by address. For example,
a piece of a contribution looks like,

  VA         RelativeVA  Sect No.  Offset    Length    Compiland
  14000087B0 000087B0    0001      000077B0  000000BB  exe_main.obj

So given an address, it's possible to determine its compiland with
this information.

llvm-svn: 328178

6 years ago[PDB] Get more DIA table enumerators
Aaron Smith [Thu, 22 Mar 2018 03:57:06 +0000 (03:57 +0000)]
[PDB] Get more DIA table enumerators

Rename the original function and make it a static template.

llvm-svn: 328177

6 years ago[SymbolFilePDB] Run clang-format; NFC
Aaron Smith [Thu, 22 Mar 2018 03:44:51 +0000 (03:44 +0000)]
[SymbolFilePDB] Run clang-format; NFC

llvm-svn: 328176

6 years ago[clang-format] Add a few more Core Graphics identifiers to ObjC heuristic
Ben Hamilton [Thu, 22 Mar 2018 03:25:22 +0000 (03:25 +0000)]
[clang-format] Add a few more Core Graphics identifiers to ObjC heuristic

Summary:
We received reports of the Objective-C style guesser getting a false
negative on header files like:

CGSize SizeOfThing(MyThing thing);

This adds more Core Graphics identifiers to the Objective-C style
guesser.

Test Plan: New tests added. Ran tests with:
  % make -j12 FormatTests && ./tools/clang/unittests/Format/FormatTests

Reviewers: jolesiak, djasper

Reviewed By: jolesiak, djasper

Subscribers: krasimir, klimek, cfe-commits

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

llvm-svn: 328175

6 years ago[clang-format] Don't insert space between r_paren and 'new' in ObjC decl
Ben Hamilton [Thu, 22 Mar 2018 03:23:53 +0000 (03:23 +0000)]
[clang-format] Don't insert space between r_paren and 'new' in ObjC decl

Summary:
Previously, clang-format would insert a space between
the closing parenthesis and 'new' in the following valid Objective-C
declaration:

  + (instancetype)new;

This was because 'new' is treated as a keyword, not an identifier.

TokenAnnotator::spaceRequiredBefore() already handled the case where
r_paren came before an identifier, so this diff extends it to
handle r_paren before 'new'.

Test Plan: New tests added. Ran tests with:
  % make -j12 FormatTests && ./tools/clang/unittests/Format/FormatTests

Reviewers: djasper, jolesiak, stephanemoore

Reviewed By: djasper, jolesiak, stephanemoore

Subscribers: stephanemoore, klimek, cfe-commits

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

llvm-svn: 328174

6 years agoImprove -Winfinite-recursion
Robert Widmann [Thu, 22 Mar 2018 03:16:23 +0000 (03:16 +0000)]
Improve -Winfinite-recursion

Summary: Rewrites -Winfinite-recursion to remove the state dictionary and explore paths in loops - especially infinite loops.  The new check now detects recursion in loop bodies dominated by a recursive call.

Reviewers: rsmith, rtrieu

Reviewed By: rtrieu

Subscribers: lebedev.ri, cfe-commits

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

llvm-svn: 328173

6 years agoRevert "[clang-doc] Reland "[clang-doc] Setup clang-doc frontend framework""
Julie Hockett [Thu, 22 Mar 2018 02:05:51 +0000 (02:05 +0000)]
Revert "[clang-doc] Reland "[clang-doc] Setup clang-doc frontend framework""

This reverts commit r328150 until we can fix the test that are failing
on the Windows release build.

llvm-svn: 328172

6 years ago[Frontend] Fix some Clang-tidy modernize and Include What You Use warnings; other...
Eugene Zelenko [Thu, 22 Mar 2018 00:53:26 +0000 (00:53 +0000)]
[Frontend] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).

llvm-svn: 328171

6 years agovim: add `dso_local` and `dso_preemptable` keywords
Saleem Abdulrasool [Wed, 21 Mar 2018 23:46:09 +0000 (23:46 +0000)]
vim: add `dso_local` and `dso_preemptable` keywords

Support the new keywords introduced in SVN r316668.

llvm-svn: 328170

6 years agoUpdate for LLVM header movement
David Blaikie [Wed, 21 Mar 2018 23:21:10 +0000 (23:21 +0000)]
Update for LLVM header movement

llvm-svn: 328169

6 years agoMake test a bit less strict. NFC.
Rafael Espindola [Wed, 21 Mar 2018 23:01:10 +0000 (23:01 +0000)]
Make test a bit less strict. NFC.

llvm-svn: 328168

6 years ago[test] Try to unbreak hexagon bots after r328160.
Michael Zolotukhin [Wed, 21 Mar 2018 22:57:33 +0000 (22:57 +0000)]
[test] Try to unbreak hexagon bots after r328160.

llvm-svn: 328167

6 years agoFix for LLVM change (Transforms/Utils/Local.h -> Analysis/Utils/Local.h)
David Blaikie [Wed, 21 Mar 2018 22:34:27 +0000 (22:34 +0000)]
Fix for LLVM change (Transforms/Utils/Local.h -> Analysis/Utils/Local.h)

llvm-svn: 328166

6 years agoFix a couple of layering violations in Transforms
David Blaikie [Wed, 21 Mar 2018 22:34:23 +0000 (22:34 +0000)]
Fix a couple of layering violations in Transforms

Remove #include of Transforms/Scalar.h from Transform/Utils to fix layering.

Transforms depends on Transforms/Utils, not the other way around. So
remove the header and the "createStripGCRelocatesPass" function
declaration (& definition) that is unused and motivated this dependency.

Move Transforms/Utils/Local.h into Analysis because it's used by
Analysis/MemoryBuiltins.cpp.

llvm-svn: 328165

6 years agoReplace a std::pair with a struct.
Rafael Espindola [Wed, 21 Mar 2018 22:32:17 +0000 (22:32 +0000)]
Replace a std::pair with a struct.

This is more readable and should reduce the noise in a followup patch.

llvm-svn: 328164

6 years ago[InstrProf] Encapsulates access to AddrToMD5Map.
Mircea Trofin [Wed, 21 Mar 2018 22:27:31 +0000 (22:27 +0000)]
[InstrProf] Encapsulates access to AddrToMD5Map.

Summary:
This fixes a unittest failure introduced by D44717

D44717 introduced lazy sorting of the internal data structures of the
symbol table. The AddrToMD5Map getter was potentially exposing
inconsistent (unsorted) state. We could sort in the accessor, however,
a client may store the pointer and thus bypass the internal state
management of the symbol table. The alternative in this CL blocks
direct access to the state, thus ensuring consistent
externally-observable state.

Reviewers: davidxl, xur, eraman

Reviewed By: xur

Subscribers: llvm-commits

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

llvm-svn: 328163

6 years ago[PDB] Don't ignore bucket 0 when writing the PDB string table.
Zachary Turner [Wed, 21 Mar 2018 22:23:59 +0000 (22:23 +0000)]
[PDB] Don't ignore bucket 0 when writing the PDB string table.

The hash table is a list of buckets, and the *value* stored in
the bucket cannot be 0 since that is reserved.  However, the code
here was incorrectly skipping over the 0'th bucket entirely.
The 0'th bucket is perfectly fine, just none of these buckets
can contain the value 0.

As a result, whenever there was a string where hash(S) % Size
was equal to 0, we would write the value in the next bucket
instead.  We never caught this in our tests due to *another*
bug, which is that we would iterate the entire list of buckets
looking for the value, only using the hash value as a starting
point.  However, the real algorithm stops when it finds 0 in
a bucket since it takes that to mean "the item is not in the
hash table".

The unit test is updated to carefully construct a set of hash
values that will cause one item to hash to 0 mod bucket count,
and the reader is also updated to return an error indicating that
the item is not found when it encounters a 0 bucket.

llvm-svn: 328162

6 years ago[CUDA] Disable LTO for device-side compilations.
Artem Belevich [Wed, 21 Mar 2018 22:22:59 +0000 (22:22 +0000)]
[CUDA] Disable LTO for device-side compilations.

This fixes host-side LTO during CUDA compilation. Before, LTO
pipeline construction was clashing with CUDA pipeline construction.

At the moment there's no point doing LTO on device side as each
device-side TU is a complete program.  We will need to figure out
compilation pipeline construction for the device-side LTO when we
have working support for multi-TU device-side CUDA compilation.

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

llvm-svn: 328161

6 years ago[test] Add tests for opt passes pipelines for O0, O2, O3, and Os.
Michael Zolotukhin [Wed, 21 Mar 2018 22:17:31 +0000 (22:17 +0000)]
[test] Add tests for opt passes pipelines for O0, O2, O3, and Os.

llvm-svn: 328160

6 years ago[test] Add tests for llc passes pipelines.
Michael Zolotukhin [Wed, 21 Mar 2018 22:17:13 +0000 (22:17 +0000)]
[test] Add tests for llc passes pipelines.

This is basically an extension of existing test
test/CodeGen/X86/O0-pipeline.ll introduced in r302608.

llvm-svn: 328159

6 years ago[NVPTX] Make tensor shape part of WMMA intrinsic's name.
Artem Belevich [Wed, 21 Mar 2018 21:55:02 +0000 (21:55 +0000)]
[NVPTX] Make tensor shape part of WMMA intrinsic's name.

This is needed for the upcoming implementation of the
new 8x32x16 and 32x8x16 variants of WMMA instructions
introduced in CUDA 9.1.

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

llvm-svn: 328158

6 years ago[llvm-profdata] Use "-o /dev/null" in invalid-profdata.test
Reid Kleckner [Wed, 21 Mar 2018 21:51:53 +0000 (21:51 +0000)]
[llvm-profdata] Use "-o /dev/null" in invalid-profdata.test

Lit automatically rewrites /dev/null to a temp file on Windows.

llvm-svn: 328157

6 years ago[PDB] Remove unused private variable, re-applying r327900 after relanding more natvis...
Reid Kleckner [Wed, 21 Mar 2018 21:47:26 +0000 (21:47 +0000)]
[PDB] Remove unused private variable, re-applying r327900 after relanding more natvis changes[4~

llvm-svn: 328156

6 years ago[WebAssembly] Really disable wasm register name matcher
Reid Kleckner [Wed, 21 Mar 2018 21:46:47 +0000 (21:46 +0000)]
[WebAssembly] Really disable wasm register name matcher

The "ShouldEmitMatchRegisterName" bit wasn't taking effect because the
WebAssembly target didn't point to the custom WebAssemblyAsmParser
record.

llvm-svn: 328155

6 years agoHandle abbr_offset with relocations.
Rafael Espindola [Wed, 21 Mar 2018 21:31:25 +0000 (21:31 +0000)]
Handle abbr_offset with relocations.

This is mostly just plumbing to get a DWARFDataExtractor where we
compute abbr_offset so we can use getRelocatedValue.

This is part of PR36793.

llvm-svn: 328154

6 years ago[Modules] Fix creating fake definition data for lambdas.
Volodymyr Sapsai [Wed, 21 Mar 2018 21:28:54 +0000 (21:28 +0000)]
[Modules] Fix creating fake definition data for lambdas.

During reading C++ definition data for lambda we can access
CXXRecordDecl representing lambda before we finished reading the
definition data. This can happen by reading a captured variable which is
VarDecl, then reading its decl context which is CXXMethodDecl `operator()`,
then trying to merge redeclarable methods and accessing
enclosing CXXRecordDecl. The call stack looks roughly like

    VisitCXXRecordDecl
      ReadCXXRecordDefinition
        VisitVarDecl
          VisitCXXMethodDecl
            mergeRedeclarable
              getPrimaryContextForMerging

If we add fake definition data at this point, later we'll hit the assertion

    Assertion failed: (!DD.IsLambda && !MergeDD.IsLambda && "faked up lambda definition?"), function MergeDefinitionData, file clang/lib/Serialization/ASTReaderDecl.cpp, line 1675.

The fix is to assign definition data before reading it. Fixes PR32556.

rdar://problem/37461072

Reviewers: rsmith, bruno

Reviewed By: rsmith

Subscribers: cfe-commits, jkorous-apple, aprantl

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

llvm-svn: 328153

6 years ago[InstCombine] move/add tests for fmul distribution; NFC
Sanjay Patel [Wed, 21 Mar 2018 21:28:19 +0000 (21:28 +0000)]
[InstCombine] move/add tests for fmul distribution; NFC

There are at least 3 problems:
1. We're distributing across large patterns, but fail to do that for the minimal patterns.
2. We're not checking uses, so we may create more instructions than we eliminate.
3. We should be able to do these transforms with less than full 'fast' fmuls.

llvm-svn: 328152

6 years agoMmap interceptor new option, Write Exec runtime detector
Vitaly Buka [Wed, 21 Mar 2018 21:25:07 +0000 (21:25 +0000)]
Mmap interceptor new option, Write Exec runtime detector

Summary:
Following-up the refactoring of mmap interceptors, adding a new common
option to detect PROT_WRITE|PROT_EXEC pages request.

Patch by David CARLIER

Reviewers: vitalybuka, vsk

Reviewed By: vitalybuka

Subscribers: krytarowski, #sanitizers

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

llvm-svn: 328151

6 years ago[clang-doc] Reland "[clang-doc] Setup clang-doc frontend framework"
Julie Hockett [Wed, 21 Mar 2018 21:21:45 +0000 (21:21 +0000)]
[clang-doc] Reland "[clang-doc] Setup clang-doc frontend framework"

Fixing the the failing Windows tests.

llvm-svn: 328150

6 years ago[clangd][nfc] Correct header name in comment
Jan Korous [Wed, 21 Mar 2018 21:04:10 +0000 (21:04 +0000)]
[clangd][nfc] Correct header name in comment

llvm-svn: 328149

6 years ago[OpenMP][libomptarget] Initialize global memory stack only once.
Gheorghe-Teodor Bercea [Wed, 21 Mar 2018 21:02:55 +0000 (21:02 +0000)]
[OpenMP][libomptarget] Initialize global memory stack only once.

Summary: The global stack initialization function may be called multiple times. The initialization of the shared memory slots should only happen when the function is called for the first time for a given warp master thread.

Reviewers: grokos, carlo.bertolli, ABataev, caomhin

Reviewed By: grokos

Subscribers: guansong, openmp-commits

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

llvm-svn: 328148

6 years ago[POWER9][NFC] update testcase check statements
Lei Huang [Wed, 21 Mar 2018 20:59:45 +0000 (20:59 +0000)]
[POWER9][NFC] update testcase check statements

llvm-svn: 328147

6 years ago[OpenMP][libomptarget] Fix master warp check
Gheorghe-Teodor Bercea [Wed, 21 Mar 2018 20:51:16 +0000 (20:51 +0000)]
[OpenMP][libomptarget] Fix master warp check

Summary: The check for the master warp must take into consideration the actual number of warps: the master warp is equal to the last active warp not necessarily WARPSIZE - 1.

Reviewers: grokos, carlo.bertolli, ABataev, caomhin

Reviewed By: grokos

Subscribers: guansong, openmp-commits

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

llvm-svn: 328146

6 years agoRevert r328119 "[InstCombine] add folds for xor-of-icmp signbit tests (PR36682)"
Reid Kleckner [Wed, 21 Mar 2018 20:35:36 +0000 (20:35 +0000)]
Revert r328119 "[InstCombine] add folds for xor-of-icmp signbit tests (PR36682)"

This asserts when compiling safe_numerics_unittest.cpp in Chromium with
MSan.

llvm-svn: 328145

6 years ago[OpenMP][libomptarget] Enable globalization for workers
Gheorghe-Teodor Bercea [Wed, 21 Mar 2018 20:34:19 +0000 (20:34 +0000)]
[OpenMP][libomptarget] Enable globalization for workers

Summary:
This patch allows worker to have a global memory stack managed by the runtime. This patch is needed for completeness and consistency with the globalization policy: if a worker-side variable escapes the current context it then needs to be globalized.
Until now, only the master thread was allowed to have such a stack. These global values can now potentially be shared amongst workers if the semantics of the OpenMP program require it.

Reviewers: ABataev, grokos, carlo.bertolli, caomhin

Reviewed By: grokos

Subscribers: guansong, openmp-commits

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

llvm-svn: 328144

6 years ago[llvm-objcopy] Implement support for section groups
Alexander Shaposhnikov [Wed, 21 Mar 2018 19:53:44 +0000 (19:53 +0000)]
[llvm-objcopy] Implement support for section groups

This diff adds support for SHT_GROUP sections to llvm-objcopy.
Some sections are interrelated and comprise a group.
For example, a definition of an inline function might require,
in addition to the section containing its instructions,
a read-only data section containing literals referenced inside the function.
A section of the type SHT_GROUP contains the indices of the group members,
therefore, it needs to be updated whenever the indices change.
Similarly, the fields sh_link, sh_info should be recalculated as well.

[Resubmit r328012 with the proper handling of endianness]

Test plan: make check-all

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

llvm-svn: 328143

6 years ago[TableGen] Hoist the code for copying InstRWs from an old scheduling class to a new...
Craig Topper [Wed, 21 Mar 2018 19:52:13 +0000 (19:52 +0000)]
[TableGen] Hoist the code for copying InstRWs from an old scheduling class to a new one out of the loop that assigns instructions to the new class. NFCI

We already know all the of instructions we're processing in the instruction loop belong to no class or all to the same class. So we only have to worry about remapping one class. So hoist it all out and remove the SmallPtrSet that tracked which class we'd already remapped.

I had to introduce new instruction loop inside this code to print an error message, but that only occurs on the error path.

llvm-svn: 328142

6 years agotypo
Adrian Prantl [Wed, 21 Mar 2018 19:33:07 +0000 (19:33 +0000)]
typo

llvm-svn: 328141

6 years ago[InstSimplify] fp_binop X, NaN --> NaN
Sanjay Patel [Wed, 21 Mar 2018 19:31:53 +0000 (19:31 +0000)]
[InstSimplify] fp_binop X, NaN --> NaN

We propagate the existing NaN value when possible.

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

llvm-svn: 328140

6 years ago[TableGen] Remove unnecessary map lookup and shadowing of a variable. NFCI
Craig Topper [Wed, 21 Mar 2018 19:30:33 +0000 (19:30 +0000)]
[TableGen] Remove unnecessary map lookup and shadowing of a variable. NFCI

We already have an OldSCIdx variable in the outer loop here. And we already did the map lookup in the loop that populated ClassInstrs. And the outer OldSCIdx got it from ClassInstrs.

llvm-svn: 328139

6 years ago[TableGen] Use range-based for loops. NFC
Craig Topper [Wed, 21 Mar 2018 19:30:31 +0000 (19:30 +0000)]
[TableGen] Use range-based for loops. NFC

llvm-svn: 328138

6 years ago[TableGen] Use count_if instead of a manual loop. NFC
Craig Topper [Wed, 21 Mar 2018 19:30:30 +0000 (19:30 +0000)]
[TableGen] Use count_if instead of a manual loop. NFC

llvm-svn: 328137

6 years ago[X86] Rewrite getOperandBias in X86BaseInfo.h to be a little more structured and...
Craig Topper [Wed, 21 Mar 2018 19:30:28 +0000 (19:30 +0000)]
[X86] Rewrite getOperandBias in X86BaseInfo.h to be a little more structured and update comments to be more clear about what it does. NFC

llvm-svn: 328136

6 years agoSink Analysis/ObjectUtil(canBeOmittedFromSymbolTable) into IR so it can be legitimate...
David Blaikie [Wed, 21 Mar 2018 19:23:45 +0000 (19:23 +0000)]
Sink Analysis/ObjectUtil(canBeOmittedFromSymbolTable) into IR so it can be legitimately be used by Object/IRSymtab

llvm-svn: 328135

6 years ago[Builtins] Overload __builtin_operator_new/delete to allow forwarding to usual alloca...
Eric Fiselier [Wed, 21 Mar 2018 19:19:48 +0000 (19:19 +0000)]
[Builtins] Overload __builtin_operator_new/delete to allow forwarding to usual allocation/deallocation functions.

Summary:
Libc++'s default allocator uses `__builtin_operator_new` and `__builtin_operator_delete` in order to allow the calls to new/delete to be ellided. However, libc++ now needs to support over-aligned types in the default allocator. In order to support this without disabling the existing optimization Clang needs to support calling the aligned new overloads from the builtins.

See llvm.org/PR22634 for more information about the libc++ bug.

This patch changes `__builtin_operator_new`/`__builtin_operator_delete` to call any usual `operator new`/`operator delete` function. It does this by performing overload resolution with the arguments passed to the builtin to determine which allocation function to call. If the selected function is not a usual allocation function a diagnostic is issued.

One open issue is if the `align_val_t` overloads should be considered "usual" when `LangOpts::AlignedAllocation` is disabled.

In order to allow libc++ to detect this new behavior the value for `__has_builtin(__builtin_operator_new)` has been updated to `201802`.

Reviewers: rsmith, majnemer, aaron.ballman, erik.pilkington, bogner, ahatanak

Reviewed By: rsmith

Subscribers: cfe-commits

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

llvm-svn: 328134

6 years ago[SLP] Add test case for a gather sequence with multiple uses
Matthew Simpson [Wed, 21 Mar 2018 19:13:14 +0000 (19:13 +0000)]
[SLP] Add test case for a gather sequence with multiple uses

llvm-svn: 328133

6 years ago[InstrProf] Support for external functions in text format.
Mircea Trofin [Wed, 21 Mar 2018 19:06:06 +0000 (19:06 +0000)]
[InstrProf] Support for external functions in text format.

Summary:
External functions appearing as indirect call targets could not be
found in the SymTab, and the value:counter record was represented,
in the text format, using an empty string for the name. This would
then cause a silent parsing error when reading.

This CL:
- adds explicit support for such functions
- fixes the places where we would not propagate errors when reading
- addresses a performance issue due to eager resorting of the SymTab.

Reviewers: xur, eraman, davidxl

Reviewed By: davidxl

Subscribers: llvm-commits

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

llvm-svn: 328132

6 years agoReland "[lit] Adding config initialization to lit tests in clang-tools-extra"
Julie Hockett [Wed, 21 Mar 2018 18:50:26 +0000 (18:50 +0000)]
Reland "[lit] Adding config initialization to lit tests in clang-tools-extra"

Adding the config initialization to clang-tools-extra so that tests that
use REQUIRES, UNSUPPORTED, and XFAIL based on platform or target triple
work properly.

llvm-svn: 328131

6 years agoEnsure that DataTypes.h is installed now that it's moved to llvm-c
David Blaikie [Wed, 21 Mar 2018 18:21:57 +0000 (18:21 +0000)]
Ensure that DataTypes.h is installed now that it's moved to llvm-c

llvm-svn: 328130

6 years ago[llvm-mca] Move the logic that computes the register file usage to the BackendStatist...
Andrea Di Biagio [Wed, 21 Mar 2018 18:11:05 +0000 (18:11 +0000)]
[llvm-mca] Move the logic that computes the register file usage to the BackendStatistics view.

With this patch, the "instruction dispatched" event now provides information
related to the number of microarchitectural registers used in each register
file. Similarly, the "instruction retired" event is now able to tell how may
registers are freed in each register file.

Currently, the BackendStatistics view is the only consumer of register
usage/pressure information. BackendStatistics uses that info to print out a few
general statistics (i.e. max number of mappings used; total mapping created).
Before this patch, the BackendStatistics was forced to query the Backend to
obtain the register pressure information.

This helps removes that dependency. Now views are completely independent from
the Backend.  As a consequence, it should be easier to address PR36663 and
further modularize the pipeline.

Added a couple of test cases in the BtVer2 specific directory.

llvm-svn: 328129

6 years ago[SchedModel] Use CodeGenSchedClass::getSchedClassIdx helper directly. NFCI.
Simon Pilgrim [Wed, 21 Mar 2018 18:09:34 +0000 (18:09 +0000)]
[SchedModel] Use CodeGenSchedClass::getSchedClassIdx helper directly. NFCI.

llvm-svn: 328128

6 years ago[clang-tidy] Marking hicpp-no-assembler-msvc unsupported on Windows
Julie Hockett [Wed, 21 Mar 2018 18:03:41 +0000 (18:03 +0000)]
[clang-tidy] Marking hicpp-no-assembler-msvc unsupported on Windows

After changes to lit.site.cfg.in, the test is now running (and failing)
on windows, so temporarily marking it unsupported. See PR36855 for more
details.

llvm-svn: 328127

6 years ago[SchedModel] Use CodeGenSchedClass::isKeyEqual instead of duplicating code. NFCI.
Simon Pilgrim [Wed, 21 Mar 2018 17:57:21 +0000 (17:57 +0000)]
[SchedModel] Use CodeGenSchedClass::isKeyEqual instead of duplicating code. NFCI.

llvm-svn: 328126

6 years ago[libFuzzer] Disable equivalence-signals test on Darwin due to persistent failures
George Karpenkov [Wed, 21 Mar 2018 17:55:36 +0000 (17:55 +0000)]
[libFuzzer] Disable equivalence-signals test on Darwin due to persistent failures

llvm-svn: 328125

6 years ago[Docs] Remove some WIP X86 documentation I accidentally leaked into r328031.
Craig Topper [Wed, 21 Mar 2018 17:32:57 +0000 (17:32 +0000)]
[Docs] Remove some WIP X86 documentation I accidentally leaked into r328031.

I didn't mean to commit it, but I guess I failed to switch branches or stash it in my local tree.

llvm-svn: 328124

6 years agoReapply Support layering fixes.
David Blaikie [Wed, 21 Mar 2018 17:31:49 +0000 (17:31 +0000)]
Reapply Support layering fixes.

Compiler.h is used by Demangle (which Support depends on) - so sink it
into Demangle to avoid a circular dependency

DataTypes.h is used by llvm-c (which Support depends on) - so sink it
into llvm-c.

DataTypes.h could probably be fixed the other way - making llvm-c depend
on Support instead of Support depending on llvm-c - if anyone feels
that's the better option, happy to work with them on that.

I /think/ this'll address the layering issues that previous attempts to
commit this have triggered in the Modules buildbot, but I haven't been
able to reproduce that build so can't say for sure. If anyone's having
trouble with this - it might be worth taking a look to see if there's a
quick fix/something small I missed rather than revert, but no worries.

llvm-svn: 328123

6 years agoAdd missing #includes to Analysis/MustExecute.h
David Blaikie [Wed, 21 Mar 2018 17:31:45 +0000 (17:31 +0000)]
Add missing #includes to Analysis/MustExecute.h

llvm-svn: 328122

6 years ago[Documentation] Fix markup problems in X86Usage.rst
Eugene Zelenko [Wed, 21 Mar 2018 17:24:04 +0000 (17:24 +0000)]
[Documentation] Fix markup problems in X86Usage.rst

llvm-svn: 328121

6 years ago[Hexagon] Generalize DAG mutation for function calls
Krzysztof Parzyszek [Wed, 21 Mar 2018 17:23:32 +0000 (17:23 +0000)]
[Hexagon] Generalize DAG mutation for function calls

Add barrier edges to check for any physical register. The previous code
worked for the function return registers: r0/d0, v0/w0.

Patch by Brendon Cahoon.

llvm-svn: 328120

6 years ago[InstCombine] add folds for xor-of-icmp signbit tests (PR36682)
Sanjay Patel [Wed, 21 Mar 2018 17:17:13 +0000 (17:17 +0000)]
[InstCombine] add folds for xor-of-icmp signbit tests (PR36682)

This is part of solving:
https://bugs.llvm.org/show_bug.cgi?id=36682

There's also a leftover improvement from the long-ago-closed:
https://bugs.llvm.org/show_bug.cgi?id=5438

https://rise4fun.com/Alive/dC1

llvm-svn: 328119

6 years agoTableGen: Remove redundant loop in ListInit::resolveReferences
Nicolai Haehnle [Wed, 21 Mar 2018 17:13:10 +0000 (17:13 +0000)]
TableGen: Remove redundant loop in ListInit::resolveReferences

Summary:
Recursive lookups are handled by the Resolver, so the loop was purely
a waste of runtime.

Change-Id: I2bd23a68b478aea0bbac1a86ca7635adffa28688

Reviewers: arsenm, craig.topper, tra, MartinO

Subscribers: wdng, llvm-commits

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

llvm-svn: 328118

6 years agoTableGen: Streamline how defs are instantiated
Nicolai Haehnle [Wed, 21 Mar 2018 17:12:53 +0000 (17:12 +0000)]
TableGen: Streamline how defs are instantiated

Summary:
Instantiating def's and defm's needs to perform the following steps:

- for defm's, clone multiclass def prototypes and subsitute template args
- for def's and defm's, add subclass definitions, substituting template
  args
- clone the record based on foreach loops and substitute loop iteration
  variables
- override record variables based on the global 'let' stack
- resolve the record name (this should be simple, but unfortunately it's
  not due to existing .td files relying on rather silly implementation
  details)
- for def(m)s in multiclasses, add the unresolved record as a multiclass
  prototype
- for top-level def(m)s, resolve all internal variable references and add
  them to the record keeper and any active defsets

This change streamlines how we go through these steps, by having both
def's and defm's feed into a single addDef() method that handles foreach,
final resolve, and routing the record to the right place.

This happens to make foreach inside of multiclasses work, as the new
test case demonstrates. Previously, foreach inside multiclasses was not
forbidden by the parser, but it was de facto broken.

Another side effect is that the order of "instantiated from" notes in error
messages is reversed, as the modified test case shows. This is arguably
clearer, since the initial error message ends up pointing directly to
whatever triggered the error, and subsequent notes will point to increasingly
outer layers of multiclasses. This is consistent with how C++ compilers
report nested #includes and nested template instantiations.

Change-Id: Ica146d0db2bc133dd7ed88054371becf24320447

Reviewers: arsenm, craig.topper, tra, MartinO

Subscribers: wdng, llvm-commits

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

llvm-svn: 328117

6 years ago[Documentation] Fix markup problem in AMDGPUUsage.rst.
Eugene Zelenko [Wed, 21 Mar 2018 17:09:35 +0000 (17:09 +0000)]
[Documentation] Fix markup problem in AMDGPUUsage.rst.

llvm-svn: 328116

6 years ago[clang-tidy] Use :doc: for check links in Release Notes.
Eugene Zelenko [Wed, 21 Mar 2018 17:06:13 +0000 (17:06 +0000)]
[clang-tidy] Use :doc: for check links in Release Notes.

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

llvm-svn: 328115

6 years ago[Fuchsia] Don't install libc++, libc++abi or libunwind on Darwin
Petr Hosek [Wed, 21 Mar 2018 16:48:26 +0000 (16:48 +0000)]
[Fuchsia] Don't install libc++, libc++abi or libunwind on Darwin

The Clang driver doesn't currently know how to use the libraries
that are shipped as part of the toolchain so there's no reason to
ship them at all.

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

llvm-svn: 328114

6 years ago[Hexagon] Eliminate subregisters from PHI nodes before pipelining
Krzysztof Parzyszek [Wed, 21 Mar 2018 16:39:11 +0000 (16:39 +0000)]
[Hexagon] Eliminate subregisters from PHI nodes before pipelining

The pipeliner needs to remove instructions from the SlotIndexes
structure when they are deleted. Otherwise, the SlotIndexes map
has stale data, and an assert will occur when adding new
instructions.

This patch also changes the pipeliner to make the back-edge of
a loop carried dependence 1 cycle. The 1 cycle latency is added
to the anti-dependence that represents the back-edge. This
changes eliminates a couple of hacks added to the pipeliner to
handle the latency of the back-edge. It is needed to correctly
pipeline the test case for the sub-register elimination pass.

llvm-svn: 328113

6 years ago[WebAssembly] Suppress unused function warning for register name matcher
Reid Kleckner [Wed, 21 Mar 2018 16:20:58 +0000 (16:20 +0000)]
[WebAssembly] Suppress unused function warning for register name matcher

llvm-svn: 328112

6 years ago[X86][Haswell] Merge multiple InstrRW entries that map to the same SchedWriteRes...
Simon Pilgrim [Wed, 21 Mar 2018 16:19:03 +0000 (16:19 +0000)]
[X86][Haswell] Merge multiple InstrRW entries that map to the same SchedWriteRes group (NFCI) (PR35955)

I've also merged some VEX/non-VEX instregex strings with a (V?) prefix or (Y?) ymm variant - there are still a lot more of these to do.

llvm-svn: 328111

6 years ago[X86][SandyBridge] Merge more VEX/non-VEX instregex patterns (NFCI) (PR35955)
Simon Pilgrim [Wed, 21 Mar 2018 16:05:58 +0000 (16:05 +0000)]
[X86][SandyBridge] Merge more VEX/non-VEX instregex patterns (NFCI) (PR35955)

llvm-svn: 328110

6 years ago[InstCombine] move/add tests for xor-of-icmps (PR36682); NFC
Sanjay Patel [Wed, 21 Mar 2018 15:54:48 +0000 (15:54 +0000)]
[InstCombine] move/add tests for xor-of-icmps (PR36682); NFC

llvm-svn: 328109

6 years ago[Fix] fix type deduction on ARM and MSVC
Jonas Toth [Wed, 21 Mar 2018 15:50:15 +0000 (15:50 +0000)]
[Fix] fix type deduction on ARM and MSVC

llvm-svn: 328108

6 years ago[clang-tidy] Resubmit hicpp-multiway-paths-covered without breaking test
Jonas Toth [Wed, 21 Mar 2018 15:34:15 +0000 (15:34 +0000)]
[clang-tidy] Resubmit hicpp-multiway-paths-covered without breaking test

The original check did break the green buildbot in the sanitizer build.
It took a while to redroduce and understand the issue.

There occured a stackoverflow while parsing the AST. The testcase with
256 case labels was the problem because each case label added another
stackframe. It seemed that the issue occured only in 'RelWithDebInfo' builds
and not in normal sanitizer builds.

To simplify the matchers the recognition for the different kinds of switch
statements has been moved into a seperate function and will not be done with
ASTMatchers. This is an attempt to reduce recursion and stacksize as well.

The new check removed this big testcase. Covering all possible values is still
implemented for bitfields and works there. The same logic on integer types
will lead to the issue.

Running it over LLVM gives the following results:

Differential: https://reviews.llvm.org/D40737
llvm-svn: 328107

6 years agoLast batch of test-tree cleaning changes
Pavel Labath [Wed, 21 Mar 2018 15:29:32 +0000 (15:29 +0000)]
Last batch of test-tree cleaning changes

- postmortem tests: make sure the core files are created in the build
  folder
- TestSourceManager: copy the .c file into the build dir before
  modifying it
- TestLogging: create log files in the build folder

After these changes I get a clean test run (on linux) even if I set the
source tree to be read only. It's possible some of the skipped/xfailed
tests are still creating files in the source tree, but at the moment, I
don't have plans to go hunting for those.

llvm-svn: 328106