platform/upstream/llvm.git
8 years agoNext set of additional error checks for invalid Mach-O files for the
Kevin Enderby [Mon, 17 Oct 2016 22:09:25 +0000 (22:09 +0000)]
Next set of additional error checks for invalid Mach-O files for the
load commands that use the MachO::sub_framework_command,
MachO::sub_umbrella_command, MachO::sub_library_command
and MachO::sub_client_command types but are not used in llvm
libObject code but used in llvm tool code.

This includes the LC_SUB_FRAMEWORK, LC_SUB_UMBRELLA,
LC_SUB_LIBRARY and LC_SUB_CLIENT load commands.

llvm-svn: 284431

8 years ago[Driver] Use stem rather than filename for executable name
Petr Hosek [Mon, 17 Oct 2016 22:02:53 +0000 (22:02 +0000)]
[Driver] Use stem rather than filename for executable name

When comparing the linker name in Fuchsia driver, use stem rather
than filename to get the name of the linker becase on Windows, the
filename will have an extension.

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

llvm-svn: 284430

8 years agoRevert formatting changes.
Zachary Turner [Mon, 17 Oct 2016 21:25:41 +0000 (21:25 +0000)]
Revert formatting changes.

This reverts r288425 and r284428 as they are causing test crashes
on some systems.

llvm-svn: 284429

8 years agoTry to fix build after invalid pointer conversion.
Zachary Turner [Mon, 17 Oct 2016 21:14:27 +0000 (21:14 +0000)]
Try to fix build after invalid pointer conversion.

llvm-svn: 284428

8 years agoremove FIXME comment (fixed with r284424); NFC
Sanjay Patel [Mon, 17 Oct 2016 21:08:39 +0000 (21:08 +0000)]
remove FIXME comment (fixed with r284424); NFC

llvm-svn: 284427

8 years agoHandle multi-dimensional invariant load.
Eli Friedman [Mon, 17 Oct 2016 21:04:26 +0000 (21:04 +0000)]
Handle multi-dimensional invariant load.

If the address of a load depends on another load, make sure to emit
the loads in the right order.

llvm-svn: 284426

8 years ago[Support] Add support for "advanced" number formatting.
Zachary Turner [Mon, 17 Oct 2016 20:57:45 +0000 (20:57 +0000)]
[Support] Add support for "advanced" number formatting.

raw_ostream has not afforded a lot of flexibility in terms of
how to format numbers when outputting.  Wrap this all up into
a set of low level helper functions that can be used to output
numbers with arbitrary precision, alignment, format, etc and
then update raw_ostream to use these functions.

This will be useful for upcoming improvements to llvm's string
formatting libraries, but are still useful independently.

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

llvm-svn: 284425

8 years ago[DAG] use isConstOrConstSplat in ComputeNumSignBits to optimize SRA
Sanjay Patel [Mon, 17 Oct 2016 20:41:39 +0000 (20:41 +0000)]
[DAG] use isConstOrConstSplat in ComputeNumSignBits to optimize SRA

The scalar version of this pattern was noted in:
https://reviews.llvm.org/D25485

and fixed with:
https://reviews.llvm.org/rL284395

More refactoring of the constant/splat helpers is needed and will happen in follow-up patches.

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

llvm-svn: 284424

8 years agoExplicitly pass an isysroot to avoid the SDKROOT overriding the deployment target.
Adrian Prantl [Mon, 17 Oct 2016 20:37:56 +0000 (20:37 +0000)]
Explicitly pass an isysroot to avoid the SDKROOT overriding the deployment target.
This fixes the green dragon builders after r284416.

llvm-svn: 284423

8 years ago[lldb] Read modules from memory when a local copy is not available
Walter Erquinigo [Mon, 17 Oct 2016 20:28:19 +0000 (20:28 +0000)]
[lldb] Read modules from memory when a local copy is not available

Summary:
When the local lldb doesn't have access to a copy of the modules in the target, e.g. winphone, with this change now we read these modules from memory.

There are mainly 2 changes:
1. create pecoff object files from memory
2. read from memory when the local file is not available

Reviewers: sas, fjricci, zturner

Subscribers: #lldb

Tags: #lldb

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

llvm-svn: 284422

8 years ago[DAG] make isConstOrConstSplat and isConstOrConstSplatFP more accessible; NFC
Sanjay Patel [Mon, 17 Oct 2016 20:26:46 +0000 (20:26 +0000)]
[DAG] make isConstOrConstSplat and isConstOrConstSplatFP more accessible; NFC

As noted in:
https://reviews.llvm.org/D25685

This is the next-to-smallest step needed to enable the ComputeNumSignBits fix in that patch.
In a minor attempt to keep some structure, we're pulling the FP helper over along with its
integer sibling, but clearly we can and should do more refactoring of the similar helper
functions in DAGCombiner and SelectionDAG to simplify and not duplicate functionality.

llvm-svn: 284421

8 years agoImprove the CHECK lines in debug-options.c by separating out the check
Adrian Prantl [Mon, 17 Oct 2016 20:14:23 +0000 (20:14 +0000)]
Improve the CHECK lines in debug-options.c by separating out the check
for debug info kind and dwarf version.

llvm-svn: 284420

8 years ago[Coverage] Update test after r284418.
Davide Italiano [Mon, 17 Oct 2016 20:06:32 +0000 (20:06 +0000)]
[Coverage] Update test after r284418.

We now strip coverage metadata if debug info are not present.

llvm-svn: 284419

