platform/upstream/llvm.git
8 years agoValueMapper: Separate mapping of distinct and uniqued nodes (again)
Duncan P. N. Exon Smith [Sat, 16 Apr 2016 21:44:08 +0000 (21:44 +0000)]
ValueMapper: Separate mapping of distinct and uniqued nodes (again)

Since the result of a mapped distinct node is known up front, it's more
efficient to map them separately from uniqued nodes.  This commit pulls
them out of the post-order traversal and stores them in a worklist to be
remapped at the top-level.

This is essentially reapplying r244181 ("ValueMapper: Rotate distinct
node remapping algorithm") to the new iterative algorithm from r265456
("ValueMapper: Rewrite Mapper::mapMetadata without recursion").

Now that the traversal logic only handles uniqued MDNodes, it's much
simpler to inline it all into MDNodeMapper::createPOT (I've killed the
MDNodeMapper::push and MDNodeMapper::tryToPop helpers and localized the
traversal worklist).

The resulting high-level algorithm for MDNodeMapper::map now looks like
this:

  - Distinct nodes are immediately mapped and added to
    MDNodeMapper::DistinctWorklist using MDNodeMapper::mapDistinctNode.

  - Uniqued nodes are mapped via MDNodeMapper::mapTopLevelUniquedNode,
    which traverses the transitive uniqued subgraph of a node to
    calculate uniqued node mappings in bulk.

      - This is a simplified version of MDNodeMapper::map from before
        this commit (originally r265456) that doesn't traverse through
        any distinct nodes.

      - Distinct nodes are added to MDNodeMapper::DistinctWorklist via
        MDNodeMapper::mapDistinctNode.

      - This uses MDNodeMapper::createPOT to fill a
        MDNodeMapper::UniquedGraph (a post-order traversal and side
        table), UniquedGraph::propagateChanges to track which uniqued
        nodes need to change, and MDNodeMapper::mapNodesInPOT to create
        the uniqued nodes.

      - Placeholders for forward references are now only needed when
        there's a uniquing cycle (a cycle of uniqued nodes unbroken by
        distinct nodes).  This is the key functionality change that
        we're reintroducing (from r244181).  As of r265456, a temporary
        forward reference might be needed for any cycle that involved
        uniqued nodes.

  - After mapping the first node appropriately, MDNodeMapper::map works
    through MDNodeMapper::DistinctWorklist.  For each distinct node, its
    operands are remapped with MDNodeMapper::mapDistinctNode and
    MDNodeMapper::mapTopLevelUniquedNode until all nodes have been
    mapped.

Sadly there's nothing observable I can test here; no real functionality
change, just a compile-time speedup from reduced malloc traffic.

llvm-svn: 266537

8 years agoValueMapper: Only put cyclic nodes into CyclicNodes, NFCI
Duncan P. N. Exon Smith [Sat, 16 Apr 2016 21:09:53 +0000 (21:09 +0000)]
ValueMapper: Only put cyclic nodes into CyclicNodes, NFCI

As a minor fixup to r266258, only track nodes that needed a placeholder
in CyclicNodes in MDNodeMapper::mapUniquedNodes.  There should be no
observable functionality change, just some local memory savings because
CyclicNodes only needs to grow to accommodate nodes that are actually
involved in cycles.  (This was the original intent of r266258, or else
the vector would have been called "ChangedNodes".)

llvm-svn: 266536

8 years ago[X86][AVX] Add shuffle combine tests for MOVDDUP/MOVSHDUP/MOVSLDUP
Simon Pilgrim [Sat, 16 Apr 2016 20:30:59 +0000 (20:30 +0000)]
[X86][AVX] Add shuffle combine tests for MOVDDUP/MOVSHDUP/MOVSLDUP

128, 256 and 512 bit implementations (some not yet supported by combineX86ShuffleChain)

llvm-svn: 266535

8 years ago[X86] Use ternary operator to reduce code slightly. NFC
Craig Topper [Sat, 16 Apr 2016 19:09:32 +0000 (19:09 +0000)]
[X86] Use ternary operator to reduce code slightly. NFC

llvm-svn: 266534

8 years ago[X86][XOP] Added VPPERM constant mask decoding and target shuffle combining support
Simon Pilgrim [Sat, 16 Apr 2016 17:52:07 +0000 (17:52 +0000)]
[X86][XOP] Added VPPERM constant mask decoding and target shuffle combining support

Added additional test that peeks through bitcast to v16i8 mask

llvm-svn: 266533

8 years agoAdd missing #include to fix build
Vedant Kumar [Sat, 16 Apr 2016 17:39:40 +0000 (17:39 +0000)]
Add missing #include to fix build

Failing bot:
http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental/23112/

llvm-svn: 266532

8 years ago[X86][XOP] More VPPERM shuffle mask decode tests
Simon Pilgrim [Sat, 16 Apr 2016 16:37:21 +0000 (16:37 +0000)]
[X86][XOP] More VPPERM shuffle mask decode tests

As requested by D18441

llvm-svn: 266531

8 years agoFix cmake build after r266524.
Oleksiy Vyalov [Sat, 16 Apr 2016 16:29:17 +0000 (16:29 +0000)]
Fix cmake build after r266524.

llvm-svn: 266530

8 years agoValueMapper: Fix unused var warning. NFC
Simon Atanasyan [Sat, 16 Apr 2016 11:49:40 +0000 (11:49 +0000)]
ValueMapper: Fix unused var warning. NFC

llvm-svn: 266529

8 years agoRemove links to deleted TODOs.
Simon Atanasyan [Sat, 16 Apr 2016 11:11:56 +0000 (11:11 +0000)]
Remove links to deleted TODOs.

llvm-svn: 266528

8 years ago[ELF] Include Twine.h header to restore LLD build after r266524. NFC
Simon Atanasyan [Sat, 16 Apr 2016 10:58:45 +0000 (10:58 +0000)]
[ELF] Include Twine.h header to restore LLD build after r266524. NFC

llvm-svn: 266527

