28281 Commits

Author SHA1 Message Date
Tim Northover
ea26cb1f48 GlobalISel: implement legalization pass, with just one transformation.
This adds the actual MachineLegalizeHelper to do the work and a trivial pass
wrapper that legalizes all instructions in a MachineFunction. Currently the
only transformation supported is splitting up a vector G_ADD into one acting on
smaller vectors.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276461 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-22 20:03:43 +00:00
Zachary Turner
428d4aa99f Make PDBFile store an msf::Layout.
Previously it was storing all the fields of an msf::Layout as
separate members.  This is a trivial cleanup to make it store
an msf::Layout directly.  This makes the code more readable
since it becomes clear which fields of PDBFile are actually the
msf specific layout information in a sea of other bookkeeping
fields.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276460 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-22 19:56:33 +00:00
Zachary Turner
9a3129ad49 [pdb] Have builders share a single BumpPtrAllocator.
This makes it easier to have the writable and readable PDB
interfaces share code since the read/write and write-only
interfaces now share a single allocator, you don't have to worry
about a builder building a read only interface and then having
the read-only interface's data become corrupt when the builder
goes out of scope.  Now the allocator is specified explicitly
to all constructors, so all interfaces can share a single allocator
that is scoped appropriately.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276459 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-22 19:56:26 +00:00
Zachary Turner
4ab13f5ec5 [msf] Create LLVMDebugInfoMsf
This provides a better layering of responsibilities among different
aspects of PDB writing code.  Some of the MSF related code was
contained in CodeView, and some was in PDB prior to this.  Further,
we were often saying PDB when we meant MSF, and the two are
actually independent of each other since in theory you can have
other types of data besides PDB data in an MSF.  So, this patch
separates the MSF specific code into its own library, with no
dependencies on anything else, and DebugInfoCodeView and
DebugInfoPDB take dependencies on DebugInfoMsf.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276458 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-22 19:56:05 +00:00
Wei Mi
a6c7a032fe [PM] Port BreakCriticalEdges to the new PM.
Differential Revision: https://reviews.llvm.org/D22688


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276449 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-22 18:04:25 +00:00
Anna Thomas
80ee170cb3 Invariant start/end intrinsics overloaded for address space
Summary:
The llvm.invariant.start and llvm.invariant.end intrinsics currently
support specifying invariant memory objects only in the default address
space.

With this change, these intrinsics are overloaded for any adddress space
for memory objects
and we can use these llvm invariant intrinsics in non-default address
spaces.

Example: llvm.invariant.start.p1i8(i64 4, i8 addrspace(1)* %ptr)

This overloaded intrinsic is needed for representing final or invariant
memory in managed languages.

Reviewers: apilipenko, reames

Subscribers: llvm-commits

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276447 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-22 17:49:40 +00:00
Matt Arsenault
30f0e3e4be AMDGPU: Add HSA dispatch id intrinsic
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276437 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-22 17:01:30 +00:00
Tim Northover
04e7d3ce19 GlobalISel: implement alloca instruction
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276433 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-22 16:59:52 +00:00
Xinliang David Li
7528433be1 [Profile] Cleanup: remove unused interface
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276431 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-22 16:11:56 +00:00
Lang Hames
780954376e [Support] Make ErrorAsOutParameter take an Error* rather than an Error&.
This allows ErrorAsOutParameter to work better with "optional" errors. For
example, consider a function where for certain input values it is known that
the function can't fail. This can now be written as:

Result foo(Arg X, Error *Err) {
  ErrorAsOutParameter EAO(Err);

  if (<Error Condition>) {
    if (Err)
      *Err = <report error>;
    else
      llvm_unreachable("Unexpected failure!");
  }
}

