platform/upstream/llvm.git
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

8 years ago[MachineScheduler]Add support for store clustering
Jun Bum Lim [Fri, 15 Apr 2016 14:58:38 +0000 (14:58 +0000)]
[MachineScheduler]Add support for store clustering

Perform store clustering just like load clustering. This change add
StoreClusterMutation in machine-scheduler. To control StoreClusterMutation,
added enableClusterStores() in TargetInstrInfo.h. This is enabled only on
AArch64 for now.

This change also add support for unscaled stores which were not handled in
getMemOpBaseRegImmOfs().

llvm-svn: 266437

8 years ago[Coverage] Prevent detection of false instantiations in case of macro expansion.
Igor Kudrin [Fri, 15 Apr 2016 14:56:50 +0000 (14:56 +0000)]
[Coverage] Prevent detection of false instantiations in case of macro expansion.

The root of the problem was that findMainViewFileID(File, Function)
could return some ID for any given file, even though that file
was not the main file for that function.

This patch ensures that the result of this function is conformed
with the result of findMainViewFileID(Function).

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

llvm-svn: 266436

8 years ago[SimplifyCFG] add metadata to show failure to propagate (PR27344)
Sanjay Patel [Fri, 15 Apr 2016 14:53:35 +0000 (14:53 +0000)]
[SimplifyCFG] add metadata to show failure to propagate (PR27344)

llvm-svn: 266435

8 years ago[Coverage] Add support for making test data for more than one function.
Igor Kudrin [Fri, 15 Apr 2016 14:46:31 +0000 (14:46 +0000)]
[Coverage] Add support for making test data for more than one function.

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

llvm-svn: 266434

8 years agoAMDGPU/SI: Fix regression with no-return atomics
Nicolai Haehnle [Fri, 15 Apr 2016 14:42:36 +0000 (14:42 +0000)]
AMDGPU/SI: Fix regression with no-return atomics

Summary:
In the added test-case, the atomic instruction feeds into a non-machine
CopyToReg node which hasn't been selected yet, so guard against
non-machine opcodes here.

Reviewers: arsenm, tstellarAMD

Subscribers: arsenm, llvm-commits

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

llvm-svn: 266433

8 years agoStore a Symbol for EntrySym.
Rafael Espindola [Fri, 15 Apr 2016 14:41:56 +0000 (14:41 +0000)]
Store a Symbol for EntrySym.

This makes it impossible to forget to call repl on the SymbolBody.

llvm-svn: 266432

8 years agoRevert r266415, it broke parsing SDK headers (PR27367).
Nico Weber [Fri, 15 Apr 2016 14:35:06 +0000 (14:35 +0000)]
Revert r266415, it broke parsing SDK headers (PR27367).

llvm-svn: 266431

8 years agoprepare-builtins: Remove call to getGlobalContext()
Tom Stellard [Fri, 15 Apr 2016 14:18:58 +0000 (14:18 +0000)]
prepare-builtins: Remove call to getGlobalContext()

This function has been removed from LLVM.

Patch By: Laurent Carlier

llvm-svn: 266430

8 years agoAdd a testcase for symbol resolution with -r.
Rafael Espindola [Fri, 15 Apr 2016 14:11:36 +0000 (14:11 +0000)]
Add a testcase for symbol resolution with -r.

llvm-svn: 266429

8 years agoRemove include duplicate. NFC.
Alexey Bader [Fri, 15 Apr 2016 13:23:26 +0000 (13:23 +0000)]
Remove include duplicate. NFC.

llvm-svn: 266428

8 years agoDon't create relocations for absolute got entries.
Rafael Espindola [Fri, 15 Apr 2016 12:44:43 +0000 (12:44 +0000)]
Don't create relocations for absolute got entries.

llvm-svn: 266427

8 years ago[TSAN] Make tsan tests more portable (take 3)
Renato Golin [Fri, 15 Apr 2016 12:34:00 +0000 (12:34 +0000)]
[TSAN] Make tsan tests more portable (take 3)

Some tests didn't merge stderr with stdout.

Patch by Maxim Kuvyrkov.

llvm-svn: 266426

8 years agoDon't create relocations for non preemptable absolute symbols.
Rafael Espindola [Fri, 15 Apr 2016 12:22:22 +0000 (12:22 +0000)]
Don't create relocations for non preemptable absolute symbols.

llvm-svn: 266425

8 years agoTwo small related fixes.
Rafael Espindola [Fri, 15 Apr 2016 11:57:07 +0000 (11:57 +0000)]
Two small related fixes.

* A hidden undefined is not preemptable.
* It is always zero, so we don't need a dynamic reloc for it.

llvm-svn: 266424

8 years agoWork around a linux libc bug causing a crash in TaskPool
Pavel Labath [Fri, 15 Apr 2016 10:49:07 +0000 (10:49 +0000)]
Work around a linux libc bug causing a crash in TaskPool

Summary:
Doing a pthread_detach while the thread is exiting can cause crashes or other mischief, so we
make sure the thread stays around long enough. The performance impact of the added
synchronization should be minimal, as the parent thread is already holding a mutex, so I am just
making sure it holds it for a little while longer. It's possible the new thread will block on
this mutex immediately after startup, but it should be unblocked really quickly and some
blocking is unavoidable if we actually want to have this synchronization.

Reviewers: tberghammer

Subscribers: lldb-commits

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

llvm-svn: 266423

