platform/upstream/llvm.git
7 years ago[libc++] Default to vcruntime when targeting MSVC
Shoaib Meenai [Thu, 20 Apr 2017 23:33:49 +0000 (23:33 +0000)]
[libc++] Default to vcruntime when targeting MSVC

Summary:
libc++abi is never the right option for LIBCXX_TARGETING_MSVC, since it
targets the Itanium ABI, whereas MSVC uses the Microsoft ABI. Make the
default ABI be vcruntime when targeting MSVC even if libc++abi is
present in the tree.

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

llvm-svn: 300921

7 years agoFix ATOMIC_<TYPE>_LOCK_FREE macros on Windows.
Eric Fiselier [Thu, 20 Apr 2017 23:22:46 +0000 (23:22 +0000)]
Fix ATOMIC_<TYPE>_LOCK_FREE macros on Windows.

Previously the ATOMIC_<TYPE>_LOCK_FREE macros were implemented
using __GCC_ATOMIC_<TYPE>_LOCK_FREE but GCC specific macros
are defined when -fms-compatibility is specified.

To avoid this Libc++ now tries to use the newly added
__CLANG_ATOMIC_<TYPE>_LOCK_FREE macros instead, and only falls
back to the GCC versions when the Clang ones aren't available.

llvm-svn: 300920

7 years agoUse __CLANG_ATOMIC_TYPE_LOCK_FREE macros in `stdatomic.h`
Eric Fiselier [Thu, 20 Apr 2017 23:07:38 +0000 (23:07 +0000)]
Use __CLANG_ATOMIC_TYPE_LOCK_FREE macros in `stdatomic.h`

Summary: This patch makes the header `stdatomic.h` work when `-fms-compatibility` is specified.

Reviewers: rsmith

Reviewed By: rsmith

Subscribers: cfe-commits

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

llvm-svn: 300919

7 years agoFix typo in comment
Sanjoy Das [Thu, 20 Apr 2017 23:07:00 +0000 (23:07 +0000)]
Fix typo in comment

llvm-svn: 300918

7 years ago[CMake] Enable ARM target in Fuchsia toolchain
Petr Hosek [Thu, 20 Apr 2017 23:06:53 +0000 (23:06 +0000)]
[CMake] Enable ARM target in Fuchsia toolchain

This is still used by some users of Fuchsia toolchain. Also include
llc and opt which is useful for development and testing.

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

llvm-svn: 300917

7 years agoRevert "[AArch64] Improve code generation for logical instructions taking"
Akira Hatanaka [Thu, 20 Apr 2017 23:03:30 +0000 (23:03 +0000)]
Revert "[AArch64] Improve code generation for logical instructions taking"

This reverts r300913.

This broke bots.

llvm-svn: 300916

7 years ago[Simplify] Add testcase to show that merging conditional stores for triangles is...
Craig Topper [Thu, 20 Apr 2017 22:57:36 +0000 (22:57 +0000)]
[Simplify] Add testcase to show that merging conditional stores for triangles is sensitive to the order of the branch targets on the conditional branches. NFC

llvm-svn: 300915

7 years agoAdd __CLANG_ATOMIC_<TYPE>_LOCK_FREE macros for use in MSVC compatibility mode.
Eric Fiselier [Thu, 20 Apr 2017 22:53:57 +0000 (22:53 +0000)]
Add __CLANG_ATOMIC_<TYPE>_LOCK_FREE macros for use in MSVC compatibility mode.

Summary:
Libc++ currently implements the `ATOMIC_<TYPE>_LOCK_FREE` macros using the `__GCC_ATOMIC_<TYPE>_LOCK_FREE` macros. However these are not available when MSVC compatibility is enabled even though C11 `_Atomic` is.  This prevents libc++ from correctly implementing `ATOMIC_<TYPE>_LOCK_FREE`.

This patch adds an alternative spelling `__CLANG_ATOMIC_<TYPE>_LOCK_FREE` that is enabled with `-fms-compatibility`.

Reviewers: rsmith, aaron.ballman, majnemer, zturner, compnerd, jfb, rnk

Reviewed By: rsmith

Subscribers: BillyONeal, smeenai, jfb, cfe-commits, dschuff

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

llvm-svn: 300914

7 years ago[AArch64] Improve code generation for logical instructions taking
Akira Hatanaka [Thu, 20 Apr 2017 22:47:56 +0000 (22:47 +0000)]
[AArch64] Improve code generation for logical instructions taking
immediate operands.

This commit adds an AArch64 dag-combine that optimizes code generation
for logical instructions taking immediate operands. The optimization
uses demanded bits to change a logical instruction's immediate operand
so that the immediate can be folded into the immediate field of the
instruction.

rdar://problem/18231627

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

llvm-svn: 300913

7 years ago[InstCombine] function names start with lower-case letter; NFC
Sanjay Patel [Thu, 20 Apr 2017 22:37:01 +0000 (22:37 +0000)]
[InstCombine] function names start with lower-case letter; NFC

Forgot to make this fix with the signature change in r300911.

llvm-svn: 300912

7 years ago[InstCombine] allow shl+shr demanded bits folds with splat constants
Sanjay Patel [Thu, 20 Apr 2017 22:33:54 +0000 (22:33 +0000)]
[InstCombine] allow shl+shr demanded bits folds with splat constants

llvm-svn: 300911

7 years agoCOFF: Remove some undefined declarations. NFC.
Peter Collingbourne [Thu, 20 Apr 2017 22:23:36 +0000 (22:23 +0000)]
COFF: Remove some undefined declarations. NFC.

