platform/upstream/llvm.git
7 years agoNext set of additional error checks for invalid Mach-O files for bad load commands
Kevin Enderby [Tue, 20 Sep 2016 20:14:14 +0000 (20:14 +0000)]
Next set of additional error checks for invalid Mach-O files for bad load commands
that use the Mach::dylib_command type for the load commands that are
currently used in the MachOObjectFile constructor.

This contains the missing checks for LC_ID_DYLIB, LC_ID_DYLIB, etc.
load commands and the fields for the Mach::dylib_command type.

Also checks that only an MH_DYLIB or MH_STUB_DYLIB has an
LC_ID_DYLIB load command (and others filetype don’t) and there
is not more than one of these load commands.

llvm-svn: 282008

7 years agoRemove some boilerplate comments that don't explain anything.
Eric Christopher [Tue, 20 Sep 2016 19:45:06 +0000 (19:45 +0000)]
Remove some boilerplate comments that don't explain anything.

llvm-svn: 282007

7 years agoSimplify SORT and --sort-section command line option handling.
Rui Ueyama [Tue, 20 Sep 2016 19:42:41 +0000 (19:42 +0000)]
Simplify SORT and --sort-section command line option handling.

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

llvm-svn: 282006

7 years ago[x86] split up tests, regenerate checks
Sanjay Patel [Tue, 20 Sep 2016 19:31:30 +0000 (19:31 +0000)]
[x86] split up tests, regenerate checks

Note that we fail to eliminate 'or' with 0!

llvm-svn: 282005

7 years agoFix a regex error breaking tests.
Zachary Turner [Tue, 20 Sep 2016 19:10:56 +0000 (19:10 +0000)]
Fix a regex error breaking tests.

llvm-svn: 282004

7 years ago[CMake] Support overriding CLANG_VERSION_*
Chris Bieneman [Tue, 20 Sep 2016 19:09:21 +0000 (19:09 +0000)]
[CMake] Support overriding CLANG_VERSION_*

As with how we handle LLVM_VERSION_* variables we should support
overriding clang version variables.

llvm-svn: 282003

7 years ago[Profile] code refactoring: make getStep a method in base class
Xinliang David Li [Tue, 20 Sep 2016 19:07:22 +0000 (19:07 +0000)]
[Profile] code refactoring: make getStep a method in base class

llvm-svn: 282002

7 years agoRevert part of "AArch64: Do not test for CPUs, use SubtargetFeatures"
Evandro Menezes [Tue, 20 Sep 2016 19:02:09 +0000 (19:02 +0000)]
Revert part of "AArch64: Do not test for CPUs, use SubtargetFeatures"

