platform/upstream/llvm.git
7 years ago[libcxx] [test] Strip trailing whitespace. NFC.
Stephan T. Lavavej [Thu, 4 May 2017 01:43:58 +0000 (01:43 +0000)]
[libcxx] [test] Strip trailing whitespace. NFC.

llvm-svn: 302105

7 years ago[libcxx] [test] In msvc_stdlib_force_include.hpp, use _HAS_CXX17 to set TEST_STD_VER.
Stephan T. Lavavej [Thu, 4 May 2017 01:35:11 +0000 (01:35 +0000)]
[libcxx] [test] In msvc_stdlib_force_include.hpp, use _HAS_CXX17 to set TEST_STD_VER.

_HAS_CXX17 indicates whether MSVC's STL is in C++17 mode.

In MSVC there's a distinction between CRT headers like stdlib.h and STL headers
like cstdlib. Only the STL headers drag in yvals.h, our internal STL-wide header
that defines internal macros like _HAS_CXX17.

_HAS_CXX17 is an MSVC STL library macro, unconditionally defined. We centralize
everything on this, because we have to ask different questions to determine
whether C1XX, EDG, or Clang is in 14 or 17 mode, and we additionally permit
users to override the detection in one way (it's okay to ask for 17 from the
compiler, but only 14 from the libs, at least for the moment; only noexcept
in the type system will give us a headache).

As this header is for testing MSVC's STL, we can assume _HAS_CXX17 is defined.

Fixes D32726.

llvm-svn: 302104

7 years ago[XRay] Detect loops in functions being lowered
Dean Michael Berris [Thu, 4 May 2017 01:24:26 +0000 (01:24 +0000)]
[XRay] Detect loops in functions being lowered

Summary:
This is an implementation of the loop detection logic that XRay needs to
determine whether a function might take time at runtime. Without this
heuristic, XRay will tend to not instrument short functions that have
loops that might have runtime dependent on inputs or external values.

While this implementation doesn't do any further analysis than just
figuring out whether there is a loop in the MachineFunction being
code-gen'ed, we're paving the way for being able to perform more
sophisticated analysis of the function in the future (for example to
determine whether the trip count for the loop might be constant, and
make a decision on that instead). This enables us to cover more
functions with the default heuristics, and potentially identify ones
that have variable runtime latency just by looking for the presence of
loops.

Reviewers: chandlerc, rnk, pelikan

Subscribers: llvm-commits

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

llvm-svn: 302103

7 years agoAttempt to escape paths correctly
Eric Fiselier [Thu, 4 May 2017 01:17:22 +0000 (01:17 +0000)]
Attempt to escape paths correctly

llvm-svn: 302102

7 years agoAttempt to setup MSVC 2017
Eric Fiselier [Thu, 4 May 2017 01:17:21 +0000 (01:17 +0000)]
Attempt to setup MSVC 2017

llvm-svn: 302101

7 years agoUse nullptr instead of the literal 0
Eric Fiselier [Thu, 4 May 2017 01:06:56 +0000 (01:06 +0000)]
Use nullptr instead of the literal 0

llvm-svn: 302100

7 years agoFix macro redefinition warnings for _LIBCPP_NO_RTTI
Eric Fiselier [Thu, 4 May 2017 01:06:54 +0000 (01:06 +0000)]
Fix macro redefinition warnings for _LIBCPP_NO_RTTI

llvm-svn: 302099

7 years agoAdd #pragma clang module begin/end pragmas and generate them when preprocessing a...
Richard Smith [Thu, 4 May 2017 00:29:54 +0000 (00:29 +0000)]
Add #pragma clang module begin/end pragmas and generate them when preprocessing a module.

These pragmas are intended to simulate the effect of entering or leaving a file
with an associated module. This is not completely implemented yet: declarations
between the pragmas will not be attributed to the correct module, but macro
visibility is already functional.

Modules named by #pragma clang module begin must already be known to clang (in
some module map that's either loaded or on the search path).

llvm-svn: 302098

7 years agoTest commit for Appveyor - Remove incorrect caching logic
Eric Fiselier [Thu, 4 May 2017 00:16:35 +0000 (00:16 +0000)]
Test commit for Appveyor - Remove incorrect caching logic

llvm-svn: 302097

7 years ago[SCEV] createAddRecFromPHI: Optimize for the most common case.
Michael Zolotukhin [Wed, 3 May 2017 23:53:38 +0000 (23:53 +0000)]
[SCEV] createAddRecFromPHI: Optimize for the most common case.

Summary:
The existing implementation creates a symbolic SCEV expression every
time we analyze a phi node and then has to remove it, when the analysis
is finished. This is very expensive, and in most of the cases it's also
unnecessary. According to the data I collected, ~60-70% of analyzed phi
nodes (measured on SPEC) have the following form:
  PN = phi(Start, OP(Self, Constant))
Handling such cases separately significantly speeds this up.

Reviewers: sanjoy, pete

Subscribers: llvm-commits

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

llvm-svn: 302096

7 years agoCMake: Only add test/ subdirectory when it exists
Duncan P. N. Exon Smith [Wed, 3 May 2017 23:33:54 +0000 (23:33 +0000)]
CMake: Only add test/ subdirectory when it exists

r296685 started adding the test/ subdirectory even when
LIBCXX_INCLUDE_TESTS=OFF.  This is great for testing libcxx standalone,
but it also breaks the build when the test/ subdirectory is removed
(and our submission system strips all test/ directories).

This patch updates the logic to check for test/ before adding it.

rdar://problem/31931366

llvm-svn: 302095

7 years agostrlen-1.ll: Fix test
Matthias Braun [Wed, 3 May 2017 23:32:51 +0000 (23:32 +0000)]
strlen-1.ll: Fix test

Change test for `strlen(x) == 0 --> *x == 0` to actually test the
pattern.

llvm-svn: 302094

7 years ago[InstCombine][KnownBits] Use KnownBits better to detect nsw adds
Craig Topper [Wed, 3 May 2017 23:22:46 +0000 (23:22 +0000)]
[InstCombine][KnownBits] Use KnownBits better to detect nsw adds

