platform/upstream/llvm.git
9 years agoThis reverts commit r224668 and r224667.
Rafael Espindola [Tue, 23 Dec 2014 15:57:12 +0000 (15:57 +0000)]
This reverts commit r224668 and r224667.

r224667 broke bootstrap on Fedora 20 X86_64 (at least).

See pr22006 for the details.

r224668 depends on r224667.

llvm-svn: 224770

9 years ago[OCaml] PR22014: OCaml bindings didn't link to libLLVM-*.so with -Wl,--as-needed
Peter Zotov [Tue, 23 Dec 2014 13:09:59 +0000 (13:09 +0000)]
[OCaml] PR22014: OCaml bindings didn't link to libLLVM-*.so with -Wl,--as-needed

Patch by Evangelos Foutras <evangelos@foutrelis.com>.

llvm-svn: 224766

9 years ago[ValueTracking] Move GlobalAlias handling to be after the max depth check in computeK...
Michael Kuperstein [Tue, 23 Dec 2014 11:33:41 +0000 (11:33 +0000)]
[ValueTracking] Move GlobalAlias handling to be after the max depth check in computeKnownBits()

GlobalAlias handling used to be after GlobalValue handling, which meant it was, in practice, dead code. r220165 moved GlobalAlias handling to be before GlobalValue handling, but also moved it to be before the max depth check, causing an assert due to a recursion depth limit violation.

This moves GlobalAlias handling forward to where it's safe, and changes the GlobalValue handling to only look at GlobalObjects.

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

llvm-svn: 224765

9 years agoAVX-512: Added FMA instructions, intrinsics an tests for KNL and SKX targets
Elena Demikhovsky [Tue, 23 Dec 2014 10:30:39 +0000 (10:30 +0000)]
AVX-512: Added FMA instructions, intrinsics an tests for KNL and SKX targets

by Asaf Badouh

http://reviews.llvm.org/D6456

llvm-svn: 224764

9 years ago[asan] Fix line >80 chars.
Evgeniy Stepanov [Tue, 23 Dec 2014 10:18:47 +0000 (10:18 +0000)]
[asan] Fix line >80 chars.

llvm-svn: 224763

9 years ago[asan] Better error message in coverage.
Evgeniy Stepanov [Tue, 23 Dec 2014 10:12:51 +0000 (10:12 +0000)]
[asan] Better error message in coverage.

llvm-svn: 224762

9 years ago[PowerPC] Don't mark the return-address slot as immutable
Hal Finkel [Tue, 23 Dec 2014 09:45:06 +0000 (09:45 +0000)]
[PowerPC] Don't mark the return-address slot as immutable

It is tempting to mark the fixed stack slot used to store the return address as
immutable when lowering @llvm.returnaddress(i32 0). Unfortunately, within the
function, it is not completely immutable: it is written during the function
prologue. When using post-RA instruction scheduling, the prologue instructions
are available for scheduling, and we're not free to interchange the order of a
particular store in the prologue with loads from that stack location.

Fixes PR21976.

llvm-svn: 224761

9 years agoAVX-512: BLENDM - fixed encoding of the broadcast version
Elena Demikhovsky [Tue, 23 Dec 2014 09:36:28 +0000 (09:36 +0000)]
AVX-512: BLENDM - fixed encoding of the broadcast version
Added more intrinsics and encoding tests.

llvm-svn: 224760

9 years ago[DagCombine] Improve DAGCombiner BUILD_VECTOR when it has two sources of elements
Michael Kuperstein [Tue, 23 Dec 2014 08:59:45 +0000 (08:59 +0000)]
[DagCombine] Improve DAGCombiner BUILD_VECTOR when it has two sources of elements

This partially fixes PR21943.

For AVX, we go from:

vmovq   (%rsi), %xmm0
vmovq   (%rdi), %xmm1
vpermilps       $-27, %xmm1, %xmm2 ## xmm2 = xmm1[1,1,2,3]
vinsertps       $16, %xmm2, %xmm1, %xmm1 ## xmm1 = xmm1[0],xmm2[0],xmm1[2,3]
vinsertps       $32, %xmm0, %xmm1, %xmm1 ## xmm1 = xmm1[0,1],xmm0[0],xmm1[3]
vpermilps       $-27, %xmm0, %xmm0 ## xmm0 = xmm0[1,1,2,3]
vinsertps       $48, %xmm0, %xmm1, %xmm0 ## xmm0 = xmm1[0,1,2],xmm0[0]

To the expected:

vmovq   (%rdi), %xmm0
vmovhpd (%rsi), %xmm0, %xmm0
retq

Fixing this for AVX2 is still open.

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

llvm-svn: 224759

9 years ago[PowerPC] Don't attempt a 64-bit pow2 division on PPC32
Hal Finkel [Tue, 23 Dec 2014 08:38:50 +0000 (08:38 +0000)]
[PowerPC] Don't attempt a 64-bit pow2 division on PPC32

In r224033, in moving the signed power-of-2 division expansion into
BuildSDIVPow2, I accidentally made it possible to attempt the lowering for a
64-bit division on PPC32. This later asserts.

Fixes PR21928.

llvm-svn: 224758

9 years ago[SimplifyCFG] Revise common code sinking
Michael Liao [Tue, 23 Dec 2014 08:26:55 +0000 (08:26 +0000)]
[SimplifyCFG] Revise common code sinking

- Fix the case where more than 1 common instructions derived from the same
  operand cannot be sunk. When a pair of value has more than 1 derived values
  in both branches, only 1 derived value could be sunk.
- Replace BB1 -> (BB2, PN) map with joint value map, i.e.
  map of (BB1, BB2) -> PN, which is more accurate to track common ops.

llvm-svn: 224757

9 years agoRemove a bad cast in CloneModule()
Michael Kuperstein [Tue, 23 Dec 2014 08:23:45 +0000 (08:23 +0000)]
Remove a bad cast in CloneModule()

A cast that was introduced in r209007 was accidentally left in after the changes made to GlobalAlias rules in r210062. This crashes if the aliasee is a now-leggal ConstantExpr.

llvm-svn: 224756