This reverts part of commit 119e358d9635c8d1f3e7aee67e3ea3b8a62f8db6 by
removing FeatureUseRSqrt et al per request by Eric Christopher
<echristo@gmail.com> (v. http://bit.ly/2cmz6kW).

llvm-svn: 282001

7 years agoRevert "[AArch64] Use the reciprocal estimation machinery"
Evandro Menezes [Tue, 20 Sep 2016 19:02:06 +0000 (19:02 +0000)]
Revert "[AArch64] Use the reciprocal estimation machinery"

This reverts commit b7d42b0048f65346e9fa37fb65defeea7ce8c337 per request by
Eric Christopher <echristo@gmail.com> (v. http://bit.ly/2cmz6kW).

llvm-svn: 282000

7 years agoRevert "[AArch64] Properly validate the reciprocal estimation."
Evandro Menezes [Tue, 20 Sep 2016 19:02:02 +0000 (19:02 +0000)]
Revert "[AArch64] Properly validate the reciprocal estimation."

This reverts commit ad8ca1528242e2a4cb363e3779309e70eb7a430e per request by
Eric Christopher <echristo@gmail.com> (v. http://bit.ly/2cmz6kW).

llvm-svn: 281999

7 years agoAdd some entropy to the folder name in Driver/warning-options.cpp.
Zachary Turner [Tue, 20 Sep 2016 18:41:19 +0000 (18:41 +0000)]
Add some entropy to the folder name in Driver/warning-options.cpp.

It was trying to check that things behave correctly when a
non-existant folder was specified for -isysroot.  Incidentally,
I have a folder named FOO in the root of my drive, so this test
was failing.  Make this impossible by using %T to refer to a
definitely non-existant folder.:

llvm-svn: 281998

7 years agoCodeGen: further merge cstring literal construction
Saleem Abdulrasool [Tue, 20 Sep 2016 18:38:54 +0000 (18:38 +0000)]
CodeGen: further merge cstring literal construction

Use the new CreateCStringLiteral in an additional site.  Now all the C string
literals are created in one function.  Furthermore, mark the additional literal
as an `unnamed_addr constant`.

llvm-svn: 281997

7 years agoFix typo in documentation.
Nick Lewycky [Tue, 20 Sep 2016 18:37:25 +0000 (18:37 +0000)]
Fix typo in documentation.

Since this is a header it will break links to this section.

llvm-svn: 281996

7 years ago[cleanup] Remove excessive padding from TextTokenRetokenizer::Position
Alexander Shaposhnikov [Tue, 20 Sep 2016 18:32:48 +0000 (18:32 +0000)]
[cleanup] Remove excessive padding from TextTokenRetokenizer::Position

Reorder the fields of the struct TextTokenRetokenizer::Position to remove excessive padding.
Test plan: make -j8 check-clang

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

llvm-svn: 281995

7 years agoASAN: Don't drop debug info attachements for global variables.
Adrian Prantl [Tue, 20 Sep 2016 18:28:42 +0000 (18:28 +0000)]
ASAN: Don't drop debug info attachements for global variables.
This is a follow-up to r281284. Global Variables now can have
!dbg attachements, so ASAN should clone these when generating a
sanitized copy of a global variable.

<rdar://problem/24899262>

llvm-svn: 281994

7 years agoMake it so that one can register prefix matches as well as identical matches as extra...
Enrico Granata [Tue, 20 Sep 2016 18:26:30 +0000 (18:26 +0000)]
Make it so that one can register prefix matches as well as identical matches as extra cases for NSDictionary data formatting

llvm-svn: 281993

7 years agotsan: revert r281970
Dmitry Vyukov [Tue, 20 Sep 2016 18:05:06 +0000 (18:05 +0000)]
tsan: revert r281970

r281970 extended the check in a useful way,
but caused (true) failures on aarch64.
Revert it for now.

llvm-svn: 281992

7 years agoFix syntactical nit from r281990.
Adrian McCarthy [Tue, 20 Sep 2016 17:42:13 +0000 (17:42 +0000)]
Fix syntactical nit from r281990.

llvm-svn: 281991

7 years agoEmit S_COMPILE3 CodeView record
Adrian McCarthy [Tue, 20 Sep 2016 17:20:51 +0000 (17:20 +0000)]
Emit S_COMPILE3 CodeView record

CodeView has an S_COMPILE3 record to identify the compiler and source language of the compiland.  This record comes first in the debug$S section for the compiland. The debuggers rely on this record to know the source language of the code.

There was a little test fallout from introducing a new record into the symbols subsection.

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

llvm-svn: 281990

7 years agoDon't produce an error for undefined entry symbol.
Rafael Espindola [Tue, 20 Sep 2016 17:14:16 +0000 (17:14 +0000)]
Don't produce an error for undefined entry symbol.

This is particularly important when the symbol comes from a linker
script. It is common to use the same linker script for shared
libraries and executables. Without this we would always fail to link
shared libraries with -z,defs and a linker script with an ENTRY
directive.

llvm-svn: 281989

7 years ago[docs] Extend the code coverage docs some more
Vedant Kumar [Tue, 20 Sep 2016 17:11:18 +0000 (17:11 +0000)]
[docs] Extend the code coverage docs some more

Flesh out the section on interpreting coverage reports, mention the
coverage export feature, and add notes on how to build llvm with
coverage turned on.

llvm-svn: 281988

7 years ago[ScopDetection] Remove redundant checks for endless loops
Tobias Grosser [Tue, 20 Sep 2016 17:05:22 +0000 (17:05 +0000)]
[ScopDetection] Remove redundant checks for endless loops

Summary:
Both `canUseISLTripCount()` and `addOverApproximatedRegion()` contained checks
to reject endless loops which are now removed and replaced by a single check
in `isValidLoop()`.

For reporting such loops the `ReportLoopOverlapWithNonAffineSubRegion` is
renamed to `ReportLoopHasNoExit`. The test case
`ReportLoopOverlapWithNonAffineSubRegion.ll` is adapted and renamed as well.

The schedule generation in `buildSchedule()` is based on the following
assumption:

Given some block B that is contained in a loop L and a SESE region R,
we assume that L is contained in R or the other way around.

However, this assumption is broken in the presence of endless loops that are
nested inside other loops. Therefore, in order to prevent erroneous behavior
in `buildSchedule()`, r265280 introduced a corresponding check in
`canUseISLTripCount()` to reject endless loops. Unfortunately, it was possible
to bypass this check with -polly-allow-nonaffine-loops which was fixed by adding
another check to reject endless loops in `allowOverApproximatedRegion()` in
r273905. Hence there existed two separate locations that handled this case.

Thank you Johannes Doerfert for helping to provide the above background
information.

Reviewers: Meinersbur, grosser

Subscribers: _jdoerfert, pollydev

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

Contributed-by: Matthias Reisinger <d412vv1n@gmail.com>
llvm-svn: 281987

7 years agoX86: loosen an overly aggressive MachO assertion
Saleem Abdulrasool [Tue, 20 Sep 2016 17:05:04 +0000 (17:05 +0000)]
X86: loosen an overly aggressive MachO assertion

We would assert that the FP setup CFI used esp/rsp always.  This held up in
practice when the code was generated from IR.  However, with the integrated
assembler, it is possible to have the input be user specified assembly.  In such
a case, we cannot assume that the function implementation has a compact unwind
representation.  Loosen the assertion into a check and bail if we cannot
represent the frame pointer in the compact unwinding.

Addresses PR30453!

llvm-svn: 281986

7 years agoRedirect stderr to /dev/null. NFC.
Rafael Espindola [Tue, 20 Sep 2016 17:02:38 +0000 (17:02 +0000)]
Redirect stderr to /dev/null. NFC.

Makes the error output less confusing when this test fails.

llvm-svn: 281985

7 years ago[Writer] Fix a typo. NFC.
Davide Italiano [Tue, 20 Sep 2016 16:57:02 +0000 (16:57 +0000)]
[Writer] Fix a typo. NFC.

llvm-svn: 281984

7 years agoRemove more guts of TargetMachine::getNameWithPrefix and migrate one check to the...
Eric Christopher [Tue, 20 Sep 2016 16:05:02 +0000 (16:05 +0000)]
Remove more guts of TargetMachine::getNameWithPrefix and migrate one check to the TLOF mach-o version.

NFC intended.

llvm-svn: 281983

7 years agoRemove a use of subtarget initialization in the X86 backend so we can get rid of...
Eric Christopher [Tue, 20 Sep 2016 16:04:59 +0000 (16:04 +0000)]
Remove a use of subtarget initialization in the X86 backend so we can get rid of the default subtarget.

NFC intended.

llvm-svn: 281982

7 years agoRemove extra argument used once on TargetMachine::getNameWithPrefix and inline the...
Eric Christopher [Tue, 20 Sep 2016 16:04:50 +0000 (16:04 +0000)]
Remove extra argument used once on TargetMachine::getNameWithPrefix and inline the result into the singular caller.

llvm-svn: 281981

7 years agoImprove the -debug output for Debug Range Extension (NFC)
Keith Walker [Tue, 20 Sep 2016 16:04:31 +0000 (16:04 +0000)]
Improve the -debug output for Debug Range Extension (NFC)

Include header messages and remove unnecessary blank lines.

llvm-svn: 281980

7 years agoReplace 'isProvablyNonNull' with existing utility llvm::IsKnownNonNull which handles...
Nick Lewycky [Tue, 20 Sep 2016 15:49:58 +0000 (15:49 +0000)]
Replace 'isProvablyNonNull' with existing utility llvm::IsKnownNonNull which handles more cases. Noticed by inspection.

Because of how the IR generation works, this isn't expected to cause an observable difference.

llvm-svn: 281979

7 years agoDisable --rosegment when we have linker scripts.
Rafael Espindola [Tue, 20 Sep 2016 15:22:27 +0000 (15:22 +0000)]
Disable --rosegment when we have linker scripts.

Linker scripts are responsible for aliging '.'. Since they are
designed for bfd which has no --rosegment, they don't align the RO to
RX transition.

llvm-svn: 281978

7 years agoGlobalISel: split aggregates for PCS lowering
Tim Northover [Tue, 20 Sep 2016 15:20:36 +0000 (15:20 +0000)]
GlobalISel: split aggregates for PCS lowering

This should match the existing behaviour for passing complicated struct and
array types, in particular HFAs come through like that from Clang.

For C & C++ we still need to somehow support all the weird ABI flags, or at
least those that are present in the IR (signext, byval, ...), and stack-based
parameter passing.

llvm-svn: 281977

7 years agoMake tests less dependent on the exact layout.
Rafael Espindola [Tue, 20 Sep 2016 15:08:24 +0000 (15:08 +0000)]
Make tests less dependent on the exact layout.

In most cases that means just not checking the address when we don't
need it.

For some tests it is easier to just set . to a known value.

llvm-svn: 281976

7 years ago[mips] MSA intrinsics header file
Simon Dardis [Tue, 20 Sep 2016 15:07:36 +0000 (15:07 +0000)]
[mips] MSA intrinsics header file

This patch adds the msa.h header file containing the shorter names for the
MSA instrinsics, e.g. msa_sll_b for builtin_msa_sll_b.

Reviewers: vkalintiris, zoran.jovanovic

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

llvm-svn: 281975

7 years agoMove test to the correct directory. NFC.
Rafael Espindola [Tue, 20 Sep 2016 14:49:18 +0000 (14:49 +0000)]
Move test to the correct directory. NFC.

llvm-svn: 281974

7 years ago[X86][SSE] Regenerate multiple combine tests
Simon Pilgrim [Tue, 20 Sep 2016 14:42:45 +0000 (14:42 +0000)]
[X86][SSE] Regenerate multiple combine tests

llvm-svn: 281973

7 years agomove variables closer to their uses; add FIXMEs; NFC
Sanjay Patel [Tue, 20 Sep 2016 14:36:14 +0000 (14:36 +0000)]
move variables closer to their uses; add FIXMEs; NFC

llvm-svn: 281972

7 years ago[XRay] ARM 32-bit no-Thumb support in compiler-rt
Dean Michael Berris [Tue, 20 Sep 2016 14:35:57 +0000 (14:35 +0000)]
[XRay] ARM 32-bit no-Thumb support in compiler-rt

This is a port of XRay to ARM 32-bit, without Thumb support yet.
This is one of 3 commits to different repositories of XRay ARM port. The other 2 are:

https://reviews.llvm.org/D23931 (LLVM)
https://reviews.llvm.org/D23932 (Clang test)

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

llvm-svn: 281971

7 years agotsan: check more addresses in CheckShadowMapping
Dmitry Vyukov [Tue, 20 Sep 2016 13:30:01 +0000 (13:30 +0000)]
tsan: check more addresses in CheckShadowMapping

There is still a handful of them, so should not slow down
tsan apps. But gives assurance if we change/complicate
shadow mappings.

llvm-svn: 281970

7 years agotsan: make CHECK more robust
Dmitry Vyukov [Tue, 20 Sep 2016 13:28:20 +0000 (13:28 +0000)]
tsan: make CHECK more robust

Enable more ignores when we start crashing.
Unwind in CHECK SIGSEGVs if happens early:

FATAL: ThreadSanitizer CHECK failed: ../projects/compiler-rt/lib/tsan/rtl/tsan_platform_posix.cc:105 "((beg)) <= ((end))" (0x8000000000, 0x4000000000)
Program received signal SIGSEGV, Segmentation fault.
__tsan::MetaMap::GetAndLock (this=0x1337c88 <__tsan::ctx_placeholder+8>, thr=thr@entry=0x7ffff7f91800, pc=pc@entry=4639488, addr=addr@entry=140737339086992, write_lock=write_lock@entry=true,
    create=create@entry=true) at ../projects/compiler-rt/lib/tsan/rtl/tsan_sync.cc:208
208   u32 idx0 = *meta;
(gdb) bt
#0  __tsan::MetaMap::GetAndLock (this=0x1337c88 <__tsan::ctx_placeholder+8>, thr=thr@entry=0x7ffff7f91800, pc=pc@entry=4639488, addr=addr@entry=140737339086992, write_lock=write_lock@entry=true,
    create=create@entry=true) at ../projects/compiler-rt/lib/tsan/rtl/tsan_sync.cc:208
#1  0x00000000004a965f in __tsan::MetaMap::GetOrCreateAndLock (this=<optimized out>, thr=thr@entry=0x7ffff7f91800, pc=pc@entry=4639488, addr=addr@entry=140737339086992, write_lock=write_lock@entry=true)
    at ../projects/compiler-rt/lib/tsan/rtl/tsan_sync.cc:198
#2  0x00000000004a162a in __tsan::Release (thr=0x7ffff7f91800, pc=pc@entry=4639488, addr=addr@entry=140737339086992) at ../projects/compiler-rt/lib/tsan/rtl/tsan_rtl_mutex.cc:395
#3  0x000000000046cc40 in __interceptor_pthread_once (o=0x7ffff71a5890 <once_regsizes>, f=0x7ffff6f9d9c0 <init_dwarf_reg_size_table>) at ../projects/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc:1334
#4  0x00007ffff6f9fe86 in __gthread_once (__func=0x7ffff6f9d9c0 <init_dwarf_reg_size_table>, __once=0x7ffff71a5890 <once_regsizes>) at ./gthr-default.h:699
#5  uw_init_context_1 (context=context@entry=0x7fffffffd6d0, outer_cfa=outer_cfa@entry=0x7fffffffd980, outer_ra=0x437d13 <__sanitizer::BufferedStackTrace::SlowUnwindStack(unsigned long, unsigned int)+67>)
    at ../../../src/libgcc/unwind-dw2.c:1572
#6  0x00007ffff6fa06a8 in _Unwind_Backtrace (trace=0x437c30 <__sanitizer::Unwind_Trace(_Unwind_Context*, void*)>, trace_argument=0x7fffffffd980) at ../../../src/libgcc/unwind.inc:283
#7  0x0000000000437d13 in __sanitizer::BufferedStackTrace::SlowUnwindStack (this=0x7ffff6103208, pc=pc@entry=4863574, max_depth=max_depth@entry=256)
    at ../projects/compiler-rt/lib/sanitizer_common/sanitizer_unwind_linux_libcdep.cc:125
#8  0x0000000000434f4a in __sanitizer::BufferedStackTrace::Unwind (this=this@entry=0x7ffff6103208, max_depth=max_depth@entry=256, pc=pc@entry=4863574, bp=bp@entry=0, context=context@entry=0x0,
    stack_top=stack_top@entry=0, stack_bottom=stack_bottom@entry=0, request_fast_unwind=request_fast_unwind@entry=false) at ../projects/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_libcdep.cc:76
#9  0x00000000004a36b3 in PrintCurrentStackSlow (pc=4863574) at ../projects/compiler-rt/lib/tsan/rtl/tsan_rtl_report.cc:696
#10 __tsan::TsanCheckFailed (file=<optimized out>, line=<optimized out>, cond=<optimized out>, v1=<optimized out>, v2=<optimized out>) at ../projects/compiler-rt/lib/tsan/rtl/tsan_rtl_report.cc:44
#11 0x000000000042dfd6 in __sanitizer::CheckFailed (file=file@entry=0x4b9fd0 "../projects/compiler-rt/lib/tsan/rtl/tsan_platform_posix.cc", line=line@entry=105,
    cond=cond@entry=0x4ba049 "((beg)) <= ((end))", v1=v1@entry=549755813888, v2=v2@entry=274877906944) at ../projects/compiler-rt/lib/sanitizer_common/sanitizer_termination.cc:79