8 years agoRecommitted 266457 with fix:
George Rimar [Sat, 16 Apr 2016 10:10:32 +0000 (10:10 +0000)]
Recommitted 266457 with fix:
* Do script driven layout only if SECTIONS section exist.

Initial commit message:

[ELF] - Implemented basic location counter support.

This patch implements location counter support.
It also separates assign addresses for sections to assignAddressesScript() if it scipt exists.

Main testcase is test/ELF/linkerscript-locationcounter.s, It contains some work with location counter. It is basic now.
Implemented location counter assignment and '+' operations.

Patch by myself with LOTS of comments and design suggestions from Rui Ueyama.

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

llvm-svn: 266526

8 years agoAdd missing headers (fix build after headers cleanup in LLVM)
Mehdi Amini [Sat, 16 Apr 2016 08:14:10 +0000 (08:14 +0000)]
Add missing headers (fix build after headers cleanup in LLVM)

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

8 years agoRemove some unneeded headers and replace some headers with forward class declarations...
Mehdi Amini [Sat, 16 Apr 2016 07:51:28 +0000 (07:51 +0000)]
Remove some unneeded headers and replace some headers with forward class declarations (NFC)

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

Patch by Eugene Kosov <claprix@yandex.ru>

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

8 years agoAdd SVN version to libLLVMLTO
Mehdi Amini [Sat, 16 Apr 2016 07:33:14 +0000 (07:33 +0000)]
Add SVN version to libLLVMLTO

Summary: For Incremental LTO, we need to make sure that an old
cache entry is not used when incrementally re-linking with a new
libLTO.
Adding a global LLVM_REVISION in llvm-config.h would for to
rebuild/relink the world for every "git pull"/"svn update".
So instead only libLTO is made dependent on the VCS and will
be rebuilt (and the dependent binaries relinked, i.e. as of
today: libLTO.dylib and llvm-lto).

Reviewers: beanz

Subscribers: llvm-commits

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

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

8 years agoReplace hardcoded comment at 'lit.site.cfg.in'
Alex Denisov [Sat, 16 Apr 2016 07:14:05 +0000 (07:14 +0000)]
Replace hardcoded comment at 'lit.site.cfg.in'

At the moment almost every lit.site.cfg.in contains two lines comment:

  ## Autogenerated by LLVM/Clang configuration.
  # Do not edit!

The patch adds variable LIT_SITE_CFG_IN_HEADER, that is replaced from
configure_lit_site_cfg with the note and some useful information.

llvm-svn: 266522

8 years agoReplace hardcoded comment at 'lit.site.cfg.in'
Alex Denisov [Sat, 16 Apr 2016 07:09:39 +0000 (07:09 +0000)]
Replace hardcoded comment at 'lit.site.cfg.in'

At the moment almost every lit.site.cfg.in contains two lines comment:

  ## Autogenerated by LLVM/Clang configuration.
  # Do not edit!

The patch adds variable LIT_SITE_CFG_IN_HEADER, that is replaced from
configure_lit_site_cfg with the note and some useful information.

llvm-svn: 266521

8 years agoReplace hardcoded comment at 'lit.site.cfg.in'
Alex Denisov [Sat, 16 Apr 2016 07:03:45 +0000 (07:03 +0000)]
Replace hardcoded comment at 'lit.site.cfg.in'

At the moment almost every lit.site.cfg.in contains two lines comment:

  ## Autogenerated by LLVM/Clang configuration.
  # Do not edit!

The patch adds variable LIT_SITE_CFG_IN_HEADER, that is replaced from
configure_lit_site_cfg with the note and some useful information.

llvm-svn: 266520

8 years agoThinLTO: Move the ODR resolution to be based purely on the summary.
Mehdi Amini [Sat, 16 Apr 2016 07:02:16 +0000 (07:02 +0000)]
ThinLTO: Move the ODR resolution to be based purely on the summary.

This is a requirement for the cache handling in D18494

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

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

8 years agoReplace hardcoded comment at 'lit.site.cfg.in'
Alex Denisov [Sat, 16 Apr 2016 07:01:42 +0000 (07:01 +0000)]
Replace hardcoded comment at 'lit.site.cfg.in'

At the moment almost every lit.site.cfg.in contains two lines comment:

  ## Autogenerated by LLVM/Clang configuration.
  # Do not edit!

The patch adds variable LIT_SITE_CFG_IN_HEADER, that is replaced from
configure_lit_site_cfg with the note and some useful information.

llvm-svn: 266518

8 years agoThinLTO: Make aliases explicit in the summary
Mehdi Amini [Sat, 16 Apr 2016 06:56:44 +0000 (06:56 +0000)]
ThinLTO: Make aliases explicit in the summary

To be able to work accurately on the reference graph when taking
decision about internalizing, promoting, renaming, etc. We need
to have the alias information explicit.

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

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

8 years agoReplace hardcoded comment at 'lit.site.cfg.in'
Alex Denisov [Sat, 16 Apr 2016 06:54:46 +0000 (06:54 +0000)]
Replace hardcoded comment at 'lit.site.cfg.in'

At the moment almost every lit.site.cfg.in contains two lines comment:

  ## Autogenerated by LLVM/Clang configuration.
  # Do not edit!

The patch adds variable LIT_SITE_CFG_IN_HEADER, that is replaced from
configure_lit_site_cfg with the note and some useful information.

llvm-svn: 266516

8 years agoReplace hardcoded comment at 'lit.site.cfg.in'
Alex Denisov [Sat, 16 Apr 2016 06:47:41 +0000 (06:47 +0000)]
Replace hardcoded comment at 'lit.site.cfg.in'

At the moment almost every lit.site.cfg.in contains two lines comment:

## Autogenerated by LLVM/Clang configuration.
# Do not edit!

The patch adds variable LIT_SITE_CFG_IN_HEADER, that is replaced from
configure_lit_site_cfg with the note and some useful information.

llvm-svn: 266515

8 years agoDo not modify a cl::opt programmatically, global mutable state is evil.
Mehdi Amini [Sat, 16 Apr 2016 04:58:30 +0000 (04:58 +0000)]
Do not modify a cl::opt programmatically, global mutable state is evil.