llvm-svn: 300910

7 years agoSema: protect against ObjC++ typo-correction failure
Saleem Abdulrasool [Thu, 20 Apr 2017 22:23:10 +0000 (22:23 +0000)]
Sema: protect against ObjC++ typo-correction failure

ObjC++ has two different types of "pointer" types (ObjCClassPointerType
and PointerType).  Both can be indirected through.  However, the former
is not a member expression.  Ensure that we do not try to rebuild the
MRE in that case.

llvm-svn: 300909

7 years agoParse: cleanup some bleeding whitespace
Saleem Abdulrasool [Thu, 20 Apr 2017 22:23:07 +0000 (22:23 +0000)]
Parse: cleanup some bleeding whitespace

Clean up some bleeding whitespace that I noticed.  NFC

llvm-svn: 300908

7 years ago[InstCombine] add tests for shl+shr demanded bits splat vector folds; NFC
Sanjay Patel [Thu, 20 Apr 2017 22:18:47 +0000 (22:18 +0000)]
[InstCombine] add tests for shl+shr demanded bits splat vector folds; NFC

llvm-svn: 300907

7 years ago[asan] Match BUS and SIGV to fix test on Darwin
Vitaly Buka [Thu, 20 Apr 2017 21:58:18 +0000 (21:58 +0000)]
[asan] Match BUS and SIGV to fix test on Darwin

llvm-svn: 300906

7 years agoAArch64: lower "fence singlethread" to a pure compiler barrier.
Tim Northover [Thu, 20 Apr 2017 21:57:45 +0000 (21:57 +0000)]
AArch64: lower "fence singlethread" to a pure compiler barrier.

Single-threaded fences aren't required to provide any synchronization with
other processing elements so there's no need for a DMB. They should still be a
barrier for compiler optimizations though.

llvm-svn: 300905

7 years agoARM: lower "fence singlethread" to a pure compiler barrier.
Tim Northover [Thu, 20 Apr 2017 21:56:52 +0000 (21:56 +0000)]
ARM: lower "fence singlethread" to a pure compiler barrier.

Single-threaded fences aren't required to provide any synchronization with
other processing elements so there's no need for a DMB. They should still be a
barrier for compiler optimizations though.

llvm-svn: 300904

7 years agoEnable LSan on PowerPC64.
Alex Shlyapnikov [Thu, 20 Apr 2017 21:56:36 +0000 (21:56 +0000)]
Enable LSan on PowerPC64.

Summary: Re-landing reverted D31995 with suppressions defined in D32303.

Reviewers: eugenis

Subscribers: nemanjai, llvm-commits

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

llvm-svn: 300903

7 years agoAdd an example command to toggle between disassembly-only and source mode.
Jim Ingham [Thu, 20 Apr 2017 21:51:27 +0000 (21:51 +0000)]
Add an example command to toggle between disassembly-only and source mode.

Sometimes you are debugging in source, but you really only want to see
the disassembly.  That's easy to do but you have to set a few variables.
This command toggles between your old values, and a disassembly only mode.

llvm-svn: 300902

7 years ago[cfi] Add explicit -flto in create-derivers test.
Evgeniy Stepanov [Thu, 20 Apr 2017 21:44:37 +0000 (21:44 +0000)]
[cfi] Add explicit -flto in create-derivers test.

This is necessary to run the test suite in ThinLTO mode - otherwise
opt complains about an input file containing several modules.

llvm-svn: 300901

7 years ago[cfi] Move one test under cross-dso/icall.
Evgeniy Stepanov [Thu, 20 Apr 2017 21:44:35 +0000 (21:44 +0000)]
[cfi] Move one test under cross-dso/icall.

The test is using indirect calls.

llvm-svn: 300900

7 years agoUse basicblock split block utility function
Xinliang David Li [Thu, 20 Apr 2017 21:40:22 +0000 (21:40 +0000)]
Use basicblock split block utility function

Instead of calling BasicBlock::SplitBasicBlock directly in
CodeExtractor.

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

llvm-svn: 300899

7 years ago[InstCombine] allow shl demanded bits folds with splat constants
Sanjay Patel [Thu, 20 Apr 2017 21:33:02 +0000 (21:33 +0000)]
[InstCombine] allow shl demanded bits folds with splat constants

More fixes are needed to enable the helper SimplifyShrShlDemandedBits().

llvm-svn: 300898

7 years agoEnable lsan test suite on Darwin x86_64 builds
Francis Ricci [Thu, 20 Apr 2017 21:27:25 +0000 (21:27 +0000)]
Enable lsan test suite on Darwin x86_64 builds

Reviewers: kubamracek, alekseyshl

Subscribers: mgorny, llvm-commits

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

llvm-svn: 300897

7 years ago[InstCombine] Use APInt::intersects and APInt::isSubsetOf to improve a few more place...
Craig Topper [Thu, 20 Apr 2017 21:24:37 +0000 (21:24 +0000)]
[InstCombine] Use APInt::intersects and APInt::isSubsetOf to improve a few more places in SimplifyDemandedBits.

llvm-svn: 300896

7 years agoFix Python 2 vs 3 incompatability with dict.items() vs iteritems()
Eric Fiselier [Thu, 20 Apr 2017 21:23:58 +0000 (21:23 +0000)]
Fix Python 2 vs 3 incompatability with dict.items() vs iteritems()

llvm-svn: 300895