Rather than having to construct an ErrorAsOutParameter under every conditional
where Err is known to be non-null.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276430 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-22 16:11:25 +00:00
Zachary Turner
44bd3bd7dc [pdb] Move file layout header structs to RawTypes.h
This facilitates code reuse between the builder classes and the
"frozen" read only versions of the classes used for parsing
existing PDB files.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276427 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-22 15:46:46 +00:00
Zachary Turner
6406b60a78 [pdb] Round-trip module & file info to/from YAML.
This implements support for writing compiland and compiland source
file info to a binary PDB.  This is tested by adding support for
dumping these fields from an existing PDB to yaml, reading them
back in, and dumping them again and verifying the values are as
expected.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276426 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-22 15:46:37 +00:00
Simon Pilgrim
370589a158 [X86][AVX] Added support for lowering to VBROADCASTF128/VBROADCASTI128 (reapplied)
As reported on PR26235, we don't currently make use of the VBROADCASTF128/VBROADCASTI128 instructions (or the AVX512 equivalents) to load+splat a 128-bit vector to both lanes of a 256-bit vector.

This patch enables lowering from subvector insertion/concatenation patterns and auto-upgrades the llvm.x86.avx.vbroadcastf128.pd.256 / llvm.x86.avx.vbroadcastf128.ps.256 intrinsics to match.

We could possibly investigate using VBROADCASTF128/VBROADCASTI128 to load repeated constants as well (similar to how we already do for scalar broadcasts).

Reapplied with fix for PR28657 - removed intrinsic definitions (clang companion patch to be be submitted shortly).

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276416 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-22 13:58:44 +00:00
Xinliang David Li
9fb35fc1cc Sync up InstrProfData.inc with compiler-rt with fixes to references
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276388 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-22 04:46:56 +00:00
Xinliang David Li
ffdd4801d1 Revert 276386
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276387 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-22 04:31:26 +00:00
Xinliang David Li
4e19f6e23a Sync up InstrProfData.inc with compiler-rt
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276386 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-22 04:18:17 +00:00
Pete Cooper
59023bf389 Avoid dsymutil calls to getFileNameByIndex.
This change adds a hasFileAtIndex method. getChildDeclContext can first call this method, and if it returns true it knows it can then lookup the resolved path cache for the given file index. If we hit that cache then we don't even have to call getFileNameByIndex.

Running dsymutil against the swift executable built from github gives a 20% performance improvement without any change in the binary.

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

Reviewed by friss.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276380 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-22 01:41:32 +00:00
Xinliang David Li
5a06a46a4f [Profile] deprecate __llvm_profile_override_default_filename
This eliminates unncessary calls and init functions.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276354 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-21 23:19:10 +00:00
Wei Mi
3a4fa31d34 [PM] Port NaryReassociate to the new PM
Differential Revision: https://reviews.llvm.org/D22648


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276349 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-21 22:28:52 +00:00
Rong Xu
8dbdfe6cb7 [PGO] Make needsComdatForCounter() available (NFC)
Move needsComdatForCounter() to lib/ProfileData/InstrProf.cpp from
lib/Transforms/Instrumentation/InstrProfiling.cpp to make is available for
other files.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276330 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-21 20:50:02 +00:00
Anna Thomas
d89a69b5fd Revert "Invariant start/end intrinsics overloaded for address space"
This reverts commit r276316.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276320 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-21 19:06:28 +00:00
Anna Thomas
4227f92f58 Invariant start/end intrinsics overloaded for address space
Summary:
The llvm.invariant.start and llvm.invariant.end intrinsics currently
support specifying invariant memory objects only in the default address space.

With this change, these intrinsics are overloaded for any adddress space for memory objects
and we can use these llvm invariant intrinsics in non-default address spaces.

Example: llvm.invariant.start.p1i8(i64 4, i8 addrspace(1)* %ptr)

This overloaded intrinsic is needed for representing final or invariant memory in managed languages.