#12 0x00000000004aa36c in ProtectRange (end=274877906944, beg=549755813888) at ../projects/compiler-rt/lib/tsan/rtl/tsan_platform_posix.cc:105
#13 __tsan::CheckAndProtect () at ../projects/compiler-rt/lib/tsan/rtl/tsan_platform_posix.cc:133
#14 0x00000000004a9e95 in __tsan::InitializePlatform () at ../projects/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cc:280
#15 0x0000000000497e73 in __tsan::Initialize (thr=0x7ffff7f91800) at ../projects/compiler-rt/lib/tsan/rtl/tsan_rtl.cc:343
#16 0x00007ffff7dea25a in _dl_init (main_map=0x7ffff7ffe1c8, argc=1, argv=0x7fffffffdb88, env=0x7fffffffdb98) at dl-init.c:111
#17 0x00007ffff7ddb30a in _dl_start_user () at rtld.c:871

llvm-svn: 281969

7 years agoRemove empty section commands.
Rafael Espindola [Tue, 20 Sep 2016 13:12:07 +0000 (13:12 +0000)]
Remove empty section commands.

We were already not creating them, and with this other parts of the
code don't have to worry about them.

llvm-svn: 281968

7 years ago[AMDGPU][mc] Add regression tests for Bug 28168
Artem Tamazov [Tue, 20 Sep 2016 11:58:40 +0000 (11:58 +0000)]
[AMDGPU][mc] Add regression tests for Bug 28168

