platform/upstream/llvm.git
7 years agoRevert "[SCCP] Fix mem-sanitizer failure introduced by r315288."
Bruno Cardoso Lopes [Tue, 10 Oct 2017 16:37:51 +0000 (16:37 +0000)]
Revert "[SCCP] Fix mem-sanitizer failure introduced by r315288."

This reverts commit r315294. Part of fixing seg fault introduced in:
http://green.lab.llvm.org/green/job/clang-stage2-configure-Rlto/21675/

llvm-svn: 315328

7 years ago[MC] Thread unique_ptr<MCObjectWriter> through the create.*ObjectWriter
Lang Hames [Tue, 10 Oct 2017 16:28:07 +0000 (16:28 +0000)]
[MC] Thread unique_ptr<MCObjectWriter> through the create.*ObjectWriter
functions.

This makes the ownership of the resulting MCObjectWriter clear, and allows us
to remove one instance of MCObjectStreamer's bizarre "holding ownership via
someone else's reference" trick.

llvm-svn: 315327

7 years ago[WebAssembly] Narrow the scope of WebAssemblyFixFunctionBitcasts
Jacob Gravelle [Tue, 10 Oct 2017 16:20:18 +0000 (16:20 +0000)]
[WebAssembly] Narrow the scope of WebAssemblyFixFunctionBitcasts

Summary:
The pass to fix function bitcasts generates thunks for functions that
are called directly with a mismatching signature. It was also generating
thunks in cases where the function was address-taken, causing aliasing
problems in otherwise valid cases.
This patch tightens the restrictions for when the pass runs.

Reviewers: sunfish, dschuff

Subscribers: jfb, sbc100, llvm-commits, aheejin

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

llvm-svn: 315326

7 years ago[clangd] Use UniqueFunction for deferred computations.
Ilya Biryukov [Tue, 10 Oct 2017 16:12:54 +0000 (16:12 +0000)]
[clangd] Use UniqueFunction for deferred computations.

Previsouly, `std::future` that were results of
`std::async(std::launch::deferred, ...` were used.

llvm-svn: 315325

7 years ago[clangd] Added missing #includes to Function.h
Ilya Biryukov [Tue, 10 Oct 2017 16:12:50 +0000 (16:12 +0000)]
[clangd] Added missing #includes to Function.h

llvm-svn: 315324

7 years ago[clangd] Added forgotten return in UniqueFunction.
Ilya Biryukov [Tue, 10 Oct 2017 16:12:47 +0000 (16:12 +0000)]
[clangd] Added forgotten return in UniqueFunction.

This hasn't bitten us because we only used functions returning
'void'.

llvm-svn: 315323

7 years ago[X86][AVX512] Regenerate element insertion/extraction tests
Simon Pilgrim [Tue, 10 Oct 2017 15:58:54 +0000 (15:58 +0000)]
[X86][AVX512] Regenerate element insertion/extraction tests

llvm-svn: 315322

7 years ago[TableGen] Convert VarDef to range_loop. NFC.
Javed Absar [Tue, 10 Oct 2017 15:58:45 +0000 (15:58 +0000)]
[TableGen] Convert VarDef to range_loop. NFC.

llvm-svn: 315321

7 years ago[sanitizer] Revert D38706
Kostya Kortchinsky [Tue, 10 Oct 2017 15:35:11 +0000 (15:35 +0000)]
[sanitizer] Revert D38706

Summary:
D38706 breaks tsan and the nolibc build.
Reverting while working on a fix.

Reviewers: alekseyshl

Subscribers: kubamracek, mgorny, llvm-commits

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

llvm-svn: 315320

7 years ago[sanitizer] Move the errno/ENOMEM allocator checks logic to separate .cc
Kostya Kortchinsky [Tue, 10 Oct 2017 14:58:09 +0000 (14:58 +0000)]
[sanitizer] Move the errno/ENOMEM allocator checks logic to separate .cc

Summary:
The fact that `sanitizer_allocator_checks.h` is including `sanitizer_errno.h`
creates complications for future changes, where it would conflict with `errno.h`
definitions on Android and Fuchsia (macro redefinition).

By moving the portion that sets errno in the checks to a separate compilation
unit, we avoid the inclusion of the header there, which solves the issue.

Not that it is not vital to have that function in a header as it is called as a
result of an unlikely event, and doesn't need to be inlined.

Reviewers: alekseyshl

Reviewed By: alekseyshl

Subscribers: kubamracek, llvm-commits, mgorny

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

llvm-svn: 315319

7 years ago[mips] Duplicate the reciprocal instruction definitions for FP32
Simon Dardis [Tue, 10 Oct 2017 14:41:11 +0000 (14:41 +0000)]
[mips] Duplicate the reciprocal instruction definitions for FP32

Add instruction definitions for FP32 mode for recip.d and rsqrt.d.

Previously these instructions were only defined when targeting the
full 64-bit FPU model but were not guarded properly.

Reviewers: nitesh.jain, atanasyan

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

llvm-svn: 315318

7 years ago[clangd] clang-format the source code. NFC.
Ilya Biryukov [Tue, 10 Oct 2017 14:21:04 +0000 (14:21 +0000)]
[clangd] clang-format the source code. NFC.

llvm-svn: 315317

7 years agoRe-land "[llvm-dwarfdump] Print type names in DW_AT_type DIEs"
Jonas Devlieghere [Tue, 10 Oct 2017 14:15:25 +0000 (14:15 +0000)]
Re-land "[llvm-dwarfdump] Print type names in DW_AT_type DIEs"

This patch adds printing for DW_AT_type DIEs like it is already the case
for DW_AT_specification DIEs. This is a rather naive approach and only a
start. We should have pretty printers for different languages.

