platform/upstream/llvm.git
7 years ago[LoopPredication] NFC. Move a nested struct declaration before the fields, clang...
Artur Pilipenko [Mon, 22 May 2017 12:01:32 +0000 (12:01 +0000)]
[LoopPredication] NFC. Move a nested struct declaration before the fields, clang-format a bit

This will simplify the diff for an upcoming review.

llvm-svn: 303543

7 years agoRevert r303259 - [globalisel][tablegen] Import rules containing intrinsic_wo_chain.
Daniel Sanders [Mon, 22 May 2017 10:14:33 +0000 (10:14 +0000)]
Revert r303259 - [globalisel][tablegen] Import rules containing intrinsic_wo_chain.

It's causing some buildbots to timeout whenever tablegen needs re-compilation,
particularly those with -fsanitize=memory but not only them. A compile time
regression was expected since it triples the amount of SelectionDAG rules we
are able to import but it's currently too high.

llvm-svn: 303542

7 years ago[clang-format] Keep trailing preprocessor line comments separate from the following...
Krasimir Georgiev [Mon, 22 May 2017 10:07:56 +0000 (10:07 +0000)]
[clang-format] Keep trailing preprocessor line comments separate from the following section comments

Summary:
r303415 changed the way a sequence of line comments following a preprocessor
macro is handled, which has the unfortunate effect of aligning a trailing
preprocessor line comment and following unrelated section comments, so:
```
#ifdef A // comment about A
// section comment
#endif
```
gets turned into:
```
#ifdef A // comment about A
         // section comment
#endif
```
This patch fixes this by additionally checking the original start columns of
the line comments.

Reviewers: djasper

Reviewed By: djasper

Subscribers: klimek, cfe-commits

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

llvm-svn: 303541

7 years agoRe-apply r302416: [ARM] Clear the constant pool cache on explicit .ltorg directives
James Molloy [Mon, 22 May 2017 09:42:07 +0000 (09:42 +0000)]
Re-apply r302416: [ARM] Clear the constant pool cache on explicit .ltorg directives

Re-applying now that PR32825 which was raised on the commit this fixed up is now known to have also been fixed by this commit.

Original commit message:
    Multiple ldr pseudoinstructions with the same constant value will
    reuse the same constant pool entry. However, if the constant pool
    is explicitly flushed with a .ltorg directive, we should not try
    to reference constants in the previous pool any longer, since they
    may be out of range.

    This fixes assembling hand-written assembler source which repeatedly
    loads the same constant value, across a binary size larger than the
    pc-relative fixup range for ldr instructions (4096 bytes). Such
    assembler source already uses explicit .ltorg instructions to emit
    constant pools with regular intervals. However if we try to reuse
    constants emitted in earlier pools, they end up out of range.

    This makes the output of the testcase match what binutils gas does
    (prior to this patch, it would fail to assemble).

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

llvm-svn: 303540

7 years agoRe-apply r286006: Fix 24560: assembler does not share constant pool for same constants
James Molloy [Mon, 22 May 2017 09:42:01 +0000 (09:42 +0000)]
Re-apply r286006: Fix 24560:  assembler does not share constant pool for same constants

Re-applying now that the open bug on this commit, PR32825, is known to be fixed.

Original commit message:
    Summary: This patch returns the same label if the CP entry with the same value has been created.

    Reviewers: eli.friedman, rengolin, jmolloy

    Subscribers: majnemer, jmolloy, llvm-commits

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

llvm-svn: 303539

7 years ago[MIPS] Add support to match more patterns for DINS instruction
Strahinja Petrovic [Mon, 22 May 2017 09:06:44 +0000 (09:06 +0000)]
[MIPS] Add support to match more patterns for DINS instruction

This patch adds support for recognizing patterns to match
DINS instruction.

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

llvm-svn: 303537

