platform/upstream/llvm.git
8 years agoARM, AArch64, X86: Check preserved registers for tail calls.
Matthias Braun [Mon, 4 Apr 2016 18:56:13 +0000 (18:56 +0000)]
ARM, AArch64, X86: Check preserved registers for tail calls.

We can only perform a tail call to a callee that preserves all the
registers that the caller needs to preserve.

This situation happens with calling conventions like preserver_mostcc or
cxx_fast_tls. It was explicitely handled for fast_tls and failing for
preserve_most. This patch generalizes the check to any calling
convention.

Related to rdar://24207743

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

llvm-svn: 265329

8 years agoAssignment operators should return by reference.
John McCall [Mon, 4 Apr 2016 18:53:01 +0000 (18:53 +0000)]
Assignment operators should return by reference.

Thanks to Sean Silva for pointing this out.

llvm-svn: 265328

8 years ago[ThinLTO] Add option to dump value name to GUID mapping
Teresa Johnson [Mon, 4 Apr 2016 18:52:58 +0000 (18:52 +0000)]
[ThinLTO] Add option to dump value name to GUID mapping

Summary:
Useful for debugging since we lose this correlation after the permodule
summary/VST is read and until we later materialize source modules in the
function importer.

Reviewers: joker.eph

Subscribers: llvm-commits, joker.eph

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

llvm-svn: 265327

8 years ago[ThinLTO] Augment FunctionImport dump with value name to GUID map
Teresa Johnson [Mon, 4 Apr 2016 18:52:23 +0000 (18:52 +0000)]
[ThinLTO] Augment FunctionImport dump with value name to GUID map

Summary:
To aid in debugging, dump out the correlation between value names and
GUID for each source module when it is materialized. This will make it
easier to comprehend the earlier summary-based function importing debug
trace which only has access to and prints the GUIDs.

Reviewers: joker.eph

Subscribers: llvm-commits, joker.eph

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

llvm-svn: 265326

8 years agoAdd copyright notice to the modulemap file.
Yunzhong Gao [Mon, 4 Apr 2016 18:46:09 +0000 (18:46 +0000)]
Add copyright notice to the modulemap file.

The module.modulemap file in the lib/Headers directory was missing the LLVM
copyright notice. This patch adds the copyright notice just like the rest of
the files in this directory.

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

llvm-svn: 265325

8 years agoIRGen-level lowering for the Swift calling convention.
John McCall [Mon, 4 Apr 2016 18:33:08 +0000 (18:33 +0000)]
IRGen-level lowering for the Swift calling convention.

llvm-svn: 265324

8 years agoAdd a couple of convenience operations to CharUnits.
John McCall [Mon, 4 Apr 2016 18:33:00 +0000 (18:33 +0000)]
Add a couple of convenience operations to CharUnits.

llvm-svn: 265323

8 years agoApply suggestion from HJ Lu to avoid misaligned stack in test
Reid Kleckner [Mon, 4 Apr 2016 18:27:32 +0000 (18:27 +0000)]
Apply suggestion from HJ Lu to avoid misaligned stack in test

Fixes PR27191

llvm-svn: 265322

8 years agofix documentation comments; NFC
Sanjay Patel [Mon, 4 Apr 2016 18:25:06 +0000 (18:25 +0000)]
fix documentation comments; NFC

llvm-svn: 265321

8 years agoAdd comments.
Rui Ueyama [Mon, 4 Apr 2016 18:15:38 +0000 (18:15 +0000)]
Add comments.

llvm-svn: 265320

8 years ago[DependenceAnalysis] Check if result of getConstantPart is null
Brendon Cahoon [Mon, 4 Apr 2016 18:13:18 +0000 (18:13 +0000)]
[DependenceAnalysis] Check if result of getConstantPart is null

A seg-fault occurs due to a reference of a null pointer, which is
the value returned by getConstantPart. This function returns
null if the constant part is not found. The code that calls this
function needs to check for the null return value.

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

llvm-svn: 265319

8 years agoReplace MachineRegisterInfo::isSSA() with a MachineFunctionProperty
Derek Schuff [Mon, 4 Apr 2016 18:03:29 +0000 (18:03 +0000)]
Replace MachineRegisterInfo::isSSA() with a MachineFunctionProperty

Use the MachineFunctionProperty mechanism to indicate whether a MachineFunction
is in SSA form instead of a custom method on MachineRegisterInfo. NFC

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

llvm-svn: 265318

8 years agoRevert r265309 and r265312 because they caused some errors I need to investigate.
Wei Mi [Mon, 4 Apr 2016 17:45:03 +0000 (17:45 +0000)]
Revert r265309 and r265312 because they caused some errors I need to investigate.

llvm-svn: 265317

8 years agoFix -disable-verify test.
Rui Ueyama [Mon, 4 Apr 2016 17:42:01 +0000 (17:42 +0000)]
Fix -disable-verify test.

This test didn't actually test the functionality. The new test
verifies that "-verify" is passed if and only if -disable-verify
is not given.

llvm-svn: 265316