9 years agotsan: fix style
Dmitry Vyukov [Tue, 23 Dec 2014 07:21:23 +0000 (07:21 +0000)]
tsan: fix style

Usually we roll the variable declaration into the condition in cases like this.

llvm-svn: 224755

9 years ago[ARM] Don't break alignment when combining base updates into load/stores.
Ahmed Bougacha [Tue, 23 Dec 2014 06:07:31 +0000 (06:07 +0000)]
[ARM] Don't break alignment when combining base updates into load/stores.

r223862/r224203 tried to also combine base-updating load/stores.
There was a mistake there: the alignment was added as is as an operand to
the ARMISD::VLD/VST node.  However, the VLD/VST selection logic doesn't care
about less-than-standard alignment attributes.
For example, no matter the alignment of a v2i64 load (say 1), SelectVLD picks
VLD1q64 (because of the memory type).  But VLD1q64 ("vld1.64 {dXX, dYY}") is
8-aligned, per ARMARMv7a 3.2.1.
For the 1-aligned load, what we really want is VLD1q8.

This commit introduces bitcasts if necessary, and changes the vld/vst type to
one whose standard alignment matches the original load/store alignment.

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

llvm-svn: 224754

9 years agoPrevent ill-formed instantiation of __invoke_of<...> during the evaluation of a bind...
Eric Fiselier [Tue, 23 Dec 2014 05:54:34 +0000 (05:54 +0000)]
Prevent ill-formed instantiation of __invoke_of<...> during the evaluation of a bind expression. Fixes PR22003.

The SFINAE on the function __mu(Fn, Args...) that evaluates nested bind
expressions always tries to deduce the return type for Fn(Args...) even when Fn
is not a nested bind expression. This can cause hard compile errors when the
instantation of Fn(Args...) is ill-formed. This patch prevents the instantation
of __invoke_of<Fn, Args...> unless Fn is actually a bind expression.

Bug reportand patch from Michel Morin.

http://llvm.org/bugs/show_bug.cgi?id=22003

llvm-svn: 224753

9 years agoFix UBSan bootstrap: replace shift of negative value with multiplication.
Alexey Samsonov [Tue, 23 Dec 2014 04:15:53 +0000 (04:15 +0000)]
Fix UBSan bootstrap: replace shift of negative value with multiplication.

llvm-svn: 224752

9 years agoFix UBSan bootstrap: don't bind reference to nullptr.
Alexey Samsonov [Tue, 23 Dec 2014 04:15:47 +0000 (04:15 +0000)]
Fix UBSan bootstrap: don't bind reference to nullptr.

llvm-svn: 224751

9 years agoRevert r224739: Debug info: Teach SROA how to update debug info for
Chandler Carruth [Tue, 23 Dec 2014 02:58:14 +0000 (02:58 +0000)]
Revert r224739: Debug info: Teach SROA how to update debug info for
fragmented variables.

This caused codegen to start crashing when we built somewhat large
programs with debug info and optimizations. 'check-msan' hit in, and
I suspect a bootstrap would as well. I mailed a test case to the
review thread.

llvm-svn: 224750

9 years agoChange the CMake build to generate full debugging info when COMPILER_RT_DEBUG=ON
Kuba Brecka [Tue, 23 Dec 2014 01:52:53 +0000 (01:52 +0000)]
Change the CMake build to generate full debugging info when COMPILER_RT_DEBUG=ON

The compiler-rt CMake build currently uses -gline-tables-only for all builds. While this makes the debugger correctly map source files, debugging of the runtime libraries in general is pretty tough, because you don't see any local variables, parameters, etc. Let's allow emitting full debugging info by setting COMPILER_RT_DEBUG=ON.

Reviewed at http://reviews.llvm.org/D6764

llvm-svn: 224749

9 years agoRemove non-const test to get test passing. Will come back later and (correctly) add...
Marshall Clow [Tue, 23 Dec 2014 01:30:39 +0000 (01:30 +0000)]
Remove non-const test to get test passing. Will come back later and (correctly) add non-const tests

llvm-svn: 224748

9 years agoAdd a triple to try and get this test passing on the ARM bots.
Nico Weber [Tue, 23 Dec 2014 01:07:10 +0000 (01:07 +0000)]
Add a triple to try and get this test passing on the ARM bots.

llvm-svn: 224747

9 years agoX86: Don't over-align combined loads.
Jim Grosbach [Tue, 23 Dec 2014 00:35:23 +0000 (00:35 +0000)]
X86: Don't over-align combined loads.

When combining consecutive loads+inserts into a single vector load,
we should keep the alignment of the base load. Doing otherwise can, and does,
lead to using overly aligned instructions. In the included test case, for
example, using a 32-byte vmovaps on a 16-byte aligned value. Oops.

rdar://19190968

llvm-svn: 224746

9 years agoMake musttail more robust for vector types on x86
Reid Kleckner [Mon, 22 Dec 2014 23:58:37 +0000 (23:58 +0000)]
Make musttail more robust for vector types on x86

Previously I tried to plug musttail into the existing vararg lowering
code. That turned out to be a mistake, because non-vararg calls use
significantly different register lowering, even on x86. For example, AVX
vectors are usually passed in registers to normal functions and memory
to vararg functions.  Now musttail uses a completely separate lowering.

Hopefully this can be used as the basis for non-x86 perfect forwarding.

Reviewers: majnemer

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

llvm-svn: 224745

9 years agoRemove dynamic allocation/indirection from GCOVBlocks owned by GCOVFunction
David Blaikie [Mon, 22 Dec 2014 23:12:42 +0000 (23:12 +0000)]
Remove dynamic allocation/indirection from GCOVBlocks owned by GCOVFunction

Since these are all created in the DenseMap before they are referenced,
there's no problem with pointer validity by the time it's required. This
removes another use of DeleteContainerSeconds/manual memory management
which I'm cleaning up from time to time.

llvm-svn: 224744

9 years agoThumb1 frame lowering: Mark CFI instructions with the FrameSetup flag.
Adrian Prantl [Mon, 22 Dec 2014 23:09:14 +0000 (23:09 +0000)]
Thumb1 frame lowering: Mark CFI instructions with the FrameSetup flag.

Followup to r224294:

