1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 11:02:59 +02:00
Commit Graph

20335 Commits

Author SHA1 Message Date
Richard Smith
a49b5ce5a2 [modules] "Specialize" a function by actually specializing a function template
rather than by adding an overload and hoping that it's declared before the code
that calls it. (In a modules build, it isn't.)

llvm-svn: 207133
2014-04-24 18:27:29 +00:00
Adrian Prantl
807e5d8a9a Debug info for optimized code: Support variables that are on the stack and
described by DBG_VALUEs during their lifetime.

Previously, when a variable was at a FrameIndex for any part of its
lifetime, this would shadow all other DBG_VALUEs and only a single
fbreg location would be emitted, which in fact is only valid for a small
range and not the entire lexical scope of the variable. The included
dbg-value-const-byref testcase demonstrates this.

This patch fixes this by
Local
- emitting dbg.value intrinsics for allocas that are passed by reference
- dropping all dbg.declares (they are now fully lowered to dbg.values)
SelectionDAG
- renamed constructors for SDDbgValue for better readability.
- fix UserValue::match() to handle indirect values correctly
- not inserting an MMI table entries for dbg.values that describe allocas.
- lowering dbg.values that describe allocas into *indirect* DBG_VALUEs.
CodeGenPrepare
- leaving dbg.values for an alloca were they are (see comment)
Other
- regenerated/updated instcombine-intrinsics testcase and included source


rdar://problem/16679879
http://reviews.llvm.org/D3374

llvm-svn: 207130
2014-04-24 17:41:45 +00:00
Andrea Di Biagio
dae3a5b91a [X86] Add support for Read Time Stamp Counter x86 builtin intrinsics.
This patch:
- Adds two new X86 builtin intrinsics ('int_x86_rdtsc' and
   'int_x86_rdtscp') as GCCBuiltin intrinsics;
- Teaches the backend how to lower the two new builtins;
- Introduces a common function to lower READCYCLECOUNTER dag nodes
  and the two new rdtsc/rdtscp intrinsics;
- Improves (and extends) the existing x86 test 'rdtsc.ll'; now test 'rdtsc.ll'
  correctly verifies that both READCYCLECOUNTER and the two new intrinsics
  work fine for both 64bit and 32bit Subtargets.

llvm-svn: 207127
2014-04-24 17:18:27 +00:00
David Blaikie
52ea9cc073 Spread some const around for non-mutating uses of MCSymbolData.
I discovered this const-hole while attempting to coalesnce the Symbol
and SymbolMap data structures. There's some pending issues with that,
but I figured this change was easy to flush early.

llvm-svn: 207124
2014-04-24 16:59:40 +00:00
Chandler Carruth
9e4513f082 [LCG] Incorporate the core trick of improvements on the naive Tarjan's
algorithm here: http://dl.acm.org/citation.cfm?id=177301.

The idea of isolating the roots has even more relevance when using the
stack not just to implement the DFS but also to implement the recursive
step. Because we use it for the recursive step, to isolate the roots we
need to maintain two stacks: one for our recursive DFS walk, and another
of the nodes that have been walked. The nice thing is that the latter
will be half the size. It also fixes a complete hack where we scanned
backwards over the stack to find the next potential-root to continue
processing. Now that is always the top of the DFS stack.

While this is a really nice improvement already (IMO) it further opens
the door for two important simplifications:

1) De-duplicating some of the code across the two different walks. I've
   actually made the duplication a bit worse in some senses with this
   patch because the two are starting to converge.
2) Dramatically simplifying the loop structures of both walks.

I wanted to do those separately as they'll be essentially *just* CFG
restructuring. This patch on the other hand actually uses different
datastructures to implement the algorithm itself.

llvm-svn: 207098
2014-04-24 11:05:20 +00:00
Chandler Carruth
cd39f4c2e6 [LCG] Switch the parent SCC tracking from a SmallSetVector to
a SmallPtrSet. Currently, there is no need for stable iteration in this
dimension, and I now thing there won't need to be going forward.

If this is ever re-introduced in any form, it needs to not be
a SetVector based solution because removal cannot be linear. There will
be many SCCs with large numbers of parents. When encountering these, the
incremental SCC update for intra-SCC edge removal was quadratic due to
linear removal (kind of).