7 years agoRevert "[ARM] Clear the constant pool cache on explicit .ltorg directives"
James Molloy [Mon, 22 May 2017 08:49:28 +0000 (08:49 +0000)]
Revert "[ARM] Clear the constant pool cache on explicit .ltorg directives"

This reverts commit r302416. This was a fixup for r286006, which has now been reverted so this doesn't apply (either in concept or in code).

This commit itself has no problems, but the underlying issue it was fixing has now disappeared from the codebase.

llvm-svn: 303536

7 years agoRevert "Fix 24560: assembler does not share constant pool for same constants"
James Molloy [Mon, 22 May 2017 08:42:47 +0000 (08:42 +0000)]
Revert "Fix 24560:  assembler does not share constant pool for same constants"

This reverts commit r286006. It caused PR32825 and wasn't fixed.

llvm-svn: 303535

7 years agoclang-format: Allow customizing the penalty for breaking assignment
Francois Ferrand [Mon, 22 May 2017 08:28:17 +0000 (08:28 +0000)]
clang-format: Allow customizing the penalty for breaking assignment

Summary:
Add option to customize the penalty for breaking assignment

This allows increasing the priority of the assignment, to prefer spliting
an operation instead of splitting the assignment, e.g. :

  int a = bbbbbbbbbbbbbbbb +
          cccccccccccccccc;

Reviewers: krasimir, djasper

Reviewed By: djasper

Subscribers: cfe-commits, klimek

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

llvm-svn: 303534

7 years agoRegenerate expected result for test constant-combines.ll . NFC
Amaury Sechet [Mon, 22 May 2017 07:49:16 +0000 (07:49 +0000)]
Regenerate expected result for test constant-combines.ll . NFC

llvm-svn: 303533

7 years agolibDebugInfo/DWARF: Apply relocations for debug_addr addresses in object files
David Blaikie [Mon, 22 May 2017 07:02:47 +0000 (07:02 +0000)]
libDebugInfo/DWARF: Apply relocations for debug_addr addresses in object files

llvm-symbolizer would fail to symbolize addresses in unlinked object
files when handling .dwo file data because the addresses would not be
relocated in the same way as the ranges in the skeleton CU in the object
file.

Fix that so object files can be symbolized the same as executables.

llvm-svn: 303532

7 years ago[SCEV] Clarify behavior around max backedge taken count
Sanjoy Das [Mon, 22 May 2017 06:46:04 +0000 (06:46 +0000)]
[SCEV] Clarify behavior around max backedge taken count

This is a re-application of a r303497 that was reverted in r303498.
I thought it had broken a bot when it had not (the breakage did not
go away with the revert).

This change makes the split between the "exact" backedge taken count
and the "maximum" backedge taken count a bit more obvious.  Both of
these are upper bounds on the number of times the loop header
executes (since SCEV does not account for most kinds of abnormal
control flow), but the latter is guaranteed to be a constant.

There were a few places where the max backedge taken count *was* a
non-constant; I've changed those to compute constants instead.

At this point, I'm not sure if the constant max backedge count can be
computed by calling `getUnsignedRange(Exact).getUnsignedMax()` without
losing precision.  If it can, we can simplify even further by making
`getMaxBackedgeTakenCount` a thin wrapper around
`getBackedgeTakenCount` and `getUnsignedRange`.

llvm-svn: 303531

7 years ago[X86] Add (ix bitcast(vsetcc)) test cases with illegal types. NFC.
Zvi Rackover [Mon, 22 May 2017 06:39:12 +0000 (06:39 +0000)]
[X86] Add (ix bitcast(vsetcc)) test cases with illegal types. NFC.

llvm-svn: 303530

7 years ago[InstCombine] Cleanup the interface for overflow checks
Craig Topper [Mon, 22 May 2017 06:25:31 +0000 (06:25 +0000)]
[InstCombine] Cleanup the interface for overflow checks

Summary:
Fix naming conventions and const correctness.
This completes the changes made in rL303029.

Patch by Yoav Ben-Shalom.

Reviewers: craig.topper