Found by TSAN on ThinLTO.

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

8 years agoValueMapper: Stop memoizing ConstantAsMetadata
Duncan P. N. Exon Smith [Sat, 16 Apr 2016 03:39:44 +0000 (03:39 +0000)]
ValueMapper: Stop memoizing ConstantAsMetadata

Stop memoizing ConstantAsMetadata in ValueMapper::mapMetadata.  Now we
have to recompute it, but these metadata aren't particularly common, and
it restricts the lifetime of the Metadata map unnecessarily.

(The motivation is that I have a patch which uses a single Metadata map
for the lifetime of IRMover.  Mehdi profiled r266446 with the patch
applied and we saw a pretty big speedup in lib/Linker.)

llvm-svn: 266513

8 years ago[DebugInfo] Correct the assertion introduced in r266509 + update test.
Davide Italiano [Sat, 16 Apr 2016 03:23:48 +0000 (03:23 +0000)]
[DebugInfo] Correct the assertion introduced in r266509 + update test.

llvm-svn: 266512

8 years agoAdd missing override keyword to silence -Winconsistent-missing-override. NFC
Craig Topper [Sat, 16 Apr 2016 02:42:03 +0000 (02:42 +0000)]
Add missing override keyword to silence -Winconsistent-missing-override. NFC

llvm-svn: 266511

8 years agoReapply "ValueMapper: Eliminate cross-file co-recursion, NFC"
Duncan P. N. Exon Smith [Sat, 16 Apr 2016 02:29:55 +0000 (02:29 +0000)]
Reapply "ValueMapper: Eliminate cross-file co-recursion, NFC"

This reverts commit r266507, reapplying r266503 (and r266505
"ValueMapper: Use API from r266503 in unit tests, NFC") completely
unchanged.

I reverted because of a bot failure here:
  http://lab.llvm.org:8011/builders/lld-x86_64-freebsd/builds/16810/

However, looking more closely, the failure was from a host-compiler
crash (clang 3.7.1) when building:
  lib/CodeGen/AsmPrinter/CMakeFiles/LLVMAsmPrinter.dir/DwarfAccelTable.cpp.o

I didn't modify that file, or anything it includes, with that commit.

The next build (which hadn't picked up my revert) got past it:
  http://lab.llvm.org:8011/builders/lld-x86_64-freebsd/builds/16811/

I think this was just unfortunate timing.  I suppose the bot must be
flakey.

llvm-svn: 266510

8 years ago[DebugInfo] Reduce size of DILocalVariable from 40 to 32 bytes.
Davide Italiano [Sat, 16 Apr 2016 02:27:56 +0000 (02:27 +0000)]
[DebugInfo] Reduce size of DILocalVariable from 40 to 32 bytes.

This significantly contributes to peak memory usage during a
LTO Release+DebugInfo build of clang. In my profile the peak usage
is around 164MB before this change and ~130MB after.

llvm-svn: 266509

8 years agoAMDGPU: Enable LocalStackSlotAllocation pass
Matt Arsenault [Sat, 16 Apr 2016 02:13:37 +0000 (02:13 +0000)]
AMDGPU: Enable LocalStackSlotAllocation pass

This resolves more frame indexes early and folds
the immediate offsets into the scratch mubuf instructions.

This cleans up a lot of the mess that's currently emitted,
such as emitting add 0s and repeatedly initializing the same
register to 0 when spilling.

llvm-svn: 266508

8 years agoRevert "ValueMapper: Eliminate cross-file co-recursion, NFC"
Duncan P. N. Exon Smith [Sat, 16 Apr 2016 02:05:33 +0000 (02:05 +0000)]
Revert "ValueMapper: Eliminate cross-file co-recursion, NFC"

This reverts commit r266503, in case it's the root cause of this bot
failure:

  http://lab.llvm.org:8011/builders/lld-x86_64-freebsd/builds/16810

I'm also reverting r266505 -- "ValueMapper: Use API from r266503 in unit
tests, NFC" -- since it's in the way.

llvm-svn: 266507

8 years agoAMDGPU: Use s_addk_i32 / s_mulk_i32
Matt Arsenault [Sat, 16 Apr 2016 01:46:49 +0000 (01:46 +0000)]
AMDGPU: Use s_addk_i32 / s_mulk_i32

llvm-svn: 266506

8 years agoValueMapper: Use API from r266503 in unit tests, NFC
Duncan P. N. Exon Smith [Sat, 16 Apr 2016 01:40:24 +0000 (01:40 +0000)]
ValueMapper: Use API from r266503 in unit tests, NFC

I'm not in a hurry to migrate all the users, but the unit tests at least
should use the new API.

llvm-svn: 266505

8 years ago[LTO] Don't crash on a BitcodeFile without DataLayout.
Davide Italiano [Sat, 16 Apr 2016 01:33:33 +0000 (01:33 +0000)]
[LTO] Don't crash on a BitcodeFile without DataLayout.

Emit an error instead.

llvm-svn: 266504

8 years agoValueMapper: Eliminate cross-file co-recursion, NFC
Duncan P. N. Exon Smith [Sat, 16 Apr 2016 01:29:08 +0000 (01:29 +0000)]
ValueMapper: Eliminate cross-file co-recursion, NFC

Eliminate co-recursion of Mapper::mapValue through
ValueMaterializer::materializeInitFor, through a major redesign of the
ValueMapper.cpp interface.

  - Expose a ValueMapper class that controls the entry points to the
    mapping algorithms.
  - Change IRLinker to use ValueMapper directly, rather than
    llvm::RemapInstruction, llvm::MapValue, etc.
  - Use (e.g.) ValueMapper::scheduleMapGlobalInit to add mapping work to
    a worklist in ValueMapper instead of recursing.

There were two fairly major complications.

Firstly, IRLinker::linkAppendingVarProto incorporates an on-the-fly IR
ugprade that I had to split apart.  Long-term, this upgrade should be
done in the bitcode reader (and we should only accept the "new" form),
but for now I've just made it work and added a FIXME.  The hold-op is
that we need to deprecate C API that relies on this.

Secondly, IRLinker has special logic to correctly implement aliases with
comdats, and uses two ValueToValueMapTy instances and two
ValueMaterializers.  I supported this by allowing clients to register an
alternate mapping context, whose MCID can be passed in when scheduling
new work.

While out of scope for this commit, it should now be straightforward to
remove recursion from Mapper::mapValue.

llvm-svn: 266503

8 years agoUpdate and fix LLVM_ENABLE_MODULES:
Richard Smith [Sat, 16 Apr 2016 00:48:58 +0000 (00:48 +0000)]
Update and fix LLVM_ENABLE_MODULES:

1) We need to add this flag prior to adding any other, in case the user has
specified a -fmodule-cache-path= flag in their custom CXXFLAGS. Such a flag
causes -Werror builds to fail, and thus all config checks fail, until we add
the corresponding -fmodules flag. The modules selfhost bot does this, for
instance.

