platform/upstream/llvm.git
8 years agoReplace GAlloc with a template function.
Rafael Espindola [Tue, 1 Nov 2016 21:06:40 +0000 (21:06 +0000)]
Replace GAlloc with a template function.

This patch replaces GAlloc<ELFT>::<sometype>.Allocate() with
alloc<sometype<ELFT>>().

Patch by Rui!

llvm-svn: 285748

8 years agoSimplify getStringTableIndex.
Rafael Espindola [Tue, 1 Nov 2016 20:56:15 +0000 (20:56 +0000)]
Simplify getStringTableIndex.

The description in the ELF spec is just

---------------------------
If the section name string table section index is greater than or
equal to SHN_LORESERVE (0xff00), this member has the value SHN_XINDEX
(0xffff) and the actual index of the section name string table section
is contained in the sh_link field of the section header at index 0.
---------------------------

So we only have to check for it being SHN_XINDEX. Also, sh_link is
always 32 bits, so don't return an uintX_t.

llvm-svn: 285747

8 years ago[ScopInfo] Make memset etc. affine where possible.
Eli Friedman [Tue, 1 Nov 2016 20:53:11 +0000 (20:53 +0000)]
[ScopInfo] Make memset etc. affine where possible.

We don't actually check whether a MemoryAccess is affine in very many
places, but one important one is in checks for aliasing.

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

llvm-svn: 285746

8 years agoAdd missing test from r284848.
Eli Friedman [Tue, 1 Nov 2016 20:45:28 +0000 (20:45 +0000)]
Add missing test from r284848.

Original commit title: [SCEVAffinator] Make precise modular math
more correct.

llvm-svn: 285745

8 years ago[ValueTracking] remove TODO comment; NFC
Sanjay Patel [Tue, 1 Nov 2016 20:43:00 +0000 (20:43 +0000)]
[ValueTracking] remove TODO comment; NFC

InstCombine should always canonicalize patterns like the one shown in the comment
when visiting 'select' insts in adjustMinMax().

Scalars were already handled there, and vector splats are handled after:
https://reviews.llvm.org/rL285732

llvm-svn: 285744

8 years agoAMDGPU: Workaround for instruction size with literals
Matt Arsenault [Tue, 1 Nov 2016 20:42:24 +0000 (20:42 +0000)]
AMDGPU: Workaround for instruction size with literals

Instructions with a 32-bit base encoding with an optional
32-bit literal encoded after them report their size as 4
for the disassembler. Consider these when computing the
MachineInstr size. This fixes problems caused by size estimate
consistency in BranchRelaxation.

llvm-svn: 285743

8 years agoSwitch SBWatchpoint::SetEnabled over to using Process::{Enable,Disable}Watchpoint.
Jim Ingham [Tue, 1 Nov 2016 20:37:02 +0000 (20:37 +0000)]
Switch SBWatchpoint::SetEnabled over to using Process::{Enable,Disable}Watchpoint.

We don't have a good story for what happens to watchpoints when you don't
have a process, or if your process exits.  Clearing that up will instruct
how to fix this for real.

Also added a test to make sure disable->enable works as well.
This resolves llvm.org/pr30789.

llvm-svn: 285742

8 years ago[test] Fix detecting LLVM zlib support in stand-alone builds
Michal Gorny [Tue, 1 Nov 2016 20:31:52 +0000 (20:31 +0000)]
[test] Fix detecting LLVM zlib support in stand-alone builds

Fix the test run to declare missing HAVE_LIBZ value in stand-alone
builds, using the LLVM_ENABLE_ZLIB that is exported in LLVMConfig.cmake.

When using in-tree builds, HAVE_LIBZ is declared in
cmake/config-ix.cmake as a result of LLVM's CMake checks. When building
stand-alone, this value is not available and as a result caused clang to
wrongly assume that LLVM was built without zlib support.

To fix it, set it to the value of LLVM_ENABLE_ZLIB. While this variable
is originally used to control the user preference, LLVM updates its
value to 0 if zlib checks fail. Therefore, we can use it to reliably
determine whether LLVM was built with zlib support or not.

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

llvm-svn: 285741

8 years agoCreate SyntheticSections.cpp.
Rui Ueyama [Tue, 1 Nov 2016 20:28:21 +0000 (20:28 +0000)]
Create SyntheticSections.cpp.

We are going to have many more classes for linker-synthesized
input sections, so it's worth to be added to a separate file
than to the file for regular input sections.

llvm-svn: 285740

8 years agoUpdate for llvm change.
Rafael Espindola [Tue, 1 Nov 2016 20:25:27 +0000 (20:25 +0000)]
Update for llvm change.

llvm-svn: 285739

8 years agoUse the existing std::error_code out parameter.
Rafael Espindola [Tue, 1 Nov 2016 20:24:22 +0000 (20:24 +0000)]
Use the existing std::error_code out parameter.

This avoids calling exit with a partially constructed object.

llvm-svn: 285738

8 years agoFix llvm-shlib cmake build
Chris Bieneman [Tue, 1 Nov 2016 20:19:33 +0000 (20:19 +0000)]
Fix llvm-shlib cmake build

Summary:
This fixes a few things that used to work with a Makefile build, but were broken in cmake.

1. Treat MINGW like a Linux system.
2. The shlib should never contain other shared libraries.

Patch By: Valentin Churavy

Reviewers: axw, beanz

Subscribers: modocache, beanz, mgorny

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

llvm-svn: 285737

8 years agoAdd helpers for the notion of a type scavenger that is "either this or that" source...
Enrico Granata [Tue, 1 Nov 2016 20:17:14 +0000 (20:17 +0000)]
Add helpers for the notion of a type scavenger that is "either this or that" source, and one that is "both this and that" source

