platform/upstream/llvm.git
8 years ago[analyzer] Add LocationContext information to SymbolMetadata.
Artem Dergachev [Wed, 17 Aug 2016 15:37:52 +0000 (15:37 +0000)]
[analyzer] Add LocationContext information to SymbolMetadata.

Like SymbolConjured, SymbolMetadata also needs to be uniquely
identified by the moment of its birth.

Such moments are coded by the (Statement, LocationContext, Block count) triples.
Each such triple represents the moment of analyzing a statement with a certain
call backtrace, with corresponding CFG block having been entered a given amount
of times during analysis of the current code body.

The LocationContext information was accidentally omitted for SymbolMetadata,
which leads to reincarnation of SymbolMetadata upon re-entering a code body
with a different backtrace; the new symbol is incorrectly unified with
the old symbol, which leads to unsound assumptions.

Patch by Alexey Sidorin!

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

llvm-svn: 278937

8 years agoUpdate ISL to isl-0.17.1-200-gd8de4ea.
Michael Kruse [Wed, 17 Aug 2016 15:24:45 +0000 (15:24 +0000)]
Update ISL to isl-0.17.1-200-gd8de4ea.

This version fixes a bug in set coalescing.

llvm-svn: 278936

8 years ago[InstCombine] use m_APInt to allow icmp (add X, Y), C folds for splat constant vectors
Sanjay Patel [Wed, 17 Aug 2016 15:24:30 +0000 (15:24 +0000)]
[InstCombine] use m_APInt to allow icmp (add X, Y), C folds for splat constant vectors

This is a sibling of:
https://reviews.llvm.org/rL278859

llvm-svn: 278935

8 years agoAdapt to TraverseLambdaCapture interface change from D23204
Martin Bohme [Wed, 17 Aug 2016 15:00:22 +0000 (15:00 +0000)]
Adapt to TraverseLambdaCapture interface change from D23204

Summary:
Depends on D23204.

This is intended to be submitted immediately after D23204 lands.

Reviewers: jdennett, alexfh

Subscribers: cfe-commits

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

llvm-svn: 278934

8 years agoVisit lambda capture inits from RecursiveASTVisitor::TraverseLambdaCapture().
Martin Bohme [Wed, 17 Aug 2016 14:59:53 +0000 (14:59 +0000)]
Visit lambda capture inits from RecursiveASTVisitor::TraverseLambdaCapture().

Summary:
rL277342 made RecursiveASTVisitor visit lambda capture initialization
expressions (these are the Exprs in LambdaExpr::capture_inits()).

jdennett identified two issues with rL277342 (see comments there for details):

- It visits initialization expressions for implicit lambda captures, even if
  shouldVisitImplicitCode() returns false.

- It visits initialization expressions for init captures twice (because these
  were already traveresed in TraverseLambdaCapture() before rL277342)

This patch fixes these issues and moves the code for traversing initialization
expressions into TraverseLambdaCapture().

This patch also makes two changes required for the tests:

- It adds Lang_CXX14 to the Language enum in TestVisitor.

- It adds a parameter to ExpectedLocationVisitor::ExpectMatch() that specifies
  the number of times a match is expected to be seen.

Reviewers: klimek, jdennett, alexfh

Subscribers: cfe-commits

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

llvm-svn: 278933

8 years agoClarify the statement on using #if 0 ... #endif in CodingStandards.
Andrey Bokhanko [Wed, 17 Aug 2016 14:53:18 +0000 (14:53 +0000)]
Clarify the statement on using #if 0 ... #endif in CodingStandards.

The statement on using #if 0 ... #endif is not very clear (for people like me
:-)). This patch clarifies it a bit to avoid confusion.

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

llvm-svn: 278932

8 years ago[ELF] - Linkerscript: make readAt() signature to be consistent with others read*...
George Rimar [Wed, 17 Aug 2016 14:48:17 +0000 (14:48 +0000)]
[ELF] - Linkerscript: make readAt() signature to be consistent with others read*(). NFC.

llvm-svn: 278931

8 years ago[mips] Add l.[sd] and s.[sd] instruction aliases
Simon Dardis [Wed, 17 Aug 2016 14:45:09 +0000 (14:45 +0000)]
[mips] Add l.[sd] and s.[sd] instruction aliases

Reviewers: dsanders, vkalintiris

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

llvm-svn: 278930

8 years agoRevert "[Reassociate] Avoid iterator invalidation when negating value."
Chad Rosier [Wed, 17 Aug 2016 14:31:34 +0000 (14:31 +0000)]
Revert "[Reassociate] Avoid iterator invalidation when negating value."

This reverts commit r278928 due to lit test failures.

llvm-svn: 278929

8 years ago[Reassociate] Avoid iterator invalidation when negating value.
Chad Rosier [Wed, 17 Aug 2016 14:16:45 +0000 (14:16 +0000)]
[Reassociate] Avoid iterator invalidation when negating value.

Differential Revision: https://reviews.llvm.org/D23464
PR28367

llvm-svn: 278928

8 years ago[LoopStrenghtReduce] Refactoring and addition of a new target cost function.
Jonas Paulsson [Wed, 17 Aug 2016 13:24:19 +0000 (13:24 +0000)]
[LoopStrenghtReduce] Refactoring and addition of a new target cost function.

Refactored so that a LSRUse owns its fixups, as oppsed to letting the
LSRInstance own them. This makes it easier to rate formulas for
LSRUses, since the fixups are available directly. The Offsets vector
has been removed since it was no longer necessary.

New target hook isFoldableMemAccessOffset(), which is used during formula
rating.

For SystemZ, this is useful to express that loads and stores with
float or vector types with a big/negative offset should be avoided in
loops. Without this, LSR will generate a lot of negative offsets that
would require extra instructions for loading the address.

Updated tests:
test/CodeGen/SystemZ/loop-01.ll