Reviewed By: craig.topper

Subscribers: llvm-commits

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

llvm-svn: 303529

7 years agoAdd a test case for large integer subtraction via subcarry. NFC
Amaury Sechet [Mon, 22 May 2017 06:06:45 +0000 (06:06 +0000)]
Add a test case for large integer subtraction via subcarry. NFC

llvm-svn: 303528

7 years agoRevert r303304: Re-submit r303225: Garbage collect dllimported symbols.
Rui Ueyama [Mon, 22 May 2017 06:01:37 +0000 (06:01 +0000)]
Revert r303304: Re-submit r303225: Garbage collect dllimported symbols.

This reverts commit r303304 because it looks like the change
introduced a crash bug. At least after that change, LLD with thinlto
crashes when linking Chromium.

llvm-svn: 303527

7 years ago[XRay][compiler-rt] Add __xray_remove_customevent_handler(...)
Dean Michael Berris [Mon, 22 May 2017 03:23:54 +0000 (03:23 +0000)]
[XRay][compiler-rt] Add __xray_remove_customevent_handler(...)

This change adds __xray_remove_customevent_handler(...) to be consistent
with other APIs that add/remove handlers.

llvm-svn: 303526

7 years agoAdd test case for subcarry optimization.
Amaury Sechet [Mon, 22 May 2017 02:31:42 +0000 (02:31 +0000)]
Add test case for subcarry optimization.

llvm-svn: 303525

7 years ago[SimplifyCFG] Prevent a few APInt copies on method calls that return const reference...
Craig Topper [Mon, 22 May 2017 00:49:35 +0000 (00:49 +0000)]
[SimplifyCFG] Prevent a few APInt copies on method calls that return const reference. NFCI

llvm-svn: 303523

7 years ago[KnownBits] Use isNegative/isNonNegative to shorten some code. NFC
Craig Topper [Mon, 22 May 2017 00:49:33 +0000 (00:49 +0000)]
[KnownBits] Use isNegative/isNonNegative to shorten some code. NFC

llvm-svn: 303522

7 years agoNewGVN: Fix PR 33116, the memoryphi version of bug 32838.
Daniel Berlin [Sun, 21 May 2017 23:41:58 +0000 (23:41 +0000)]
NewGVN: Fix PR 33116, the memoryphi version of bug 32838.

llvm-svn: 303521

7 years agoNewGVN: Cleanup some repeated code using some templated helpers
Daniel Berlin [Sun, 21 May 2017 23:41:56 +0000 (23:41 +0000)]
NewGVN: Cleanup some repeated code using some templated helpers

llvm-svn: 303520

7 years agoNewGVN: Fix printing of simplified expression
Daniel Berlin [Sun, 21 May 2017 23:41:53 +0000 (23:41 +0000)]
NewGVN: Fix printing of simplified expression

llvm-svn: 303519

7 years agoSmallPtrSetImpl/SmallPtrSet: Add a public value_type and key_type
Daniel Berlin [Sun, 21 May 2017 23:41:51 +0000 (23:41 +0000)]
SmallPtrSetImpl/SmallPtrSet: Add a public value_type and key_type

llvm-svn: 303518

7 years ago[CodeGen] Support partial write accesses.
Michael Kruse [Sun, 21 May 2017 22:46:57 +0000 (22:46 +0000)]
[CodeGen] Support partial write accesses.

Allow the BlockGenerator to generate memory writes that are not defined
over the complete statement domain, but only over a subset of it. It
generates a condition that evaluates to 1 if executing the subdomain,
and only then execute the access.

Only write accesses are supported. Read accesses would require a PHINode
which has a value if the access is not executed.

Partial write makes DeLICM able to apply mappings that are not defined
over the entire domain (for instance, a branch that leaves a loop with
a PHINode in its header; a MemoryKind::PHI write when leaving is never
read by its PHI read).

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

llvm-svn: 303517