Use the helper to rewrite the ObjC type lookup logic (first modules, then runtime) in terms of an either scavenger

llvm-svn: 285736

8 years ago[ELF/GC] Fix pending references to garbage collected sections.
Davide Italiano [Tue, 1 Nov 2016 20:11:01 +0000 (20:11 +0000)]
[ELF/GC] Fix pending references to garbage collected sections.

The example reported in PR30793 shows a case where gc reclaims
a SHF_TLS section, but it doesn't reclaim the section containing
the debug info for it.
This is expected, as we do not reclaim non-alloc sections
during the garbage collection phase (and this is not going to
change anytime soon, at least this is what I gathered last I
talked with Rafael about it).
So, we end up with a pending reference, thinking that the input
was invalid (which is not true, as it's GC that removed the
SHT_TLS section, and therefore didn't create the PT_TLS *segment*
for it). In cases like this, just assign a VA of zero at relocation
time instead of error'ing out (this is what gold does as well, FWIW).

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

llvm-svn: 285735

8 years agoGC empty subdirectories.
Joerg Sonnenberger [Tue, 1 Nov 2016 20:09:41 +0000 (20:09 +0000)]
GC empty subdirectories.

llvm-svn: 285734

8 years agoclang/test/CodeGenOpenCL/convergent.cl: Satisfy -Asserts with "opt -instnamer".
NAKAMURA Takumi [Tue, 1 Nov 2016 20:08:17 +0000 (20:08 +0000)]
clang/test/CodeGenOpenCL/convergent.cl: Satisfy -Asserts with "opt -instnamer".

llvm-svn: 285733

8 years ago[InstCombine] allow splat vector folds in adjustMinMax()
Sanjay Patel [Tue, 1 Nov 2016 20:08:02 +0000 (20:08 +0000)]
[InstCombine] allow splat vector folds in adjustMinMax()

llvm-svn: 285732

8 years ago[clang-query] Fix Clang-tidy readability-redundant-string-cstr warnings
Malcolm Parsons [Tue, 1 Nov 2016 20:07:05 +0000 (20:07 +0000)]
[clang-query] Fix Clang-tidy readability-redundant-string-cstr warnings

Reviewers: pcc, dblaikie

Subscribers: cfe-commits

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

llvm-svn: 285731

8 years ago[RISCV] Add RISCV.def to module.modulemap
Alex Bradbury [Tue, 1 Nov 2016 19:31:30 +0000 (19:31 +0000)]
[RISCV] Add RISCV.def to module.modulemap

llvm-svn: 285730

8 years ago[InstCombine] Fold nuw left-shifts in `ugt`/`ule` comparisons.
Sanjay Patel [Tue, 1 Nov 2016 19:19:29 +0000 (19:19 +0000)]
[InstCombine] Fold nuw left-shifts in `ugt`/`ule` comparisons.

This transforms

%a = shl nuw %x, c1
%b = icmp {ugt|ule} %a, c0

into

%b = icmp {ugt|ule} %x, (c0 >> c1)

z3:

(declare-const x (_ BitVec 64))
(declare-const c0 (_ BitVec 64))
(declare-const c1 (_ BitVec 64))

(push)
(assert (= x (bvlshr (bvshl x c1) c1)))  ; nuw
(assert (not (= (bvugt (bvshl x c1) c0)
                (bvugt x
                       (bvlshr c0 c1)))))
(check-sat)
(get-model)
(pop)

(push)
(assert (= x (bvlshr (bvshl x c1) c1)))  ; nuw
(assert (not (= (bvule (bvshl x c1) c0)
                (bvule x
                       (bvlshr c0 c1)))))
(check-sat)
(get-model)
(pop)

Patch by bryant!

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

llvm-svn: 285729

8 years ago[Hexagon] Rename operand/predicate names for unshifted integers
Krzysztof Parzyszek [Tue, 1 Nov 2016 19:02:10 +0000 (19:02 +0000)]
[Hexagon] Rename operand/predicate names for unshifted integers

For example, rename s6Ext to s6_0Ext. The names for shifted integers
include the underscore and this will make the naming consistent. It
also exposed a few duplicates that were removed.

llvm-svn: 285728

8 years agoImplement a general type scavenger that can dig types from debug info + a filtering...
Enrico Granata [Tue, 1 Nov 2016 18:50:49 +0000 (18:50 +0000)]
Implement a general type scavenger that can dig types from debug info + a filtering mechanism to accept/reject results thusly obtained

Implement the C++ type lookup support in terms of this general scavenger

The idea is that we may want other languages to do debug info based search (exclusively, or as an add-on to runtime/module based searching) and it makes sense to avoid duplicating this functionality

llvm-svn: 285727

8 years agochange ProcessAttach test to no-debug-info
Todd Fiala [Tue, 1 Nov 2016 18:50:34 +0000 (18:50 +0000)]
change ProcessAttach test to no-debug-info

Fixes:
https://bugs.swift.org/browse/SR-3103

llvm-svn: 285726

8 years ago[OpenCL] Mark group functions as convergent in opencl-c.h
Yaxun Liu [Tue, 1 Nov 2016 18:45:32 +0000 (18:45 +0000)]
[OpenCL] Mark group functions as convergent in opencl-c.h

Certain OpenCL builtin functions are supposed to be executed by all threads in a work group or sub group. Such functions should not be made divergent during transformation. It makes sense to mark them with convergent attribute.

The adding of convergent attribute is based on Ettore Speziale's work and the original proposal and patch can be found at https://www.mail-archive.com/cfe-commits@lists.llvm.org/msg22271.html.

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