8 years ago[opt] Strip coverage if debug info is not present.
Davide Italiano [Mon, 17 Oct 2016 20:05:35 +0000 (20:05 +0000)]
[opt] Strip coverage if debug info is not present.

If -coverage is passed, but -g is not, clang populates the PassManager
pipeline with StripSymbols(debugOnly = true).
The stripSymbol pass therefore scans the list of named metadata,
drops !llvm.dbg.cu, but leaves !llvm.gcov and !0 (the compileUnit MD)
around. The verifier runs, and finds out that there's a CU not listed
in !llvm.dbg.cu (as it was previously dropped) -> crash.
When we strip debug info, so, check if there's coverage data,
and strip it as well, in order to avoid pending metadata left around.

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

llvm-svn: 284418

8 years agoUpdate testcase for r284416.
Adrian Prantl [Mon, 17 Oct 2016 19:46:26 +0000 (19:46 +0000)]
Update testcase for r284416.

llvm-svn: 284417

8 years agoDriver/Darwin: Set the DWARF version based on the deployment target.
Adrian Prantl [Mon, 17 Oct 2016 19:36:18 +0000 (19:36 +0000)]
Driver/Darwin: Set the DWARF version based on the deployment target.

System utilities such as atos only support DWARF 4 on OS X 10.11+ and
iOS 9+. We thus want to enable DWARF 4 only if the deployment target
has a recent enough operating system version and use DWARF 2 for older
systems.

<rdar://problem/28766743>

llvm-svn: 284416

8 years agoIgnore debug info when making optimization decisions in SimplifyCFG.
Dehao Chen [Mon, 17 Oct 2016 19:28:44 +0000 (19:28 +0000)]
Ignore debug info when making optimization decisions in SimplifyCFG.

Summary: Debug info should *not* affect code generation. This patch properly handles debug info to make sure the generated code are the same with or without debug info.

Reviewers: davidxl, mzolotukhin, jmolloy

Subscribers: aprantl, llvm-commits

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

llvm-svn: 284415

8 years agoDelete dead code.
Rafael Espindola [Mon, 17 Oct 2016 19:25:42 +0000 (19:25 +0000)]
Delete dead code.

llvm-svn: 284414

8 years agoAvoid using getComdatSymbolTable.
Rafael Espindola [Mon, 17 Oct 2016 19:25:08 +0000 (19:25 +0000)]
Avoid using getComdatSymbolTable.

This is not particularly efficient, but does avoid exposing Comdat*
out of LTO.h.

I will send a patch for review with a more efficient interface that
should map nicely to a bitcode symbol table.

llvm-svn: 284413

8 years ago[doc] use double `` to prevent html output of merging double dash
Mehdi Amini [Mon, 17 Oct 2016 19:23:19 +0000 (19:23 +0000)]
[doc] use double `` to prevent html output of merging double dash

llvm-svn: 284412

8 years agoTest commit.
Michael LeMay [Mon, 17 Oct 2016 19:09:19 +0000 (19:09 +0000)]
Test commit.

llvm-svn: 284411

8 years agoHandle relocations to thumb functions when dynamic linking COFF modules
Walter Erquinigo [Mon, 17 Oct 2016 18:56:18 +0000 (18:56 +0000)]
Handle relocations to thumb functions when dynamic linking COFF modules

Summary:
This adds the necessary logic to support relocations to thumb functions in the COFF dynamic linker.
The jumps to function addresses are mostly blx, which requires the ISA selection bit when jumping to a thumb function.

Note: I'm determining if the relocation requires the ISA bit when creating the relocation entries and not when resolving the relocation. I have to do that because I need the ObjectFile and the actual Symbol, which are available only when creating the entries. It would require a gross refactor if I do it otherwise, but I'm okay with doing it if you think it's better.

Reviewers: peter.smith, compnerd

Subscribers: rengolin, sas

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

llvm-svn: 284410

8 years agoUpdate for llvm change.
Rafael Espindola [Mon, 17 Oct 2016 18:51:27 +0000 (18:51 +0000)]
Update for llvm change.

llvm-svn: 284409

8 years agoReturn a StringRef instead of a Comdat*.
Rafael Espindola [Mon, 17 Oct 2016 18:51:02 +0000 (18:51 +0000)]
Return a StringRef instead of a Comdat*.

This is a small step in making this interface compatible with an
bitcode symbol table.

llvm-svn: 284408

8 years agoELF: Implement skip() as (void)next()
Justin Bogner [Mon, 17 Oct 2016 18:40:35 +0000 (18:40 +0000)]
ELF: Implement skip() as (void)next()

Thanks to Rafael for pointing out the simplification.

llvm-svn: 284407

8 years agoGlobalISel: support wider range of load/store sizes in AArch64.
Tim Northover [Mon, 17 Oct 2016 18:36:53 +0000 (18:36 +0000)]
GlobalISel: support wider range of load/store sizes in AArch64.

llvm-svn: 284406

8 years agounittests: Specify types in a bunch of unittest EXPECT's
Justin Bogner [Mon, 17 Oct 2016 18:22:03 +0000 (18:22 +0000)]
unittests: Specify types in a bunch of unittest EXPECT's

The EXPECT and ASSERT macros in gtest don't do the usual arithmetic
conversions. Specify types in several of them to fix -Werror.

llvm-svn: 284405

8 years ago[ELF] Support for R_ARM_TARGET2 relocation
Peter Smith [Mon, 17 Oct 2016 18:12:24 +0000 (18:12 +0000)]
[ELF] Support for R_ARM_TARGET2 relocation