ARM/AArch64: Attach the FrameSetup MIFlag to CFI instructions.
Debug info marks the first instruction without the FrameSetup flag
as being the end of the function prologue. Any CFI instructions in the
middle of the function prologue would cause debug info to end the prologue
too early and worse, attach the line number of the CFI instruction, which
incidentally is often 0.

llvm-svn: 224743

9 years ago[SROA] Lift the logic for traversing the alloca slices one partition at
Chandler Carruth [Mon, 22 Dec 2014 22:46:00 +0000 (22:46 +0000)]
[SROA] Lift the logic for traversing the alloca slices one partition at
a time into a partition iterator and a Partition class.

There is a lot of knock-on simplification that this enables, largely
stemming from having a Partition object to refer to in lots of helpers.
I've only done a minimal amount of that because enoguh stuff is changing
as-is in this commit.

This shouldn't change any observable behavior. I've worked hard to
preserve the *exact* traversal semantics which were originally present
even though some of them make no sense. I'll be changing some of this in
subsequent commits now that the logic is carefully factored into
a reusable place.

The primary motivation for this change is to break the rewriting into
phases in order to support more intelligent rewriting. For example, I'm
planning to change how split loads and stores are rewritten to remove
the significant overuse of integer bit packing in the resulting code and
allow more effective secondary splitting of aggregates. For any of this
to work, they have to share the exact traversal logic.

llvm-svn: 224742

9 years ago[libcxx] Consolidate new/delete replacement in tests and disable it when using saniti...
Eric Fiselier [Mon, 22 Dec 2014 22:38:59 +0000 (22:38 +0000)]
[libcxx] Consolidate new/delete replacement in tests and disable it when using sanitizers.

Summary:
MSAN and ASAN also replace new/delete which leads to a link error in these tests. Currently they are unsupported but I think it would be useful if these tests could run with sanitizers.

This patch creates a support header that consolidates the new/delete replacement functionality and checking.
When we are using sanitizers new and delete are no longer replaced and the checks always return true.

Reviewers: mclow.lists, danalbert, jroelofs, EricWF

Reviewed By: EricWF

Subscribers: cfe-commits

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

llvm-svn: 224741

9 years ago[LCSSA] Handle PHI insertion in disjoint loops
Bruno Cardoso Lopes [Mon, 22 Dec 2014 22:35:46 +0000 (22:35 +0000)]
[LCSSA] Handle PHI insertion in disjoint loops

Take two disjoint Loops L1 and L2.

LoopSimplify fails to simplify some loops (e.g. when indirect branches
are involved). In such situations, it can happen that an exit for L1 is
the header of L2. Thus, when we create PHIs in one of such exits we are
also inserting PHIs in L2 header.

This could break LCSSA form for L2 because these inserted PHIs can also
have uses in L2 exits, which are never handled in the current
implementation. Provide a fix for this corner case and test that we
don't assert/crash on that.

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

rdar://problem/19166231

llvm-svn: 224740

9 years agoDebug info: Teach SROA how to update debug info for fragmented variables.
Adrian Prantl [Mon, 22 Dec 2014 22:26:00 +0000 (22:26 +0000)]
Debug info: Teach SROA how to update debug info for fragmented variables.
This allows us to generate debug info for extremely advanced code such as

  typedef struct { long int a; int b;} S;

  int foo(S s) {
    return s.b;
  }

which at -O1 on x86_64 is codegen'd into

  define i32 @foo(i64 %s.coerce0, i32 %s.coerce1) #0 {
    ret i32 %s.coerce1, !dbg !24
  }

with this patch we emit the following debug info for this

  TAG_formal_parameter [3]
    AT_location( 0x00000000
                 0x0000000000000000 - 0x0000000000000006: rdi, piece 0x00000008, rsi, piece 0x00000004
                 0x0000000000000006 - 0x0000000000000008: rdi, piece 0x00000008, rax, piece 0x00000004 )
                 AT_name( "s" )
                 AT_decl_file( "/Volumes/Data/llvm/_build.ninja.release/test.c" )

Thanks to chandlerc, dblaikie, and echristo for their feedback on all
previous iterations of this patch!

llvm-svn: 224739

9 years agoFix Windows unwind info for functions in sections other than .text
Reid Kleckner [Mon, 22 Dec 2014 22:10:08 +0000 (22:10 +0000)]
Fix Windows unwind info for functions in sections other than .text

Previously we assumed the section name had the form .text$foo, which is
what we used to do for inline functions. If the dollar wasn't present,
we'd put unwind data in the .pdata and .xdata sections for the main
.text section, which is incorrect.

Fixes PR22001.

llvm-svn: 224738

9 years ago[Sanitizer] Make CommonFlags immutable after initialization.
Alexey Samsonov [Mon, 22 Dec 2014 21:46:10 +0000 (21:46 +0000)]
[Sanitizer] Make CommonFlags immutable after initialization.

Summary:
Protect CommonFlags singleton by adding const qualifier to
common_flags() accessor. The only ways to modify the flags are
SetCommonFlagsDefaults(), ParseCommonFlagsFromString() and
OverrideCommonFlags() functions, which are only supposed to be
called during initialization.

Test Plan: regression test suite

Reviewers: kcc, eugenis, glider

Subscribers: llvm-commits

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

llvm-svn: 224736

9 years ago[Hexagon] Adding memb instruction. Fixing whitespace in test from 224730.
Colin LeMahieu [Mon, 22 Dec 2014 21:40:43 +0000 (21:40 +0000)]
[Hexagon] Adding memb instruction.  Fixing whitespace in test from 224730.

llvm-svn: 224735

9 years agoUse iterators rather than indices to make this forwards-compatible with a change...
David Blaikie [Mon, 22 Dec 2014 21:26:38 +0000 (21:26 +0000)]
Use iterators rather than indices to make this forwards-compatible with a change to the underlying container (to std::list)

llvm-svn: 224734

9 years agounique_ptrify MatchableInfo(const CodeGenInstAlias *Alias)'s parameter
David Blaikie [Mon, 22 Dec 2014 21:26:26 +0000 (21:26 +0000)]
unique_ptrify MatchableInfo(const CodeGenInstAlias *Alias)'s parameter