Reviewed by: Quentin Colombet and Ulrich Weigand.
https://reviews.llvm.org/D19152

llvm-svn: 278927

8 years agoAdd an AST matcher for external formal linkage.
Aaron Ballman [Wed, 17 Aug 2016 13:10:42 +0000 (13:10 +0000)]
Add an AST matcher for external formal linkage.

Patch by Visoiu Mistrih

llvm-svn: 278926

8 years agoFix unittests on windows after r278915
Pavel Labath [Wed, 17 Aug 2016 12:00:19 +0000 (12:00 +0000)]
Fix unittests on windows after r278915

Apparently clang will happily capture a const variable in a lambda without it being specified in
the capture clause. MSVC does not like that.

llvm-svn: 278925

8 years agoRemove cmake legacy code
Pavel Labath [Wed, 17 Aug 2016 11:55:50 +0000 (11:55 +0000)]
Remove cmake legacy code

Summary: Cmake 2.8 support is gone and not coming back. We can remove a bit of legacy code now.

Reviewers: zturner

Subscribers: lldb-commits

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

llvm-svn: 278924

8 years agoFixing bug committed in rev. 278321
Marina Yatsina [Wed, 17 Aug 2016 11:40:21 +0000 (11:40 +0000)]
Fixing bug committed in rev. 278321

In theory the indices of RC (and thus the index used for LiveRegs) may differ from the indices of OpRC.
Fixed the code to extract the correct RC index.
OpRC contains the first X consecutive elements of RC, and thus their indices are currently de facto the same, therefore a test cannot be added at this point.

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

llvm-svn: 278923

8 years ago[include-fixer] Update -help message.
Haojian Wu [Wed, 17 Aug 2016 11:31:19 +0000 (11:31 +0000)]
[include-fixer] Update -help message.

llvm-svn: 278922

8 years ago[AMDGPU] llvm-objdump: Skip amd_kernel_code_t only at the begining of kernel symbol.
Sam Kolton [Wed, 17 Aug 2016 10:17:57 +0000 (10:17 +0000)]
[AMDGPU] llvm-objdump: Skip amd_kernel_code_t only at the begining of kernel symbol.

Summary: This change fix bug in AMDGPU disassembly. Previously, presence of symbols other than kernel symbols caused objdump to skip begining of those symbols.

Reviewers: tstellarAMD, vpykhtin, Bigcheese, ruiu

Subscribers: kzhuravl, arsenm

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

llvm-svn: 278921

8 years agoLiveIntervals: add removeRegUnit
Nicolai Haehnle [Wed, 17 Aug 2016 09:34:55 +0000 (09:34 +0000)]
LiveIntervals: add removeRegUnit

Summary:
See D22198 for the motivation: We have a pass that uses LiveIntervals anyway,
and there is now a requirement to track a physical register that is not
usually tracked at this point of the compilation. The pass also introduces
instructions that affect this physical register, but we want to preserve
LiveIntervals.

Rather than add brittle and rarely exercised code to keep the tracking of
the physical register intact, we want to just remove the corresponding
LiveRange -- it didn't exist before anyway, and subsequent passes don't
expect it to be there.

Reviewers: MatzeB, arsenm

Subscribers: llvm-commits, MatzeB

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

llvm-svn: 278920