The R_ARM_TARGET2 relocation is used in ARM exception tables to encode
a data dependency that will only be dereferenced by code in the
run-time support library. In a similar way to R_ARM_TARGET1 the
handling of the relocation is target specific, it maps to one of
R_ARM_ABS32, R_ARM_REL32 or R_ARM_GOT_PREL. The choice depends on the
run-time library. R_ARM_GOT_PREL is used for linux and BSD,
R_ARM_ABS32 and R_ARM_REL32 are used for bare-metal.

The command line option --target2=<target> can be used to select the
relocation used for R_ARM_TARGET2. The default is R_ARM_GOT_PREL.

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

llvm-svn: 284404

8 years ago[Driver] Use VFS to perform all distribution checks
Michal Gorny [Mon, 17 Oct 2016 18:07:15 +0000 (18:07 +0000)]
[Driver] Use VFS to perform all distribution checks

Use the VFS provided by D.getVFS() for all distribution checks,
including those performing read of the release file. Requested
by @bruno on D24954.

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

llvm-svn: 284403

8 years agoAdd a dummy file in each subdirectory in test/Driver/Inputs/hexagon_tree
Krzysztof Parzyszek [Mon, 17 Oct 2016 18:04:05 +0000 (18:04 +0000)]
Add a dummy file in each subdirectory in test/Driver/Inputs/hexagon_tree

Git does not store empty subdirectories (while SVN does). Git clone of
the clang repository did not create the fake Hexagon installation tree
used for testing the driver. This only became evident after a change
in the Hexagon toolchain that started checking for existence of certain
directories.

llvm-svn: 284402

8 years agoHexagon: add dummy files to test dir so git keeps them.
Tim Northover [Mon, 17 Oct 2016 18:00:27 +0000 (18:00 +0000)]
Hexagon: add dummy files to test dir so git keeps them.

Should fix hexagon-elf-toolchain.c tests on Git.

llvm-svn: 284401

8 years agoFix a typo.
Adrian Prantl [Mon, 17 Oct 2016 17:41:51 +0000 (17:41 +0000)]
Fix a typo.

llvm-svn: 284400

8 years ago[clang-tidy] Clean up code after applying replacements.
Alexander Kornienko [Mon, 17 Oct 2016 17:25:02 +0000 (17:25 +0000)]
[clang-tidy] Clean up code after applying replacements.

Summary:
Remove empty namespaces and initializer list commas / colons in
affected ranges. Initial patch: proper options for enabling the cleanup and
specifying the format style are needed.

Reviewers: hokein, ioeric

Subscribers: beanz, mgorny, cfe-commits

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

llvm-svn: 284399

8 years agoAMDGPU/SI: LowerParameter() should be computing align based on memory type
Tom Stellard [Mon, 17 Oct 2016 16:56:19 +0000 (16:56 +0000)]
AMDGPU/SI: LowerParameter() should be computing align based on memory type

Reviewers: arsenm

Subscribers: kzhuravl, wdng, nhaehnle, yaxunl, tony-tye, llvm-commits

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

llvm-svn: 284398

8 years agoAMDGPU/SI: Fix LowerParameter() for i16 arguments
Tom Stellard [Mon, 17 Oct 2016 16:21:45 +0000 (16:21 +0000)]
AMDGPU/SI: Fix LowerParameter() for i16 arguments

Summary:
If we are loading an i16 value from a 32-bit memory location, then
we need to be able to truncate the loaded value to i16.

Reviewers: arsenm

Subscribers: kzhuravl, wdng, nhaehnle, yaxunl, tony-tye, llvm-commits

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

llvm-svn: 284397

8 years agoRename skip(StringRef) -> consume(StringRef).
Rui Ueyama [Mon, 17 Oct 2016 16:01:53 +0000 (16:01 +0000)]
Rename skip(StringRef) -> consume(StringRef).

skip() and skip(StringRef) were overloaded functions that
have different semantics. This patch rename one of the functions
to avoid function overloading.

llvm-svn: 284396

8 years ago[DAG] optimize away an arithmetic-right-shift of a 0 or -1 value
Sanjay Patel [Mon, 17 Oct 2016 15:58:28 +0000 (15:58 +0000)]
[DAG] optimize away an arithmetic-right-shift of a 0 or -1 value

This came up as part of:
https://reviews.llvm.org/D25485

Note that the vector case is missed because ComputeNumSignBits() is deficient for vectors.

llvm-svn: 284395

8 years ago[x86] add tests to show missing DAG folds for arithmetic-shift-right
Sanjay Patel [Mon, 17 Oct 2016 15:44:59 +0000 (15:44 +0000)]
[x86] add tests to show missing DAG folds for arithmetic-shift-right

llvm-svn: 284394

8 years ago[x86] auto-generate checks
Sanjay Patel [Mon, 17 Oct 2016 15:38:41 +0000 (15:38 +0000)]
[x86] auto-generate checks

llvm-svn: 284393

8 years agoReapply r284383. The test failures were due to a missing dir in test/
Krzysztof Parzyszek [Mon, 17 Oct 2016 15:30:10 +0000 (15:30 +0000)]
Reapply r284383. The test failures were due to a missing dir in test/

llvm-svn: 284392

8 years ago[clang-move] Fix generating illegal header guard.
Haojian Wu [Mon, 17 Oct 2016 15:26:34 +0000 (15:26 +0000)]
[clang-move] Fix generating illegal header guard.

