platform/upstream/llvm.git
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

6 years ago[PredicateInfo] Stable sort ValueDFS to remove non-deterministic ordering
Mandeep Singh Grang [Tue, 14 Nov 2017 18:22:50 +0000 (18:22 +0000)]
[PredicateInfo] Stable sort ValueDFS to remove non-deterministic ordering

Summary: This fixes failure in Transforms/Util/PredicateInfo/testandor.ll uncovered by D39245.

Reviewers: dberlin

Reviewed By: dberlin

Subscribers: llvm-commits

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

llvm-svn: 318165

6 years agoAdd check for self-assignment. NFC
Don Hinton [Tue, 14 Nov 2017 18:19:41 +0000 (18:19 +0000)]
Add check for self-assignment.  NFC

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

llvm-svn: 318164

6 years ago[XRay] Stable sort XRayRecord to remove non-deterministic ordering
Mandeep Singh Grang [Tue, 14 Nov 2017 18:11:08 +0000 (18:11 +0000)]
[XRay] Stable sort XRayRecord to remove non-deterministic ordering

Summary:
This fixes failure in tools/llvm-xray/X86/graph-zero-latency-calls.yaml
uncovered by D39245.

Reviewers: dberris

Reviewed By: dberris

Subscribers: llvm-commits

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

llvm-svn: 318163

6 years agoAdd missing const qualifier to AttributeSet::operator==
Serge Guelton [Tue, 14 Nov 2017 18:08:05 +0000 (18:08 +0000)]
Add missing const qualifier to AttributeSet::operator==

llvm-svn: 318162

6 years agoNote that the benchmark set has been updated.
Rafael Espindola [Tue, 14 Nov 2017 17:48:48 +0000 (17:48 +0000)]
Note that the benchmark set has been updated.

The only difference is that it now has a response file for each
variation. This allows it to be used with utils/benchmark.py.

llvm-svn: 318161

6 years agoAdjust test after r318159
Adam Nemet [Tue, 14 Nov 2017 17:12:36 +0000 (17:12 +0000)]
Adjust test after r318159

llvm-svn: 318160

6 years ago[llvm-profdata] Report if profile data file is IR- or FE-level
Adam Nemet [Tue, 14 Nov 2017 16:59:18 +0000 (16:59 +0000)]
[llvm-profdata] Report if profile data file is IR- or FE-level

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

llvm-svn: 318159

6 years agoAdd a script to run various benchmarks and send the result to lnt.
Rafael Espindola [Tue, 14 Nov 2017 16:40:30 +0000 (16:40 +0000)]
Add a script to run various benchmarks and send the result to lnt.

Lnt is both a server and a set of script for benchmarking llvm.

I don't think it makes sense to use the scripts for lld since our
benchmarks are quite different.

The server on the other hand is very general and seems to work well
for tracking any quantities.

This patch adds a script to lld that can be used to run various
benchmarks and send the result to lnt.

The benchmarks are assumed to each be a response file in a
subdirectory. Each subdirectory can contain multiple response
files. That can be used to have a plain response.txt and a
response-icf.txt for example. The name of each benchmark is the
combination of the directory name and the "flavor": firefox-gc,
chromium-icf, etc.

For the first version the script uses perf and collects all the
metrics that a plain "perf stat" prints.

This script can then be used by a developer to test a patch or by a
bot to keep track of lld's performance.

llvm-svn: 318158

6 years ago[scudo] Simplify initialization and flags
Kostya Kortchinsky [Tue, 14 Nov 2017 16:14:53 +0000 (16:14 +0000)]
[scudo] Simplify initialization and flags

Summary:
This is mostly some cleanup and shouldn't affect functionalities.

Reviewing some code for a future addition, I realized that the complexity of
the initialization path was unnecessary, and so was maintaining a structure
for the allocator options throughout the initialization.

So we get rid of that structure, of an extraneous level of nesting for the
`init` function, and correct a couple of related code inaccuracies in the
flags cpp.

Reviewers: alekseyshl

Reviewed By: alekseyshl

Subscribers: llvm-commits

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

llvm-svn: 318157

6 years ago[X86] Fix typo in comment. NFC
Craig Topper [Tue, 14 Nov 2017 16:14:00 +0000 (16:14 +0000)]
[X86] Fix typo in comment. NFC

llvm-svn: 318156

6 years ago[Docs] Add tablegen backend for target opcode documentation
Oliver Stannard [Tue, 14 Nov 2017 15:35:15 +0000 (15:35 +0000)]
[Docs] Add tablegen backend for target opcode documentation

This is a tablegen backend to generate documentation for the opcodes that exist
for each target. For each opcode, it lists the assembly string, the names and
types of all operands, and the flags and predicates that apply to the opcode.

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

llvm-svn: 318155