7 years ago[NewGVN] Actually check the NewGVN output.
Davide Italiano [Sun, 21 May 2017 20:55:53 +0000 (20:55 +0000)]
[NewGVN] Actually check the NewGVN output.

Apparently I messed up squashing two consecutive commits.

llvm-svn: 303516

7 years ago[NewGVN] Add a test for non most dominating leader.
Davide Italiano [Sun, 21 May 2017 20:50:16 +0000 (20:50 +0000)]
[NewGVN] Add a test for non most dominating leader.

Taken from PR32845. Dan removed the most dominating leader check
in r303443, but we check this test anyway to make sure things
don't regress.

llvm-svn: 303515

7 years ago[ScopInfo] Translate updateDimensionality to isl C++ [NFC]
Tobias Grosser [Sun, 21 May 2017 20:38:33 +0000 (20:38 +0000)]
[ScopInfo] Translate updateDimensionality to isl C++ [NFC]

llvm-svn: 303514

7 years ago[InstCombine] Take in account the size in sext->lshr->trunc patterns.
Davide Italiano [Sun, 21 May 2017 20:30:27 +0000 (20:30 +0000)]
[InstCombine] Take in account the size in sext->lshr->trunc patterns.

Otherwise we end up miscompiling, transforming:

define i8 @tinky() {
  %sext = sext i1 1 to i16
  %hibit = lshr i16 %sext, 15
  %tr = trunc i16 %hibit to i8
  ret i8 %tr
}

into:

  %sext = sext i1 1 to i8
  ret i8 %sext

and the first get folded to ret i8 1, while the second gets folded
to ret i8 -1.

Eventually we should get rid of this transform entirely, but for now,
this at least fixes a know correctness bug.

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

llvm-svn: 303513

7 years ago[isl++] add isl_constraint to C++ bindings [NFC]
Tobias Grosser [Sun, 21 May 2017 20:23:26 +0000 (20:23 +0000)]
[isl++] add isl_constraint to C++ bindings [NFC]

llvm-svn: 303512

7 years ago[ScopInfo] Translate wrapConstantDimensions to isl C++ [NFC]
Tobias Grosser [Sun, 21 May 2017 20:23:23 +0000 (20:23 +0000)]
[ScopInfo] Translate wrapConstantDimensions to isl C++ [NFC]

llvm-svn: 303511

7 years ago[ScopInfo] Translate addRangeBoundsToSet to isl C++ [NFC]
Tobias Grosser [Sun, 21 May 2017 20:23:20 +0000 (20:23 +0000)]
[ScopInfo] Translate addRangeBoundsToSet to isl C++ [NFC]

llvm-svn: 303510

7 years agoFix include order to stop clang-format complains
Tobias Grosser [Sun, 21 May 2017 16:34:09 +0000 (16:34 +0000)]
Fix include order to stop clang-format complains

llvm-svn: 303509

7 years ago[ScheduleOptimizer] Move schedule construction to isl C++ [NFC]
Tobias Grosser [Sun, 21 May 2017 16:21:33 +0000 (16:21 +0000)]
[ScheduleOptimizer] Move schedule construction to isl C++ [NFC]

llvm-svn: 303508

7 years ago[Simplify] Move to isl C++
Tobias Grosser [Sun, 21 May 2017 16:12:21 +0000 (16:12 +0000)]
[Simplify] Move to isl C++

llvm-svn: 303507

7 years ago[isl++] Export (almost) all functions from isl
Tobias Grosser [Sun, 21 May 2017 16:00:32 +0000 (16:00 +0000)]
[isl++] Export (almost) all functions from isl

This commit exports the majority of the isl functions to the isl C++ interface.

The official isl C++ bindings still require discussions to define the set of
functions that are officially supported. As a result, the officially exported
functionality will be rather limited until these discussions conclude and a
non-trivial set of isl functions is officially supported through the isl C++
bindings. Starting from this commit we ship with Polly an extended version of
the official isl C++ bindings to ensure sufficient functionality is available
such that LLVM developers can make efficient use of isl through C++. The
practical experience Polly gathers with its bindings will then be used to
gradually upstream patches to isl to extend the official bindings.