Change checkRippleForAdd from a heuristic to a full check -
if it is provable that the add does not overflow return true, otherwise false.

Patch by Yoav Ben-Shalom

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

llvm-svn: 302093

7 years agoMark functions as not having CFI once we finalize an x86 stack frame
Reid Kleckner [Wed, 3 May 2017 23:13:42 +0000 (23:13 +0000)]
Mark functions as not having CFI once we finalize an x86 stack frame

We'll set it back to true in emitPrologue if it gets called. It doesn't
get called for naked functions.

Fixes PR32912

llvm-svn: 302092

7 years ago[KnownBits] Add methods for determining if KnownBits is a constant value
Craig Topper [Wed, 3 May 2017 23:12:29 +0000 (23:12 +0000)]
[KnownBits] Add methods for determining if KnownBits is a constant value

This patch adds isConstant and getConstant for determining if KnownBits represents a constant value and to retrieve the value. Use them to simplify code.

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

llvm-svn: 302091

7 years agoRemove a comment that is no longer true.
Rui Ueyama [Wed, 3 May 2017 23:10:33 +0000 (23:10 +0000)]
Remove a comment that is no longer true.

llvm-svn: 302090

7 years ago[ValueTracking] Remove handling for BitWidth being 0 in ComputeSignBit and isKnownNon...
Craig Topper [Wed, 3 May 2017 22:25:19 +0000 (22:25 +0000)]
[ValueTracking] Remove handling for BitWidth being 0 in ComputeSignBit and isKnownNonZero.

I don't believe its possible to have non-zero values here since DataLayout became required. The APInt constructor inside of the KnownBits object will assert if this ever happens.

llvm-svn: 302089

7 years ago[KnownBits] Add zext, sext, and trunc methods to KnownBits
Craig Topper [Wed, 3 May 2017 22:07:25 +0000 (22:07 +0000)]
[KnownBits] Add zext, sext, and trunc methods to KnownBits

This patch adds zext, sext, and trunc methods to KnownBits and uses them where possible.

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

llvm-svn: 302088

7 years ago[TargetLowering] use isSubsetOf in SimplifyDemandedBits; NFCI
Sanjay Patel [Wed, 3 May 2017 21:55:34 +0000 (21:55 +0000)]
[TargetLowering] use isSubsetOf in SimplifyDemandedBits; NFCI

This is the DAG equivalent of https://reviews.llvm.org/D32255 ,
which will hopefully be committed again. The functionality
(preferring a 'not' op) is already here in the DAG, so this is
just intended to be a clean-up and performance improvement.

llvm-svn: 302087

7 years agoclang-format and restyle DWARFFormValue before working on it. NFC
Paul Robinson [Wed, 3 May 2017 21:53:21 +0000 (21:53 +0000)]
clang-format and restyle DWARFFormValue before working on it. NFC

llvm-svn: 302086

7 years agoDebugInfo: elide type index entries for synthetic types
Saleem Abdulrasool [Wed, 3 May 2017 21:39:01 +0000 (21:39 +0000)]
DebugInfo: elide type index entries for synthetic types

Compiler emitted synthetic types may not have an associated DIFile
(translation unit).  In such a case, when generating CodeView debug type
information, we would attempt to compute an absolute filepath which
would result in a segfault due to a NULL DIFile*.  If there is no source
file associated with the type, elide the type index entry for the type
and record the type information.  This actually results in higher
fidelity debug information than clang/C2 as of this writing.

Resolves PR32668!

llvm-svn: 302085

7 years agoAttempt to fix appveyor build
Eric Fiselier [Wed, 3 May 2017 21:14:26 +0000 (21:14 +0000)]
Attempt to fix appveyor build

llvm-svn: 302084

7 years agoAccept archive files with no symbol table instad of warning on them.
Rui Ueyama [Wed, 3 May 2017 21:03:08 +0000 (21:03 +0000)]
Accept archive files with no symbol table instad of warning on them.

It seems virtually everyone who tries to do LTO build with Clang and
LLD was hit by a mistake to forget using llvm-ar command to create
archive files. I wasn't an exception. Since this is an annoying common
issue, it is probably better to handle that gracefully rather than
reporting an error and tell the user to redo build with different
configuration.

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

llvm-svn: 302083

7 years agoQualify calls to __invoke, __apply_fuctor, and __mu
Eric Fiselier [Wed, 3 May 2017 21:02:19 +0000 (21:02 +0000)]
Qualify calls to __invoke, __apply_fuctor, and __mu

llvm-svn: 302082

7 years ago[AArch64] Fix variable name ambiguity in r302078.
Ahmed Bougacha [Wed, 3 May 2017 20:51:34 +0000 (20:51 +0000)]
[AArch64] Fix variable name ambiguity in r302078.

ArchKind is passed to the function, but it's also a type.

llvm-svn: 302081

7 years ago[TailCallElim] Remove an unused argument. NFCI
Xin Tong [Wed, 3 May 2017 20:37:07 +0000 (20:37 +0000)]
[TailCallElim] Remove an unused argument. NFCI

llvm-svn: 302080

7 years ago[Driver] Update AArch64 testcase to match llvm r302078.
Ahmed Bougacha [Wed, 3 May 2017 20:34:32 +0000 (20:34 +0000)]
[Driver] Update AArch64 testcase to match llvm r302078.

llvm-svn: 302079

7 years ago[AArch64] Make the TargetParser add CPU exts provided by the arch.
Ahmed Bougacha [Wed, 3 May 2017 20:33:58 +0000 (20:33 +0000)]
[AArch64] Make the TargetParser add CPU exts provided by the arch.

Otherwise, each CPU has to manually specify the extensions it supports,
even though they have to be a superset of the base arch extensions.
And when there's redundant data there's stale data, so most of the CPUs
lie about the features they support (almost none lists AEK_FP).

Instead, do the saner thing: add the optional extensions on top of the
base extensions provided by the architecture.