6 years ago[tooling] Make compile_flags.txt negative test more hermetic
Sam McCall [Tue, 14 Nov 2017 15:22:34 +0000 (15:22 +0000)]
[tooling] Make compile_flags.txt negative test more hermetic

llvm-svn: 318154

6 years agoUse input redirection in WebAssembly/comdat.ll test.
Ilya Biryukov [Tue, 14 Nov 2017 14:26:42 +0000 (14:26 +0000)]
Use input redirection in WebAssembly/comdat.ll test.

To match how the other tests do it.

llvm-svn: 318153

6 years agoMake isDefinition matcher support ObjCMethodDecl
Dave Lee [Tue, 14 Nov 2017 14:17:26 +0000 (14:17 +0000)]
Make isDefinition matcher support ObjCMethodDecl

Summary:
Allow the `isDefinition()` matcher to apply to `ObjCMethodDecl` nodes, in
addition to those it already supports. For whatever reason, `ObjCMethodDecl`
does not inherit from `FunctionDecl` and so this is specialization is necessary.

Reviewers: aaron.ballman, malcolm.parsons, alexshap

Reviewed By: aaron.ballman

Subscribers: cfe-commits, klimek

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

llvm-svn: 318152

6 years ago[X86][AVX] Add scheduling test for vmovntdq 256-bit store
Simon Pilgrim [Tue, 14 Nov 2017 14:03:29 +0000 (14:03 +0000)]
[X86][AVX] Add scheduling test for vmovntdq 256-bit store

Needs to use inline asm as domain will otherwise be changed to float (vmovntps)

llvm-svn: 318151

6 years agoMake DiagnosticIDs::getAllDiagnostics static. NFC.
Gabor Horvath [Tue, 14 Nov 2017 12:14:49 +0000 (12:14 +0000)]
Make DiagnosticIDs::getAllDiagnostics static. NFC.

Patch by: Andras Leitereg!

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

llvm-svn: 318150

6 years ago[LV] Introduce VPBlendRecipe, VPWidenMemoryInstructionRecipe
Gil Rapaport [Tue, 14 Nov 2017 12:09:30 +0000 (12:09 +0000)]
[LV] Introduce VPBlendRecipe, VPWidenMemoryInstructionRecipe

This patch is part of D38676.

The patch introduces two new Recipes to handle instructions whose vectorization
involves masking. These Recipes take VPlan-level masks in D38676, but still rely
on ILV's existing createEdgeMask(), createBlockInMask() in this patch.

VPBlendRecipe handles intra-loop phi nodes, which are vectorized as a sequence
of SELECTs. Its execute() code is refactored out of ILV::widenPHIInstruction(),
which now handles only loop-header phi nodes.

VPWidenMemoryInstructionRecipe handles load/store which are to be widened
(but are not part of an Interleave Group). In this patch it simply calls
ILV::vectorizeMemoryInstruction on execute().

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

llvm-svn: 318149

6 years agoARM: correctly update CFG when splitting BB to fix branch.
Tim Northover [Tue, 14 Nov 2017 11:43:54 +0000 (11:43 +0000)]
ARM: correctly update CFG when splitting BB to fix branch.

Because the block-splitting code is multi-purpose, we have to meddle with the
branches when using it to fixup a conditional branch destination. We got the
code right, but forgot to update the CFG so the verifier complained when
expensive checks were on.

Probably harmless since constant-islands comes so late, but best to fix it
anyway.

llvm-svn: 318148

6 years ago[ASTImporter] TypeAliasTemplate and PackExpansion importing capability
Gabor Horvath [Tue, 14 Nov 2017 11:30:38 +0000 (11:30 +0000)]
[ASTImporter] TypeAliasTemplate and PackExpansion importing capability

Patch by: Zoltan Gera!

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

llvm-svn: 318147

6 years ago[ARM GlobalISel] Remove C++ code for G_CONSTANT
Diana Picus [Tue, 14 Nov 2017 11:20:32 +0000 (11:20 +0000)]
[ARM GlobalISel] Remove C++ code for G_CONSTANT

Get rid of the handwritten instruction selector code for handling
G_CONSTANT. This code wasn't checking all the preconditions correctly
anyway, so it's better to leave it to TableGen, which can handle at
least some cases correctly (e.g. MOVi, MOVi16, folding into binary
operations). Also add tests to cover those cases.

llvm-svn: 318146

6 years agoAdd a data formatter for libc++ std::bitset
Pavel Labath [Tue, 14 Nov 2017 11:15:03 +0000 (11:15 +0000)]
Add a data formatter for libc++ std::bitset

Reviewers: jingham, EricWF

Subscribers: mgorny, lldb-commits

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

llvm-svn: 318145

6 years agoRename identifiers named `__output`
Alexander Richardson [Tue, 14 Nov 2017 11:14:25 +0000 (11:14 +0000)]
Rename identifiers named `__output`