Recommit after being reverted in r315299.

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

llvm-svn: 315316

7 years ago[OPENMP] Add default codegen|tests for 'target parallel for[ simd]'
Alexey Bataev [Tue, 10 Oct 2017 14:14:43 +0000 (14:14 +0000)]
[OPENMP] Add default codegen|tests for 'target parallel for[ simd]'
constructs.

Added default codegen for 'target parallel for' construct + tests for
default codegen of 'target parallel for[ simd]' constructs.

llvm-svn: 315315

7 years agoFix a (slightly weird) 'comma operator within array index expression' warning on...
Simon Pilgrim [Tue, 10 Oct 2017 13:56:17 +0000 (13:56 +0000)]
Fix a (slightly weird) 'comma operator within array index expression' warning on VS builds. NFCI.

llvm-svn: 315314

7 years ago[PowerPC] Add missing record form instructions to the P9 Scheduling Model
Stefan Pintilie [Tue, 10 Oct 2017 13:45:35 +0000 (13:45 +0000)]
[PowerPC] Add missing record form instructions to the P9 Scheduling Model

A number of record form instructions were missing from the P9 scheduling
model. Added those instructions and marked the P9 model as complete.

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

llvm-svn: 315313

7 years ago[x86] add tests for insertelement; NFC
Sanjay Patel [Tue, 10 Oct 2017 13:45:25 +0000 (13:45 +0000)]
[x86] add tests for insertelement; NFC

llvm-svn: 315312

7 years agoafter fixing the i386 case
Uriel Korach [Tue, 10 Oct 2017 13:43:09 +0000 (13:43 +0000)]
after fixing the i386 case

Change-Id: If6fe0b6ec01f111115fb734fe31c0e152dbc165f
llvm-svn: 315311

7 years ago[mips] Partially fix PR34391
Simon Dardis [Tue, 10 Oct 2017 13:34:45 +0000 (13:34 +0000)]
[mips] Partially fix PR34391

Previously, the parsing of the 'subu $reg, ($reg,) imm' relied on a parser
which also rendered the operand to the instruction. In some cases the
general parser could construct an MCExpr which was not a MCConstantExpr
which MipsAsmParser was expecting.

Address this by altering the special handling to cope with unexpected inputs
and fine-tune the handling of cases where an register name that is not
available in the current ABI is regarded as not a match for the custom parser
but also not as an outright error.

Also enforces the binutils restriction that only constants are accepted.

This partially resolves PR34391.

Thanks to Ed Maste for reporting the issue!

Reviewers: nitesh.jain, arichardson

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

llvm-svn: 315310

7 years agoRevert "[Modules TS] Module ownership semantics for redeclarations."
Eric Liu [Tue, 10 Oct 2017 13:09:40 +0000 (13:09 +0000)]
Revert "[Modules TS] Module ownership semantics for redeclarations."

This reverts commit r315251. See the original commit thread for reason.

llvm-svn: 315309

7 years agoRevert "[Modules TS] Avoid computing the linkage of the enclosing DeclContext for...
Eric Liu [Tue, 10 Oct 2017 13:00:18 +0000 (13:00 +0000)]
Revert "[Modules TS] Avoid computing the linkage of the enclosing DeclContext for a declaration in the global module."

This reverts commit r315256. See the original commit thread for reason.

llvm-svn: 315308

7 years ago[DAGCombine] Fix for shuffle to vector extend for non power 2 vectors
David Stuttard [Tue, 10 Oct 2017 12:45:45 +0000 (12:45 +0000)]
[DAGCombine] Fix for shuffle to vector extend for non power 2 vectors

Summary:
See https://llvm.org/PR33743 for more details

It seems that for non-power of 2 vector sizes, the algorithm can produce
non-matching sizes for input and result causing an assert.

This usually isn't a problem as the isAnyExtend check will weed these out, but
in some cases (most often with lots of undefined values for the mask indices) it
can pass this check for non power of 2 vectors.

Adding in an extra check that ensures that bit size will match for the result
and input (as required)

Subscribers: nhaehnle

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

llvm-svn: 315307

7 years ago[XRay][compiler-rt] Fix rdtscp support check for x86_64
Dean Michael Berris [Tue, 10 Oct 2017 12:44:20 +0000 (12:44 +0000)]
[XRay][compiler-rt] Fix rdtscp support check for x86_64

Follow-up to D29438.

llvm-svn: 315306

7 years ago[ARM, Asm] Harden GNU LDRD/STRD aliases against invalid inputs
Oliver Stannard [Tue, 10 Oct 2017 12:38:22 +0000 (12:38 +0000)]
[ARM, Asm] Harden GNU LDRD/STRD aliases against invalid inputs

Previously, the code that implemented the GNU assembler aliases for the
LDRD and STRD instructions (where the second register is omitted)
assumed that the input was a valid instruction. This caused assertion
failures for every example in ldrd-strd-gnu-bad-inst.s.

This improves this code so that it bails out if the instruction is not
in the expected format, the check bails out, and the asm parser is run
on the unmodified instruction.

It also relaxes the alias on thumb targets, so that unaligned pairs of
registers can be used. The restriction that Rt must be even-numbered
only applies to the ARM versions of these instructions.

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

llvm-svn: 315305

7 years ago[ARM, Asm] Add diagnostics for floating-point register operands
Oliver Stannard [Tue, 10 Oct 2017 12:35:09 +0000 (12:35 +0000)]
[ARM, Asm] Add diagnostics for floating-point register operands

This adds diagnostic strings for the ARM floating-point register
classes, which will be used when these classes are expected by the
assembler, but the provided operand is not valid.