llvm-svn: 224733

9 years ago[Hexagon] Adding classes and load unsigned byte instruction, updating usages.
Colin LeMahieu [Mon, 22 Dec 2014 21:20:03 +0000 (21:20 +0000)]
[Hexagon] Adding classes and load unsigned byte instruction, updating usages.

llvm-svn: 224730

9 years ago[libcxx] Add numerous options to libc++ LIT test suite configuration.
Eric Fiselier [Mon, 22 Dec 2014 20:49:45 +0000 (20:49 +0000)]
[libcxx] Add numerous options to libc++ LIT test suite configuration.

Summary:
In order to fully replace the testit script we need to update LIT so it provides the same functionality.
This patch adds a number of different configuration options to LIT to do that. It also adds documentation for all of the command line parameters that LIT supports.

Generic options added:
- `libcxx_headers`
- `libcxx_library`
- `compile_flags`

Generic options modified:
- `link_flags`: Changed from overriding the default args to adding extra args instead (to match compile flags)
- `use_sanitizer`: Renamed from `llvm_use_sanitizer`

Please see the added documentation for more information about the switches. As for the actual documentation I'm not sure if it should be kept in libc++ forever since it adds an undue maintenance burden, but I think it should be added for the time being while the changes are new. I'm verify unskilled with HTML so if the documentation needs any changes please let me know.

Hopefully this will kill testit.

Reviewers: jroelofs, mclow.lists, danalbert

Reviewed By: danalbert

Subscribers: alexfh, cfe-commits

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

llvm-svn: 224728

9 years ago[x86] Add vector @llvm.ctpop intrinsic custom lowering
Bruno Cardoso Lopes [Mon, 22 Dec 2014 19:45:43 +0000 (19:45 +0000)]
[x86] Add vector @llvm.ctpop intrinsic custom lowering

Currently, when ctpop is supported for scalar types, the expansion of
@llvm.ctpop.vXiY uses vector element extractions, insertions and individual
calls to @llvm.ctpop.iY. When not, expansion with bit-math operations is used
for the scalar calls.

Local haswell measurements show that we can improve vector @llvm.ctpop.vXiY
expansion in some cases by using a using a vector parallel bit twiddling
approach, based on:

