platform/upstream/llvm.git
7 years agoFix valid-for-expr ellipses eaten as invalid decl
Hubert Tong [Sat, 20 May 2017 00:21:55 +0000 (00:21 +0000)]
Fix valid-for-expr ellipses eaten as invalid decl

Summary:
The trial parse for declarative syntax accepts an invalid pack
declaration syntax, which is ambiguous with valid pack expansions of
expressions. This commit removes the invalid pack declaration syntax to
avoid mistaking valid pack expansions as invalid declarator components.

Additionally, the trial parse of a //template-argument-list// then needs
to handle the optional ellipsis that is part of that grammar, as opposed
to relying on the trial parse for declarators accepting stray ellipses.

Reviewers: rsmith, rcraik, aaron.ballman

Reviewed By: rsmith

Subscribers: cfe-commits

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

llvm-svn: 303472

7 years agoCosmetic. Added braces to address gcc warning: suggest explicit braces to avoid ambig...
Galina Kistanova [Sat, 20 May 2017 00:02:08 +0000 (00:02 +0000)]
Cosmetic. Added braces to address gcc warning: suggest explicit braces to avoid ambiguous 'else' [-Wdangling-else].

llvm-svn: 303471

7 years agoRevert "Revert "ThinLTO: Verify bitcode before lauching the ThinLTOCodeGenerator.""
Adrian Prantl [Sat, 20 May 2017 00:00:08 +0000 (00:00 +0000)]
Revert "Revert "ThinLTO: Verify bitcode before lauching the ThinLTOCodeGenerator.""

This reapplies commit r303438 modified to not verify cross-imported
bitcode in FunctionImporter.

rdar://problem/31233625

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

llvm-svn: 303470

7 years agoRemove last (unnecessary) use of mapping from SourceLocation to Module and
Richard Smith [Fri, 19 May 2017 23:49:00 +0000 (23:49 +0000)]
Remove last (unnecessary) use of mapping from SourceLocation to Module and
remove the mechanism for doing so.

