platform/upstream/llvm.git
8 years ago[sanitizer] Add strchr* to the common interceptors
Evgeniy Stepanov [Mon, 21 Mar 2016 21:36:17 +0000 (21:36 +0000)]
[sanitizer] Add strchr* to the common interceptors

Adds strchr, strchrnul, and strrchr to the common interceptors, under a new
common flag intercept_strchr.

Removes the now-duplicate strchr interceptor from asan and all 3
interceptors from tsan. Previously, asan did not intercept strchrnul, but
does now; previously, msan did not intercept strchr, strchrnul, or strrchr,
but does now.

http://reviews.llvm.org/D18329

Patch by Derek Bruening!

llvm-svn: 263992

8 years ago[MemorySSA] Consider def-only BBs for live-in calculations.
George Burgess IV [Mon, 21 Mar 2016 21:25:39 +0000 (21:25 +0000)]
[MemorySSA] Consider def-only BBs for live-in calculations.

If we have a BB with only MemoryDefs, live-in calculations will ignore
it. This means we get results like this:

define void @foo(i8* %p) {
  ; 1 = MemoryDef(liveOnEntry)
  store i8 0, i8* %p
  br i1 undef, label %if.then, label %if.end

if.then:
  ; 2 = MemoryDef(1)
  store i8 1, i8* %p
  br label %if.end

if.end:
  ; 3 = MemoryDef(1)
  store i8 2, i8* %p
  ret void
}

...When there should be a MemoryPhi in the `if.end` BB.

This patch fixes that behavior.

llvm-svn: 263991

8 years agoRemove leftover options from multiline.ll
Krzysztof Parzyszek [Mon, 21 Mar 2016 21:25:01 +0000 (21:25 +0000)]
Remove leftover options from multiline.ll

I added -march=hexagon to force using Hexagon target when testing
locally, and I forgot to take it out.

llvm-svn: 263990

8 years ago[modules] Renumber DECL_UPDATES from 30 to 50, so it no longer collides with
Richard Smith [Mon, 21 Mar 2016 21:16:01 +0000 (21:16 +0000)]
[modules] Renumber DECL_UPDATES from 30 to 50, so it no longer collides with
TYPE_TEMPLATE_SPECIALIZATION. This was fine in practice because both record
kinds are only ever found by offset, but made the llvm-bcanalyzer -dump output
very confusing.

llvm-svn: 263989

8 years agoAdd a testcase that would have found the bug in r263971.
Rafael Espindola [Mon, 21 Mar 2016 21:09:38 +0000 (21:09 +0000)]
Add a testcase that would have found the bug in r263971.

llvm-svn: 263988

8 years agoRevert "[llvm-objdump] Printing relocations in executable and shared object files...
Rafael Espindola [Mon, 21 Mar 2016 20:59:15 +0000 (20:59 +0000)]
Revert "[llvm-objdump] Printing relocations in executable and shared object files.  This partially reverts r215844 by removing test objdump-reloc-shared.test which stated GNU objdump doesn't print relocations, it does."

This reverts commit r263971.
It produces the wrong results for .rela.dyn. I will add a test.

llvm-svn: 263987

8 years agoUnxfail test/DebugInfo/Generic/multiline.ll on Hexagon
Krzysztof Parzyszek [Mon, 21 Mar 2016 20:55:59 +0000 (20:55 +0000)]
Unxfail test/DebugInfo/Generic/multiline.ll on Hexagon

llvm-svn: 263986

8 years ago[sanitizier] initializing common flags.
Mike Aizatsky [Mon, 21 Mar 2016 20:53:20 +0000 (20:53 +0000)]
[sanitizier] initializing common flags.

Summary: Without SetDefaults() CommonFlags contain garbage.

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

llvm-svn: 263985

8 years agoRevert "Convert some ObjC msgSends to runtime calls."
Pete Cooper [Mon, 21 Mar 2016 20:50:03 +0000 (20:50 +0000)]
Revert "Convert some ObjC msgSends to runtime calls."

This reverts commit r263607.

This change caused more objc_retain/objc_release calls in the IR but those
are then incorrectly optimized by the ARC optimizer.  Work is going to have
to be done to ensure the ARC optimizer doesn't optimize user written RR, but
that should land before this change.

This change will also need to be updated to take account for any changes required
to ensure that user written calls to RR are distinct from those inserted by ARC.

llvm-svn: 263984

8 years agoAMDGPU: Coding style fixes
Nicolai Haehnle [Mon, 21 Mar 2016 20:39:24 +0000 (20:39 +0000)]
AMDGPU: Coding style fixes

I meant to add these before committing r263982 as per the review,
but I forgot to squash.

llvm-svn: 263983

8 years agoAMDGPU: Add SIWholeQuadMode pass
Nicolai Haehnle [Mon, 21 Mar 2016 20:28:33 +0000 (20:28 +0000)]
AMDGPU: Add SIWholeQuadMode pass

Summary:
Whole quad mode is already enabled for pixel shaders that compute
derivatives, but it must be suspended for instructions that cause a
shader to have side effects (i.e. stores and atomics).

This pass addresses the issue by storing the real (initial) live mask
in a register, masking EXEC before instructions that require exact
execution and (re-)enabling WQM where required.

This pass is run before register coalescing so that we can use
machine SSA for analysis.