8 years agoFix usage of APInt.getRawData for big-endian systems
Ulrich Weigand [Fri, 15 Apr 2016 09:55:52 +0000 (09:55 +0000)]
Fix usage of APInt.getRawData for big-endian systems

Recommit modified version of r266311 including build bot regression fix.

This differs from the original r266311 by:

- Fixing Scalar::Promote to correctly zero- or sign-extend value depending
  on signedness of the *source* type, not the target type.

- Omitting a few stand-alone fixes that were already committed separately.

llvm-svn: 266422

8 years ago[ELF] Remove redundant empty line. NFC
Simon Atanasyan [Fri, 15 Apr 2016 09:47:36 +0000 (09:47 +0000)]
[ELF] Remove redundant empty line. NFC

llvm-svn: 266421

8 years agoMake Scalar::SChar return an explicit signed type
Ulrich Weigand [Fri, 15 Apr 2016 09:15:47 +0000 (09:15 +0000)]
Make Scalar::SChar return an explicit signed type

This is needed for platforms where the default "char" type is unsigned.

Originally committed as part of (now reverted) r266311.

llvm-svn: 266420

8 years agoFix Scalar::MakeSigned for 128- and 256-bit types.
Ulrich Weigand [Fri, 15 Apr 2016 09:15:22 +0000 (09:15 +0000)]
Fix Scalar::MakeSigned for 128- and 256-bit types.

Obvious fix for incorrect result types of the operation.

Originally committed as part of (now reverted) r266311.

llvm-svn: 266419

8 years agoFix Scalar::SetValueFromData for 128- and 256-bit types
Ulrich Weigand [Fri, 15 Apr 2016 09:14:59 +0000 (09:14 +0000)]
Fix Scalar::SetValueFromData for 128- and 256-bit types

Obvious fix for incorrect use of GetU64 offset pointer.

Originally committed as part of (now reverted) r266311.

llvm-svn: 266418

8 years agoFix ABISysV_s390x::GetArgumentValues
Ulrich Weigand [Fri, 15 Apr 2016 09:14:32 +0000 (09:14 +0000)]
Fix ABISysV_s390x::GetArgumentValues

This routine contained a stray "return false;" making part of the code
never executed.  Also, the stack offset where to find on-stack arguments
was incorrect.

llvm-svn: 266417

8 years agoMake destructor breakpoint location test more resilient
Pavel Labath [Fri, 15 Apr 2016 09:11:22 +0000 (09:11 +0000)]
Make destructor breakpoint location test more resilient