One of these, DPR, requires C++ code to select the correct error
message, as that class contains different registers depending on the
FPU. The rest can all have their diagnostic strings stored in the
tablegen decription of them.

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

llvm-svn: 315304

7 years ago[ARM, Asm] Add diagnostics for general-purpose register operands
Oliver Stannard [Tue, 10 Oct 2017 12:31:53 +0000 (12:31 +0000)]
[ARM, Asm] Add diagnostics for general-purpose register operands

This adds diagnostic strings for the ARM general-purpose register
classes, which will be used when these classes are expected by the
assembler, but the provided operand is not valid.

One of these, rGPR, requires C++ code to select the correct error
message, as that class contains different registers in pre-v8 and v8
targets. The rest can all have their diagnostic strings stored in the
tablegen description of them.

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

llvm-svn: 315303

7 years agoAMDGPU: Split MUBUF offset into aligned components
Nicolai Haehnle [Tue, 10 Oct 2017 12:22:23 +0000 (12:22 +0000)]
AMDGPU: Split MUBUF offset into aligned components

Summary:
Atomic buffer operations do not work (and trap on gfx9) when the
components are unaligned, even if their sum is aligned.

Previously, we generated an offset of 4156 without an SGPR by
splitting it as 4095 + 61 (immediate + inline constant). The
highest offset for which we can do this correctly is 4156 = 4092 + 64.

Fixes dEQP-GLES31.functional.ssbo.atomic.*

Reviewers: arsenm

Subscribers: kzhuravl, wdng, yaxunl, dstuttard, tpr, llvm-commits, t-tye

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

llvm-svn: 315302

7 years ago[analyzer] MisusedMovedObject: Fix state-resetting a base-class sub-object.
Artem Dergachev [Tue, 10 Oct 2017 11:55:56 +0000 (11:55 +0000)]
[analyzer] MisusedMovedObject: Fix state-resetting a base-class sub-object.

If a method is resetting the state of an object that was moved from, it should
be safe to use this object again. However if the method was defined in a parent
class, but used in a child class, the reset didn't happen from the checker's
perspective.

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

llvm-svn: 315301

7 years ago[analyzer] MisusedMovedObject: Add printState() method for self-debugging.
Artem Dergachev [Tue, 10 Oct 2017 11:50:45 +0000 (11:50 +0000)]
[analyzer] MisusedMovedObject: Add printState() method for self-debugging.

This method injects additional information into program state dumps,
describing which objects have been moved from.

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

llvm-svn: 315300

7 years agoRevert "[llvm-dwarfdump] Print type names in DW_AT_type DIEs"
Jonas Devlieghere [Tue, 10 Oct 2017 11:49:56 +0000 (11:49 +0000)]
Revert "[llvm-dwarfdump] Print type names in DW_AT_type DIEs"

This reverts commit r315297.

llvm-svn: 315299

7 years ago[analyzer] PthreadLockChecker: Add printState() method for self-debugging.
Artem Dergachev [Tue, 10 Oct 2017 11:49:09 +0000 (11:49 +0000)]
[analyzer] PthreadLockChecker: Add printState() method for self-debugging.

This method injects additional information into program state dumps,
describing states of mutexes tracked by the checker.

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

llvm-svn: 315298

7 years ago[llvm-dwarfdump] Print type names in DW_AT_type DIEs
Jonas Devlieghere [Tue, 10 Oct 2017 11:24:41 +0000 (11:24 +0000)]
[llvm-dwarfdump] Print type names in DW_AT_type DIEs

This patch adds printing for DW_AT_type DIEs like it is already the case
for DW_AT_specification DIEs. This is a rather naive approach and only a
start. We should have pretty printers for different languages.

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

llvm-svn: 315297

7 years ago[analyzer] Implement pointer arithmetic on constants
Gabor Horvath [Tue, 10 Oct 2017 11:01:49 +0000 (11:01 +0000)]
[analyzer] Implement pointer arithmetic on constants

Patch by: Rafael Stahl!

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

llvm-svn: 315296

7 years ago[AsmParser] Add DiagnosticString to register classes in tablegen
Oliver Stannard [Tue, 10 Oct 2017 11:00:40 +0000 (11:00 +0000)]
[AsmParser] Add DiagnosticString to register classes in tablegen

This allows a DiagnosticType and/or DiagnosticString to be associated
with a RegisterClass in tablegen, so that we can emit diagnostics in the
assembler when a register operand is incorrect.

DiagnosticType creates a predictable enum value, which gets returned as
the error code when an operand does not match, and can be used by the
assembly parser to map to a user-facing diagnostic. DiagnosticString
creates an anonymous enum value (currently based on the tablegen class
name), and a function to map from enum values to strings will be
generated. Both of these work the same was as they do for AsmOperand.

This isn't used by any targets yet, but has one (positive) side-effect.
It improves the diagnostic codes returned by validateOperandClass - we
always want to emit the diagnostic that relates to the expected operand
class, but this wasn't always being done when the expected and actual
classes were completely different (token/register/custom). This causes a
few AArch64 diagnostics to be improved, as Match_InvalidOperand was
being returned instead of a specific diagnostic type.

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

llvm-svn: 315295

7 years ago[SCCP] Fix mem-sanitizer failure introduced by r315288.
Florian Hahn [Tue, 10 Oct 2017 10:33:45 +0000 (10:33 +0000)]
[SCCP] Fix mem-sanitizer failure introduced by r315288.

llvm-svn: 315294

7 years ago[ELF] Set Dot initially to --image-base value when using linker scripts
James Henderson [Tue, 10 Oct 2017 10:09:35 +0000 (10:09 +0000)]
[ELF] Set Dot initially to --image-base value when using linker scripts