The changes in this patch expose a problem with the second machine
scheduling pass: target independent instructions like COPY implicitly
use EXEC when they operate on VGPRs, but this fact is not encoded in
the MIR. This can lead to miscompilation because instructions are
moved past changes to EXEC.

This patch fixes the problem by adding use-implicit operands to
target independent instructions. Some general codegen passes are
relaxed to work with such implicit use operands.

Reviewers: arsenm, tstellarAMD, mareko

Subscribers: MatzeB, arsenm, llvm-commits

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

llvm-svn: 263982

8 years ago[Hexagon] Add handling fixups and instruction relaxation
Krzysztof Parzyszek [Mon, 21 Mar 2016 20:27:17 +0000 (20:27 +0000)]
[Hexagon] Add handling fixups and instruction relaxation

llvm-svn: 263981

8 years ago[Hexagon] Properly encode registers in duplex instructions
Krzysztof Parzyszek [Mon, 21 Mar 2016 20:13:33 +0000 (20:13 +0000)]
[Hexagon] Properly encode registers in duplex instructions

llvm-svn: 263980

8 years ago[asan] Disable thread-safe static initilization with VS 2015
Reid Kleckner [Mon, 21 Mar 2016 20:08:59 +0000 (20:08 +0000)]
[asan] Disable thread-safe static initilization with VS 2015

ASan interceptors contain local statics which run before the CRT is
initialized. Thread-safe statics appear to rely on CRT-internal state,
and will crash without this flag.

llvm-svn: 263979

8 years ago[Hexagon] Fix reserving emergency spill slots for register scavenger
Krzysztof Parzyszek [Mon, 21 Mar 2016 19:57:08 +0000 (19:57 +0000)]
[Hexagon] Fix reserving emergency spill slots for register scavenger

- R10 and R11 are not reserved registers.
- Check for reserved registers when finding unused caller-saved registers.

llvm-svn: 263977

8 years ago[WebAssembly] Implement the eqz instructions.
Dan Gohman [Mon, 21 Mar 2016 19:54:41 +0000 (19:54 +0000)]
[WebAssembly] Implement the eqz instructions.

llvm-svn: 263976

8 years ago[SLP] Remove unnecessary member variables by using container APIs.
Chad Rosier [Mon, 21 Mar 2016 19:47:44 +0000 (19:47 +0000)]
[SLP] Remove unnecessary member variables by using container APIs.

This changes the debug output, but still retains its usefulness.
Differential Revision: http://reviews.llvm.org/D18324

llvm-svn: 263975

8 years agoclang-cl: With -fmsc-version=1900, use MSVS2015 diag formatting.
Nico Weber [Mon, 21 Mar 2016 19:44:18 +0000 (19:44 +0000)]
clang-cl: With -fmsc-version=1900, use MSVS2015 diag formatting.

llvm-svn: 263974

8 years ago[asan] Pass -fms-compatibility-version=19 with VS 2015
Reid Kleckner [Mon, 21 Mar 2016 19:37:30 +0000 (19:37 +0000)]
[asan] Pass -fms-compatibility-version=19 with VS 2015

This resolves errors about char16_t and char32_t when compiling 2015 STL
headers with clang.

llvm-svn: 263973

8 years agoCompilation can end up calling functions (e.g. to resolve indirect functions) so...
Jim Ingham [Mon, 21 Mar 2016 19:21:13 +0000 (19:21 +0000)]
Compilation can end up calling functions (e.g. to resolve indirect functions) so I added
a way for compilation to take a "thread to use for compilation".  If it isn't set then the
compilation will use the currently selected thread.  This should help keep function execution
to the one thread intended.

llvm-svn: 263972

8 years ago[llvm-objdump] Printing relocations in executable and shared object files. This...
Colin LeMahieu [Mon, 21 Mar 2016 19:14:50 +0000 (19:14 +0000)]
[llvm-objdump] Printing relocations in executable and shared object files.  This partially reverts r215844 by removing test objdump-reloc-shared.test which stated GNU objdump doesn't print relocations, it does.

In executable and shared object ELF files, relocations in the file contain the final virtual address rather than section offset so this is adjusted to display section offset.

Differential revision: http://reviews.llvm.org/D15965

llvm-svn: 263971

8 years ago[modules] Don't invent a module cache path unless implicit module builds are enabled.
Richard Smith [Mon, 21 Mar 2016 19:06:06 +0000 (19:06 +0000)]
[modules] Don't invent a module cache path unless implicit module builds are enabled.

llvm-svn: 263970

8 years agoAMDGPU/SI: Fix threshold calculation for branching when exec is zero
Tom Stellard [Mon, 21 Mar 2016 18:56:58 +0000 (18:56 +0000)]
AMDGPU/SI: Fix threshold calculation for branching when exec is zero

Summary:
When control flow is implemented using the exec mask, the compiler will
insert branch instructions to skip over the masked section when exec is
zero if the section contains more than a certain number of instructions.

The previous code would only count instructions in successor blocks,
and this patch modifies the code to start counting instructions in all
blocks between the start and end of the branch.

Reviewers: nhaehnle, arsenm

Subscribers: arsenm, llvm-commits

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

llvm-svn: 263969

8 years agoFix Clang-tidy modernize-deprecated-headers warnings; other minor fixes.
Eugene Zelenko [Mon, 21 Mar 2016 18:32:35 +0000 (18:32 +0000)]
Fix Clang-tidy modernize-deprecated-headers warnings; other minor fixes.

Differential revision: http://reviews.llvm.org/D18232