Reviewers: tstellarAMD, reames, apilipenko

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276316 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-21 18:41:44 +00:00
Quentin Colombet
9abf24c5c4 [IRTranslator] Add G_SUB opcode.
This commit adds a generic SUB opcode to global-isel.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276308 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-21 17:26:50 +00:00
Quentin Colombet
513679d9f5 [IRTranslator] Add G_AND opcode.
This commit adds a generic AND opcode to global-isel.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276297 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-21 15:50:42 +00:00
Konstantin Zhuravlyov
33649d7d0b AMDGPU/SI: Add support for R_AMDGPU_ABS32
Differential Revision: https://reviews.llvm.org/D21646


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276294 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-21 15:29:19 +00:00
Benjamin Kramer
59e5ecf20b Weaken ThreadSafeRefCountedBase atomics.
Doesn't make a difference on x86, but avoids memory barriers on
weakly-ordered archs like PowerPC and ARM.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276291 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-21 15:06:50 +00:00
Benjamin Kramer
1a324fd49a [DenseMap] Add a C++17-style try_emplace method.
This provides an elegant pattern to solve the "construct if not in map
already" problem we have many times in LLVM. Without try_emplace we
either have to rely on a sentinel value (nullptr) or do two lookups.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276277 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-21 13:37:53 +00:00
Benjamin Kramer
b11b3529ce Rename StringMap::emplace_second to try_emplace.
Coincidentally this function maps to the C++17 try_emplace. Rename it
for consistentcy with C++17 std::map. NFC.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276276 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-21 13:37:48 +00:00
Amaury Sechet
8fad35613e Expose AttributeSetNode, use it to provide aggregate getter for attribute in the C API.
Summary: See D19181 for context.

Reviewers: whitequark, Wallbraker, jyknight, echristo, bkramer, void

Subscribers: mehdi_amini

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276236 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-21 04:25:06 +00:00
Adam Nemet
20e71624df [OptDiag] Missed these when making the IR Value a const pointer
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276224 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-21 01:11:12 +00:00
Adam Nemet
42a372e9b8 [OptDiag,LV] Add hotness attribute to applied-optimization remarks
Test coverage is provided by modifying the function in the FP-math
testcase that we are allowed to vectorize.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276223 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-21 01:07:13 +00:00
Adam Nemet
cebe016761 [OptDiag,LV] Add hotness attribute to the derived analysis remarks
This includes FPCompute and Aliasing.