The filepath might contain some characters (i.e. '@') which are not
illegal in c identifiers. This patch changes all non-alphanumeric characters
to '_'.

llvm-svn: 284391

8 years agoRename interface for querying physical hardware concurrency
Teresa Johnson [Mon, 17 Oct 2016 14:56:53 +0000 (14:56 +0000)]
Rename interface for querying physical hardware concurrency

Based on post-commit review for D25585/r284180, rename
hardware_physical_concurrency to heavyweight_hardware_concurrency,
to better reflect what type of tasks it should be used for and
to enable other systems to map this to something other than the
number of physical cores.

llvm-svn: 284390

8 years agoRevert r284383, while I figure out how to reproduce the failures locally
Krzysztof Parzyszek [Mon, 17 Oct 2016 14:47:29 +0000 (14:47 +0000)]
Revert r284383, while I figure out how to reproduce the failures locally

llvm-svn: 284389

8 years ago[ELF] - Add support for -nopie
George Rimar [Mon, 17 Oct 2016 14:42:11 +0000 (14:42 +0000)]
[ELF] - Add support for -nopie

This is https://llvm.org/bugs/show_bug.cgi?id=30696,

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

llvm-svn: 284388

8 years ago[Object/ELF] - Check Header->e_shoff value earlier and do not crash.
George Rimar [Mon, 17 Oct 2016 14:28:12 +0000 (14:28 +0000)]
[Object/ELF] - Check Header->e_shoff value earlier and do not crash.

Patch checks that section pointer is aligned properly.
This should be done before getStringTable() call.

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

llvm-svn: 284387

8 years ago[Support] remove_dots: Remove windows test.
Benjamin Kramer [Mon, 17 Oct 2016 13:57:16 +0000 (13:57 +0000)]
[Support] remove_dots: Remove windows test.

Windows doesn't have roots, so I think this test doesn't make sense
there.

llvm-svn: 284386

8 years ago[ScopDetect] Depend transitively on ScalarEvolution.
Michael Kruse [Mon, 17 Oct 2016 13:29:20 +0000 (13:29 +0000)]
[ScopDetect] Depend transitively on ScalarEvolution.

ScopDetection might be queried by -dot-scops or -view-scops passes for which
it accesses ScalarEvolution.

llvm-svn: 284385

8 years ago[Support] remove_dots: Remove .. from absolute paths.
Benjamin Kramer [Mon, 17 Oct 2016 13:28:21 +0000 (13:28 +0000)]
[Support] remove_dots: Remove .. from absolute paths.

/../foo is still a proper path after removing the dotdot. This should
now finally match https://9p.io/sys/doc/lexnames.html [Cleaning names].

llvm-svn: 284384

8 years agoReturn correct path from HexagonToolChain::getHexagonTargetDir
Krzysztof Parzyszek [Mon, 17 Oct 2016 13:23:41 +0000 (13:23 +0000)]
Return correct path from HexagonToolChain::getHexagonTargetDir

This problem was exposed by r284129, causing clang-hexagon-elf to fail
clang tests.

llvm-svn: 284383

8 years agoRevert "Reinstate r281429, reverted in r281452, with a fix for its mishandling of"
Benjamin Kramer [Mon, 17 Oct 2016 13:00:44 +0000 (13:00 +0000)]
Revert "Reinstate r281429, reverted in r281452, with a fix for its mishandling of"

This reverts commit r284176. It still marks some modules as invisible
that should be visible. Will follow up with the author with a test case.

llvm-svn: 284382

8 years ago[SDAG] Use ABI type alignment for constant pools when optimizing for size
James Molloy [Mon, 17 Oct 2016 12:54:07 +0000 (12:54 +0000)]
[SDAG] Use ABI type alignment for constant pools when optimizing for size

SelectionDAG::getConstantPool will automatically determine an appropriate alignment if one is not specified. It does this by querying the type's preferred alignment. This can end up creating quite a lot of padding when the preferred alignment for vectors is 128.

In optimize-for-size mode, it makes sense to instead query the ABI type alignment which is often smaller and causes less padding.

llvm-svn: 284381

8 years ago[docs] Reduce the number of places 'minimum requirements' is mentioned to one
Renato Golin [Mon, 17 Oct 2016 12:29:00 +0000 (12:29 +0000)]
[docs] Reduce the number of places 'minimum requirements' is mentioned to one

llvm-svn: 284380

8 years ago[SimplifyCFG] Don't lower complex ConstantExprs to lookup tables
Oliver Stannard [Mon, 17 Oct 2016 12:00:24 +0000 (12:00 +0000)]
[SimplifyCFG] Don't lower complex ConstantExprs to lookup tables

Not all ConstantExprs can be represented by a global variable, for example most
pointer arithmetic other than addition of a constant, so we can't convert these
values from switch statements to lookup tables.

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

llvm-svn: 284379

8 years ago[SCEV] Consider delinearization pattern with extension with identity factor
Tobias Grosser [Mon, 17 Oct 2016 11:56:26 +0000 (11:56 +0000)]
[SCEV] Consider delinearization pattern with extension with identity factor

Summary: The delinearization algorithm did not consider terms which had an extension without a multiply factor, i.e. a identify factor. We lose cases where size is char type where there will no multiply factor.

Reviewers: sanjoy, grosser

Subscribers: mzolotukhin, Eugene.Zelenko, llvm-commits, mssimpso, sanjoy, grosser

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

llvm-svn: 284378