Summary:
In the CHERI clang compiler __output and __input are keywords and therefore
we can't compile libc++ with our compiler.

Reviewers: mclow.lists, EricWF, theraven

Reviewed By: EricWF

Subscribers: cfe-commits

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

llvm-svn: 318144

6 years ago[ARM] Fix incorrect conversion of a tail call to an ordinary call
Momchil Velikov [Tue, 14 Nov 2017 10:36:52 +0000 (10:36 +0000)]
[ARM] Fix incorrect conversion of a tail call to an ordinary call

When we emit a tail call for Armv8-M, but then discover that the caller needs to
save/restore `LR`, we convert the tail call to an ordinary one, since restoring
`LR` takes extra instructions, which may negate the benefits of the tail
call. If the callee, however, takes stack arguments, this conversion is
incorrect, since nothing has been done to pass the stack arguments.

Thus the patch reverts https://reviews.llvm.org/rL294000

Also, we improve the instruction sequence for popping `LR` in the case when we
couldn't immediately find a scratch low register, but we can use as a temporary
one of the callee-saved low registers and restore `LR` before popping other
callee-saves.

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

llvm-svn: 318143

6 years ago[libclang] Allow crash recovery with LIBCLANG_NOTHREADS
Erik Verbruggen [Tue, 14 Nov 2017 09:34:39 +0000 (09:34 +0000)]
[libclang] Allow crash recovery with LIBCLANG_NOTHREADS

Enabled crash recovery for some libclang operations on a calling thread even
when LIBCLANG_NOTHREAD is specified.

Previously it would only run under crash recovery if LIBCLANG_NOTHREAD is not
set. Moved handling of LIBCLANG_NOTHREAD env variable into RunSafely from its
call sites.

llvm-svn: 318142

6 years agoRefactor ContinuationIndenter's breakProtrudingToken logic.
Manuel Klimek [Tue, 14 Nov 2017 09:19:53 +0000 (09:19 +0000)]
Refactor ContinuationIndenter's breakProtrudingToken logic.

Create more orthogonal pieces. The restructuring made it easy to try out
several alternatives to D33589, and while none of the alternatives
turned out to be the right solution, the underlying simplification of
the structure is helpful.

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

llvm-svn: 318141

6 years ago[NewPassManager] Pass the -fdebug-pass-manager flag setting into the Analysis manager...
Craig Topper [Tue, 14 Nov 2017 08:48:28 +0000 (08:48 +0000)]
[NewPassManager] Pass the -fdebug-pass-manager flag setting into the Analysis managers to match what we do in opt

Summary: Currently the -fdebug-pass-manager flag for clang doesn't enable the debug logging in the analysis managers. This is different than what the switch does when passed to opt.

Reviewers: chandlerc

Reviewed By: chandlerc

Subscribers: cfe-commits

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

llvm-svn: 318140

6 years ago[builtins] Include GENERIC_SOURCES in arm_SOURCES for MinGW
Martin Storsjo [Tue, 14 Nov 2017 07:07:01 +0000 (07:07 +0000)]
[builtins] Include GENERIC_SOURCES in arm_SOURCES for MinGW

It is included in the built sources for all other arches supported
for MinGW currently, except for arm.

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

llvm-svn: 318139

6 years agoAMDGPU: Fix test
Matt Arsenault [Tue, 14 Nov 2017 06:40:00 +0000 (06:40 +0000)]
AMDGPU: Fix test

llvm-svn: 318138

6 years ago[PM] Require a registered x86 target for this test which uses the x86
Chandler Carruth [Tue, 14 Nov 2017 05:20:03 +0000 (05:20 +0000)]
[PM] Require a registered x86 target for this test which uses the x86
triple.

llvm-svn: 318137

6 years ago[opt-viewer] Truncate long remark text in source view
Adam Nemet [Tue, 14 Nov 2017 04:48:18 +0000 (04:48 +0000)]
[opt-viewer] Truncate long remark text in source view

The table is changed to fixed layout[1] and the lines use ellipses if they
would overflow their cell.

[1] https://css-tricks.com/fixing-tables-long-strings/

llvm-svn: 318136

6 years ago[opt-viewer] With hotness only show max 1000 entries on the index page
Adam Nemet [Tue, 14 Nov 2017 04:37:32 +0000 (04:37 +0000)]
[opt-viewer] With hotness only show max 1000 entries on the index page

Adjustable with an option.

llvm-svn: 318135

6 years ago[AVR] Remove the select-mbb-placement-bug.ll test
Dylan McKay [Tue, 14 Nov 2017 04:32:49 +0000 (04:32 +0000)]
[AVR] Remove the select-mbb-placement-bug.ll test

This test was originally added when an old bug was fixed that caused
broken iterator code to break basic block placement.