llvm-svn: 281967

7 years agoAVX-512: Fixed a bug in lowering saturated operations on KNL.
Elena Demikhovsky [Tue, 20 Sep 2016 11:02:26 +0000 (11:02 +0000)]
AVX-512: Fixed a bug in lowering saturated operations on KNL.

The generated code is still not optimal.

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

llvm-svn: 281966

7 years ago[AMDGPU] Refactor VOP3 instruction TD definitions
Valery Pykhtin [Tue, 20 Sep 2016 10:41:16 +0000 (10:41 +0000)]
[AMDGPU] Refactor VOP3 instruction TD definitions

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

llvm-svn: 281965

7 years agoMake llvm::ConvertDebugDeclareToDebugValue() be a void function (NFC)
Keith Walker [Tue, 20 Sep 2016 10:36:17 +0000 (10:36 +0000)]
Make llvm::ConvertDebugDeclareToDebugValue() be a void function (NFC)

The routines llvm::ConvertDebugDeclareToDebugValue() always returned
a true value which was never checked at the call site; change the
function return type to void.

This NFC cleanup was approved in the review https://reviews.llvm.org/D23715

llvm-svn: 281964

7 years agoAMDGPU: Improve documentation.
Nikolay Haustov [Tue, 20 Sep 2016 09:04:51 +0000 (09:04 +0000)]
AMDGPU: Improve documentation.

Summary:
Add links to ISA manuals and ABI.
Add text about assembler syntax.
Add info about instructions operands.
Add instruction examples for each encoding.
Update directives section, add missing .amdgpu_hsa_kernel.