llvm-svn: 285725

8 years agoBranchRelaxation: Expand unconditional branches first
Matt Arsenault [Tue, 1 Nov 2016 18:34:00 +0000 (18:34 +0000)]
BranchRelaxation: Expand unconditional branches first

It's likely if a conditional branch needs to be expanded, the following
unconditional branch will also need expansion. By expanding the
unconditional branch first, the conditional branch can be simply
inverted to jump over the inserted indirect branch block. If the
conditional branch is expanded first, it results in an additional
branch.

This avoids test regressions in future commits.

llvm-svn: 285722

8 years ago[Clang-tidy] Fix copy-paste error in misc-redundant-expression detected by PVS-Studio
Eugene Zelenko [Tue, 1 Nov 2016 18:33:50 +0000 (18:33 +0000)]
[Clang-tidy] Fix copy-paste error in misc-redundant-expression detected by PVS-Studio

Also fix some Include What You Use and modernize-use-bool-literals warnings.

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

llvm-svn: 285721

8 years agoImplement R_PPC_ADDR32.
Rui Ueyama [Tue, 1 Nov 2016 18:30:28 +0000 (18:30 +0000)]
Implement R_PPC_ADDR32.

Patch from Jack Andersen.

llvm-svn: 285720

8 years agoImplement R_PPC_REL24 and R_PPC_REL32 relocations.
Rui Ueyama [Tue, 1 Nov 2016 18:30:26 +0000 (18:30 +0000)]
Implement R_PPC_REL24 and R_PPC_REL32 relocations.

This enables LLD to relocate PC-relative R_PPC_REL32 and
R_PPC_REL24 types (as used in bl instructions).

Patch from Jack Andersen!

llvm-svn: 285719

8 years ago[InstCombine] clean up adjustMinMax(); NFCI
Sanjay Patel [Tue, 1 Nov 2016 18:15:03 +0000 (18:15 +0000)]
[InstCombine] clean up adjustMinMax(); NFCI

1. Change param names for readability
2. Change pointer param to ref
3. Early exit to reduce indent
4. Change switch to if/else

llvm-svn: 285718

8 years agoTest Commit, removed extraneous newline
Erich Keane [Tue, 1 Nov 2016 17:54:05 +0000 (17:54 +0000)]
Test Commit, removed extraneous newline

llvm-svn: 285717

8 years ago[AMDGPU] Check if type transforms to i16 (VI+) when getting AMDGPUISD::FFBH_U32
Konstantin Zhuravlyov [Tue, 1 Nov 2016 17:49:33 +0000 (17:49 +0000)]
[AMDGPU] Check if type transforms to i16 (VI+) when getting AMDGPUISD::FFBH_U32

This will prevent following regression when enabling i16 support (D18049):

test/CodeGen/AMDGPU/ctlz.ll
test/CodeGen/AMDGPU/ctlz_zero_undef.ll

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

llvm-svn: 285716

8 years ago[InstCombine] add helper function for adjustMinMax(); NFCI
Sanjay Patel [Tue, 1 Nov 2016 17:46:08 +0000 (17:46 +0000)]
[InstCombine] add helper function for adjustMinMax(); NFCI

This is just a cut and paste; clean-up and enhancements to follow.

llvm-svn: 285715

8 years ago[CMake] Fix rpath construction for out-of-tree builds
Chris Bieneman [Tue, 1 Nov 2016 17:44:58 +0000 (17:44 +0000)]
[CMake] Fix rpath construction for out-of-tree builds

This patch was produced in conjunction with Michał Górny. It should resolve the issues that were trying to be solved by D25304.

This moves rpath handling into `llvm_add_library` and `add_llvm_executable` so that it is available to all projects using AddLLVM whether built in-tree or out-of-tree.

llvm-svn: 285714

8 years ago[InstCombine] add vector tests for ext+adjust min/max
Sanjay Patel [Tue, 1 Nov 2016 17:34:29 +0000 (17:34 +0000)]
[InstCombine] add vector tests for ext+adjust min/max

llvm-svn: 285713

8 years ago[RISCV] Add stub backend
Alex Bradbury [Tue, 1 Nov 2016 17:27:54 +0000 (17:27 +0000)]
[RISCV] Add stub backend

This contains just enough for lib/Target/RISCV to compile. Notably a basic
RISCVTargetMachine and RISCVTargetInfo. At this point you can attempt llc
-march=riscv32 myinput.ll and will find it fails due to the lack of
MCAsmInfo.

See http://lists.llvm.org/pipermail/llvm-dev/2016-August/103748.html for
further discussion

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

llvm-svn: 285712

8 years agoAMDGPU: Fix buildbots broken by r285704
Tom Stellard [Tue, 1 Nov 2016 17:20:03 +0000 (17:20 +0000)]
AMDGPU: Fix buildbots broken by r285704

llvm-svn: 285711

8 years agoFix RHEL 6 build with missing cerrno and some other Include What You Use warnings.
Eugene Zelenko [Tue, 1 Nov 2016 17:11:10 +0000 (17:11 +0000)]
Fix RHEL 6 build with missing cerrno and some other Include What You Use warnings.

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

llvm-svn: 285710

8 years ago[RISCV] Add missing RISCV.def
Alex Bradbury [Tue, 1 Nov 2016 17:09:49 +0000 (17:09 +0000)]
[RISCV] Add missing RISCV.def

Fix rL285708

llvm-svn: 285709

8 years ago[RISCV] Add RISC-V ELF defines
Alex Bradbury [Tue, 1 Nov 2016 16:59:37 +0000 (16:59 +0000)]
[RISCV] Add RISC-V ELF defines