8 years agoXcode: modify lldb-python-test-suite target to build inferiors with $(LLDB_PYTHON_TES...
Todd Fiala [Mon, 4 Apr 2016 17:15:57 +0000 (17:15 +0000)]
Xcode: modify lldb-python-test-suite target to build inferiors with $(LLDB_PYTHON_TESTSUITE_CC)

$(LLDB_PYTHON_TESTSUITE_CC) defaults to the just-built clang.  Together
with changes to the zorg repo, this enables the Green Dragon LLDB OS X
Xcode-based builder to run the new TSAN LLDB tests.

llvm-svn: 265315

8 years agoDocument standard substitutions defined by lit.
Paul Robinson [Mon, 4 Apr 2016 17:14:45 +0000 (17:14 +0000)]
Document standard substitutions defined by lit.

Patch by Guilherme Bufolo!

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

llvm-svn: 265314

8 years agoAdd MachineFunctionProperty checks for AllVRegsAllocated for target passes
Derek Schuff [Mon, 4 Apr 2016 17:09:25 +0000 (17:09 +0000)]
Add MachineFunctionProperty checks for AllVRegsAllocated for target passes

Summary:
This adds the same checks that were added in r264593 to all
target-specific passes that run after register allocation.

Reviewers: qcolombet

Subscribers: jyknight, dsanders, llvm-commits

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

llvm-svn: 265313

8 years agoFix unused var warning caused by r265309.
Wei Mi [Mon, 4 Apr 2016 17:03:58 +0000 (17:03 +0000)]
Fix unused var warning caused by r265309.

llvm-svn: 265312

8 years agoFix test which failed Error migration on Windows bots.
Pete Cooper [Mon, 4 Apr 2016 16:56:09 +0000 (16:56 +0000)]
Fix test which failed Error migration on Windows bots.

Note, this is https://llvm.org/bugs/show_bug.cgi?id=27187.

The problem here was that just converting an error to a bool doesn't
always set the checked bit.  We only set that bit if the Error didn't
actually contain an error.  Otherwise we'd end potentially up silently
dropping it.

Instead just use the consumeError method which is designed to allow us
to drop an error.

llvm-svn: 265311

8 years ago[ELF][MIPS] Extend test case to check LA25 stubs creation for STO_MIPS_PIC symbols...
Simon Atanasyan [Mon, 4 Apr 2016 16:47:31 +0000 (16:47 +0000)]
[ELF][MIPS] Extend test case to check LA25 stubs creation for STO_MIPS_PIC symbols. NFC.

The only way to get an object file with symbols marked by the STO_MIPS_PIC
flag is to link PIC and non-PIC object files and generate a relocatable
output using '-r' command line option. Now LLD is able to generate a relocatable
output but does not mark PIC symbols by the STO_MIPS_PIC flag. So I have
to use binary input mips-sto-pic.o generated by GNU BFD linker.

llvm-svn: 265310

8 years agoReplace analyzeSiblingValues with new algorithm to fix its compile
Wei Mi [Mon, 4 Apr 2016 16:42:40 +0000 (16:42 +0000)]
Replace analyzeSiblingValues with new algorithm to fix its compile
time issue. The patch is to solve PR17409 and its duplicates.

analyzeSiblingValues is a N x N complexity algorithm where N is
the number of siblings generated by reg splitting. Although it
causes siginificant compile time issue when N is large, it is also
important for performance since it removes redundent spills and
enables rematerialization.

To solve the compile time issue, the patch removes analyzeSiblingValues
and replaces it with lower cost alternatives containing two parts. The
first part creates a new spill hoisting method in postOptimization of
register allocation. It does spill hoisting at once after all the spills
are generated instead of inside every instance of selectOrSplit. The
second part queries the define expr of the original register for
rematerializaiton and keep it always available during register allocation
even if it is already dead. It deletes those dead instructions only in
postOptimization. With the two parts in the patch, it can remove
analyzeSiblingValues without sacrificing performance.

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

llvm-svn: 265309

8 years agoSet the architecture type from minidump more precisely. Differentiate i686 v i386...
Adrian McCarthy [Mon, 4 Apr 2016 16:41:16 +0000 (16:41 +0000)]
Set the architecture type from minidump more precisely.  Differentiate i686 v i386 when possible.

llvm-svn: 265308

8 years agoFix for Bug #27193; 'std::acos on complex does not agree with C'. Tests need work...
Marshall Clow [Mon, 4 Apr 2016 16:08:54 +0000 (16:08 +0000)]
Fix for Bug #27193; 'std::acos on complex does not agree with C'. Tests need work; so the bug will stay open.

llvm-svn: 265306

8 years agoRegenerate test file.
Rafael Espindola [Mon, 4 Apr 2016 16:02:39 +0000 (16:02 +0000)]
Regenerate test file.

It had been created with a lld version that was producing an invalid
sh_info.

llvm-svn: 265305

8 years ago[OPENMP] Codegen for teams directive for NVPTX
Carlo Bertolli [Mon, 4 Apr 2016 15:55:02 +0000 (15:55 +0000)]
[OPENMP] Codegen for teams directive for NVPTX

This patch implements the teams directive for the NVPTX backend. It is different from the host code generation path as it:

Does not call kmpc_fork_teams. All necessary teams and threads are started upon touching the target region, when launching a CUDA kernel, and their execution is coordinated through sequential and parallel regions within the target region.
Does not call kmpc_push_num_teams even if a num_teams of thread_limit clause is present. Setting the number of teams and the thread limit is implemented by the nvptx-related runtime.
Please note that I am now passing a Clang Expr * to emitPushNumTeams instead of the originally chosen llvm::Value * type. The reason for that is that I want to avoid emitting expressions for num_teams and thread_limit if they are not needed in the target region.

http://reviews.llvm.org/D17963

llvm-svn: 265304

8 years ago[clang-tidy] Reduce false-positive ratio in misc-suspicious-missing-comma check.
Etienne Bergeron [Mon, 4 Apr 2016 15:46:38 +0000 (15:46 +0000)]
[clang-tidy] Reduce false-positive ratio in misc-suspicious-missing-comma check.

Summary:
This patch is adding detection of common string literal patterns
that should not trigger warnings.

  [*] Add a limit on the number of concatenated token,
  [*] Add support for parenthese sequence of tokens,
  [*] Add detection of valid indentation.

As an example, this code will no longer trigger a warning:
```
const char* Array[] = {
  "first literal"
    "indented literal"
    "indented literal",
  "second literal",
  [...]
```

Reviewers: alexfh

Subscribers: cfe-commits

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

llvm-svn: 265303

8 years ago[mips] Range check simm32 and fold MIPS16's imm32 into simm32.
Daniel Sanders [Mon, 4 Apr 2016 15:32:49 +0000 (15:32 +0000)]
[mips] Range check simm32 and fold MIPS16's imm32 into simm32.

Summary:
At this point we should be able to enable IAS by default for O32 without
breaking check-all, or recursion.

Reviewers: vkalintiris

Subscribers: dsanders, llvm-commits

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

llvm-svn: 265302

8 years agoAnnotateFunctions: Tweak for mingw.
NAKAMURA Takumi [Mon, 4 Apr 2016 15:30:44 +0000 (15:30 +0000)]
AnnotateFunctions: Tweak for mingw.

  - Externalize the registry.
  - Update libdeps.

llvm-svn: 265301

8 years ago[asan,tsan] Make Darwin-specific tests more stable (use ignore_interceptors_accesses...
Kuba Brecka [Mon, 4 Apr 2016 14:54:05 +0000 (14:54 +0000)]
[asan,tsan] Make Darwin-specific tests more stable (use ignore_interceptors_accesses=1 for GCD tests and printf instead of NSLog).

llvm-svn: 265300

8 years agoMake FileSpec handling platform-independent
Pavel Labath [Mon, 4 Apr 2016 14:39:12 +0000 (14:39 +0000)]
Make FileSpec handling platform-independent

Summary:
Even though FileSpec attempted to handle both kinds of path syntaxes (posix and windows) on both
platforms, it relied on the llvm path library to do its work, whose behavior differed on
different platforms. This led to subtle differences in FileSpec behavior between platforms. This
replaces the pieces of the llvm library with our own implementations. The functions are simply
copied from llvm, with #ifdefs replaced by runtime checks for ePathSyntaxWindows.

Reviewers: zturner

Subscribers: lldb-commits

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

llvm-svn: 265299

8 years ago[clang-tidy] fix a couple of modernize-use-override bugs
Alexander Kornienko [Mon, 4 Apr 2016 14:31:36 +0000 (14:31 +0000)]
[clang-tidy] fix a couple of modernize-use-override bugs

Fix for __declspec attributes and const=0 without space

This patch is to address 2 problems I found with Clang-tidy:modernize-use-override.

1: missing spaces on pure function decls.

Orig:
void pure() const=0
Problem:
void pure() constoverride =0
Fixed:
void pure() const override =0

2: This is ms-extension specific, but possibly applies to other attribute types. The override is placed before the attribute which doesn’t work well with declspec as this attribute can be inherited or placed before the method identifier.

Orig:
class __declspec(dllexport) X : public Y

{
void p();
};
Problem:
class override __declspec(dllexport) class X : public Y

{
void p();
};
Fixed:
class __declspec(dllexport) class X : public Y

{
void p() override;
};

Patch by Robert Bolter!

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

llvm-svn: 265298

8 years agoTry to fix the windows build.
Rafael Espindola [Mon, 4 Apr 2016 14:31:20 +0000 (14:31 +0000)]
Try to fix the windows build.

MSVC doesn't want StringRef in an union.

llvm-svn: 265297

8 years ago[SystemZ] Add compare-and-branch instructions to MC
Ulrich Weigand [Mon, 4 Apr 2016 14:26:43 +0000 (14:26 +0000)]
[SystemZ] Add compare-and-branch instructions to MC

This adds MC support for fused compare + indirect branch instructions,
ie. CRB, CGRB, CLRB, CLGRB, CIB, CGIB, CLIB, CLGIB. They aren't actually
generated yet -- this is preparation for their use for conditional
returns in the next iteration of D17339.

Author: koriakin
Differential Revision: http://reviews.llvm.org/D18742

llvm-svn: 265296

8 years agoAdd a PragmaHandler Registry for plugins to add PragmaHandlers to
John Brawn [Mon, 4 Apr 2016 14:22:58 +0000 (14:22 +0000)]
Add a PragmaHandler Registry for plugins to add PragmaHandlers to

This allows plugins which add AST passes to also define pragmas to do things
like only enable certain behaviour of the AST pass in files where a certain
pragma is used.

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

llvm-svn: 265295

8 years agoFix flakyness in TestWatchpointMultipleThreads
Pavel Labath [Mon, 4 Apr 2016 14:18:21 +0000 (14:18 +0000)]
Fix flakyness in TestWatchpointMultipleThreads

This addresses the same problem as r264846 (the test not expecting the situation when two thread
hit the watchpoint simultaneously), but for a different test.

llvm-svn: 265294

8 years agoDon't store an Elf_Sym for most symbols.
Rafael Espindola [Mon, 4 Apr 2016 14:04:16 +0000 (14:04 +0000)]
Don't store an Elf_Sym for most symbols.

Our symbol representation was redundant, and some times would get out of
sync. It had an Elf_Sym, but some fields were copied to SymbolBody.

Different parts of the code were checking the bits in SymbolBody and
others were checking Elf_Sym.

There are two general approaches to fix this:
* Copy the required information and don't store and Elf_Sym.
* Don't copy the information and always use the Elf_Smy.

The second way sounds tempting, but has a big problem: we would have to
template SymbolBody. I started doing it, but it requires templeting
*everything* and creates a bit chicken and egg problem at the driver
where we have to find ELFT before we can create an ArchiveFile for
example.

As much as possible I compared the test differences with what gold and
bfd produce to make sure they are still valid. In most cases we are just
adding hidden visibility to a local symbol, which is harmless.

In most tests this is a small speedup. The only slowdown was scylla
(1.006X). The largest speedup was clang with no --build-id, -O3 or
--gc-sections (i.e.: focus on the relocations): 1.019X.

llvm-svn: 265293

8 years ago[SystemZ] Support ATOMIC_FENCE
Ulrich Weigand [Mon, 4 Apr 2016 12:45:44 +0000 (12:45 +0000)]
[SystemZ] Support ATOMIC_FENCE

A cross-thread sequentially consistent fence should be lowered into
z/Architecture's BCR serialization instruction, instead of causing a
fatal error in the back-end.

Author: bryanpkc
Differential Revision: http://reviews.llvm.org/D18644

llvm-svn: 265292

8 years ago[SystemZ] Support llvm.frameaddress/llvm.returnaddress intrinsics
Ulrich Weigand [Mon, 4 Apr 2016 12:44:55 +0000 (12:44 +0000)]
[SystemZ] Support llvm.frameaddress/llvm.returnaddress intrinsics

Enable the SystemZ back-end to lower FRAMEADDR and RETURNADDR, which
previously would cause the back-end to crash.  Currently, only a
frame count of zero is supported.

Author: bryanpkc
Differential Revision: http://reviews.llvm.org/D18514

llvm-svn: 265291

8 years agoFixup r265277 [-Wdocumentation]
NAKAMURA Takumi [Mon, 4 Apr 2016 11:54:48 +0000 (11:54 +0000)]
Fixup r265277 [-Wdocumentation]

llvm-svn: 265290

8 years agotsan: fix ignore handling in signal handlers
Dmitry Vyukov [Mon, 4 Apr 2016 10:52:59 +0000 (10:52 +0000)]
tsan: fix ignore handling in signal handlers

We've reset thr->ignore_reads_and_writes, but forget to do
thr->fast_state.ClearIgnoreBit(). So ignores were not effective
reset and fast_state.ignore_bit was corrupted if signal handler
itself uses ignores.

Properly reset/restore fast_state.ignore_bit around signal handlers.

llvm-svn: 265288

8 years ago[OPENMP 4.0] Support for 'inbranch|noinbranch' clauses in 'declare
Alexey Bataev [Mon, 4 Apr 2016 10:12:15 +0000 (10:12 +0000)]
[OPENMP 4.0] Support for 'inbranch|noinbranch' clauses in 'declare
simd'.

Added parsing/semantic analysis for 'inbranch|notinbranch' clauses of
'#pragma omp declare simd' construct.

llvm-svn: 265287

8 years agoDo not allow to complex branch conditions
Johannes Doerfert [Mon, 4 Apr 2016 07:59:41 +0000 (07:59 +0000)]
Do not allow to complex branch conditions

  Even before we build the domain the branch condition can become very
  complex, especially if we have to build the complement of a lot of
  equality constraints. With this patch we bail if the branch condition
  has a lot of basic sets and parameters.

  After this patch we now successfully compile
    External/SPEC/CINT2000/186_crafty/186_crafty
  with "-polly-process-unprofitable -polly-position=before-vectorizer".

llvm-svn: 265286

8 years agoExploit graph properties during domain generation
Johannes Doerfert [Mon, 4 Apr 2016 07:57:39 +0000 (07:57 +0000)]
Exploit graph properties during domain generation

  As a CFG is often structured we can simplify the steps performed during
  domain generation. When we push domain information we can utilize the
  information from a block A to build the domain of a block B, if A dominates B
  and there is no loop backede on a path from A to B. When we pull domain
  information we can use information from a block A to build the domain of a
  block B if B post-dominates A. This patch implements both ideas and thereby
  simplifies domains that were not simplified by isl. For the FINAL basic block
  in test/ScopInfo/complex-successor-structure-3.ll we used to build a universe
  set with 81 basic sets. Now it actually is represented as universe set.

  While the initial idea to utilize the graph structure depended on the
  dominator and post-dominator tree we can use the available region
  information as a coarse grained replacement. To this end we push the
  region entry domain to the region exit and pull it from the region
  entry for the region exit if applicable.

  With this patch we now successfully compile
    External/SPEC/CINT2006/400_perlbench/400_perlbench
  and
    SingleSource/Benchmarks/Adobe-C++/loop_unroll.

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

llvm-svn: 265285

8 years agoFactor out "adjustDomainDimensions" function [NFC]
Johannes Doerfert [Mon, 4 Apr 2016 07:50:40 +0000 (07:50 +0000)]
Factor out "adjustDomainDimensions" function [NFC]

llvm-svn: 265284

8 years agoAVX-512: Truncating store for i1 vectors
Elena Demikhovsky [Mon, 4 Apr 2016 07:17:47 +0000 (07:17 +0000)]
AVX-512: Truncating store for i1 vectors
Implemented truncstore for KNL and skylake-avx512.
Covered vectors from v2i1 to v64i1. We save the value in bits (not in bytes) - v32i1 is saved in 4 bytes.

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

llvm-svn: 265283

8 years agoValueMapper: Remove old FIXMEs; almost NFC
Duncan P. N. Exon Smith [Mon, 4 Apr 2016 04:59:56 +0000 (04:59 +0000)]
ValueMapper: Remove old FIXMEs; almost NFC

Remove a few old FIXMEs from the original commit of the Metadata/Value
split in r223802.  These are commented out assertions to the effect that
calls between mapValue and mapMetadata never return nullptr.

(The only behaviour change is that Mapper::mapSimpleMetadata memoizes
the nullptr return.)

When I originally rewrote the mapping code, I thought we could be
stricter in the new metadata hierarchy and never return nullptr when
RF_NullMapMissingGlobalValues was off.  It's still not entirely clear to
me why these assertions failed (a few months ago, I had a theory that I
forgot to write down, but that's helping no one).

Understood or not, I no longer see how these commented-out assertions
would be useful.  I'm relegating them to the annals of source control
before making significant changes to ValueMapper.cpp.

llvm-svn: 265282

8 years ago[DebugInfo] Fix tests in Assembler/
Davide Italiano [Mon, 4 Apr 2016 02:11:34 +0000 (02:11 +0000)]
[DebugInfo] Fix tests in Assembler/

Each DISubprogram with isDefinition : true must
belong to a compile unit.

llvm-svn: 265281

8 years ago[FIX] Do not create a SCoP in the presence of infinite loops
Johannes Doerfert [Sun, 3 Apr 2016 23:09:06 +0000 (23:09 +0000)]
[FIX] Do not create a SCoP in the presence of infinite loops

  If a loop has no exiting blocks the region covering we use during
  schedule genertion might not cover that loop properly. For now we bail
  out as we would not optimize these loops anyway.

llvm-svn: 265280

8 years agoIR: Lazily create ReplaceableMetadataImpl on MDNode
Duncan P. N. Exon Smith [Sun, 3 Apr 2016 21:23:52 +0000 (21:23 +0000)]
IR: Lazily create ReplaceableMetadataImpl on MDNode

RAUW support on MDNode usually requires an extra allocation for
ReplaceableMetadataImpl.  This is only strictly necessary if there are
tracking references to the MDNode.  Make the construction of
ReplaceableMetadataImpl lazy, so that we don't get allocations if we
don't need them.

Since MDNode::isResolved now checks MDNode::isTemporary and
MDNode::NumUnresolved instead of whether a ReplaceableMetadataImpl is
allocated, the internal changes are intrusive (at various internal
checkpoints, isResolved now has a different answer).

However, there should be no real functionality change here; just
slightly lazier allocation behaviour.  The external semantics should be
identical.

llvm-svn: 265279

8 years agoIR: Make MDNode::Context private, NFC
Duncan P. N. Exon Smith [Sun, 3 Apr 2016 21:10:00 +0000 (21:10 +0000)]
IR: Make MDNode::Context private, NFC

llvm-svn: 265278

8 years agoVarious style fix in Core.h/Core.cpp . NFC
Amaury Sechet [Sun, 3 Apr 2016 21:06:04 +0000 (21:06 +0000)]
Various style fix in Core.h/Core.cpp . NFC

llvm-svn: 265277

8 years agoValueMapper: Disallow metadata mapping recursion through mapValue
Duncan P. N. Exon Smith [Sun, 3 Apr 2016 20:54:51 +0000 (20:54 +0000)]
ValueMapper: Disallow metadata mapping recursion through mapValue

This adds an assertion to maintain the property from r265273.  When
Mapper::mapSimpleMetadata calls Mapper::mapValue, it should not find its
way back to mapMetadataImpl.  This guarantees that mapSimpleMetadata is
not involved in any recursion.

Since Mapper::mapValue calls out to arbitrary materializers, we need to
save a bit on the ValueMap to make this assertion effective.

There should be no functionality change here.  This co-recursion should
already have been impossible.

llvm-svn: 265276

8 years agoWork around MSVC failure from r265273
Duncan P. N. Exon Smith [Sun, 3 Apr 2016 20:42:21 +0000 (20:42 +0000)]
Work around MSVC failure from r265273

http://lab.llvm.org:8011/builders/sanitizer-windows/builds/19726

llvm-svn: 265275

8 years ago[X86] Removed duplicate code.
Simon Pilgrim [Sun, 3 Apr 2016 20:40:35 +0000 (20:40 +0000)]
[X86] Removed duplicate code.

llvm-svn: 265274

8 years agoValueMapper: Avoid recursion in mapSimplifiedMetadata, NFC
Duncan P. N. Exon Smith [Sun, 3 Apr 2016 20:17:45 +0000 (20:17 +0000)]
ValueMapper: Avoid recursion in mapSimplifiedMetadata, NFC

The main change is to delay materializing GlobalValue initializers from
Mapper::mapValue until Mapper::~Mapper.  This effectively removes all
recursion from mapSimplifiedMetadata, as promised in r265270.
mapSimplifiedMetadata calls mapValue for ConstantAsMetadata nodes to
find the mapped constant, and now it shouldn't be possible for mapValue
to indirectly re-invoke mapMetadata.  I'll add an assertion to that
effect in a follow-up (separated so that the assertion can easily be
reverted independently, if it comes to that).

This a step toward a broader goal: converting Mapper::mapMetadataImpl
from a recursive to an iterative algorithm.

When a BlockAddress points at a BasicBlock inside an unmaterialized
function body, we need to delay it until the function body is
materialized in Mapper::~Mapper.  This commit creates a temporary
BasicBlock and returns a new BlockAddress, then RAUWs the BasicBlock
once it is known.  This situation should be extremely rare since a
BlockAddress is usually used from within the function it's referencing
(and BlockAddress itself is rare).

There should be no observable functionality change.

llvm-svn: 265273

8 years agoRevert "[FIX] Do not create a SCoP in the presence of infinite loops"
Tobias Grosser [Sun, 3 Apr 2016 19:36:52 +0000 (19:36 +0000)]
Revert "[FIX] Do not create a SCoP in the presence of infinite loops"

This reverts commit r265260, as it caused the following 'make check-polly'
failures:

    Polly :: ScopDetect/index_from_unpredictable_loop.ll
    Polly :: ScopInfo/multiple_exiting_blocks.ll
    Polly :: ScopInfo/multiple_exiting_blocks_two_loop.ll
    Polly :: ScopInfo/schedule-const-post-dominator-walk-2.ll
    Polly :: ScopInfo/schedule-const-post-dominator-walk.ll
    Polly :: ScopInfo/switch-5.ll

llvm-svn: 265272

8 years ago[CodeGenPrepare] Fix r265264 (again).
Peter Zotov [Sun, 3 Apr 2016 19:32:13 +0000 (19:32 +0000)]
[CodeGenPrepare] Fix r265264 (again).

Don't require TLI for SinkCmpExpression, like it wasn't before
r265264.

llvm-svn: 265271

8 years agoValueMapper: Split out mapSimpleMetadata, NFC
Duncan P. N. Exon Smith [Sun, 3 Apr 2016 19:31:01 +0000 (19:31 +0000)]
ValueMapper: Split out mapSimpleMetadata, NFC

Split out a helper for mapping metadata without operands.  This is any
metadata that is not an MDNode, and any MDNode where the answer is known
without looking at operands.

Through some weird twists, this function is co-recursive:

    mapSimpleMetadata
    => MapValue
    => materializeInitFor
    => linkFunctionBody
    => RemapInstructions
    => MapMetadata
    => mapSimpleMetadata

I plan to break the recursion in a follow-up.

llvm-svn: 265270

8 years ago[sanitizer] Make AtosSymbolizer more resilient when symbolicating a zero address
Kuba Brecka [Sun, 3 Apr 2016 19:13:03 +0000 (19:13 +0000)]
[sanitizer] Make AtosSymbolizer more resilient when symbolicating a zero address

llvm-svn: 265269

8 years agoValueMapper: Introduce Mapper helper class, NFC
Duncan P. N. Exon Smith [Sun, 3 Apr 2016 19:06:24 +0000 (19:06 +0000)]
ValueMapper: Introduce Mapper helper class, NFC

Remove a bunch of boilerplate from ValueMapper.cpp by using a new
file-local class called Mapper.

llvm-svn: 265268

8 years ago[X86][SSE] Refreshed MOVMSK sign bit tests
Simon Pilgrim [Sun, 3 Apr 2016 18:59:42 +0000 (18:59 +0000)]
[X86][SSE] Refreshed MOVMSK sign bit tests

llvm-svn: 265267

8 years ago[X86][SSE] Support for MOVMSK signbit extraction instructions
Simon Pilgrim [Sun, 3 Apr 2016 18:22:03 +0000 (18:22 +0000)]
[X86][SSE] Support for MOVMSK signbit extraction instructions

Add support for lowering with the MOVMSK instruction to extract vector element signbits to a GPR.

This is an early step towards more optimal handling of vector comparison results.

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

llvm-svn: 265266

8 years ago[CodeGenPrepare] Fix r265264.
Peter Zotov [Sun, 3 Apr 2016 17:11:53 +0000 (17:11 +0000)]
[CodeGenPrepare] Fix r265264.

The case where there was no TargetLowering was not handled,
leading to null pointer dereferences.

llvm-svn: 265265

8 years ago[CodeGenPrepare] Avoid sinking soft-FP comparisons
Peter Zotov [Sun, 3 Apr 2016 16:36:17 +0000 (16:36 +0000)]
[CodeGenPrepare] Avoid sinking soft-FP comparisons

Sinking comparisons in CGP can undo the job of hoisting them done
earlier by LICM, and soft-FP makes this an expensive mistake.

A common pattern that produces floating point comparisons uniform
over a loop is an explicit check for division by zero. If the divisor
is hoisted out of the loop, the comparison can also be, but hoisting
the function that unwinds is never legal, since it may cause side
effects in the loop body prior to the unwinding to not be executed.

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

llvm-svn: 265264

8 years ago[X86] Tidied up X86ISD instruction nodes. NFCI.
Simon Pilgrim [Sun, 3 Apr 2016 14:14:32 +0000 (14:14 +0000)]
[X86] Tidied up X86ISD instruction nodes. NFCI.

Tidied up comments, stripped trailing whitespace, split apart nodes that aren't related.

No change in ordering although there is definitely some scope for it.

llvm-svn: 265263

8 years agoMark some FP intrinsics as safe to speculatively execute
Peter Zotov [Sun, 3 Apr 2016 12:30:46 +0000 (12:30 +0000)]
Mark some FP intrinsics as safe to speculatively execute

Floating point intrinsics in LLVM are generally not speculatively
executed, since most of them are defined to behave the same as libm
functions, which set errno.

However, the only error that can happen  when executing ceil, floor,
nearbyint, rint and round libm functions per POSIX.1-2001 is -ERANGE,
and that requires the maximum value of the exponent to be smaller
than  the number of mantissa bits, which is not the case with any of
the floating point types supported by LLVM.

The trunc and copysign functions never set errno per per POSIX.1-2001.

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

llvm-svn: 265262

8 years ago[FIX] Do not create two SAI objects for exit PHIs
Johannes Doerfert [Sun, 3 Apr 2016 11:16:00 +0000 (11:16 +0000)]
[FIX] Do not create two SAI objects for exit PHIs

  If an exit PHI is written and also read in the SCoP we should not create two
  SAI objects but only one. As the read is only modeled to ensure OpenMP code
  generation knows about it we can simply use the EXIT_PHI MemoryKind for both
  accesses.

llvm-svn: 265261

8 years ago[FIX] Do not create a SCoP in the presence of infinite loops
Johannes Doerfert [Sun, 3 Apr 2016 11:12:39 +0000 (11:12 +0000)]
[FIX] Do not create a SCoP in the presence of infinite loops

  If a loop has no exiting blocks the region covering we use during
  schedule genertion might not cover that loop properly. For now we bail
  out as we would not optimize these loops anyway.

llvm-svn: 265260

8 years agoAVX-512: Load and Extended Load for i1 vectors
Elena Demikhovsky [Sun, 3 Apr 2016 08:41:12 +0000 (08:41 +0000)]
AVX-512: Load and Extended Load for i1 vectors

Implemented load+{sign|zero}_extend for i1 vectors
Fixed failures in i1 vector load.
Covered loading of v2i1, v4i1, v8i1, v16i1, v32i1, v64i1 vectors for KNL and SKX.

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

llvm-svn: 265259

8 years ago[LTO] Implement -disable-verify, which disables bitcode verification.
Davide Italiano [Sun, 3 Apr 2016 03:39:09 +0000 (03:39 +0000)]
[LTO] Implement -disable-verify, which disables bitcode verification.

So, there are some cases when the IR Linker produces a broken
module (which doesn't pass the verifier) and we end up asserting
inside the verifier. I think it's always a bug producing a module
which does not pass the verifier but there are some cases in which
people can live with the broken module (e.g. if only DebugInfo
metadata are broken). The gold plugin has something similar.

This commit is motivated by a situation I found in the
wild. It seems that somebody else discovered it independently
and reported in PR24923.

llvm-svn: 265258

8 years agoFix test case committed in r265197.
Akira Hatanaka [Sun, 3 Apr 2016 03:36:22 +0000 (03:36 +0000)]
Fix test case committed in r265197.

The test was failing on some release build because the basic block names
I was expecting weren't printed.

llvm-svn: 265257

8 years ago[LTO] Add a test to ensure we reject negative opt level.
Davide Italiano [Sun, 3 Apr 2016 03:12:00 +0000 (03:12 +0000)]
[LTO] Add a test to ensure we reject negative opt level.

We already got this right, but it never hurts adding another
test, in case we'll change the handling in the future, to ensure
we don't break it.

llvm-svn: 265256

8 years ago[LTO] Reject invalid optimization levels.
Davide Italiano [Sun, 3 Apr 2016 02:41:15 +0000 (02:41 +0000)]
[LTO] Reject invalid optimization levels.

llvm-svn: 265255

8 years ago[LTO] Fix -save-temps in case -o is not specified.
Davide Italiano [Sun, 3 Apr 2016 02:16:56 +0000 (02:16 +0000)]
[LTO] Fix -save-temps in case -o is not specified.

Currently we create a file called .lto.bc. In UNIX,
ls(1) by default doesn't show up files starting with
a dot, as they're (only by convention) hidden.
This makes the output of -save-temps a little bit
hard to find. Use "a.out.lto.bc" instead if the
output file is not specified.

While here, change an existing -save-temps test to
exercise this more interesting behaviour.

llvm-svn: 265254

8 years ago[SimplifyLibCalls] Garbage collect dead code.
Davide Italiano [Sun, 3 Apr 2016 01:46:52 +0000 (01:46 +0000)]
[SimplifyLibCalls] Garbage collect dead code.

We already skip optimizations if the return value
of printf() is used, so CI->use_empty() is always
true.

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

llvm-svn: 265253

8 years ago[c-index-test] Fix leak in print_completion_result, NFC
Vedant Kumar [Sun, 3 Apr 2016 00:54:46 +0000 (00:54 +0000)]
[c-index-test] Fix leak in print_completion_result, NFC

llvm-svn: 265252

8 years ago[lanai] Fix for LanaiDelaySlotFiller and LanaiMCInstLower.cpp
Jacques Pienaar [Sun, 3 Apr 2016 00:49:27 +0000 (00:49 +0000)]
[lanai] Fix for LanaiDelaySlotFiller and LanaiMCInstLower.cpp

Summary:
* Fix to stop delay slot filler from inserting SP modifying instructions in the newly expanded call/return instructions.
* In LowerSymbol the outermost type was not LanaiMCExpr if there was a binary expression
* Remove printExpr in LanaiInstPrinter

Subscribers: joker.eph, llvm-commits

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

llvm-svn: 265251

8 years ago[ELF] Prefer 'auto' over explicit type for consistency.
Davide Italiano [Sat, 2 Apr 2016 23:47:54 +0000 (23:47 +0000)]
[ELF] Prefer 'auto' over explicit type for consistency.

llvm-svn: 265250

8 years ago[mips][microMIPS] Revert commits r264245 and r264248.
Zoran Jovanovic [Sat, 2 Apr 2016 23:06:13 +0000 (23:06 +0000)]
[mips][microMIPS] Revert commits r264245 and r264248.
Commit r264245 was the reason for failing tests in LLVM test suite.
Commit r264248 depends on the first one.

llvm-svn: 265249

8 years ago[X86][SSE] Added 1024-bit vector comparison tests
Simon Pilgrim [Sat, 2 Apr 2016 21:33:09 +0000 (21:33 +0000)]
[X86][SSE] Added 1024-bit vector comparison tests

More examples of PR22603, poor vector splitting for AVX512F targets as well as missing uses of PACKSS/MOVMSK

llvm-svn: 265248

8 years ago[X86][AVX512] Added AVX512 comparison tests
Simon Pilgrim [Sat, 2 Apr 2016 21:24:42 +0000 (21:24 +0000)]
[X86][AVX512] Added AVX512 comparison tests

llvm-svn: 265247

8 years agoProvide support for Binutils' --no-dynamic-linker option.
Ed Schouten [Sat, 2 Apr 2016 20:58:02 +0000 (20:58 +0000)]
Provide support for Binutils' --no-dynamic-linker option.

GNU ld seems to write a PT_INTERP header into executables containing a
default (read: bogus) value if --dynamic-linker flag is not provided.
LLD is different in the sense that it omits it unless --dynamic-linker
is provided, which seems fair.

Binutils 2.26 added a new flag, --no-dynamic-linker, that can be used to
generate binaries without PT_INTERP. Let's go ahead and also add this
flag to LLD, so that we can invoke the linker in a portable way.

Reviewed by: ruiu
Differential Revision: http://reviews.llvm.org/D18723

llvm-svn: 265246

8 years agoSimplify. NFC.
Rui Ueyama [Sat, 2 Apr 2016 19:36:36 +0000 (19:36 +0000)]
Simplify. NFC.

llvm-svn: 265242

8 years agoMerge two `if`s.
Rui Ueyama [Sat, 2 Apr 2016 19:31:01 +0000 (19:31 +0000)]
Merge two `if`s.

llvm-svn: 265241

8 years agoAArch64: support .cpu directive
Saleem Abdulrasool [Sat, 2 Apr 2016 19:29:52 +0000 (19:29 +0000)]
AArch64: support .cpu directive

Add support for the AArch64 .cpu directive.  This is a slightly involved
directive since the parameter is actually a variable encoded string.  The
general structure is:

  <cpu>[[+-]<feature>]*

We now map some of the supported string names for features for internal
representation of feature flags.  If we encounter one which we do not support,
bail out as we cannot validate the assembly any longer.

Resolves PR27010.

llvm-svn: 265240

8 years agoVariable names should start with uppercase letters.
Rui Ueyama [Sat, 2 Apr 2016 19:15:26 +0000 (19:15 +0000)]
Variable names should start with uppercase letters.

llvm-svn: 265239

8 years agoclang-cl: Don't skip i_group flags other than -include when building pchs.
Nico Weber [Sat, 2 Apr 2016 19:10:07 +0000 (19:10 +0000)]
clang-cl: Don't skip i_group flags other than -include when building pchs.

Before this change, e.g. -isystem flags in front of the /FI corresponding to the
pch file would be incorrectly ignored.

llvm-svn: 265238

8 years agoRename a variable. NFC.
Rui Ueyama [Sat, 2 Apr 2016 19:09:07 +0000 (19:09 +0000)]
Rename a variable. NFC.

We had variables MB and Mb in this function. Rename of one them.

llvm-svn: 265237

8 years agoDo not return early.
Rui Ueyama [Sat, 2 Apr 2016 18:52:23 +0000 (18:52 +0000)]
Do not return early.

Early return in this context is a bit confusing, so avoid doing it.

llvm-svn: 265236

8 years agoMove code to initialize LLVM to one place.
Rui Ueyama [Sat, 2 Apr 2016 18:18:44 +0000 (18:18 +0000)]
Move code to initialize LLVM to one place.

llvm-svn: 265235

8 years agoRemove DefinedElf class.
Rui Ueyama [Sat, 2 Apr 2016 18:06:18 +0000 (18:06 +0000)]
Remove DefinedElf class.

DefinedElf was a superclass of DefinedRegular and SharedSymbol classes
and represented the notion of defined symbols created for ELF symbols.

It turned out that we didn't use that class often. We had only two
occurrences of dyn_cast'ing to DefinedElf, and both were easily
rewritten without it.

The class was also a bit confusing. The concept of "created for ELF
symbol" is orthogonal to defined/undefined types. However, we had
two distinct classes, DefinedElf and UndefinedElf.

This patch simply removes the class. Now the class hierarchy is one
level shallower.

llvm-svn: 265234

8 years agoLinker: Split mapUnneededSubprograms into two; almost NFC
Duncan P. N. Exon Smith [Sat, 2 Apr 2016 17:54:01 +0000 (17:54 +0000)]
Linker: Split mapUnneededSubprograms into two; almost NFC

Split the loop through compile units in mapUnneededSubprograms in two.
First, visit imported entities to ensure that we've visited all need
subprograms.  Second, visit subprograms, and drop the ones we don't
need.

Hypothetically this protects against a subprogram from one compile unit
being referenced from an imported entity in a different compile unit.  I
don't think that's valid IR (a debug info expert could confirm), but I
think the refactor makes the code more clear.

llvm-svn: 265233

8 years agoRemove redundant assertion after cast, NFC
Duncan P. N. Exon Smith [Sat, 2 Apr 2016 17:41:52 +0000 (17:41 +0000)]
Remove redundant assertion after cast, NFC

llvm-svn: 265232

8 years agoLinker: Avoid unnecessary work when moving named metadata
Duncan P. N. Exon Smith [Sat, 2 Apr 2016 17:39:31 +0000 (17:39 +0000)]
Linker: Avoid unnecessary work when moving named metadata

IRLinker::mapUnneededSubprograms has to be sure that any "needed"
subprograms get linked in.  Rather than traversing through imported
entities using llvm::getSubprogram, call MapMetadata.  The latter
memoizes the result in the ValueMap (sharing work with
IRLinker::linkNamedMDNodes proper), and makes the local SmallPtrSet
redundant.

llvm-svn: 265231

8 years agoRename FunctionIndex into GlobalValueIndex to reflect the recent changes (NFC)
Mehdi Amini [Sat, 2 Apr 2016 17:29:47 +0000 (17:29 +0000)]
Rename FunctionIndex into GlobalValueIndex to reflect the recent changes (NFC)

The index used to contain only Function, but now contains GlobalValue
in general.

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

8 years agoLinker: Remove IRMover::isMetadataUnneeded indirection; almost NFC
Duncan P. N. Exon Smith [Sat, 2 Apr 2016 17:12:00 +0000 (17:12 +0000)]
Linker: Remove IRMover::isMetadataUnneeded indirection; almost NFC

Instead of checking live during MapMetadata whether a subprogram is
needed, seed the ValueMap with `nullptr` up-front.

There is a small hypothetical functionality change.  Previously, calling
MapMetadataOp on a node whose "scope:" chain led to an unneeded
subprogram would return nullptr.  However, if that were ever called,
then the subprogram would be needed; a situation that the IRMover is
supposed to avoid a priori!

Besides cleaning up the code a little, this restores a nice property:
MapMetadataOp returns the same as MapMetadata.

llvm-svn: 265229

8 years agoValueMapper: Add support for seeding metadata with nullptr
Duncan P. N. Exon Smith [Sat, 2 Apr 2016 17:04:38 +0000 (17:04 +0000)]
ValueMapper: Add support for seeding metadata with nullptr

Support seeding a ValueMap with nullptr for Metadata entries, a
situation I didn't consider in the Metadata/Value split.

I added a ValueMapper::getMappedMD accessor that returns an
Optional<Metadata*> with the mapped (possibly null) metadata.  IRMover
needs to use this to avoid modifying the map when it's checking for
unneeded subprograms.  I updated a call from bugpoint since I find the
new code clearer.

llvm-svn: 265228

8 years agoDocument end of anonymous namespaces, NFC
Duncan P. N. Exon Smith [Sat, 2 Apr 2016 16:45:51 +0000 (16:45 +0000)]
Document end of anonymous namespaces, NFC

Prevent clang-format from deleting the preceding newline.

llvm-svn: 265227

8 years agoBitcode: Try to emit metadata in function blocks
Duncan P. N. Exon Smith [Sat, 2 Apr 2016 15:22:57 +0000 (15:22 +0000)]
Bitcode: Try to emit metadata in function blocks

Whenever metadata is only referenced by a single function, emit the
metadata just in that function block.  This should improve lazy-loading
by reducing the amount of metadata in the global block.

For now, this should catch all DILocations, and anything else that
happens to be referenced only by a single function.

It's also a first step toward a couple of possible future directions
(which this commit does *not* implement):

 1. Some debug info metadata is only referenced from compile units and
    individual functions.  If we can drop the link from the compile
    unit, this optimization will get more powerful.

 2. Any uniqued metadata that isn't referenced globally can in theory be
    emitted in every function block that references it (trading off
    bitcode size and full-parse time vs. lazy-load time).

Note: this assumes the new BitcodeReader error checking from r265223.
The metadata stored in function blocks gets purged after parsing each
function, which means unresolved forward references will get lost.
Since all the global metadata should have already been resolved by the
time we get to the function metadata blocks we just need to check for
that case.  (If for some reason we need to handle bitcode that fails the
checks in r265223, the fix is to store about-to-be-dropped unresolved
nodes in MetadataList::shrinkTo until they can be handled succesfully by
a future call to MetadataList::tryToResolveCycles.)

llvm-svn: 265226

8 years agoFix doxygen comments from r265224, NFC
Duncan P. N. Exon Smith [Sat, 2 Apr 2016 15:16:56 +0000 (15:16 +0000)]
Fix doxygen comments from r265224, NFC

llvm-svn: 265225