7 years agoEnable leak sanitizer builds for darwin
Francis Ricci [Thu, 20 Apr 2017 21:11:51 +0000 (21:11 +0000)]
Enable leak sanitizer builds for darwin

Summary:
Support for leak sanitizer on darwin has been added to
compiler-rt, this patch adds compiler support.

Reviewers: dexonsmith, compnerd

Subscribers: alekseyshl, kubamracek, cfe-commits

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

llvm-svn: 300894

7 years ago[AArch64] Whitespace/ordering fixes for Falkor machine description. NFC.
Chad Rosier [Thu, 20 Apr 2017 21:11:17 +0000 (21:11 +0000)]
[AArch64] Whitespace/ordering fixes for Falkor machine description. NFC.

llvm-svn: 300893

7 years ago[AArch64] Refine Falkor machine description for pre/post-inc and stores.
Chad Rosier [Thu, 20 Apr 2017 21:11:09 +0000 (21:11 +0000)]
[AArch64] Refine Falkor machine description for pre/post-inc and stores.

llvm-svn: 300892

7 years agoBegin making git-clang-format python3 compatible.
Eric Fiselier [Thu, 20 Apr 2017 21:05:58 +0000 (21:05 +0000)]
Begin making git-clang-format python3 compatible.

This patch fixes most of the python3 incompatabilities
within git-clang-format while keeping the script python2 compatible.
There is still one remaining incompatability that prevents using Python3
which is the `str` vs `byte` type change. I plan to put those fixes
up for review separately.

This patch contains fixes for the following incompatabilities:

1) Use the new style Python3 `print` function. This requires importing
   __future__.print_function.

2) Fix incompatability between the Python3 octal prefix and the
   octal prefix Git uses.

3) Replace use of dict.iteritems() with dict.viewitems() because iteritems()
   has been removed in Python3. viewitems() reviews python 2.7 but that is
   also what the script is documented as requiring.

llvm-svn: 300891

7 years agomake detect_leaks=1 the default for the lsan test suite
Francis Ricci [Thu, 20 Apr 2017 21:00:02 +0000 (21:00 +0000)]
make detect_leaks=1 the default for the lsan test suite

Summary:
This already appears to be the case in all .cc test files,
it was probably left out of the .c test files accidentally. Make it a global
default, instead of manually adding it to each individual test.

This is needed to force leak detection for Darwin tests, where leak detection
is disabled by default.

Reviewers: m.ostapenko, kubamracek, alekseyshl

Subscribers: llvm-commits

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

llvm-svn: 300890

7 years ago[asan] Optimize strchr for strict_string_checks=false
Vitaly Buka [Thu, 20 Apr 2017 20:59:37 +0000 (20:59 +0000)]
[asan] Optimize strchr for strict_string_checks=false

Summary:
strchr interceptor does not need to call strlen if strict_string_checks is not
enabled. Unnecessary strlen calls affect python parser performance.

Reviewers: eugenis, kcc

Subscribers: llvm-commits, kubamracek

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

llvm-svn: 300889

7 years ago[InstCombine] allow ashr/lshr demanded bits folds with splat constants
Sanjay Patel [Thu, 20 Apr 2017 20:59:02 +0000 (20:59 +0000)]
[InstCombine] allow ashr/lshr demanded bits folds with splat constants

llvm-svn: 300888

7 years agoDefine standard suppressions for LSan, start with this one.
Alex Shlyapnikov [Thu, 20 Apr 2017 20:54:22 +0000 (20:54 +0000)]
Define standard suppressions for LSan, start with this one.

llvm-svn: 300887

7 years agoDefine a suppression for known leaks on pthread_exit call.
Alex Shlyapnikov [Thu, 20 Apr 2017 20:54:19 +0000 (20:54 +0000)]
Define a suppression for known leaks on pthread_exit call.

Summary: Refer to D32194 for the context.

Reviewers: eugenis

Subscribers: kubamracek, llvm-commits

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

llvm-svn: 300886

7 years ago[InstCombine] Use APInt::isSubsetOf to simplify some code in SimplifyDemandedBits...
Craig Topper [Thu, 20 Apr 2017 20:47:35 +0000 (20:47 +0000)]
[InstCombine] Use APInt::isSubsetOf to simplify some code in SimplifyDemandedBits. NFC

This allows us to use less temporary APInt for And and Invert operations.

llvm-svn: 300885

7 years ago[InstCombine] add tests for demanded bits ashr/lshr splat constants; NFC
Sanjay Patel [Thu, 20 Apr 2017 20:44:54 +0000 (20:44 +0000)]
[InstCombine] add tests for demanded bits ashr/lshr splat constants; NFC

llvm-svn: 300884

7 years agoDon't emit locations that need a DW_OP_stack_value in DWARF 2 & 3.
Adrian Prantl [Thu, 20 Apr 2017 20:42:33 +0000 (20:42 +0000)]
Don't emit locations that need a DW_OP_stack_value in DWARF 2 & 3.

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

llvm-svn: 300883

7 years ago[Support] Make asan poisoning for recyclers more aggressive by also poisoning the...
Benjamin Kramer [Thu, 20 Apr 2017 20:28:18 +0000 (20:28 +0000)]
[Support] Make asan poisoning for recyclers more aggressive by also poisoning the 'next' pointer.

llvm-svn: 300882

7 years agoFix comment and remove incorrect linker flags in test configuration
Eric Fiselier [Thu, 20 Apr 2017 20:22:19 +0000 (20:22 +0000)]
Fix comment and remove incorrect linker flags in test configuration

llvm-svn: 300881