Add the necessary definitions for RISC-V ELF files, including relocs. Also
make necessary trivial change to ELFYaml, llvm-objdump, and llvm-readobj in
order to work with RISC-V ELFs.

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

llvm-svn: 285708

8 years ago[RISCV] Recognise riscv32 and riscv64 in triple parsing code
Alex Bradbury [Tue, 1 Nov 2016 16:47:54 +0000 (16:47 +0000)]
[RISCV] Recognise riscv32 and riscv64 in triple parsing code

This is the first in a series of 10 initial patches that incrementally add an
MC layer for RISC-V to LLVM. See
<http://lists.llvm.org/pipermail/llvm-dev/2016-August/103748.html> for more
discussion.

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

llvm-svn: 285707

8 years ago[InstCombine] move/fix tests for adjusted min/max
Sanjay Patel [Tue, 1 Nov 2016 16:39:30 +0000 (16:39 +0000)]
[InstCombine] move/fix tests for adjusted min/max

I think the former 'test50' had a typo making it functionally equivalent
to the former 'test49'; changed the predicate to provide more coverage.

llvm-svn: 285706

8 years ago[TableGen] Move OperandMatchResultTy enum to MCTargetAsmParser.h
Alex Bradbury [Tue, 1 Nov 2016 16:32:05 +0000 (16:32 +0000)]
[TableGen] Move OperandMatchResultTy enum to MCTargetAsmParser.h

As it stands, the OperandMatchResultTy is only included in the generated
header if there is custom operand parsing. However, almost all backends
make use of MatchOperand_Success and friends from OperandMatchResultTy for
e.g. parseRegister. This is a pain when starting an AsmParser for a new
backend that doesn't yet have custom operand parsing. Move the enum to
MCTargetAsmParser.h.

This patch is a prerequisite for D23563

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

llvm-svn: 285705

8 years agoAMDGPU: Implement expansion of f16 = FP_TO_FP16 f64
Tom Stellard [Tue, 1 Nov 2016 16:31:48 +0000 (16:31 +0000)]
AMDGPU: Implement expansion of f16 = FP_TO_FP16 f64

I wanted to implement this as a target independent expansion, however when
targets say they want to expand FP_TO_FP16 what they actually want is
the unsafe math expansion when possible and expansion to a libcall in all
other cases.

The only way to make this work as a target independent would be to add logic
to target's TargetLowering construction to mark theses nodes as Expand when
LegalizeDAG can use the unsafe expansion and mark them as LibCall when it
cannot.  I think this would be possible, but I think it would be too fragile
and complex as it would require targets to keep their expansion logic up
to date with the code in LegalizeDAG.

Reviewers: bogner, ab, t.p.northover, arsenm

Subscribers: wdng, llvm-commits, nhaehnle

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

llvm-svn: 285704

8 years agoFixed problem introduced by part of https://reviews.llvm.org/D21196.
Andrey Churbanov [Tue, 1 Nov 2016 16:19:04 +0000 (16:19 +0000)]
Fixed problem introduced by part of https://reviews.llvm.org/D21196.

Check Task Scheduling Constraint (TSC) on stealing of untied task.
This is needed because the untied task can produce tied children
those can break TSC if untied is not a descendant of current task.
This can cause live lock on complex tyasking tests
(e.g. kastors/strassen-task-dep).

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

llvm-svn: 285703

8 years agoRemove TimeValue usage from FileSpec.h
Pavel Labath [Tue, 1 Nov 2016 16:11:14 +0000 (16:11 +0000)]
Remove TimeValue usage from FileSpec.h

Summary:
The only usage there was in GetModificationTime(). I also took the opportunity
to move this function from FileSpec to the FileSystem class - since we are
using FileSpecs to also represent remote files for which we cannot (easily)
retrieve modification time, it makes sense to make the decision to get the
modification time more explicit.

The new function returns a llvm::sys::TimePoint<>. To aid the transition
from TimeValue, I have added a constructor to it which enables implicit
conversion from a time_point.

Reviewers: zturner, clayborg

Subscribers: mehdi_amini, tberghammer, danalbert, beanz, mgorny, lldb-commits

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

llvm-svn: 285702

8 years agoThis is a 1 character fix for an ARM build attribute test (r284571): the
Sjoerd Meijer [Tue, 1 Nov 2016 15:59:37 +0000 (15:59 +0000)]
This is a 1 character fix for an ARM build attribute test (r284571): the
purpose of the test was to have 2 different function attribute sets, but due
to a typo there was only one both with number #0.

llvm-svn: 285701

8 years ago[OpenCL] Override supported OpenCL extensions with -cl-ext option
Alexey Bader [Tue, 1 Nov 2016 15:50:52 +0000 (15:50 +0000)]
[OpenCL] Override supported OpenCL extensions with -cl-ext option

Summary:
This patch adds a command line option '-cl-ext' to control a set of
supported OpenCL extensions. Option accepts a comma-separated list
of extensions prefixed with '+' or '-'.

It can be used together with a target triple to override support for some
extensions:

  // spir target supports all extensions, but we want to disable fp64
  clang -cc1 -triple spir-unknown-unknown -cl-ext=-cl_khr_fp64

Special 'all' extension allows to enable or disable all possible
extensions:

  // only fp64 will be supported
  clang -cc1 -triple spir-unknown-unknown -cl-ext=-all,+cl_khr_fp64

Patch by asavonic (Andrew Savonichev).

Reviewers: joey, yaxunl

Subscribers: yaxunl, bader, Anastasia, cfe-commits

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

llvm-svn: 285700