2) Delete module maps that were putting .cpp files into modules.

3) Enable -fmodules-local-submodule-visibility, to get proper module
visibility rules applied across submodules of the same module. Disable
-fmodules for C builds, since that flag is not available there.

llvm-svn: 266502

8 years ago[modules] Don't expose *intrin.h headers that cannot be included standalone as
Richard Smith [Sat, 16 Apr 2016 00:46:26 +0000 (00:46 +0000)]
[modules] Don't expose *intrin.h headers that cannot be included standalone as
separate modules. These cause build breakage with -fmodules-local-submodule-visibility.

llvm-svn: 266501

8 years agoAdd some missing #includes, found by C++ modules selfhost.
Richard Smith [Sat, 16 Apr 2016 00:42:37 +0000 (00:42 +0000)]
Add some missing #includes, found by C++ modules selfhost.

llvm-svn: 266500

8 years ago[sanitizers] Fixup to r266494; the Unit test should not run on Windows
Anna Zaks [Sat, 16 Apr 2016 00:32:16 +0000 (00:32 +0000)]
[sanitizers] Fixup to r266494; the Unit test should not run on Windows

The test is failing on Windows because we do not have a definition for
DemangleSwiftAndCXX nor DemangleCXXABI, which I am replacing, on Windows.

llvm-svn: 266499

8 years agoTeach map/unordered_map how to optimize 'emplace(Key, T)'.
Eric Fiselier [Sat, 16 Apr 2016 00:23:12 +0000 (00:23 +0000)]
Teach map/unordered_map how to optimize 'emplace(Key, T)'.

In cases where emplace is called with two arguments and the first one
matches the key_type we can Key to check for duplicates before allocating.

This patch expands on work done by dexonsmith@apple.com.

llvm-svn: 266498

8 years ago[sanitizers] Fixup r266494; make it build on Linux.
Anna Zaks [Sat, 16 Apr 2016 00:12:46 +0000 (00:12 +0000)]
[sanitizers] Fixup r266494; make it build on Linux.

llvm-svn: 266497

8 years ago[CUDA] Raise an error if the CUDA install can't be found.
Justin Lebar [Sat, 16 Apr 2016 00:11:11 +0000 (00:11 +0000)]
[CUDA] Raise an error if the CUDA install can't be found.

Summary:
Without this change, we silently proceed on without including
__clang_cuda_runtime_wrapper.h.  This leads to very strange behavior --
you say you're compiling CUDA code, but e.g. __device__ is not defined!

Reviewers: tra

Subscribers: cfe-commits

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

llvm-svn: 266496

8 years agoImprove diagnostic for the case when a non-defined function-like macro is used
Richard Smith [Sat, 16 Apr 2016 00:07:09 +0000 (00:07 +0000)]
Improve diagnostic for the case when a non-defined function-like macro is used
in a preprocessor constant expression.

llvm-svn: 266495

8 years ago[sanitizers] Teach the internal demangler about Swift names
Anna Zaks [Fri, 15 Apr 2016 23:51:00 +0000 (23:51 +0000)]
[sanitizers] Teach the internal demangler about Swift names

Add support for Swift names when symbolicating sanitizer traces. This is
now relevant since TSan and ASan support have been added to Swift on OS X.

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

llvm-svn: 266494

8 years agoLinker: Remove an unnecessary local variable in for loop, NFC
Duncan P. N. Exon Smith [Fri, 15 Apr 2016 23:32:44 +0000 (23:32 +0000)]
Linker: Remove an unnecessary local variable in for loop, NFC

Reduces changes in a follow-up commit.

llvm-svn: 266493

8 years agoMake this header include the header it depends on, rather than trying to include...
Richard Smith [Fri, 15 Apr 2016 23:30:57 +0000 (23:30 +0000)]
Make this header include the header it depends on, rather than trying to include itself. Found by C++ modules build.

llvm-svn: 266492

8 years agoExtract key to avoid preemptive mallocs in insert/emplace in associative containers
Eric Fiselier [Fri, 15 Apr 2016 23:27:27 +0000 (23:27 +0000)]
Extract key to avoid preemptive mallocs in insert/emplace in associative containers

Summary: This patch applies Duncan's work on __hash_table to __tree.

Reviewers: mclow.lists, dexonsmith

Subscribers: dexonsmith, cfe-commits

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

llvm-svn: 266491

8 years agoValueMapper: Hide Mapper::VM behind an accessor, NFC
Duncan P. N. Exon Smith [Fri, 15 Apr 2016 23:18:43 +0000 (23:18 +0000)]
ValueMapper: Hide Mapper::VM behind an accessor, NFC

Change Mapper::VM to a pointer and add a `getVM()` accessor for it.
While this has no functionality change, it minimizes the diff on an
upcoming patch that allows switching between instances of
ValueToValueMapTy on a single Mapper instance.

llvm-svn: 266490

8 years agoDon't skip splitSeparateComponents in eliminateDeadDefs for HoistSpillHelper::hoistAl...
Wei Mi [Fri, 15 Apr 2016 23:16:44 +0000 (23:16 +0000)]
Don't skip splitSeparateComponents in eliminateDeadDefs for HoistSpillHelper::hoistAllSpills.