8 years ago[CodeGenPrepare] When moving a zext near to its associated load, do not retain the...
Andrea Di Biagio [Mon, 17 Oct 2016 11:32:26 +0000 (11:32 +0000)]
[CodeGenPrepare] When moving a zext near to its associated load, do not retain the original debug location.

CodeGenPrepare knows how to move a zext of a load into the same basic block
where the load lives. The goal is to help ISel match a zero-extending load
instead of two separated instructions.

CGP attempts to move a zext computation even if it lives in a basic block that
does not post-dominate the load's basic block. That means, the hoisted zext may
be speculated. Preserving the zext location would hurt the debugging experience
and the quality of sample pgo.
With this patch, when moving a zext near to its associated load, CGP no longer
propagates the zext's debug location. Instead, CGP conservatively reuses the
same debug location for the load and the zext.

An alternative approach would be to assign an artificial line-0 location to the
zext. However we don't want to over-use the 'line-0' for this particular case
because it would have a size cost in the line-table section for no additional
benefit.

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

llvm-svn: 284377

8 years ago[ELF] - Don't crash on multiple SHT_MIPS_REGINFO/SHT_MIPS_ABIFLAGS sections.
George Rimar [Mon, 17 Oct 2016 11:31:46 +0000 (11:31 +0000)]
[ELF] - Don't crash on multiple SHT_MIPS_REGINFO/SHT_MIPS_ABIFLAGS sections.

In continue of D25555, this patch fixes possible crash when
we have multiple SHT_MIPS_REGINFO or SHT_MIPS_ABIFLAGS sections.
yaml2obj was used to produce such objects.

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

llvm-svn: 284376

8 years ago[ELF] - Added testcase relative to D25090.
George Rimar [Mon, 17 Oct 2016 11:15:12 +0000 (11:15 +0000)]
[ELF] - Added testcase relative to D25090.

It was requested on review for https://reviews.llvm.org/D25090 to add testcase in lld.