llvm-svn: 303506

7 years ago[isl++] Rebase isl C++ bindings on top of 29aee98ce
Tobias Grosser [Sun, 21 May 2017 15:59:15 +0000 (15:59 +0000)]
[isl++] Rebase isl C++ bindings on top of 29aee98ce

This reduces the diff to the official isl C++ bindings and solves a correctness
issue with isl::booleans, where isl_bool_error results were accidentally
converted to isl::boolean::true.

llvm-svn: 303505

7 years ago[InstCombine] add tests for potential (lshr(sext X), C) folds; NFC
Sanjay Patel [Sun, 21 May 2017 15:18:52 +0000 (15:18 +0000)]
[InstCombine] add tests for potential (lshr(sext X), C) folds; NFC

As discussed in:
https://reviews.llvm.org/D33338
...we may be able to remove a wider pattern match by doing these more
basic canonicalizations.

llvm-svn: 303504

7 years ago[isl++] Move isl raw_ostream printers into separate header
Tobias Grosser [Sun, 21 May 2017 13:16:05 +0000 (13:16 +0000)]
[isl++] Move isl raw_ostream printers into separate header

Instead of relying on these functions to be part of the isl C++ bindings, we
just define this functionality independently. This allows us to use isl C++
bindings that do not contain LLVM specific functionality.

llvm-svn: 303503

7 years ago[GlobalISel][X86] Fix G_TRUNC instruction selection.
Igor Breger [Sun, 21 May 2017 11:13:56 +0000 (11:13 +0000)]
[GlobalISel][X86] Fix G_TRUNC instruction selection.
Updated tests with -verify-machineinstrs flag.
It fixes 3 tests failed with machine verifier enabled and listed
in PR27481

llvm-svn: 303502

7 years ago[Format] Add curly braces to suppress a -Wmisleading-indentation warning from gcc.
Craig Topper [Sun, 21 May 2017 07:29:07 +0000 (07:29 +0000)]
[Format] Add curly braces to suppress a -Wmisleading-indentation warning from gcc.

llvm-svn: 303501

7 years agoSummary
Hiroshi Inoue [Sun, 21 May 2017 06:00:05 +0000 (06:00 +0000)]
Summary

PPC backend eliminates compare instructions by using record-form instructions in PPCInstrInfo::optimizeCompareInstr, which is called from peephole optimization pass.
This patch improves this optimization to eliminate more compare instructions in two types of common case.

- comparison against a constant 1 or -1

The record-form instructions set CR bit based on signed comparison against 0. So, the current implementation does not exploit the record-form instruction for comparison against a non-zero constant.
This patch enables record-form optimization for constant of 1 or -1 if possible; it changes the condition "greater than -1" into "greater than or equal to 0" and "less than 1" into "less than or equal to 0".
With this patch, compare can be eliminated in the following code sequence, as an example.

uint64_t a, b;
if ((a | b) & 0x8000000000000000ull) { ... }
else { ... }

- andi for 32-bit comparison on PPC64

Since record-form instructions execute 64-bit signed comparison and so we have limitation in eliminating 32-bit comparison, i.e. with cmplwi, using the record-form. The original implementation already has such checks but andi. is not recognized as an instruction which executes implicit zero extension and hence safe to convert into record-form if used for equality check.

%1 = and i32 %a, 10
%2 = icmp ne i32 %1, 0
br i1 %2, label %foo, label %bar

In this simple example, LLVM generates andi. + cmplwi + beq on PPC64.
This patch make it possible to eliminate the cmplwi for this case.
I added andi. for optimization targets if it is safe to do so.

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

llvm-svn: 303500

7 years ago[Docs] Fix LangRef links referred in GetElementPtr.rst
George Burgess IV [Sun, 21 May 2017 05:31:29 +0000 (05:31 +0000)]
[Docs] Fix LangRef links referred in GetElementPtr.rst