llvm-svn: 263968

8 years ago[STATS] Add OMP_critical and OMP_critical_wait timers
Jonathan Peyton [Mon, 21 Mar 2016 18:32:26 +0000 (18:32 +0000)]
[STATS] Add OMP_critical and OMP_critical_wait timers

OMP_critical - time spent in critical section
OMP_critical_wait - time spent waiting to enter a critical section

llvm-svn: 263967

8 years ago[asan] Update hotpatch code for VS 2015 memset implementation
Reid Kleckner [Mon, 21 Mar 2016 18:23:07 +0000 (18:23 +0000)]
[asan] Update hotpatch code for VS 2015 memset implementation

In VS 2015, the memset fill parameter is zero extended from one byte
instead of being copied wholesale.

The issue reproduces with existing tests if you use VS2015.

llvm-svn: 263966

8 years ago[AArch64] Add a helpful assert. NFC.
Chad Rosier [Mon, 21 Mar 2016 18:04:10 +0000 (18:04 +0000)]
[AArch64] Add a helpful assert. NFC.

llvm-svn: 263965

8 years agoAMDGPU: Remove SignBitIsZero for mubuf scratch offsets
Matt Arsenault [Mon, 21 Mar 2016 18:02:18 +0000 (18:02 +0000)]
AMDGPU: Remove SignBitIsZero for mubuf scratch offsets

These instructions do not have the same negative base
address problem that DS instructions do on SI.

llvm-svn: 263964

8 years ago[clang-tidy] Fix check broken in rL263822.
Samuel Benzaquen [Mon, 21 Mar 2016 18:00:43 +0000 (18:00 +0000)]
[clang-tidy] Fix check broken in rL263822.

Add names missing from rL263822 and add tests to prevent future omissions.

llvm-svn: 263963

8 years agoARM: Better codegen for 64-bit compares.
Peter Collingbourne [Mon, 21 Mar 2016 18:00:02 +0000 (18:00 +0000)]
ARM: Better codegen for 64-bit compares.

This introduces a custom lowering for ISD::SETCCE (introduced in r253572)
that allows us to emit a short code sequence for 64-bit compares.

Before:

push {r7, lr}
cmp r0, r2
mov.w r0, #0
mov.w r12, #0
it hs
movhs r0, #1
cmp r1, r3
it ge
movge.w r12, #1
it eq
moveq r12, r0
cmp.w r12, #0
bne .LBB1_2
@ BB#1:                                 @ %bb1
bl f
pop {r7, pc}
.LBB1_2:                                @ %bb2
bl g
pop {r7, pc}

After:

push {r7, lr}
subs r0, r0, r2
sbcs.w r0, r1, r3
bge .LBB1_2
@ BB#1:                                 @ %bb1
bl f
pop {r7, pc}
.LBB1_2:                                @ %bb2
bl g
pop {r7, pc}

Saves around 80KB in Chromium's libchrome.so.

Some notes on this patch:

- I don't much like the ARMISD::BRCOND and ARMISD::CMOV combines I
  introduced (nothing else needs them). However, they are necessary in
  order to avoid poor codegen, and they seem similar to existing combines
  in other backends (e.g. X86 combines (brcond (cmp (setcc Compare))) to
  (brcond Compare)).

- No support for Thumb-1. This is in principle possible, but we'd need
  to implement ARMISD::SUBE for Thumb-1.

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

llvm-svn: 263962

8 years agoclang-format: [JS] no space in union and intersection types.
Daniel Jasper [Mon, 21 Mar 2016 17:57:31 +0000 (17:57 +0000)]
clang-format: [JS] no space in union and intersection types.

The operators | and & in types, as opposed to the bitwise operators,
should not have whitespace around them (e.g. `Foo<Bar|Baz>`).

Patch by Martin Probst. Thank you.

llvm-svn: 263961

8 years agoAdd replacement = "xxx" to AvailabilityAttr.
Manman Ren [Mon, 21 Mar 2016 17:30:55 +0000 (17:30 +0000)]
Add replacement = "xxx" to AvailabilityAttr.

This commit adds a named argument to AvailabilityAttr, while r263652 adds an
optional string argument to __attribute__((deprecated)).

This was commited in r263687 and reverted in 263752 due to misaligned
access.

rdar://20588929

llvm-svn: 263958

8 years ago[ARM] Clang tests for ARM Cortex-A32 support
Renato Golin [Mon, 21 Mar 2016 17:29:51 +0000 (17:29 +0000)]
[ARM] Clang tests for ARM Cortex-A32 support

Patch by Sam Parker.

llvm-svn: 263957

8 years ago[ARM] Add Cortex-A32 support
Renato Golin [Mon, 21 Mar 2016 17:29:01 +0000 (17:29 +0000)]
[ARM] Add Cortex-A32 support

Adding Cortex-A32 as an available target in the ARM backend.

Patch by Sam Parker.

llvm-svn: 263956

8 years agoNFC: wrap Availability-related data in its own struct in AttributeList.
Manman Ren [Mon, 21 Mar 2016 17:26:40 +0000 (17:26 +0000)]
NFC: wrap Availability-related data in its own struct in AttributeList.

This makes it easy to add more data into Availability.

llvm-svn: 263955

8 years ago[STATS] separate noTotal bit flag from onlyInMaster and noUnits
Jonathan Peyton [Mon, 21 Mar 2016 17:26:23 +0000 (17:26 +0000)]
[STATS] separate noTotal bit flag from onlyInMaster and noUnits