When parsing linker scripts, LLD previously started with a '.' value of 0,
regardless of the internal default image base for the target, and regardless of
switches such as --image-base. It seems reasonable to use a different image base
value when using linker scripts and --image-base is specified, since otherwise the
switch has no effect. This change does this, as well as removing unnecessary
initialisation of Dot where it is not used.

The default image base should not be used when processing linker
scripts, because this will change the behaviour for existing linker script users,
and potentially result in invalid output being produced, as a subsequent assignment
to Dot could move the location counter backwards. Instead, we maintain the existing
behaviour of starting from 0 if --image-base is not specified.

Reviewers: ruiu

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

llvm-svn: 315293

7 years ago[LLD] Fix findOrphanPos to consistently ignore "dead" OutputSection's
Andrew Ng [Tue, 10 Oct 2017 10:05:52 +0000 (10:05 +0000)]
[LLD] Fix findOrphanPos to consistently ignore "dead" OutputSection's

When findOrphanPos does the reverse search to find the OutputSection
preceding the orphan's insertion point, look for a live OutputSection
and ignore "dead" OutputSection's. This matches the behaviour of the
forward search performed earlier in this function.

Added test which without the above fix fails as a result of an orphan
executable section being incorrectly placed in a non-executable segment.

Differential Review: https://reviews.llvm.org/D38690

llvm-svn: 315292

7 years ago[X86][SKYLAKE] Update regression test to differentiate between HASWELL and SKYLAKE...
Gadi Haber [Tue, 10 Oct 2017 09:53:18 +0000 (09:53 +0000)]
[X86][SKYLAKE] Update regression test to differentiate between HASWELL and SKYLAKE scheduling.<NFC>

NFC.
Updated 6 regression tests to differentiate between HASWELL and SKYLAKE scheduling information.

The fix is in preparation of a patch to update the information of the Skylake Client scheduling to include the appropriate load and store latencies.

Reviewers: zvi, RKSimon
Differential Revision: https://reviews.llvm.org/D38685

Change-Id: Ifc6b98d9eaf266913698f24c766fd994fc977555
llvm-svn: 315291

7 years ago[clang-refactor] Fix clang-tidy misc-move-const-arg warning.
Haojian Wu [Tue, 10 Oct 2017 09:48:38 +0000 (09:48 +0000)]
[clang-refactor] Fix clang-tidy misc-move-const-arg warning.

NFC

llvm-svn: 315290

7 years ago[CodeGen] Do not construct complete LValue base info in trivial cases
Ivan A. Kosarev [Tue, 10 Oct 2017 09:39:32 +0000 (09:39 +0000)]
[CodeGen] Do not construct complete LValue base info in trivial cases

Besides obvious code simplification, avoiding explicit creation
of LValueBaseInfo objects makes it easier to make TBAA
information to be part of such objects.

This is part of D38126 reworked to be a separate patch to
simplify review.

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

llvm-svn: 315289

7 years ago[SCCP] Propagate integer range info for parameters in IPSCCP.
Florian Hahn [Tue, 10 Oct 2017 09:32:38 +0000 (09:32 +0000)]
[SCCP] Propagate integer range info for parameters in IPSCCP.

Summary:
This updates the SCCP solver to use of the ValueElement lattice for
parameters, which provides integer range information. The range
information is used to remove unneeded icmp instructions.

For the following function, f() can be optimized to `ret i32 2` with
this change

  source_filename = "sccp.c"
  target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
  target triple = "x86_64-unknown-linux-gnu"

  ; Function Attrs: norecurse nounwind readnone uwtable
  define i32 @main() local_unnamed_addr #0 {
  entry:
    %call = tail call fastcc i32 @f(i32 1)
    %call1 = tail call fastcc i32 @f(i32 47)
    %add3 = add nsw i32 %call, %call1
    ret i32 %add3
  }

  ; Function Attrs: noinline norecurse nounwind readnone uwtable
  define internal fastcc i32 @f(i32 %x) unnamed_addr #1 {
  entry:
    %c1 = icmp sle i32 %x, 100

    %cmp = icmp sgt i32 %x, 300
    %. = select i1 %cmp, i32 1, i32 2
    ret i32 %.
  }

  attributes #1 = { noinline }

Reviewers: davide, sanjoy, efriedma, dberlin

Reviewed By: davide, dberlin

Subscribers: mcrosier, gberry, mssimpso, dberlin, llvm-commits

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

llvm-svn: 315288

7 years agoRevert "Revert r315214 since diff -Z isn't portable, this is breaking:"
Ilya Biryukov [Tue, 10 Oct 2017 09:08:47 +0000 (09:08 +0000)]
Revert "Revert r315214 since diff -Z isn't portable, this is breaking:"

This reverts commit r315242 and restores r315214.

To fix original failure, replaced non-portable `diff -Z` with portable
alternative: `diff -b`.

llvm-svn: 315287

7 years agoFix small nits in clang-refactor doc.
Haojian Wu [Tue, 10 Oct 2017 09:00:56 +0000 (09:00 +0000)]
Fix small nits in clang-refactor doc.

llvm-svn: 315286

7 years agoFix for PR34888.
Nemanja Ivanovic [Tue, 10 Oct 2017 08:46:10 +0000 (08:46 +0000)]
Fix for PR34888.

The issue is that we assume operand zero of the input to the add instruction
is a register. In this case, the input comes from inline assembly and
operand zero is not a register thereby causing a crash.
The code will bail anyway if the input instruction doesn't have the right
opcode. So do that check first and let short-circuiting prevent the crash.

llvm-svn: 315285