Patch by chenwj!

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

llvm-svn: 303499

7 years agoRevert "[SCEV] Clarify behavior around max backedge taken count"
Sanjoy Das [Sun, 21 May 2017 05:02:12 +0000 (05:02 +0000)]
Revert "[SCEV] Clarify behavior around max backedge taken count"

This reverts commit r303497 since it breaks the msan bootstrap bot:
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap/builds/1379/

llvm-svn: 303498

7 years ago[SCEV] Clarify behavior around max backedge taken count
Sanjoy Das [Sun, 21 May 2017 01:47:50 +0000 (01:47 +0000)]
[SCEV] Clarify behavior around max backedge taken count

This change makes the split between the "exact" backedge taken count
and the "maximum" backedge taken count a bit more obvious.  Both of
these are upper bounds on the number of times the loop header
executes (since SCEV does not account for most kinds of abnormal
control flow), but the latter is guaranteed to be a constant.

There were a few places where the max backedge taken count *was* a
non-constant; I've changed those to compute constants instead.

At this point, I'm not sure if the constant max backedge count can be
computed by calling `getUnsignedRange(Exact).getUnsignedMax()` without
losing precision.  If it can, we can simplify even further by making
`getMaxBackedgeTakenCount` a thin wrapper around
`getBackedgeTakenCount` and `getUnsignedRange`.

llvm-svn: 303497

7 years agoRevert "Add pthread_self function prototype and make it speculatable."
Xin Tong [Sun, 21 May 2017 00:37:55 +0000 (00:37 +0000)]
Revert "Add pthread_self function prototype and make it speculatable."

This reverts commit 143d7445b5dfa2f6d6c45bdbe0433d9fc531be21.

Build breaking

llvm-svn: 303496

7 years agoAdd pthread_self function prototype and make it speculatable.
Xin Tong [Sat, 20 May 2017 22:40:25 +0000 (22:40 +0000)]
Add pthread_self function prototype and make it speculatable.

Summary: This allows pthread_self to be pulled out of a loop by LICM.

Reviewers: hfinkel, arsenm, davide

Reviewed By: davide

Subscribers: davide, wdng, llvm-commits

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

llvm-svn: 303495

7 years agoCOFF: Fix another StringRef return error
Martell Malone [Sat, 20 May 2017 21:54:15 +0000 (21:54 +0000)]
COFF: Fix another StringRef return error

This should appease the lld build bot regression
Following up on rL303493

llvm-svn: 303494

7 years agoCOFF: Fix single StringRef return error
Martell Malone [Sat, 20 May 2017 21:00:36 +0000 (21:00 +0000)]
COFF: Fix single StringRef return error

This should appease the lld build bot regression
Intrroduced by rL303490

llvm-svn: 303493

7 years agoFix PR25627: constant expressions being odr-used in template arguments.
Faisal Vali [Sat, 20 May 2017 19:58:04 +0000 (19:58 +0000)]
Fix PR25627: constant expressions being odr-used in template arguments.

This patch ensures that clang processes the expression-nodes that are generated when disambiguating between types and expressions within template arguments as constant-expressions by installing the ConstantEvaluated ExpressionEvaluationContext just before attempting the disambiguation - and then making sure that Context carries through into ParseConstantExpression (by refactoring it out into a function that does not create its own EvaluationContext: ParseConstantExpressionInExprEvalContext)

Note, prior to this patch, trunk would correctly disambiguate and identify the expression as an expression - and while it would annotate the token with the expression - it would fail to complete the odr-use processing (specifically, failing to trigger Sema::UpdateMarkingForLValueToRValue as is done for all Constant Expressions, which would remove it from being considered odr-used).  By installing the ConstantExpression Evaluation Context prior to disambiguation, and making sure it carries though, we ensure correct processing of the expression-node.