8 years agoDeal with buildbot fallout from r278917: s/AllocType()/GetAllocType()/ (had the same...
Filipe Cabecinhas [Wed, 17 Aug 2016 09:24:33 +0000 (09:24 +0000)]
Deal with buildbot fallout from r278917: s/AllocType()/GetAllocType()/ (had the same name as the enum)

llvm-svn: 278919

8 years agoFix unittest compilation error in r278915
Pavel Labath [Wed, 17 Aug 2016 09:17:08 +0000 (09:17 +0000)]
Fix unittest compilation error in r278915

llvm-svn: 278918

8 years agoRename DescribeHeapAddress to DescribeAddressIfHeap and split it into a function...
Filipe Cabecinhas [Wed, 17 Aug 2016 09:16:08 +0000 (09:16 +0000)]
Rename DescribeHeapAddress to DescribeAddressIfHeap and split it into a function to get all the information about the address, and one to print it.

Summary:
Replacement for part of D23518
This deals with heap addresses, and renames DescribeHeapAddress.
Requires D23520, which moves code around to make it accessible in asan_describers.cc (and still accessible in asan_report.cc if needed).

Reviewers: kcc, samsonov

Subscribers: kubabrecka, llvm-commits

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

llvm-svn: 278917

8 years agoRemove manual packet construction from GDBRemoteRegisterContext::SetPrimordialRegister
Pavel Labath [Wed, 17 Aug 2016 09:12:21 +0000 (09:12 +0000)]
Remove manual packet construction from GDBRemoteRegisterContext::SetPrimordialRegister

llvm-svn: 278916

8 years agoMove packet construction from GDBRemoteRegisterContext go the communication class
Pavel Labath [Wed, 17 Aug 2016 08:53:31 +0000 (08:53 +0000)]
Move packet construction from GDBRemoteRegisterContext go the communication class

Summary:
When saving/restoring registers the GDBRemoteRegisterContext class was manually constructing
the register save/restore packets. This creates appropriate helper functions in
GDBRemoteCommunicationClient, and switches the class to use those. It also removes what a
duplicate packet send in some of those functions, a thing that I can only attribute to a bad
merge artefact.

I also add a test framework for testing gdb-remote client functionality and add tests for the new
functions I introduced. I'd like to be able to test the register context changes in isolation as
well, but currently there doesn't seem to be a way to reasonably construct a standalone register
context object, so we'll have to rely on the end-to-end tests to verify that.

Reviewers: clayborg

Subscribers: lldb-commits

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

llvm-svn: 278915

8 years agoAttemp to fix linux build bot after r278911 ("[ELF] - linkerscript AT keyword (in...
George Rimar [Wed, 17 Aug 2016 08:16:57 +0000 (08:16 +0000)]
Attemp to fix linux build bot after r278911 ("[ELF] - linkerscript AT keyword (in output section description) implemented.")

http://lab.llvm.org:8011/builders/lld-x86_64-darwin13/builds/26289/steps/build_Lld/logs/stdio

llvm-svn: 278914

8 years agoFix bug in DAGBuilder for getelementptr with expanded vector.
Ayman Musa [Wed, 17 Aug 2016 07:52:15 +0000 (07:52 +0000)]
Fix bug in DAGBuilder for getelementptr with expanded vector.

Replacing the usage of MVT with EVT in case the vector type is expanded.
Differential Revision: https://reviews.llvm.org/D23306

llvm-svn: 278913

8 years ago[LTO] Fix a use-after-free introduced in r278907 and caught by ASan.
Chandler Carruth [Wed, 17 Aug 2016 07:48:34 +0000 (07:48 +0000)]
[LTO] Fix a use-after-free introduced in r278907 and caught by ASan.

The ASan build bot caught this right away:
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/15580/steps/check-llvm%20asan/logs/stdio

This was also breaking a Windows build bot I'm pretty sure.

llvm-svn: 278912

8 years ago[ELF] - linkerscript AT keyword (in output section description) implemented.
George Rimar [Wed, 17 Aug 2016 07:44:19 +0000 (07:44 +0000)]
[ELF] - linkerscript AT keyword (in output section description) implemented.

The linker will normally set the LMA equal to the VMA.
You can change that by using the AT keyword.
The expression lma that follows the AT keyword specifies
the load address of the section.

Patch implements this keyword.

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

llvm-svn: 278911

8 years agoFirst commit (test commit) - Adding empty line.
Ayman Musa [Wed, 17 Aug 2016 07:37:34 +0000 (07:37 +0000)]
First commit (test commit) - Adding empty line.

llvm-svn: 278910

8 years agoRestrict the use of the C++17 attribute to C++17 (at least as best we
Chandler Carruth [Wed, 17 Aug 2016 07:18:44 +0000 (07:18 +0000)]
Restrict the use of the C++17 attribute to C++17 (at least as best we
can given the current __cplusplus definitions).

Without this, Clang triggers TONS of warnings about using a C++17
extension. I tried using LLVM_EXTENSION to turn these off and it doesn't
work.

Suggestions on a better approach are welcome, but at least this makes
the build usable for me again.

llvm-svn: 278909

8 years agoAdd missing tests
Roger Ferrer Ibanez [Wed, 17 Aug 2016 06:52:15 +0000 (06:52 +0000)]
Add missing tests

Change r278483 was missing the tests

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

llvm-svn: 278908

8 years ago[LTO] Introduce an Output class to wrap the output stream creation (NFC)
Mehdi Amini [Wed, 17 Aug 2016 06:23:09 +0000 (06:23 +0000)]
[LTO] Introduce an Output class to wrap the output stream creation (NFC)

Summary:
While NFC for now, this will allow more flexibility on the client side
to hold state necessary to back up the stream.
Also when adding caching, this class will grow in complexity.

Note I blindly modified the gold-plugin as I can't compile it.

Reviewers: tejohnson

Subscribers: mehdi_amini, llvm-commits

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

llvm-svn: 278907

8 years ago[ThinLTO] Adapt backend invocation to llvm API changes.
Mehdi Amini [Wed, 17 Aug 2016 06:23:08 +0000 (06:23 +0000)]
[ThinLTO] Adapt backend invocation to llvm API changes.

Reviewers: tejohnson

Subscribers: mehdi_amini, llvm-commits

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

llvm-svn: 278906

8 years agoSupport allocators with explicit conversion constructors. Fixes bug #29000
Marshall Clow [Wed, 17 Aug 2016 05:58:40 +0000 (05:58 +0000)]
Support allocators with explicit conversion constructors. Fixes bug #29000

llvm-svn: 278904

8 years agoFix a use of LLVM_FALLTHROUGH that wasn't even in a switch.
Justin Bogner [Wed, 17 Aug 2016 05:25:38 +0000 (05:25 +0000)]
Fix a use of LLVM_FALLTHROUGH that wasn't even in a switch.

I was over-aggressive in my conversions from comments to the
fallthrough attribute.

llvm-svn: 278903

8 years agoReplace "fallthrough" comments with LLVM_FALLTHROUGH
Justin Bogner [Wed, 17 Aug 2016 05:10:15 +0000 (05:10 +0000)]
Replace "fallthrough" comments with LLVM_FALLTHROUGH

This is a mechanical change of comments in switches like fallthrough,
fall-through, or fall-thru to use the LLVM_FALLTHROUGH macro instead.

llvm-svn: 278902

8 years agoFix the RangeMapVector::FindEntryThatContainsOrFollows method to
Jason Molenda [Wed, 17 Aug 2016 03:56:04 +0000 (03:56 +0000)]
Fix the RangeMapVector::FindEntryThatContainsOrFollows method to
back up the iterator, as long as it still contains the address.
std::lower_bound will point us to the entry after the one we
are really interested in, leading to problems with backtracing
in corefiles.

<rdar://problem/27823549>

llvm-svn: 278901

8 years ago[ppc64] Don't apply sibling call optimization if callee has any byval arg
Chuang-Yu Cheng [Wed, 17 Aug 2016 03:17:44 +0000 (03:17 +0000)]
[ppc64] Don't apply sibling call optimization if callee has any byval arg

This is a quick work around, because in some cases, e.g. caller's stack
size > callee's stack size, we are still able to apply sibling call
optimization even callee has any byval arg.

This patch fix: https://llvm.org/bugs/show_bug.cgi?id=28328

Reviewers: hfinkel kbarton nemanjai amehsan
Subscribers: hans, tjablin

https://reviews.llvm.org/D23441

llvm-svn: 278900

8 years agoRemove the Triple tests that stressing the TargetParser's behaviour.
Zijiao Ma [Wed, 17 Aug 2016 03:17:07 +0000 (03:17 +0000)]
Remove the Triple tests that stressing the TargetParser's behaviour.

Now the tests of TargetParser is in place:
unittests/Support/TargetParserTest.cpp.
So the tests in TripleTest.cpp which actually stressing TargetParser's behavior could be removed.

llvm-svn: 278899

8 years agoCodeGen: Avoid dereferencing end() in ScalarExprEmitter::EmitOverflowCheckedBinOp
Duncan P. N. Exon Smith [Wed, 17 Aug 2016 03:15:29 +0000 (03:15 +0000)]
CodeGen: Avoid dereferencing end() in ScalarExprEmitter::EmitOverflowCheckedBinOp

Use BB.getNextNode(), which returns nullptr on end(), instead of
&*BB.getIterator(), which is UB on end().
CodeGenFunction::createBasicBlock expects nullptr in this case already.

llvm-svn: 278898

8 years ago[PM] Update Clang for LLVM's r278896 which re-organized a header.
Chandler Carruth [Wed, 17 Aug 2016 03:09:11 +0000 (03:09 +0000)]
[PM] Update Clang for LLVM's r278896 which re-organized a header.

(sorry this didn't get landed closer in time...)

llvm-svn: 278897

8 years ago[PM] Port the always inliner to the new pass manager in a much more
Chandler Carruth [Wed, 17 Aug 2016 02:56:20 +0000 (02:56 +0000)]
[PM] Port the always inliner to the new pass manager in a much more
minimal and boring form than the old pass manager's version.

This pass does the very minimal amount of work necessary to inline
functions declared as always-inline. It doesn't support a wide array of
things that the legacy pass manager did support, but is alse ... about
20 lines of code. So it has that going for it. Notably things this
doesn't support:

- Array alloca merging
  - To support the above, bottom-up inlining with careful history
    tracking and call graph updates
- DCE of the functions that become dead after this inlining.
- Inlining through call instructions with the always_inline attribute.
  Instead, it focuses on inlining functions with that attribute.

The first I've omitted because I'm hoping to just turn it off for the
primary pass manager. If that doesn't pan out, I can add it here but it
will be reasonably expensive to do so.

The second should really be handled by running global-dce after the
inliner. I don't want to re-implement the non-trivial logic necessary to
do comdat-correct DCE of functions. This means the -O0 pipeline will
have to be at least 'always-inline,global-dce', but that seems
reasonable to me. If others are seriously worried about this I'd like to
hear about it and understand why. Again, this is all solveable by
factoring that logic into a utility and calling it here, but I'd like to
wait to do that until there is a clear reason why the existing
pass-based factoring won't work.

The final point is a serious one. I can fairly easily add support for
this, but it seems both costly and a confusing construct for the use
case of the always inliner running at -O0. This attribute can of course
still impact the normal inliner easily (although I find that
a questionable re-use of the same attribute). I've started a discussion
to sort out what semantics we want here and based on that can figure out
if it makes sense ta have this complexity at O0 or not.

One other advantage of this design is that it should be quite a bit
faster due to checking for whether the function is a viable candidate
for inlining exactly once per function instead of doing it for each call
site.

Anyways, hopefully a reasonable starting point for this pass.

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

llvm-svn: 278896

8 years agoIfConversion: Use references instead of pointers where possible; NFC
Matthias Braun [Wed, 17 Aug 2016 02:52:01 +0000 (02:52 +0000)]
IfConversion: Use references instead of pointers where possible; NFC

Also put some commonly used subexpressions into variables.

llvm-svn: 278895

8 years agoIfConversion: Use range based for; NFC
Matthias Braun [Wed, 17 Aug 2016 02:51:59 +0000 (02:51 +0000)]
IfConversion: Use range based for; NFC

Also avoid some pointless use of auto! Because that's friendlier to
readers and avoids several types accidentally resolving to unnecessary
references here (MachineInstr *&, unsigned &).

llvm-svn: 278894

8 years agoIfConversion: Improve doxygen comments
Matthias Braun [Wed, 17 Aug 2016 02:51:57 +0000 (02:51 +0000)]
IfConversion: Improve doxygen comments

llvm-svn: 278893

8 years ago[Inliner] Add a flag to disable manual alloca merging in the Inliner.
Chandler Carruth [Wed, 17 Aug 2016 02:40:23 +0000 (02:40 +0000)]
[Inliner] Add a flag to disable manual alloca merging in the Inliner.

This is off for now while testing can take place to make sure that in
fact we do sufficient stack coloring to fully obviate the manual alloca
array merging.

Some context on why we should be using stack coloring rather than
merging allocas in this way:

LLVM relies very heavily on analyzing pointers as coming from different
allocas in order to make aliasing decisions. These are some of the most
powerful aliasing signals available in LLVM. So merging allocas is an
extremely destructive operation on the LLVM IR -- it takes away highly
valuable and hard to reconstruct information.

As a consequence, inlined functions which happen to have array allocas
that this pattern matches will fail to be properly interleaved unless
SROA manages to hoist everything to an SSA register. Instead, the
inliner will have added an unnecessary dependence that one inlined
function execute after the other because they will have been rewritten
to refer to the same memory.

All that said, folks will reasonably want some time to experiment here
and make sure there are no significant regressions. A flag should give
us an easy knob to test.

For more context, see the thread here:
http://lists.llvm.org/pipermail/llvm-dev/2016-July/103277.html
http://lists.llvm.org/pipermail/llvm-dev/2016-August/103285.html

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

llvm-svn: 278892

8 years agoAdd missing close brace to fix Windows bots. Oops :(
Richard Smith [Wed, 17 Aug 2016 02:22:39 +0000 (02:22 +0000)]
Add missing close brace to fix Windows bots. Oops :(

llvm-svn: 278891

8 years agoSome missing usage of TargetParser. NFC.
Zijiao Ma [Wed, 17 Aug 2016 02:13:33 +0000 (02:13 +0000)]
Some missing usage of TargetParser. NFC.

llvm-svn: 278890

8 years ago[ELF] Set MAXPAGESIZE to 2MiB on x86-64 to match bfd and gold.
Michael J. Spencer [Wed, 17 Aug 2016 02:10:51 +0000 (02:10 +0000)]
[ELF] Set MAXPAGESIZE to 2MiB on x86-64 to match bfd and gold.

The FreeBSD kernel relies on this behavior to not overwrite the boot loader.

llvm-svn: 278889

8 years agoSome places that could using TargetParser in LLVM. NFC.
Zijiao Ma [Wed, 17 Aug 2016 02:08:28 +0000 (02:08 +0000)]
Some places that could using TargetParser in LLVM. NFC.

llvm-svn: 278888

8 years agoADT: Add some missing coverage for iplist::splice
Duncan P. N. Exon Smith [Wed, 17 Aug 2016 02:08:08 +0000 (02:08 +0000)]
ADT: Add some missing coverage for iplist::splice

These splices are interesting because they involve swapping two nodes in
the same list.  There are two ways to do this.  Assuming:

    A -> B -> [Sentinel]

You can either:
- splice B before A, with:        L.splice(A,       L, B) or
- splice A before Sentinel, with: L.splice(L.end(), L, A) to create:

    B -> A -> [Sentinel]

These two swapping-splices are somewhat interesting corner cases for
maintaining the list invariants.  The tests pass even with my new ilist
implementation, but I had some doubts about the latter when I was
looking at weird UB effects.  Since I can't find equivalent explicit
test coverage elsewhere it seems prudent to commit.

llvm-svn: 278887

8 years agoScalar: Avoid dereferencing end() in IndVarSimplify
Duncan P. N. Exon Smith [Wed, 17 Aug 2016 01:54:41 +0000 (01:54 +0000)]
Scalar: Avoid dereferencing end() in IndVarSimplify

IndVarSimplify::sinkUnusedInvariants calls
BasicBlock::getFirstInsertionPt on the ExitBlock and moves instructions
before it.  This can return end(), so it's not safe to dereference.  Add
an iterator-based overload to Instruction::moveBefore to avoid the UB.

llvm-svn: 278886

8 years ago[Docs] Fix post-review comments on MemorySSA's docs.
George Burgess IV [Wed, 17 Aug 2016 01:50:54 +0000 (01:50 +0000)]
[Docs] Fix post-review comments on MemorySSA's docs.

Thanks to Sean Silva for bringing these up. :)

llvm-svn: 278885

8 years agoIPO: Swap || operands to avoid dereferencing end()
Duncan P. N. Exon Smith [Wed, 17 Aug 2016 01:23:58 +0000 (01:23 +0000)]
IPO: Swap || operands to avoid dereferencing end()

IsOperandBundleUse conveniently indicates  whether
std::next(F->arg_begin(),UseIndex) will get to (or past) end().  Check
it first to avoid dereferencing end().

llvm-svn: 278884

8 years agoScalar: Avoid dereferencing end() in InductiveRangeCheckElimination
Duncan P. N. Exon Smith [Wed, 17 Aug 2016 01:16:17 +0000 (01:16 +0000)]
Scalar: Avoid dereferencing end() in InductiveRangeCheckElimination

BasicBlock::Create isn't designed to take iterators (which might be
end()), but pointers (which might be nullptr).  Fix the UB that was
converting end() to a BasicBlock* by calling BasicBlock::getNextNode()
in the first place.

llvm-svn: 278883

8 years agoIf possible, set the stack rlimit to at least 8MiB on cc1 startup, and work
Richard Smith [Wed, 17 Aug 2016 01:05:07 +0000 (01:05 +0000)]
If possible, set the stack rlimit to at least 8MiB on cc1 startup, and work
around a Linux kernel bug where the actual amount of available stack may be a
*lot* lower than the rlimit.

GCC also sets a higher stack rlimit on startup, but it goes all the way to
64MiB. We can increase this limit if it proves necessary.

The kernel bug is as follows: Linux kernels prior to version 4.1 may choose to
map the process's heap as little as 128MiB before the process's stack for a PIE
binary, even in a 64-bit virtual address space. This means that allocating more
than 128MiB before you reach the process's stack high water mark can lead to
crashes, even if you don't recurse particularly deeply.

We work around the kernel bug by touching a page deep within the stack (after
ensuring that we know how big it is), to preallocate virtual address space for
the stack so that the kernel doesn't allow the brk() area to wander into it,
when building clang as a Linux PIE binary.

llvm-svn: 278882

8 years agoObjCARC: Don't increment or dereference end() when scanning args
Duncan P. N. Exon Smith [Wed, 17 Aug 2016 01:02:18 +0000 (01:02 +0000)]
ObjCARC: Don't increment or dereference end() when scanning args

When there's only one argument and it doesn't match one of the known
functions, return ARCInstKind::CallOrUser rather than falling through
to the two argument case.  The old behaviour both incremented past and
dereferenced end().

llvm-svn: 278881

8 years agoARM: Avoid dereferencing end() in ARMFrameLowering::emitPrologue
Duncan P. N. Exon Smith [Wed, 17 Aug 2016 00:53:04 +0000 (00:53 +0000)]
ARM: Avoid dereferencing end() in ARMFrameLowering::emitPrologue

llvm::tryFoldSPUpdateIntoPushPop assumes its arguments are valid
MachineInstrs.  Update ARMFrameLowering::emitPrologue to respect that;
when LastPush==end(), it can't possibly be a push instruction anyway.

llvm-svn: 278880

8 years agoCodeGen: Avoid dereferencing end() in OptimizePHIs::OptimizeBB
Duncan P. N. Exon Smith [Wed, 17 Aug 2016 00:43:59 +0000 (00:43 +0000)]
CodeGen: Avoid dereferencing end() in OptimizePHIs::OptimizeBB

llvm-svn: 278879

8 years agoHexagon: Avoid dereferencing end() in HexagonInstrInfo::InsertBranch
Duncan P. N. Exon Smith [Wed, 17 Aug 2016 00:34:00 +0000 (00:34 +0000)]
Hexagon: Avoid dereferencing end() in HexagonInstrInfo::InsertBranch

llvm-svn: 278878

8 years ago[Docs] Add initial MemorySSA documentation.
George Burgess IV [Wed, 17 Aug 2016 00:17:29 +0000 (00:17 +0000)]
[Docs] Add initial MemorySSA documentation.

Patch partially by Danny.

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

llvm-svn: 278875

8 years agoAMDGPU: Avoid looking for the DebugLoc in end()
Duncan P. N. Exon Smith [Wed, 17 Aug 2016 00:06:43 +0000 (00:06 +0000)]
AMDGPU: Avoid looking for the DebugLoc in end()

The end() iterator isn't a safe thing to dereference.  Pass the DebugLoc
into EmitFetchClause and EmitALUClause to avoid it.

llvm-svn: 278873

8 years agoSimplifyCFG: Avoid dereferencing end()
Duncan P. N. Exon Smith [Tue, 16 Aug 2016 23:57:56 +0000 (23:57 +0000)]
SimplifyCFG: Avoid dereferencing end()

When comparing a User* to a BasicBlock::iterator in
passingValueIsAlwaysUndefined, don't dereference the iterator in case it
is end().

llvm-svn: 278872

8 years agoRevert "Write the TPI stream from a PDB to Yaml."
Justin Bogner [Tue, 16 Aug 2016 23:37:10 +0000 (23:37 +0000)]
Revert "Write the TPI stream from a PDB to Yaml."

This is hitting a "use of undeclared identifier 'skipPadding' error
locally and on some bots.

This reverts r278869.

llvm-svn: 278871

8 years agoCodeGen: Avoid dereferencing end() when unconstifying iterators
Duncan P. N. Exon Smith [Tue, 16 Aug 2016 23:34:07 +0000 (23:34 +0000)]
CodeGen: Avoid dereferencing end() when unconstifying iterators

Rather than doing a funny dance that relies on dereferencing end() not
crashing, add some API to MachineInstrBundleIterator to get a non-const
version of the iterator.

llvm-svn: 278870

8 years agoWrite the TPI stream from a PDB to Yaml.
Zachary Turner [Tue, 16 Aug 2016 23:28:54 +0000 (23:28 +0000)]
Write the TPI stream from a PDB to Yaml.

Reviewed By: ruiu, rnk
Differential Revision: https://reviews.llvm.org/D23226

llvm-svn: 278869

8 years agoIntroduce LLVM_FALLTHROUGH, which expands to the C++17 attribute.
Justin Bogner [Tue, 16 Aug 2016 23:24:13 +0000 (23:24 +0000)]
Introduce LLVM_FALLTHROUGH, which expands to the C++17 attribute.

This allows you to annotate switch case fallthrough in a better way
than a "// FALLTHROUGH" comment. Eventually it would be nice to turn
on -Wimplicit-fallthrough, if we can get the code base clean.

llvm-svn: 278868

8 years ago[InstCombine] add tests for fold with no coverage and missing vector fold
Sanjay Patel [Tue, 16 Aug 2016 23:18:42 +0000 (23:18 +0000)]
[InstCombine] add tests for fold with no coverage and missing vector fold

llvm-svn: 278867

8 years agoCodegen: Don't tail-duplicate blocks with un-analyzable fallthrough.
Kyle Butt [Tue, 16 Aug 2016 22:56:14 +0000 (22:56 +0000)]
Codegen: Don't tail-duplicate blocks with un-analyzable fallthrough.

If AnalyzeBranch can't analyze a block and it is possible to
fallthrough, then duplicating the block doesn't make sense, as only one
block can be the layout predecessor for the un-analyzable fallthrough.

Submitted wit a test case, but NOTE: the test case doesn't currently
fail. However, the test case fails with D20505 and would have saved me
some time debugging.

llvm-svn: 278866

8 years ago[InstCombine] clean up foldICmpAddConstant(); NFCI
Sanjay Patel [Tue, 16 Aug 2016 22:34:42 +0000 (22:34 +0000)]
[InstCombine] clean up foldICmpAddConstant(); NFCI

1. Fix variable names
2. Add local variables to reduce code
3. Fix code comments
4. Add early exit to reduce indentation
5. Remove 'else' after if -> return
6. Hoist common predicate

llvm-svn: 278864

8 years ago[AMDGPU] Remove duplicate initialization of SIDebuggerInsertNops pass
Konstantin Zhuravlyov [Tue, 16 Aug 2016 22:30:11 +0000 (22:30 +0000)]
[AMDGPU] Remove duplicate initialization of SIDebuggerInsertNops pass

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

llvm-svn: 278863

8 years ago[CMake] Workflow improvements to PGO generation
Chris Bieneman [Tue, 16 Aug 2016 22:16:29 +0000 (22:16 +0000)]
[CMake] Workflow improvements to PGO generation

This patch adds a few new convenience options used by the PGO CMake cache to setup options on bootstrap stages. The new options are:

PGO_INSTRUMENT_LTO - Builds the instrumented and final builds with LTO
PGO_BUILD_CONFIGURATION - Accepts a CMake cache script that can be used for complex configuration of the stage2-instrumented and stage2 builds.

The patch also includes a fix for bootstrap dependencies so that the instrumented LTO tools don't get used when building the final stage, and it adds distribution targets to the passthrough.

llvm-svn: 278862

8 years agoEmit debug info for dynamic classes if they are imported from a DLL.
Adrian McCarthy [Tue, 16 Aug 2016 22:11:18 +0000 (22:11 +0000)]
Emit debug info for dynamic classes if they are imported from a DLL.

With -debug-info-kind=limited, we omit debug info for dynamic classes that live in other TUs. This reduces duplicate type information. When statically linked, the type information comes together. But if your binary has a class derived from a base in a DLL, the base class info is not available to the debugger.

The decision is made in shouldOmitDefinition (CGDebugInfo.cpp). Per a suggestion from rnk, I've tweaked the decision so that we do include definitions for classes marked as DLL imports. This should be a relatively small number of classes, so we don't pay a large price for duplication of the type info, yet it should cover most cases on Windows.

Essentially this makes debug info for DLLs independent, but we still assume that all TUs within the same DLL will be consistently built with (or without) debug info and the debugger will be able to search across the debug info within that scope to resolve any declarations into definitions, etc.

llvm-svn: 278861

8 years agoPreserve the assumption cache more often
David Majnemer [Tue, 16 Aug 2016 22:07:32 +0000 (22:07 +0000)]
Preserve the assumption cache more often

We were clearing it out in LoopUnswitch and InlineFunction instead of
attempting to preserve it.

llvm-svn: 278860

8 years ago[InstCombine] use m_APInt to allow icmp (sub X, Y), C folds for splat constant vectors
Sanjay Patel [Tue, 16 Aug 2016 21:53:19 +0000 (21:53 +0000)]
[InstCombine] use m_APInt to allow icmp (sub X, Y), C folds for splat constant vectors

llvm-svn: 278859

8 years agoCodeGen: Don't dereference end() in MachineBasicBlock::CorrectExtraCFGEdges
Duncan P. N. Exon Smith [Tue, 16 Aug 2016 21:46:03 +0000 (21:46 +0000)]
CodeGen: Don't dereference end() in MachineBasicBlock::CorrectExtraCFGEdges

The current MachineBasicBlock might be the last block, so FallThru may
be past the end().  Use getNextNode(), which will convert to nullptr,
rather than &*++, which is invalid if we reach the end().

llvm-svn: 278858

8 years ago[x86] Allow merging multiple instances of an immediate within a basic block for code...
Sanjay Patel [Tue, 16 Aug 2016 21:35:16 +0000 (21:35 +0000)]
[x86] Allow merging multiple instances of an immediate within a basic block for code size savings, for 64-bit constants.

This patch handles 64-bit constants which can be encoded as 32-bit immediates.

It extends the functionality added by https://reviews.llvm.org/D11363 for 32-bit constants to 64-bit constants.

Patch by Sunita Marathe!

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

llvm-svn: 278857

8 years ago[libFuzzer] minor speed improvement
Kostya Serebryany [Tue, 16 Aug 2016 21:28:05 +0000 (21:28 +0000)]
[libFuzzer] minor speed improvement

llvm-svn: 278856

8 years ago[InstCombine] fix variable names to match formula comments; NFC
Sanjay Patel [Tue, 16 Aug 2016 21:26:10 +0000 (21:26 +0000)]
[InstCombine] fix variable names to match formula comments; NFC

llvm-svn: 278855

8 years ago[LoopUnroll] Don't clear out the AssumptionCache on each loop
David Majnemer [Tue, 16 Aug 2016 21:09:46 +0000 (21:09 +0000)]
[LoopUnroll] Don't clear out the AssumptionCache on each loop

Clearing out the AssumptionCache can cause us to rescan the entire
function for assumes.  If there are many loops, then we are scanning
over the entire function many times.

Instead of clearing out the AssumptionCache, register all cloned
assumes.

llvm-svn: 278854

8 years agoRevert "Enhance SCEV to compute the trip count for some loops with unknown stride."
Reid Kleckner [Tue, 16 Aug 2016 21:02:04 +0000 (21:02 +0000)]
Revert "Enhance SCEV to compute the trip count for some loops with unknown stride."

This reverts commit r278731. It caused http://crbug.com/638314

llvm-svn: 278853

8 years agoRevert "[compiler-rt] Allow c++ abi to be explictly disabled in cmake configuration"
Francis Ricci [Tue, 16 Aug 2016 20:52:22 +0000 (20:52 +0000)]
Revert "[compiler-rt] Allow c++ abi to be explictly disabled in cmake configuration"

This reverts commit dbb6e905684e2e9488887b26c02ee8881849f09f.

llvm-svn: 278852

8 years ago[OpenCL] AMDGPU: Add extensions cl_amd_media_ops and cl_amd_media_ops2
Yaxun Liu [Tue, 16 Aug 2016 20:49:49 +0000 (20:49 +0000)]
[OpenCL] AMDGPU: Add extensions cl_amd_media_ops and cl_amd_media_ops2

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

llvm-svn: 278851

8 years ago[CMake] Fixing typo in Info.plist generation
Chris Bieneman [Tue, 16 Aug 2016 20:49:49 +0000 (20:49 +0000)]
[CMake] Fixing typo in Info.plist generation

This is causing an error in the generation of the clang info plist.

llvm-svn: 278850

8 years ago[CMake] [Apple Cache] Set CLANG_VENDOR_UTI for Apple builds
Chris Bieneman [Tue, 16 Aug 2016 20:44:58 +0000 (20:44 +0000)]
[CMake] [Apple Cache] Set CLANG_VENDOR_UTI for Apple builds

This is just a minor update to the Apple packaging configuration.

llvm-svn: 278849

8 years ago[compiler-rt] Allow c++ abi to be explictly disabled in cmake configuration
Francis Ricci [Tue, 16 Aug 2016 20:39:10 +0000 (20:39 +0000)]
[compiler-rt] Allow c++ abi to be explictly disabled in cmake configuration

Summary: This will allow for the sanitizers to be used when c++ abi is unavailable.

Reviewers: samsonov, beanz, pcc, rnk

Subscribers: llvm-commits, kubabrecka, compnerd, dberris

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

llvm-svn: 278848

8 years agoTailDuplicator: Use range loops
Matt Arsenault [Tue, 16 Aug 2016 20:38:05 +0000 (20:38 +0000)]
TailDuplicator: Use range loops

llvm-svn: 278847

8 years ago[AArch64] Adjust the scheduling model for Exynos M1.
Evandro Menezes [Tue, 16 Aug 2016 20:35:01 +0000 (20:35 +0000)]
[AArch64] Adjust the scheduling model for Exynos M1.

Refine the model for the FP division unit.

llvm-svn: 278846

8 years ago[AArch64] Adjust the scheduling model for Exynos M1.
Evandro Menezes [Tue, 16 Aug 2016 20:34:58 +0000 (20:34 +0000)]
[AArch64] Adjust the scheduling model for Exynos M1.

Refine the model for the integer division unit.

llvm-svn: 278845

8 years agoAMDGPU: Remove excessive padding from ImmOp and RegOp.
Matt Arsenault [Tue, 16 Aug 2016 20:28:06 +0000 (20:28 +0000)]
AMDGPU: Remove excessive padding from ImmOp and RegOp.

The structs ImmOp and RegOp are in AArch64AsmParser.cpp (inside
anonymous namespace).
This diff changes the order of fields and removes the excessive padding
(8 bytes).

Patch by Alexander Shaposhnikov

llvm-svn: 278844

8 years agoFix an instance of -Wmicrosoft-enum-value by making the enum unsigned
Reid Kleckner [Tue, 16 Aug 2016 20:22:49 +0000 (20:22 +0000)]
Fix an instance of -Wmicrosoft-enum-value by making the enum unsigned

llvm-svn: 278843

8 years agoTry to work around an MSVC 2013 bug around defaulted default ctors
Reid Kleckner [Tue, 16 Aug 2016 20:20:56 +0000 (20:20 +0000)]
Try to work around an MSVC 2013 bug around defaulted default ctors

An UnresolvedSetIterator() is supposed to be zeroed out, but MSVC 2013
does not do that.

llvm-svn: 278842

8 years ago[BranchFolding] Change a test case of r278575.
Haicheng Wu [Tue, 16 Aug 2016 20:06:25 +0000 (20:06 +0000)]
[BranchFolding] Change a test case of r278575.

Rename the operands to make the test less brittle.

llvm-svn: 278841

8 years ago[MBP] do not reorder and move up loop latch block
Sjoerd Meijer [Tue, 16 Aug 2016 19:50:33 +0000 (19:50 +0000)]
[MBP] do not reorder and move up loop latch block

Do not reorder and move up a loop latch block before a loop header
when optimising for size because this will generate an extra
unconditional branch.

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

llvm-svn: 278840

8 years ago[libFuzzer] new experimental feature: value profiling. Profiles values that affect...
Kostya Serebryany [Tue, 16 Aug 2016 19:33:51 +0000 (19:33 +0000)]
[libFuzzer] new experimental feature: value profiling. Profiles values that affect control flow and treats new values as new coverage.

llvm-svn: 278839

8 years agoRemove excessive padding from LineNoCacheTy
Benjamin Kramer [Tue, 16 Aug 2016 19:20:10 +0000 (19:20 +0000)]
Remove excessive padding from LineNoCacheTy

The struct LineNoCacheTy is in SourceMgr.cpp inside anonymous namespace.
This diff changes the order of fields and removes the excessive padding
(8 bytes).

Patch by Alexander Shaposhnikov!

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

llvm-svn: 278838

8 years agoMake MDNode::intersect faster than O(n * m)
David Majnemer [Tue, 16 Aug 2016 18:48:37 +0000 (18:48 +0000)]
Make MDNode::intersect faster than O(n * m)

It is pretty easy to get it down to O(nlogn + mlogm).  This
implementation has the added benefit of automatically deduplicating
entries between the two sets.

llvm-svn: 278837

8 years agoDon't passively concatenate MDNodes
David Majnemer [Tue, 16 Aug 2016 18:48:34 +0000 (18:48 +0000)]
Don't passively concatenate MDNodes

I have audited all the callers of concatenate and none require duplicate
entries to service concatenation.
These duplicates serve no purpose but to needlessly embiggen the IR.

N.B. Layering getMostGenericAliasScope on top of concatenate makes it
O(nlogn + mlogm) instead of O(n*m).

llvm-svn: 278836

8 years agosanitizer_common: Fix warning
Matthias Braun [Tue, 16 Aug 2016 18:28:55 +0000 (18:28 +0000)]
sanitizer_common: Fix warning

Clang added warning that taking the address of a packed struct member
possibly yields an unaligned pointer. This case is benign because
the pointer gets casted to an uptr and not used for unaligned accesses.
Add an intermediate cast to char* until this warning is improved (see
also https://reviews.llvm.org/D20561)

llvm-svn: 278835

8 years ago[Driver] Remove break after return. NFCI.
Davide Italiano [Tue, 16 Aug 2016 18:23:44 +0000 (18:23 +0000)]
[Driver] Remove break after return. NFCI.

llvm-svn: 278834

8 years ago[StreamExecutor] Rename StreamExecutor to Executor
Jason Henline [Tue, 16 Aug 2016 18:18:32 +0000 (18:18 +0000)]
[StreamExecutor] Rename StreamExecutor to Executor

Summary: No functional changes just renaming this class for better readability.

Reviewers: jlebar

Subscribers: jprice, parallel_libs-commits

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

llvm-svn: 278833