v = v - ((v >> 1) & 0x55555555);
v = (v & 0x33333333) + ((v >> 2) & 0x33333333);
v = ((v + (v >> 4) & 0xF0F0F0F)
v = v + (v >> 8)
v = v + (v >> 16)
v = v & 0x0000003F
(from http://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel)

When scalar ctpop isn't supported, the approach above performs better for
v2i64, v4i32, v4i64 and v8i32 (see numbers below). And even when scalar ctpop
is supported, this approach performs ~2x better for v8i32.

Here, x86_64 implies -march=corei7-avx without ctpop and x86_64h includes ctpop
support with -march=core-avx2.

== [x86_64h - new]
v8i32: 0.661685
v4i32: 0.514678
v4i64: 0.652009
v2i64: 0.324289
== [x86_64h - old]
v8i32: 1.29578
v4i32: 0.528807
v4i64: 0.65981
v2i64: 0.330707

== [x86_64 - new]
v8i32: 1.003
v4i32: 0.656273
v4i64: 1.11711
v2i64: 0.754064
== [x86_64 - old]
v8i32: 2.34886
v4i32: 1.72053
v4i64: 1.41086
v2i64: 1.0244

More work for other vector types will come next.

llvm-svn: 224725

9 years ago[Msan] Fix msan_test.cc inclusions to build the unit tests on FreeBSD
Viktor Kutuzov [Mon, 22 Dec 2014 19:14:23 +0000 (19:14 +0000)]
[Msan] Fix msan_test.cc inclusions to build the unit tests on FreeBSD
Differential Revision: http://reviews.llvm.org/D6757

llvm-svn: 224724

9 years agoFix PR22000. __bit_iterator::move_backwards. Also make a note that __bit_iterator
Marshall Clow [Mon, 22 Dec 2014 19:10:11 +0000 (19:10 +0000)]
Fix PR22000. __bit_iterator::move_backwards. Also make a note that __bit_iterator
is quite underrepresented in the libc++ tests suite.

llvm-svn: 224723

9 years agoRemove unused header. NFC.
Juergen Ributzka [Mon, 22 Dec 2014 19:09:15 +0000 (19:09 +0000)]
Remove unused header. NFC.

llvm-svn: 224722

9 years agoAdd a C++ marker to this header file.
Adrian Prantl [Mon, 22 Dec 2014 19:07:45 +0000 (19:07 +0000)]
Add a C++ marker to this header file.

llvm-svn: 224721

9 years ago[C API] Expose LLVMGetGlobalValueAddress and LLVMGetFunctionAddress.
Peter Zotov [Mon, 22 Dec 2014 18:53:11 +0000 (18:53 +0000)]
[C API] Expose LLVMGetGlobalValueAddress and LLVMGetFunctionAddress.

Patch by Ramkumar Ramachandra <artagnon@gmail.com>

llvm-svn: 224720

9 years agoDisable trigraphs in microsoft mode by default. Matches cl.exe.
Nico Weber [Mon, 22 Dec 2014 18:35:03 +0000 (18:35 +0000)]
Disable trigraphs in microsoft mode by default. Matches cl.exe.

The default value of Opts.Trigraphs now no longer depends solely on the
language input kind, so move the code out of setLangDefaults().  Also make
sure that Opts.MSVCCompat is set before the Trigraph code runs.

Related to PR21974.

llvm-svn: 224719

9 years agoRename test.cc files to test.cpp.
Nico Weber [Mon, 22 Dec 2014 18:13:07 +0000 (18:13 +0000)]
Rename test.cc files to test.cpp.

The lit.cfg files only add .cpp to suffixes, so these tests used to never run,
oops.  (Also tweak to of these tests in minor ways to make the actually pass.)

llvm-svn: 224718

9 years ago[CodeGenPrepare] Handle properly the promotion of operands when this does not
Quentin Colombet [Mon, 22 Dec 2014 18:11:52 +0000 (18:11 +0000)]
[CodeGenPrepare] Handle properly the promotion of operands when this does not
generate instructions.

Fixes PR21978.
Related to <rdar://problem/18310086>

llvm-svn: 224717

9 years agoAdd test coverage for cc1's trigraph option handling.
Nico Weber [Mon, 22 Dec 2014 17:56:50 +0000 (17:56 +0000)]
Add test coverage for cc1's trigraph option handling.

llvm-svn: 224714

9 years agoSimplify test for rdar://19256338
Fariborz Jahanian [Mon, 22 Dec 2014 17:54:25 +0000 (17:54 +0000)]
Simplify test for rdar://19256338
(from patch r224549).

llvm-svn: 224713

9 years agoAddressSanitizer: Abort after failed exec() and get rid of the allow_reexec ASan...
Kuba Brecka [Mon, 22 Dec 2014 17:32:27 +0000 (17:32 +0000)]
AddressSanitizer: Abort after failed exec() and get rid of the allow_reexec ASan flag

As mentioned in
https://code.google.com/p/address-sanitizer/issues/detail?id=365, when the
re-exec that adds the required DYLD_INSERT_LIBRARIES variable fails, ASan
currently continues to run, but things are broken (some memory can be
overwritten, interceptors don't work, ...). This patch aborts if the execv()
fails and prints an error message that DYLD_INSERT_LIBRARIES is required. It
also removes the "alllow_reexec" flag, since using it causes the same issues.

Reviewed at http://reviews.llvm.org/D6752

llvm-svn: 224712

9 years agoAddressSanitizer: Properly handle dispatch_source_set_cancel_handler with a
Kuba Brecka [Mon, 22 Dec 2014 17:30:04 +0000 (17:30 +0000)]
AddressSanitizer: Properly handle dispatch_source_set_cancel_handler with a
NULL handler

Per
https://developer.apple.com/library/mac/documentation/Performance/Reference/GCD_libdispatch_Ref/index.html,
the dispatch_source_set_cancel_handler() API *can* be called with a NULL
handler. In that case, the libdispatch removes an already existing cancellation
handler, if there was one. ASan's interceptor always creates a new block that
always tries to call the original handler. In case the original block is NULL,
a segmentation fault happens. Let's fix that by not wrapping a NULL-block at
all.

It looks like all the other libdispatch APIs (which we intercept) do *not*
allow NULL. So it's really only the dispatch_source_set_cancel_handler one that
needs this fix.

Reviewed at http://reviews.llvm.org/D6747

llvm-svn: 224711

9 years ago[ASan] Fix the logic that decides whether we need to spawn a new llvm-symbolizer...
Alexander Potapenko [Mon, 22 Dec 2014 16:00:00 +0000 (16:00 +0000)]
[ASan] Fix the logic that decides whether we need to spawn a new llvm-symbolizer in asan_symbolize.py

llvm-svn: 224710

9 years ago[Sanitizers] Intercept wcsnrtombs() on FreeBSD
Viktor Kutuzov [Mon, 22 Dec 2014 14:45:30 +0000 (14:45 +0000)]
[Sanitizers] Intercept wcsnrtombs() on FreeBSD
Differential Revision: http://reviews.llvm.org/D6755

llvm-svn: 224709

9 years ago[Msan] Fix uname() interception on FreeBSD
Viktor Kutuzov [Mon, 22 Dec 2014 14:42:24 +0000 (14:42 +0000)]
[Msan] Fix uname() interception on FreeBSD
Differential Revision: http://reviews.llvm.org/D6738

llvm-svn: 224708

9 years agoAVX-512: Added all forms of BLENDM instructions,
Elena Demikhovsky [Mon, 22 Dec 2014 13:52:48 +0000 (13:52 +0000)]
AVX-512: Added all forms of BLENDM instructions,
intrinsics, encoding tests for AVX-512F and skx instructions.

llvm-svn: 224707

9 years agoLower multiply-negate operation to mneg on AArch64
Karthik Bhat [Mon, 22 Dec 2014 13:38:58 +0000 (13:38 +0000)]
Lower multiply-negate operation to mneg on AArch64

This patch pattern matches code such as-
neg  w8, w8
mul  w8, w9, w8
to
mneg  w8, w8, w9

Review: http://reviews.llvm.org/D6754
llvm-svn: 224706

9 years agoConvert a few tests to FileCheck. NFC.
Rafael Espindola [Mon, 22 Dec 2014 13:29:46 +0000 (13:29 +0000)]
Convert a few tests to FileCheck. NFC.

llvm-svn: 224705

9 years agoThe leak detector is dead, long live asan and valgrind.
Rafael Espindola [Mon, 22 Dec 2014 13:00:36 +0000 (13:00 +0000)]
The leak detector is dead, long live asan and valgrind.

In resent times asan and valgrind have found way more memory management bugs
in llvm than the special purpose leak detector.

llvm-svn: 224703

9 years agotsan: reset stack0 in the first partition of thread trace
Dmitry Vyukov [Mon, 22 Dec 2014 12:32:52 +0000 (12:32 +0000)]
tsan: reset stack0 in the first partition of thread trace

stack0/mset0 contained bogus values from the previous thread
that used the same id

llvm-svn: 224702

9 years agotsan: fix debugging output
Dmitry Vyukov [Mon, 22 Dec 2014 12:31:32 +0000 (12:31 +0000)]
tsan: fix debugging output

llvm-svn: 224701

9 years ago[Sanitizers] Intercept snprintf_l() on FreeBSD
Viktor Kutuzov [Mon, 22 Dec 2014 12:29:40 +0000 (12:29 +0000)]
[Sanitizers] Intercept snprintf_l() on FreeBSD
Differential Revision: http://reviews.llvm.org/D6418

llvm-svn: 224700

9 years ago[Sanitizers] Intercept wordexp on FreeBSD
Viktor Kutuzov [Mon, 22 Dec 2014 12:21:35 +0000 (12:21 +0000)]
[Sanitizers] Intercept wordexp on FreeBSD
Differential Revision: http://reviews.llvm.org/D6737

llvm-svn: 224699

9 years agoAdd support for frameless function compact unwind encodings on x86_64/i386.
Jason Molenda [Mon, 22 Dec 2014 11:02:02 +0000 (11:02 +0000)]
Add support for frameless function compact unwind encodings on x86_64/i386.
This completes the compact unwind support for x86 targets.

I'm still skipping the UNWIND_X86_64_MODE_STACK_IND encodings for
x86_64 right now because clang was emitting bad data for this form
until it was fixed in r217020 circa Sep 2014.

arm64 parsing still needs to be added.

llvm-svn: 224698

9 years agotsan: add acquire/release functions to java interface
Dmitry Vyukov [Mon, 22 Dec 2014 09:44:56 +0000 (09:44 +0000)]
tsan: add acquire/release functions to java interface

they are required to handle synchronization on volatile/final fields

llvm-svn: 224697

9 years agoMS ABI: Make the string mangling code more concise
David Majnemer [Mon, 22 Dec 2014 06:24:49 +0000 (06:24 +0000)]
MS ABI: Make the string mangling code more concise

No functional change intended.

llvm-svn: 224696

9 years agoWrap to 80 columns. NfC.
Nico Weber [Mon, 22 Dec 2014 05:21:03 +0000 (05:21 +0000)]
Wrap to 80 columns. NfC.

llvm-svn: 224695

9 years agolog-path_test testcase - make the invalid path more invalid
Kuba Brecka [Mon, 22 Dec 2014 00:02:28 +0000 (00:02 +0000)]
log-path_test testcase - make the invalid path more invalid

The ASan test/asan/TestCases/log-path_test.cc testcase uses /INVALID as an invalid path and expects that the program will not be allowed to create or write to that file. This actually is a valid writable path on one of my setups. Let's make the path more invalid.

Reviewed at http://reviews.llvm.org/D6727

llvm-svn: 224694

9 years agoCodeGen: minor style tweaks to SSP
Saleem Abdulrasool [Sun, 21 Dec 2014 21:52:38 +0000 (21:52 +0000)]
CodeGen: minor style tweaks to SSP

Clean up some style related things in the StackProtector CodeGen.  NFC.

llvm-svn: 224693

9 years ago[X86] Add hasSideEffects = 0 to CALLpcrel16. This matches what is inferred from patte...
Craig Topper [Sun, 21 Dec 2014 20:05:06 +0000 (20:05 +0000)]
[X86] Add hasSideEffects = 0 to CALLpcrel16. This matches what is inferred from patterns for the 32-bit version.

llvm-svn: 224692

9 years agoEnable (sext x) == C --> x == (trunc C) combine
Matt Arsenault [Sun, 21 Dec 2014 16:48:42 +0000 (16:48 +0000)]
Enable (sext x) == C --> x == (trunc C) combine

Extend the existing code which handles this for zext. This makes this
more useful for targets with ZeroOrNegativeOne BooleanContent and
obsoletes a custom combine SI uses for i1 setcc (sext(i1), 0, setne)
since the constant will now be shrunk to i1.

llvm-svn: 224691

9 years agoSilence warnings in libunwind.
Logan Chien [Sun, 21 Dec 2014 14:22:00 +0000 (14:22 +0000)]
Silence warnings in libunwind.

* Remove the embedded directive undefined behavior by moving the
  the #ifdef out of the macro arguments.  [-Wembedded-directive]

* Remove the local variable shadowing warning by renaming
  frameInfo in UnwindLevel1-gcc-ext.c.  [-Wshadow]

* Explicitly cast the function pointer to void pointer to avoid
  the comparison between function pointer and void pointer.
  [-Wpedantic]

llvm-svn: 224690

9 years agoVarious unwinder work.
Jason Molenda [Sun, 21 Dec 2014 10:44:54 +0000 (10:44 +0000)]
Various unwinder work.

Most of the changes are to the FuncUnwinders class -- as we've added
more types of unwind information, the way this class was written was
making it a mess to maintain.  Instead of trying to keep one
"non-call site" unwind plan and one "call site" unwind plan, track
all the different types of unwind plans we can possibly retrieve for
each function and have the call-site/non-call-site accessor methods
retrieve those.

Add a real "fast unwind plan" for x86_64 / i386 -- when doing an
unwind through a function, this only has to read the first 4 bytes
to tell if the function has a standard prologue sequence.  If so,
we can use the architecture default unwind plan to backtrace
through this function.  If we try to retrieve the save location for
other registers later on, a real unwind plan will be used.  This
one is just for doing fast backtraces.

Change the compact unwind plan importer to fill in the valid address
range it is valid for.

Compact unwind, in theory, may have multiple entries for a single
function.  The FuncUnwinders rewrite includes the start of supporting
this correctly.  In practice compact unwind encodings are used for
the entire range of the function today -- in fact, sometimes the same
encoding is used for multiple functions that have the same unwind
rules.  But I want to handle a single function that has multiple
different compact unwind UnwindPlans eventually.

llvm-svn: 224689

9 years agoReapply "Change -save-temps to emit unoptimized bitcode files."
Bob Wilson [Sun, 21 Dec 2014 07:00:00 +0000 (07:00 +0000)]
Reapply "Change -save-temps to emit unoptimized bitcode files."

This reapplies r224503 along with a fix for compiling Fortran by having the
clang driver invoke gcc (see r224546, where it was reverted). I have added
a testcase for that as well.

Original commit message:
It is often convenient to use -save-temps to collect the intermediate
results of a compilation, e.g., when triaging a bug report. Besides the
temporary files for preprocessed source and assembly code, this adds the
unoptimized bitcode files as well.

This adds a new BackendJobAction, which is mostly mechanical, to run after
the CompileJobAction. When not using -save-temps, the BackendJobAction is
combined into one job with the CompileJobAction, similar to the way the
integrated assembler is handled. I've implemented this entirely as a
driver change, so under the hood, it is just using -disable-llvm-optzns
to get the unoptimized bitcode.

Based in part on a patch by Steven Wu.
rdar://problem/18909437

llvm-svn: 224688

9 years ago[X86] Swap operand order in Intel syntax on a bunch of aliases.
Craig Topper [Sat, 20 Dec 2014 23:05:59 +0000 (23:05 +0000)]
[X86] Swap operand order in Intel syntax on a bunch of aliases.

llvm-svn: 224687

9 years ago[X86] Swap operand order of imul aliases in Intel syntax. Also disable printing of...
Craig Topper [Sat, 20 Dec 2014 23:05:57 +0000 (23:05 +0000)]
[X86] Swap operand order of imul aliases in Intel syntax. Also disable printing of the alias instead of the real instruction.

llvm-svn: 224686

9 years ago[X86] Remove '*' from asm strings in far call/jump aliases for Intel syntax.
Craig Topper [Sat, 20 Dec 2014 23:05:55 +0000 (23:05 +0000)]
[X86] Remove '*' from asm strings in far call/jump aliases for Intel syntax.

llvm-svn: 224685

9 years ago[X86] Don't swap the order of segment and offset in immediate form of far call/jump...
Craig Topper [Sat, 20 Dec 2014 23:05:52 +0000 (23:05 +0000)]
[X86] Don't swap the order of segment and offset in immediate form of far call/jump in Intel syntax.

llvm-svn: 224684

9 years agoCodeGen: constify and use range loop for SSP
Saleem Abdulrasool [Sat, 20 Dec 2014 21:37:51 +0000 (21:37 +0000)]
CodeGen: constify and use range loop for SSP

Use range-based for loop and constify the iterators.  NFC.

llvm-svn: 224683

9 years agoARM: further improve deprecated diagnosis (LDM)
Saleem Abdulrasool [Sat, 20 Dec 2014 20:25:36 +0000 (20:25 +0000)]
ARM: further improve deprecated diagnosis (LDM)

The ARM ARM states:
  LDM/LDMIA/LDMFD:
    The SP can be in the list. However, ARM deprecates using these instructions
    with SP in the list.

    ARM deprecates using these instructions with both the LR and the PC in the
    list.

  LDMDA/LDMFA/LDMDB/LDMEA/LDMIB/LDMED:
    The SP can be in the list. However, instructions that include the SP in the
    list are deprecated.

    Instructions that include both the LR and the PC in the list are deprecated.

  POP:
    The SP can only be in the list before ARMv7. ARM deprecates any use of ARM
    instructions that include the SP, and the value of the SP after such an
    instruction is UNKNOWN.

    ARM deprecates the use of this instruction with both the LR and the PC in
    the list.

Attempt to diagnose use of deprecated forms of these instructions.  This mirrors
the previous changes to diagnose use of the deprecated forms of STM in ARM mode.

llvm-svn: 224682

9 years ago[macho] Minor install_name fixes
Jean-Daniel Dupas [Sat, 20 Dec 2014 09:22:56 +0000 (09:22 +0000)]
[macho] Minor install_name fixes

Summary:
Fix the binary file reader to properly read dyld version info.
Update the install_name test case to properly test the binary reader. We can't use '-print_atoms' as the output format is 'native' yaml and it does not contains the dyld current and compatibility versions.

Also change the timestamp value of LD_ID_DYLD to match the one generated by ld64.
The dynamic linker (dyld) used to expects different values for timestamp in LD_ID_DYLD and LD_LOAD_DYLD for prebound images. While prebinding is deprecated, we should probably keep it safe and match ld64.

Reviewers: kledzik

Subscribers: llvm-commits

Projects: #lld

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

llvm-svn: 224681

9 years agoFrontend: Fix typo in comments.
Logan Chien [Sat, 20 Dec 2014 08:51:22 +0000 (08:51 +0000)]
Frontend: Fix typo in comments.

llvm-svn: 224680

9 years agostrnlen isn't available on some platforms, use StringRef instead
David Majnemer [Sat, 20 Dec 2014 08:24:43 +0000 (08:24 +0000)]
strnlen isn't available on some platforms, use StringRef instead

llvm-svn: 224679

9 years ago[X86] Immediate forms of far call/jump are not valid in x86-64.
Craig Topper [Sat, 20 Dec 2014 07:43:27 +0000 (07:43 +0000)]
[X86] Immediate forms of far call/jump are not valid in x86-64.

llvm-svn: 224678

9 years agoThis should have been part of r224676.
David Majnemer [Sat, 20 Dec 2014 04:48:34 +0000 (04:48 +0000)]
This should have been part of r224676.

llvm-svn: 224677

9 years agoInstCombine: Squash an icmp+select into bitwise arithmetic
David Majnemer [Sat, 20 Dec 2014 04:45:35 +0000 (04:45 +0000)]
InstCombine: Squash an icmp+select into bitwise arithmetic

(X & INT_MIN) == 0 ? X ^ INT_MIN : X  into  X | INT_MIN
(X & INT_MIN) != 0 ? X ^ INT_MIN : X  into  X & INT_MAX

This fixes PR21993.

llvm-svn: 224676

9 years agoInstSimplify: Don't bother if getScalarSizeInBits returns zero
David Majnemer [Sat, 20 Dec 2014 04:45:33 +0000 (04:45 +0000)]
InstSimplify: Don't bother if getScalarSizeInBits returns zero

getScalarSizeInBits returns zero when the comparison operands are not
integral.  No functionality change intended.

llvm-svn: 224675

9 years agoMove unconditional test compile and link flags into their configuration functions.
Eric Fiselier [Sat, 20 Dec 2014 04:14:14 +0000 (04:14 +0000)]
Move unconditional test compile and link flags into their configuration functions.

llvm-svn: 224674

9 years agoSimplify the code
David Majnemer [Sat, 20 Dec 2014 03:29:59 +0000 (03:29 +0000)]
Simplify the code

No functionality change intended.

llvm-svn: 224673

9 years agoSplit executeShTest into two parts so that it can be better leveraged by libc++
Eric Fiselier [Sat, 20 Dec 2014 03:23:53 +0000 (03:23 +0000)]
Split executeShTest into two parts so that it can be better leveraged by libc++

llvm-svn: 224672

9 years ago[libcxx] Teach libcxx's lit configuration new ways to find lit.site.cfg
Eric Fiselier [Sat, 20 Dec 2014 03:16:55 +0000 (03:16 +0000)]
[libcxx] Teach libcxx's lit configuration new ways to find lit.site.cfg

Summary:
Currently to run tests in tree you need to symlink the lit.site.cfg file generated by the cmake build into the source tree, and teach your VCS to ignore it.

This allows the user to specify where to find the lit.site.cfg file two different ways:
* lit_site_config lit parameter
* LIT_SITE_CONFIG enviroment variable.

example usage:
```
lit -sv --param=libcxx_site_config=path/to/libcxx-build/test/lit.site.cfg path/to/tests
```
Or
```
export LIBCXX_SITE_CONFIG=path/to/libcxx-build/test/lit.site.cfg
lit -sv path/to/tests
```
The command line parameter will override the environment variable.
If neither options are present a warning is issued and the `lit.cfg` file is loaded directly.

Reviewers: mclow.lists, jroelofs, danalbert

Reviewed By: danalbert

Subscribers: ddunbar, cfe-commits

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

llvm-svn: 224671

9 years agoRe-enable compact unwind use on Mac platforms.
Jason Molenda [Sat, 20 Dec 2014 03:12:51 +0000 (03:12 +0000)]
Re-enable compact unwind use on Mac platforms.
When lldb has a binary with protected section contents,
don't use the on-disk representation of that compact
uwnind -- read it only out of live memory where it has
been decrypted.

llvm-svn: 224670

9 years agoInstSimplify: Optimize away pointless comparisons
David Majnemer [Sat, 20 Dec 2014 03:04:38 +0000 (03:04 +0000)]
InstSimplify: Optimize away pointless comparisons

(X & INT_MIN) ? X & INT_MAX : X  into  X & INT_MAX
(X & INT_MIN) ? X : X & INT_MAX  into  X
(X & INT_MIN) ? X | INT_MIN : X  into  X
(X & INT_MIN) ? X : X | INT_MIN  into  X | INT_MIN

llvm-svn: 224669

9 years agoFix a bunch of integer template argument problems in template type diffing.
Richard Trieu [Sat, 20 Dec 2014 03:03:32 +0000 (03:03 +0000)]
Fix a bunch of integer template argument problems in template type diffing.

Reverts most of the changes from r168005.  Since template arguments have proper
conversions now, no extending of integers is needed.  Further, since the
integers are the correct size now, use APSInt::operator== instead of
APSInt::hasSameValue since operator== will check the size and signness match.

Prior to one comparison of APSInt's, check that both are valid.  Previous, one
could be uninitialized.  Also changed APInt to APSInt in GetInt.  This
occassionally produced a sign flip, which will now be caught by operator==.

llvm-svn: 224668

9 years agoFix for PR21758
Richard Trieu [Sat, 20 Dec 2014 02:42:08 +0000 (02:42 +0000)]
Fix for PR21758

When a non-type template argument expression needs a conversion to change it
into the argument type, preserve that information by remaking the
TemplateArgument with an expression that has those conversions.  Also a small
fix to template type diffing to handle the extra conversions in some cases.

llvm-svn: 224667

9 years ago[SROA] Run clang-format over the entire SROA pass as I wrote it before
Chandler Carruth [Sat, 20 Dec 2014 02:39:18 +0000 (02:39 +0000)]
[SROA] Run clang-format over the entire SROA pass as I wrote it before
much of the glory of clang-format, and now any time I touch it I risk
introducing formatting changes as part of a functional commit.

Also, clang-format is *way* better at formatting my code than I am.
Most of this is a huge improvement although I reverted a couple of
places where I hit a clang-format bug with lambdas that has been filed
but not (fully) fixed.

llvm-svn: 224666

9 years ago[x86] Change the test added in r223774 to first check the spelling of
Chandler Carruth [Sat, 20 Dec 2014 02:19:22 +0000 (02:19 +0000)]
[x86] Change the test added in r223774 to first check the spelling of
the error message for a bogus processor, and then look specifically for
that error message using FileCheck.

I actually tried to write the test this way at first, but drew a blank
on how to ensure the error message stayed in sync (oops). Now that I've
recalled how to do that, this is clearly better.

It also fixes an issue with a malloc implementation that actually prints
to stderr in all cases, which was causing problems for some builders it
seems.

llvm-svn: 224665

9 years agoLiveIntervalAnalysis: No kill flags for partially undefined uses.
Matthias Braun [Sat, 20 Dec 2014 01:54:50 +0000 (01:54 +0000)]
LiveIntervalAnalysis: No kill flags for partially undefined uses.

We must not add kill flags when reading a vreg with some undefined
subregisters, if subreg liveness tracking is enabled.  This is because
the register allocator may reuse these undefined subregisters for other
values which are not killed.

llvm-svn: 224664

9 years agoLiveIntervalAnalysis: cleanup addKills(), NFC
Matthias Braun [Sat, 20 Dec 2014 01:54:48 +0000 (01:54 +0000)]
LiveIntervalAnalysis: cleanup addKills(), NFC

- Use more const modifiers
- Use references for things that can't be nullptr
- Improve some variable names

llvm-svn: 224663

9 years agoRemoving an outdated FIXME; try block attributes are parsed with the rest of the...
Aaron Ballman [Sat, 20 Dec 2014 01:54:07 +0000 (01:54 +0000)]
Removing an outdated FIXME; try block attributes are parsed with the rest of the statement attributes (as per the standard), and function-try-blocks may not have attributes. NFC.

llvm-svn: 224662

9 years agoUnbreak cmake build with shared libraries enabled.
Matthias Braun [Sat, 20 Dec 2014 01:51:02 +0000 (01:51 +0000)]
Unbreak cmake build with shared libraries enabled.

llvm-svn: 224661

9 years ago[sanitizer] fix a performance regression in sanitizer coverage: move a small perf...
Kostya Serebryany [Sat, 20 Dec 2014 01:45:28 +0000 (01:45 +0000)]
[sanitizer] fix a performance regression in sanitizer coverage: move a small perf-critical function to a header. ALso set the coverage guard to 1 before the early return from CoverageData::Add

llvm-svn: 224660

9 years agoCleanup some redundant code
Enrico Granata [Sat, 20 Dec 2014 01:41:27 +0000 (01:41 +0000)]
Cleanup some redundant code

llvm-svn: 224659