Testcase is based on no_fpmath.ll.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276211 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-20 23:50:32 +00:00
Tim Northover
cd887433f5 GlobalISel: Remove explicit enumerator values from .def file.
They were all auto-incremented from 0 anyway, and I'm getting really annoying
conflicts and runtime failures when different people add more for GlobalISel
(and even when I'm refactoring my own patches).

NFC.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276204 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-20 22:58:01 +00:00
Adam Nemet
957976efe6 [OptDiag,LV] Add hotness attribute to analysis remarks
The earlier change added hotness attribute to missed-optimization
remarks.  This follows up with the analysis remarks (the ones explaining
the reason for the missed optimization).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276192 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-20 21:44:26 +00:00
Adam Nemet
ef4767cee4 [OptDiag] Take the IR Value as a const pointer
This helps because LoopAccessReport is passed around as a const
reference and we derive the basic block passed as the Value parameter
from the instruction in LoopAccessReport.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276191 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-20 21:44:22 +00:00
Tim Northover
6f08925c54 GlobalISel: implement Legalization querying framework.
This adds an (incomplete, inefficient) framework for deciding what to do with
some operation on a given type.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276184 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-20 21:13:29 +00:00
George Burgess IV
bd986a7d74 [MSSA] Add an overload for getClobberingMemoryAccess.
A seemingly common use for the walker's getClobberingMemoryAccess
function is:

```
MemoryAccess *getClobber(MemorySSAWalker *W, MemoryUseOrDef *MUD) {
  const Instruction *I = MUD->getMemoryInst();
  return W->getClobberingMemoryAccess(I);
}
```

Which is kind of redundant, since walkers will ultimately query MSSA to
find out which MemoryAccess `I` maps to (...which is always `MUD`).

So, this patch adds an overload of getClobberingMemoryAccess that
accepts MemoryAccesses directly. As a result, the Instruction overload
of getClobberingMemoryAccess becomes a lightweight wrapper around our
new overload.

Additionally, this patch un`virtual`izes the Instruction overload of
getClobberingMemoryAccess, since there doesn't seem to be a walker that
benefits from that being virtual, and I can't think of how else one
would implement it. Happy to make it virtual again if we would benefit
from doing so.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276169 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-20 19:51:34 +00:00
Tim Northover
6d11357f4b GlobalISel: properly conditionalize LLT use.
We can't guard the include of LowLevelType.h because getType and setType are
(trivial) functions even when GlobalISel isn't built.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276160 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-20 19:17:29 +00:00
Tim Northover
4951996d06 GlobalISel: implement low-level type with just size & vector lanes.
This should be all the low-level instruction selection needs to determine how
to implement an operation, with the remaining context taken from the opcode
(e.g. G_ADD vs G_FADD) or other flags not based on type (e.g. fast-math).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276158 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-20 19:09:30 +00:00
Adam Nemet
5f9c124059 [OptDiag] Fix function comment
Function is not passed unlike in the original of this
(llvm::emitOptimizationRemarkMissed).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276150 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-20 18:16:45 +00:00
Sanjay Patel
402ec84aa3 move decomposeBitTestICmp() to Transforms/Utils; NFC
As noted in https://reviews.llvm.org/D22537 , we can use this functionality in 
visitSelectInstWithICmp() and InstSimplify, but currently we have duplicated
code.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276140 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-20 17:18:45 +00:00
Wei Mi
fe11fa4d16 Use ValueOffsetPair to enhance value reuse during SCEV expansion.
In D12090, the ExprValueMap was added to reuse existing value during SCEV expansion.
However, const folding and sext/zext distribution can make the reuse still difficult.

A simplified case is: suppose we know S1 expands to V1 in ExprValueMap, and
  S1 = S2 + C_a
  S3 = S2 + C_b
where C_a and C_b are different SCEVConstants. Then we'd like to expand S3 as
V1 - C_a + C_b instead of expanding S2 literally. It is helpful when S2 is a
complex SCEV expr and S2 has no entry in ExprValueMap, which is usually caused
by the fact that S3 is generated from S1 after const folding.

In order to do that, we represent ExprValueMap as a mapping from SCEV to
ValueOffsetPair. We will save both S1->{V1, 0} and S2->{V1, C_a} into the
ExprValueMap when we create SCEV for V1. When S3 is expanded, it will first
expand S2 to V1 - C_a because of S2->{V1, C_a} in the map, then expand S3 to
V1 - C_a + C_b.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276136 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-20 16:40:33 +00:00
Sanjay Patel
475ddcccb2 fix documentation comments; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276135 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-20 16:30:55 +00:00
Adam Nemet
dc062efb06 [LV] Add hotness attribute to missed-optimization remarks
The new OptimizationRemarkEmitter analysis pass is hooked up to both new
and old PM passes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276080 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-20 04:03:43 +00:00
Matthias Braun
e3d8cd87b2 Revert "RegScavenging: Add scavengeRegisterBackwards()"
Reverting this commit for now as it seems to be causing failures on
test-suite tests on the clang-ppc64le-linux-lnt bot.

This reverts commit r276044.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276068 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-20 00:21:32 +00:00
Sean Silva
d8c90ea6b8 [PM] Port LoopUnroll.
We just set PreserveLCSSA to always true since we don't have an
analogous method `mustPreserveAnalysisID(LCSSA)`.

Also port LoopInfo verifier pass to test LoopUnrollPass.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276063 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-19 23:54:23 +00:00
Kyle Butt
ebd8d9a1ff Codegen: Factor out canTailDuplicate
canTailDuplicate accepts two blocks and returns true if the first can be
duplicated into the second successfully. Use this function to
encapsulate the heuristic.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276062 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-19 23:54:21 +00:00
Justin Lebar
00d973e3f3 [ADT] Warn on unused results from ArrayRef and StringRef functions that read like they might mutate.
Summary:
Functions like "slice" and "drop_front" sound like they might mutate the
underlying object, but they don't.  Warning on unused results would have
saved me an hour yesterday, and I'm sure I'm not the only one.

LLVM and Clang are clean wrt this warning after D22540.

Reviewers: majnemer

Subscribers: sanjoy, chandlerc, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276058 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-19 23:19:25 +00:00
Daniel Berlin
aee8a35ce9 Make MemorySSA::dominates/locallydominates constant time
Summary: Make MemorySSA::dominates/locallydominates constant time

Reviewers: george.burgess.iv, gberry

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276046 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-19 22:49:43 +00:00
Chandler Carruth
df36f1ccea Add AIX support to Path.inc, Host.h, and CMake.
Patch by Andrew Paprocki!

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276045 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-19 22:46:39 +00:00