For e.g:
  template<int> struct X { };
  void f() {
    const int N = 10;
    X<N> x; // should be OK.
    [] { return X<N>{}; }; // Should be OK - no capture - but clang errors!
  }

See a related bug: https://bugs.llvm.org//show_bug.cgi?id=25627

In summary (and reiteration), the fix is as follows:

    - Remove the EnteredConstantEvaluatedContext action from ParseTemplateArgumentList (relying on ParseTemplateArgument getting it right)
    - Add the EnteredConstantEvaluatedContext action just prior to undergoing the disambiguating parse, and if the parse succeeds for an expression, carry the context though into a refactored version of ParseConstantExpression that does not create its own ExpressionEvaluationContext.

See https://reviews.llvm.org/D31588 for additional context regarding some of the more fragile and complicated approaches attempted, and Richard's feedback that eventually shaped the simpler and more robust rendition that is being committed.

Thanks Richard!

llvm-svn: 303492

7 years agoCOFF: migrate def parser from LLD to LLVM [2/2]
Martell Malone [Sat, 20 May 2017 19:56:44 +0000 (19:56 +0000)]
COFF: migrate def parser from LLD to LLVM [2/2]

This is split up into two commits.
This commit removes the DEF parser from LLD
See the previous commit for the creation in LLVM.

Reviewers: ruiu

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

llvm-svn: 303491

7 years agoCOFF: migrate def parser from LLD to LLVM [1/2]
Martell Malone [Sat, 20 May 2017 19:56:29 +0000 (19:56 +0000)]
COFF: migrate def parser from LLD to LLVM [1/2]

This is split up into two commits.
The will create the DEF parser in LLVM.
Check the following commit to see the removal from LLD

Reviewers: ruiu

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

llvm-svn: 303490

7 years agoFix test typo. NFC
Xin Tong [Sat, 20 May 2017 19:40:24 +0000 (19:40 +0000)]
Fix test typo. NFC

llvm-svn: 303489

7 years ago[Devirtualization] insert placement new barrier with -O0
Piotr Padlewski [Sat, 20 May 2017 08:56:18 +0000 (08:56 +0000)]
[Devirtualization] insert placement new barrier with -O0

Summary:
To not break LTO with different optimizations levels, we should insert
the barrier regardles of optimization level.

Reviewers: rjmccall, rsmith, mehdi_amini

Reviewed By: mehdi_amini

Subscribers: mehdi_amini, cfe-commits

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

llvm-svn: 303488

7 years agoDocs: Fix pluralization in CMake docs
Duncan P. N. Exon Smith [Sat, 20 May 2017 05:25:19 +0000 (05:25 +0000)]
Docs: Fix pluralization in CMake docs

Fixed "most platform" to read "most platforms", and changed "are not
using the same" to "use different" as a drive-by.

llvm-svn: 303487

7 years ago[docs] Small style nits.
George Burgess IV [Sat, 20 May 2017 04:52:29 +0000 (04:52 +0000)]
[docs] Small style nits.

llvm-svn: 303486

7 years agoFix buildbots after r303429
Tobias Grosser [Sat, 20 May 2017 04:22:26 +0000 (04:22 +0000)]
Fix buildbots after r303429

A test case with a GPU runline was added without setting 'REQUIRES=pollyacc'. We
drop the GPU run line, as the basic functionality can already be tested with
the normal code generation.

llvm-svn: 303485

7 years ago[index] Fix forward declarations interfering with USR generation of external source...
Argyrios Kyrtzidis [Sat, 20 May 2017 04:11:33 +0000 (04:11 +0000)]
[index] Fix forward declarations interfering with USR generation of external source symbols

Patch by Nathan Hawes.
https://reviews.llvm.org/D33346

llvm-svn: 303484

7 years agoFix -Wunneeded-internal-declaration by removing constant arrays only used in sizeof...
David Blaikie [Sat, 20 May 2017 03:32:51 +0000 (03:32 +0000)]
Fix -Wunneeded-internal-declaration by removing constant arrays only used in sizeof expressions, in favor of constants containing the size directly