The ARM TargetParser has the same behavior.

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

llvm-svn: 302078

7 years ago[AArch64] armv8-A doesn't have CRC.
Ahmed Bougacha [Wed, 3 May 2017 20:33:52 +0000 (20:33 +0000)]
[AArch64] armv8-A doesn't have CRC.

That's only a required extension as of v8.1a.

Remove it from the "generic" CPU as well: it should only support the
base ISA (and binutils agrees).

Also unify the MC tests into crc.s and arm64-crc32.s

llvm-svn: 302077

7 years ago[libFuzzer] exit without running atexit handlers in libfuzzer's crash handler
Vitaly Buka [Wed, 3 May 2017 20:31:19 +0000 (20:31 +0000)]
[libFuzzer] exit without running atexit handlers in libfuzzer's crash handler

Summary:
It's not safe to assume that atexit handlers can be run once the app crashed.

Patch by Jochen Eisinger.

Reviewers: kcc, vitalybuka

Subscribers: llvm-commits

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

llvm-svn: 302076

7 years ago[Hexagon] Use automatically-generated scheduling information for HVX
Krzysztof Parzyszek [Wed, 3 May 2017 20:10:36 +0000 (20:10 +0000)]
[Hexagon] Use automatically-generated scheduling information for HVX

Patch by Jyotsna Verma.

llvm-svn: 302073

7 years ago[ScopInfo] Do not use LLVM names to identify statements, arrays, and parameters
Tobias Grosser [Wed, 3 May 2017 20:08:52 +0000 (20:08 +0000)]
[ScopInfo] Do not use LLVM names to identify statements, arrays, and parameters

LLVM-IR names are commonly available in debug builds, but often not in release
builds. Hence, using LLVM-IR names to identify statements or memory reference
results makes the behavior of Polly depend on the compile mode. This is
undesirable. Hence, we now just number the statements instead of using LLVM-IR
names to identify them (this issue has previously been brought up by Zino
Benaissa).

However, as LLVM-IR names help in making test cases more readable, we add an
option '-polly-use-llvm-names' to still use LLVM-IR names. This flag is by
default set in the polly tests to make test cases more readable.

This change reduces the time in ScopInfo from 32 seconds to 2 seconds for the
following test case provided by Eli Friedman <efriedma@codeaurora.org> (already
used in one of the previous commits):

  struct X { int x; };
  void a();
  #define SIG (int x, X **y, X **z)
  typedef void (*fn)SIG;
  #define FN { for (int i = 0; i < x; ++i) { (*y)[i].x += (*z)[i].x; } a(); }
  #define FN5 FN FN FN FN FN
  #define FN25 FN5 FN5 FN5 FN5
  #define FN125 FN25 FN25 FN25 FN25 FN25
  #define FN250 FN125 FN125
  #define FN1250 FN250 FN250 FN250 FN250 FN250
  void x SIG { FN1250 }

For a larger benchmark I have on-hand (10000 loops), this reduces the time for
running -polly-scops from 5 minutes to 4 minutes, a reduction by 20%.

The reason for this large speedup is that our previous use of printAsOperand
had a quadratic cost, as for each printed and unnamed operand the full function
was scanned to find the instruction number that identifies the operand.

We do not need to adjust the way memory reference ids are constructured, as
they do not use LLVM values.

Reviewed by: efriedma

Tags: #polly

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

llvm-svn: 302072

7 years agoRemove unused private field.
Zachary Turner [Wed, 3 May 2017 19:42:06 +0000 (19:42 +0000)]
Remove unused private field.

llvm-svn: 302069

7 years agoAvoid warning of unused variable in release builds. NFC
Anna Thomas [Wed, 3 May 2017 19:25:04 +0000 (19:25 +0000)]
Avoid warning of unused variable in release builds. NFC

llvm-svn: 302068

7 years agoRevert r301897, "ELF: Set symbol binding to STB_GLOBAL when undefining symbols during...
Peter Collingbourne [Wed, 3 May 2017 19:23:30 +0000 (19:23 +0000)]
Revert r301897, "ELF: Set symbol binding to STB_GLOBAL when undefining symbols during LTO."

It doesn't matter what binding we store in a non-UsedInRegularObj undefined
symbol because we should reset it when we see a real undefined symbol in
a combined LTO object. The fact that we weren't doing so before is a bug
(PR32899) which is now fixed.

llvm-svn: 302067

7 years agoTests: strengthen CHECK line to avoid picking up stray path.
Tim Northover [Wed, 3 May 2017 19:20:45 +0000 (19:20 +0000)]
Tests: strengthen CHECK line to avoid picking up stray path.

A bot had "-LTO" in its working directory, which matched the regex used in this
test. Since the arg is quoted, we can exploit that instead. Still broken if
there's a path with a quote in, but I think that's pretty niche.

llvm-svn: 302066

7 years agoHandle mixed strong and weak undefined symbols.
Rafael Espindola [Wed, 3 May 2017 18:40:27 +0000 (18:40 +0000)]
Handle mixed strong and weak undefined symbols.

We were ignoring strong undefined symbols if they followed weak ones.

Fixes pr32899.

llvm-svn: 302065