The issue has an extremely low chance of every being a problem again.

This specific test is very flaky and fails often due to upstream
changes.

I have removed this test because it negates more value than it returns.

llvm-svn: 318134

6 years agoAMDGPU: Fix producing saveexec when the copy is spilled
Matt Arsenault [Tue, 14 Nov 2017 02:16:54 +0000 (02:16 +0000)]
AMDGPU: Fix producing saveexec when the copy is spilled

If the register from the copy from exec was spilled,
the copy before the spill was deleted leaving a spill
of undefined register verifier error and miscompiling.
Check for other use instructions of the copy register.

llvm-svn: 318132

6 years ago[PM] Wire up support for the bounds checking sanitizer with the new PM.
Chandler Carruth [Tue, 14 Nov 2017 01:59:18 +0000 (01:59 +0000)]
[PM] Wire up support for the bounds checking sanitizer with the new PM.

Not much interesting here. Mostly wiring things together.

One thing worth noting is that the approach is substantially different
from the old PM. Here, the -O0 case works fundamentally differently in
that we just directly build the pipeline without any callbacks or other
cruft. In some ways, this is nice and clean. However, I don't like that
it causes the sanitizers to be enabled with different changes at
different times. =/ Suggestions for a better way to do this are welcome.

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

llvm-svn: 318131

6 years ago[PM] Add a missing header that I had in the next commit but was needed
Chandler Carruth [Tue, 14 Nov 2017 01:47:24 +0000 (01:47 +0000)]
[PM] Add a missing header that I had in the next commit but was needed
in r318128. Should fix the build.

llvm-svn: 318130

6 years ago[completion] complete ObjC interface names in an expression
Alex Lorenz [Tue, 14 Nov 2017 01:46:24 +0000 (01:46 +0000)]
[completion] complete ObjC interface names in an expression

Objective-C interfaces can be used in a class property expression.

rdar://26982192

llvm-svn: 318129

6 years ago[PM] Port BoundsChecking to the new PM.
Chandler Carruth [Tue, 14 Nov 2017 01:30:04 +0000 (01:30 +0000)]
[PM] Port BoundsChecking to the new PM.

Registers it and everything, updates all the references, etc.

Next patch will add support to Clang's `-fexperimental-new-pass-manager`
path to actually enable BoundsChecking correctly.

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

llvm-svn: 318128

6 years agoUse TempFile in llvm-ar. NFC.
Rafael Espindola [Tue, 14 Nov 2017 01:21:15 +0000 (01:21 +0000)]
Use TempFile in llvm-ar. NFC.

llvm-svn: 318127

6 years agoAnother test for LWG2952
Marshall Clow [Tue, 14 Nov 2017 01:18:36 +0000 (01:18 +0000)]
Another test for LWG2952

llvm-svn: 318126

6 years agoImplement LWG2950: std::byte operations are misspecified
Marshall Clow [Tue, 14 Nov 2017 01:14:53 +0000 (01:14 +0000)]
Implement LWG2950: std::byte operations are misspecified

llvm-svn: 318125

6 years ago[PM] Refactor BoundsChecking further to prepare it to be exposed both as
Chandler Carruth [Tue, 14 Nov 2017 01:13:59 +0000 (01:13 +0000)]
[PM] Refactor BoundsChecking further to prepare it to be exposed both as
a legacy and new PM pass.

This essentially moves the class state to parameters and re-shuffles the
code to make that reasonable. It also does some minor cleanups along the
way and leaves some comments.

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

llvm-svn: 318124

6 years ago[WebAssembly] Explicily disable comdat support for wasm output
Sam Clegg [Tue, 14 Nov 2017 00:49:16 +0000 (00:49 +0000)]
[WebAssembly] Explicily disable comdat support for wasm output

For now at least.  We clearly need some kind of comdat or
linkonce_odr support for wasm but currently COMDAT is not
supported.

Disable COMDAT support in the same way we do the Mach-O.  This
also causes clang not to generated COMDATs.

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

llvm-svn: 318123

6 years agoAdd a move assignment operator to TempFile. NFC.
Rafael Espindola [Tue, 14 Nov 2017 00:31:28 +0000 (00:31 +0000)]
Add a move assignment operator to TempFile. NFC.

llvm-svn: 318122

6 years ago[Sema] Stable sort OverloadCandidates to remove non-deterministic ordering
Mandeep Singh Grang [Tue, 14 Nov 2017 00:22:24 +0000 (00:22 +0000)]
[Sema] Stable sort OverloadCandidates to remove non-deterministic ordering

Summary: This fixes failure in Misc/diag-template-diffing.cpp uncovered by D39245.

Reviewers: rjmccall, rsmith

Reviewed By: rjmccall

Subscribers: cfe-commits

Tags: #clang

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

llvm-svn: 318121