I'm really hoping we can avoid having an ordering property here at all
though...

llvm-svn: 207091
2014-04-24 09:22:31 +00:00
Chandler Carruth
ccccef94ac [LCG] We don't actually need a set in each SCC to track the nodes. We
can use the node -> SCC mapping in the top-level graph to test this on
the rare occasions we need it.

llvm-svn: 207090
2014-04-24 08:55:36 +00:00
Chandler Carruth
1f0b2fa5fc [LCG] Switch the SCC's parent iterators to be value iterators rather
than pointer iterators.

llvm-svn: 207086
2014-04-24 07:48:18 +00:00
Chandler Carruth
136fbde351 [ADT] Attempt to appease another MSVC oddity by moving the injected
class name usage into a context we can put typename on it.

llvm-svn: 207084
2014-04-24 06:59:50 +00:00
Craig Topper
c7c3a99ec2 [C++] Use 'nullptr'.
llvm-svn: 207083
2014-04-24 06:44:33 +00:00
Chandler Carruth
a753835442 [ADT] Try to appease MSVC by sinking the enable_if from a default
template argument to a default argument to the constructor.

llvm-svn: 207082
2014-04-24 06:16:12 +00:00
Chandler Carruth
30919c406c Use the shiny new iterator adaptor tool to implement the
value_op_iterator.

llvm-svn: 207078
2014-04-24 05:33:53 +00:00
Chandler Carruth
1c2bf6883e [ADT] Factor out the facade aspect of the iterator_adaptor_base into its
own CRTP base class for more general purpose use. Add some clarifying
comments for the exact way in which the adaptor uses it. Hopefully this
will help us write increasingly full featured iterators. This is
becoming important as they start to be used heavily inside of ranges.

llvm-svn: 207072
2014-04-24 04:07:06 +00:00
Chandler Carruth
6ca401b17b [ADT] Add a generic iterator utility for adapting iterators much like
Boost's iterator_adaptor, and a specific adaptor which iterates over
pointees when wrapped around an iterator over pointers.

This is the result of a long discussion on IRC with Duncan Smith, Dave
Blaikie, Richard Smith, and myself. Essentially, I could use some subset
of the iterator facade facilities often used from Boost, and everyone
seemed interested in having the functionality in a reasonably generic
form. I've tried to strike a balance between the pragmatism and the
established Boost design. The primary differences are:

1) Delegating to the standard iterator interface names rather than
   special names that then make up a second iterator-like API.
2) Using the name 'pointee_iterator' which seems more clear than
   'indirect_iterator'. The whole business of calling the '*p' operation
   'pointer indirection' in the standard is ... quite confusing. And
   'dereference' is no better of a term for moving from a pointer to
   a reference.

Hoping Duncan, and others continue to provide comments on this until
we've got a nice, minimal abstraction.

llvm-svn: 207069
2014-04-24 03:31:23 +00:00
Chandler Carruth
a18f590cc4 [LCG] Normalize the post-order SCC iterator to just iterate over the SCC
values rather than having pointers in weird places.

llvm-svn: 207053
2014-04-23 23:51:07 +00:00
Chandler Carruth
1729fb332d [LCG] Remove two unused typedefs from the iterators.
llvm-svn: 207052
2014-04-23 23:51:02 +00:00
Chandler Carruth
1d124691ed [LCG] Switch the primary node iterator to be a *much* more normal C++
iterator, returning a Node by reference on dereference.

llvm-svn: 207048
2014-04-23 23:34:48 +00:00
Chandler Carruth
18f0202abb [LCG] Make the insertion and query paths into the LCG which cannot fail
return references to better model this property.

No functionality changed.

llvm-svn: 207047
2014-04-23 23:20:36 +00:00
Chandler Carruth
ddc1da4ac6 [LCG] Switch the SCC lookup to be in terms of call graph nodes rather
than functions. So far, this access pattern is *much* more common. It
seems likely that any user of this interface is going to have nodes at
the point that they are querying the SCCs.

No functionality changed.