Spec says (http://www.sco.com/developers/gabi/1998-04-29/ch4.eheader.html) :
e_shnum
This member holds the number of entries in the section header table.
Thus the product of e_shentsize and e_shnum gives the section header table's size in bytes.
If a file has no section header table, e_shnum holds the value zero.

In case revealed, broken input did not contain zero in this field.
 LLD then could crash when proccessed sections (returned array has incorrect size):

template <class ELFT> void SharedFile<ELFT>::parseSoName() {
...
  for (const Elf_Shdr &Sec : Obj.sections()) {
...

llvm-svn: 284375

8 years agoRecommit r284371 "[Object/ELF] - Check that e_shnum is null when e_shoff is."
George Rimar [Mon, 17 Oct 2016 10:58:02 +0000 (10:58 +0000)]
Recommit r284371 "[Object/ELF] - Check that e_shnum is null when e_shoff is."
With fix: hex edited the precompiled inputs from another testcases to pass new checks.

Original commit message:

[Object/ELF] - Check that e_shnum is null when e_shoff is.

Spec says (http://www.sco.com/developers/gabi/1998-04-29/ch4.eheader.html) :
e_shnum
This member holds the number of entries in the section header table. Thus the product of e_shentsize and e_shnum gives the section header table's size in bytes. If a file has no section header table, e_shnum holds the value zero.

Revealed using "id_000037,sig_11,src_000015,op_havoc,rep_8" from PR30540

That was the reason of crash in lld on incorrect input file.
Binary reduced using afl-min.

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

llvm-svn: 284374

8 years agoRevert r284371 "[Object/ELF] - Check that e_shnum is null when e_shoff is."
George Rimar [Mon, 17 Oct 2016 10:20:47 +0000 (10:20 +0000)]
Revert r284371 "[Object/ELF] - Check that e_shnum is null when e_shoff is."

It broke build bot:
http://lab.llvm.org:8011/builders/clang-with-lto-ubuntu/builds/908/steps/test-stage1-compiler/logs/stdio

llvm-svn: 284373

8 years agoDo not reset TUScope when we are in incremental processing mode.
Vassil Vassilev [Mon, 17 Oct 2016 10:15:25 +0000 (10:15 +0000)]
Do not reset TUScope when we are in incremental processing mode.

Patch by Axel Naumann!

Reviewed by Richard Smith and me.

llvm-svn: 284372

8 years ago[Object/ELF] - Check that e_shnum is null when e_shoff is.
George Rimar [Mon, 17 Oct 2016 10:06:44 +0000 (10:06 +0000)]
[Object/ELF] - Check that e_shnum is null when e_shoff is.

Spec says (http://www.sco.com/developers/gabi/1998-04-29/ch4.eheader.html) :
e_shnum
This member holds the number of entries in the section header table. Thus the product of e_shentsize and e_shnum gives the section header table's size in bytes. If a file has no section header table, e_shnum holds the value zero.

Revealed using "id_000037,sig_11,src_000015,op_havoc,rep_8" from PR30540

That was the reason of crash in lld on incorrect input file.
Binary reduced using afl-min.

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

llvm-svn: 284371

8 years agoFix windows buildbot error.
Haojian Wu [Mon, 17 Oct 2016 10:05:25 +0000 (10:05 +0000)]
Fix windows buildbot error.

llvm-svn: 284370

8 years ago[Object/ELF] - Do not crash on invalid section index.
George Rimar [Mon, 17 Oct 2016 09:30:06 +0000 (09:30 +0000)]
[Object/ELF] - Do not crash on invalid section index.

If object has wrong (large) string table index and
also incorrect large value for amount of sections in total,
then section index passes the check:

  if (Index >= getNumSections())
    return object_error::invalid_section_index;

But result pointer then is far after end of file data, what
result in a crash.

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

llvm-svn: 284369

8 years agoRecommit "[ClangTidy] Add UsingInserter and NamespaceAliaser"
Haojian Wu [Mon, 17 Oct 2016 08:33:59 +0000 (08:33 +0000)]
Recommit "[ClangTidy] Add UsingInserter and NamespaceAliaser"

Summary: This adds helper classes to add using declaractions and namespace aliases to function bodies. These help making function calls to deeply nested functions concise (e.g. when calling helpers in a refactoring)

Patch by Julian Bangert!

Reviewers: alexfh, hokein

Subscribers: beanz, mgorny, cfe-commits

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

llvm-svn: 284368

8 years agoSupport: Drop LLVM_ATTRIBUTE_UNUSED_RESULT
Justin Bogner [Mon, 17 Oct 2016 07:37:11 +0000 (07:37 +0000)]
Support: Drop LLVM_ATTRIBUTE_UNUSED_RESULT

Uses of this have all been updated to use LLVM_NODISCARD, which
matches the C++17 [[nodiscard]] semantics rather than those of GCC's
__attribute__((warn_unused_result)).

llvm-svn: 284367

8 years agoAST: Prefer LLVM_NODISCARD to LLVM_ATTRIBUTE_UNUSED_RESULT
Justin Bogner [Mon, 17 Oct 2016 06:46:35 +0000 (06:46 +0000)]
AST: Prefer LLVM_NODISCARD to LLVM_ATTRIBUTE_UNUSED_RESULT

llvm-svn: 284366

8 years ago[X86] Fix shuffle decoding assertions to print the right number of required operands...
Craig Topper [Mon, 17 Oct 2016 06:41:18 +0000 (06:41 +0000)]
[X86] Fix shuffle decoding assertions to print the right number of required operands. Update the checks themselves to be >= to the same number instead of > one less than the required number.

llvm-svn: 284365

8 years agoADT: Use LLVM_NODISCARD instead of LLVM_ATTRIBUTE_UNUSED_RESULT for StringRef
Justin Bogner [Mon, 17 Oct 2016 06:35:23 +0000 (06:35 +0000)]
ADT: Use LLVM_NODISCARD instead of LLVM_ATTRIBUTE_UNUSED_RESULT for StringRef

Instead of annotating (most of) the StringRef API, we can just
annotate the type directly. This is less code and it will warn in more
cases.

llvm-svn: 284364

8 years agoELF: Add a skip() overload to ignore any token
Justin Bogner [Mon, 17 Oct 2016 06:21:13 +0000 (06:21 +0000)]
ELF: Add a skip() overload to ignore any token

Most functions that return StringRef should check their return values,
so I'm planning on marking StringRef [[nodiscard]]. This requires
splitting up functions like next() that are sometimes just used for
side effects.

llvm-svn: 284363

8 years agoInterpreter: Don't return StringRef from functions whose return value is never used
Justin Bogner [Mon, 17 Oct 2016 06:17:56 +0000 (06:17 +0000)]
Interpreter: Don't return StringRef from functions whose return value is never used

StringRef is passed through all of these APIs but never actually
used. Just remove it from the API for now and if people want to use it
they can add it back.

llvm-svn: 284362

8 years agoELF: Fix a misuse of Twine::toStringRef
Justin Bogner [Mon, 17 Oct 2016 06:08:48 +0000 (06:08 +0000)]
ELF: Fix a misuse of Twine::toStringRef

While the toStringRef API almost certainly ends up populating the
SmallString here, the correct way to use this API is to use the return
value.

llvm-svn: 284361

8 years agoClangMoveTests.cpp: Appease msc18.
NAKAMURA Takumi [Mon, 17 Oct 2016 05:09:58 +0000 (05:09 +0000)]
ClangMoveTests.cpp: Appease msc18.

  clang-tools-extra\unittests\clang-move\ClangMoveTests.cpp(216) : error C2593: 'operator =' is ambiguous
          llvm\include\llvm/ADT/SmallVector.h(898): could be 'const llvm::SmallVector<std::string,4> &llvm::SmallVector<std::string,4>::operator =(std::initializer_list<std::basic_string<char,std::char_traits<char>,std::allocator<char>>>)'
          llvm\include\llvm/ADT/SmallVector.h(893): or       'const llvm::SmallVector<std::string,4> &llvm::SmallVector<std::string,4>::operator =(llvm::SmallVectorImpl<T> &&)'
          with
          [
              T=std::string
          ]
          llvm\include\llvm/ADT/SmallVector.h(883): or       'const llvm::SmallVector<std::string,4> &llvm::SmallVector<std::string,4>::operator =(llvm::SmallVector<std::string,4> &&)'
          llvm\include\llvm/ADT/SmallVector.h(873): or       'const llvm::SmallVector<std::string,4> &llvm::SmallVector<std::string,4>::operator =(const llvm::SmallVector<std::string,4> &)'
          while trying to match the argument list '(llvm::SmallVector<std::string,4>, initializer-list)'

llvm-svn: 284360

8 years agoReformat.
NAKAMURA Takumi [Mon, 17 Oct 2016 05:08:49 +0000 (05:08 +0000)]
Reformat.

llvm-svn: 284359

8 years ago[AVX-512] Add shuffle combining support for vpermi2var shuffles derived from existing...
Craig Topper [Mon, 17 Oct 2016 04:26:47 +0000 (04:26 +0000)]
[AVX-512] Add shuffle combining support for vpermi2var shuffles derived from existing support for vpermt2var.

llvm-svn: 284357

8 years ago[AVX-512] Add vpermi2var test cases to shuffle combining test case. Combining will...
Craig Topper [Mon, 17 Oct 2016 04:26:44 +0000 (04:26 +0000)]
[AVX-512] Add vpermi2var test cases to shuffle combining test case. Combining will be added in a future commit.

llvm-svn: 284356

8 years ago[CUDA] Fix false-positive in known-emitted handling.
Justin Lebar [Mon, 17 Oct 2016 02:25:55 +0000 (02:25 +0000)]
[CUDA] Fix false-positive in known-emitted handling.

Previously: When compiling for host, our constructed call graph went
*through* kernel calls.  This meant that if we had

  host calls kernel calls HD

we would incorrectly mark the HD function as known-emitted on the host
side, and thus perform host-side checks on it.

Fixing this exposed another issue, wherein when marking a function as
known-emitted, we also need to traverse the callgraph of its template,
because non-dependent calls are attached to a function's template, not
its instantiation.

llvm-svn: 284355

8 years ago[AVX-512] Add support for turning a 256-bit load that goes to both halfs of an insert...
Craig Topper [Sun, 16 Oct 2016 23:29:51 +0000 (23:29 +0000)]
[AVX-512] Add support for turning a 256-bit load that goes to both halfs of an insert_subvector into a subvector broadcast.

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

llvm-svn: 284353

8 years agoclang/test/CXX/conv/conv.fctptr/p1.cpp: Appease for targeting i686-win32.
NAKAMURA Takumi [Sun, 16 Oct 2016 23:00:18 +0000 (23:00 +0000)]
clang/test/CXX/conv/conv.fctptr/p1.cpp: Appease for targeting i686-win32.

  error: 'error' diagnostics seen but not expected:
    File clang\test\CXX\conv\conv.fctptr\p1.cpp Line 16: assigning to 'void (S::*)() __attribute__((thiscall)) noexcept' from incompatible type 'void (S::*)() __attribute__((thiscall))': different exception specifications

llvm-svn: 284352

8 years agoRevert "Revert "[analyzer] Make MallocChecker more robust against custom redeclarations""
Devin Coughlin [Sun, 16 Oct 2016 22:19:03 +0000 (22:19 +0000)]
Revert "Revert "[analyzer] Make MallocChecker more robust against custom redeclarations""

This reverts commit r284340 to reapply r284335. The bot breakage was due to
an unrelated change in the polybench test suite.

llvm-svn: 284351

8 years agounittests: Explicitly ignore some return values in crash tests
Justin Bogner [Sun, 16 Oct 2016 22:09:24 +0000 (22:09 +0000)]
unittests: Explicitly ignore some return values in crash tests

Ideally these would actually check that the results are reasonable,
but given that we're looping over so many different kinds of path that
isn't really practical.

llvm-svn: 284350

8 years ago[test] Add missing colon.
Michael Kruse [Sun, 16 Oct 2016 22:05:51 +0000 (22:05 +0000)]
[test] Add missing colon.

llvm-svn: 284349

8 years agoSupport: Return void from Scanner::scan_ns_uri_char, no one uses the result
Justin Bogner [Sun, 16 Oct 2016 22:01:22 +0000 (22:01 +0000)]
Support: Return void from Scanner::scan_ns_uri_char, no one uses the result

Simplify this a little bit since the result is never used. It can be
added back easily enough if that changes.

llvm-svn: 284348

8 years ago[cmake] Add polly-isl-test dependency to lit tests.
Michael Kruse [Sun, 16 Oct 2016 21:35:57 +0000 (21:35 +0000)]
[cmake] Add polly-isl-test dependency to lit tests.

Also handle the in-llvm-tree case forgotten in r284339.

llvm-svn: 284347

8 years agoMachineModuleInfo: Prefer the LLVM_NODISCARD spelling
Justin Bogner [Sun, 16 Oct 2016 21:18:26 +0000 (21:18 +0000)]
MachineModuleInfo: Prefer the LLVM_NODISCARD spelling

Update a function annotated with LLVM_ATTRIBUTE_UNUSED_RESULT to use
LLVM_NODISCARD instead.

llvm-svn: 284346

8 years agoSCEV: Prefer the LLVM_NODISCARD spelling
Justin Bogner [Sun, 16 Oct 2016 21:17:29 +0000 (21:17 +0000)]
SCEV: Prefer the LLVM_NODISCARD spelling

Update functions annotated with LLVM_ATTRIBUTE_UNUSED_RESULT to use
LLVM_NODISCARD instead.

llvm-svn: 284345

8 years agoSupport: Prefer the LLVM_NODISCARD spelling
Justin Bogner [Sun, 16 Oct 2016 20:56:20 +0000 (20:56 +0000)]
Support: Prefer the LLVM_NODISCARD spelling

Update functions annotated with LLVM_ATTRIBUTE_UNUSED_RESULT to use
LLVM_NODISCARD instead.

llvm-svn: 284344

8 years agoADT: Prefer the LLVM_NODISCARD spelling
Justin Bogner [Sun, 16 Oct 2016 20:42:34 +0000 (20:42 +0000)]
ADT: Prefer the LLVM_NODISCARD spelling

Update functions annotated with LLVM_ATTRIBUTE_UNUSED_RESULT to use
LLVM_NODISCARD instead.

llvm-svn: 284343

8 years agoADT: Use LLVM_NODISCARD instead of LLVM_ATTRIBUTE_UNUSED_RESULT for ArrayRef
Justin Bogner [Sun, 16 Oct 2016 20:30:40 +0000 (20:30 +0000)]
ADT: Use LLVM_NODISCARD instead of LLVM_ATTRIBUTE_UNUSED_RESULT for ArrayRef

Instead of annotating (most of) the ArrayRef API, we can just annotate
the type directly. This is less code and it will warn in more cases.

llvm-svn: 284342

8 years agoAST: Improve a couple of comments and cast unused values to void
Justin Bogner [Sun, 16 Oct 2016 20:12:42 +0000 (20:12 +0000)]
AST: Improve a couple of comments and cast unused values to void

Make these comments a bit more explicit that they're initializing the
RawText member, and explicitly cast the unused result of getRawText to
void for clarity.

llvm-svn: 284341

8 years agoRevert "[analyzer] Make MallocChecker more robust against custom redeclarations"
Devin Coughlin [Sun, 16 Oct 2016 19:26:07 +0000 (19:26 +0000)]
Revert "[analyzer] Make MallocChecker more robust against custom redeclarations"

This reverts commit r284335.

It appears to be causing test-suite compile-time and execution-time
performance measurements to take longer than expected on several bots.
This is surprising, because r284335 is a static-analyzer-only change.

llvm-svn: 284340

8 years ago[cmake] Add polly-isl-test dependency to lit tests.
Michael Kruse [Sun, 16 Oct 2016 18:22:02 +0000 (18:22 +0000)]
[cmake] Add polly-isl-test dependency to lit tests.

lit recursively iterates through the test subdirectories and finds the ISL
unittest. For this test to work, the polly-isl-test executable needs to be
compiled.

Add the polly-isl-test dependency to POLLY_TEST_DEPS. This makes check-polly and
check-polly-tests work from a fresh build directory.

llvm-svn: 284339

8 years ago[test] Add -polly-unprofitable-scalar-accs to test that needs it.
Michael Kruse [Sun, 16 Oct 2016 18:13:01 +0000 (18:13 +0000)]
[test] Add -polly-unprofitable-scalar-accs to test that needs it.

The test non_affine_loop_used_later.ll also tests the profability heuristic. Add
the option -polly-unprofitable-scalar-accs explicitely to ensure that the test
succeeds if the default value is changed.

llvm-svn: 284338

8 years agoP0012R1: Make exception specifications be part of the type system. This
Richard Smith [Sun, 16 Oct 2016 17:54:23 +0000 (17:54 +0000)]
P0012R1: Make exception specifications be part of the type system. This
implements the bulk of the change (modifying the type system to include
exception specifications), but not all the details just yet.

llvm-svn: 284337

8 years agoPR30711: Fix incorrect profiling of 'long long' in FoldingSet, then use it to
Richard Smith [Sun, 16 Oct 2016 17:49:09 +0000 (17:49 +0000)]
PR30711: Fix incorrect profiling of 'long long' in FoldingSet, then use it to
fix TBAA violation in profiling of pointers.

llvm-svn: 284336

8 years ago[analyzer] Make MallocChecker more robust against custom redeclarations
Devin Coughlin [Sun, 16 Oct 2016 17:26:06 +0000 (17:26 +0000)]
[analyzer] Make MallocChecker more robust against custom redeclarations

Add additional checking to MallocChecker to avoid crashing when memory
routines have unexpected numbers of arguments. You wouldn't expect to see much
of this in normal code (-Wincompatible-library-redeclaration warns on this),
but, for example, CMake tests can generate these.

This is PR30616.

rdar://problem/28631974

llvm-svn: 284335

8 years agoMake any_cast<void()>(nullptr) compile
Eric Fiselier [Sun, 16 Oct 2016 11:56:38 +0000 (11:56 +0000)]
Make any_cast<void()>(nullptr) compile

llvm-svn: 284333

8 years ago[clang-tidy] Use ignoreImplicit in cert-err58-cpp check
Malcolm Parsons [Sun, 16 Oct 2016 09:47:10 +0000 (09:47 +0000)]
[clang-tidy] Use ignoreImplicit in cert-err58-cpp check

Summary:
Fix a false negative in cert-err58-cpp check when calling a constructor
creates objects that require cleanup.

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

llvm-svn: 284332

8 years agoExtend this test and make it a bit clearer which cases Clang is getting wrong.
Richard Smith [Sun, 16 Oct 2016 06:23:29 +0000 (06:23 +0000)]
Extend this test and make it a bit clearer which cases Clang is getting wrong.

llvm-svn: 284331

8 years ago[AVX-512] Fix the operand order for vpermi2var_qi intrinsics to match the other vperm...
Craig Topper [Sun, 16 Oct 2016 04:54:35 +0000 (04:54 +0000)]
[AVX-512] Fix the operand order for vpermi2var_qi intrinsics to match the other vpermi2var intrinsics.

llvm-svn: 284329

8 years ago[AVX-512] Correct execution domain for VPERMT2PS and VPERMI2PS.
Craig Topper [Sun, 16 Oct 2016 04:54:31 +0000 (04:54 +0000)]
[AVX-512] Correct execution domain for VPERMT2PS and VPERMI2PS.

llvm-svn: 284328