Summary:
The original breakpoint location test was failing for linux, because the compilers here tend to
merge the full-object and subobject destructors even at -O0 (as a result, we are getting only 2
breakpoint locations, and not 4 as the test expected. The fixup in r266164 substantially weakened
the test, as it now did not check whether both kinds of destructors were being found.

Because of these contraints, I have altered the logic of the test. It sets the
breakpoint by name, and then independently verifies that the breakpoint is set on the correct
demangled symbol name (which is not very meaningful since both kinds of destructors demangle to
the same name) *and* the correct symbol address (which is obtained by looking up the mangled
symbol name).

Reviewers: clayborg

Subscribers: ovyalov, zturner, lldb-commits

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

llvm-svn: 266416

8 years ago[MSVC Compat] Implementation of __unaligned (MS extension) as a type qualifier
Andrey Bokhanko [Fri, 15 Apr 2016 08:03:51 +0000 (08:03 +0000)]
[MSVC Compat] Implementation of __unaligned (MS extension) as a type qualifier

This patch implements __unaligned as a type qualifier; before that, it was
modeled as an attribute. Proper mangling of __unaligned is implemented as well.
Some OpenCL code/tests are tangenially affected, as they relied on existing
number and sizes of type qualifiers.

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

llvm-svn: 266415

8 years agoUse MVT instead of EVT to remove a bunch of unnecessary calls to getSimpleVT.
Craig Topper [Fri, 15 Apr 2016 06:20:21 +0000 (06:20 +0000)]
Use MVT instead of EVT to remove a bunch of unnecessary calls to getSimpleVT.

llvm-svn: 266414

8 years agoAdd a setOperationPromotedToType convenience method that sets an operation to promote...
Craig Topper [Fri, 15 Apr 2016 06:20:18 +0000 (06:20 +0000)]
Add a setOperationPromotedToType convenience method that sets an operation to promoted and set the type in one call. Use it so save code in X86.

llvm-svn: 266413

8 years ago[X86] AND, OR, and XOR of vectors are always legal no need to set them legal explicitly.
Craig Topper [Fri, 15 Apr 2016 06:20:14 +0000 (06:20 +0000)]
[X86] AND, OR, and XOR of vectors are always legal no need to set them legal explicitly.

llvm-svn: 266412

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

Summary:
Removed unwanted --check-prefix=CHECK from the following unit tests:
      DeadCodeElimination/dead_iteration_elimination.ll
      Isl/CodeGen/simple_vec_cast.ll

Patch by: Mandeep Singh Grang (mgrang)

Reviewers: jdoerfert, zinob, spop, grosser

Projects: #polly

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

llvm-svn: 266411

8 years ago[X86] Combine an if and else block that had the same set of calls to setOperationActi...
Craig Topper [Fri, 15 Apr 2016 04:57:09 +0000 (04:57 +0000)]
[X86] Combine an if and else block that had the same set of calls to setOperationAction that only varied in Legal/Custom. Use the ternary operator on that argument instead. NFC

llvm-svn: 266410

8 years ago[libcxx] Remove the "reduced-arity-initialization" extension from the uses-allocator...
Eric Fiselier [Fri, 15 Apr 2016 03:29:40 +0000 (03:29 +0000)]
[libcxx] Remove the "reduced-arity-initialization" extension from the uses-allocator constructors

Summary:
A default uses-allocator constructor has been added since that overload was previously provided by the extended constructor.

Since Clang does implicit conversion checking after substitution this constructor has to deduce the allocator_arg_t parameter so that it can prevent the evaluation of "is_default_constructible" if the first argument doesn't match. See http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1391 for more information.

This patch fixes PR24779 (https://llvm.org/bugs/show_bug.cgi?id=24779)

Subscribers: cfe-commits

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

llvm-svn: 266409

8 years agoRevert "[LTO] Add a new splitCodeGen() API which takes a TargetMachineFactory."
Davide Italiano [Fri, 15 Apr 2016 02:07:03 +0000 (02:07 +0000)]
Revert "[LTO] Add a new splitCodeGen() API which takes a TargetMachineFactory."

This reverts commits r266390 and r266396 as they broke some bots.

llvm-svn: 266408

8 years agoAdd the PDBParser.{cpp,h} files to the Xcode project.
Jim Ingham [Fri, 15 Apr 2016 01:42:30 +0000 (01:42 +0000)]
Add the PDBParser.{cpp,h} files to the Xcode project.

llvm-svn: 266407

8 years ago[NVPTX] Set NVPTXTTI::getInliningThresholdMultiplier to 5.
Justin Lebar [Fri, 15 Apr 2016 01:38:50 +0000 (01:38 +0000)]
[NVPTX] Set NVPTXTTI::getInliningThresholdMultiplier to 5.

Summary:
Calls on NVPTX are unusually expensive (for one thing, lots of state
needs to be saved to memory, which is slow), so make the inlininer much
more aggressive.

Reviewers: chandlerc

Subscribers: jholewinski, llvm-commits, tra

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

llvm-svn: 266406

8 years ago[TTI] Add getInliningThresholdMultiplier.
Justin Lebar [Fri, 15 Apr 2016 01:38:48 +0000 (01:38 +0000)]
[TTI] Add getInliningThresholdMultiplier.

Summary:
InlineCost's threshold is multiplied by this value.  This lets us adjust
the inlining threshold up or down on a per-target basis.  For example,
we might want to increase the threshold on targets where calls are
unusually expensive.

Reviewers: chandlerc

Subscribers: llvm-commits

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

llvm-svn: 266405

8 years ago[ifcnv] Don't duplicate blocks that contain convergent instructions.
Justin Lebar [Fri, 15 Apr 2016 01:38:41 +0000 (01:38 +0000)]
[ifcnv] Don't duplicate blocks that contain convergent instructions.

It's unsafe to duplicate blocks that contain convergent instructions
during ifcnv.  See the patch for details.

Reviewers: hfinkel

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

llvm-svn: 266404

8 years agoMove divergent-target test into CodeGen/NVPTX because it requires an NVPTX target.
Justin Lebar [Fri, 15 Apr 2016 01:20:52 +0000 (01:20 +0000)]
Move divergent-target test into CodeGen/NVPTX because it requires an NVPTX target.

llvm-svn: 266403

8 years agoclang-cl: Don't check for existence of linker inputs when /link is used
Hans Wennborg [Fri, 15 Apr 2016 01:12:32 +0000 (01:12 +0000)]
clang-cl: Don't check for existence of linker inputs when /link is used

There might be flags passed to the linker (e.g. /libpath), causing it
to search in paths the Clang driver doesn't know about.

PR27234

llvm-svn: 266402

8 years agoRename out->std_out in AppleObjCRuntimeV2.cpp.
Oleksiy Vyalov [Fri, 15 Apr 2016 00:56:11 +0000 (00:56 +0000)]
Rename out->std_out in AppleObjCRuntimeV2.cpp.

llvm-svn: 266401

8 years agoBlocks are only reliably supported on Darwin. Disable the test otherwise.
Sean Callanan [Fri, 15 Apr 2016 00:44:59 +0000 (00:44 +0000)]
Blocks are only reliably supported on Darwin.  Disable the test otherwise.

llvm-svn: 266400

8 years ago[PM] Add a SpeculativeExecution pass for targets with divergent branches.
Justin Lebar [Fri, 15 Apr 2016 00:32:12 +0000 (00:32 +0000)]
[PM] Add a SpeculativeExecution pass for targets with divergent branches.

Summary:
This IR pass is helpful for GPUs, and other targets with divergent
branches.  It's a nop on targets without divergent branches.

Reviewers: chandlerc

Subscribers: llvm-commits, jingyue, rnk, joker.eph, tra

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

llvm-svn: 266399

8 years ago[Speculation] Add a SpeculativeExecution mode where the pass does nothing unless...
Justin Lebar [Fri, 15 Apr 2016 00:32:09 +0000 (00:32 +0000)]
[Speculation] Add a SpeculativeExecution mode where the pass does nothing unless TTI::hasBranchDivergence() is true.

Summary:
This lets us add this pass to the IR pass manager unconditionally; it
will simply not do anything on targets without branch divergence.

Reviewers: tra

Subscribers: llvm-commits, jingyue, rnk, chandlerc

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

llvm-svn: 266398

8 years agoAdded a testcase for defining and using lambdas in the expression parser.
Sean Callanan [Fri, 15 Apr 2016 00:26:32 +0000 (00:26 +0000)]
Added a testcase for defining and using lambdas in the expression parser.

<rdar://problem/25739133>

llvm-svn: 266397

8 years ago[ParallelCG] Attempt to placate MSVC.
Davide Italiano [Fri, 15 Apr 2016 00:25:19 +0000 (00:25 +0000)]
[ParallelCG] Attempt to placate MSVC.

llvm-svn: 266396

8 years agoclang-cl: Make /link accept an optional joined argument.
Hans Wennborg [Fri, 15 Apr 2016 00:24:15 +0000 (00:24 +0000)]
clang-cl: Make /link accept an optional joined argument.

For example, "cl.exe a.c /linkfoo bar" is a valid invocation and
forwards "foo" and "bar" to link.exe. This makes clang-cl handle
that kind of invocation.

Depends on LLVM r266394.

llvm-svn: 266395

8 years agoOption parser: class for consuming a joined arg in addition to all remaining args
Hans Wennborg [Fri, 15 Apr 2016 00:23:30 +0000 (00:23 +0000)]
Option parser: class for consuming a joined arg in addition to all remaining args

llvm-svn: 266394

8 years agoOptionParsingTest.cpp: reorder EXPECT_EQs to put expectation on the left. NFC.
Hans Wennborg [Fri, 15 Apr 2016 00:23:15 +0000 (00:23 +0000)]
OptionParsingTest.cpp: reorder EXPECT_EQs to put expectation on the left. NFC.

This provides for better error messages from the framework when the expected
and actual values don't match.

llvm-svn: 266393

8 years agoInitial support for reading type information from PDBs.
Zachary Turner [Fri, 15 Apr 2016 00:21:26 +0000 (00:21 +0000)]
Initial support for reading type information from PDBs.

This implements a PDBASTParser and corresponding logic in
SymbolFilePDB to do type lookup by name.  This is just a first
pass and leaves many aspects of type lookup unimplemented, and
just focuses on laying the framework.  With this patch, you should
be able to lookup basic types by name from a PDB.

Full class definitions are not completed yet, we will instead
just return a forward declaration of the class.

Differential Revision: http://reviews.llvm.org/D18848
Reviewed by: Greg Clayton

llvm-svn: 266392

8 years agoDelete a dead repl.
Rafael Espindola [Fri, 15 Apr 2016 00:15:02 +0000 (00:15 +0000)]
Delete a dead repl.

It is only ever used on symbols taken from the symbol table.

llvm-svn: 266391

8 years ago[LTO] Add a new splitCodeGen() API which takes a TargetMachineFactory.
Davide Italiano [Fri, 15 Apr 2016 00:07:28 +0000 (00:07 +0000)]
[LTO] Add a new splitCodeGen() API which takes a TargetMachineFactory.

This will be used in lld to avoid creating TargetMachine in two
different places. See D18999 for a more detailed discussion.

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

llvm-svn: 266390

8 years agoAdded a testcase for defining and using a block in the expression parser.
Sean Callanan [Fri, 15 Apr 2016 00:05:50 +0000 (00:05 +0000)]
Added a testcase for defining and using a block in the expression parser.

<rdar://problem/25738696>

llvm-svn: 266389

8 years agoFix StaticAnalyzer complaints. NFC.
George Burgess IV [Thu, 14 Apr 2016 23:58:26 +0000 (23:58 +0000)]
Fix StaticAnalyzer complaints. NFC.

Clang's StaticAnalyzer seems to (correctly) complain about code like:

    T *p = calloc(sizeof(U), N);

...Where T and U are different types.

This patch removes some instances of this pattern from compiler-rt.

Patch by Apelete Seketeli.
Differential Revision: http://reviews.llvm.org/D19085

llvm-svn: 266388

8 years agoLit C++11 Compatibility Patch #8
Charles Li [Thu, 14 Apr 2016 23:47:07 +0000 (23:47 +0000)]
Lit C++11 Compatibility Patch #8

24 tests have been updated for C++11 compatibility.

llvm-svn: 266387

8 years ago[test] Require 'asserts' for a test which uses -debug-only
Vedant Kumar [Thu, 14 Apr 2016 23:32:40 +0000 (23:32 +0000)]
[test] Require 'asserts' for a test which uses -debug-only

Without this line, bots which run check-all on Release compilers will
break.

llvm-svn: 266386

8 years agoAMDGPU: Remove custom load/store scalarization
Matt Arsenault [Thu, 14 Apr 2016 23:31:26 +0000 (23:31 +0000)]
AMDGPU: Remove custom load/store scalarization

llvm-svn: 266385

8 years agoDon't disable stdin buffering on Windows
Adrian McCarthy [Thu, 14 Apr 2016 23:31:17 +0000 (23:31 +0000)]
Don't disable stdin buffering on Windows

Disabling buffering exposes a bug in the MS VS 2015 CRT implementation of fgets, where you sometimes have to hit Enter twice, depending on if the input had an odd or even number of characters.

This was hidden until a few days ago by the Python initialization which was re-enabling buffering on the streams. A few days ago, Enrico make the Python initialization on-demand, which exposed this problem.

llvm-svn: 266384

8 years agoAMDGPU: Add test for generic builtin behavior
Matt Arsenault [Thu, 14 Apr 2016 22:34:39 +0000 (22:34 +0000)]
AMDGPU: Add test for generic builtin behavior

llvm-svn: 266383

8 years agoAMDGPU: Include LDS size in printed comment
Matt Arsenault [Thu, 14 Apr 2016 22:11:51 +0000 (22:11 +0000)]
AMDGPU: Include LDS size in printed comment

llvm-svn: 266382

8 years ago[AliasSetTracker] Correctly handle changing the size of an entry
Michael Kuperstein [Thu, 14 Apr 2016 22:00:11 +0000 (22:00 +0000)]
[AliasSetTracker] Correctly handle changing the size of an entry

If the size of an AST entry changes, we also need to make sure we perform
necessary alias set merges, as the new size may overlap pointers in other sets.
We happen to run into this with memset, because memset allows an entry for a
i8* pointer to have a decidedly non-i8 size.

This fixes PR27262.

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

llvm-svn: 266381

8 years agoNuke getGlobalContext() from LLVM (but the C API)
Mehdi Amini [Thu, 14 Apr 2016 21:59:18 +0000 (21:59 +0000)]
Nuke getGlobalContext() from LLVM (but the C API)

The only use for getGlobalContext() is in the C API.
Let's just move the static global here and nuke the C++ API.

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

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

8 years agoRemove every uses of getGlobalContext() in LLVM (but the C API)
Mehdi Amini [Thu, 14 Apr 2016 21:59:01 +0000 (21:59 +0000)]
Remove every uses of getGlobalContext() in LLVM (but the C API)

At the same time, fixes InstructionsTest::CastInst unittest: yes
you can leave the IR in an invalid state and exit when you don't
destroy the context (like the global one), no longer now.

This is the first part of http://reviews.llvm.org/D19094

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

8 years agoAMDGPU: Run SIFoldOperands after PeepholeOptimizer
Matt Arsenault [Thu, 14 Apr 2016 21:58:24 +0000 (21:58 +0000)]
AMDGPU: Run SIFoldOperands after PeepholeOptimizer

PeepholeOptimizer cleans up redundant copies, which makes
the operand folding more effective.

shader-db stats:

Totals:
SGPRS: 34200 -> 34336 (0.40 %)
VGPRS: 22118 -> 21655 (-2.09 %)
Code Size: 632144 -> 633460 (0.21 %) bytes
LDS: 11 -> 11 (0.00 %) blocks
Scratch: 10240 -> 11264 (10.00 %) bytes per wave
Max Waves: 8822 -> 8918 (1.09 %)
Wait states: 0 -> 0 (0.00 %)

Totals from affected shaders:
SGPRS: 7704 -> 7840 (1.77 %)
VGPRS: 5169 -> 4706 (-8.96 %)
Code Size: 234444 -> 235760 (0.56 %) bytes
LDS: 2 -> 2 (0.00 %) blocks
Scratch: 0 -> 1024 (0.00 %) bytes per wave
Max Waves: 1188 -> 1284 (8.08 %)
Wait states: 0 -> 0 (0.00 %)

Increases:
SGPRS: 35 (0.01 %)
VGPRS: 1 (0.00 %)
Code Size: 59 (0.02 %)
LDS: 0 (0.00 %)
Scratch: 1 (0.00 %)
Max Waves: 48 (0.02 %)
Wait states: 0 (0.00 %)

Decreases:
SGPRS: 26 (0.01 %)
VGPRS: 54 (0.02 %)
Code Size: 68 (0.03 %)
LDS: 0 (0.00 %)
Scratch: 0 (0.00 %)
Max Waves: 4 (0.00 %)
Wait states: 0 (0.00 %)

llvm-svn: 266378

8 years agoAMDGPU: Directly emit m0 initialization with s_mov_b32
Matt Arsenault [Thu, 14 Apr 2016 21:58:15 +0000 (21:58 +0000)]
AMDGPU: Directly emit m0 initialization with s_mov_b32

Currently what comes out of instruction selection is a
register initialized to -1, and then copied to m0.
MachineCSE doesn't consider copies, but we want these
to be CSEed. This isn't much of a problem currently,
because SIFoldOperands is run immediately after.

This avoids regressions when SIFoldOperands is run later
from leaving all copies to m0.

llvm-svn: 266377

8 years agoAMDGPU: Fold bitcasts of scalar constants to vectors
Matt Arsenault [Thu, 14 Apr 2016 21:58:07 +0000 (21:58 +0000)]
AMDGPU: Fold bitcasts of scalar constants to vectors

This cleans up some messes since the individual scalar components
can be CSEed.

llvm-svn: 266376

8 years agoDo not use llvm::getGlobalContext().
Rui Ueyama [Thu, 14 Apr 2016 21:41:44 +0000 (21:41 +0000)]
Do not use llvm::getGlobalContext().

llvm-svn: 266375

8 years agoRevert "Do not use llvm::getGlobalContext(), trying to nuke it from LLVM"
Mehdi Amini [Thu, 14 Apr 2016 21:31:46 +0000 (21:31 +0000)]
Revert "Do not use llvm::getGlobalContext(), trying to nuke it from LLVM"

This reverts commit r266365 and r266367, the contexts in the two
places have to match.

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

8 years ago[ScheduleDAGInstrs] Re-factor for based on review feedback. NFC.
Geoff Berry [Thu, 14 Apr 2016 21:31:07 +0000 (21:31 +0000)]
[ScheduleDAGInstrs] Re-factor for based on review feedback. NFC.

Summary:
Re-factor some code to improve clarity and style based on review
comments from http://reviews.llvm.org/D18093.

Reviewers: MatzeB, mcrosier

Subscribers: MatzeB, mcrosier, llvm-commits

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

llvm-svn: 266372

8 years ago[sanitizer] [SystemZ] Fix stack traces.
Marcin Koscielnicki [Thu, 14 Apr 2016 21:19:27 +0000 (21:19 +0000)]
[sanitizer] [SystemZ] Fix stack traces.

On s390, the return address is in %r14, which is saved 14 words from
the frame pointer.

Unfortunately, there's no way to do a proper fast backtrace on SystemZ
with current LLVM - the saved %r15 in fixed-layout register save
area points to the containing frame itself, and not to the next one.
Likewise for %r11 - it's identical to %r15, unless alloca is used
(and even if it is, it's still useless).  There's just no way to
determine frame size / next frame pointer.  -mbackchain would fix that
(and make the current code just work), but that's not yet supported
in LLVM.  We will thus need to XFAIL some asan tests
(Linux/stack-trace-dlclose.cc, deep_stack_uaf.cc).

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

llvm-svn: 266371

8 years ago[sanitizer] [SystemZ] Add/fix kernel and libc type definitions.
Marcin Koscielnicki [Thu, 14 Apr 2016 21:17:19 +0000 (21:17 +0000)]
[sanitizer] [SystemZ] Add/fix kernel and libc type definitions.

This is the first part of upcoming asan support for s390 and s390x.
Note that there are bits for 31-bit support in this and subsequent
patches - while LLVM itself doesn't support it, gcc should be able
to make use of it just fine.

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

llvm-svn: 266370

8 years ago[clang-tidy] Add check misc-multiple-statement-macro
Samuel Benzaquen [Thu, 14 Apr 2016 21:15:57 +0000 (21:15 +0000)]
[clang-tidy] Add check misc-multiple-statement-macro

Summary:
The check detects multi-statement macros that are used in unbraced conditionals.
Only the first statement will be part of the conditionals and the rest will fall
outside of it and executed unconditionally.

Reviewers: alexfh

Subscribers: cfe-commits

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

llvm-svn: 266369

8 years ago[ELF][MIPS] Make R_MIPS_LO16 a relative relocation if it references _gp_disp symbol
Simon Atanasyan [Thu, 14 Apr 2016 21:10:05 +0000 (21:10 +0000)]
[ELF][MIPS] Make R_MIPS_LO16 a relative relocation if it references _gp_disp symbol

The _gp_disp symbol designates offset between start of function and 'gp'
pointer into GOT. The following code is a typical MIPS function preamble
used to setup $gp register:

lui    $gp, %hi(_gp_disp)
addi   $gp, $gp, %lo(_gp_disp)

To calculate R_MIPS_HI16 / R_MIPS_LO16 relocations results we use
the following formulas:

%hi(_gp - P + A)
%lo(_gp - P + A + 4),
where _gp is a value of _gp symbol, A is addend, and P current address.

The R_MIPS_LO16 relocation references _gp_disp symbol is always the second
instruction. That is why we need four byte adjustments. The patch assigns
R_PC type for R_MIPS_LO16 relocation and adjusts its addend by 4. That fix
R_MIPS_LO16 calculation.

For details see p. 4-19 at ftp://www.linux-mips.org/pub/linux/mips/doc/ABI/mipsabi.pdf

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

llvm-svn: 266368

8 years agoUse fully qualified name to refer to LLVMContext
Mehdi Amini [Thu, 14 Apr 2016 21:09:10 +0000 (21:09 +0000)]
Use fully qualified name to refer to LLVMContext

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

8 years agoIn vector comparisons, handle scalar LHS just as we handle scalar RHS
Reid Kleckner [Thu, 14 Apr 2016 21:03:38 +0000 (21:03 +0000)]
In vector comparisons, handle scalar LHS just as we handle scalar RHS

Summary: Fixes PR27258

Reviewers: rsmith

Subscribers: cfe-commits

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

llvm-svn: 266366

8 years agoDo not use llvm::getGlobalContext(), trying to nuke it from LLVM
Mehdi Amini [Thu, 14 Apr 2016 20:53:39 +0000 (20:53 +0000)]
Do not use llvm::getGlobalContext(), trying to nuke it from LLVM

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

8 years agoSpecialize the symbol table data structure a bit.
Rafael Espindola [Thu, 14 Apr 2016 20:42:43 +0000 (20:42 +0000)]
Specialize the symbol table data structure a bit.

We never need to iterate over the K,V pairs, so we can avoid copying the
key as MapVector does.

This is a small speedup on most benchmarks.

llvm-svn: 266364

8 years ago[ARM] Adding IEEE-754 SIMD detection to loop vectorizer
Renato Golin [Thu, 14 Apr 2016 20:42:18 +0000 (20:42 +0000)]
[ARM] Adding IEEE-754 SIMD detection to loop vectorizer

Some SIMD implementations are not IEEE-754 compliant, for example ARM's NEON.

This patch teaches the loop vectorizer to only allow transformations of loops
that either contain no floating-point operations or have enough allowance
flags supporting lack of precision (ex. -ffast-math, Darwin).

For that, the target description now has a method which tells us if the
vectorizer is allowed to handle FP math without falling into unsafe
representations, plus a check on every FP instruction in the candidate loop
to check for the safety flags.

This commit makes LLVM behave like GCC with respect to ARM NEON support, but
it stops short of fixing the underlying problem: sub-normals. Neither GCC
nor LLVM have a flag for allowing sub-normal operations. Before this patch,
GCC only allows it using unsafe-math flags and LLVM allows it by default with
no way to turn it off (short of not using NEON at all).

As a first step, we push this change to make it safe and in sync with GCC.
The second step is to discuss a new sub-normal's flag on both communitues
and come up with a common solution. The third step is to improve the FastMath
flags in LLVM to encode sub-normals and use those flags to restrict NEON FP.

Fixes PR16275.

llvm-svn: 266363

8 years ago[InstCombine] remove constant by inverting compare + logic (PR27105)
Sanjay Patel [Thu, 14 Apr 2016 20:17:40 +0000 (20:17 +0000)]
[InstCombine] remove constant by inverting compare + logic (PR27105)

https://llvm.org/bugs/show_bug.cgi?id=27105

We can check if all bits outside of a constant mask are set with a
single constant.

As noted in the bug report, although this form should be considered the
canonical IR, backends may want to transform this into an 'andn' / 'andc'
comparison against zero because that could be a single machine instruction.

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

llvm-svn: 266362

8 years agoFix Xcode project after recent s390x changes.
Greg Clayton [Thu, 14 Apr 2016 20:05:21 +0000 (20:05 +0000)]
Fix Xcode project after recent s390x changes.

llvm-svn: 266361

8 years agoFix null pointer access for discriminator assignment.
Dehao Chen [Thu, 14 Apr 2016 19:46:38 +0000 (19:46 +0000)]
Fix null pointer access for discriminator assignment.

Summary: This fixes the buildbot failure.

Reviewers: dnovillo, davidxl

Subscribers: llvm-commits

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

llvm-svn: 266360

8 years agoMake this code less brittle. The benefits of a fixed-size array aren't worth the...
Richard Smith [Thu, 14 Apr 2016 19:45:19 +0000 (19:45 +0000)]
Make this code less brittle. The benefits of a fixed-size array aren't worth the maintenance cost.

llvm-svn: 266359

8 years agoAdd support for type aliases to modernize-redundant-void-arg.cpp
Aaron Ballman [Thu, 14 Apr 2016 19:28:13 +0000 (19:28 +0000)]
Add support for type aliases to modernize-redundant-void-arg.cpp

Patch by Clement Courbet.

llvm-svn: 266358

8 years agoHash symbol names only once per global SymbolBody.
Rafael Espindola [Thu, 14 Apr 2016 19:17:16 +0000 (19:17 +0000)]
Hash symbol names only once per global SymbolBody.

The DenseMap doesn't store hash results. This means that when it is
resized it has to recompute them.

This patch is a small hack that wraps the StringRef in a struct that
remembers the hash value. That way we can be sure it is only hashed
once.

llvm-svn: 266357

8 years agoAMDGPU: Add skeleton GlobalIsel implementation
Tom Stellard [Thu, 14 Apr 2016 19:09:28 +0000 (19:09 +0000)]
AMDGPU: Add skeleton GlobalIsel implementation

Summary:
This adds the necessary target code to be able to run the ir translator.
Lowering function arguments and returns is a nop and there is no support
for RegBankSelect.

Reviewers: arsenm, qcolombet

Subscribers: arsenm, joker.eph, vkalintiris, llvm-commits

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

llvm-svn: 266356

8 years agoSimplify handling of size relocations. NFC.
Rafael Espindola [Thu, 14 Apr 2016 18:39:44 +0000 (18:39 +0000)]
Simplify handling of size relocations. NFC.

llvm-svn: 266355

8 years agoUpdate discriminator assignment algorithm to handle nested call correctly.
Dehao Chen [Thu, 14 Apr 2016 18:37:18 +0000 (18:37 +0000)]
Update discriminator assignment algorithm to handle nested call correctly.

Summary: Add discriminator for nested call correctly.

Reviewers: davidxl, dnovillo

Subscribers: llvm-commits

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

llvm-svn: 266354

8 years agoFix off-by-one error in worst-case number of offsets needed for an AST record.
Richard Smith [Thu, 14 Apr 2016 18:32:54 +0000 (18:32 +0000)]
Fix off-by-one error in worst-case number of offsets needed for an AST record.

llvm-svn: 266353

8 years agoFix regression in gnu_libstdcpp.py introduced by r266313
Ulrich Weigand [Thu, 14 Apr 2016 18:31:12 +0000 (18:31 +0000)]
Fix regression in gnu_libstdcpp.py introduced by r266313

CreateChildAtOffset needs a byte offset, not an element number.

llvm-svn: 266352

8 years agoSink DI metadata usage out of MachineInstr.h and MachineInstrBuilder.h
Reid Kleckner [Thu, 14 Apr 2016 18:29:59 +0000 (18:29 +0000)]
Sink DI metadata usage out of MachineInstr.h and MachineInstrBuilder.h

MachineInstr.h and MachineInstrBuilder.h are very popular headers,
widely included across all LLVM backends. It turns out that there only a
handful of TUs that actually care about DI operands on MachineInstrs.

After this change, touching DebugInfoMetadata.h and rebuilding llc only
needs 112 actions instead of 542.

llvm-svn: 266351

8 years ago[ValueMapper] Range-loopify to improve readability. NFC.
Davide Italiano [Thu, 14 Apr 2016 18:07:32 +0000 (18:07 +0000)]
[ValueMapper] Range-loopify to improve readability. NFC.

llvm-svn: 266350

8 years ago[lanai] Add custom lowering for SRL_PARTS i32.
Jacques Pienaar [Thu, 14 Apr 2016 17:59:22 +0000 (17:59 +0000)]
[lanai] Add custom lowering for SRL_PARTS i32.

llvm-svn: 266349

8 years ago[GlobalISel] Move GISelAccessor class into public headers
Tom Stellard [Thu, 14 Apr 2016 17:45:38 +0000 (17:45 +0000)]
[GlobalISel] Move GISelAccessor class into public headers

Reviewers: qcolombet

Subscribers: joker.eph, vkalintiris, llvm-commits

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

llvm-svn: 266348

8 years ago[DivergenceAnalysis] Treat PHI with incoming undef as constant
Nicolai Haehnle [Thu, 14 Apr 2016 17:42:47 +0000 (17:42 +0000)]
[DivergenceAnalysis] Treat PHI with incoming undef as constant

Summary:
If a PHI has an incoming undef, we can pretend that it is equal to one
non-undef, non-self incoming value.

This is particularly relevant in combination with the StructurizeCFG
pass, which introduces PHI nodes with undefs. Previously, this lead to
branch conditions that were uniform before StructurizeCFG to become
non-uniform afterwards, which confused the SIAnnotateControlFlow
pass.

This fixes a crash when Mesa radeonsi compiles a shader from
dEQP-GLES3.functional.shaders.switch.switch_in_for_loop_dynamic_vertex

Reviewers: arsenm, tstellarAMD, jingyue

Subscribers: llvm-commits

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

llvm-svn: 266347

8 years ago[StructurizeCFG] Annotate branches that were treated as uniform
Nicolai Haehnle [Thu, 14 Apr 2016 17:42:35 +0000 (17:42 +0000)]
[StructurizeCFG] Annotate branches that were treated as uniform

Summary:
This fully solves the problem where the StructurizeCFG pass does not
consider the same branches as uniform as the SIAnnotateControlFlow pass.
The patch in D19013 helps with this problem, but is not sufficient
(and, interestingly, causes a "regression" with one of the existing
test cases).

No tests included here, because tests in D19013 already cover this.

Reviewers: arsenm, tstellarAMD

Subscribers: arsenm, llvm-commits

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

llvm-svn: 266346

8 years agoAMDGPU: Remove SIFixSGPRLiveRanges pass
Nicolai Haehnle [Thu, 14 Apr 2016 17:42:29 +0000 (17:42 +0000)]
AMDGPU: Remove SIFixSGPRLiveRanges pass

Summary:
This pass is unnecessary and overly conservative. It was motivated by
situations like

  def %vreg0:SGPR_32
  ...
if-block:
  ..
  def %vreg1:SGPR_32
  ...
else-block:
  ...
  use %vreg0:SGPR_32
  ...

and similar situations with uses after the non-uniform control flow, where
we are not allowed to assign %vreg0 and %vreg1 to the same physical register,
even though in the original, thread/workitem-based CFG, it looks like the
live ranges of these registers do not overlap.

However, by the time register allocation runs, we have moved to a wave-based
CFG that accurately represents the fact that the wave may run through both
the if- and the else-block. So the live ranges of %vreg0 and %vreg1 already
overlap even without the SIFixSGPRLiveRanges pass.

In addition to proving this change correct, I have tested it with Piglit
and a small number of other tests.

Reviewers: arsenm, tstellarAMD

Subscribers: MatzeB, arsenm, llvm-commits

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

llvm-svn: 266345

8 years agoAMDGPU: change a redundant if () to an assert(). NFC
Nicolai Haehnle [Thu, 14 Apr 2016 17:42:18 +0000 (17:42 +0000)]
AMDGPU: change a redundant if () to an assert(). NFC

Summary:
I've been carrying this change around with me for a while, because the if ()
managed to confuse me while following the code. All callers ensure that the
assertion holds.

Reviewers: arsenm, tstellarAMD

Subscribers: arsenm, llvm-commits

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

llvm-svn: 266344

8 years agoDisable LinuxCoreTestCase.test_s390x
Ulrich Weigand [Thu, 14 Apr 2016 17:36:41 +0000 (17:36 +0000)]
Disable LinuxCoreTestCase.test_s390x

This seems to hang on non-s390x hosts.  Disable for now to get the build
bots going again.

llvm-svn: 266343

8 years ago[GlobalISel] Coding style and whitespace fixes
Tom Stellard [Thu, 14 Apr 2016 17:23:33 +0000 (17:23 +0000)]
[GlobalISel] Coding style and whitespace fixes

Reviewers: qcolombet

Subscribers: joker.eph, llvm-commits, vkalintiris

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

llvm-svn: 266342

8 years agoRevert r266311 - Fix usage of APInt.getRawData for big-endian systems
Ulrich Weigand [Thu, 14 Apr 2016 17:22:18 +0000 (17:22 +0000)]
Revert r266311 - Fix usage of APInt.getRawData for big-endian systems

Try to get 32-bit build bots running again.

llvm-svn: 266341