Reviewers: tstellarAMD, SamWot, vpykhtin

Subscribers: kzhuravl, wdng, nhaehnle, yaxunl, tony-tye, artem.tamazov, llvm-commits

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

llvm-svn: 281962

7 years agoReverting revision 281960 due to test failures.
Dorit Nuzman [Tue, 20 Sep 2016 08:27:48 +0000 (08:27 +0000)]
Reverting revision 281960 due to test failures.

llvm-svn: 281961

7 years ago[SROA] Preserve llvm.mem.parallel_loop_access metadata.
Dorit Nuzman [Tue, 20 Sep 2016 07:50:49 +0000 (07:50 +0000)]
[SROA] Preserve llvm.mem.parallel_loop_access metadata.

SROA doesn't preserve the llvm.mem.parallel_loop_access metadata when it
transforms loads/stores. This patch fixes a couple occurences of this
issue.

(Partially addresses PR28981).

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

llvm-svn: 281960

7 years ago[AVX-512] Teach X86InstrInfo::copyPhysReg to use a 512-bit move if XMM16-XMM31 or...
Craig Topper [Tue, 20 Sep 2016 06:49:17 +0000 (06:49 +0000)]
[AVX-512] Teach X86InstrInfo::copyPhysReg to use a 512-bit move if XMM16-XMM31 or YMM16-YMM31 are the source or dest of the copy and VLX is not supported.

This can happen with SUBREG_TO_REG of ZMM16-ZMM31. Fixes PR30430.

llvm-svn: 281959

7 years ago[AVX-512] Use 512-bit vcvtps2ph/vcvtph2ps to implement fp_to_f16/f16_to_fp when F16C...
Craig Topper [Tue, 20 Sep 2016 05:44:47 +0000 (05:44 +0000)]
[AVX-512] Use 512-bit vcvtps2ph/vcvtph2ps to implement fp_to_f16/f16_to_fp when F16C and VLX are not supported.

Fixes PR23941.

llvm-svn: 281958

7 years agoBranchFolder: Fix invalid undef flags after merge.
Matthias Braun [Tue, 20 Sep 2016 01:14:42 +0000 (01:14 +0000)]
BranchFolder: Fix invalid undef flags after merge.

It is legal to merge instructions with different undef flags; However we
must drop the undef flag from the merged instruction if it isn't present
everywhere.

This fixes http://llvm.org/PR30199

llvm-svn: 281957

7 years agoMachine{Instr|Operand}: Clarify some isIdenticalTo() subtleties.
Matthias Braun [Tue, 20 Sep 2016 01:14:39 +0000 (01:14 +0000)]
Machine{Instr|Operand}: Clarify some isIdenticalTo() subtleties.

llvm-svn: 281956

7 years ago[RegisterBankInfo] Avoid heap allocation in InstructionMapping.
Quentin Colombet [Tue, 20 Sep 2016 00:48:44 +0000 (00:48 +0000)]
[RegisterBankInfo] Avoid heap allocation in InstructionMapping.

Use SmallVector instead of dynamically allocated arrays for the mapping of the
operands in the InstructionMapping. That way we avoid heap allocation for most
of the cases. Ultimately, we should not have to rely on such tricky, the
instances of InstructionMapping would be TableGen'ed.

This improves the compilation time of the RegBankSelect pass.

llvm-svn: 281955

7 years agoclang-change-namespace: Update libdeps.
NAKAMURA Takumi [Tue, 20 Sep 2016 00:44:45 +0000 (00:44 +0000)]
clang-change-namespace: Update libdeps.

FIXME: It seems clangFormat is not referred.
llvm-svn: 281954

7 years ago[x86] fix variable names; NFC
Sanjay Patel [Tue, 20 Sep 2016 00:27:22 +0000 (00:27 +0000)]
[x86] fix variable names; NFC

llvm-svn: 281953

7 years ago[sanitizer-coverage] add comdat to coverage guards if needed
Kostya Serebryany [Tue, 20 Sep 2016 00:16:54 +0000 (00:16 +0000)]
[sanitizer-coverage] add comdat to coverage guards if needed

llvm-svn: 281952

7 years agoRemove a use of std::list.
Rui Ueyama [Tue, 20 Sep 2016 00:02:06 +0000 (00:02 +0000)]
Remove a use of std::list.

llvm-svn: 281951

7 years ago[x86] auto-generate checks
Sanjay Patel [Mon, 19 Sep 2016 23:44:50 +0000 (23:44 +0000)]
[x86] auto-generate checks

llvm-svn: 281950

7 years ago[LCSSA] Cache LoopExits to avoid wasted work
Philip Reames [Mon, 19 Sep 2016 23:30:23 +0000 (23:30 +0000)]
[LCSSA] Cache LoopExits to avoid wasted work

When looking at the scribus_1.3 example from https://llvm.org/bugs/show_bug.cgi?id=10584, I noticed that we were spending a large amount of time computing loop exits in LCSSA. This code appears to be written with the assumption that LoopExits are stored in the Loop and thus cheap to query. This is not true, so we should cache the result across the potentially long running loop which tends to visit a small handful of Loops.

On the particular example from 10584, this change drops the time spent in LCSSA computation by about 80%.

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

llvm-svn: 281949

7 years ago[RegisterBankInfo] Adapt call to std::fill due to use of SmallVector.
Quentin Colombet [Mon, 19 Sep 2016 23:18:47 +0000 (23:18 +0000)]
[RegisterBankInfo] Adapt call to std::fill due to use of SmallVector.

This was meant to be commited with my previous commit.

llvm-svn: 281948

7 years agoMerge branch 'ADCE5'
David Callahan [Mon, 19 Sep 2016 23:17:58 +0000 (23:17 +0000)]
Merge branch 'ADCE5'

llvm-svn: 281947