8 years ago[InstCombine] fix tests for adjusted min/max
Sanjay Patel [Tue, 1 Nov 2016 15:48:30 +0000 (15:48 +0000)]
[InstCombine] fix tests for adjusted min/max

1. Delete identical tests
2. Rename tests to reflect actual functionality
3. Add comments
4. Add unsigned variants
5. Add vector variants with FIXME comments
6. Rename test file

llvm-svn: 285699

8 years agoMinidump plugin: Fix flaky test
Dimitar Vlahovski [Tue, 1 Nov 2016 15:48:24 +0000 (15:48 +0000)]
Minidump plugin: Fix flaky test

Summary:
One of the tests was flaky, because similarly to
https://reviews.llvm.org/D18697 (rL265391) - if there is a process running
which is with the same PID as in the core file, the minidump
core file debugging will fail, because we get some information from the
running process.
The fix is routing the ProcessInfo requests through the Process class
and overriding it in ProcessMinidump to return correct data.

Reviewers: labath

Subscribers: lldb-commits, beanz

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

llvm-svn: 285698

8 years agoProtect exceptional paths under libcpp-no-exceptions
Roger Ferrer Ibanez [Tue, 1 Nov 2016 15:46:16 +0000 (15:46 +0000)]
Protect exceptional paths under libcpp-no-exceptions

These tests are of the form

try {
   action-that-may-throw
   assert(!exceptional-condition)
   assert(some-other-facts)
 } catch (relevant-exception) {
   assert(exceptional-condition)
 }

Under libcpp-no-exceptions there is still value in verifying
some-other-facts while avoiding the exceptional case. So for these tests
just conditionally check some-other-facts if exceptional-condition is
false. When exception are supported make sure that a true
exceptional-condition throws an exception

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

llvm-svn: 285697

8 years ago[InstCombine] Folding of shifts by the sum of positive values
Simon Pilgrim [Tue, 1 Nov 2016 15:40:30 +0000 (15:40 +0000)]
[InstCombine] Folding of shifts by the sum of positive values

This patch introduces the combine:

(C1 shift (A add C2)) -> ((C1 shift C2) shift A)
iff A and C2 are both positive

If both A and C2 are know to be positive then we can safely split into 2 shifts, permitting the folding of the Inner shift.

Fix for the spec benchmark case mentioned by @nadav on PR15141 (assuming we can prove that the inputs as positive).

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

llvm-svn: 285696

8 years agoProtect lock tests under libcpp-no-exceptions
Roger Ferrer Ibanez [Tue, 1 Nov 2016 15:00:16 +0000 (15:00 +0000)]
Protect lock tests under libcpp-no-exceptions

Skip tests that expect an exception to be thrown.

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

llvm-svn: 285695

8 years ago[PowerPC] Implement vector shift builtins - clang portion
Nemanja Ivanovic [Tue, 1 Nov 2016 14:46:20 +0000 (14:46 +0000)]
[PowerPC] Implement vector shift builtins - clang portion

This patch corresponds to review https://reviews.llvm.org/D26092.
Committing on behalf of Tony Jiang.

llvm-svn: 285694

8 years ago[InstCombine] auto-generate better checks
Sanjay Patel [Tue, 1 Nov 2016 14:38:30 +0000 (14:38 +0000)]
[InstCombine] auto-generate better checks

llvm-svn: 285693

8 years ago[Sparc][LEON] Test for FixFDIVSQRT erratum fix.
Chris Dewhurst [Tue, 1 Nov 2016 14:23:37 +0000 (14:23 +0000)]
[Sparc][LEON] Test for FixFDIVSQRT erratum fix.

Note: Test is per differential review, but the other changed code in the review was for an optimisation that din't quite work. Nevertheless, the test is valid for the unoptimised version of the fix.

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

llvm-svn: 285692

8 years agoDon't store an OutputLoc in every InputSection.
Rafael Espindola [Tue, 1 Nov 2016 13:57:19 +0000 (13:57 +0000)]
Don't store an OutputLoc in every InputSection.

It was only used by build-id and that can easily compute it.

llvm-svn: 285691

8 years ago[Thumb-1] Synthesize TBB/TBH instructions to make use of compressed jump tables
James Molloy [Tue, 1 Nov 2016 13:37:41 +0000 (13:37 +0000)]
[Thumb-1] Synthesize TBB/TBH instructions to make use of compressed jump tables

[Reapplying r284580 and r285917 with fix and testing to ensure emitted jump tables for Thumb-1 have 4-byte alignment]

The TBB and TBH instructions in Thumb-2 allow jump tables to be compressed into sequences of bytes or shorts respectively. These instructions do not exist in Thumb-1, however it is possible to synthesize them out of a sequence of other instructions.

It turns out this sequence is so short that it's almost never a lose for performance and is ALWAYS a significant win for code size.