llvm-svn: 207045
2014-04-23 23:12:06 +00:00
Jordan Rose
1c39b310bb Use std::less instead of < in array_pod_sort's default comparator.
This makes array_pod_sort portably safe to use with pointers.

llvm-svn: 207043
2014-04-23 22:44:11 +00:00
Justin Bogner
6f40bf9196 llvm-cov: Add support for gcov's --long-file-names option
GCOV provides an option to prepend output file names with the source
file name, to disambiguate between covered data that's included from
multiple sources. Add a flag to llvm-cov that does the same.

llvm-svn: 207035
2014-04-23 21:44:55 +00:00
Rafael Espindola
9cce557694 Remove AssemblyAnnotationWriter from NamedMDNode::print.
No functionality change, this parameter was always set to nullptr.

Patch by Robert Matusewicz!

llvm-svn: 206972
2014-04-23 12:23:05 +00:00
Evgeniy Stepanov
c242bd4b23 Create MCTargetOptions.
For now it contains a single flag, SanitizeAddress, which enables
AddressSanitizer instrumentation of inline assembly.

Patch by Yuri Gorshenin.

llvm-svn: 206971
2014-04-23 11:16:03 +00:00
Simon Atanasyan
6d57f42c12 [yaml2obj][ELF] Add a virtual destructor to the ELFYAML::Section class
to prevent memory leaks.

llvm-svn: 206969
2014-04-23 11:10:55 +00:00
Chandler Carruth
72105b1195 [LCG] Add the first round of mutation support to the lazy call graph.
This implements the core functionality necessary to remove an edge from
the call graph and correctly update both the basic graph and the SCC
structure. As part of that it has to run a tiny (in number of nodes)
Tarjan-style DFS walk of an SCC being mutated to compute newly formed
SCCs, etc.

This is *very rough* and a WIP. I have a bunch of FIXMEs for code
cleanup that will reduce the boilerplate in this change substantially.
I also have a bunch of simplifications to various parts of both
algorithms that I want to make, but first I'd like to have a more
holistic picture. Ideally, I'd also like more testing. I'll probably add
quite a few more unit tests as I go here to cover the various different
aspects and corner cases of removing edges from the graph.

Still, this is, so far, successfully updating the SCC graph in-place
without disrupting the identity established for the existing SCCs even
when we do challenging things like delete the critical edge that made an
SCC cycle at all and have to reform things as a tree of smaller SCCs.
Getting this to work is really critical for the new pass manager as it
is going to associate significant state with the SCC instance and needs
it to be stable. That is also the motivation behind the return of the
newly formed SCCs. Eventually, I'll wire this all the way up to the
public API so that the pass manager can use it to correctly re-enqueue
newly formed SCCs into a fresh postorder traversal.

llvm-svn: 206968
2014-04-23 11:03:03 +00:00
Chandler Carruth
ba4ce79281 [LCG] Implement Tarjan's algorithm correctly this time. We have to walk
up the stack finishing the exploration of each entries children before
we're finished in addition to accounting for their low-links. Added
a unittest that really hammers home the need for this with interlocking
cycles that would each appear distinct otherwise and crash or compute
the wrong result. As part of this, nuke a stale fixme and bring the rest
of the implementation still more closely in line with the original
algorithm.

llvm-svn: 206966
2014-04-23 10:31:17 +00:00
Chandler Carruth
da074e6ecd [LCG] Add some accessor methods to the SCC to allow iterating over the
parents of an SCC, and add a lookup method for finding the SCC for
a given function. These aren't used yet, but will be used shortly in
some unit tests I'm adding and are really part of the broader intended
interface for the analysis.

llvm-svn: 206959
2014-04-23 09:57:18 +00:00
Chandler Carruth
4d480e7c41 [LCG] Add a unittest for the LazyCallGraph. I had a weak moment and
resisted this for too long. Just with the basic testing here I was able
to exercise the analysis in more detail and sift out both type signature
bugs in the API and a bug in the DFS numbering. All of these are fixed
here as well.

The unittests will be much more important for the mutation support where
it is necessary to craft minimal mutations and then inspect the state of
the graph. There is just no way to do that with a standard FileCheck
test. However, unittesting these kinds of analyses is really quite easy,
especially as they're designed with the new pass manager where there is
essentially no infrastructure required to rig up the core logic and
exercise it at an API level.