7 years ago[clangd] Fix compilation on gcc.
Ilya Biryukov [Tue, 10 Oct 2017 08:40:57 +0000 (08:40 +0000)]
[clangd] Fix compilation on gcc.

llvm-svn: 315284

7 years agoSILoadStoreOptimizer.cpp: Fix build; Clang doesn't like "using anonymous struct"...
NAKAMURA Takumi [Tue, 10 Oct 2017 08:30:53 +0000 (08:30 +0000)]
SILoadStoreOptimizer.cpp: Fix build; Clang doesn't like "using anonymous struct" since rL315256.

llvm-svn: 315283

7 years agoMCWinCOFFObjectWriter.h: Fix modules build in rL315257.
NAKAMURA Takumi [Tue, 10 Oct 2017 08:30:45 +0000 (08:30 +0000)]
MCWinCOFFObjectWriter.h: Fix modules build in rL315257.

llvm-svn: 315282

7 years agoRe-land "[MergeICmps] Disable mergeicmps if the target does not want to handle memcmp...
Clement Courbet [Tue, 10 Oct 2017 08:00:45 +0000 (08:00 +0000)]
Re-land "[MergeICmps] Disable mergeicmps if the target does not want to handle memcmp expansion."

(fixed stability issues)

This reverts commit d6492333d3b478a1d88163315002022f8d5e58dc.

llvm-svn: 315281

7 years ago[ELF] - Improve "has non-ABS reloc" error.
George Rimar [Tue, 10 Oct 2017 07:55:07 +0000 (07:55 +0000)]
[ELF] - Improve "has non-ABS reloc" error.

It did not contain information about relocation type and symbol.

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

llvm-svn: 315280

7 years agoIgnore all duplicate frame index expression
Bjorn Steinbrink [Tue, 10 Oct 2017 07:46:17 +0000 (07:46 +0000)]
Ignore all duplicate frame index expression

Some passes might duplicate calls to llvm.dbg.declare creating
duplicate frame index expression which currently trigger an assertion
which is meant to catch erroneous, overlapping fragment declarations.
But identical frame index expressions are just redundant and don't
actually conflict with each other, so we can be more lenient and just
ignore the duplicates.

Reviewers: aprantl, rnk

Subscribers: llvm-commits, JDevlieghere

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

llvm-svn: 315279

7 years agoRemove unneeded typename from test
Roger Ferrer Ibanez [Tue, 10 Oct 2017 07:42:19 +0000 (07:42 +0000)]
Remove unneeded typename from test

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

llvm-svn: 315278

7 years ago[clang-tidy] Use a more efficient map for the virtual near miss check.
Benjamin Kramer [Tue, 10 Oct 2017 07:21:51 +0000 (07:21 +0000)]
[clang-tidy] Use a more efficient map for the virtual near miss check.

DenseMap performs better here. No functionality change intended.

llvm-svn: 315277

7 years ago[ASTMatchers] Don't create a copy of a std::set when iterating over it.
Benjamin Kramer [Tue, 10 Oct 2017 07:21:34 +0000 (07:21 +0000)]
[ASTMatchers] Don't create a copy of a std::set when iterating over it.

This is a bit awkward because lookup returns a copy instead of a
reference. No functionality change intended.

llvm-svn: 315276

7 years ago[RISCV] Fix build after r315254
Alex Bradbury [Tue, 10 Oct 2017 07:19:18 +0000 (07:19 +0000)]
[RISCV] Fix build after r315254

createELFObjectWriter now takes a std::unique_ptr<MCELFObjectTargetWriter>
rather than a MCELFObjectTargetWriter*.

llvm-svn: 315275

7 years ago[AVX512] Add patterns to commute integer comparison instructions during isel.
Craig Topper [Tue, 10 Oct 2017 06:36:46 +0000 (06:36 +0000)]
[AVX512] Add patterns to commute integer comparison instructions during isel.

This enables broadcast loads to be commuted and allows normal loads to be folded without the peephole pass.

llvm-svn: 315274

7 years ago[COFF] Don't error out on relocations to discarded sections in .eh_frame
Martin Storsjo [Tue, 10 Oct 2017 06:05:29 +0000 (06:05 +0000)]
[COFF] Don't error out on relocations to discarded sections in .eh_frame

This allows linking code with dwarf exception handling.

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

llvm-svn: 315273

7 years ago Renable r314928
Xinliang David Li [Tue, 10 Oct 2017 05:07:54 +0000 (05:07 +0000)]
 Renable r314928

 Eliminate inttype phi with inttoptr/ptrtoint.

 This version fixed a bug in finding the matching
 phi -- the order of the incoming blocks may be
 different (triggered in self build on Windows).
 A new test case is added.

llvm-svn: 315272

7 years agoMake a local variable name shorter. NFC.
Rui Ueyama [Tue, 10 Oct 2017 04:53:14 +0000 (04:53 +0000)]
Make a local variable name shorter. NFC.

llvm-svn: 315271

7 years agoSimplify.
Rui Ueyama [Tue, 10 Oct 2017 04:45:48 +0000 (04:45 +0000)]
Simplify.

llvm-svn: 315270

7 years agoRemove dead function.
Rui Ueyama [Tue, 10 Oct 2017 03:58:32 +0000 (03:58 +0000)]
Remove dead function.

llvm-svn: 315269

7 years agoAdd comments.
Rui Ueyama [Tue, 10 Oct 2017 03:58:18 +0000 (03:58 +0000)]
Add comments.

llvm-svn: 315268

7 years agoAdd more comments.
Rui Ueyama [Tue, 10 Oct 2017 03:40:57 +0000 (03:40 +0000)]
Add more comments.