7 years agoRemove stray ^S. NFC.
Benjamin Kramer [Thu, 20 Apr 2017 20:03:36 +0000 (20:03 +0000)]
Remove stray ^S. NFC.

llvm-svn: 300880

7 years ago[DWARF] Fix a couple of typos
Paul Robinson [Thu, 20 Apr 2017 20:03:03 +0000 (20:03 +0000)]
[DWARF] Fix a couple of typos

llvm-svn: 300879

7 years agoARM: handle post-indexed NEON ops where the offset isn't the access width.
Tim Northover [Thu, 20 Apr 2017 19:54:02 +0000 (19:54 +0000)]
ARM: handle post-indexed NEON ops where the offset isn't the access width.

Before, we assumed that any ConstantInt offset was precisely the access width,
so we could use the "[rN]!" form. ISelLowering only ever created that kind, but
further simplification during combining could lead to unexpected constants and
incorrect codegen.

Should fix PR32658.

llvm-svn: 300878

7 years agoVarStreamArrayIterator needed non-const operator* overload.
Adrian McCarthy [Thu, 20 Apr 2017 19:34:06 +0000 (19:34 +0000)]
VarStreamArrayIterator needed non-const operator* overload.

Without this change, the operator-> provided by iterator_facade lost type
qualifiers.

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

llvm-svn: 300877

7 years ago[InstCombine] Remove redundant code from SimplifyDemandedBits handling for Or. The...
Craig Topper [Thu, 20 Apr 2017 19:31:22 +0000 (19:31 +0000)]
[InstCombine] Remove redundant code from SimplifyDemandedBits handling for Or. The code above it is equivalent if you work through the bitwise math.

llvm-svn: 300876

7 years ago[DWARF] Versioning for DWARF constants; verify FORMs
Paul Robinson [Thu, 20 Apr 2017 19:16:51 +0000 (19:16 +0000)]
[DWARF] Versioning for DWARF constants; verify FORMs

Associate the version-when-defined with definitions of standard DWARF
constants.  Identify the "vendor" for DWARF extensions.
Use this information to verify FORMs in .debug_abbrev are defined as
of the DWARF version specified in the associated unit.
Removed two tests that had specified DWARF v1 (which essentially does
not exist).

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

llvm-svn: 300875

7 years ago[DeLICM] Use Known information when comparing Existing.Written and Proposed.Written.
Michael Kruse [Thu, 20 Apr 2017 19:16:39 +0000 (19:16 +0000)]
[DeLICM] Use Known information when comparing Existing.Written and Proposed.Written.

This change only affects unit tests, but no functional changes are
expected on LLVM-IR, as no Known information is yet extracted and
consequently this functionality is only triggered through unit tests.

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

llvm-svn: 300874

7 years ago[Driver] Add a missing -no-canonical-prefixes to test.
Benjamin Kramer [Thu, 20 Apr 2017 19:06:24 +0000 (19:06 +0000)]
[Driver] Add a missing -no-canonical-prefixes to test.

llvm-svn: 300873

7 years ago[go bindings] Rmove duplicated conversion function definitions after r300843.
Benjamin Kramer [Thu, 20 Apr 2017 19:06:11 +0000 (19:06 +0000)]
[go bindings] Rmove duplicated conversion function definitions after r300843.

llvm-svn: 300872

7 years ago[AArch64] Improve scheduling of logical operations on Falkor.
Chad Rosier [Thu, 20 Apr 2017 18:50:21 +0000 (18:50 +0000)]
[AArch64] Improve scheduling of logical operations on Falkor.

llvm-svn: 300871

7 years ago[Thumb-1] Fix corner cases for compressed jump tables
Weiming Zhao [Thu, 20 Apr 2017 18:37:14 +0000 (18:37 +0000)]
[Thumb-1] Fix corner cases for compressed jump tables

Summary:
When synthesized TBB/TBH is expanded, we need to avoid the case of:
   BaseReg is redefined after the load of branching target. E.g.:

    %R2 = tLEApcrelJT <jt#1>
    %R1 =  tLDRr %R1, %R2    ==> %R2 = tLEApcrelJT <jt#1>
    %R2 = tLDRspi %SP, 12        %R2 = tLDRspi %SP, 12
    tBR_JTr %R1                  tTBB_JT %R2, %R1