Because HoistSpillHelper::hoistAllSpills is called in postOptimization, before the
patch we didn't want LiveRangeEdit::eliminateDeadDefs to call splitSeparateComponents
and generate unassigned new vregs. However, skipping splitSeparateComponents will make
verify-machineinstrs unhappy, so I remove the early return, and use
HoistSpillHelper::LRE_DidCloneVirtReg to assign physreg/stackslot for those new vregs.

In addition, some code reorganization to make class HoistSpillHelper privately inheriting
from LiveRangeEdit::Delegate possible. This is to be consistent with class RAGreedy and
class RegisterCoalescer.

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

llvm-svn: 266489

8 years agoAdd ProfileData to required_libraries
Easwaran Raman [Fri, 15 Apr 2016 23:08:52 +0000 (23:08 +0000)]
Add ProfileData to required_libraries

This should fix ppc64be build breakage due to r266477

llvm-svn: 266488

8 years ago[LTO] Add datalayout to test to prevent an assertion in Debug mode.
Davide Italiano [Fri, 15 Apr 2016 22:58:57 +0000 (22:58 +0000)]
[LTO] Add datalayout to test to prevent an assertion in Debug mode.

While here, run this test only on x86.

llvm-svn: 266487

8 years ago[cfi] Support explicit sections for functions in cfi-icall.
Evgeniy Stepanov [Fri, 15 Apr 2016 22:55:38 +0000 (22:55 +0000)]
[cfi] Support explicit sections for functions in cfi-icall.

Allow explicit section for indirectly called functions in cfi-icall.
Jumptables for functions in the same type class must be contiguous, so they
always go to the default text section.

Fixes PR25079.

llvm-svn: 266486

8 years agoRevert r266457: "[ELF] - Implemented basic location counter support."
Rui Ueyama [Fri, 15 Apr 2016 22:39:27 +0000 (22:39 +0000)]
Revert r266457: "[ELF] - Implemented basic location counter support."

This reverts commit r266457 as it breaks "hello world" both on
Linux and FreeBSD.

llvm-svn: 266485

8 years ago[LTO] Implement parallel Codegen for LTO using splitCodeGen.
Davide Italiano [Fri, 15 Apr 2016 22:38:10 +0000 (22:38 +0000)]
[LTO] Implement parallel Codegen for LTO using splitCodeGen.

Parallelism level can be chosen using the new --lto-jobs=K option
where K is the number of threads used for CodeGen. It currently
defaults to 1.

llvm-svn: 266484

8 years ago[sanitizer] [SystemZ] Enable UBSan.
Marcin Koscielnicki [Fri, 15 Apr 2016 22:25:04 +0000 (22:25 +0000)]
[sanitizer] [SystemZ] Enable UBSan.

sanitizer_common is now in good enough shape on s390x to support UBSan
- all tests passing.  Let's enable it.

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

llvm-svn: 266483

8 years ago[sanitizers] [SystemZ] Introduce sanitizer_linux_s390.cc.
Marcin Koscielnicki [Fri, 15 Apr 2016 22:11:10 +0000 (22:11 +0000)]
[sanitizers] [SystemZ] Introduce sanitizer_linux_s390.cc.

This file will contain s390-specific code.  For now, let's move the s390
version of internal_mmap here.

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

llvm-svn: 266482

8 years agoConvert this sample-based-profiling testcase to use a NoDebug CU.
Adrian Prantl [Fri, 15 Apr 2016 22:05:38 +0000 (22:05 +0000)]
Convert this sample-based-profiling testcase to use a NoDebug CU.

llvm-svn: 266481

8 years ago[libFuzzer] add a better warning for command line flags with -- (two dashes)
Kostya Serebryany [Fri, 15 Apr 2016 21:56:29 +0000 (21:56 +0000)]
[libFuzzer] add a better warning for command line flags with -- (two dashes)

llvm-svn: 266480

8 years agoSwitch lowering: don't add incoming PHI values from skipped bit test MBB's (PR27135)
Hans Wennborg [Fri, 15 Apr 2016 21:45:30 +0000 (21:45 +0000)]
Switch lowering: don't add incoming PHI values from skipped bit test MBB's (PR27135)

After r245976, LLVM will skip the last bit test case if knows it will always be
true. However, we would still erroneously update PHI nodes with incoming values
from the MBB that would perform the final bit test, causing -verify-machineinstrs
to fail.

llvm-svn: 266479

8 years agoSelectionDAGISel: rangeify a loop
Hans Wennborg [Fri, 15 Apr 2016 21:45:09 +0000 (21:45 +0000)]
SelectionDAGISel: rangeify a loop

llvm-svn: 266478

8 years agoReplace the use of MaxFunctionCount module flag
Easwaran Raman [Fri, 15 Apr 2016 21:39:58 +0000 (21:39 +0000)]
Replace the use of MaxFunctionCount module flag

Adds an interface to get ProfileSummary for a module and makes InlineCost use ProfileSummary to get max function count.

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

llvm-svn: 266477

8 years ago[libFuzzer] menion the git mirror in the docs
Kostya Serebryany [Fri, 15 Apr 2016 21:10:27 +0000 (21:10 +0000)]
[libFuzzer] menion the git mirror in the docs

llvm-svn: 266476

8 years agoUpdate two more test cases for r266445+r266446 II
Tobias Grosser [Fri, 15 Apr 2016 21:02:35 +0000 (21:02 +0000)]
Update two more test cases for r266445+r266446 II

llvm-svn: 266475

8 years agoUpdate two more test cases for r266445+r266446
Tobias Grosser [Fri, 15 Apr 2016 20:56:17 +0000 (20:56 +0000)]
Update two more test cases for r266445+r266446

llvm-svn: 266474

8 years agoUpdate debug metadata after LLVM commits r266445+r266446
Tobias Grosser [Fri, 15 Apr 2016 20:51:27 +0000 (20:51 +0000)]
Update debug metadata after LLVM commits r266445+r266446