llvm-svn: 315267

7 years agoAdd comment to InputSectionBase::File.
Rui Ueyama [Tue, 10 Oct 2017 03:22:29 +0000 (03:22 +0000)]
Add comment to InputSectionBase::File.

This patch also moves declarations so that related declarations next
to each other.

llvm-svn: 315266

7 years agoRemove dead function.
Rui Ueyama [Tue, 10 Oct 2017 03:01:41 +0000 (03:01 +0000)]
Remove dead function.

llvm-svn: 315265

7 years ago[MC] Properly diagnose badly scoped .cfi_ directives
Reid Kleckner [Tue, 10 Oct 2017 01:49:21 +0000 (01:49 +0000)]
[MC] Properly diagnose badly scoped .cfi_ directives

Removes two report_fatal_errors.

Implement this by removing EmitCFICommon, and do the checking in
getCurrentDwarfFrameInfo. Have the callers check for null before
dereferencing it.

llvm-svn: 315264

7 years agoGive a test a triple
Reid Kleckner [Tue, 10 Oct 2017 01:34:31 +0000 (01:34 +0000)]
Give a test a triple

llvm-svn: 315263

7 years ago[SEH] Use reportError instead of report_fatal_error for bad directives
Reid Kleckner [Tue, 10 Oct 2017 01:26:25 +0000 (01:26 +0000)]
[SEH] Use reportError instead of report_fatal_error for bad directives

This makes the .seh_ directives slightly more usable from standalone
assembly files.

This removes a large number of report_fatal_errors and recovers from the
error by ignoring the directive.

llvm-svn: 315262

7 years ago[Sema][ObjC] Preserve syntactic sugar when removing
Akira Hatanaka [Tue, 10 Oct 2017 01:24:33 +0000 (01:24 +0000)]
[Sema][ObjC] Preserve syntactic sugar when removing
ARCReclaimReturnedObject cast.

This is a follow-up to r314370.

Rather than throwing away the enclosing parentheses, this commit walks
down the expression until an ARCReclaimReturnedObject cast is found and
removes just the cast, preserving the syntactic sugar expressions
(parens and casts) that were visited up to that point.

rdar://problem/34705720

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

llvm-svn: 315261

7 years ago[MC] Plumb unique_ptr<MCWasmObjectTargetWriter> through createWasmObjectWriter
Lang Hames [Tue, 10 Oct 2017 01:15:10 +0000 (01:15 +0000)]
[MC] Plumb unique_ptr<MCWasmObjectTargetWriter> through createWasmObjectWriter
to WasmObjectWriter's constructor.

Fixes the same ownership issue for COFF that r315245 did for MachO:
WasmObjectWriter takes ownership of its MCWasmObjectTargetWriter, so we want to
pass this through to the constructor via a unique_ptr, rather than a raw ptr.

llvm-svn: 315260

7 years ago[MC] Suppress .Lcfi labels when emitting textual assembly
Reid Kleckner [Tue, 10 Oct 2017 00:57:36 +0000 (00:57 +0000)]
[MC] Suppress .Lcfi labels when emitting textual assembly

Summary:
This suppresses the generation of .Lcfi labels in our textual assembler.
It was annoying that this generated cascading .Lcfi labels:
  llc foo.ll -o - | llvm-mc | llvm-mc

After three trips through MCAsmStreamer, we'd have three labels in the
output when none are necessary. We should only bother creating the
labels and frame data when making a real object file.

This supercedes D38605, which moved the entire .seh_ implementation into
MCObjectStreamer.

This has the advantage that we do more checking when emitting textual
assembly, as a minor efficiency cost. Outputting textual assembly is not
performance critical, so this shouldn't matter.

Reviewers: majnemer, MatzeB

Subscribers: qcolombet, nemanjai, javed.absar, eraman, hiraditya, JDevlieghere, llvm-commits

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

llvm-svn: 315259

7 years agoFix Wasm build after r315254
Reid Kleckner [Tue, 10 Oct 2017 00:52:40 +0000 (00:52 +0000)]
Fix Wasm build after r315254

llvm-svn: 315258

7 years ago[MC] Plumb unique_ptr<MCWinCOFFObjectTargetWriter> through
Lang Hames [Tue, 10 Oct 2017 00:50:29 +0000 (00:50 +0000)]
[MC] Plumb unique_ptr<MCWinCOFFObjectTargetWriter> through
createWinCOFFObjectWriter to WinCOFFObjectWriter's constructor.

Fixes the same ownership issue for COFF that r315245 did for MachO:
WinCOFFObjectWriter takes ownership of its MCWinCOFFObjectTargetWriter, so we
want to pass this through to the constructor via a unique_ptr, rather than a
raw ptr.

llvm-svn: 315257

7 years ago[Modules TS] Avoid computing the linkage of the enclosing DeclContext for a declarati...
Richard Smith [Tue, 10 Oct 2017 00:49:38 +0000 (00:49 +0000)]
[Modules TS] Avoid computing the linkage of the enclosing DeclContext for a declaration in the global module.

This works around a language issue where adding a typedef name for linkage
purposes changes the linkage of an already-defined class after it becomes
complete.

llvm-svn: 315256

7 years agoR13575: Fix USR mangling for function pointer types
Jan Korous [Tue, 10 Oct 2017 00:35:16 +0000 (00:35 +0000)]
R13575: Fix USR mangling for function pointer types

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

llvm-svn: 315255

7 years ago[MC] Plumb unique_ptr<MCELFObjectTargetWriter> through createELFObjectWriter to
Lang Hames [Mon, 9 Oct 2017 23:53:15 +0000 (23:53 +0000)]
[MC] Plumb unique_ptr<MCELFObjectTargetWriter> through createELFObjectWriter to
ELFObjectWriter's constructor.