This change logically separates the stats_flags_e::noTotal bit flag from the
stats_flags_e::onlyInMaster and stats_flags_e::noUnits bit flags. If no
TOTAL_foo output is wanted for a particular statistic, the flag must be
explicitly included in that statistic's flags.

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

llvm-svn: 263954

8 years agoclang-cl: Move /FC from "Unsupported" to "Ignored" list.
Nico Weber [Mon, 21 Mar 2016 17:19:31 +0000 (17:19 +0000)]
clang-cl: Move /FC from "Unsupported" to "Ignored" list.

/FC affects if diagnostics print with full paths and if __FILE__ expands with a
full path.  clang-cl does both of these two by default.

llvm-svn: 263953

8 years ago[llvm-readobj] Impl GNU style symbols printing
Hemant Kulkarni [Mon, 21 Mar 2016 17:18:23 +0000 (17:18 +0000)]
[llvm-readobj] Impl GNU style symbols printing

Implements "readelf -sW and readelf -DsW"

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

llvm-svn: 263952

8 years ago[Orc] Switch RPC Procedure to take a function type, rather than an arg list.
Lang Hames [Mon, 21 Mar 2016 16:56:25 +0000 (16:56 +0000)]
[Orc] Switch RPC Procedure to take a function type, rather than an arg list.

No functional change, just a little more readable.

llvm-svn: 263951

8 years agoAPFloat: Add frexp
Matt Arsenault [Mon, 21 Mar 2016 16:49:16 +0000 (16:49 +0000)]
APFloat: Add frexp

llvm-svn: 263950

8 years agoAMDGPU: Add frexp_mant intrinsic
Matt Arsenault [Mon, 21 Mar 2016 16:11:05 +0000 (16:11 +0000)]
AMDGPU: Add frexp_mant intrinsic

llvm-svn: 263948

8 years agoclang-cl: support __cdecl-on-struct anachronism
Reid Kleckner [Mon, 21 Mar 2016 16:08:49 +0000 (16:08 +0000)]
clang-cl: support __cdecl-on-struct anachronism

Summary:
The Microsoft compiler emits

  warning C4229: anachronism used : modifiers on data are ignored

for

  struct {} __cdecl s;

but ICU's gendict can generate such (and does when building
LibreOffice), so accepting this in clang-cl too would be useful.

Reviewers: rnk

Patch by Stephan Bergmann

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

llvm-svn: 263947