llvm-svn: 266473

8 years ago[mips] More range-based for loops. NFC.
Vasileios Kalintiris [Fri, 15 Apr 2016 20:43:17 +0000 (20:43 +0000)]
[mips] More range-based for loops. NFC.

There are still a couple more inside the MIPS target. I opted for a single
commit in order to avoid spamming the list.

llvm-svn: 266472

8 years ago[mips] Use range-based for loops and simplify slightly the code. NFC.
Vasileios Kalintiris [Fri, 15 Apr 2016 20:18:48 +0000 (20:18 +0000)]
[mips] Use range-based for loops and simplify slightly the code. NFC.

llvm-svn: 266471

8 years agoRevert "[sanitizer] [SystemZ] Abort if the kernel might be vulnerable to CVE-2016...
Marcin Koscielnicki [Fri, 15 Apr 2016 20:00:12 +0000 (20:00 +0000)]
Revert "[sanitizer] [SystemZ] Abort if the kernel might be vulnerable to CVE-2016-2143."

This reverts commit r266297.

llvm-svn: 266470

8 years ago[SystemZ] Call tryAddingSymbolicOperand in the disassembler
Ulrich Weigand [Fri, 15 Apr 2016 19:55:58 +0000 (19:55 +0000)]
[SystemZ] Call tryAddingSymbolicOperand in the disassembler

Use the tryAddingSymbolicOperand callback to attempt to present immediate
values in symbolic form when disassembling.  This is currently only used
for PC-relative immediates (which are most likely to be symbolic in the
SystemZ ISA).  Add new DecodeMethod types to allow distinguishing between
branch and non-branch instructions.

llvm-svn: 266469

8 years agoLet the DISubprogram in this test point to the right compile unit.
Adrian Prantl [Fri, 15 Apr 2016 19:38:14 +0000 (19:38 +0000)]
Let the DISubprogram in this test point to the right compile unit.

llvm-svn: 266468

8 years agoUpdate testcase to new debug metadata format.
Adrian Prantl [Fri, 15 Apr 2016 19:32:22 +0000 (19:32 +0000)]
Update testcase to new debug metadata format.

llvm-svn: 266467

8 years agoSimplify got handling.
Rafael Espindola [Fri, 15 Apr 2016 19:14:18 +0000 (19:14 +0000)]
Simplify got handling.

Each getRelExpr is now expected to return the correct got expression
instead of having Writer patch it up with needsGot.

llvm-svn: 266466

8 years ago[codeview] Dump char16_t and char32_t simple types
Reid Kleckner [Fri, 15 Apr 2016 18:26:45 +0000 (18:26 +0000)]
[codeview] Dump char16_t and char32_t simple types

llvm-svn: 266465

8 years agoARM: don't try to hoist constant RHS out of a division.
Tim Northover [Fri, 15 Apr 2016 18:17:18 +0000 (18:17 +0000)]
ARM: don't try to hoist constant RHS out of a division.

Divisions by a constant can be converted into multiplies which are usually
cheaper, but this isn't possible if the constant gets separated (particularly
in loops). Fix this by telling ConstantHoisting that the immediate in a DIV is
cheap.

I considered making the check generic, but neither AArch64 (strangely) nor x86
showed any benefit on the tests I had.

llvm-svn: 266464

8 years ago[clang-tidy] Add more detection rules for redundant c_str calls.
Etienne Bergeron [Fri, 15 Apr 2016 18:12:06 +0000 (18:12 +0000)]
[clang-tidy] Add more detection rules for redundant c_str calls.

Summary:
The string class contains methods which support receiving either a string literal or a string object.

For example, calls to append can receive either a char* or a string.
```
  string& append (const string& str);
  string& append (const char* s);
```

Which make these cases equivalent, and the .c_str() useless:
```
  std::string s = "123";
  str.append(s);
  str.append(s.c_str());
```

In these cases, removing .c_str()  doesn't provide any size or speed improvement.
It's only a readability issue.

If the string contains embedded NUL characters,  the string literal and the string
object won't produce the same semantic.

Reviewers: alexfh, sbenza

Subscribers: LegalizeAdulthood, aaron.ballman, chapuni, Eugene.Zelenko, cfe-commits

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

llvm-svn: 266463

8 years ago[AArch64] Add load/store pair instructions to getMemOpBaseRegImmOfsWidth().
Chad Rosier [Fri, 15 Apr 2016 18:09:10 +0000 (18:09 +0000)]
[AArch64] Add load/store pair instructions to getMemOpBaseRegImmOfsWidth().

This improves AA in the MI schduler when reason about paired instructions.

Phabricator Revision: http://reviews.llvm.org/D17098
PR26358

llvm-svn: 266462

8 years agoCleanup and guard tuple's constructor SFINAE. Fixes PR22806 and PR23256.
Eric Fiselier [Fri, 15 Apr 2016 18:05:59 +0000 (18:05 +0000)]
Cleanup and guard tuple's constructor SFINAE.  Fixes PR22806 and PR23256.

There are two main fixes in this patch.