7 years ago[GC] Don't crash when printing the special Discarded GC section.
Davide Italiano [Mon, 19 Sep 2016 23:15:51 +0000 (23:15 +0000)]
[GC] Don't crash when printing the special Discarded GC section.

InputSection<ELFT>::Discarded has no name and it's not backed by
a file. Trying to report it as discared will cause a nullptr
dereference, therefore a crash. Skip it.

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

llvm-svn: 281946

7 years ago[Kaleidoscope] Make Chapter 2 use llvm::make_unique, rather than a helper.
Lang Hames [Mon, 19 Sep 2016 23:00:27 +0000 (23:00 +0000)]
[Kaleidoscope] Make Chapter 2 use llvm::make_unique, rather than a helper.

This essentially reverts r251936, minimizing the difference between Chapter2
and Chapter 3, and making Chapter 2's code match the tutorial text.

llvm-svn: 281945

7 years ago[x86] use getSignBit() to simplify code; NFCI
Sanjay Patel [Mon, 19 Sep 2016 22:07:27 +0000 (22:07 +0000)]
[x86] use getSignBit() to simplify code; NFCI

llvm-svn: 281944

7 years agoFixed the build by changing a couple of const char *s to StringRefs.
Sean Callanan [Mon, 19 Sep 2016 22:06:12 +0000 (22:06 +0000)]
Fixed the build by changing a couple of const char *s to StringRefs.

llvm-svn: 281943

7 years agoConvert 3 more functions to use a StringRef.
Zachary Turner [Mon, 19 Sep 2016 21:56:59 +0000 (21:56 +0000)]
Convert 3 more functions to use a StringRef.

This converts Args::Unshift, Args::AddOrReplaceEnvironmentVariable,
and Args::ContainsEnvironmentVariable to use StringRefs.  The code
is also simplified somewhat as a result.

llvm-svn: 281942

7 years agoMove the armv8.1-a ras test to a negative with noras test as ras is
Eric Christopher [Mon, 19 Sep 2016 21:55:04 +0000 (21:55 +0000)]
Move the armv8.1-a ras test to a negative with noras test as ras is
included in armv8.1-a by default and so we weren't testing anything.

llvm-svn: 281941

7 years agoBitcodeWriter: fix emission of invoke when calling a var-arg function with operand...
Mehdi Amini [Mon, 19 Sep 2016 21:27:04 +0000 (21:27 +0000)]
BitcodeWriter: fix emission of invoke when calling a var-arg function with operand bundles

llvm-svn: 281940

7 years agoMisleading comments of SplitBlockAndInsertIfThenElse in BasicBlockUtils.h
Evgeniy Stepanov [Mon, 19 Sep 2016 21:26:05 +0000 (21:26 +0000)]
Misleading comments of SplitBlockAndInsertIfThenElse in BasicBlockUtils.h

The comments of SplitBlockAndInsertIfThenElse say the SplitBefore instruction will stay in the old block.
But according to the implementation(split the block at SplitBefore by using splitBasicBlock), the SplitBefore will be moved to the new block.

This patch fixes the comments.

Patch by Zhe Yu Wu.

llvm-svn: 281939

7 years ago[scudo] Modify Scudo to use its own Secondary Allocator
Kostya Kortchinsky [Mon, 19 Sep 2016 21:11:55 +0000 (21:11 +0000)]
[scudo] Modify Scudo to use its own Secondary Allocator

Summary:
The Sanitizer Secondary Allocator was not entirely ideal was Scudo for several
reasons: decent amount of unneeded code, redundant checks already performed by
the front end, unneeded data structures, difficulty to properly protect the
secondary chunks header.

Given that the second allocator is pretty straight forward, Scudo will use its
own, trimming all the unneeded code off of the Sanitizer one. A significant
difference in terms of security is that now each secondary chunk is preceded
and followed by a guard page, thus mitigating overflows into and from the
chunk.

A test was added as well to illustrate the overflow & underflow situations
into the guard pages.

Reviewers: kcc

Subscribers: llvm-commits

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

llvm-svn: 281938

7 years ago[X86][SSE] Updated vector abs tests
Simon Pilgrim [Mon, 19 Sep 2016 20:50:35 +0000 (20:50 +0000)]
[X86][SSE] Updated vector abs tests

Renamed and added v2i64 / v4i64 tests

llvm-svn: 281937

7 years agoFix signatures of fallback tow(upper|lower)_l.
Dan Albert [Mon, 19 Sep 2016 20:42:57 +0000 (20:42 +0000)]
Fix signatures of fallback tow(upper|lower)_l.

Summary:
These functions take and return wint_t, not int:
http://pubs.opengroup.org/onlinepubs/9699919799/functions/towupper.html

Reviewers: mclow.lists, EricWF

Subscribers: cfe-commits

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

llvm-svn: 281936

7 years agoAdd missing dependency to change-namespace.
Eric Liu [Mon, 19 Sep 2016 20:41:39 +0000 (20:41 +0000)]
Add missing dependency to change-namespace.

llvm-svn: 281935

7 years ago[analyzer] Calculate extent size for memory regions allocated by new expression.
Gabor Horvath [Mon, 19 Sep 2016 20:39:52 +0000 (20:39 +0000)]
[analyzer] Calculate extent size for memory regions allocated by new expression.

ArrayBoundChecker did not detect out of bounds memory access errors in case an
array was allocated by the new expression. This patch resolves this issue.

Patch by Daniel Krupp!

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

llvm-svn: 281934

7 years ago[libFuzzer] use sleep() instead of std::this_thread::sleep_for to avoid coverage...
Kostya Serebryany [Mon, 19 Sep 2016 20:32:34 +0000 (20:32 +0000)]
[libFuzzer] use sleep() instead of  std::this_thread::sleep_for to  avoid coverage from instrumented libc++

llvm-svn: 281933

7 years agoUse FileCheck variables. NFC.
Rafael Espindola [Mon, 19 Sep 2016 20:23:19 +0000 (20:23 +0000)]
Use FileCheck variables. NFC.

