platform/upstream/llvm.git
6 years ago[mips] Improve genConstMult() to work with arbitrary precision
Petar Jovanovic [Wed, 15 Nov 2017 15:24:04 +0000 (15:24 +0000)]
[mips] Improve genConstMult() to work with arbitrary precision

APInt is now used instead of uint64_t in function genConstMult() allowing
multiplication optimizations with constants of arbitrary length.

Patch by Milos Stojanovic.

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

llvm-svn: 318296

6 years ago[llvm-opt-fuzzer] Add opt fuzzer to the test-depends list.
Igor Laevsky [Wed, 15 Nov 2017 15:07:37 +0000 (15:07 +0000)]
[llvm-opt-fuzzer] Add opt fuzzer to the test-depends list.
This should help with the buildbot failures after rL318293.

llvm-svn: 318295

6 years ago[llvm-opt-fuzzer] Only run tests for the x86 target.
Igor Laevsky [Wed, 15 Nov 2017 13:35:42 +0000 (13:35 +0000)]
[llvm-opt-fuzzer] Only run tests for the x86 target.
This fixes build bot failures after rL318293.

llvm-svn: 318294

6 years ago[llvm-opt-fuzzer] NFC. Add sanity tests.
Igor Laevsky [Wed, 15 Nov 2017 12:36:57 +0000 (12:36 +0000)]
[llvm-opt-fuzzer] NFC. Add sanity tests.

llvm-svn: 318293

6 years ago[libclang] Fix cursors for in-class initializer of field declarations
Benjamin Kramer [Wed, 15 Nov 2017 12:20:41 +0000 (12:20 +0000)]
[libclang] Fix cursors for in-class initializer of field declarations

Fixes PR33745.

Patch by Nikolai Kosjar!

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

llvm-svn: 318292

6 years ago[ARM] Split Arm jump table branch into i12 and rs suffixed versions
Momchil Velikov [Wed, 15 Nov 2017 12:02:55 +0000 (12:02 +0000)]
[ARM] Split Arm jump table branch into i12 and rs suffixed versions

This is a refactoring/cleanup of Arm `addrmode2` operand class. The patch
removes it completely.

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

llvm-svn: 318291

6 years ago[OpenCL] Fix code generation of function-scope constant samplers.
Alexey Bader [Wed, 15 Nov 2017 11:38:17 +0000 (11:38 +0000)]
[OpenCL] Fix code generation of function-scope constant samplers.

Summary:
Constant samplers are handled as static variables and clang's code generation
library, which leads to llvm::unreachable. We bypass emitting sampler variable
as static since it's translated to a function call later.

Reviewers: yaxunl, Anastasia

Reviewed By: yaxunl, Anastasia

Subscribers: cfe-commits

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

llvm-svn: 318290

6 years ago[DebugInfo] Fix potential CU mismatch for SubprogramScopeDIEs.
Jonas Devlieghere [Wed, 15 Nov 2017 10:57:05 +0000 (10:57 +0000)]
[DebugInfo] Fix potential CU mismatch for SubprogramScopeDIEs.

In constructAbstractSubprogramScopeDIE there can be a potential mismatch
between `this` and the CU of ContextDIE when a scope is shared between
two DISubprograms belonging to a different CU. In that case, `this` is
the CU that was specified in the IR, but the CU of ContextDIE is that of
the first subprogram that was emitted. This patch fixes the mismatch by
looking up the CU of ContextDIE, and switching to use that.