7 years ago[asan] print the 'unexpected format specifier in printf interceptor' warning just...
Kostya Serebryany [Wed, 3 May 2017 18:38:34 +0000 (18:38 +0000)]
[asan] print the 'unexpected format specifier in printf interceptor' warning just once (came up in https://github.com/google/oss-fuzz/pull/562). Not touching a similar scanf warning -- for some reason it does not fire for me.

llvm-svn: 302064

7 years agoFix typos in comment
Sanjoy Das [Wed, 3 May 2017 18:29:34 +0000 (18:29 +0000)]
Fix typos in comment

llvm-svn: 302063

7 years agoBreak verification down into smaller functions to keep code clean.
Greg Clayton [Wed, 3 May 2017 18:25:46 +0000 (18:25 +0000)]
Break verification down into smaller functions to keep code clean.

Adrian requested that we break things down to make things clean in the DWARFVerifier. This patch breaks everything down into nice individual functions and cleans up the code quite a bit and prepares us for the next round of verifiers.

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

llvm-svn: 302062

7 years agoFix PPC64 warning for missing parantheses. NFC.
Anna Thomas [Wed, 3 May 2017 18:25:43 +0000 (18:25 +0000)]
Fix PPC64 warning for missing parantheses. NFC.

llvm-svn: 302061

7 years ago[IR] Abstract away ArgNo+1 attribute indexing as much as possible
Reid Kleckner [Wed, 3 May 2017 18:17:31 +0000 (18:17 +0000)]
[IR] Abstract away ArgNo+1 attribute indexing as much as possible

Summary:
Do three things to help with that:
- Add AttributeList::FirstArgIndex, which is an enumerator currently set
  to 1. It allows us to change the indexing scheme with fewer changes.
- Add addParamAttr/removeParamAttr. This just shortens addAttribute call
  sites that would otherwise need to spell out FirstArgIndex.
- Remove some attribute-specific getters and setters from Function that
  take attribute list indices.  Most of these were only used from
  BuildLibCalls, and doesNotAlias was only used to test or set if the
  return value is malloc-like.

I'm happy to split the patch, but I think they are probably easier to
review when taken together.

This patch should be NFC, but it sets the stage to change the indexing
scheme to this, which is more convenient when indexing into an array:
  0: func attrs
  1: retattrs
  2...: arg attrs

Reviewers: chandlerc, pete, javed.absar

Subscribers: david2050, llvm-commits

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

llvm-svn: 302060

7 years ago[CodeView] Remove constructor initialization of a removed field.
Davide Italiano [Wed, 3 May 2017 18:02:46 +0000 (18:02 +0000)]
[CodeView] Remove constructor initialization of a removed field.

I should've staged this with my last commit.

llvm-svn: 302059

7 years ago[RuntimeLoopUnroller] Add assert that we dont unroll non-rotated loops
Anna Thomas [Wed, 3 May 2017 17:43:59 +0000 (17:43 +0000)]
[RuntimeLoopUnroller] Add assert that we dont unroll non-rotated loops

Summary:
Cloning basic blocks in the loop for runtime loop unroller depends on loop being
in rotated form (i.e. loop latch target is the exit block).
Assert that this is true, so that callers of runtime loop unroller pass in
canonical loops.
The single caller of this function has that check recently added:
https://reviews.llvm.org/rL301239

Reviewers: davide

Subscribers: llvm-commits

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

llvm-svn: 302058

7 years agoDelete dead function causing compilation failure.
Zachary Turner [Wed, 3 May 2017 17:38:49 +0000 (17:38 +0000)]
Delete dead function causing compilation failure.

llvm-svn: 302057

7 years ago[CodeView] Remove unused private field. NFCI.
Davide Italiano [Wed, 3 May 2017 17:37:35 +0000 (17:37 +0000)]
[CodeView] Remove unused private field. NFCI.

llvm-svn: 302056

7 years ago[bpf] add relocation support
Alexei Starovoitov [Wed, 3 May 2017 17:30:56 +0000 (17:30 +0000)]
[bpf] add relocation support

  . there should be no runtime relocation inside the bpf function.
  . relocation supported here mostly for debugging.
  . a test case is added.

Signed-off-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
llvm-svn: 302055

7 years agoRevert "CMake: Move sphinx detection into AddSphinxTarget.cmake"
Tom Stellard [Wed, 3 May 2017 17:22:23 +0000 (17:22 +0000)]
Revert "CMake: Move sphinx detection into AddSphinxTarget.cmake"

This reverts commit r302025.

clang and lld need to be updated too so they don't break with this patch.

llvm-svn: 302054

7 years ago[CodeView] Use actual strings for dealing with checksums and lines.
Zachary Turner [Wed, 3 May 2017 17:11:40 +0000 (17:11 +0000)]
[CodeView] Use actual strings for dealing with checksums and lines.

The raw CodeView format references strings by "offsets", but it's
confusing what table the offset refers to.  In the case of line
number information, it's an offset into a buffer of records,
and an indirection is required to get another offset into a
different table to find the final string.  And in the case of
checksum information, there is no indirection, and the offset
refers directly to the location of the string in another buffer.

This would be less confusing if we always just referred to the
strings by their value, and have the library be smart enough
to correctly resolve the offsets on its own from the right
location.

This patch makes that possible.  When either reading or writing,
all the user deals with are strings, and the library does the
appropriate translations behind the scenes.

llvm-svn: 302053

7 years ago[llvm-readobj] Update readobj to re-use parsing code.
Zachary Turner [Wed, 3 May 2017 17:11:11 +0000 (17:11 +0000)]
[llvm-readobj] Update readobj to re-use parsing code.

llvm-readobj hand rolls some CodeView parsing code for string
tables, so this patch updates it to re-use some of the newly
introduced parsing code in LLVMDebugInfoCodeView.

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

llvm-svn: 302052

7 years agoARM: add extra test for addrmode folding.
Tim Northover [Wed, 3 May 2017 16:54:30 +0000 (16:54 +0000)]
ARM: add extra test for addrmode folding.

I was worried we might replace a mul with a mul+shift even if there were later
uses. Turns out to be unfounded but I'd just as well add an actual test for it.

llvm-svn: 302051

7 years ago[tsan] Detect races on modifying accesses in Swift code
Kuba Mracek [Wed, 3 May 2017 16:51:01 +0000 (16:51 +0000)]
[tsan] Detect races on modifying accesses in Swift code

This patch allows the Swift compiler to emit calls to `__tsan_external_write` before starting any modifying access, which will cause TSan to detect races on arrays, dictionaries and other classes defined in non-instrumented modules. Races on collections from the Swift standard library and user-defined structs and a frequent cause of subtle bugs and it's important that TSan detects those on top of existing LLVM IR instrumentation, which already detects races in direct memory accesses.

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

llvm-svn: 302050

7 years ago[X86][LWP] Add stack folding mappings and tests for LWPINS/LWPVAL instructions
Simon Pilgrim [Wed, 3 May 2017 16:46:30 +0000 (16:46 +0000)]
[X86][LWP] Add stack folding mappings and tests for LWPINS/LWPVAL instructions

llvm-svn: 302049

7 years agoSilence a 'enum and non-enum used in conditional' warning.
Simon Pilgrim [Wed, 3 May 2017 16:43:57 +0000 (16:43 +0000)]
Silence a 'enum and non-enum used in conditional' warning.

llvm-svn: 302048

7 years ago[DAGCombine] (addcarry (add|uaddo X, Y), 0, Carry) -> (addcarry X, Y, Carry)
Amaury Sechet [Wed, 3 May 2017 16:28:10 +0000 (16:28 +0000)]
[DAGCombine] (addcarry (add|uaddo X, Y), 0, Carry) -> (addcarry X, Y, Carry)

Summary: Do the transform when the carry isn't used. It's a pattern exposed when legalizing large integers.

Reviewers: jyknight, nemanjai, mkuper, spatel, RKSimon, zvi, bkramer

Subscribers: llvm-commits

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

llvm-svn: 302047

7 years agoRevert r302037
Alex Lorenz [Wed, 3 May 2017 16:22:16 +0000 (16:22 +0000)]
Revert r302037

The commit caused the following two buildbot failures:

    Clang :: Misc/error-limit-multiple-notes.cpp
    Clang :: Misc/error-limit.c

llvm-svn: 302046

7 years agoRevert my bad winasan coverage test fix and apply one that actually works
Reid Kleckner [Wed, 3 May 2017 16:11:01 +0000 (16:11 +0000)]
Revert my bad winasan coverage test fix and apply one that actually works

trace-pc doesn't work, but trace-pc-guard does. *shrug*

llvm-svn: 302045

7 years agoCreate DWARFVerifier.cpp and .h and move all DWARF verification code over into it.
Greg Clayton [Wed, 3 May 2017 16:02:29 +0000 (16:02 +0000)]
Create DWARFVerifier.cpp and .h and move all DWARF verification code over into it.

Adrian requested we create a DWARFVerifier.cpp file to contain all of the DWARF verification stuff. This change simply moves the functionality over into DWARFVerifier.h and DWARFVerifier.cpp, renames the DWARFVerifier methods to start with lower case, and switches DWARFContext.cpp over to using the new functionality.

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

llvm-svn: 302044

7 years agoSpeculative fix for WinASan after r301994
Reid Kleckner [Wed, 3 May 2017 15:59:07 +0000 (15:59 +0000)]
Speculative fix for WinASan after r301994

llvm-svn: 302043

7 years agoResubmit r301986 and r301987 "Add codeview::StringTable"
Zachary Turner [Wed, 3 May 2017 15:58:37 +0000 (15:58 +0000)]
Resubmit r301986 and r301987 "Add codeview::StringTable"

This was reverted due to a "missing" file, but in reality
what happened was that I renamed a file, and then due to
a merge conflict both the old file and the new file got
added to the repository.  This led to an unused cpp file
being in the repo and not referenced by any CMakeLists.txt
but #including a .h file that wasn't in the repo.  In an
even more unfortunate coincidence, CMake didn't report the
unused cpp file because it was in a subdirectory of the
folder with the CMakeLists.txt, and not in the same directory
as any CMakeLists.txt.

The presence of the unused file was then breaking certain
tools that determine file lists by globbing rather than
by what's specified in CMakeLists.txt

In any case, the fix is to just remove the unused file from
the patch set.

llvm-svn: 302042

7 years ago[X86][LWP] Add llvm support for LWP instructions (reapplied).
Simon Pilgrim [Wed, 3 May 2017 15:51:39 +0000 (15:51 +0000)]
[X86][LWP] Add llvm support for LWP instructions (reapplied).

This patch adds support for the the LightWeight Profiling (LWP) instructions which are available on all AMD Bulldozer class CPUs (bdver1 to bdver4).

Reapplied - this time without changing line endings of existing files.

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

llvm-svn: 302041

7 years ago[APInt] Give the value union a name so we can remove assumptions on VAL being the...
Craig Topper [Wed, 3 May 2017 15:46:24 +0000 (15:46 +0000)]
[APInt] Give the value union a name so we can remove assumptions on VAL being the larger member

Currently several places assume the VAL member is always at least the same size as pVal. In particular for a memcpy in the move assignment operator. While this is a true assumption, it isn't good practice to assume this.

This patch gives the union a name so we can write the memcpy in terms of the union itself. This also adds a similar memcpy to the move constructor where we previously just copied using VAL directly.

This patch is mostly just a mechanical addition of the U in front of VAL and pVAL everywhere. But several constructors had to be modified since we can't directly initializer a field of named union from the initializer list.

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

llvm-svn: 302040

7 years agoVerify that no compile units share the same line table in "llvm-dwarfdump --verify"
Greg Clayton [Wed, 3 May 2017 15:45:31 +0000 (15:45 +0000)]
Verify that no compile units share the same line table in "llvm-dwarfdump --verify"

Check to make sure no compile units have the same DW_AT_stmt_list values. Report a verification error if they do.

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

llvm-svn: 302039

7 years agoRevert rL302028 due to accidental line ending changes.
Simon Pilgrim [Wed, 3 May 2017 15:42:29 +0000 (15:42 +0000)]
Revert rL302028 due to accidental line ending changes.

llvm-svn: 302038

7 years agoDiagnosticsEngine should clear DelayedDiagID before reporting the
Alex Lorenz [Wed, 3 May 2017 15:41:16 +0000 (15:41 +0000)]
DiagnosticsEngine should clear DelayedDiagID before reporting the
delayed diagnostic

This avoids an infinite loop that was uncovered in one of our internal tests
by r301992. The testcase is the most reduced version of that auto-generated
test.

rdar://31962618

llvm-svn: 302037

7 years ago[Hexagon] Handle S2_storerf_io in HexagonInstrInfo
Krzysztof Parzyszek [Wed, 3 May 2017 15:36:51 +0000 (15:36 +0000)]
[Hexagon] Handle S2_storerf_io in HexagonInstrInfo

llvm-svn: 302036

7 years ago[Hexagon] Misc fixes in HexagonInstrInfo, NFC
Krzysztof Parzyszek [Wed, 3 May 2017 15:34:52 +0000 (15:34 +0000)]
[Hexagon] Misc fixes in HexagonInstrInfo, NFC

Formatting changes + remove unused function.

llvm-svn: 302035

7 years ago[Hexagon] Adjust latency between allocframe and the first store on stack
Krzysztof Parzyszek [Wed, 3 May 2017 15:33:09 +0000 (15:33 +0000)]
[Hexagon] Adjust latency between allocframe and the first store on stack

Allocframe and the following stores on the stack have a latency of 2 cycles
when not in the same packet. This happens because R29 is needed early by the
store instruction. Since one of such stores can be packetized along with
allocframe and use old value of R29, we can assign it 0 cycle latency
while leaving latency of other stores to the default value of 2 cycles.

Patch by Jyotsna Verma.

llvm-svn: 302034

7 years ago[Hexagon] Handle J2_jumptpt and J2_jumpfpt in HexagonInstrInfo
Krzysztof Parzyszek [Wed, 3 May 2017 15:30:46 +0000 (15:30 +0000)]
[Hexagon] Handle J2_jumptpt and J2_jumpfpt in HexagonInstrInfo

llvm-svn: 302033

7 years ago[Hexagon] Implement undoing .cur instructions in packetizer
Krzysztof Parzyszek [Wed, 3 May 2017 15:28:56 +0000 (15:28 +0000)]
[Hexagon] Implement undoing .cur instructions in packetizer

The packetizer needs to convert .cur instruction to its regular form if
the use is not in the same packet as the .cur. The code in the packetizer
handles one type of .cur, which is the vector load case. This patch
updates the packetizer so that it can undo all the .cur instructions.
In the test case, the .cur is the 128B version, but there are also the
post-increment versions.

Patch by Brendon Cahoon.

llvm-svn: 302032

7 years ago[OpenMP] Extended parse for 'always' map modifier
Carlo Bertolli [Wed, 3 May 2017 15:28:48 +0000 (15:28 +0000)]
[OpenMP] Extended parse for 'always' map modifier

https://reviews.llvm.org/D32807

This patch allows the map modifier 'always' to be separated by the map type (to, from, tofrom) only by a whitespace, rather than strictly by a comma as in current trunk.

llvm-svn: 302031

7 years ago[Hexagon] Add memory operands to a rewritten load
Krzysztof Parzyszek [Wed, 3 May 2017 15:26:13 +0000 (15:26 +0000)]
[Hexagon] Add memory operands to a rewritten load

llvm-svn: 302030

7 years ago[Hexagon] Reset spill alignment when variable-sized objects are present
Krzysztof Parzyszek [Wed, 3 May 2017 15:23:53 +0000 (15:23 +0000)]
[Hexagon] Reset spill alignment when variable-sized objects are present

llvm-svn: 302029

7 years ago[X86][LWP] Add llvm support for LWP instructions.
Simon Pilgrim [Wed, 3 May 2017 15:18:34 +0000 (15:18 +0000)]
[X86][LWP] Add llvm support for LWP instructions.

This patch adds support for the the LightWeight Profiling (LWP) instructions which are available on all AMD Bulldozer class CPUs (bdver1 to bdver4).

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

llvm-svn: 302028

7 years agoDon't attempt to use mpx registers on unsupported platforms
Francis Ricci [Wed, 3 May 2017 15:00:04 +0000 (15:00 +0000)]
Don't attempt to use mpx registers on unsupported platforms

Summary:
The existing cpp-level checks using PR_MPX_ENABLE_MANAGEMENT aren't sufficient,
as this isn't defined for linux kernel versions below 3.19.

Reviewers: valentinagiusti, zturner, labath

Subscribers: lldb-commits

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

llvm-svn: 302027

7 years agoCMake: Add LLVM_DYLIB_SYMBOL_VERSIONING option
Tom Stellard [Wed, 3 May 2017 14:43:44 +0000 (14:43 +0000)]
CMake: Add LLVM_DYLIB_SYMBOL_VERSIONING option

Summary:
When apps or other libraries link against a library with symbol
versions, the version string is recorded in the import table, and used
at runtime to resolve the symbol back to a library that provides that
version (vaguely like how two-level namespaces work in Mach-O).  ld's
--default-symver flag tags every exported symbol with a symbol version
string equal to the library's soname.  Using --default-symver means
multiple versions of libLLVM can coexist within the same process, at
least to the extent that they don't try to pass data between each
other's llvms.

As an example, imagine a language like Rust using llvm for CPU codegen,
binding to OpenGL, with Mesa as the OpenGL implementation using llvm for
R600 codegen.  With --default-symver Rust and Mesa will resolve their
llvm usage to the version each was linked against, which need not match.

(Other ELF platforms like BSD and Solaris might have similar semantics,
I've not checked.)

This is based on an autoconf version of this patch by Adam Jackson.

This new option can be used to add --default-symver to the linker flags
for libLLVM.so.

Reviewers: beanz

Reviewed By: beanz

Subscribers: mgorny, llvm-commits

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

llvm-svn: 302026

7 years agoCMake: Move sphinx detection into AddSphinxTarget.cmake
Tom Stellard [Wed, 3 May 2017 14:29:56 +0000 (14:29 +0000)]
CMake: Move sphinx detection into AddSphinxTarget.cmake

Reviewers: chandlerc, beanz, mgorny

Reviewed By: beanz

Subscribers: llvm-commits

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

llvm-svn: 302025

7 years agoReusing an existing attribute diagnostic
Oren Ben Simhon [Wed, 3 May 2017 14:05:00 +0000 (14:05 +0000)]
Reusing an existing attribute diagnostic

In a previous patch, a new generic error diagnostic for inconsistent attributes was added.
In this commit I reuse this diagnostic for ns_returns_retained attribute check.

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

llvm-svn: 302024

7 years ago[X86][AVX512] remove unnecessary case. NFC
Guy Blank [Wed, 3 May 2017 13:34:05 +0000 (13:34 +0000)]
[X86][AVX512] remove unnecessary case. NFC

VFPCLASS is for vector types and not scalar, so it cannot get here.

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

llvm-svn: 302023

7 years ago[SystemZ] Properly check number of operands in getCmpOpsType()
Jonas Paulsson [Wed, 3 May 2017 13:33:45 +0000 (13:33 +0000)]
[SystemZ]  Properly check number of operands in getCmpOpsType()

It is needed to check that the number of operands are 2 when
finding the case of a logic combination, e.g. 'and' of two compares.

Review: Ulrich Weigand
llvm-svn: 302022

7 years ago[CUDA Managed Memory] Fix regression introduced by Managed Memory
Siddharth Bhat [Wed, 3 May 2017 13:15:27 +0000 (13:15 +0000)]
[CUDA Managed Memory] Fix regression introduced by Managed Memory

- Fixes breakage from commit 5536f.
- Interference with commit 764f3 caused testcase to fail. Reverting
  764f3 allows commit 5536f to succeed.
- Generated kernel code was slightly different due to 764f3, which
  caused testcase to fail.

llvm-svn: 302021

7 years ago[X86] Support of no_caller_saved_registers attribute
Oren Ben Simhon [Wed, 3 May 2017 13:07:19 +0000 (13:07 +0000)]
[X86] Support of no_caller_saved_registers attribute

This patch implements the LLVM part for no_caller_saved_registers attribute as appears here: https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=5ed3cc7b66af4758f7849ed6f65f4365be8223be.
In order to implement the attribute, we use the dynamic CSR mechanism to remove returned/passed arguments from the function regmask/CSR list.

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

llvm-svn: 302020

7 years agoSupport arbitrary address space pointers in masked gather/scatter intrinsics.
Elad Cohen [Wed, 3 May 2017 12:28:54 +0000 (12:28 +0000)]
Support arbitrary address space pointers in masked gather/scatter intrinsics.

Fixes PR31789 - When loop-vectorize tries to use these intrinsics for a
non-default address space pointer we fail with a "Calling a function with a
bad singature!" assertion. This patch solves this by adding the 'vector of
pointers' argument as an overloaded type which will determine the address
space.

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

llvm-svn: 302018

7 years ago[AVR] Reserve the Y register in all functions
Dylan McKay [Wed, 3 May 2017 11:56:01 +0000 (11:56 +0000)]
[AVR] Reserve the Y register in all functions

llvm-svn: 302017

7 years ago[analyzer] Fix memory error bug category capitalization.
Artem Dergachev [Wed, 3 May 2017 11:47:13 +0000 (11:47 +0000)]
[analyzer] Fix memory error bug category capitalization.

It was written as "Memory Error" in most places and as "Memory error" in a few
other places, however it is the latter that is more consistent with
other categories (such as "Logic error").

rdar://problem/31718115

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

llvm-svn: 302016

7 years ago[Loop Deletion] Delete loops that are never executed
Anna Thomas [Wed, 3 May 2017 11:47:11 +0000 (11:47 +0000)]
[Loop Deletion] Delete loops that are never executed

Summary:
Currently, loop deletion deletes loop where the only values
that are used outside the loop are loop-invariant.
This patch adds logic to delete loops where the loop is proven to be
never executed (i.e. the only predecessor of the loop preheader has a
constant conditional branch as terminator, and the preheader is not the
taken target). This will remove loops that become dead after
loop-unswitching generates constant conditional branches.

The next steps are:
1. moving the loop deletion implementation to LoopUtils.
2. Add logic in loop-simplifyCFG which will support changing conditional
constant branches to unconditional branches. If loops become unreachable in this
process, they can be removed using `deleteDeadLoop` function.

Reviewers: chandlerc, efriedma, sanjoy, reames

Reviewed by: sanjoy

Subscribers: mzolotukhin, llvm-commits

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

llvm-svn: 302015

7 years agoRevert "[AVR] Enable the frame pointer for all functions"
Dylan McKay [Wed, 3 May 2017 11:36:42 +0000 (11:36 +0000)]
Revert "[AVR] Enable the frame pointer for all functions"

This reverts commit 358ad02d999e88853d2cfc954bd2f668308a51f7.

llvm-svn: 302014

7 years agoWindows fix for TestConflictingDefinition makefile
Pavel Labath [Wed, 3 May 2017 11:27:35 +0000 (11:27 +0000)]
Windows fix for TestConflictingDefinition makefile

gnuwin32 rm does not like wildcards that match nothing even if we
specify -f (probably because the wildcard expansion happens in-process
there). We could use make $(wildcard) here, but it seems safer to
explicitly list the files here, just like the normal Makefile.rules
does.

llvm-svn: 302013

7 years agoUndo turning ExtBehavior into a bitfield.
Daniel Jasper [Wed, 3 May 2017 11:27:34 +0000 (11:27 +0000)]
Undo turning ExtBehavior into a bitfield.

This produces warnings that I can't explain in a GCC build:

In file included from ../tools/clang/include/clang/Lex/LexDiagnostic.h:13:0,
                 from /usr/local/google/home/djasper/llvm/tools/clang/lib/Lex/PTHLexer.cpp:19:
../tools/clang/include/clang/Basic/Diagnostic.h:219:34: warning: ‘clang::DiagnosticsEngine::DiagState::ExtBehavior’ is too small to hold all values of ‘enum class clang::diag::Severity’ [enabled by default]
     diag::Severity ExtBehavior : 4;     // Map extensions to warnings or errors?
                                  ^

While I don't think this warning makes sense, I'd like to get this back to being
warning-free. This only seems to trigger for "enum class".

Reproducer:
https://godbolt.org/g/P2ekVd

llvm-svn: 302012

7 years ago[Triple] Add a "macos" OS type that acts as a synonym for "macosx"
Alex Lorenz [Wed, 3 May 2017 10:42:35 +0000 (10:42 +0000)]
[Triple] Add a "macos" OS type that acts as a synonym for "macosx"

The "macosx" OS type is still the canonical type. In the future "macos" will
become the canonical OS type (but we will still support "macosx").

rdar://27043820

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

llvm-svn: 302011

7 years ago[X86] Refactored LowerINTRINSIC_W_CHAIN to use a switch statament. NFCI.
Simon Pilgrim [Wed, 3 May 2017 10:40:18 +0000 (10:40 +0000)]
[X86] Refactored LowerINTRINSIC_W_CHAIN to use a switch statament. NFCI.

Pre-commit as requested in D32769.

llvm-svn: 302010

7 years agoFix tests after speculatable intrinsics patch
Daniel Jasper [Wed, 3 May 2017 10:04:25 +0000 (10:04 +0000)]
Fix tests after speculatable intrinsics patch

These were relying on the attribute group numbering

llvm-svn: 302009

7 years agoCheck for lack of C++ context first when demangling
Pavel Labath [Wed, 3 May 2017 10:00:00 +0000 (10:00 +0000)]
Check for lack of C++ context first when demangling

Summary: It seems that if we have no context, then it can't possibly be a method.  Check that first.

Reviewers: clayborg

Reviewed By: clayborg

Subscribers: labath, lldb-commits

Differential Revision: https://reviews.llvm.org/D32708
Patch by Scott Smith <scott.smith@purestorage.com>.

llvm-svn: 302008

7 years ago[ELF] Fix problems with fabricateDefaultCommands() and --section-start
Peter Smith [Wed, 3 May 2017 08:44:50 +0000 (08:44 +0000)]
[ELF] Fix problems with fabricateDefaultCommands() and --section-start

The --section-start <name>=<address> needs to be translated into equivalent
linker script commands. There are a couple of problems with the existing
implementation:
- The --section-start with the lowest address is assumed to be at the start
of the map. This assumption is incorrect, we have to iterate through the
SectionStartMap to find the lowest address.
- The addresses in --section-start were being over-aligned when the
sections were marked as PageAlign. This is inconsistent with the use of
SectionStartMap in fixHeaders(), and can cause problems when the PageAlign
causes an "unable to move location counter backward" error when the
--section-start with PageAlign is aligned to an address higher than the next
--section-start. The ld.bfd and ld.gold seem to be more consistent with this
approach but this is not a well specified area.

This change fixes the problems above and also corrects a typo in which
fabricateDefaultCommands() is called with the wrong parameter, it should be
called with AllocateHeader not Config->MaxPageSize.

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

llvm-svn: 302007

7 years ago[ELF] - Added testcase gdb-index-ranges.s (https://reviews.llvm.org/D32750)
George Rimar [Wed, 3 May 2017 08:21:42 +0000 (08:21 +0000)]
[ELF] - Added testcase gdb-index-ranges.s (https://reviews.llvm.org/D32750)

Before rL301170 was landed, LLD did not produce correct entries in .gdb_index address area.
Issue was fixed on LLVM DWARF parsers side and was relative to how .debug_ranges
section was scanned. It was main problem of PR32319.

It makes sense to have testcase on LLD size too. This checks that we generate proper values
now, because we do not have any tests for .gdb_index which works with .debug_ranges atm.

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

llvm-svn: 302006

7 years ago[ScopInfo] Remove code not needed anymore after r302004
Tobias Grosser [Wed, 3 May 2017 08:02:32 +0000 (08:02 +0000)]
[ScopInfo] Remove code not needed anymore after r302004

llvm-svn: 302005

7 years ago[ScopInfo] Do not add array name into memory reference ids
Tobias Grosser [Wed, 3 May 2017 07:57:35 +0000 (07:57 +0000)]
[ScopInfo] Do not add array name into memory reference ids

Before this change a memory reference identifier had the form:

  <STMT>_<ACCESSTYPE><ID>_<MEMREF>, e.g., Stmt_bb9_Write0_MemRef_tmp11

After this change, we use the format:

  <STMT>_<ACCESSTYPE><ID>, e.g., Stmt_bb9_Write0

The name of the array that is accessed through a memory reference is not
necessary to uniquely identify a memory reference, but was only added to
provide additional information for debugging. We drop this information now
for the following two reasons:

  1) This shortens the names and consequently improves readability
  2) This removes a second location where we decide on the name of a scop array,
     leaving us only with the location where the actual scop array is created.

Having after 2) only a single location to name scop arrays will allow us to
change the naming convention of scop arrays more easily, which we will do
in a future commit to reduce compilation time.

llvm-svn: 302004

7 years agoSilences gcc's -Wnarrowing.
Daniel Jasper [Wed, 3 May 2017 07:48:27 +0000 (07:48 +0000)]
Silences gcc's -Wnarrowing.

I think this is a false positive in GCC's warning, but nonetheless, we
should try to be warning-free. Smaller reproducer (reproduces with GCC
6.3):
https://godbolt.org/g/cJuO2z

llvm-svn: 302003

7 years agoRevert r301986 (and subsequent r301987).
Daniel Jasper [Wed, 3 May 2017 07:29:25 +0000 (07:29 +0000)]
Revert r301986 (and subsequent r301987).

The patch is failing to add StringTableStreamBuilder.h, but that isn't
even discovered because the corresponding StringTableStreamBuilder.cpp
isn't added to any CMakeLists.txt file and thus never built. I think
this patch is just incomplete.

llvm-svn: 302002

7 years ago[sanitizer] Intercept mcheck and mprobe on Linux
Maxim Ostapenko [Wed, 3 May 2017 07:09:10 +0000 (07:09 +0000)]
[sanitizer] Intercept mcheck and mprobe on Linux

This patch addresses https://github.com/google/sanitizers/issues/804.
Users can use mcheck and mprobe functions to verify heap state so we should intercept them to avoid breakage of valid code.

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

llvm-svn: 302001