llvm-svn: 281932

7 years agoMap .data.rel.ro correctly.
Rafael Espindola [Mon, 19 Sep 2016 19:59:21 +0000 (19:59 +0000)]
Map .data.rel.ro correctly.

An input section named .data.rel.ro now maps to an output section
named .data.rel.ro. Before we were mapping it to .data.

llvm-svn: 281931

7 years agoMake this test a bit stricter.
Rafael Espindola [Mon, 19 Sep 2016 19:56:51 +0000 (19:56 +0000)]
Make this test a bit stricter.

By making every section on byte and checking the size it now shows how
many sections were concatenated into each output section.

llvm-svn: 281930

7 years agoDon't CHECK the addresses. NFC
Rafael Espindola [Mon, 19 Sep 2016 18:58:30 +0000 (18:58 +0000)]
Don't CHECK the addresses. NFC

That is not what this test is about. This reduces changes in another
patch that changes layout.

llvm-svn: 281929

7 years agoHandle early inline for hot callsites that reside in the same basic block.
Dehao Chen [Mon, 19 Sep 2016 18:38:14 +0000 (18:38 +0000)]
Handle early inline for hot callsites that reside in the same basic block.

Summary: Callsites in the same basic block should share the same hotness. This patch checks for the hottest callsite in the same basic block, and use the hotness for all callsites in that basic block for early inline decisions. It also fixes the test to add "-S" so theat the "CHECK-NOT" is actually checking the content.

Reviewers: dnovillo

Subscribers: llvm-commits

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

llvm-svn: 281927

7 years agoFix compilation of unit tests.
Zachary Turner [Mon, 19 Sep 2016 18:32:23 +0000 (18:32 +0000)]
Fix compilation of unit tests.

llvm-svn: 281926

7 years ago[libc++] Fix extern template visibility for Windows
Shoaib Meenai [Mon, 19 Sep 2016 18:29:07 +0000 (18:29 +0000)]
[libc++] Fix extern template visibility for Windows

On Windows, marking an `extern template class` declaration as exported
actually forces an instantiation, which is not the desired behavior.
Instead, the actual explicit instantiations need to be exported.

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

llvm-svn: 281925

7 years agoReorder initializers in CallStackFrame so that we don't get a warning.
Samuel Antao [Mon, 19 Sep 2016 18:13:13 +0000 (18:13 +0000)]
Reorder initializers in CallStackFrame so that we don't get a warning.

llvm-svn: 281923

7 years agoTry to fix freebsd and android builds.
Zachary Turner [Mon, 19 Sep 2016 18:03:54 +0000 (18:03 +0000)]
Try to fix freebsd and android builds.

llvm-svn: 281922

7 years agoReplace __ANDROID__ with __BIONIC__.
Dan Albert [Mon, 19 Sep 2016 18:00:45 +0000 (18:00 +0000)]
Replace __ANDROID__ with __BIONIC__.

Summary:
None of these checks are specific to Android devices. If libc++ was
used with Bionic on a normal Linux system these checks would still be
needed.

Reviewers: mclow.lists, EricWF

Subscribers: compnerd, tberghammer, danalbert, srhines, cfe-commits

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

llvm-svn: 281921

7 years agoTrying to fix name conflict in change-namespace tool.
Eric Liu [Mon, 19 Sep 2016 17:58:59 +0000 (17:58 +0000)]
Trying to fix name conflict in change-namespace tool.

llvm-svn: 281920

7 years agoFix more functions in Args to use StringRef.
Zachary Turner [Mon, 19 Sep 2016 17:54:06 +0000 (17:54 +0000)]
Fix more functions in Args to use StringRef.

This patch also marks the const char* versions as =delete to prevent
their use.  This has the potential to cause build breakages on some
platforms which I can't compile.  I have tested on Windows, Linux,
and OSX.  Best practices for fixing broken callsites are outlined in
Args.h in a comment above the deleted function declarations.

Eventually we can remove these =delete declarations, but for now they
are important to make sure that all implicit conversions from
const char * are manually audited to make sure that they do not invoke a
conversion from nullptr.

llvm-svn: 281919

7 years agoA clang tool for changing surrouding namespaces of class/function definitions.
Eric Liu [Mon, 19 Sep 2016 17:40:32 +0000 (17:40 +0000)]
A clang tool for changing surrouding namespaces of class/function definitions.

Summary:
A tool for changing surrouding namespaces of class/function definitions while keeping
references to types in the changed namespace correctly qualified by prepending
namespace specifiers before them.

Example: test.cc
   namespace na {
   class X {};
   namespace nb {
   class Y { X x; };
   } // namespace nb
   } // namespace na

To move the definition of class Y from namespace "na::nb" to "x::y", run:
   clang-change-namespace --old_namespace "na::nb" \
     --new_namespace "x::y" --file_pattern "test.cc" test.cc --

Output:
   namespace na {
   class X {};
   } // namespace na
   namespace x {
   namespace y {
   class Y { na::X x; };
   } // namespace y
   } // namespace x

Reviewers: alexfh, omtcyfz, hokein

Subscribers: mgorny, klimek, djasper, beanz, alexshap, Eugene.Zelenko, cfe-commits

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

llvm-svn: 281918

7 years ago[Writer] Rename variables to reflect reality. NFCI.
Davide Italiano [Mon, 19 Sep 2016 17:38:39 +0000 (17:38 +0000)]
[Writer] Rename variables to reflect reality. NFCI.

The InputSection variables in the Writer were named `C`. This
was because when the ELF linker was ported (from COFF)
the name `Chunks` for input sections was retained.
Luckily we switched to a more ELF-compliant jargon, but these
variables weren't reanamed accordingly during the transition.

llvm-svn: 281917