Fixes the same ownership issue for ELF that r315245 did for MachO:
ELFObjectWriter takes ownership of its MCELFObjectTargetWriter, so we want to
pass this through to the constructor via a unique_ptr, rather than a raw ptr.

llvm-svn: 315254

7 years agoRename OptimizationDiagnosticInfo.h to OptimizationRemarkEmitter.h
Adam Nemet [Mon, 9 Oct 2017 23:49:08 +0000 (23:49 +0000)]
Rename OptimizationDiagnosticInfo.h to OptimizationRemarkEmitter.h

Polly version of r315249 on LLVM trunk.

llvm-svn: 315253

7 years agoFix typos in documentation
Jan Korous [Mon, 9 Oct 2017 23:45:20 +0000 (23:45 +0000)]
Fix typos in documentation

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

llvm-svn: 315252

7 years ago[Modules TS] Module ownership semantics for redeclarations.
Richard Smith [Mon, 9 Oct 2017 23:42:09 +0000 (23:42 +0000)]
[Modules TS] Module ownership semantics for redeclarations.

When declaring an entity in the "purview" of a module, it's never a
redeclaration of an entity in the purview of a default module or in no module
("in the global module"). Don't consider those other declarations as possible
redeclaration targets if they're not visible, and reject any cases where we
pick a prior visible declaration that violates this rule.

llvm-svn: 315251

7 years ago[Analyzer] Do not segfault on unexpected call_once implementation
George Karpenkov [Mon, 9 Oct 2017 23:20:46 +0000 (23:20 +0000)]
[Analyzer] Do not segfault on unexpected call_once implementation

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

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

llvm-svn: 315250

7 years agoRename OptimizationDiagnosticInfo.* to OptimizationRemarkEmitter.*
Adam Nemet [Mon, 9 Oct 2017 23:19:02 +0000 (23:19 +0000)]
Rename OptimizationDiagnosticInfo.* to OptimizationRemarkEmitter.*

Sync it up with the name of the class actually defined here.  This has been
bothering me for a while...

llvm-svn: 315249

7 years ago[llvm-rc] Try again to fix errors on big endian systems.
Zachary Turner [Mon, 9 Oct 2017 22:59:40 +0000 (22:59 +0000)]
[llvm-rc] Try again to fix errors on big endian systems.

llvm-svn: 315248

7 years ago[ubsan] Fix Asan internal alloc corruption in PR33221 test.
Evgeniy Stepanov [Mon, 9 Oct 2017 22:52:13 +0000 (22:52 +0000)]
[ubsan] Fix Asan internal alloc corruption in PR33221 test.

MAP_FIXED discards the existing mapping at the given address.

llvm-svn: 315247

7 years agoFix LLDB build for Android.
Eugene Zemtsov [Mon, 9 Oct 2017 22:43:35 +0000 (22:43 +0000)]
Fix LLDB build for Android.

Currently libstdc++ on Android doesn't support std::to_string().

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

llvm-svn: 315246

7 years ago[MC] Plumb unique_ptr<MCMachObjectTargetWriter> through createMachObjectWriter
Lang Hames [Mon, 9 Oct 2017 22:38:13 +0000 (22:38 +0000)]
[MC] Plumb unique_ptr<MCMachObjectTargetWriter> through createMachObjectWriter
to MCObjectWriter's constructor.

MCObjectWriter takes ownership of its MCMachObjectTargetWriter argument -- this
patch plumbs that ownership relationship through the constructor (which
previously took raw MCMachObjectTargetWriter*) and the createMachObjectWriter
function.

llvm-svn: 315245

7 years ago[DWARF] DW_TAG_imported_unit is not a unit type.
Jonas Devlieghere [Mon, 9 Oct 2017 22:33:53 +0000 (22:33 +0000)]
[DWARF] DW_TAG_imported_unit is not a unit type.

As pointed out by David in D38453 and confirmed with the DWARF mailing
list, DW_TAG_imported_unit is not a valid unit type.

llvm-svn: 315244

7 years ago[llvm-objdump] Use initializer list for scoped xar api constructors
Francis Ricci [Mon, 9 Oct 2017 20:27:14 +0000 (20:27 +0000)]
[llvm-objdump] Use initializer list for scoped xar api constructors

llvm-svn: 315243

7 years agoRevert r315214 since diff -Z isn't portable, this is breaking:
Bruno Cardoso Lopes [Mon, 9 Oct 2017 20:22:05 +0000 (20:22 +0000)]
Revert r315214 since diff -Z isn't portable, this is breaking:

http://green.lab.llvm.org/green/job/clang-stage1-cmake-RA-expensive
http://green.lab.llvm.org/green/job/clang-stage1-configure-RA

llvm-svn: 315242

7 years agoPR13575: Fix test
Jan Korous [Mon, 9 Oct 2017 20:17:28 +0000 (20:17 +0000)]
PR13575: Fix test

Ignore OS-specific mangled name.

llvm-svn: 315241

7 years ago[GISel]: Fix generation of illegal COPYs during CallLowering
Aditya Nandakumar [Mon, 9 Oct 2017 20:07:43 +0000 (20:07 +0000)]
[GISel]: Fix generation of illegal COPYs during CallLowering

We end up creating COPY's that are either truncating/extending and this
should be illegal.

https://reviews.llvm.org/D37640

Patch for X86 and ARM by igorb, rovka

llvm-svn: 315240

7 years agoAdd a helper to build Copy instructions in MachineIRBuilder
Aditya Nandakumar [Mon, 9 Oct 2017 20:07:41 +0000 (20:07 +0000)]
Add a helper to build Copy instructions in MachineIRBuilder