8 years ago[tsan] Adding a test case for r263939 ("Add some NULL pointer checks into the debuggi...
Kuba Brecka [Mon, 21 Mar 2016 16:05:42 +0000 (16:05 +0000)]
[tsan] Adding a test case for r263939 ("Add some NULL pointer checks into the debugging API")

llvm-svn: 263946

8 years agoImplement constant folding for bitreverse
Matt Arsenault [Mon, 21 Mar 2016 15:00:35 +0000 (15:00 +0000)]
Implement constant folding for bitreverse

llvm-svn: 263945

8 years agoRevert "[ELF] SHF_MERGE section with 0 entsize is not fatal"
Rafael Espindola [Mon, 21 Mar 2016 14:57:20 +0000 (14:57 +0000)]
Revert "[ELF] SHF_MERGE section with 0 entsize is not fatal"

This reverts commit r263664.

The reason we were getting broken files was lld -r, and that has been
fixed.

llvm-svn: 263944

8 years agoclang-format: Make include sorting's main include detection configurable.
Daniel Jasper [Mon, 21 Mar 2016 14:11:27 +0000 (14:11 +0000)]
clang-format: Make include sorting's main include detection configurable.

This patch adds a regular expression to configure suffixes of an
included file to check whether it is the "main" include of the current
file. Previously, clang-format has allowed arbitrary suffixes on the
formatted file, which is still the case when no IncludeMainRegex is
specified.

llvm-svn: 263943

8 years ago[AArch64] Fix a -Wdocumentation warning. NFC.
Chad Rosier [Mon, 21 Mar 2016 13:43:58 +0000 (13:43 +0000)]
[AArch64] Fix a -Wdocumentation warning. NFC.

llvm-svn: 263942

8 years ago[IndVars] Fix PR26974: make sure replaceCongruentIVs doesn't break LCSSA
Silviu Baranga [Mon, 21 Mar 2016 12:44:29 +0000 (12:44 +0000)]
[IndVars] Fix PR26974: make sure replaceCongruentIVs doesn't break LCSSA

Summary:
replaceCongruentIVs can break LCSSA when trying to replace IV increments
since it tries to replace all uses of a phi node with another phi node
while both of the phi nodes are not necessarily in the processed loop.
This will cause an assert in IndVars.

To fix this, we add a check to make sure that the replacement maintains
LCSSA.

Reviewers: sanjoy

Subscribers: mzolotukhin, llvm-commits

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

llvm-svn: 263941

8 years ago[OMPT] Fix wrong parent_task_id in serialized parallel_begin with GCC
Jonas Hahnfeld [Mon, 21 Mar 2016 12:37:52 +0000 (12:37 +0000)]
[OMPT] Fix wrong parent_task_id in serialized parallel_begin with GCC

Without this patch a simple '#pragma omp parallel num_threads(1)' leads to
ompt_event_parallel_begin: parent_task_id=3, [...], parallel_id=2, [...]
ompt_event_parallel_end: parallel_id=2, task_id=4, [...]

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

llvm-svn: 263940

8 years ago[tsan] Add some NULL pointer checks into the debugging API
Kuba Brecka [Mon, 21 Mar 2016 12:12:44 +0000 (12:12 +0000)]
[tsan] Add some NULL pointer checks into the debugging API

`__tsan_get_report_thread` and others can crash if a stack trace is missing, let's add the missing checks.

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

llvm-svn: 263939

8 years agoRemove debug output. Sorry for the noise.
NAKAMURA Takumi [Mon, 21 Mar 2016 11:44:05 +0000 (11:44 +0000)]
Remove debug output. Sorry for the noise.

llvm-svn: 263936

8 years ago[DAGCombine] Catch the case where extract_vector_elt can cause an any_ext while proce...
Silviu Baranga [Mon, 21 Mar 2016 11:43:46 +0000 (11:43 +0000)]
[DAGCombine] Catch the case where extract_vector_elt can cause an any_ext while processing AND SDNodes

Summary:
extract_vector_elt can cause an implicit any_ext if the types don't
match. When processing the following pattern:

  (and (extract_vector_elt (load ([non_ext|any_ext|zero_ext] V))), c)

DAGCombine was ignoring the possible extend, and sometimes removing
the AND even though it was required to maintain some of the bits
in the result to 0, resulting in a miscompile.

This change fixes the issue by limiting the transformation only to
cases where the extract_vector_elt doesn't perform the implicit
extend.

Reviewers: t.p.northover, jmolloy

Subscribers: llvm-commits

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

llvm-svn: 263935

8 years agoclang/test/CodeGenCXX/cxx1z-lambda-star-this.cpp: Satisfy -Asserts.
NAKAMURA Takumi [Mon, 21 Mar 2016 11:40:15 +0000 (11:40 +0000)]
clang/test/CodeGenCXX/cxx1z-lambda-star-this.cpp: Satisfy -Asserts.

llvm-svn: 263934

8 years agoEliminated trailing whitespaces from test. NFC.
George Rimar [Mon, 21 Mar 2016 11:23:53 +0000 (11:23 +0000)]
Eliminated trailing whitespaces from test. NFC.

llvm-svn: 263933

8 years agoFixed -mcpu flag
Elena Demikhovsky [Mon, 21 Mar 2016 11:06:20 +0000 (11:06 +0000)]
Fixed -mcpu flag
"core-avx" does not exist; I changed to "nehalem"

llvm-svn: 263932

8 years agoclang/test/Frontend/plugin-annotate-functions.c requires the target examples/Annotate...
NAKAMURA Takumi [Mon, 21 Mar 2016 11:03:39 +0000 (11:03 +0000)]
clang/test/Frontend/plugin-annotate-functions.c requires the target examples/AnnotateFunctions.

llvm-svn: 263931

8 years agoReorder data members to be consistent with member initializers, to silence warnings.
Faisal Vali [Mon, 21 Mar 2016 10:37:42 +0000 (10:37 +0000)]
Reorder data members to be consistent with member initializers, to silence warnings.

llvm-svn: 263922

8 years ago[Cxx1z] Implement Lambda Capture of *this by Value as [=,*this] (P0018R3)
Faisal Vali [Mon, 21 Mar 2016 09:25:37 +0000 (09:25 +0000)]
[Cxx1z] Implement Lambda Capture of *this by Value as [=,*this] (P0018R3)

Implement lambda capture of *this by copy.
For e.g.:
struct A {

  int d = 10;
  auto foo() { return [*this] (auto a) mutable { d+=a; return d; }; }

};

auto L = A{}.foo(); // A{}'s lifetime is gone.

// Below is still ok, because *this was captured by value.
assert(L(10) == 20);
assert(L(100) == 120);

If the capture was implicit, or [this] (i.e. *this was captured by reference), this code would be otherwise undefined.

Implementation Strategy:
  - amend the parser to accept *this in the lambda introducer
  - add a new king of capture LCK_StarThis
  - teach Sema::CheckCXXThisCapture to handle by copy captures of the
    enclosing object (i.e. *this)
  - when CheckCXXThisCapture does capture by copy, the corresponding
    initializer expression for the closure's data member
    direct-initializes it thus making a copy of '*this'.
  - in codegen, when assigning to CXXThisValue, if *this was captured by
    copy, make sure it points to the corresponding field member, and
    not, unlike when captured by reference, what the field member points
    to.
  - mark feature as implemented in svn

Much gratitude to Richard Smith for his carefully illuminating reviews!

llvm-svn: 263921

8 years agoclang-cl: Add a comment about /Oy- (see r245913).
Nico Weber [Mon, 21 Mar 2016 02:48:05 +0000 (02:48 +0000)]
clang-cl: Add a comment about /Oy- (see r245913).

llvm-svn: 263920

8 years ago[COFF] Don't call memcpy with a NULL argument
David Majnemer [Sun, 20 Mar 2016 23:10:12 +0000 (23:10 +0000)]
[COFF] Don't call memcpy with a NULL argument

Some declarations of memcpy (like glibc's for example) are attributed
with notnull which makes it UB for NULL to get passed in, even if the
memcpy count is zero.

To account for this, guard the memcpy with an appropriate precondition.

This should fix the last UBSan bug, exposed by the test suite, in the
COFF linker.

llvm-svn: 263919

8 years ago[COFF] Remove undefined behavior from ObjectFile::createWeakExternal
David Majnemer [Sun, 20 Mar 2016 22:56:31 +0000 (22:56 +0000)]
[COFF] Remove undefined behavior from ObjectFile::createWeakExternal

LLD type-punned an integral type and a pointer type using a pointer
field.  This is problematic because the pointer type has alignment
greater than some of the integral values.

This would be less problematic if a union was used but it turns out the
integral values are only present for a short, transient, amount of time.

Let's remove this undefined behavior by skipping the punning altogether
by storing the state in a separate memory location: a vector which
informs us which symbols to process for weak externs.

llvm-svn: 263918

8 years ago[X86][SSE] Add vector integer division by constant tests
Simon Pilgrim [Sun, 20 Mar 2016 21:46:58 +0000 (21:46 +0000)]
[X86][SSE] Add vector integer division by constant tests

Expanded tests and split into sdiv/srem and udiv/urem cases for 128 and 256 bit vectors.

llvm-svn: 263917

8 years ago[NVPTX] Adds a new address space inference pass.
Jingyue Wu [Sun, 20 Mar 2016 20:59:20 +0000 (20:59 +0000)]
[NVPTX] Adds a new address space inference pass.

Summary:
The old address space inference pass (NVPTXFavorNonGenericAddrSpaces) is unable
to convert the address space of a pointer induction variable. This patch adds a
new pass called NVPTXInferAddressSpaces that overcomes that limitation using a
fixed-point data-flow analysis (see the file header comments for details).

The new pass is experimental and not enabled by default. Users can turn
it on by setting the -nvptx-use-infer-addrspace flag of llc.

Reviewers: jholewinski, tra, jlebar

Subscribers: jholewinski, llvm-commits

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

llvm-svn: 263916

8 years agoVisual Studio Visualizers for clang::FunctionDecl
Mike Spertus [Sun, 20 Mar 2016 20:15:23 +0000 (20:15 +0000)]
Visual Studio Visualizers for clang::FunctionDecl

Readably displays a FunctionDecl in the Visual Studio Locals Window something like:
  void g(int, double d, struct A && arr)

llvm-svn: 263915

8 years ago[gold] Emit a diagnostic in case we fail to remove a file.
Davide Italiano [Sun, 20 Mar 2016 20:12:33 +0000 (20:12 +0000)]
[gold] Emit a diagnostic in case we fail to remove a file.

llvm-svn: 263914

8 years ago[tsan] Allow -fsanitize=thread for iOS-style simulator targets
Devin Coughlin [Sun, 20 Mar 2016 18:24:33 +0000 (18:24 +0000)]
[tsan] Allow -fsanitize=thread for iOS-style simulator targets

Update the clang driver to allow -fsanitize=thread when targeting x86_64 iOS and tvOS
simulators. Also restrict TSan targeting OS X to only be supported on x86_64 and not i386.

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

llvm-svn: 263913

8 years ago[VFS] Fix test to use more restrict set of headers
Bruno Cardoso Lopes [Sun, 20 Mar 2016 18:08:32 +0000 (18:08 +0000)]
[VFS] Fix test to use more restrict set of headers

llvm-svn: 263912

8 years ago[X86][SSE] Tidyup setTargetShuffleZeroElements to match computeZeroableShuffleElements
Simon Pilgrim [Sun, 20 Mar 2016 17:43:07 +0000 (17:43 +0000)]
[X86][SSE] Tidyup setTargetShuffleZeroElements to match computeZeroableShuffleElements

Based on feedback for D14261

llvm-svn: 263911

8 years ago[tsan] Build TSan dylibs for iOS-style simulators
Devin Coughlin [Sun, 20 Mar 2016 17:35:45 +0000 (17:35 +0000)]
[tsan] Build TSan dylibs for iOS-style simulators

Update the compiler-rt cmake to build TSan dylibs for iOS-style simulators when the
corresponding COMPILER_RT_ENABLE_FOO_OS setting is enabled.

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

Part of rdar://problem/24048382

llvm-svn: 263910

8 years agoAST: Fix some bogus indentation. NFC
Justin Bogner [Sun, 20 Mar 2016 16:58:03 +0000 (16:58 +0000)]
AST: Fix some bogus indentation. NFC

Noticed by Liu Xin. Thanks!

llvm-svn: 263909

8 years agoFixed -Wdocumentation warning
Simon Pilgrim [Sun, 20 Mar 2016 16:25:23 +0000 (16:25 +0000)]
Fixed -Wdocumentation warning

llvm-svn: 263908

8 years ago[X86][SSE] Detect zeroable shuffle elements from different value types
Simon Pilgrim [Sun, 20 Mar 2016 15:45:42 +0000 (15:45 +0000)]
[X86][SSE] Detect zeroable shuffle elements from different value types

Improve computeZeroableShuffleElements to be able to peek through bitcasts to extract zero/undef values from BUILD_VECTOR nodes of different element sizes to the shuffle mask.

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

llvm-svn: 263906

8 years ago[clang-tidy] Update check for API change in r263895.
Benjamin Kramer [Sun, 20 Mar 2016 14:24:49 +0000 (14:24 +0000)]
[clang-tidy] Update check for API change in r263895.

for range stmts now have split begin and ends, just apply OR to the
condition. Should unbreak the build.

llvm-svn: 263900

8 years agoAttempt to fix MSVC build (no __attribute__ there)
Pavel Labath [Sun, 20 Mar 2016 13:37:55 +0000 (13:37 +0000)]
Attempt to fix MSVC build (no __attribute__ there)

llvm-svn: 263899

8 years agoAVX512BW: Enable v32i1/v64i1 BUILD_VECTOR
Igor Breger [Sun, 20 Mar 2016 13:09:43 +0000 (13:09 +0000)]
AVX512BW: Enable v32i1/v64i1 BUILD_VECTOR

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

llvm-svn: 263898

8 years ago[ELF][MIPS] Add case demonstrates creation redundant MIPS GOT entries for non-local...
Simon Atanasyan [Sun, 20 Mar 2016 11:53:39 +0000 (11:53 +0000)]
[ELF][MIPS] Add case demonstrates creation redundant MIPS GOT entries for non-local symbols. NFC.

llvm-svn: 263897

8 years agoMark C++ features implemented in Clang 3.8 as done now that 3.8 has released.
Richard Smith [Sun, 20 Mar 2016 10:37:12 +0000 (10:37 +0000)]
Mark C++ features implemented in Clang 3.8 as done now that 3.8 has released.

llvm-svn: 263896

8 years agoP0184R0: Allow types of 'begin' and 'end' expressions in range-based for loops to...
Richard Smith [Sun, 20 Mar 2016 10:33:40 +0000 (10:33 +0000)]
P0184R0: Allow types of 'begin' and 'end' expressions in range-based for loops to differ.

llvm-svn: 263895

8 years ago[ELF] Update x86_64 relocations to 0.99.8 ABI
George Rimar [Sun, 20 Mar 2016 09:45:08 +0000 (09:45 +0000)]
[ELF] Update x86_64 relocations to 0.99.8 ABI

Added: R_X86_64_GOTPCRELX, R_X86_64_REX_GOTPCRELX
llvm-svn: 263894

8 years agoReapply [2] [VFS] Add 'overlay-relative' field to YAML files
Bruno Cardoso Lopes [Sun, 20 Mar 2016 02:08:48 +0000 (02:08 +0000)]
Reapply [2] [VFS] Add 'overlay-relative' field to YAML files

This reapplies r261552 and r263748. Fixed testcase to reapply.

The VFS overlay mapping between virtual paths and real paths is done through
the 'external-contents' entries in YAML files, which contains hardcoded paths
to the real files.

When a module compilation crashes, headers are dumped into <name>.cache/vfs
directory and are mapped via the <name>.cache/vfs/vfs.yaml. The script
generated for reproduction uses -ivfsoverlay pointing to file to gather the
mapping between virtual paths and files inside <name>.cache/vfs. Currently, we
are only capable of reproducing such crashes in the same machine as they
happen, because of the hardcoded paths in 'external-contents'.

To be able to reproduce a crash in another machine, this patch introduces a new
option in the VFS yaml file called 'overlay-relative'. When it's equal to
'true' it means that the provided path to the YAML file through the
-ivfsoverlay option should also be used to prefix the final path for every
'external-contents'.

Example, given the invocation snippet "... -ivfsoverlay
<name>.cache/vfs/vfs.yaml" and the following entry in the yaml file:

"overlay-relative": "true",
"roots": [
...
  "type": "directory",
  "name": "/usr/include",
  "contents": [
    {
      "type": "file",
      "name": "stdio.h",
      "external-contents": "/usr/include/stdio.h"
    },
...

Here, a file manager request for virtual "/usr/include/stdio.h", that will map
into real path "/<absolute_path_to>/<name>.cache/vfs/usr/include/stdio.h.

This is a useful feature for debugging module crashes in machines other than
the one where the error happened.

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

rdar://problem/24499339

llvm-svn: 263893

8 years agoSuppress a -Wunused-variable warning in release builds.
Craig Topper [Sun, 20 Mar 2016 01:17:54 +0000 (01:17 +0000)]
Suppress a -Wunused-variable warning in release builds.

llvm-svn: 263892

8 years agoBetter visualization of clang::BuiltinType in VisualStudio
Mike Spertus [Sun, 20 Mar 2016 00:32:30 +0000 (00:32 +0000)]
Better visualization of clang::BuiltinType in VisualStudio

Whenever possible, use C++ names for visualizing builtin types. E.g., "long double" instead of "LongDouble"

llvm-svn: 263891

8 years agoVisual Studio Visualizer for clang::FunctionProtoType
Mike Spertus [Sun, 20 Mar 2016 00:20:43 +0000 (00:20 +0000)]
Visual Studio Visualizer for clang::FunctionProtoType

Displays return type and parameters for the Function Protoype object in the Locals window.

llvm-svn: 263890

8 years agoUse a range-based for loop. NFC.
Michael Kuperstein [Sun, 20 Mar 2016 00:16:13 +0000 (00:16 +0000)]
Use a range-based for loop. NFC.

llvm-svn: 263889

8 years ago[Sema] Make type deduction work with some overloadable functions
George Burgess IV [Sat, 19 Mar 2016 21:51:45 +0000 (21:51 +0000)]
[Sema] Make type deduction work with some overloadable functions

Some functions can't have their address taken. If we encounter an
overload set where only one of the candidates can have its address
taken, we should automatically select that candidate's type in type
deduction.

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

llvm-svn: 263888

8 years ago[Sema] Allow casting of some overloaded functions
George Burgess IV [Sat, 19 Mar 2016 21:36:10 +0000 (21:36 +0000)]
[Sema] Allow casting of some overloaded functions

Some functions can't have their address taken. If we encounter an
overload set where only one of the candidates can have its address
taken, we should automatically select that candidate in cast
expressions.

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

llvm-svn: 263887

8 years agoExpose IRBuilder::CreateAtomicCmpXchg as LLVMBuildAtomicCmpXchg in the C API.
Mehdi Amini [Sat, 19 Mar 2016 21:28:28 +0000 (21:28 +0000)]
Expose IRBuilder::CreateAtomicCmpXchg as LLVMBuildAtomicCmpXchg in the C API.

Summary: Also expose getters and setters in the C API, so that the change can be tested.

Reviewers: nhaehnle, axw, joker.eph

Subscribers: llvm-commits

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

From: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
llvm-svn: 263886

8 years agoConst-correctness in libLTO
Mehdi Amini [Sat, 19 Mar 2016 21:28:18 +0000 (21:28 +0000)]
Const-correctness in libLTO

Looks like I was sloppy when bridging to C.
Thanks D. Blaikie for noticing!

From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 263885

8 years agoCodeGen: use range based for loop
Saleem Abdulrasool [Sat, 19 Mar 2016 16:35:32 +0000 (16:35 +0000)]
CodeGen: use range based for loop

Convert a loop to use a range based style loop.  NFC.

llvm-svn: 263884

8 years ago[ELF] - ignore the -rpath-link option
George Rimar [Sat, 19 Mar 2016 11:15:54 +0000 (11:15 +0000)]
[ELF] - ignore the -rpath-link option

Just ignore the -rpath-link command line
option in the same way like gold do.

Behavior of lld/gold differs from gnu ld here.
GNU ld tries to resolve undefined symbols in all
shared object files at link time.

Differential revision: http://reviews.llvm.org/D18269

llvm-svn: 263876

8 years ago[SimplifyLibCalls] Only consider sinpi/cospi functions within the same function
David Majnemer [Sat, 19 Mar 2016 04:53:02 +0000 (04:53 +0000)]
[SimplifyLibCalls] Only consider sinpi/cospi functions within the same function

The sinpi/cospi can be replaced with sincospi to remove unnecessary
computations.  However, we need to make sure that the calls are within
the same function!

This fixes PR26993.

llvm-svn: 263875

8 years ago[InstCombine] Don't insert instructions before a catch switch
David Majnemer [Sat, 19 Mar 2016 04:39:52 +0000 (04:39 +0000)]
[InstCombine] Don't insert instructions before a catch switch

CatchSwitches are not splittable, we cannot insert casts, etc. before
them.

This fixes PR26992.

llvm-svn: 263874

8 years agoAdd a dependency from llvm-link to TransformUtils following r263860
Mehdi Amini [Sat, 19 Mar 2016 03:12:54 +0000 (03:12 +0000)]
Add a dependency from llvm-link to TransformUtils following r263860

From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 263873

8 years ago[gold] Use early return to simplify.
Davide Italiano [Sat, 19 Mar 2016 02:34:33 +0000 (02:34 +0000)]
[gold] Use early return to simplify.

llvm-svn: 263872

8 years agoRemoved trailing whitespace
Simon Pilgrim [Sat, 19 Mar 2016 02:05:33 +0000 (02:05 +0000)]
Removed trailing whitespace

llvm-svn: 263871

8 years agoFix a const_cast related warning in GCC in the C API for libLTO
Mehdi Amini [Sat, 19 Mar 2016 01:24:23 +0000 (01:24 +0000)]
Fix a const_cast related warning in GCC in the C API for libLTO

From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 263870

8 years agoAdd a comment on partial hashing of Metadata
Mehdi Amini [Sat, 19 Mar 2016 01:06:24 +0000 (01:06 +0000)]
Add a comment on partial hashing of Metadata

Following r263866, on D. Blaikie suggestion.

From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 263869

8 years ago[libFuzzer] one more trophie
Kostya Serebryany [Sat, 19 Mar 2016 01:05:33 +0000 (01:05 +0000)]
[libFuzzer] one more trophie

llvm-svn: 263868

8 years agoHash Metadata using pointer for MDString argument instead of value (NFC)
Mehdi Amini [Sat, 19 Mar 2016 01:02:34 +0000 (01:02 +0000)]
Hash Metadata using pointer for MDString argument instead of value (NFC)

MDString are uniqued in the Context on creation, hashing the
pointer is less expensive than hashing the String itself.

Reviewers: dexonsmith
Differential Revision: http://reviews.llvm.org/D16560

From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 263867

8 years agoCompute some Debug Info Metadata hash key partially (NFC)
Mehdi Amini [Sat, 19 Mar 2016 00:59:26 +0000 (00:59 +0000)]
Compute some Debug Info Metadata hash key partially (NFC)

Summary:
This patch changes the computation of the hash key for DISubprogram to
be computed on a small subset of the fields. The hash is computed a
lot faster, but there might be more collision in the table.
However by carefully selecting the fields, colisions should be rare.

Using `opt` to load the IR for FastISelEmitter.cpp.o, with this patch:
 - DISubprogram::getImpl() goes from 28ms to 15ms.
 - DICompositeType::getImpl() goes from 6ms to 2ms
 - DIDerivedType::getImpl() goes from 18 to 12ms

Reviewers: dexonsmith

Subscribers: llvm-commits

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

From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 263866