As a minor aside about the DFS numbering bug, the DFS numbering used in
LCG is a bit unusual. Rather than numbering from 0, we number from 1,
and use 0 as the sentinel "unvisited" state. Other implementations often
use '-1' for this, but I find it easier to deal with 0 and it shouldn't
make any real difference provided someone doesn't write silly bugs like
forgetting to actually initialize the DFS numbering. Oops. ;]

llvm-svn: 206954
2014-04-23 08:08:49 +00:00
Chandler Carruth
6ddb99ce88 [LCG] Hoist the logic for forming a new SCC from the top of the DFSStack
into a helper function. I plan to re-use it for doing incremental
DFS-based updates to the SCCs when we mutate the call graph.

llvm-svn: 206948
2014-04-23 06:09:03 +00:00
Chandler Carruth
b55b69947a [LCG] Switch the Callee sets to be DenseMaps pointing to the index into
the Callee list. This is going to be quite important to prevent removal
from going quadratic. No functionality changed at this point, this is
one of the refactoring patches I've broken out of my initial work toward
mutation updates of the call graph.

llvm-svn: 206938
2014-04-23 04:00:17 +00:00
Kevin Enderby
af08119374 Change the prototype for MCContext::FatalError() so it can be called
from places like MCCodeEmitter() in the MC backend when the
MCContext is const.

I was going to use this in my change for r206669 but Jim convinced
me to use an assert there. But this still is a good tweak.

llvm-svn: 206923
2014-04-22 21:42:18 +00:00
Rui Ueyama
2962a8cf09 Whitespace
llvm-svn: 206919
2014-04-22 19:52:05 +00:00
Rui Ueyama
49d727e440 No need to check condition after grow()
r206916 was not logically the same as the previous code because the
goto statements did not create loop. This should be the same as the
previous code.

llvm-svn: 206918
2014-04-22 19:47:26 +00:00
Rui Ueyama
1717e7b0c5 Replace loops using goto with plain while loops
Goto statements jumping into previous inner blocks are pretty confusing
to read even though in this case they are valid. No reason to not use
while loops there.

llvm-svn: 206916
2014-04-22 19:07:14 +00:00
Kevin Enderby
223e66dc63 Fix the assembler to print a better relocatable expression error
diagnostic that includes location information.

Currently if one has this assembly:

	.quad (0x1234 + (4 * SOME_VALUE))

where SOME_VALUE is undefined ones gets the less than
useful error message with no location information:

% clang -c x.s
clang -cc1as: fatal error: error in backend: expected relocatable expression

With this fix one now gets a more useful error message
with location information:

% clang -c x.s 
x.s:5:8: error: expected relocatable expression
 .quad (0x1234 + (4 * SOME_VALUE))
       ^

To do this I plumbed the SMLoc through the MCObjectStreamer
EmitValue() and EmitValueImpl() interfaces so it could be used
when creating the MCFixup.

rdar://12391022

llvm-svn: 206906
2014-04-22 17:27:29 +00:00
Tim Northover
8de0d64b13 AArch64/ARM64: mark fmul intrinsic as commutative.
This gives DAG patterns matching indexed patterns where either side is an
indexed vector.