llvm-svn: 303483

7 years agollvm-symbolizer: Support multiple CUs in a single DWO file
David Blaikie [Sat, 20 May 2017 03:32:49 +0000 (03:32 +0000)]
llvm-symbolizer: Support multiple CUs in a single DWO file

llvm-svn: 303482

7 years agoRevert "[compiler-rt] Change default of allow_user_segv_handler to true"
Vitaly Buka [Sat, 20 May 2017 02:09:25 +0000 (02:09 +0000)]
Revert "[compiler-rt] Change default of allow_user_segv_handler to true"

Failed libFuzzer tests on Windows.

This reverts commit r303476.

llvm-svn: 303481

7 years agoAdd functionality to cvtres to parse all entries in res file.
Eric Beckmann [Sat, 20 May 2017 01:49:19 +0000 (01:49 +0000)]
Add functionality to cvtres to parse all entries in res file.

Summary: Added the new modules in the Object/ folder.  Updated the
llvm-cvtres interface as well, and added additional tests.

Subscribers: llvm-commits, mgorny

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

llvm-svn: 303480

7 years agoRename RAII objects for performing eager instantiation to have names that
Richard Smith [Sat, 20 May 2017 01:36:41 +0000 (01:36 +0000)]
Rename RAII objects for performing eager instantiation to have names that
describe what they're for, not how they do it, and factor out a bit more
common code into them.

llvm-svn: 303479

7 years agoCodeGenModule: Always output wchar_size, check LLVM assumptions.
Matthias Braun [Sat, 20 May 2017 01:29:55 +0000 (01:29 +0000)]
CodeGenModule: Always output wchar_size, check LLVM assumptions.

Re-commit r303463 now that LLVM is fixed and adjust some lit tests.

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: 303478

7 years agoFix breakage after r303461
Matthias Braun [Sat, 20 May 2017 01:28:52 +0000 (01:28 +0000)]
Fix breakage after r303461

- Improve wchar_t size predicitions based on target triple.
- Be less strict in wchar_t size verifier.

llvm-svn: 303477

7 years ago[compiler-rt] Change default of allow_user_segv_handler to true
Vitaly Buka [Sat, 20 May 2017 01:04:59 +0000 (01:04 +0000)]
[compiler-rt] Change default of allow_user_segv_handler to true

Reviewers: eugenis

Subscribers: srhines, kubamracek, llvm-commits

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

llvm-svn: 303476

7 years ago[NewGVN] Create a StoreExpression instead of a VariableExpression.
Davide Italiano [Sat, 20 May 2017 00:46:54 +0000 (00:46 +0000)]
[NewGVN] Create a StoreExpression instead of a VariableExpression.

In the case where we have an operand defined by a lod of the
same memory location. Historically this was a VariableExpression
because we wanted to make sure they ended up in the same class,
but if we create the right expression, they end up in the same
class anyway.

Fixes PR32897. Thanks to Dan for the detailed discussion and the
fix suggestion.

llvm-svn: 303475

7 years agoRevert "CodeGenModule: Always output wchar_size, check LLVM assumptions."
Matthias Braun [Sat, 20 May 2017 00:38:27 +0000 (00:38 +0000)]
Revert "CodeGenModule: Always output wchar_size, check LLVM assumptions."

Let's revert this for now (and with it the assert()) to get the bots
back to green until I have LLVM synced up properly.

This reverts commit r303463.

llvm-svn: 303474

7 years ago[NewGVN] Get rid of an assertion.
Davide Italiano [Sat, 20 May 2017 00:24:04 +0000 (00:24 +0000)]
[NewGVN] Get rid of an assertion.

This was here because we don't want to switch leaders too much,
in order to avoid fixpoint(ing) issue, but it's not sure if it
matters in practice.

A first step towards fixing PR32897.

llvm-svn: 303473

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