First the constructor SFINAE was changed so that it's evaluated in two stages
where the first stage evaluates the "safe" SFINAE conditions and the second
evaluates the "dangerous" ones. The key is that the second stage is lazily
evaluated only if the first stage passes. This helps fix PR23256
(https://llvm.org/bugs/show_bug.cgi?id=23256).

The second fix is for PR22806 and LWG issue 2549. This fix applies
the suggested resolution to the LWG issue in order to prevent the construction
of dangling references. The SFINAE for this check is contained within
the _PreferTupleLikeConstructor alias template. The tuple-like constructors
are disabled whenever that trait returns false.

(https://llvm.org/bugs/show_bug.cgi?id=22806)
(http://cplusplus.github.io/LWG/lwg-active.html#2549)

llvm-svn: 266461

8 years agoRevert 266186 as it breaks anything that includes type_traits on some platforms
Nemanja Ivanovic [Fri, 15 Apr 2016 18:04:13 +0000 (18:04 +0000)]
Revert 266186 as it breaks anything that includes type_traits on some platforms

Since this patch provided support for the __float128 type but disabled it
on all platforms by default, some platforms can't compile type_traits with
-std=gnu++11 since there is a specialization with __float128.
This reverts the patch until D19125 is approved (i.e. we know which platforms
need this support enabled).

llvm-svn: 266460

8 years agoMerge duplicated cases. NFC.
Rafael Espindola [Fri, 15 Apr 2016 17:57:27 +0000 (17:57 +0000)]
Merge duplicated cases. NFC.

llvm-svn: 266459

8 years agoRevert "[Coverage] Prevent detection of false instantiations in case of macro expansion."
Igor Kudrin [Fri, 15 Apr 2016 17:53:48 +0000 (17:53 +0000)]
Revert "[Coverage] Prevent detection of false instantiations in case of macro expansion."

This reverts commit r266436 as it broke buildbot.

llvm-svn: 266458

8 years ago[ELF] - Implemented basic location counter support.
George Rimar [Fri, 15 Apr 2016 17:44:19 +0000 (17:44 +0000)]
[ELF] - Implemented basic location counter support.

This patch implements location counter support.
It also separates assign addresses for sections to assignAddressesScript() if it scipt exists.

Main testcase is test/ELF/linkerscript-locationcounter.s, It contains some work with location counter. It is basic now.
Implemented location counter assignment and '+' operations.

Patch by myself with LOTS of comments and design suggestions from Rui Ueyama.

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

llvm-svn: 266457

8 years ago[ParallelCG] Add a new splitCodeGen() API which takes a TargetMachineFactory.
Davide Italiano [Fri, 15 Apr 2016 17:34:32 +0000 (17:34 +0000)]
[ParallelCG] Add a new splitCodeGen() API which takes a TargetMachineFactory.

This is a recommit of r266390 with a fix that will allow tests to pass
(hopefully). Before we got a StringRef to M->getTargetTriple() and right
after we moved the Module so we were referencing a dangling object.

llvm-svn: 266456

8 years ago[Release Notes] mention Clang-tidy misc-multiple-statement-macro check.
Eugene Zelenko [Fri, 15 Apr 2016 17:32:19 +0000 (17:32 +0000)]
[Release Notes] mention Clang-tidy misc-multiple-statement-macro check.

llvm-svn: 266455

8 years ago[SystemZ] Fix large tests broken by conditional returns.
Marcin Koscielnicki [Fri, 15 Apr 2016 17:24:40 +0000 (17:24 +0000)]
[SystemZ] Fix large tests broken by conditional returns.

These were broken by D17339.

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

llvm-svn: 266454

8 years ago[LLD] Remove unwanted --check-prefix=CHECK from unit tests. NFC.
Mandeep Singh Grang [Fri, 15 Apr 2016 17:21:29 +0000 (17:21 +0000)]
[LLD] Remove unwanted --check-prefix=CHECK from unit tests. NFC.

Summary:
Removed unwanted --check-prefix=CHECK from the following unit tests:
      ELF/aarch64-gnu-ifunc.s
      ELF/gnu-ifunc-i386.s
      ELF/gnu-ifunc.s
      ELF/plt-i686.s

Patch by: Mandeep Singh Grang (mgrang)

Reviewers: rafael

Subscribers: aemerson

Projects: #lld

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

llvm-svn: 266453

8 years ago[InstCombine] Don't transform compares of calls to functions named fabs{f,l,}
David Majnemer [Fri, 15 Apr 2016 17:21:03 +0000 (17:21 +0000)]
[InstCombine] Don't transform compares of calls to functions named fabs{f,l,}

InstCombine wants to optimize compares of calls to fabs with zero.
However, we didn't have the necessary legality checking to verify that
the function call had the same behavior as fabs.

llvm-svn: 266452

8 years ago[clang-tidy] Add new checker for suspicious sizeof expressions
Etienne Bergeron [Fri, 15 Apr 2016 16:36:00 +0000 (16:36 +0000)]
[clang-tidy] Add new checker for suspicious sizeof expressions

Summary:
This check is finding suspicious cases of sizeof expression.

Sizeof expression is returning the size (in bytes) of a type or an
expression. Programmers often abuse or misuse this expression.

This checker is adding common set of patterns to detect some
of these bad constructs.

Some examples found by this checker:

R/packages/ifultools/ifultools/src/fra_neig.c
```
        /* free buffer memory */
        (void) mutil_free( dist_buff, sizeof( ctr * sizeof( double ) ) );
        (void) mutil_free( nidx_buff, sizeof( ctr * sizeof( sint32 ) ) );
```

graphviz/v2_20_2/lib/common/utils.c
```
static Dtdisc_t mapDisc = {
    offsetof(item, p),
    sizeof(2 * sizeof(void *)),
    offsetof(item, link),
    (Dtmake_f) newItem,
    (Dtfree_f) freeItem,
    (Dtcompar_f) cmpItem,
    NIL(Dthash_f),
    NIL(Dtmemory_f),
    NIL(Dtevent_f)
};
```

mDNSResponder/mDNSShared/dnsextd.c
```
context = ( TCPContext* ) malloc( sizeof( TCPContext ) );
require_action( context, exit, err = mStatus_NoMemoryErr; LogErr( "AcceptTCPConnection", "malloc" ) );
mDNSPlatformMemZero( context, sizeof( sizeof( TCPContext ) ) );
context->d  = self;
```

Reviewers: alexfh

Subscribers: malcolm.parsons, Eugene.Zelenko, cfe-commits

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

llvm-svn: 266451

8 years ago[clang-tidy] Add checker for operations between integrals and pointers
Etienne Bergeron [Fri, 15 Apr 2016 16:31:15 +0000 (16:31 +0000)]
[clang-tidy] Add checker for operations between integrals and pointers

Summary:
This check is finding suspicious operations involving pointers and integral types; which are most likely bugs.

Examples:
subversion/v1_6/subversion/libsvn_subr/utf.c
```
static const char *
fuzzy_escape(const char *src, apr_size_t len, apr_pool_t *pool)
{
  [...]
   while (src_orig < src_end)
    {
      if (! svn_ctype_isascii(*src_orig) || src_orig == '\0')   // Should be *src_orig
        {
```

apache2/v2_2_23/modules/metadata/mod_headers.c
```
static char *parse_format_tag(apr_pool_t *p, format_tag *tag, const char **sa)
{
  [...]
    tag->arg = '\0';   // ERROR: tag->arg has type char*

    /* grab the argument if there is one */
    if (*s == '{') {
        ++s;
        tag->arg = ap_getword(p,&s,'}');
    }
```

Reviewers: alexfh

Subscribers: Eugene.Zelenko, cfe-commits

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

llvm-svn: 266450

8 years agoFix testcase for MSVC targets where the output ordering is different.
Adrian Prantl [Fri, 15 Apr 2016 16:21:23 +0000 (16:21 +0000)]
Fix testcase for MSVC targets where the output ordering is different.

llvm-svn: 266449

8 years agoFix test to require Asserts since it uses debug output.
Geoff Berry [Fri, 15 Apr 2016 16:09:00 +0000 (16:09 +0000)]
Fix test to require Asserts since it uses debug output.

llvm-svn: 266448

8 years agoUpdate testcase to new debug info metadata format.
Adrian Prantl [Fri, 15 Apr 2016 16:05:13 +0000 (16:05 +0000)]
Update testcase to new debug info metadata format.

llvm-svn: 266447

8 years ago[PR27284] Reverse the ownership between DICompileUnit and DISubprogram.
Adrian Prantl [Fri, 15 Apr 2016 15:57:41 +0000 (15:57 +0000)]
[PR27284] Reverse the ownership between DICompileUnit and DISubprogram.

Currently each Function points to a DISubprogram and DISubprogram has a
scope field. For member functions the scope is a DICompositeType. DIScopes
point to the DICompileUnit to facilitate type uniquing.

Distinct DISubprograms (with isDefinition: true) are not part of the type
hierarchy and cannot be uniqued. This change removes the subprograms
list from DICompileUnit and instead adds a pointer to the owning compile
unit to distinct DISubprograms. This would make it easy for ThinLTO to
strip unneeded DISubprograms and their transitively referenced debug info.

Motivation
----------

Materializing DISubprograms is currently the most expensive operation when
doing a ThinLTO build of clang.

We want the DISubprogram to be stored in a separate Bitcode block (or the
same block as the function body) so we can avoid having to expensively
deserialize all DISubprograms together with the global metadata. If a
function has been inlined into another subprogram we need to store a
reference the block containing the inlined subprogram.

Attached to https://llvm.org/bugs/show_bug.cgi?id=27284 is a python script
that updates LLVM IR testcases to the new format.

http://reviews.llvm.org/D19034
<rdar://problem/25256815>

llvm-svn: 266446

8 years agoUpdate to match LLVM changes for PR27284.
Adrian Prantl [Fri, 15 Apr 2016 15:55:45 +0000 (15:55 +0000)]
Update to match LLVM changes for PR27284.
(Reverse the ownership between DICompileUnit and DISubprogram.)

http://reviews.llvm.org/D19034
<rdar://problem/25256815>

llvm-svn: 266445

8 years agoASTMatchers.h: Fix formatting. [-Wdocumentation]
NAKAMURA Takumi [Fri, 15 Apr 2016 15:42:27 +0000 (15:42 +0000)]
ASTMatchers.h: Fix formatting. [-Wdocumentation]

llvm-svn: 266444

8 years agollvm/test/CodeGen/AArch64/arm64-csldst-mmo.ll requires +Asserts.
NAKAMURA Takumi [Fri, 15 Apr 2016 15:37:27 +0000 (15:37 +0000)]
llvm/test/CodeGen/AArch64/arm64-csldst-mmo.ll requires +Asserts.

llvm-svn: 266443

8 years ago[SimplifyCFG] propagate branch metadata when creating select (PR27344)
Sanjay Patel [Fri, 15 Apr 2016 15:32:12 +0000 (15:32 +0000)]
[SimplifyCFG] propagate branch metadata when creating select (PR27344)

This is almost identical to:
http://reviews.llvm.org/rL264527

This doesn't solve PR27344; it just allows the profile weights to survive.
To solve the bug, we need to use the profile weights in the backend.

llvm-svn: 266442

8 years agolli.cpp: Appease some builders. There might be ownership issues between LLVMContext...
NAKAMURA Takumi [Fri, 15 Apr 2016 15:31:28 +0000 (15:31 +0000)]
lli.cpp: Appease some builders. There might be ownership issues between LLVMContext and ExecutionEngine. Investigating.

llvm-svn: 266441

8 years agoAdd an interesting GC testcase.
Rafael Espindola [Fri, 15 Apr 2016 15:26:52 +0000 (15:26 +0000)]
Add an interesting GC testcase.

It shows that we correctly look at liveness based on the final symbol
resolution.

llvm-svn: 266440

8 years ago[AArch64] Add MMOs to callee-save load/store instructions.
Geoff Berry [Fri, 15 Apr 2016 15:16:19 +0000 (15:16 +0000)]
[AArch64] Add MMOs to callee-save load/store instructions.

Summary:
Without MMOs, the callee-save load/store instructions were treated as
volatile by the MI post-RA scheduler and AArch64LoadStoreOptimizer.

Reviewers: t.p.northover, mcrosier

Subscribers: aemerson, rengolin, mcrosier, llvm-commits

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

llvm-svn: 266439

8 years agoFix typing on generated LXV2DX/STXV2DX instructions
Nirav Dave [Fri, 15 Apr 2016 15:01:38 +0000 (15:01 +0000)]
Fix typing on generated LXV2DX/STXV2DX instructions

[PPC] Previously when casting generic loads to LXV2DX/ST instructions we
would leave the original load return type in place allowing for an
assertion failure when we merge two equivalent LXV2DX nodes with
different types.

This fixes PR27350.

Reviewers: nemanjai

Subscribers: llvm-commits

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

llvm-svn: 266438