llvm-svn: 206875
2014-04-22 10:10:14 +00:00
Duncan P. N. Exon Smith
a1d9be7fae blockfreq: Rename PackagedLoops => Loops
llvm-svn: 206859
2014-04-22 03:31:50 +00:00
Duncan P. N. Exon Smith
f75da5e8f9 blockfreq: Use a pointer for ContainingLoop too
llvm-svn: 206858
2014-04-22 03:31:44 +00:00
Duncan P. N. Exon Smith
a90ab97d92 blockfreq: Use pointers to loops instead of an index
Store pointers directly to loops inside the nodes.  This could have been
done without changing the type stored in `std::vector<>`.  However,
rather than computing the number of loops before constructing them
(which `LoopInfo` doesn't provide directly), I've switched to a
`vector<unique_ptr<LoopData>>`.

This adds some heap overhead, but the number of loops is typically
small.

llvm-svn: 206857
2014-04-22 03:31:37 +00:00
Duncan P. N. Exon Smith
17a7eb45ae blockfreq: Rename PackagedLoopData => LoopData
No functionality change.

llvm-svn: 206855
2014-04-22 03:31:31 +00:00
Duncan P. N. Exon Smith
bb77d550cb blockfreq: Move PackagedLoopData above WorkingData
llvm-svn: 206854
2014-04-22 03:31:25 +00:00
Duncan P. N. Exon Smith
c07662b4d2 blockfreq: Remove "dead" comment
llvm-svn: 206853
2014-04-22 03:31:23 +00:00
Chandler Carruth
2361db41db [Modules] Remove potential ODR violations by sinking the DEBUG_TYPE
define below all header includes in the lib/CodeGen/... tree. While the
current modules implementation doesn't check for this kind of ODR
violation yet, it is likely to grow support for it in the future. It
also removes one layer of macro pollution across all the included
headers.

Other sub-trees will follow.

llvm-svn: 206837
2014-04-22 02:02:50 +00:00
Rui Ueyama
da61c4d224 Fix wrong iterator type
ELFEntityIterator does not implement RandomAccessIterator. It does
not even implement BidirectionalIterator.

This patch fixes LLD build issue when compiled with MSVC2013 with
debug: MSVC's find_if checks if the start iterator is before the end
iterator in the sense of operator< if it declares implementing
RandomAccessIterator. If a class does not have operator<, it fails
to compile.

llvm-svn: 206825
2014-04-21 23:00:42 +00:00
Chandler Carruth
15c7b91ac2 [Modules] Make Support/Debug.h modular. This requires it to not change
behavior based on other files defining DEBUG_TYPE, which means it cannot
define DEBUG_TYPE at all. This is actually better IMO as it forces folks
to define relevant DEBUG_TYPEs for their files. However, it requires all
files that currently use DEBUG(...) to define a DEBUG_TYPE if they don't
already. I've updated all such files in LLVM and will do the same for
other upstream projects.

This still leaves one important change in how LLVM uses the DEBUG_TYPE
macro going forward: we need to only define the macro *after* header
files have been #include-ed. Previously, this wasn't possible because
Debug.h required the macro to be pre-defined. This commit removes that.
By defining DEBUG_TYPE after the includes two things are fixed:

- Header files that need to provide a DEBUG_TYPE for some inline code
  can do so by defining the macro before their inline code and undef-ing
  it afterward so the macro does not escape.

- We no longer have rampant ODR violations due to including headers with
  different DEBUG_TYPE definitions. This may be mostly an academic
  violation today, but with modules these types of violations are easy
  to check for and potentially very relevant.

Where necessary to suppor headers with DEBUG_TYPE, I have moved the
definitions below the includes in this commit. I plan to move the rest
of the DEBUG_TYPE macros in LLVM in subsequent commits; this one is big
enough.

The comments in Debug.h, which were hilariously out of date already,
have been updated to reflect the recommended practice going forward.

llvm-svn: 206822
2014-04-21 22:55:11 +00:00
David Blaikie
7f6857210a Use unique_ptr to manage ownership of GCOVFunctions, Blocks, and Edges.
llvm-svn: 206796
2014-04-21 21:40:16 +00:00
David Blaikie
3fde01a358 Use unique_ptr to manage objects owned by the ScheduleDAGMI.
llvm-svn: 206784
2014-04-21 20:32:32 +00:00
Yi Jiang
b1c450606d ARM64: Combine shifts and uses from different basic block to bit-extract instruction
llvm-svn: 206774
2014-04-21 19:34:27 +00:00
Duncan P. N. Exon Smith
9067c09422 blockfreq: Some cleanup of UnsignedFloat
Change `PositiveFloat` to `UnsignedFloat`, and fix some of the comments
to indicate that it's disappearing eventually.

llvm-svn: 206771
2014-04-21 18:31:58 +00:00
Jim Grosbach
c934984b77 Tidy up. Remove extraneous typedef.
llvm-svn: 206768
2014-04-21 18:10:29 +00:00