TBB example:
Before: lsls r0, r0, #2    After: add  r0, pc
        adr  r1, .LJTI0_0         ldrb r0, [r0, #6]
        ldr  r0, [r0, r1]         lsls r0, r0, #1
        mov  pc, r0               add  pc, r0
  => No change in prologue code size or dynamic instruction count. Jump table shrunk by a factor of 4.

The only case that can increase dynamic instruction count is the TBH case:

Before: lsls r0, r4, #2    After: lsls r4, r4, #1
        adr  r1, .LJTI0_0         add  r4, pc
        ldr  r0, [r0, r1]         ldrh r4, [r4, #6]
        mov  pc, r0               lsls r4, r4, #1
                                  add  pc, r4
  => 1 more instruction in prologue. Jump table shrunk by a factor of 2.

So there is an argument that this should be disabled when optimizing for performance (and a TBH needs to be generated). I'm not so sure about that in practice, because on small cores with Thumb-1 performance is often tied to code size. But I'm willing to turn it off when optimizing for performance if people want (also note that TBHs are fairly rare in practice!)

llvm-svn: 285690

8 years ago[clang-tidy] Add check readability-redundant-declaration
Daniel Marjamaki [Tue, 1 Nov 2016 13:26:15 +0000 (13:26 +0000)]
[clang-tidy] Add check readability-redundant-declaration

Finds redundant variable and function declarations.

  extern int X;
  extern int X;  // <- redundant

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

llvm-svn: 285689

8 years ago[x86][inline-asm][clang] accept 'v' constraint
Michael Zuckerman [Tue, 1 Nov 2016 13:16:44 +0000 (13:16 +0000)]
[x86][inline-asm][clang] accept 'v' constraint
Commit on behalf of: Coby Tayree

1.'v' constraint for (x86) non-avx arch imitates the already implemented 'x' constraint, i.e. allows XMM{0-15} & YMM{0-15} depending on the apparent arch & mode (32/64).
2.for the avx512 arch it allows [X,Y,Z]MM{0-31} (mode dependent)

This patch applies the needed changes to clang
LLVM patch: https://reviews.llvm.org/D25005

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

llvm-svn: 285688

8 years agoRemove second argument to readProvideOrAssignment.
Rafael Espindola [Tue, 1 Nov 2016 11:30:45 +0000 (11:30 +0000)]
Remove second argument to readProvideOrAssignment.

With this expressions alone track if they are absolute or not.

llvm-svn: 285687

8 years ago[www] Fix a typo on the analyzer website
Alex Lorenz [Tue, 1 Nov 2016 11:12:41 +0000 (11:12 +0000)]
[www] Fix a typo on the analyzer website

llvm-svn: 285686

8 years agoFix parenthesized assert (nfc).
Manuel Klimek [Tue, 1 Nov 2016 10:30:50 +0000 (10:30 +0000)]
Fix parenthesized assert (nfc).

llvm-svn: 285685

8 years ago[AMDGPU] Expand vector mulhu/mulhs
Valery Pykhtin [Tue, 1 Nov 2016 10:26:48 +0000 (10:26 +0000)]
[AMDGPU] Expand vector mulhu/mulhs

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

llvm-svn: 285684

8 years ago[ELF] Remove unwanted typedef. NFC.
Eugene Leviant [Tue, 1 Nov 2016 10:16:52 +0000 (10:16 +0000)]
[ELF] Remove unwanted typedef. NFC.

llvm-svn: 285683

8 years agoConvert BuildIdSection to input section
Eugene Leviant [Tue, 1 Nov 2016 09:49:24 +0000 (09:49 +0000)]
Convert BuildIdSection to input section

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

llvm-svn: 285682

8 years ago[PowerPC] Implement vector shift builtins - llvm portion
Nemanja Ivanovic [Tue, 1 Nov 2016 09:42:32 +0000 (09:42 +0000)]
[PowerPC] Implement vector shift builtins - llvm portion

This patch corresponds to review https://reviews.llvm.org/D26095.
Committing on behalf of Tony Jiang.

llvm-svn: 285681

8 years agoAllow fetching source line, when multiple "AX" sections present
Eugene Leviant [Tue, 1 Nov 2016 09:17:50 +0000 (09:17 +0000)]
Allow fetching source line, when multiple "AX" sections present

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

llvm-svn: 285680

8 years ago[PPC] Add vec_absd functions to altivec.h
Nemanja Ivanovic [Tue, 1 Nov 2016 08:39:56 +0000 (08:39 +0000)]
[PPC] Add vec_absd functions to altivec.h

This patch corresponds to review https://reviews.llvm.org/D26073.
Committing on behalf of Sean Fertile.

llvm-svn: 285679

8 years agoAdd more conditions to check whether task waiting is necessary in kmp_omp_taskwait.
Andrey Churbanov [Tue, 1 Nov 2016 08:33:36 +0000 (08:33 +0000)]
Add more conditions to check whether task waiting is necessary in kmp_omp_taskwait.

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

Patch by Victor Campos

llvm-svn: 285678

8 years agoProtect tests that expect an exception for an unknown std::random_device
Roger Ferrer Ibanez [Tue, 1 Nov 2016 08:11:12 +0000 (08:11 +0000)]
Protect tests that expect an exception for an unknown std::random_device

Skip these tests under libcpp-no-exceptions.

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

llvm-svn: 285677

8 years agoAttempt to pacify buildbot
Serge Pavlov [Tue, 1 Nov 2016 07:52:10 +0000 (07:52 +0000)]
Attempt to pacify buildbot

llvm-svn: 285676

8 years agoAllow resolving response file names relative to including file
Serge Pavlov [Tue, 1 Nov 2016 06:53:29 +0000 (06:53 +0000)]
Allow resolving response file names relative to including file

If a response file included by construct @file itself includes a response file
and that file is specified by relative file name, current behavior is to resolve
the name relative to the current working directory. The change adds additional
flag to ExpandResponseFiles that may be used to resolve nested response file
names relative to including file. With the new mode a set of related response
files may be kept together and reference each other with short position
independent names.

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

llvm-svn: 285675

8 years agoclang-format: Fix bug in function reference qualifier detection.
Daniel Jasper [Tue, 1 Nov 2016 06:23:19 +0000 (06:23 +0000)]
clang-format: Fix bug in function reference qualifier detection.

Before:
  template <typename T>
      void F(T) &&
      = delete;

After:
  template <typename T>
  void F(T) && = delete;

llvm-svn: 285674

8 years agoclang-format: Fix incorrect pointer detection.
Daniel Jasper [Tue, 1 Nov 2016 06:23:14 +0000 (06:23 +0000)]
clang-format: Fix incorrect pointer detection.

Before:
  void f() { f(float{1}, a *a); }

After:
  void f() { f(float{1}, a * a); }

llvm-svn: 285673

8 years agoclang-format: [JS] Fix incorrect space when "as" is used as identifier.
Daniel Jasper [Tue, 1 Nov 2016 06:23:10 +0000 (06:23 +0000)]
clang-format: [JS] Fix incorrect space when "as" is used as identifier.

Before:
  aaaaa.as ();

After:
  aaaaa.as();

llvm-svn: 285672

8 years agoclang-format: Fix incorrect binary operator detection.
Daniel Jasper [Tue, 1 Nov 2016 06:23:05 +0000 (06:23 +0000)]
clang-format: Fix incorrect binary operator detection.

Before:
  int x = f(* + [] {});

After:
  int x = f(*+[] {});

llvm-svn: 285671

8 years agoclang-format: [JS] Fix formatting of generator functions.
Daniel Jasper [Tue, 1 Nov 2016 06:22:59 +0000 (06:22 +0000)]
clang-format: [JS] Fix formatting of generator functions.

Before:
  var x = {
    a: function*
() {
  //
}
  }

After:
  var x = {
    a: function*() {
      //
    }
  }

llvm-svn: 285670

8 years agoclang-format: [JS] Fix space when for is used as regular identifier.
Daniel Jasper [Tue, 1 Nov 2016 06:22:54 +0000 (06:22 +0000)]
clang-format: [JS] Fix space when for is used as regular identifier.

Before:
  x.for () = 1;

After:
  x.for() = 1;

llvm-svn: 285669

8 years ago[docs] remove more non-ascii stuff in the hopes to fix the bot
Kostya Serebryany [Tue, 1 Nov 2016 05:51:12 +0000 (05:51 +0000)]
[docs] remove more non-ascii stuff in the hopes to fix the bot

llvm-svn: 285668

8 years ago[AVX-512] Remove masked vector insert builtins and replace with native shufflevectors...
Craig Topper [Tue, 1 Nov 2016 05:47:56 +0000 (05:47 +0000)]
[AVX-512] Remove masked vector insert builtins and replace with native shufflevectors and selects.

Unfortunately, the backend currently doesn't fold masks into the instructions correctly when they come from these shufflevectors. I'll work on that in a future commit.

llvm-svn: 285667

8 years ago[index] Avoid using a RecursiveASTVisitor for SyntacticFormIndexer and iterate the...
Argyrios Kyrtzidis [Tue, 1 Nov 2016 04:29:39 +0000 (04:29 +0000)]
[index] Avoid using a RecursiveASTVisitor for SyntacticFormIndexer and iterate the DesignatedInitExprs of the InitListExpr directly.

This is more efficient, as per feedback by Richard.

llvm-svn: 285666

8 years ago[TBAA] Use wrapper objects instead of raw getOperand s; NFC
Sanjoy Das [Tue, 1 Nov 2016 02:58:30 +0000 (02:58 +0000)]
[TBAA] Use wrapper objects instead of raw getOperand s; NFC

This is intended to make the semantic intent clearer.

The wrapper objects are now generic to avoid `const_cast` s.  Since
`const` ness is part of the API of `MDNode::getMostGenericTBAA` (and
therefore I can't make things `const` all the way through without some
code churn outside TypeBasedAliasAnalysis.cpp), this seemed like the
cleanest solution.

llvm-svn: 285665

8 years agoImplement ABI proposal for throwing noexcept function pointers, per discussion
Richard Smith [Tue, 1 Nov 2016 01:34:46 +0000 (01:34 +0000)]
Implement ABI proposal for throwing noexcept function pointers, per discussion
on cxx-abi-dev (thread starting 2016-10-11). This is currently hidden behind a
cc1-only -m flag, pending discussion of how best to deal with language changes
that require use of new symbols from the ABI library.

llvm-svn: 285664

8 years agop0012: Teach resolving address of overloaded function with dependent exception
Richard Smith [Tue, 1 Nov 2016 01:31:23 +0000 (01:31 +0000)]
p0012: Teach resolving address of overloaded function with dependent exception
specification to resolve the exception specification as part of the type check,
in C++1z onwards. This is not actually part of P0012 / CWG1330 rules for when
an exception specification is "needed", but is necessary for sanity.

llvm-svn: 285663

8 years agoFix a bug where the EmulateInstructionARM64 handling of STP/LDP instructions
Jason Molenda [Tue, 1 Nov 2016 01:26:54 +0000 (01:26 +0000)]
Fix a bug where the EmulateInstructionARM64 handling of STP/LDP instructions
for floating point registers was not recording them correctly.  I needed to
change the EmulateInstructionARM64 unwind plans from using the DWARF
register numbering scheme to using the LLDB register numbering scheme
(because dwarf doesn't define register numbers for the 64-bit "d" registers).
Updated the EmulateInstructionARM64 unit tests to work with the LLDB
register numbering scheme and added a unit test to check the floating
point register spills & restores are correctly recorded.

https://reviews.llvm.org/D25864
<rdar://problem/28745483>

llvm-svn: 285662

8 years ago[TBAA] Rename accessors to be more idiomatic; NFC
Sanjoy Das [Tue, 1 Nov 2016 01:21:57 +0000 (01:21 +0000)]
[TBAA] Rename accessors to be more idiomatic; NFC

llvm-svn: 285661

8 years agoBitcode: Simplify BitstreamWriter::EnterBlockInfoBlock() interface.
Peter Collingbourne [Tue, 1 Nov 2016 01:18:57 +0000 (01:18 +0000)]
Bitcode: Simplify BitstreamWriter::EnterBlockInfoBlock() interface.

No block info block should need to define local abbreviations, so we can
always use a code width of 2.

Also change all block info block writers to use EnterBlockInfoBlock.

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

llvm-svn: 285660

8 years agoAMDGPU: Whitespace fixes
Matt Arsenault [Tue, 1 Nov 2016 00:55:14 +0000 (00:55 +0000)]
AMDGPU: Whitespace fixes

llvm-svn: 285659

8 years agoRemove executable bit on a source file
Stephane Sezer [Tue, 1 Nov 2016 00:21:57 +0000 (00:21 +0000)]
Remove executable bit on a source file

llvm-svn: 285658

8 years ago[ReachableCode] Skip over ExprWithCleanups in isConfigurationValue
Tim Shen [Tue, 1 Nov 2016 00:19:04 +0000 (00:19 +0000)]
[ReachableCode] Skip over ExprWithCleanups in isConfigurationValue

Summary: Fixes pr29152.

Reviewers: rsmith, pirama, krememek

Subscribers: cfe-commits

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

llvm-svn: 285657

8 years ago[DAG] disable nsw/nuw for add/sub/mul when simplifying based on demanded bits (PR30841)
Sanjay Patel [Mon, 31 Oct 2016 23:28:45 +0000 (23:28 +0000)]
[DAG] disable nsw/nuw for add/sub/mul when simplifying based on demanded bits (PR30841)

This bug was exposed by using nsw/nuw for more aggressive folds in:
https://reviews.llvm.org/rL284844

The changes mimic the IR demanded bits logic in InstCombiner::SimplifyDemandedUseBits(),
but we can't just flip flag bits in the DAG; we have to create a new node that has the
bits cleared.

This should fix:
https://llvm.org/bugs/show_bug.cgi?id=30841

llvm-svn: 285656

8 years ago[modules] Mark deleted functions as implicitly inline to allow merging
Eric Fiselier [Mon, 31 Oct 2016 23:07:15 +0000 (23:07 +0000)]
[modules] Mark deleted functions as implicitly inline to allow  merging

Summary: When merging definitions with ModulesLocalVisibility enabled it's important to make deleted definitions implicitly inline, otherwise they'll be diagnosed as a redefinition.

Reviewers: silvas, manmanren, rsmith

Subscribers: cfe-commits

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

llvm-svn: 285655

8 years ago[Hexagon] Garbage collect dead code.
Davide Italiano [Mon, 31 Oct 2016 22:56:56 +0000 (22:56 +0000)]
[Hexagon] Garbage collect dead code.

llvm-svn: 285654

8 years ago[clang-tidy] Update cert-err58-cpp to match its new generalised form.
Malcolm Parsons [Mon, 31 Oct 2016 22:47:04 +0000 (22:47 +0000)]
[clang-tidy] Update cert-err58-cpp to match its new generalised form.

Summary:
Aaron modified cert-err58-cpp to include all exceptions thrown before main()
Update the check to match.

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

llvm-svn: 285653

8 years agoFix a typo.
Evgeniy Stepanov [Mon, 31 Oct 2016 22:42:39 +0000 (22:42 +0000)]
Fix a typo.

Found with PVS-Studio here: http://www.viva64.com/en/b/0446/

llvm-svn: 285652

8 years ago[CMake] Populate the build directory's framework
Chris Bieneman [Mon, 31 Oct 2016 22:31:07 +0000 (22:31 +0000)]
[CMake] Populate the build directory's framework

This ensures that the Resources and clang headers are properly symlinked in LLDB's framework. This should fix the modules-related tests when building on Darwin with CMake if you are building a framework.

I have another fix coming which gets them working on Darwin if you're building liblldb instead of a framework.

llvm-svn: 285651

8 years ago[cfi] Fix missing !type annotation.
Evgeniy Stepanov [Mon, 31 Oct 2016 22:28:10 +0000 (22:28 +0000)]
[cfi] Fix missing !type annotation.

CFI (only in the cross-dso mode) fails to set !type annotations when
a function is used before it is defined.

llvm-svn: 285650

8 years agoCodeGen: further loosen -O0 CG for WoA division
Saleem Abdulrasool [Mon, 31 Oct 2016 22:12:37 +0000 (22:12 +0000)]
CodeGen: further loosen -O0 CG for WoA division

Generate the slowest possible codepath for noopt CodeGen.  Even trying to be
clever with the negated jump can cause out-of-range jumps.  Use a wide branch
instead. Although the code is modelled simplistically, the later optimizations
would recombine the branching into `cbz` if possible.  This re-enables the
previous optimization as well as hopefully gives us working code in all cases.

Addresses PR30356!

llvm-svn: 285649

8 years ago[ThinLTO] Disable importing and other cross-module optis at -O0
Teresa Johnson [Mon, 31 Oct 2016 22:12:21 +0000 (22:12 +0000)]
[ThinLTO] Disable importing and other cross-module optis at -O0

Summary:
There is no point to importing at -O0, since we won't inline. We should
also disable other cross-module optimizations.

(Plan to backport this fix to the 3.9 branch to fix PR30774)

Reviewers: pcc

Subscribers: johanengelen, mehdi_amini

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

llvm-svn: 285648

8 years ago[index] Fix repeated visitation of the same InitListExpr for indexing.
Argyrios Kyrtzidis [Mon, 31 Oct 2016 22:12:12 +0000 (22:12 +0000)]
[index] Fix repeated visitation of the same InitListExpr for indexing.

It was visited multiple times unnecessarily.

rdar://28985038

llvm-svn: 285647