This fixes PR35212 (https://bugs.llvm.org/show_bug.cgi?id=35212)

Patch by Philip Craig!

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

llvm-svn: 318289

6 years agoWorkaround CodeGen/WebAssembly/cfg-stackify.ll failure after r318202
Ilya Biryukov [Wed, 15 Nov 2017 10:50:43 +0000 (10:50 +0000)]
Workaround CodeGen/WebAssembly/cfg-stackify.ll failure after r318202

By disabling the introduced optimization.

llvm-svn: 318288

6 years ago[clangd] Support returning a limited number of completion results.
Sam McCall [Wed, 15 Nov 2017 09:16:29 +0000 (09:16 +0000)]
[clangd] Support returning a limited number of completion results.

Summary:
All results are scored, we only process CodeCompletionStrings for the winners.
We now return CompletionList rather than CompletionItem[] (both are valid).
sortText is now based on CodeCompletionResult::orderedName (mostly the same).

This is the first clangd-only completion option, so plumbing changed.
It requires a small clangd patch (exposing CodeCompletionResult::orderedName).

(This can't usefully be enabled yet: we don't support server-side filtering)

Reviewers: ilya-biryukov

Subscribers: cfe-commits

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

llvm-svn: 318287

6 years ago[clang] Expose orderedString from CodeCompletionResult. NFC
Sam McCall [Wed, 15 Nov 2017 09:15:06 +0000 (09:15 +0000)]
[clang] Expose orderedString from CodeCompletionResult. NFC

llvm-svn: 318286

6 years ago[MinGW] Ignore the --build-id, --pie-executable and --disable-auto-image-base options
Martin Storsjo [Wed, 15 Nov 2017 08:18:28 +0000 (08:18 +0000)]
[MinGW] Ignore the --build-id, --pie-executable and --disable-auto-image-base options

LLD already writes a build id if debug info is enabled.

Some projects set --pie-executable to avoid GNU ld bugs about stripping
base relocations from an executable when they actually are used.
Since -fixed:no is the default (and we don't support setting the
-fixed option via the MinGW frontend), we don't need to handle this.

--disable-auto-image-base is ignored just like --enable-auto-image-base
(as we ignore from before).

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

llvm-svn: 318285

6 years ago[COFF] Always include the size of the string table size field
Martin Storsjo [Wed, 15 Nov 2017 08:18:25 +0000 (08:18 +0000)]
[COFF] Always include the size of the string table size field

Even if we don't actually write any string table contents, the
4 byte size for the string table will always be written. Make
sure we accommodate for this in the file size. Since this size
is aligned up, this would seldom be an issue in practice.

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

llvm-svn: 318284

6 years ago[MinGW] Implement the --[no-]gc-sections and --icf options
Martin Storsjo [Wed, 15 Nov 2017 08:18:20 +0000 (08:18 +0000)]
[MinGW] Implement the --[no-]gc-sections and --icf options

GNU ld doesn't seem to support --icf at all, but this was suggested
in D39885, and GNU gold seems to support it.

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

llvm-svn: 318283

6 years ago[MinGW] Implement support for the --image-base option
Martin Storsjo [Wed, 15 Nov 2017 08:18:15 +0000 (08:18 +0000)]
[MinGW] Implement support for the --image-base option

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

llvm-svn: 318282

6 years ago[MinGW] Add support for --dynamicbase, ignore --nxcompat, --tsaware and --high-entropy-va
Martin Storsjo [Wed, 15 Nov 2017 08:18:11 +0000 (08:18 +0000)]
[MinGW] Add support for --dynamicbase, ignore --nxcompat, --tsaware and --high-entropy-va

All of these are disabled by default in GNU ld, but enabled by default
in lld.

Disable dynamicbase by default since it potentially could cause
compatibility issues, but just ignore the others since the lld
default should be fine for most concievable cases.

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

llvm-svn: 318281

6 years ago[MinGW] Handle --large-address-aware
Martin Storsjo [Wed, 15 Nov 2017 08:18:06 +0000 (08:18 +0000)]
[MinGW] Handle --large-address-aware

In GNU ld, this option is only available on i386, not on x86_64
(where it's enabled by default with no option to disable it either).

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

llvm-svn: 318280

6 years ago[Lint] Don't warn about passing alloca'd value to tail call if using byval
Mikael Holmen [Wed, 15 Nov 2017 07:46:48 +0000 (07:46 +0000)]
[Lint] Don't warn about passing alloca'd value to tail call if using byval

Summary:
This fixes PR35241.

When using byval, the data is effectively copied as part of the call
anyway, so the pointer returned by the alloca will not be leaked to the
callee and thus there is no reason to issue a warning.

Reviewers: rnk

Reviewed By: rnk

Subscribers: Ka-Ka, llvm-commits

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

llvm-svn: 318279

6 years ago[X86] Redefine the 128-bit version of VPGATHERQD and VGATHERQPS to use a VK2 mask...
Craig Topper [Wed, 15 Nov 2017 07:46:43 +0000 (07:46 +0000)]
[X86] Redefine the 128-bit version of VPGATHERQD and VGATHERQPS to use a VK2 mask instead of a VK4 mask.

This allows us to remove extra extend creation during lowering and more accurately reflects the semantics of the instruction.

While there add an extra output VT to X86 masked gather node to better match the isel pattern predicate. Currently we're exploiting the fact that the isel table doesn't count how many output results a node actually has if the result type of any can be inferred from the first result and the type constraints defined in tablegen. I think we might ultimately want to lower all MGATHER/MSCATTER to an X86ISD node with the extra mask result and stop relying on this hole in the isel checking.

llvm-svn: 318278

6 years agoTolerate even more [[nodiscard]] in the STL. Reviewed as https://reviews.llvm.org...
Billy Robert O'Neal III [Wed, 15 Nov 2017 07:45:07 +0000 (07:45 +0000)]
Tolerate even more [[nodiscard]] in the STL. Reviewed as https://reviews.llvm.org/D39080

llvm-svn: 318277

6 years agoTolerate [[nodiscard]] annotations in the STL. Reviewed as https://reviews.llvm.org...
Billy Robert O'Neal III [Wed, 15 Nov 2017 07:40:37 +0000 (07:40 +0000)]
Tolerate [[nodiscard]] annotations in the STL. Reviewed as https://reviews.llvm.org/D39033

llvm-svn: 318276

6 years agoGISelWorkList.h: Fix -fmodules build in rL318210.
NAKAMURA Takumi [Wed, 15 Nov 2017 07:34:35 +0000 (07:34 +0000)]
GISelWorkList.h: Fix -fmodules build in rL318210.

llvm-svn: 318275

6 years agoASTMatchers.h: Avoid warnings due to "@throw". [-Wdocumentation]
NAKAMURA Takumi [Wed, 15 Nov 2017 06:53:45 +0000 (06:53 +0000)]
ASTMatchers.h: Avoid warnings due to "@throw". [-Wdocumentation]

llvm-svn: 318274

6 years agoFix llvm/test/Transforms/LoopRotate/pr35210.ll in rL318237, it uses debug options.
NAKAMURA Takumi [Wed, 15 Nov 2017 06:46:58 +0000 (06:46 +0000)]
Fix llvm/test/Transforms/LoopRotate/pr35210.ll in rL318237, it uses debug options.

llvm-svn: 318273

6 years agoNFC Remove default argument of DataLayout::getPointerABIAlignment
Fangrui Song [Wed, 15 Nov 2017 06:17:32 +0000 (06:17 +0000)]
NFC Remove default argument of DataLayout::getPointerABIAlignment

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

llvm-svn: 318272

6 years ago[X86] Add getHostCPUName support for the Gemini Lake model number which also uses...
Craig Topper [Wed, 15 Nov 2017 06:02:43 +0000 (06:02 +0000)]
[X86] Add getHostCPUName support for the Gemini Lake model number which also uses Goldmont.

llvm-svn: 318271

6 years ago[X86] Add getHostCPUName support for cannonlake.
Craig Topper [Wed, 15 Nov 2017 06:02:42 +0000 (06:02 +0000)]
[X86] Add getHostCPUName support for cannonlake.

This adds an explicit model number check and fallback path to the unknown family 6 detection.

llvm-svn: 318270

6 years agoFirst part of P0600 - '[[nodiscard] in the standard library'. Mark the 'empty()'...
Marshall Clow [Wed, 15 Nov 2017 05:51:26 +0000 (05:51 +0000)]
First part of P0600 - '[[nodiscard] in the standard library'. Mark the 'empty()' methods of all the containers as nodiscard. If you're calling empty() w/o looking at the result, you probably meanto to call 'clear()'. c++2a only

llvm-svn: 318269

6 years agoStill more missing tests - this time for the unordered containers
Marshall Clow [Wed, 15 Nov 2017 05:25:36 +0000 (05:25 +0000)]
Still more missing tests - this time for the unordered containers

llvm-svn: 318268

6 years ago[InstCombine] Simplify binops that are only used by a select and are fed by a select...
Craig Topper [Wed, 15 Nov 2017 05:23:02 +0000 (05:23 +0000)]
[InstCombine] Simplify binops that are only used by a select and are fed by a select with the same condition.

Summary:
This patch optimizes a binop sandwiched between 2 selects with the same condition. Since we know its only used by the select we can propagate the appropriate input value from the earlier select.

As I'm writing this I realize I may need to avoid doing this for division in case the select was protecting a divide by zero?

Reviewers: spatel, majnemer

Reviewed By: majnemer

Subscribers: llvm-commits

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

llvm-svn: 318267

6 years ago[PowerPC] fix up in redundant compare elimination
Hiroshi Inoue [Wed, 15 Nov 2017 04:23:26 +0000 (04:23 +0000)]
[PowerPC] fix up in redundant compare elimination

This patch fixes a potential problem in my previous commit (https://reviews.llvm.org/rL312514) by introducing an additional check.

llvm-svn: 318266

6 years agomath: Implement minmag
Jan Vesely [Wed, 15 Nov 2017 04:10:39 +0000 (04:10 +0000)]
math: Implement minmag

Reviewer: Aaron Watry
Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
llvm-svn: 318265

6 years agomath: Implement maxmag
Jan Vesely [Wed, 15 Nov 2017 04:10:37 +0000 (04:10 +0000)]
math: Implement maxmag

Reviewer: Aaron Watry
Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
llvm-svn: 318264

6 years agoMake the test more strict. NFC.
Rafael Espindola [Wed, 15 Nov 2017 04:00:54 +0000 (04:00 +0000)]
Make the test more strict. NFC.

llvm-svn: 318263

6 years agoRoll back r318260 because it is causing the windows bot to
Jason Molenda [Wed, 15 Nov 2017 03:41:47 +0000 (03:41 +0000)]
Roll back r318260 because it is causing the windows bot to
break.  The alignas(__uint128_t) is not recognized with MSVC
it looks like.  Zachary, is there a similar type on windows?
I suppose I can go with alignas(16) here but I'd prefer to
specify the type alignment that I want & let the ABI dictate
how much padding is required.

llvm-svn: 318262

6 years ago[XRay][compiler-rt][x86_64] Align the stack before and after calling handlers
Dean Michael Berris [Wed, 15 Nov 2017 03:35:42 +0000 (03:35 +0000)]
[XRay][compiler-rt][x86_64] Align the stack before and after calling handlers

Summary:
This change fixes the XRay trampolines aside from the __xray_CustomEvent
trampoline to align the stack to 16-byte boundaries before calling the
handler. Before this change we've not been explicitly aligning the stack
to 16-byte boundaries, which makes it dangerous when calling handlers
that leave the stack in a state that isn't strictly 16-byte aligned
after calling the handlers.

We add a test that makes sure we can handle these cases appropriately
after the changes, and prevents us from regressing the state moving
forward.

Fixes http://llvm.org/PR35294.

Reviewers: pelikan, pcc

Subscribers: llvm-commits

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

llvm-svn: 318261

6 years agoTwo small fixes to handle arm64 fpu register contexts in
Jason Molenda [Wed, 15 Nov 2017 03:18:24 +0000 (03:18 +0000)]
Two small fixes to handle arm64 fpu register contexts in
a Mach-O file load command correctly, patch by Ryan
Mansfield.

<rdar://problem/35468499>

llvm-svn: 318260

6 years agoNamed the macro wrong in the test.
Marshall Clow [Wed, 15 Nov 2017 03:08:39 +0000 (03:08 +0000)]
Named the macro wrong in the test.

llvm-svn: 318259

6 years agoPR35214: don't crash if we see an array of unknown bound added to an empty but invali...
Richard Smith [Wed, 15 Nov 2017 03:03:56 +0000 (03:03 +0000)]
PR35214: don't crash if we see an array of unknown bound added to an empty but invalid designator.

llvm-svn: 318258

6 years ago[docs] Document a way to simplify names in bugpoint output
Vedant Kumar [Wed, 15 Nov 2017 02:58:45 +0000 (02:58 +0000)]
[docs] Document a way to simplify names in bugpoint output

llvm-svn: 318257

6 years agoMore missing tests - array<>::size() and array<>::max_size()
Marshall Clow [Wed, 15 Nov 2017 02:31:14 +0000 (02:31 +0000)]
More missing tests - array<>::size() and array<>::max_size()

llvm-svn: 318256

6 years agoUpdate Appveyor LLVM install link to be current and non-broken
Eric Fiselier [Wed, 15 Nov 2017 01:37:11 +0000 (01:37 +0000)]
Update Appveyor LLVM install link to be current and non-broken

llvm-svn: 318247

6 years agoAMDGPU: Add separate definitions for DS insts without m0 use
Matt Arsenault [Wed, 15 Nov 2017 01:34:06 +0000 (01:34 +0000)]
AMDGPU: Add separate definitions for DS insts without m0 use

llvm-svn: 318246

6 years ago[modules] Fix crash in complex class merging scenario.
Richard Smith [Wed, 15 Nov 2017 01:33:46 +0000 (01:33 +0000)]
[modules] Fix crash in complex class merging scenario.

When we merge together class definitions, we can end up with the canonical
declaration of a field not being the one that was lexically within the
canonical definition of the class. Additionally, when we merge class
definitions via update records (eg, for a template specialization whose
declaration is instantiated in one module and whose definition is instantiated
in multiple others), we can end up with the list of lexical contents for the
class not including a particular declaration of a field whose lexical parent is
that class definition. In the worst case, we have a field whose canonical
declaration's lexical parent has no fields, and in that case this attempt to
number the fields by walking the fields in the declaration of the class that
contained one of the canonical fields will fail.

Instead, when numbering fields in a class, do the obvious thing: walk the
fields in the definition.

I'm still trying to reduce a testcase; the setup that leads to the above
scenario seems to be quite fragile.

llvm-svn: 318245

6 years agoAdded tests for xxx.size() and xxx.empty() for all the sequence containers
Marshall Clow [Wed, 15 Nov 2017 01:33:33 +0000 (01:33 +0000)]
Added tests for xxx.size() and xxx.empty() for all the sequence containers

llvm-svn: 318244

6 years ago[X86] Correct the spelling of pentiumpro in X86TargetParser.def
Craig Topper [Wed, 15 Nov 2017 01:01:50 +0000 (01:01 +0000)]
[X86] Correct the spelling of pentiumpro in X86TargetParser.def

Thanks to Erich Keane for spotting this.

llvm-svn: 318243

6 years agoAMDGPU: Don't use MUBUF vaddr if address may overflow
Matt Arsenault [Wed, 15 Nov 2017 00:45:43 +0000 (00:45 +0000)]
AMDGPU: Don't use MUBUF vaddr if address may overflow

Effectively revert r263964. Before we would not
allow this if vaddr was not known to be positive.

llvm-svn: 318240

6 years agoRevert r318193 "[SLPVectorizer] Failure to beneficially vectorize 'copyable' elements...
Hans Wennborg [Wed, 15 Nov 2017 00:38:13 +0000 (00:38 +0000)]
Revert r318193 "[SLPVectorizer] Failure to beneficially vectorize 'copyable' elements in integer binary ops."

It crashes building sqlite; see reply on the llvm-commits thread.

> [SLPVectorizer] Failure to beneficially vectorize 'copyable' elements in integer binary ops.
>
>         Patch tries to improve vectorization of the following code:
>
>         void add1(int * __restrict dst, const int * __restrict src) {
>           *dst++ = *src++;
>           *dst++ = *src++ + 1;
>           *dst++ = *src++ + 2;
>           *dst++ = *src++ + 3;
>         }
>         Allows to vectorize even if the very first operation is not a binary add, but just a load.
>
>         Fixed issues related to previous commit.
>
>         Reviewers: spatel, mzolotukhin, mkuper, hfinkel, RKSimon, filcab, ABataev
>
>         Reviewed By: ABataev, RKSimon
>
>         Subscribers: llvm-commits, RKSimon
>
>         Differential Revision: https://reviews.llvm.org/D28907

llvm-svn: 318239

6 years ago[cfi-verify] Validate there are no register clobbers between CFI-check and instructio...
Mitch Phillips [Wed, 15 Nov 2017 00:35:26 +0000 (00:35 +0000)]
[cfi-verify] Validate there are no register clobbers between CFI-check and instruction execution.

Summary:
This patch adds another failure mode for `validateCFIProtection(..)`, wherein any register that affects the indirect control flow instruction is clobbered to between the CFI-check and the instruction's execution.

Also includes a modification to make MCInstrDesc::hasDefOfPhysReg public.

Reviewers: vlad.tsyrklevich

Reviewed By: vlad.tsyrklevich

Subscribers: llvm-commits, pcc, kcc

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

llvm-svn: 318238

6 years ago[LoopRotate] processLoop should return true even if it just simplified the loop latch...
Craig Topper [Wed, 15 Nov 2017 00:22:42 +0000 (00:22 +0000)]
[LoopRotate] processLoop should return true even if it just simplified the loop latch without making any other changes

Simplifying a loop latch changes the IR and we need to make sure the pass manager knows to invalidate analysis passes if that happened.

PR35210 discovered a case where we failed to invalidate the post dominator tree after this simplification because we no changes other than simplifying the loop latch.

Fixes PR35210.

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

llvm-svn: 318237

6 years ago[asan] Prevent rematerialization of &__asan_shadow.
Evgeniy Stepanov [Wed, 15 Nov 2017 00:11:51 +0000 (00:11 +0000)]
[asan] Prevent rematerialization of &__asan_shadow.

Summary:
In the mode when ASan shadow base is computed as the address of an
external global (__asan_shadow, currently on android/arm32 only),
regalloc prefers to rematerialize this value to save register spills.
Even in -Os. On arm32 it is rather expensive (2 loads + 1 constant
pool entry).

This changes adds an inline asm in the function prologue to suppress
this behavior. It reduces AsanTest binary size by 7%.

Reviewers: pcc, vitalybuka

Subscribers: aemerson, kristof.beyls, hiraditya, llvm-commits

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

llvm-svn: 318235

6 years agoSimplify CpuIs code to use include from LLVM
Erich Keane [Wed, 15 Nov 2017 00:11:24 +0000 (00:11 +0000)]
Simplify CpuIs code to use include from LLVM

LLVM exposes a file in the backend (X86TargetParser.def) that
contains information about the correct list of CpuIs values.

This patch removes 2 of the copied and pasted versions of this
list from clang and instead includes the data from the .def file.

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

llvm-svn: 318234

6 years ago[profile] Update InstrProfData.inc to sync with llvm
Vedant Kumar [Tue, 14 Nov 2017 23:57:58 +0000 (23:57 +0000)]
[profile] Update InstrProfData.inc to sync with llvm

llvm-svn: 318230

6 years ago[PGO] Detect more structural changes with the stable hash
Vedant Kumar [Tue, 14 Nov 2017 23:56:53 +0000 (23:56 +0000)]
[PGO] Detect more structural changes with the stable hash

Lifting from Bob Wilson's notes: The hash value that we compute and
store in PGO profile data to detect out-of-date profiles does not
include enough information. This means that many significant changes to
the source will not cause compiler warnings about the profile being out
of date, and worse, we may continue to use the outdated profile data to
make bad optimization decisions.  There is some tension here because
some source changes won't affect PGO and we don't want to invalidate the
profile unnecessarily.

This patch adds a new hashing scheme which is more sensitive to loop
nesting, conditions, and out-of-order control flow. Here are examples
which show snippets which get the same hash under the current scheme,
and different hashes under the new scheme:

Loop Nesting Example
--------------------

  // Snippet 1
  while (foo()) {
    while (bar()) {}
  }

  // Snippet 2
  while (foo()) {}
  while (bar()) {}

Condition Example
-----------------

  // Snippet 1
  if (foo())
    bar();
  baz();

  // Snippet 2
  if (foo())
    bar();
  else
    baz();

Out-of-order Control Flow Example
---------------------------------

  // Snippet 1
  while (foo()) {
    if (bar()) {}
    baz();
  }

  // Snippet 2
  while (foo()) {
    if (bar())
      continue;
    baz();
  }

In each of these cases, it's useful to differentiate between the
snippets because swapping their profiles gives bad optimization hints.

The new hashing scheme considers some logical operators in an effort to
detect more changes in conditions. This isn't a perfect scheme. E.g, it
does not produce the same hash for these equivalent snippets:

  // Snippet 1
  bool c = !a || b;
  if (d && e) {}

  // Snippet 2
  bool f = d && e;
  bool c = !a || b;
  if (f) {}

This would require an expensive data flow analysis. Short of that, the
new hashing scheme looks reasonably complete, based on a scan over the
statements we place counters on.

Profiles which use the old version of the PGO hash remain valid and can
be used without issue (there are tests in tree which check this).

rdar://17068282

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

llvm-svn: 318229

6 years ago[PGO] Bump the indexed profile format version
Vedant Kumar [Tue, 14 Nov 2017 23:56:48 +0000 (23:56 +0000)]
[PGO] Bump the indexed profile format version

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

llvm-svn: 318228

6 years ago[CMake][runtimes] Don't process common options in runtimes build
Petr Hosek [Tue, 14 Nov 2017 23:56:05 +0000 (23:56 +0000)]
[CMake][runtimes] Don't process common options in runtimes build

This is no longer needed for any of the runtimes build and it breaks
in case we don't have the working compiler yet, e.g. when building
a compiler that uses compiler-rt and libc++ as a default runtime,
because these common options check whether these are available.

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

llvm-svn: 318227

6 years ago[X86] Fix the parameter order in the default implementation of X86_VENDOR macro in...
Craig Topper [Tue, 14 Nov 2017 23:54:28 +0000 (23:54 +0000)]
[X86] Fix the parameter order in the default implementation of X86_VENDOR macro in X86TargetParser.def

The default implementation doesn't do anything so the order doesn't matter, but good for cleanliness.

llvm-svn: 318226

6 years ago[CMake][runtimes] Set compiler as working even for default target
Petr Hosek [Tue, 14 Nov 2017 23:47:20 +0000 (23:47 +0000)]
[CMake][runtimes] Set compiler as working even for default target

Even when building builtins and runtimes for the default target
we shouldn't assume that the just built compiler is already useable.
When the compiler uses compiler-rt and libc++ as the default runtime
and C++ library, it won't be usable until we finish building runtimes.

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

llvm-svn: 318224

6 years agoAMDGPU: Handle or in multi-use shl ptr combine
Matt Arsenault [Tue, 14 Nov 2017 23:46:42 +0000 (23:46 +0000)]
AMDGPU: Handle or in multi-use shl ptr combine

llvm-svn: 318223

6 years ago[AST] Fix some Clang-tidy modernize and Include What You Use warnings; other minor...
Eugene Zelenko [Tue, 14 Nov 2017 23:35:42 +0000 (23:35 +0000)]
[AST] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).

llvm-svn: 318221

6 years agoFix switch-lower-peel-top-case.ll isel pass is not registered error
Hans Wennborg [Tue, 14 Nov 2017 23:30:28 +0000 (23:30 +0000)]
Fix switch-lower-peel-top-case.ll isel pass is not registered error

The test was doing -stop-after=isel, but that pass is actually the
AMDGPUDAGToDAGISel pass, which might not be built when targeting x86_64.
This changes the test to -stop-after=expand-isel-pseudos instead.

Follow-up to r318202.

llvm-svn: 318220

6 years agoUpdate xcode project file to track ArchSpec.cpp
Jason Molenda [Tue, 14 Nov 2017 23:15:35 +0000 (23:15 +0000)]
Update xcode project file to track ArchSpec.cpp
move and LibCxxBitset.cpp addition.

llvm-svn: 318218

6 years ago[EntryExitInstrumenter] Placate GCC, the semicolon is redundant. NFCI.
Davide Italiano [Tue, 14 Nov 2017 23:13:38 +0000 (23:13 +0000)]
[EntryExitInstrumenter] Placate GCC, the semicolon is redundant. NFCI.

llvm-svn: 318217

6 years ago[AST] Fix some Clang-tidy modernize and Include What You Use warnings; other minor...
Eugene Zelenko [Tue, 14 Nov 2017 23:13:32 +0000 (23:13 +0000)]
[AST] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).

llvm-svn: 318216

6 years ago[refactor][selection] canonicalize decl ref callee to the call expr
Alex Lorenz [Tue, 14 Nov 2017 23:10:50 +0000 (23:10 +0000)]
[refactor][selection] canonicalize decl ref callee to the call expr

We would like to extract the full call when just the callee function is
selected

llvm-svn: 318215

6 years agoTry to fix the instrument-functions tests
Hans Wennborg [Tue, 14 Nov 2017 23:10:04 +0000 (23:10 +0000)]
Try to fix the instrument-functions tests

On e.g. PPC the return value and argument were marked 'signext'. This
makes the test expectations a bit more flexible.

Follow-up to r318199.

llvm-svn: 318214

6 years ago[AMDGPU] updated PAL metadata record keys
Tim Renouf [Tue, 14 Nov 2017 23:05:36 +0000 (23:05 +0000)]
[AMDGPU] updated PAL metadata record keys

Summary: The ABI changed before specification was finalized.

Reviewers: kzhuravl, dstuttard

Subscribers: wdng, nhaehnle, yaxunl, t-tye, llvm-commits

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

llvm-svn: 318213

6 years ago[Reassociate] use dyn_cast instead of isa+cast; NFCI
Sanjay Patel [Tue, 14 Nov 2017 23:03:56 +0000 (23:03 +0000)]
[Reassociate] use dyn_cast instead of isa+cast; NFCI

llvm-svn: 318212

6 years ago[cfi-verify] Add DOT graph printing for GraphResult objects.
Mitch Phillips [Tue, 14 Nov 2017 22:43:13 +0000 (22:43 +0000)]
[cfi-verify] Add DOT graph printing for GraphResult objects.

Allows users to view GraphResult objects in a DOT directed-graph format. This feature can be turned on through the --print-graphs flag.

Also enabled pretty-printing of instructions in output. Together these features make analysis of unprotected CF instructions much easier by providing a visual control flow graph.

Reviewers: pcc

Subscribers: llvm-commits, kcc, vlad.tsyrklevich

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

llvm-svn: 318211

6 years ago[GISel]: Rework legalization algorithm for better elimination of
Aditya Nandakumar [Tue, 14 Nov 2017 22:42:19 +0000 (22:42 +0000)]
[GISel]: Rework legalization algorithm for better elimination of
artifacts along with DCE

Legalization Artifacts are all those insts that are there to make the
type system happy. Currently, the target needs to say all combinations
of extends and truncs are legal and there's no way of verifying that
post legalization, we only have *truly* legal instructions. This patch
changes roughly the legalization algorithm to process all illegal insts
at one go, and then process all truncs/extends that were added to
satisfy the type constraints separately trying to combine trivial cases
until they converge. This has the added benefit that, the target
legalizerinfo can only say which truncs and extends are okay and the
artifact combiner would combine away other exts and truncs.

Updated legalization algorithm to roughly the following pseudo code.

WorkList Insts, Artifacts;
collect_all_insts_and_artifacts(Insts, Artifacts);

do {
  for (Inst in Insts)
         legalizeInstrStep(Inst, Insts, Artifacts);
  for (Artifact in Artifacts)
         tryCombineArtifact(Artifact, Insts, Artifacts);
} while(!Insts.empty());

Also, wrote a simple wrapper equivalent to SetVector, except for
erasing, it avoids moving all elements over by one and instead just
nulls them out.

llvm-svn: 318210

6 years agoCMake: Turn LLVM_ENABLE_LIBXML2 into a tri-state option
Hans Wennborg [Tue, 14 Nov 2017 22:32:49 +0000 (22:32 +0000)]
CMake: Turn LLVM_ENABLE_LIBXML2 into a tri-state option

In addition to the current ON and OFF options, this adds the FORCE_ON
option, which causes a configuration error if libxml2 cannot be used.

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

llvm-svn: 318209

6 years agoAdd two new macros: _LIBCPP_NODISCARD_AFTER_CXX17 and _LIBCPP_CONSTEXPR_AFTER_CXX17...
Marshall Clow [Tue, 14 Nov 2017 22:26:50 +0000 (22:26 +0000)]
Add two new macros: _LIBCPP_NODISCARD_AFTER_CXX17 and _LIBCPP_CONSTEXPR_AFTER_CXX17, along with a way to turn off the NODISCARD one: _LIBCPP_DISABLE_NODISCARD_AFTER_CXX17. No one is using these yet, but we will be ... soon

llvm-svn: 318208

6 years agoReland "[mips][mt][6/7] Add support for mftr, mttr instructions."
Simon Dardis [Tue, 14 Nov 2017 22:26:42 +0000 (22:26 +0000)]
Reland "[mips][mt][6/7] Add support for mftr, mttr instructions."

This adjusts the tests to hopfully pacify the
llvm-clang-x86_64-expensive-checks-win buildbot.

Unlike many other instructions, these instructions have aliases which
take coprocessor registers, gpr register, accumulator (and dsp accumulator)
registers, floating point registers, floating point control registers and
coprocessor 2 data and control operands.

For the moment, these aliases are treated as pseudo instructions which are
expanded into the underlying instruction. As a result, disassembling these
instructions shows the underlying instruction and not the alias.

Reviewers: slthakur, atanasyan

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

llvm-svn: 318207

6 years ago[CodeGen] Fix the test case added in r318202
Rong Xu [Tue, 14 Nov 2017 22:08:37 +0000 (22:08 +0000)]
[CodeGen] Fix the test case added in r318202

Add the -mtriple option to filter some platforms.

llvm-svn: 318206

6 years ago[refactor][selection] canonicalize member expr callee to the full
Alex Lorenz [Tue, 14 Nov 2017 22:06:55 +0000 (22:06 +0000)]
[refactor][selection] canonicalize member expr callee to the full
member call expression

We would like to extract the full call when just the callee is selected.

llvm-svn: 318205

6 years agonative_powr: Switch implementation to native_exp2 and native_log2
Jan Vesely [Tue, 14 Nov 2017 21:55:41 +0000 (21:55 +0000)]
native_powr: Switch implementation to native_exp2 and native_log2

v2: don't use assume
    check only for x<0, the other conditions are handled transparently
v3: don't check inputs at all, nan propagation works as expected

Reviewer: Jeroen Ketema
Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
llvm-svn: 318204

6 years agoMake salvageDebugInfo of casts work for dbg.declare and dbg.addr
Reid Kleckner [Tue, 14 Nov 2017 21:49:06 +0000 (21:49 +0000)]
Make salvageDebugInfo of casts work for dbg.declare and dbg.addr

Summary:
Instcombine (and probably other passes) sometimes want to change the
type of an alloca. To do this, they generally create a new alloca with
the desired type, create a bitcast to make the new pointer type match
the old pointer type, replace all uses with the cast, and then simplify
the casts. We already knew how to salvage dbg.value instructions when
removing casts, but we can extend it to cover dbg.addr and dbg.declare.

Fixes a debug info quality issue uncovered in Chromium in
http://crbug.com/784609

Reviewers: aprantl, vsk

Subscribers: hiraditya, llvm-commits

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

llvm-svn: 318203

6 years ago[CodeGen] Peel off the dominant case in switch statement in lowering
Rong Xu [Tue, 14 Nov 2017 21:44:09 +0000 (21:44 +0000)]
[CodeGen] Peel off the dominant case in switch statement in lowering

This patch peels off the top case in switch statement into a branch if the
probability exceeds a threshold. This will help the branch prediction and
avoids the extra compares when lowering into chain of branches.

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

llvm-svn: 318202

6 years agoFix unused variable warning.
Richard Smith [Tue, 14 Nov 2017 21:26:46 +0000 (21:26 +0000)]
Fix unused variable warning.

llvm-svn: 318201

6 years agoSwitch -mcount and -finstrument-functions to emit EnterExitInstrumenter attributes
Hans Wennborg [Tue, 14 Nov 2017 21:13:27 +0000 (21:13 +0000)]
Switch -mcount and -finstrument-functions to emit EnterExitInstrumenter attributes

This updates -mcount to use the new attribute names (LLVM r318195), and
switches over -finstrument-functions to also use these attributes rather
than inserting instrumentation in the frontend.

It also adds a new flag, -finstrument-functions-after-inlining, which
makes the cygprofile instrumentation get inserted after inlining rather
than before.

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

llvm-svn: 318199

6 years agoRename CountingFunctionInserter and use for both mcount and cygprofile calls, before...
Hans Wennborg [Tue, 14 Nov 2017 21:09:45 +0000 (21:09 +0000)]
Rename CountingFunctionInserter and use for both mcount and cygprofile calls, before and after inlining

Clang implements the -finstrument-functions flag inherited from GCC, which
inserts calls to __cyg_profile_func_{enter,exit} on function entry and exit.

This is useful for getting a trace of how the functions in a program are
executed. Normally, the calls remain even if a function is inlined into another
function, but it is useful to be able to turn this off for users who are
interested in a lower-level trace, i.e. one that reflects what functions are
called post-inlining. (We use this to generate link order files for Chromium.)

LLVM already has a pass for inserting similar instrumentation calls to
mcount(), which it does after inlining. This patch renames and extends that
pass to handle calls both to mcount and the cygprofile functions, before and/or
after inlining as controlled by function attributes.

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

llvm-svn: 318195

6 years ago[OPENMP] Fix DSA analysis for threadprivates after deserialization.
Alexey Bataev [Tue, 14 Nov 2017 21:01:01 +0000 (21:01 +0000)]
[OPENMP] Fix DSA analysis for threadprivates after deserialization.

If threadprivate vaible is deserialized, it is not marked as
threadprivate in DSAStack.

llvm-svn: 318194

6 years ago[SLPVectorizer] Failure to beneficially vectorize 'copyable' elements in integer...
Dinar Temirbulatov [Tue, 14 Nov 2017 20:55:08 +0000 (20:55 +0000)]
[SLPVectorizer] Failure to beneficially vectorize 'copyable' elements in integer binary ops.

        Patch tries to improve vectorization of the following code:

        void add1(int * __restrict dst, const int * __restrict src) {
          *dst++ = *src++;
          *dst++ = *src++ + 1;
          *dst++ = *src++ + 2;
          *dst++ = *src++ + 3;
        }
        Allows to vectorize even if the very first operation is not a binary add, but just a load.

        Fixed issues related to previous commit.

        Reviewers: spatel, mzolotukhin, mkuper, hfinkel, RKSimon, filcab, ABataev

        Reviewed By: ABataev, RKSimon

        Subscribers: llvm-commits, RKSimon

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

llvm-svn: 318193

6 years ago[llvm-objcopy] Improve command line option help messages
Jake Ehrlich [Tue, 14 Nov 2017 20:36:04 +0000 (20:36 +0000)]
[llvm-objcopy] Improve command line option help messages

I was being inconsistent with the way I was capitalizing help messages
for command line options. Additionally --remove-section wasn't using
value_desc even though it benefited from it.

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

llvm-svn: 318190

6 years agoAMDGPU: Error on stack size overflow
Matt Arsenault [Tue, 14 Nov 2017 20:33:14 +0000 (20:33 +0000)]
AMDGPU: Error on stack size overflow

llvm-svn: 318189

6 years ago[SystemZ] Do not crash when selecting an OR of two constants
Ulrich Weigand [Tue, 14 Nov 2017 20:00:34 +0000 (20:00 +0000)]
[SystemZ] Do not crash when selecting an OR of two constants

In rare cases, common code will attempt to select an OR of two
constants.  This confuses the logic in splitLargeImmediate,
causing an internal error during isel.  Fixed by simply leaving
this case to common code to handle.

This fixes PR34859.

llvm-svn: 318187

6 years ago[AArch64] Adjust the cost model for Exynos M1 and M2
Evandro Menezes [Tue, 14 Nov 2017 19:59:43 +0000 (19:59 +0000)]
[AArch64] Adjust the cost model for Exynos M1 and M2

Fix the modeling of loads and stores of registers pairs.

llvm-svn: 318186

6 years ago[llvm-strings] Add support for the -a/--all options
Martin Storsjo [Tue, 14 Nov 2017 19:58:36 +0000 (19:58 +0000)]
[llvm-strings] Add support for the -a/--all options

They don't actually change nay behaviour, as llvm-strings currently
checks the whole object without looking at individual sections anyway.

This allows using llvm-strings in a context that explicitly passes
the -a option.

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

llvm-svn: 318185

6 years ago[ARM, AArch64] Fix an assert message, Darwin isn't the only target supporting TLS...
Martin Storsjo [Tue, 14 Nov 2017 19:57:59 +0000 (19:57 +0000)]
[ARM, AArch64] Fix an assert message, Darwin isn't the only target supporting TLS. NFC.

llvm-svn: 318184

6 years agoSimplify irreducible loop metadata test code.
Hiroshi Yamauchi [Tue, 14 Nov 2017 19:48:59 +0000 (19:48 +0000)]
Simplify irreducible loop metadata test code.

Summary:
Shorten the irreducible loop metadata test code by removing insignificant
instructions.

Reviewers: davidxl

Reviewed By: davidxl

Subscribers: llvm-commits

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

llvm-svn: 318182

6 years ago[CodeGenPrepare] Disable div bypass when working set size is huge.
Easwaran Raman [Tue, 14 Nov 2017 19:31:51 +0000 (19:31 +0000)]
[CodeGenPrepare] Disable div bypass when working set size is huge.

Summary:
Bypass of slow divs based on operand values is currently disabled for
-Os. Do the same when profile summary is available and the working set
size of the application is huge. This is similar to how loop peeling is
guarded by hasHugeWorkingSetSize. In the div bypass case, the generated
extra code (and the extra branch) tendss to outweigh the benefits of the
bypass. This results in noticeable performance improvement on an
internal application.

Reviewers: davidxl

Subscribers: llvm-commits

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

llvm-svn: 318179

6 years ago[SystemZ] Fix invalid codegen using RISBMux on out-of-range bits
Ulrich Weigand [Tue, 14 Nov 2017 19:20:46 +0000 (19:20 +0000)]
[SystemZ] Fix invalid codegen using RISBMux on out-of-range bits

Before using the 32-bit RISBMux set of instructions we need to
verify that the input bits are actually within range of the 32-bit
instruction.  This fixer PR35289.

llvm-svn: 318177

6 years agoSet hasSideEffects=0 for TargetOpcode::{CFI_INSTRUCTION,EH_LABEL,GC_LABEL,ANNOTATION_...
Alex Bradbury [Tue, 14 Nov 2017 19:16:08 +0000 (19:16 +0000)]
Set hasSideEffects=0 for TargetOpcode::{CFI_INSTRUCTION,EH_LABEL,GC_LABEL,ANNOTATION_LABEL}

D37065 (committed as rL317674) explicitly set hasSideEffects for all
TargetOpcode::* instructions where it was inferred previously. This is a
follow-up to that patch, setting hasSideEffects=0 for CFI_INSTRUCTION,
EH_LABEL, GC_LABEL and ANNOTATION_LABEL. All LLVM tests pass after this
change.

This patch also modifies MachineInstr::isLabel returns true for a
TargetOpcode::ANNOTATION_LABEL, which ensures that an annotation label won't
be incorrectly considered safe to move.

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

llvm-svn: 318174

6 years agoMark intrinsics operating on the whole warp as IntrInaccessibleMemOnly
Artem Belevich [Tue, 14 Nov 2017 19:14:00 +0000 (19:14 +0000)]
Mark intrinsics operating on the whole warp as IntrInaccessibleMemOnly

It's needed to model the fact that they do access data from other threads in a
warp and thus can't be CSE'd.

llvm-svn: 318173

6 years ago[mips] Simplify test for 5.0.1 (NFC)
Simon Dardis [Tue, 14 Nov 2017 19:11:45 +0000 (19:11 +0000)]
[mips] Simplify test for 5.0.1 (NFC)

Simplify testing that an emergency spill slot is used when MSA
is used so that it can be included in the 5.0.1 release.

llvm-svn: 318172

6 years agoAdjust test after r318159
Adam Nemet [Tue, 14 Nov 2017 19:00:08 +0000 (19:00 +0000)]
Adjust test after r318159

llvm-svn: 318170

6 years ago[refactor][extract] avoid extracting expressions from types in functions
Alex Lorenz [Tue, 14 Nov 2017 18:59:01 +0000 (18:59 +0000)]
[refactor][extract] avoid extracting expressions from types in functions

llvm-svn: 318169

6 years ago[llvm-objcopy] Add -strip-non-alloc option to remove all non-allocated sections
Jake Ehrlich [Tue, 14 Nov 2017 18:50:24 +0000 (18:50 +0000)]
[llvm-objcopy] Add -strip-non-alloc option to remove all non-allocated sections

This change adds a new flag not present in GNU objcopy that we call
--strip-non-alloc.

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

llvm-svn: 318168

6 years agoCodeGen: Fix TargetLowering::LowerCallTo for sret value type
Yaxun Liu [Tue, 14 Nov 2017 18:46:52 +0000 (18:46 +0000)]
CodeGen: Fix TargetLowering::LowerCallTo for sret value type

TargetLowering::LowerCallTo assumes that sret value type corresponds to a
pointer in default address space, which is incorrect, since sret value type
should correspond to a pointer in alloca address space, which may not
be the default address space. This causes assertion for amdgcn target
in amdgiz environment.

This patch fixes that.

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

llvm-svn: 318167

6 years ago[llvm-objcopy] Support the rest of the ELF formats
Jake Ehrlich [Tue, 14 Nov 2017 18:41:47 +0000 (18:41 +0000)]
[llvm-objcopy] Support the rest of the ELF formats

We haven't been supporting anything but ELF64LE since the start. Luckily
this was always accounted for and the change is pretty trivial. B35281
requests this change for ELF32LE. This change adds support for ELF32LE,
ELF64BE, and ELF32BE with all supported features that already existed
for ELF64LE.

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

llvm-svn: 318166