This mechanism was incorrect in the presence of preprocessed modules (and
#pragma clang module begin/end).

llvm-svn: 303469

7 years ago[modules] Simplify module macro handling in non-local-submodule-visibility mode.
Richard Smith [Fri, 19 May 2017 23:32:38 +0000 (23:32 +0000)]
[modules] Simplify module macro handling in non-local-submodule-visibility mode.

When reaching the end of a module, we used to convert its macros to
ModuleMacros but also leave them in the MacroDirective chain for the
identifier. This meant that every lookup of such a macro would find two
(identical) definitions. It also made it difficult to determine the correct
owner for a macro when reaching the end of a module: the most recent
MacroDirective in the chain could be from an #included submodule rather than
the current module.

Simplify this: whenever we convert a MacroDirective to a ModuleMacro when
leaving a module, clear out the MacroDirective chain for that identifier, and
just rely on the ModuleMacro to provide the macro definition information.

(We don't want to do this for local submodule visibility mode, because in that
mode we maintain a distinct MacroDirective chain for each submodule, and we
need to keep around the prior MacroDirective in case we re-enter the submodule
-- for instance, if its header is #included more than once in a module build,
we need the include guard directive to stick around. But the problem doesn't
arise in this case for the same reason: each submodule has its own
MacroDirective chain, so the macros don't leak out of submodules in the first
place.)

This reinstates r302932, reverted in r302947, with a fix for a bug that
resulted in us sometimes losing macro definitions due to failing to clear out
the overridden module macro list when promoting a directive to a module macro.

llvm-svn: 303468

7 years agoRevert "ThinLTO: Verify bitcode before lauching the ThinLTOCodeGenerator."
Adrian Prantl [Fri, 19 May 2017 23:32:21 +0000 (23:32 +0000)]
Revert "ThinLTO: Verify bitcode before lauching the ThinLTOCodeGenerator."

This reverts commit r303438 while deliberating buildbot breakage.

llvm-svn: 303467

7 years ago[test] Add support for Objective-C++ tests
Erik Pilkington [Fri, 19 May 2017 23:02:49 +0000 (23:02 +0000)]
[test] Add support for Objective-C++ tests

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

llvm-svn: 303466

7 years agoDon't override the SDKs and force the use of /System/Library/Frameworks to
Jason Molenda [Fri, 19 May 2017 23:00:42 +0000 (23:00 +0000)]
Don't override the SDKs and force the use of /System/Library/Frameworks to
find the python headers when buiding crashinfo.c
<rdar://problem/32288076>

llvm-svn: 303465

7 years ago[compiler-rt] Switch handle_<signal> flags from bool to enum.
Vitaly Buka [Fri, 19 May 2017 22:37:16 +0000 (22:37 +0000)]
[compiler-rt] Switch handle_<signal> flags from bool to enum.

Summary: We are going to make it tri-state and remove allow_user_segv_handler.

Reviewers: eugenis, alekseys, kcc

Subscribers: kubamracek, dberris, llvm-commits

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

llvm-svn: 303464

7 years agoCodeGenModule: Always output wchar_size, check LLVM assumptions.
Matthias Braun [Fri, 19 May 2017 22:37:15 +0000 (22:37 +0000)]
CodeGenModule: Always output wchar_size, check LLVM assumptions.

llvm::TargetLibraryInfo needs to know the size of wchar_t to work on
functions like `wcslen`. This patch changes clang to always emit the
wchar_size module flag (it would only do so for ARM previously).
This also adds an `assert()` to ensure the LLVM defaults based on the
target triple are in sync with clang.

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

llvm-svn: 303463

7 years ago[compiler-rt] Add negative test for boolean flags.
Vitaly Buka [Fri, 19 May 2017 22:37:13 +0000 (22:37 +0000)]
[compiler-rt] Add negative test for boolean flags.

Reviewers: eugenis, alekseyshl

Subscribers: kubamracek, dberris, llvm-commits

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

llvm-svn: 303462

7 years agoSimplifyLibCalls: Optimize wcslen
Matthias Braun [Fri, 19 May 2017 22:37:09 +0000 (22:37 +0000)]
SimplifyLibCalls: Optimize wcslen

Refactor the strlen optimization code to work for both strlen and wcslen.

This especially helps with programs in the wild where people pass
L"string"s to const std::wstring& function parameters and the wstring
constructor gets inlined.

This also fixes a lingerind API problem/bug in getConstantStringInfo()
where zeroinitializers would always give you an empty string (without a
length) back regardless of the actual length of the initializer which
did not work well in the TrimAtNul==false causing the PR mentioned
below.

Note that the fixed getConstantStringInfo() needed fixes to SelectionDAG
memcpy lowering and may lead to some cases for out-of-bounds
zeroinitializer accesses not getting optimized anymore. So some code
with UB may produce out of bound memory reads now instead of just
producing zeros.

The refactoring "accidentally" fixes http://llvm.org/PR32124

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

llvm-svn: 303461

7 years agoVerifier: Check wchar_size module flag.
Matthias Braun [Fri, 19 May 2017 22:37:01 +0000 (22:37 +0000)]
Verifier: Check wchar_size module flag.

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

llvm-svn: 303460

7 years ago[ODRHash] Revert r303450 to fix buildbot
Richard Trieu [Fri, 19 May 2017 22:35:41 +0000 (22:35 +0000)]
[ODRHash] Revert r303450 to fix buildbot

r303450
[ODRHash] Support TemplateName and TemplateArgument

llvm-svn: 303459

7 years agoFix off-by-one bug in AttributeList::addAttributes index handling
Reid Kleckner [Fri, 19 May 2017 22:23:47 +0000 (22:23 +0000)]
Fix off-by-one bug in AttributeList::addAttributes index handling

getParamAlignment expects an argument number, not an AttributeList
index.

Johan Englan, who works on LDC, found this bug and told me about it off
list.

llvm-svn: 303458

7 years agoAdded LLVM_FALLTHROUGH to address gcc warning: this statement may fall through.
Galina Kistanova [Fri, 19 May 2017 21:08:28 +0000 (21:08 +0000)]
Added LLVM_FALLTHROUGH to address gcc warning: this statement may fall through.

llvm-svn: 303457

7 years ago[safestack] Disable stack coloring by default.
Evgeniy Stepanov [Fri, 19 May 2017 20:58:48 +0000 (20:58 +0000)]
[safestack] Disable stack coloring by default.

Workaround for apparent miscompilation of PR32143.

llvm-svn: 303456

7 years agoAdded missing break.
Galina Kistanova [Fri, 19 May 2017 20:31:51 +0000 (20:31 +0000)]
Added missing break.

llvm-svn: 303454

7 years agoNewGVN: Fix PR32838.
Daniel Berlin [Fri, 19 May 2017 20:22:20 +0000 (20:22 +0000)]
NewGVN: Fix PR32838.
This is a complicated bug involving two issues:
1. What do we do with phi nodes when we prove all arguments are not
live?
2. When is it safe to use value leaders to determine if we can ignore
an argumnet?

llvm-svn: 303453

7 years agoNewGVN: Print out the StoredValue of a StoreExpression
Daniel Berlin [Fri, 19 May 2017 20:22:14 +0000 (20:22 +0000)]
NewGVN: Print out the StoredValue of a StoreExpression

llvm-svn: 303452

7 years agoDo not issue -Wnullability-completeness for dependent types that are not written...
Richard Smith [Fri, 19 May 2017 20:20:13 +0000 (20:20 +0000)]
Do not issue -Wnullability-completeness for dependent types that are not written as pointer types.

llvm-svn: 303451

7 years ago[ODRHash] Support TemplateName and TemplateArgument
Richard Trieu [Fri, 19 May 2017 20:05:16 +0000 (20:05 +0000)]
[ODRHash] Support TemplateName and TemplateArgument

llvm-svn: 303450

7 years agoFix line-endings.
Simon Pilgrim [Fri, 19 May 2017 19:47:29 +0000 (19:47 +0000)]
Fix line-endings.

llvm-svn: 303448

7 years ago[InstCombine] *Actually* commit the test showing the miscompile.
Davide Italiano [Fri, 19 May 2017 19:41:11 +0000 (19:41 +0000)]
[InstCombine] *Actually* commit the test showing the miscompile.

Clarify a comment while I'm here.

llvm-svn: 303447

7 years agoResubmit "[CodeView] Provide a common interface for type collections."
Zachary Turner [Fri, 19 May 2017 19:26:58 +0000 (19:26 +0000)]
Resubmit "[CodeView] Provide a common interface for type collections."

This was originally reverted because it was a breaking a bunch
of bots and the breakage was not surfacing on Windows.  After much
head-scratching this was ultimately traced back to a bug in the
lit test runner related to its pipe handling.  Now that the bug
in lit is fixed, Windows correctly reports these test failures,
and as such I have finally (hopefully) fixed all of them in this
patch.

llvm-svn: 303446

7 years ago[InstCombine] Add tests to demonstrate the miscompile in PR33078.
Davide Italiano [Fri, 19 May 2017 19:23:24 +0000 (19:23 +0000)]
[InstCombine] Add tests to demonstrate the miscompile in PR33078.

llvm-svn: 303445

7 years agoLast of the major pieces to NewGVN - yay!
Daniel Berlin [Fri, 19 May 2017 19:01:27 +0000 (19:01 +0000)]
Last of the major pieces to NewGVN - yay!

Summary:
NewGVN: Handle equivalence between phi of ops and op of phis.

This makes our GVN mostly-complete. It would be complete, modulo some
deliberate choices we make.  This means it detects roughly all herband
equivalences in polynomial time, including cases notoriously hard for
other GVN's to detect.  It also detects a very large swath of the
cases we currently rely on instcombine to detect that involve folding
upwards through phis.

Fixes PR 31125, 31463, PR 31868

Reviewers: davide

Subscribers: Prazek, llvm-commits

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

llvm-svn: 303444

7 years agoNewGVN: Get rid of most dominating leader check
Daniel Berlin [Fri, 19 May 2017 19:01:24 +0000 (19:01 +0000)]
NewGVN: Get rid of most dominating leader check

llvm-svn: 303443

7 years agoBasicAA: Uninserted instructions have no parent, and notDifferentParent explicitly...
Daniel Berlin [Fri, 19 May 2017 19:01:21 +0000 (19:01 +0000)]
BasicAA: Uninserted instructions have no parent, and notDifferentParent explicitly allows for this case, but getParent crashes when handed one.

llvm-svn: 303442

7 years ago[DAGCombine] (addcarry 0, 0, X) -> (ext/trunc X)
Amaury Sechet [Fri, 19 May 2017 18:20:44 +0000 (18:20 +0000)]
[DAGCombine] (addcarry 0, 0, X) -> (ext/trunc X)

Summary:
While this makes some case better and some case worse - so it's unclear if it is a worthy combine just by itself - this is a useful canonicalisation.

As per discussion in D32756 .

Reviewers: jyknight, nemanjai, mkuper, spatel, RKSimon, zvi, bkramer

Subscribers: llvm-commits

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

llvm-svn: 303441

7 years ago[lit] Take the last error when executing pipelines.
Zachary Turner [Fri, 19 May 2017 18:12:07 +0000 (18:12 +0000)]
[lit] Take the last error when executing pipelines.

This seems to have been present since the beginning of time,
which is quite surprising.  The symptom was this: Suppose you
have a test with a run line that looks like this:

  RUN: foo | FileCheck %s

foo prints some output and then due to a bug in the program it
asserts.  On Windows this results in the program returning a
negative exit code.  But if enough output had been printed
already by the tool so that the FileCheck match would succeed
then FileCheck would return 0, and because of bad logic in
lit this 0 return value would overwrite the failed return
value from previous items in the pipeline.  This only happened
with negative exit codes.

The most sensible behavior is to just take whatever the first
exit code is.  There is no logical ordering defined on exit
codes, so comparing with < and > does not make a lot of sense.
Instead, as soon as we find the first non-successful return
value, that should be the result of the entire expression.

This fixes the issue, as now tests which fail on non-Windows
platforms also fail for me on Windows as well.

llvm-svn: 303440

7 years ago[NFC][loopIdiom] Clang format change rL303434
Anna Thomas [Fri, 19 May 2017 18:00:30 +0000 (18:00 +0000)]
[NFC][loopIdiom] Clang format change rL303434

llvm-svn: 303439

7 years agoThinLTO: Verify bitcode before lauching the ThinLTOCodeGenerator.
Adrian Prantl [Fri, 19 May 2017 17:55:02 +0000 (17:55 +0000)]
ThinLTO: Verify bitcode before lauching the ThinLTOCodeGenerator.

rdar://problem/31233625

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

llvm-svn: 303438

7 years agoRewrite llvm-lto's codegen() using ThinCodeGenerator::run(). NFC-ish.
Adrian Prantl [Fri, 19 May 2017 17:54:58 +0000 (17:54 +0000)]
Rewrite llvm-lto's codegen() using ThinCodeGenerator::run(). NFC-ish.

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

llvm-svn: 303437

7 years agoFix typo in test
Matthias Braun [Fri, 19 May 2017 17:25:20 +0000 (17:25 +0000)]
Fix typo in test

llvm-svn: 303436

7 years ago[X86][FMA] Tests showing missed fmsubadd opportunities (PR30633)
Simon Pilgrim [Fri, 19 May 2017 17:19:26 +0000 (17:19 +0000)]
[X86][FMA] Tests showing missed fmsubadd opportunities (PR30633)

llvm-svn: 303435

7 years ago[LoopIdiom] Refactor return value of isLegalStore [NFC]
Anna Thomas [Fri, 19 May 2017 17:05:36 +0000 (17:05 +0000)]
[LoopIdiom] Refactor return value of isLegalStore [NFC]

Summary:

This NFC simply refactors the return value of LoopIdiomRecognize::isLegalStore() from bool to an enumeration, and
removes the return-through-parameter mechanism that the function was using. This function is constructed such that it will
only ever recognize a single store idiom (memset, memset_pattern, or memcpy), and never a combination of these. As such it
makes much more sense for the return value to be the single idiom that the store matches, rather than
having a separate argument-return for each idiom -- it's cleaner, and makes it clearer that
only a single idiom can be matched.

Patch by Daniel Neilson!

Reviewers: anna, sanjoy, davide, haicheng

Reviewed By: anna, haicheng

Subscribers: haicheng, mzolotukhin, llvm-commits

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

llvm-svn: 303434

7 years ago[InstSimplify] Fix 80 column violation. NFC
Craig Topper [Fri, 19 May 2017 16:56:53 +0000 (16:56 +0000)]
[InstSimplify] Fix 80 column violation. NFC

llvm-svn: 303433

7 years ago[modules] Further delay calling DeclMustBeEmitted until it's safe.
Vassil Vassilev [Fri, 19 May 2017 16:46:06 +0000 (16:46 +0000)]
[modules] Further delay calling DeclMustBeEmitted until it's safe.

As discussed in D30793, we have some unsafe calls to isConsumerInterestedIn().
This patch implements Richard's suggestion (from the inline comment) that we
should track if we just deserialized an declaration. If we just deserialized,
we can skip the unsafe call because we know it's interesting. If we didn't just
deserialize the declaration, calling isConsumerInterestedIn() should be safe.

We tried to create a test case for this but we were not successful.

Patch by Raphael Isemann (D32499)!

llvm-svn: 303432

7 years ago[APInt] Add support for dividing or remainder by a uint64_t or int64_t.
Craig Topper [Fri, 19 May 2017 16:43:54 +0000 (16:43 +0000)]
[APInt] Add support for dividing or remainder by a uint64_t or int64_t.

Summary:
This patch adds udiv/sdiv/urem/srem/udivrem/sdivrem methods that can divide by a uint64_t. This makes division consistent with all the other arithmetic operations.

This modifies the interface of the divide helper method to work on raw arrays instead of APInts. This way we can pass the uint64_t in for the RHS without wrapping it in an APInt. This required moving all the Quotient and Remainder allocation handling up to the callers. For udiv/urem this was as simple as just creating the Quotient/Remainder with the right size when they were declared. For udivrem we have to rely on reallocate not changing the contents of the variable LHS or RHS is aliased with the Quotient or Remainder APInts. We also have to zero the upper bits of Remainder and Quotient that divide doesn't write to if lhsWords/rhsWords is smaller than the width.

I've update the toString method to use the new udivrem.

Reviewers: hans, dblaikie, RKSimon

Reviewed By: RKSimon

Subscribers: llvm-commits

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

llvm-svn: 303431

7 years ago[Fortran Support] Materialize outermost dimension for Fortran array.
Siddharth Bhat [Fri, 19 May 2017 15:07:45 +0000 (15:07 +0000)]
[Fortran Support] Materialize outermost dimension for Fortran array.

- We use the outermost dimension of arrays since we need this
information to generate GPU transfers.

- In general, if we do not know the outermost dimension of the array
(because the indexing expression is non-affine, for example) then we
simply cannot generate transfer code.

- However, for Fortran arrays, we can use the Fortran array
representation which stores the dimensions of all arrays.

- This patch uses the Fortran array representation to generate code that
computes the outermost dimension size.

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

llvm-svn: 303429

7 years ago[AMDGPU][MC] Corrected disassembler to decode instructions with 2 literals
Dmitry Preobrazhensky [Fri, 19 May 2017 14:27:52 +0000 (14:27 +0000)]
[AMDGPU][MC] Corrected disassembler to decode instructions with 2 literals

See bug 32922: https://bugs.llvm.org//show_bug.cgi?id=32922

Reviewers: artem.tamazov, vpykhtin

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

llvm-svn: 303428

7 years ago[LoopPredication] NFC. Extract LoopICmp struct and parseLoopICmp helper
Artur Pilipenko [Fri, 19 May 2017 14:02:46 +0000 (14:02 +0000)]
[LoopPredication] NFC. Extract LoopICmp struct and parseLoopICmp helper

llvm-svn: 303427

7 years ago[LoopPredication] NFC. Extract LoopPredication::expandCheck helper
Artur Pilipenko [Fri, 19 May 2017 14:00:58 +0000 (14:00 +0000)]
[LoopPredication] NFC. Extract LoopPredication::expandCheck helper

llvm-svn: 303426

7 years ago[LoopPredication] NFC. Extract CanExpand helper lambda
Artur Pilipenko [Fri, 19 May 2017 14:00:04 +0000 (14:00 +0000)]
[LoopPredication] NFC. Extract CanExpand helper lambda

llvm-svn: 303425

7 years ago[LoopPredication] NFC. Add an early exit if there is no guards in the loop
Artur Pilipenko [Fri, 19 May 2017 13:59:34 +0000 (13:59 +0000)]
[LoopPredication] NFC. Add an early exit if there is no guards in the loop

llvm-svn: 303424

7 years ago[AMDGPU][MC] Fixed bugs in export instruction
Dmitry Preobrazhensky [Fri, 19 May 2017 13:36:09 +0000 (13:36 +0000)]
[AMDGPU][MC] Fixed bugs in export instruction

See Bugs 33019, 33056:
  https://bugs.llvm.org//show_bug.cgi?id=33019
  https://bugs.llvm.org//show_bug.cgi?id=33056

Reviewers: artem.tamazov, vpykhtin

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

llvm-svn: 303423

7 years agoUse write instead of read permissions to check for global sections on mac
Francis Ricci [Fri, 19 May 2017 13:34:02 +0000 (13:34 +0000)]
Use write instead of read permissions to check for global sections on mac

Summary:
The LINKEDIT section is very large and is read-only. Scanning this
section caused LSan on darwin to be very slow. When only writable sections
are scanned for global pointers, performance improved by a factor of about 25x.

Reviewers: alekseyshl, kubamracek

Subscribers: llvm-commits

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

llvm-svn: 303422

7 years ago[X86][AVX512] Make i1 illegal in the CodeGen
Guy Blank [Fri, 19 May 2017 12:35:15 +0000 (12:35 +0000)]
[X86][AVX512] Make i1 illegal in the CodeGen

This patch defines the i1 type as illegal in the X86 backend for AVX512.
For DAG operations on <N x i1> types (build vector, extract vector element, ...) i8 is used, and should be truncated/extended.
This should produce better scalar code for i1 types since GPRs will be used instead of mask registers.

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

llvm-svn: 303421

7 years ago[ScopDetection] Allow detection of full functions
Tobias Grosser [Fri, 19 May 2017 12:13:02 +0000 (12:13 +0000)]
[ScopDetection] Allow detection of full functions

This is useful when only analyzing functions.

llvm-svn: 303420

7 years agoRestore and update documentation comment for EmitPointerWithAlignment
Krzysztof Parzyszek [Fri, 19 May 2017 12:03:34 +0000 (12:03 +0000)]
Restore and update documentation comment for EmitPointerWithAlignment

llvm-svn: 303419

7 years ago[globalisel][tablegen] Demote OptForSize/OptForMinSize/ForCodeSize to per-function...
Daniel Sanders [Fri, 19 May 2017 11:08:33 +0000 (11:08 +0000)]
[globalisel][tablegen] Demote OptForSize/OptForMinSize/ForCodeSize to per-function predicates.

Summary:
This causes them to be re-computed more often than necessary but resolves
objections that were raised post-commit on r301750.

Reviewers: qcolombet, ab, t.p.northover, rovka, kristof.beyls

Reviewed By: qcolombet

Subscribers: igorb, llvm-commits

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

llvm-svn: 303418

7 years agoFix vector pass-through value being unused in IRBuilder::CreateMaskedGather
Amara Emerson [Fri, 19 May 2017 10:40:18 +0000 (10:40 +0000)]
Fix vector pass-through value being unused in IRBuilder::CreateMaskedGather

Also s/0/nullptr in the call site in LV.

llvm-svn: 303416

7 years ago[clang-format] Handle trailing comment sections in import statement lines
Krasimir Georgiev [Fri, 19 May 2017 10:34:57 +0000 (10:34 +0000)]
[clang-format] Handle trailing comment sections in import statement lines

Summary:
This patch updates the handling of multiline trailing comment sections in
import statement lines to make it more consistent with the case in general.
This includes updating the parsing logic to collect the trailing comment
sections and the formatting logic to not insert escaped newlines at the end of
comment lines in import statement lines.

Specifically, before this patch this code:
```
#include <a> // line 1
             // line 2
```
will be turned into two unwrapped lines, whereas this code:
```
int i; // line 1
       // line 2
```
is turned into a single unwrapped line, enabling reflowing across comments.

An example where the old behaviour is bad is when partially formatting the lines
3 to 4 of this code:
```
#include <a> // line 1
             // line 2

int i;
```
which gets turned into:
```
#include <a> // line 1
             // line 2

             int i;
```
because the two comment lines were independent and the indent was copied.

Reviewers: djasper

Reviewed By: djasper

Subscribers: cfe-commits, klimek

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

llvm-svn: 303415

7 years agoCodeGenFunction::EmitPointerWithAlignment(): Prune a \param in r303358, possibly...
NAKAMURA Takumi [Fri, 19 May 2017 10:19:59 +0000 (10:19 +0000)]
CodeGenFunction::EmitPointerWithAlignment(): Prune a \param in r303358, possibly obsolete. [-Wdocumentation]

llvm-svn: 303414

7 years ago[GlobalISel] IRTranslator: Translate ConstantStruct
Volkan Keles [Fri, 19 May 2017 09:47:02 +0000 (09:47 +0000)]
[GlobalISel] IRTranslator: Translate ConstantStruct

Reviewers: qcolombet, ab, t.p.northover, aditya_nandakumar, dsanders

Reviewed By: qcolombet

Subscribers: rovka, kristof.beyls, javed.absar, igorb, llvm-commits

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

llvm-svn: 303412

7 years ago[APInt] Use b.negate() in place of b = -std::move(b). NFCI
Craig Topper [Fri, 19 May 2017 07:37:25 +0000 (07:37 +0000)]
[APInt] Use b.negate() in place of b = -std::move(b). NFCI

llvm-svn: 303411

7 years agoFix compilation failure.
Zachary Turner [Fri, 19 May 2017 06:25:09 +0000 (06:25 +0000)]
Fix compilation failure.

llvm-svn: 303410

7 years agoRevert "[CodeView] Provide a common interface for type collections."
Zachary Turner [Fri, 19 May 2017 05:57:45 +0000 (05:57 +0000)]
Revert "[CodeView] Provide a common interface for type collections."

This is a squash of ~5 reverts of, well, pretty much everything
I did today.  Something is seriously broken with lit on Windows
right now, and as a result assertions that fire in tests are
triggering failures.  I've been breaking non-Windows bots all
day which has seriously confused me because all my tests have
been passing, and after running lit with -a to view the output
even on successful runs, I find out that the tool is crashing
and yet lit is still reporting it as a success!

At this point I don't even know where to start, so rather than
leave the tree broken for who knows how long, I will get this
back to green, and then once lit is fixed on Windows, hopefully
hopefully fix the remaining set of problems for real.

llvm-svn: 303409

7 years agoDon't crash if someone tries to visit an empty type stream.
Zachary Turner [Fri, 19 May 2017 05:18:09 +0000 (05:18 +0000)]
Don't crash if someone tries to visit an empty type stream.

llvm-svn: 303408

7 years ago[CodeView] Reduce memory usage in TypeSerializer.
Zachary Turner [Fri, 19 May 2017 04:56:48 +0000 (04:56 +0000)]
[CodeView] Reduce memory usage in TypeSerializer.

We were using a BumpPtrAllocator to allocate stable storage for
a record, then trying to insert that into a hash table.  If a
collision occurred, the bytes were never inserted and the
allocation was unnecessary.  At the cost of an extra hash
computation, check first if it exists, and only if it does do
we allocate and insert.

llvm-svn: 303407

7 years ago[NewGVN] Delete the old store when we find congruent to a load.
Davide Italiano [Fri, 19 May 2017 04:06:10 +0000 (04:06 +0000)]
[NewGVN] Delete the old store when we find congruent to a load.

(or non-store, more in general). Fixes PR33086. Caught by the
store verifier.

llvm-svn: 303406

7 years ago[ScopInfo] Fix typo in documentation
Tobias Grosser [Fri, 19 May 2017 04:01:52 +0000 (04:01 +0000)]
[ScopInfo] Fix typo in documentation

llvm-svn: 303405

7 years ago[ScopInfo] Gracefully handle long compile times
Tobias Grosser [Fri, 19 May 2017 03:45:00 +0000 (03:45 +0000)]
[ScopInfo] Gracefully handle long compile times

The following test case tried to compute the lexicographic minimum of the
following set during alias analysis, which caused very long compile time:

[p_0, p_1, p_2, p_3, p_4, p_5] -> { MemRef0[i0] : (517p_3 >= 70944 - 298p_2 and
256i0 >= -71199 + 298p_2 + 517p_3 and 256i0 <= -70944 + 298p_2 + 517p_3) or
(409p_4 >= 57120 - 298p_2 and 256i0 >= -57375 + 298p_2 + 409p_4 and 256i0 <=
-57120 + 298p_2 + 409p_4) or (104p_4 >= 17329 + 149p_2 - 50p_3 and 128i0 >=
17328 + 149p_2 - 50p_3 - 104p_4 and 128i0 <= 17455 + 149p_2 - 50p_3 - 104p_4) or
(104p_4 <= 17328 + 149p_2 - 50p_3 and 128i0 >= 17201 + 149p_2 - 50p_3 - 104p_4
and 128i0 <= 17328 + 149p_2 - 50p_3 - 104p_4) or (409p_4 <= 57119 - 298p_2 and
256i0 >= -57120 + 298p_2 + 409p_4 and 256i0 <= -56865 + 298p_2 + 409p_4) or
(517p_3 <= 70943 - 298p_2 and 256i0 >= -70944 + 298p_2 + 517p_3 and 256i0 <=
-70689 + 298p_2 + 517p_3) or (p_1 >= 2 + 2p_0 and 298p_5 >= 70944 - 517p_3 and
256i0 >= -71199 + 517p_3 + 298p_5 and 256i0 <= -70944 + 517p_3 + 298p_5) or (p_1
>= 2 + 2p_0 and 298p_5 >= 57120 - 409p_4 and 256i0 >= -57375 + 409p_4 + 298p_5
>and 256i0 <= -57120 + 409p_4 + 298p_5) or (p_1 >= 2 + 2p_0 and 149p_5 <= -17329
>+ 50p_3 + 104p_4 and 128i0 >= 17328 - 50p_3 - 104p_4 + 149p_5 and 128i0 <=
>17455 - 50p_3 - 104p_4 + 149p_5) or (p_1 >= 2 + 2p_0 and 149p_5 >= -17328 +
>50p_3 + 104p_4 and 128i0 >= 17201 - 50p_3 - 104p_4 + 149p_5 and 128i0 <= 17328
>- 50p_3 - 104p_4 + 149p_5) or (p_1 >= 2 + 2p_0 and 298p_5 <= 57119 - 409p_4 and
>256i0 >= -57120 + 409p_4 + 298p_5 and 256i0 <= -56865 + 409p_4 + 298p_5) or
>(p_1 >= 2 + 2p_0 and 298p_5 <= 70943 - 517p_3 and 256i0 >= -70944 + 517p_3 +
>298p_5 and 256i0 <= -70689 + 517p_3 + 298p_5) }

We now guard the potentially expensive functions in Polly's scop analysis to
gracefully bail out in case of overly long compilation times.

llvm-svn: 303404

7 years agoFix a broken test.
Zachary Turner [Fri, 19 May 2017 03:04:08 +0000 (03:04 +0000)]
Fix a broken test.

Similar to my previous fix, it turns out llvm-pdbdump has been
printing an incorrect value since the beginning of time, but
we didn't know it was incorrect.  Specifically, we were interpreting
a TypeIndex as referencing a type from the TPI stream when it
actually should come from the IPI stream.  So we were printing a
string that looked like a valid string, but was just from the
wrong place.

llvm-svn: 303403

7 years agoRevert "[ADT] Fix some Clang-tidy modernize-use-using warnings; other minor fixes...
Adam Nemet [Fri, 19 May 2017 02:56:37 +0000 (02:56 +0000)]
Revert "[ADT] Fix some Clang-tidy modernize-use-using warnings; other minor fixes (NFC)."

This reverts commit r303383.

This breaks the modules-enabled macOS build with:

lib/Support/LockFileManager.cpp:86:7: error: declaration of 'gethostuuid' must be imported from module 'Darwin.POSIX.unistd' before it is required

llvm-svn: 303402

7 years agoWhen a type-id is unexpectedly given a name, assume that the name is unrelated
Richard Smith [Fri, 19 May 2017 01:54:59 +0000 (01:54 +0000)]
When a type-id is unexpectedly given a name, assume that the name is unrelated
syntax unless we have a reason to think otherwise.

This improves error recovery in a couple of cases.

llvm-svn: 303398

7 years agoFix crasher in CodeView test.
Zachary Turner [Fri, 19 May 2017 00:56:39 +0000 (00:56 +0000)]
Fix crasher in CodeView test.

Apparently this was always broken, but previously we were more
graceful about it and we would print "unknown udt" if we couldn't
find the type index, whereas now we just segfault because we
assume it's valid.  But this exposed a real bug, which is that
we weren't looking in the right place.  So fix that, and also
fix this crash at the same time.

llvm-svn: 303397

7 years agoLiveIntervalAnalysis: Fix missing case in pruneSubRegValues()
Matthias Braun [Fri, 19 May 2017 00:18:03 +0000 (00:18 +0000)]
LiveIntervalAnalysis: Fix missing case in pruneSubRegValues()

pruneSubRegValues() needs to remove subregister ranges starting at
instructions that later get removed by eraseInstrs(). It missed to check
one case in which eraseInstrs() would remove an instruction.

Fixes http://llvm.org/PR32688

llvm-svn: 303396

7 years agoFix typo
Matthias Braun [Fri, 19 May 2017 00:17:59 +0000 (00:17 +0000)]
Fix typo

llvm-svn: 303395

7 years agoFix another warning.
Zachary Turner [Thu, 18 May 2017 23:30:51 +0000 (23:30 +0000)]
Fix another warning.

llvm-svn: 303394

7 years ago[NewGVN] Break infinite recursion in singleReachablePHIPath().
Davide Italiano [Thu, 18 May 2017 23:22:44 +0000 (23:22 +0000)]
[NewGVN] Break infinite recursion in singleReachablePHIPath().

We can have cycles between PHIs and this causes singleReachablePhi()
to call itself indefintely (until we run out of stack). The proper
solution would be that of computing SCCs, but it's not worth for
now, so just keep a visited set and give up when we find a cycle.
Thanks to Dan for the discussion/help with this.

Fixes PR33014.

llvm-svn: 303393

7 years ago[compiler-rt] Replace ifs with switch statement in IsHandledDeadlySignal
Vitaly Buka [Thu, 18 May 2017 23:13:22 +0000 (23:13 +0000)]
[compiler-rt] Replace ifs with switch statement in IsHandledDeadlySignal

Reviewers: eugenis

Subscribers: kubamracek, llvm-commits, dberris

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

llvm-svn: 303392

7 years agoFix some build errors and warnings.
Zachary Turner [Thu, 18 May 2017 23:12:42 +0000 (23:12 +0000)]
Fix some build errors and warnings.

llvm-svn: 303391

7 years ago[CodeView] Raise the source to ID map out of the TypeStreamMerger.
Zachary Turner [Thu, 18 May 2017 23:04:08 +0000 (23:04 +0000)]
[CodeView] Raise the source to ID map out of the TypeStreamMerger.

This map will be needed to rewrite symbol streams after re-writing
the corresponding type streams.

llvm-svn: 303390

7 years ago[llvm-pdbdump] Add the ability to merge PDBs.
Zachary Turner [Thu, 18 May 2017 23:03:41 +0000 (23:03 +0000)]
[llvm-pdbdump] Add the ability to merge PDBs.

Merging PDBs is a feature that will be used heavily by
the linker.  The functionality already exists but does not
have deep test coverage because it's not easily exposed through
any tools.  This patch aims to address that by adding the
ability to merge PDBs via llvm-pdbdump.  It takes arbitrarily
many PDBs and outputs a single PDB.

Using this new functionality, a test is added for merging
type records.  Future patches will add the ability to merge
symbol records, module information, etc.

llvm-svn: 303389

7 years ago[CodeView] Provide a common interface for type collections.
Zachary Turner [Thu, 18 May 2017 23:03:06 +0000 (23:03 +0000)]
[CodeView] Provide a common interface for type collections.

Right now we have multiple notions of things that represent collections of
types. Most commonly used are TypeDatabase, which is supposed to keep
mappings from TypeIndex to type name when reading a type stream, which
happens when reading PDBs. And also TypeTableBuilder, which is used to
build up a collection of types dynamically which we will later serialize
(i.e. when writing PDBs).

But often you just want to do some operation on a collection of types, and
you may want to do the same operation on any kind of collection. For
example, you might want to merge two TypeTableBuilders or you might want
to merge two type streams that you loaded from various files.

This dichotomy between reading and writing is responsible for a lot of the
existing code duplication and overlapping responsibilities in the existing
CodeView library classes. For example, after building up a
TypeTableBuilder with a bunch of type records, if we want to dump it we
have to re-invent a bunch of extra glue because our dumper takes a
TypeDatabase or a CVTypeArray, which are both incompatible with
TypeTableBuilder.

This patch introduces an abstract base class called TypeCollection which
is shared between the various type collection like things. Wherever we
previously stored a TypeDatabase& in some common class, we now store a
TypeCollection&.

The advantage of this is that all the details of how the collection are
implemented, such as lazy deserialization of partial type streams, is
completely transparent and you can just treat any collection of types the
same regardless of where it came from.

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

llvm-svn: 303388

7 years ago[InstCombine] add more tests for xor-of-icmps; NFC
Sanjay Patel [Thu, 18 May 2017 22:47:57 +0000 (22:47 +0000)]
[InstCombine] add more tests for xor-of-icmps; NFC

llvm-svn: 303387

7 years ago[ScopInfo] Fix r302231 to use logical or (||). NFC.
Michael Kruse [Thu, 18 May 2017 21:55:36 +0000 (21:55 +0000)]
[ScopInfo] Fix r302231 to use logical or (||). NFC.

In r302231 we mistakenly use bitwise or (|) instead of logical
or (||). This patch fixes that.

Contributed-by: Sameer AbuAsal <sabuasal@codeaurora.org>
Differential Revision: https://reviews.llvm.org/D33337

llvm-svn: 303386

7 years ago[NewGVN] Replace predicate info leftovers.
Davide Italiano [Thu, 18 May 2017 21:43:23 +0000 (21:43 +0000)]
[NewGVN] Replace predicate info leftovers.

This time with an additional fix, i.e. we remove the dead
@llvm.ssa.copy instruction.

llvm-svn: 303385

7 years agoUse linker script commands in writeMapFile.
Rafael Espindola [Thu, 18 May 2017 21:30:14 +0000 (21:30 +0000)]
Use linker script commands in writeMapFile.

This converts the last (chronologically) user of OutputSections to use
the linker script commands instead.

The idea is to convert all uses after fabricateDefaultCommands, so
that we have a single representation.

llvm-svn: 303384

7 years ago[ADT] Fix some Clang-tidy modernize-use-using warnings; other minor fixes (NFC).
Eugene Zelenko [Thu, 18 May 2017 21:27:11 +0000 (21:27 +0000)]
[ADT] Fix some Clang-tidy modernize-use-using warnings; other minor fixes (NFC).

llvm-svn: 303383

7 years agoclang-format: [JS] for await, and fix a crash with for loops.
Martin Probst [Thu, 18 May 2017 21:19:29 +0000 (21:19 +0000)]
clang-format: [JS] for await, and fix a crash with for loops.

Summary:
The syntax is actually `for await (const x of y)` (d'oh).
This also fixes a crash for `for` tokens not followed by additional tokens.

Reviewers: djasper

Subscribers: cfe-commits, klimek

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

llvm-svn: 303382

7 years ago[InstCombine] add helper to foldXorOfICmps(); NFCI
Sanjay Patel [Thu, 18 May 2017 20:53:16 +0000 (20:53 +0000)]
[InstCombine] add helper to foldXorOfICmps(); NFCI

Also, fix the old-style capitalization of the related functions
and move them to the 'private' section of the class since they
are just helpers of the visit* functions.

As shown in the post-commit comments for D32143, we are missing
folds for xor-of-icmps.

llvm-svn: 303381

7 years ago[scudo] lower quarantine default sizes
Kostya Kortchinsky [Thu, 18 May 2017 20:47:35 +0000 (20:47 +0000)]
[scudo] lower quarantine default sizes

Summary:
After discussing the current defaults with a couple of parties, the consensus
is that they are too high. 1Mb of quarantine has about a 4Mb impact on PSS, so
memory usage goes up quickly.
This is obviously configurable, but the default value should be more
"approachable", so both the global size and the thread local size are 1/4 of
what they used to be.

Reviewers: alekseyshl, kcc

Reviewed By: alekseyshl

Subscribers: llvm-commits

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

llvm-svn: 303380

7 years ago[InstSimplify] Make m_Not work for xor -1, X
Craig Topper [Thu, 18 May 2017 20:27:32 +0000 (20:27 +0000)]
[InstSimplify] Make m_Not work for xor -1, X

Currently m_Not only works the canonical xor X, -1 form that InstCombine produces. InstSimplify can't rely on this canonicalization.

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

llvm-svn: 303379

7 years agoSet IMAGE_DLL_CHARACTERISTICS_NO_BIND.
Rui Ueyama [Thu, 18 May 2017 20:26:58 +0000 (20:26 +0000)]
Set IMAGE_DLL_CHARACTERISTICS_NO_BIND.

Our output is not compatible with the Binding feature, so make it
explicit that.

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

llvm-svn: 303378

7 years agoRevert r303375 "LLVM_FALLTHROUGH instead of fall-through comment."
Rui Ueyama [Thu, 18 May 2017 20:18:24 +0000 (20:18 +0000)]
Revert r303375 "LLVM_FALLTHROUGH instead of fall-through comment."

This reverts commit r303375 since it didn't compile.

llvm-svn: 303377

7 years ago[clangd] Make formatting.test asynchronous again.
Benjamin Kramer [Thu, 18 May 2017 20:10:04 +0000 (20:10 +0000)]
[clangd] Make formatting.test asynchronous again.

This test doesn't rely on the order of asynchronous messages, enable
threads so we have at least some coverage for those code paths.

llvm-svn: 303376

7 years agoLLVM_FALLTHROUGH instead of fall-through comment.
Galina Kistanova [Thu, 18 May 2017 20:01:52 +0000 (20:01 +0000)]
LLVM_FALLTHROUGH instead of fall-through comment.

llvm-svn: 303375

7 years agoMerge IAT and ILT.
Rui Ueyama [Thu, 18 May 2017 19:59:22 +0000 (19:59 +0000)]
Merge IAT and ILT.

Previously, LLD-produced executables had IAT (Import Address Table) and
ILT (Import Lookup Table) as separate chunks of data, although their
contents are identical. My interpretation of the COFF spec when I wrote
the COFF linker is that they need to be separate tables even though they
are the same.

But Peter found that the Windows loader is fine with executables in
which IAT and ILT are merged. This is a patch to merge IAT and ILT.
I confirmed that an lld-link self-hosted with this patch works fine.

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

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

llvm-svn: 303374

7 years agoWhen we enter a module within a linkage specification, switch the linkage
Richard Smith [Thu, 18 May 2017 19:34:55 +0000 (19:34 +0000)]
When we enter a module within a linkage specification, switch the linkage
specification and the TU to the new module.

This is necessary to get the module ownership correct for entities that we
temporarily hang off the TranslationUnitDecl, such as template parameters and
function parameters.

llvm-svn: 303373

7 years agoFix the location of "missing ';'" suggestions after annotation tokens.
Richard Smith [Thu, 18 May 2017 19:21:48 +0000 (19:21 +0000)]
Fix the location of "missing ';'" suggestions after annotation tokens.

We were incorrectly setting PrevTokLocation to the first token in the
annotation token instead of the last when consuming it. To fix this without
adding a complex switch to the hot path through ConsumeToken, we now have a
ConsumeAnnotationToken function for consuming annotation tokens in addition
to the other Consume*Token special case functions.

llvm-svn: 303372

7 years agoCOFF: Replace DLLNames maps with vectors.
Peter Collingbourne [Thu, 18 May 2017 18:53:39 +0000 (18:53 +0000)]
COFF: Replace DLLNames maps with vectors.

The import lists are already binned by DLL name, so there's no need to
deduplicate here.

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

llvm-svn: 303371

7 years agoCodeGen: Cast alloca to expected address space
Yaxun Liu [Thu, 18 May 2017 18:51:09 +0000 (18:51 +0000)]
CodeGen: Cast alloca to expected address space

Alloca always returns a pointer in alloca address space, which may
be different from the type defined by the language. For example,
in C++ the auto variables are in the default address space. Therefore
cast alloca to the expected address space when necessary.

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

llvm-svn: 303370

7 years agoRevert r302938 "Add LiveRangeShrink pass to shrink live range within BB."
Hans Wennborg [Thu, 18 May 2017 18:50:05 +0000 (18:50 +0000)]
Revert r302938 "Add LiveRangeShrink pass to shrink live range within BB."

This also reverts follow-ups r303292 and r303298.

It broke some Chromium tests under MSan, and apparently also internal
tests at Google.

llvm-svn: 303369

7 years agoUse existing helper. NFC.
Rafael Espindola [Thu, 18 May 2017 18:24:11 +0000 (18:24 +0000)]
Use existing helper. NFC.

llvm-svn: 303368

7 years ago[InstSimplify] Add test cases for missing fold (A & B) | ~(A ^ B) -> ~(A ^ B).
Craig Topper [Thu, 18 May 2017 18:14:40 +0000 (18:14 +0000)]
[InstSimplify] Add test cases for missing fold (A & B) | ~(A ^ B) -> ~(A ^ B).

llvm-svn: 303367

7 years ago[index] Avoid one more crash caused by infinite recursion that happens when
Alex Lorenz [Thu, 18 May 2017 18:06:07 +0000 (18:06 +0000)]
[index] Avoid one more crash caused by infinite recursion that happens when
looking up a dependent name in a record that derives from itself

rdar://32273000

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

llvm-svn: 303366

7 years agoReduce gcc-7 warnings by fall-through comments.
Galina Kistanova [Thu, 18 May 2017 17:53:47 +0000 (17:53 +0000)]
Reduce gcc-7 warnings by fall-through comments.

llvm-svn: 303365