llvm-svn: 315239

7 years agoAMDGPU: Add read_exec_lo/hi builtins
Matt Arsenault [Mon, 9 Oct 2017 20:06:37 +0000 (20:06 +0000)]
AMDGPU: Add read_exec_lo/hi builtins

llvm-svn: 315238

7 years ago[X86] Unsigned saturation subtraction canonicalization [the backend part]
Zvi Rackover [Mon, 9 Oct 2017 20:01:10 +0000 (20:01 +0000)]
[X86] Unsigned saturation subtraction canonicalization [the backend part]

Summary:
On behalf of julia.koval@intel.com

The patch transforms canonical version of unsigned saturation, which is sub(max(a,b),a) or sub(a,min(a,b)) to special psubus insturuction on targets, which support it(8bit and 16bit uints).
umax(a,b) - b -> subus(a,b)
a - umin(a,b) -> subus(a,b)

There is also extra case handled, when right part of sub is 32 bit and can be truncated, using UMIN(this transformation was discussed in https://reviews.llvm.org/D25987).

The example of special case code:

```
void foo(unsigned short *p, int max, int n) {

  int i;
  unsigned m;
  for (i = 0; i < n; i++) {
    m = *--p;
    *p = (unsigned short)(m >= max ? m-max : 0);
  }
}
```
Max in this example is truncated to max_short value, if it is greater than m, or just truncated to 16 bit, if it is not. It is vaid transformation, because if max > max_short, result of the expression will be zero.

Here is the table of types, I try to support, special case items are bold:

| Size | 128 | 256 | 512
| -----  | -----  | -----   | -----
| i8 | v16i8 | v32i8 | v64i8
| i16 | v8i16 | v16i16 | v32i16
| i32 | | **v8i32** | **v16i32**
| i64 | | | **v8i64**

Reviewers: zvi, spatel, DavidKreitzer, RKSimon

Reviewed By: zvi

Subscribers: llvm-commits

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

llvm-svn: 315237

7 years agoPR13575: Fix USR mangling for fixed-size arrays
Jan Korous [Mon, 9 Oct 2017 19:51:33 +0000 (19:51 +0000)]
PR13575: Fix USR mangling for fixed-size arrays

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

llvm-svn: 315236

7 years agoImplement mem_fence on ptx
Jeroen Ketema [Mon, 9 Oct 2017 19:43:04 +0000 (19:43 +0000)]
Implement mem_fence on ptx

PTX does not differentiate between read and write fences. Hence, these a
lowered to a mem_fence call. The mem_fence function compiles to the
“member.cta” instruction, which commits all outstanding reads and writes
of a thread such that these become visible to all other threads in the same
CTA (i.e., work-group). The instruction does not differentiate between
global and local memory. Hence, the flags parameter is ignored, except
for deciding whether a “member.cta” instruction should be issued at all.

Reviewed-by: Jan Vesely <jan.vesely@rutgers.edu>
llvm-svn: 315235

7 years ago[libc++] Support Microsoft ABI without vcruntime headers
Shoaib Meenai [Mon, 9 Oct 2017 19:25:17 +0000 (19:25 +0000)]
[libc++] Support Microsoft ABI without vcruntime headers

The vcruntime headers are hairy and clash with both libc++ headers
themselves and other libraries. libc++ normally deals with the clashes
by deferring to the vcruntime headers and silencing its own definitions,
but for clients which don't want to depend on vcruntime headers, it's
desirable to support the opposite, i.e. have libc++ provide its own
definitions.

Certain operator new/delete replacement scenarios are not currently
supported in this mode, which requires some tests to be marked XFAIL.
The added documentation has more details.

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

llvm-svn: 315234

7 years ago[SLP] Add test for reversed load, NFC.
Alexey Bataev [Mon, 9 Oct 2017 19:08:15 +0000 (19:08 +0000)]
[SLP] Add test for reversed load, NFC.

llvm-svn: 315232

7 years agoTesting commit access.
Hamza Sood [Mon, 9 Oct 2017 19:07:09 +0000 (19:07 +0000)]
Testing commit access.

llvm-svn: 315231

7 years agoFix some C++ value / reference semantics issues.
Zachary Turner [Mon, 9 Oct 2017 18:50:29 +0000 (18:50 +0000)]
Fix some C++ value / reference semantics issues.

Some functions were taking Twine's not by const&, these are all
fixed to take by const&.  We also had a case where some functions
were overloaded to accept by const& and &&.  Now there is only
one version which accepts by value and move's the value.

llvm-svn: 315229

7 years agoMake ptx barrier work irrespective of the cl_mem_fence_flags
Jeroen Ketema [Mon, 9 Oct 2017 18:36:48 +0000 (18:36 +0000)]
Make ptx barrier work irrespective of the cl_mem_fence_flags

This generates a "bar.sync 0” instruction, which not only causes the
threads to wait, but does acts as a memory fence, as required by
OpenCL. The fence does not differentiate between local and global
memory. Unfortunately, there is no similar instruction which does
not include a memory fence. Hence, we cannot optimize the case
where neither CLK_LOCAL_MEM_FENCE nor CLK_GLOBAL_MEM_FENCE is
passed.

llvm-svn: 315228

7 years ago[sanitizer] Don't intercept signal and sigaction on Fuchsia
Petr Hosek [Mon, 9 Oct 2017 18:29:52 +0000 (18:29 +0000)]
[sanitizer] Don't intercept signal and sigaction on Fuchsia

Fuchsia doesn't support signals, so don't use interceptors for signal or
sigaction.

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

llvm-svn: 315227