7 years ago[RegisterBankInfo] Avoid heap allocation in most cases.
Quentin Colombet [Mon, 19 Sep 2016 17:33:55 +0000 (17:33 +0000)]
[RegisterBankInfo] Avoid heap allocation in most cases.

The OperandsMapper class is used heavy in RegBankSelect and each
instantiation triggered a heap allocation for the array of operands.
Instead, use a SmallVector with a big enough size such that most of the
cases do not have to use dynamically allocated memory.

This improves the compile time of the RegBankSelect pass.

llvm-svn: 281916

7 years ago[OpenCL] Allow half type kernel argument when cl_khr_fp16 is enabled
Yaxun Liu [Mon, 19 Sep 2016 17:11:22 +0000 (17:11 +0000)]
[OpenCL] Allow half type kernel argument when cl_khr_fp16 is enabled

llvm-svn: 281915

7 years agoLiveRangeCalc: Fix reporting of invalid vreg usage in liveness calculation
Matthias Braun [Mon, 19 Sep 2016 16:49:45 +0000 (16:49 +0000)]
LiveRangeCalc: Fix reporting of invalid vreg usage in liveness calculation

Machine programs need a definition of each vreg before reaching a use
(the definition may come from an IMPLICIT_DEF instruction). This class
of errors is not detected by the MachineVerifier because of efficiency
concerns. LiveRangeCalc used to report these problems, make it do that
again (followup to r279625).

Also use report_fatal_error() instead of llvm_unreachable() as the error
reporting is only present in asserts build anyway.

llvm-svn: 281914

7 years agoXcode: support gtests that use the Inputs dir
Todd Fiala [Mon, 19 Sep 2016 16:42:41 +0000 (16:42 +0000)]
Xcode: support gtests that use the Inputs dir

This change adds support for the gtests that require input data
in the Inputs files.  This is done through a new Xcode script
phase that runs the scripts/Xcode/prepare-gtest-run-dir.sh script.
That script simply copies the contents of all unittests/**/Inputs
dirs into ${TARGET_BUILD_DIR}/Inputs before running the test.

This change also renames the Xcode 'gtest-for-debugging' to
'gtest-build', and makes the gtest "build and run" target
depend on gtest-build.  This reduces replication within the
targets.  gtest .c/.cpp files now should only be added to
the gtest-build target.

llvm-svn: 281913

7 years agoOnly set branch weight during sample pgo annotation when max_weight of the branch...
Dehao Chen [Mon, 19 Sep 2016 16:33:41 +0000 (16:33 +0000)]
Only set branch weight during sample pgo annotation when max_weight of the branch is non-zero. Otherwise use default static profile to set branch probability.

Summary: It does not make sense to set equal weights for all unkown branches as we have static branch prediction available.

Reviewers: dnovillo

Subscribers: llvm-commits

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

llvm-svn: 281912

7 years agoUse call target count to derive the call instruction weight
Dehao Chen [Mon, 19 Sep 2016 16:06:37 +0000 (16:06 +0000)]
Use call target count to derive the call instruction weight

Summary: The call target count profile is directly derived from LBR branch->target data. This is more reliable than instruction frequency profiles that could be moved across basic block boundaries. This patches uses call target count profile to annotate call instructions.

Reviewers: davidxl, dnovillo

Subscribers: llvm-commits

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

llvm-svn: 281911

7 years agoRemove InstructionCombining and its related pass from sample pgo passes as we can...
Dehao Chen [Mon, 19 Sep 2016 16:02:52 +0000 (16:02 +0000)]
Remove InstructionCombining and its related pass from sample pgo passes as we can handle "invoke" correctly.

Summary: We previously relies on InstructionCombining pass to remove invoke instructions. Now that we can inline invoke instructions correctly, we do not need these passes any more.

Reviewers: dnovillo

Subscribers: llvm-commits

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

llvm-svn: 281910

7 years ago[compiler-rt] Add support for the dynamic shadow allocation
Etienne Bergeron [Mon, 19 Sep 2016 15:59:01 +0000 (15:59 +0000)]
[compiler-rt] Add support for the dynamic shadow allocation

Summary:
This patch is adding the needed code to compiler-rt to support
dynamic shadow.

This is to support this patch:
  https://reviews.llvm.org/D23354

It's adding support for using a shadow placed at a dynamic address determined
at runtime.

The dynamic shadow is required to work on windows 64-bits.

Reviewers: rnk, kcc, vitalybuka

Subscribers: kubabrecka, dberris, llvm-commits, chrisha

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

llvm-svn: 281909

7 years ago[asan] Support dynamic shadow address instrumentation
Etienne Bergeron [Mon, 19 Sep 2016 15:58:38 +0000 (15:58 +0000)]
[asan] Support dynamic shadow address instrumentation

Summary:
This patch is adding the support for a shadow memory with
dynamically allocated address range.

The compiler-rt needs to export a symbol containing the shadow
memory range.

This is required to support ASAN on windows 64-bits.

Reviewers: kcc, rnk, vitalybuka

Subscribers: kubabrecka, dberris, llvm-commits, chrisha

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

llvm-svn: 281908

7 years agoRemove excessive padding from the struct CallStackFrame
Alexander Shaposhnikov [Mon, 19 Sep 2016 15:57:29 +0000 (15:57 +0000)]
Remove excessive padding from the struct CallStackFrame

The struct CallStackFrame is in lib/AST/ExprConstant.cpp
inside anonymous namespace.
This diff reorders the fields and removes excessive padding.
Test plan: make -j8 check-clang

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

llvm-svn: 281907

7 years ago[Support] Add StringRef::withNullAsEmpty()
Zachary Turner [Mon, 19 Sep 2016 15:34:51 +0000 (15:34 +0000)]
[Support] Add StringRef::withNullAsEmpty()

When porting large bodies of code from using const char*
to StringRef, it is helpful to be able to treat nullptr
as an empty string, since that it is often what it is used
to indicate in C-style code.

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

llvm-svn: 281906