`
Reviewers: jmolloy

Reviewed By: jmolloy

Subscribers: llvm-commits, rengolin

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

llvm-svn: 300870

7 years ago[CodeExtractor] Remove a bunch of unneeded constructors.
Davide Italiano [Thu, 20 Apr 2017 18:33:40 +0000 (18:33 +0000)]
[CodeExtractor] Remove a bunch of unneeded constructors.

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

llvm-svn: 300869

7 years ago[Recycler] Add asan/msan annotations.
Benjamin Kramer [Thu, 20 Apr 2017 18:29:37 +0000 (18:29 +0000)]
[Recycler] Add asan/msan annotations.

This enables use after free and uninit memory checking for memory
returned by a recycler. SelectionDAG currently relies on the opcode of a
free'd node being ISD::DELETED_NODE, so poke a hole in the asan poison
for SDNode opcodes. This means that we won't find some issues, but only
in SDag.

llvm-svn: 300868

7 years agoFix use-after-frees on memory allocated in a Recycler.
Benjamin Kramer [Thu, 20 Apr 2017 18:29:14 +0000 (18:29 +0000)]
Fix use-after-frees on memory allocated in a Recycler.

This will become asan errors once the patch lands that poisons the
memory after free. The x86 change is a hack, but I don't see how to
solve this properly at the moment.

llvm-svn: 300867

7 years agoFixing outdated comment [NFC]
Artyom Skrobov [Thu, 20 Apr 2017 18:20:02 +0000 (18:20 +0000)]
Fixing outdated comment [NFC]

Since r32105 back in 2006, RegisterPass doesn't support
passes without a default constructor.

llvm-svn: 300866

7 years agoFix formatting of constrained FP intrinsic documentation
Andrew Kaylor [Thu, 20 Apr 2017 18:18:36 +0000 (18:18 +0000)]
Fix formatting of constrained FP intrinsic documentation

llvm-svn: 300865

7 years agoCodeGen: Let frame index value type match alloca addr space
Yaxun Liu [Thu, 20 Apr 2017 18:15:34 +0000 (18:15 +0000)]
CodeGen: Let frame index value type match alloca addr space

Recently alloca address space has been added to data layout. Due to this
change, pointer returned by alloca may have different size as pointer in
address space 0.

However, currently the value type of frame index is assumed to be of the
same size as pointer in address space 0.

This patch fixes that.

Most targets assume alloca returning pointer in address space 0, which
is the default alloca address space. Therefore it is NFC for them.

AMDGCN target with amdgiz environment requires this change since it
assumes alloca returning pointer to addr space 5 and its size is 32,
which is different from the size of pointer in addr space 0 which is 64.

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

llvm-svn: 300864

7 years agoRemove duplicate AttributeList::removeAttributes implementation
Reid Kleckner [Thu, 20 Apr 2017 18:08:36 +0000 (18:08 +0000)]
Remove duplicate AttributeList::removeAttributes implementation

Have the AttributeList overload delegate to the AttrBuilder one.
Simplify the AttrBuilder overload by avoiding getSlotAttributes, which
creates temporary AttributeLists.

Simplify `AttrBuilder::removeAttributes(AttributeList, unsigned)` by
using getAttributes instead of manually iterating over slots.

Extracted from https://reviews.llvm.org/D32262

NFC

llvm-svn: 300863

7 years agoChanged a use of APInt::getSignBit to APInt::getSignMask.
Sean Callanan [Thu, 20 Apr 2017 18:07:51 +0000 (18:07 +0000)]
Changed a use of APInt::getSignBit to APInt::getSignMask.

llvm-svn: 300862

7 years ago[scudo] Remove GetActuallyAllocatedSize calls from the fast path
Kostya Kortchinsky [Thu, 20 Apr 2017 18:07:17 +0000 (18:07 +0000)]
[scudo] Remove GetActuallyAllocatedSize calls from the fast path

Summary:
GetActuallyAllocatedSize is actually expensive. In order to avoid calling this
function in the malloc/free fast path, we change the Scudo chunk header to
store the size of the chunk, if from the Primary, or the amount of unused
bytes if from the Secondary. This way, we only have to call the culprit
function for Secondary backed allocations (and still in realloc).

The performance gain on a singly threaded pure malloc/free benchmark exercising
the Primary allocator is above 5%.

Reviewers: alekseyshl, kcc, dvyukov

Reviewed By: dvyukov

Subscribers: llvm-commits

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

llvm-svn: 300861

7 years ago[DAGCombiner] use more local variables in isAlias(); NFCI
Sanjay Patel [Thu, 20 Apr 2017 18:02:27 +0000 (18:02 +0000)]
[DAGCombiner] use more local variables in isAlias(); NFCI

llvm-svn: 300860

7 years ago[WebAssembly] Add known failures for wasm object file backend
Sam Clegg [Thu, 20 Apr 2017 17:18:15 +0000 (17:18 +0000)]
[WebAssembly] Add known failures for wasm object file backend

Subscribers: jfb, dschuff

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

llvm-svn: 300859

7 years agoDon't pass FPOpFusion::Strict to the backend
Adam Nemet [Thu, 20 Apr 2017 17:09:35 +0000 (17:09 +0000)]
Don't pass FPOpFusion::Strict to the backend

This restores the behavior prior to D31167 where the code-gen default was
FPC_On which mapped to FPOpFusion::Standard.  After merging the FE
state (on/off) and the code-gen state (on/fast/off), the default became off to
match the front-end.

In other words, the front-end controls when to fuse along the language
standards and the backend shouldn't override this by splitting fused
intrinsics as FPOpFusion::Strict would imply.

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

llvm-svn: 300858

7 years agoResubmit "[BitVector] Add operator<<= and operator>>=."
Zachary Turner [Thu, 20 Apr 2017 16:56:54 +0000 (16:56 +0000)]
Resubmit "[BitVector] Add operator<<= and operator>>=."

This was failing due to the use of assigning a Mask to an
unsigned, rather than to a BitWord.  But most systems do not
have sizeof(unsigned) == sizeof(unsigned long), so the mask
was getting truncated.

llvm-svn: 300857

7 years ago[APInt] Rename getSignBit to getSignMask
Craig Topper [Thu, 20 Apr 2017 16:56:25 +0000 (16:56 +0000)]
[APInt] Rename getSignBit to getSignMask

getSignBit is a static function that creates an APInt with only the sign bit set. getSignMask seems like a better name to convey its functionality. In fact several places use it and then store in an APInt named SignMask.

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

llvm-svn: 300856

7 years ago[SVE] Fix mismatched sign comparison warning in unit test from r300842.
Amara Emerson [Thu, 20 Apr 2017 16:54:49 +0000 (16:54 +0000)]
[SVE] Fix mismatched sign comparison warning in unit test from r300842.

llvm-svn: 300855

7 years ago[DAGCombiner] fix variable names in isAlias(); NFCI
Sanjay Patel [Thu, 20 Apr 2017 16:36:37 +0000 (16:36 +0000)]
[DAGCombiner] fix variable names in isAlias(); NFCI

We started with zero-based params and switched to one-based locals...
Also, variables start with a capital and functions do not.

llvm-svn: 300854

7 years agoResurrect LLDB Standalone build on NetBSD
Kamil Rytarowski [Thu, 20 Apr 2017 16:35:36 +0000 (16:35 +0000)]
Resurrect LLDB Standalone build on NetBSD

Include CheckIncludeFile for check_include_file() in CMake.

Detect <sys/event.h> in CMake.
This header is available on NetBSD.

llvm-svn: 300853

7 years agoRevert "[BitVector] Add operator<<= and operator>>=."
Zachary Turner [Thu, 20 Apr 2017 16:35:22 +0000 (16:35 +0000)]
Revert "[BitVector] Add operator<<= and operator>>=."

This is causing test failures on Linux / BSD systems.  Reverting
while I investigate.

llvm-svn: 300852

7 years ago[APInt] Add isSubsetOf method that can check if one APInt is a subset of another...
Craig Topper [Thu, 20 Apr 2017 16:17:13 +0000 (16:17 +0000)]
[APInt] Add isSubsetOf method that can check if one APInt is a subset of another without creating temporary APInts

This question comes up in many places in SimplifyDemandedBits. This makes it easy to ask without allocating additional temporary APInts.

The BitVector class provides a similar functionality through its (IMHO badly named) test(const BitVector&) method. Though its output polarity is reversed.

I've provided one example use case in this patch. I plan to do more as a follow up.

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

llvm-svn: 300851

7 years ago[DAGCombiner] give names to repeated calcs in isAlias(); NFCI
Sanjay Patel [Thu, 20 Apr 2017 16:15:08 +0000 (16:15 +0000)]
[DAGCombiner] give names to repeated calcs in isAlias(); NFCI

llvm-svn: 300850

7 years agoIn SimplifyDemandedUseBits, use computeKnownBits directly to handle Constants
Craig Topper [Thu, 20 Apr 2017 16:14:58 +0000 (16:14 +0000)]
In SimplifyDemandedUseBits, use computeKnownBits directly to handle Constants

Currently we don't explicitly process ConstantDataSequential, ConstantAggregateZero, or ConstantVector, or Undef before applying the Depth limit. Instead they occur after the depth check in the non-instruction path.

For the constant types that we do handle, the code is replicated from computeKnownBits.

This patch fixes the missing constant handling and the reduces the amount of code by just using computeKnownBits directly for any type of Constant.

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

llvm-svn: 300849

7 years ago[BitVector] Add operator<<= and operator>>=.
Zachary Turner [Thu, 20 Apr 2017 15:57:58 +0000 (15:57 +0000)]
[BitVector] Add operator<<= and operator>>=.

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

llvm-svn: 300848

7 years ago[globalisel] Enable tracing the legalizer with --debug-only=legalize-mir
Daniel Sanders [Thu, 20 Apr 2017 15:46:12 +0000 (15:46 +0000)]
[globalisel] Enable tracing the legalizer with --debug-only=legalize-mir

Reviewers: t.p.northover, ab, qcolombet, aditya_nandakumar, rovka, kristof.beyls

Reviewed By: kristof.beyls

Subscribers: dberris, igorb, llvm-commits

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

llvm-svn: 300847

7 years ago[scudo] Minor changes and refactoring
Kostya Kortchinsky [Thu, 20 Apr 2017 15:11:00 +0000 (15:11 +0000)]
[scudo] Minor changes and refactoring

Summary:
This is part of D31947 that is being split into several smaller changes.

This one deals with all the minor changes, more specifically:
- Rename some variables and functions to make their purpose clearer;
- Reorder some code;
- Mark the hot termination incurring checks as `UNLIKELY`; if they happen, the
  program will die anyway;
- Add a `getScudoChunk` method;
- Add an `eraseHeader` method to ScudoChunk that will clear a header with 0s;
- Add a parameter to `allocate` to know if the allocated chunk should be filled
  with zeros. This allows `calloc` to not have to call
  `GetActuallyAllocatedSize`; more changes to get rid of this function on the
  hot paths will follow;
- reallocate was missing a check to verify that the pointer is properly
  aligned on `MinAlignment`;
- The `Stats` in the secondary have to be protected by a mutex as the `Add`
  and `Sub` methods are actually not atomic;
- The software CRC32 function was moved to the header to allow for inlining.

Reviewers: dvyukov, alekseyshl, kcc

Reviewed By: dvyukov

Subscribers: llvm-commits

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

llvm-svn: 300846

7 years ago[Utility] Placate another GCC warning.
Davide Italiano [Thu, 20 Apr 2017 14:45:33 +0000 (14:45 +0000)]
[Utility] Placate another GCC warning.

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

llvm-svn: 300845

7 years agoIntroduce LLVMDIBuilderRef
Amaury Sechet [Thu, 20 Apr 2017 14:22:47 +0000 (14:22 +0000)]
Introduce LLVMDIBuilderRef

Summary:
This patch adds a definition of `LLVMDIBuilderRef` that represents an `llvm::DIBuilder`.

Authored by Harlan Haskins

Reviewers: deadalnix, aprantl, probinson, dblaikie, echristo, whitequark

Reviewed By: deadalnix, whitequark

Subscribers: CodaFi, loladiro

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

llvm-svn: 300843

7 years ago[MVT][SVE] Scalable vector MVTs (3/3)
Amara Emerson [Thu, 20 Apr 2017 13:54:09 +0000 (13:54 +0000)]
[MVT][SVE] Scalable vector MVTs (3/3)

Adds MVT::ElementCount to represent the length of a
vector which may be scalable, then adds helper functions
that work with it.

Patch by Graham Hunter.

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

llvm-svn: 300842

7 years agoDelete unused IncompleteFormat variable, NFCi.
Krasimir Georgiev [Thu, 20 Apr 2017 13:37:27 +0000 (13:37 +0000)]
Delete unused IncompleteFormat variable, NFCi.

llvm-svn: 300841

7 years ago[MVT][SVE] Scalable vector MVTs (2/3)
Amara Emerson [Thu, 20 Apr 2017 13:36:58 +0000 (13:36 +0000)]
[MVT][SVE] Scalable vector MVTs (2/3)
Adds scalable vector machine value types, and updates
the switch statements required for tablegen.

Patch by Graham Hunter.

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

llvm-svn: 300840

7 years ago[mips][msa] Mask vectors holding shift amounts
Petar Jovanovic [Thu, 20 Apr 2017 13:26:46 +0000 (13:26 +0000)]
[mips][msa] Mask vectors holding shift amounts

Masked vectors which hold shift amounts when creating the following nodes:
ISD::SHL, ISD::SRL or ISD::SRA.
Instructions that use said nodes, which have had their arguments altered are
sll, srl, sra, bneg, bclr and bset.

For said instructions, the shift amount or the bit position that is
specified in the corresponding vector elements will be interpreted as the
shift amount/bit position modulo the size of the element in bits.

The problem lies in compiling with -O2 enabled, where the instructions for
formats .w and .d are not generated, but are instead optimized away.
In this case, having shift amounts that are either negative or greater than
the element bit size results in generation of incorrect results when
constant folding.

We remedy this by masking the operands for the nodes mentioned above before
actually creating them, so that the final result is correct before placed
into the constant pool.

Patch by Stefan Maksimovic.

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

llvm-svn: 300839

7 years ago[MVT][SVE] Scalable vector MVTs (1/3)
Amara Emerson [Thu, 20 Apr 2017 13:08:17 +0000 (13:08 +0000)]
[MVT][SVE] Scalable vector MVTs (1/3)

This patch adds a few helper functions to obtain new vector
value types based on existing ones without needing to care
about whether they are scalable or not.

I've confined their use to a few common locations right now,
and targets that don't have scalable vectors should never
need to care about these.

Patch by Graham Hunter.

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

llvm-svn: 300838

7 years agoSkip TestLibCxxAtomic with gcc
Pavel Labath [Thu, 20 Apr 2017 12:30:30 +0000 (12:30 +0000)]
Skip TestLibCxxAtomic with gcc

older versions of libc++ (still used on some linux systems) are not
compatible with gcc.

llvm-svn: 300837

7 years agoRecompute ArchSpec core after MergeFrom
Pavel Labath [Thu, 20 Apr 2017 12:30:18 +0000 (12:30 +0000)]
Recompute ArchSpec core after MergeFrom

Summary:
MergeFrom was updating the architecture if the target triple did not
have it set. However, it was leaving the core field as invalid. This
resulted in assertion failures in core file tests as a missing core
meant we were unable to compute the address byte size properly.

Add a unit test for the new behaviour.

Reviewers: jingham, clayborg

Subscribers: lldb-commits

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

llvm-svn: 300836

7 years agoMake TestStaticVariables XFAIL more specific
Pavel Labath [Thu, 20 Apr 2017 11:28:07 +0000 (11:28 +0000)]
Make TestStaticVariables XFAIL more specific

The test fails because an older clang did not emit the required debug
info (I am not sure when this got added, but clang-3.7 certainly did not
work yet). The actual platform has nothing to do with this.

llvm-svn: 300834

7 years agoAdd libc++ category the three more tests
Pavel Labath [Thu, 20 Apr 2017 11:27:58 +0000 (11:27 +0000)]
Add libc++ category the three more tests

I thought my previous commit got the last ones but somehow I missed
these. This also resurrects TestDataFormatterLibcxxSet, which got
commented out in r263859 as a part of some seemingly unrelated change.

llvm-svn: 300833

7 years ago[index] Record class template specializations using a new 'SpecializationOf'
Alex Lorenz [Thu, 20 Apr 2017 10:43:22 +0000 (10:43 +0000)]
[index] Record class template specializations using a new 'SpecializationOf'
relationship

rdar://31603531

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

llvm-svn: 300832

7 years ago[ARM] Fix handling of mapping symbols when changing sections
John Brawn [Thu, 20 Apr 2017 10:18:13 +0000 (10:18 +0000)]
[ARM] Fix handling of mapping symbols when changing sections

ChangeSection incorrectly registers LastEMSInfo as belonging to the previous
section, not the current section. This happens to work when changing sections
using .section, as the previous section is set to the current section before
the call to ChangeSection, but not when using .popsection.

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

llvm-svn: 300831

7 years ago[AArch64] Fix handling of zero immediate in fmov instructions
John Brawn [Thu, 20 Apr 2017 10:13:54 +0000 (10:13 +0000)]
[AArch64] Fix handling of zero immediate in fmov instructions

Currently fmov #0 with a vector destination is handle incorrectly and results in
fmov #-1.9375 being emitted but should instead give an error. This is due to the
way we cope with fmov #0 with a scalar destination being an alias of fmov zr, so
fix this by actually doing it through an alias.

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

llvm-svn: 300830

7 years agoAdd Python 3 support to clang.cindex
Jonathan Coe [Thu, 20 Apr 2017 10:11:01 +0000 (10:11 +0000)]
Add Python 3 support to clang.cindex

Summary:
Introduce an interop string to convert from unicode to c-strings where needed.
Add missing conversions from _CXString to strings in function registrations.
Explicitly evaluate lists where Python 3's lazy iterators would not otherwise do so.

This is an improvement upon the reverted change proposed in https://reviews.llvm.org/D26082

Reviewers: compnerd, skalinichev, modocache, MathieuDuponchelle

Reviewed By: compnerd

Subscribers: cfe-commits

Tags: #clang-c

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

llvm-svn: 300829

7 years ago[AArch64] Fix handling of integer fp immediates
John Brawn [Thu, 20 Apr 2017 10:10:10 +0000 (10:10 +0000)]
[AArch64] Fix handling of integer fp immediates

When an integer is used as an fp immediate we're failing to check the return
value of getFP64Imm, so invalid values are silently permitted. Fix this by
merging together the integer and real handling.

llvm-svn: 300828

7 years ago[ARM] Rename HW div feature to HW div Thumb. NFCI.
Diana Picus [Thu, 20 Apr 2017 09:38:25 +0000 (09:38 +0000)]
[ARM] Rename HW div feature to HW div Thumb. NFCI.

The hardware div feature refers only to Thumb, but because of its name
it is tempting to use it to check for hardware division in general,
which may cause problems in ARM mode. See https://reviews.llvm.org/D32005.

This patch adds "Thumb" to its name, to make its scope clear. One
notable place where I haven't made the change is in the feature flag
(used with -mattr), which is still hwdiv. Changing it would also require
changes in a lot of tests, including clang tests, and it doesn't seem
like it's worth the effort.

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

llvm-svn: 300827

7 years agoAdd #pragma clang attribute support to the availability attribute
Alex Lorenz [Thu, 20 Apr 2017 09:35:02 +0000 (09:35 +0000)]
Add #pragma clang attribute support to the availability attribute

rdar://31707804

llvm-svn: 300826

7 years agoPR19260: Teach doxygen to spell correctly the include paths.
Vassil Vassilev [Thu, 20 Apr 2017 08:57:41 +0000 (08:57 +0000)]
PR19260: Teach doxygen to spell correctly the include paths.

Currently we have #include <Sema.h> in the doxygen page documenting Sema. The
patch changes it ot #include "clang/Sema/Sema.h" which is what we would spell if
we need to include it in a real codebase.

Patch by Yuka Takahashi (D32113)!

llvm-svn: 300825

7 years ago[APInt] In slt/sgt(uint64_t), only call getMinSignedBits if the APInt is not a single...
Craig Topper [Thu, 20 Apr 2017 06:04:03 +0000 (06:04 +0000)]
[APInt] In slt/sgt(uint64_t), only call getMinSignedBits if the APInt is not a single word.

llvm-svn: 300824

7 years ago[APInt] Call the slow case counting methods directly in isMask/isShiftedMask. We...
Craig Topper [Thu, 20 Apr 2017 06:04:01 +0000 (06:04 +0000)]
[APInt] Call the slow case counting methods directly in isMask/isShiftedMask. We already handled the single word case. NFC

llvm-svn: 300823

7 years ago[XRay] [compiler-rt] - Fix standalone and non-deterministic test issue
Keith Wyss [Thu, 20 Apr 2017 05:59:26 +0000 (05:59 +0000)]
[XRay] [compiler-rt] - Fix standalone and non-deterministic test issue

Summary:
The thread order test fails sometimes my machine independently of standalone
build.

From testing both standalone and in-tree build, I see I configured it wrong.

The other hypothesis for an issue is that cold starts can interfere with whether
record unwriting happens. Once this happens more than once, we can naively
FileCheck on the wrong test output, which compounds the issue.

While "rm blah.* || true" will print to stderr if the glob can't expand, this is
mostly harmless and makes sure earlier failing tests don't sabotage us.

Example failure:

---
header:
  version:         1
  type:            1
  constant-tsc:    true
  nonstop-tsc:     true
  cycle-frequency: 3800000000
records:
  - { type: 0, func-id: 1, function: 'f1()', cpu: 9, thread: 21377, kind: function-enter, tsc: 2413745203147228 }
  - { type: 0, func-id: 1, function: 'f1()', cpu: 9, thread: 21377, kind: function-exit, tsc: 2413745203304238 }
...

The CMAKE related change fixes the expectation that COMPILER_RT_STANDALONE_BUILD will be explicitly FALSE instead
of empty string when it is not "TRUE".

Reviewers: dberris

Subscribers: llvm-commits

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

llvm-svn: 300822

7 years ago[SelectionDAG] Fix another place that was passing a large value to APInt::lshrInPlace.
Craig Topper [Thu, 20 Apr 2017 04:55:01 +0000 (04:55 +0000)]
[SelectionDAG] Fix another place that was passing a large value to APInt::lshrInPlace.

llvm-svn: 300821

7 years agoDisable the filesystem library on Windows by default
Eric Fiselier [Thu, 20 Apr 2017 04:24:29 +0000 (04:24 +0000)]
Disable the filesystem library on Windows by default

llvm-svn: 300820