Commit Graph

1169 Commits

Author SHA1 Message Date
Rafael Espindola
2ad4cf54ee No point in having a "#if 0"ed unittest.
It is also not clear what the value of the test was. The API is used from
existing tools and can (and is) tested with lit.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@197654 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-19 03:44:13 +00:00
Anna Zaks
629f3b229e Fix a buffer overrun detected by AddressSanitizer.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@197647 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-19 02:35:26 +00:00
NAKAMURA Takumi
90a24a560a ArchiveFileDescriptorTests: Fix CMake build. Each unit test is expected to have suffix "*Tests" for lit gtest runner to seek one.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@197636 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-19 00:41:08 +00:00
NAKAMURA Takumi
2fcb0c34b3 ArchiveFileDescriptorTests: Resurrect part of r197600, but make it invalidated, to appease buildbots.
Please revert this several hours later ;)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@197635 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-19 00:41:03 +00:00
Owen Anderson
4fc184584c Revert r197600 while I sort out why it's failing on Windows.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@197602 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-18 19:25:51 +00:00
Owen Anderson
04946d54db Add a unit test for loading an object file via a file descriptor. Patch by Pete Cooper.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@197600 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-18 19:20:29 +00:00
Michael Gottesman
1b98ef1c19 [block-freq] Add a right shift to BlockFrequency that saturates at 1.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@197302 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-14 02:24:22 +00:00
Michael Gottesman
cadf450e17 Remove APInt::extractBit since it is already implemented via operator[]. Change tests for extractBit to test operator[].
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@197277 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-13 22:00:19 +00:00
Michael Gottesman
46f829ee25 [block-freq] Add the method APInt::nearestLogBase2().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@197272 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-13 20:47:37 +00:00
Michael Gottesman
5bb504f4ea [block-freq] Add the APInt method extractBit.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@197271 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-13 20:47:34 +00:00
Rafael Espindola
f343bc9956 Use a: and s: instead of a0: and s0: in the DataLayout strings.
They are equivalent and the size of 'a' and 's' is unused.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@197259 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-13 18:56:34 +00:00
Richard Barton
b4605d4d4b Remove some dead code
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@197144 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-12 11:18:08 +00:00
Alp Toker
7f8ef1ecc4 Swap around EXPECT_EQ() arguments orders for more natural gtest Failure messages
Somewhat counterintuitively the first arg in gtest is treated as the
expectation.

No change to the tests themselves.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@197124 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-12 03:31:20 +00:00
Alp Toker
22e0e0c1de Add missing escape characters to the new Regex::escape() function
The old AddFixedStringToRegEx() it was based on got away with this for the
longest time, but the problem became easy to spot after the cleanup in r197096.

Also add a quick unit test to cover regex escaping.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@197121 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-12 02:51:58 +00:00
Tim Northover
9f84f21a4c Darwin: update default iOS version to 5.0
Defaulting to iOS 3.0 when LLVM has to guess the version is no longer a useful
option and can give surprising results (like tail calls being disabled).

5.0 seems like a reasonable compromise as a platform that's still interesting
to some people.

rdar://problem/15567348

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@196912 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-10 11:53:16 +00:00
NAKAMURA Takumi
3aabdebde2 [CMake] Update LLVM_LINK_COMPONENTS for each CMakeLists.txt.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@196908 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-10 11:13:32 +00:00
NAKAMURA Takumi
1f2868899a Add JIT to LINK_COMPONENTS in MCJITTests/Makefile.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@196907 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-10 11:12:35 +00:00
Kostya Serebryany
daa1bf3b74 [asan] rewrite asan's stack frame layout
Summary:
Rewrite asan's stack frame layout.
First, most of the stack layout logic is moved into a separte file
to make it more testable and (potentially) useful for other projects.
Second, make the frames more compact by using adaptive redzones
(smaller for small objects, larger for large objects).
Third, try to minimized gaps due to large alignments (this is hypothetical since
today we don't see many stack vars aligned by more than 32).

The frames indeed become more compact, but I'll still need to run more benchmarks
before committing, but I am sking for review now to get early feedback.

This change will be accompanied by a trivial change in compiler-rt tests
to match the new frame sizes.

Reviewers: samsonov, dvyukov

Reviewed By: samsonov

CC: llvm-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D2324

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@196568 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-06 09:00:17 +00:00
Michael Ilseman
faf4d59137 Use present fast-math flags when applicable in CreateBinOp
We were previously not adding fast-math flags through CreateBinOp()
when it happened to be making a floating point binary operator. This
patch updates it to do so similarly to directly calling CreateF*().



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@196438 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-05 00:32:09 +00:00
Diego Novillo
97add46aee Fix dominator descendants for unreachable blocks.
When a block is unreachable, asking its dom tree descendants should
return the empty set. However, the computation of the descendants
was causing a segmentation fault because the dom tree node we get
from the basic block is initially NULL.

Fixed by adding a test for a valid dom tree node before we iterate.

The patch also adds some unit tests to the existing dom tree tests.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@196099 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-02 14:08:27 +00:00
NAKAMURA Takumi
bfc7e8719f [CMake] Also OptionTests can be free from add_dependencies() with add_public_tablegen_target().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195928 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-28 17:04:13 +00:00
Chandler Carruth
54fec07ec0 [PM] Split the CallGraph out from the ModulePass which creates the
CallGraph.

This makes the CallGraph a totally generic analysis object that is the
container for the graph data structure and the primary interface for
querying and manipulating it. The pass logic is separated into its own
class. For compatibility reasons, the pass provides wrapper methods for
most of the methods on CallGraph -- they all just forward.

This will allow the new pass manager infrastructure to provide its own
analysis pass that constructs the same CallGraph object and makes it
available. The idea is that in the new pass manager, the analysis pass's
'run' method returns a concrete analysis 'result'. Here, that result is
a 'CallGraph'. The 'run' method will typically do only minimal work,
deferring much of the work into the implementation of the result object
in order to be lazy about computing things, but when (like DomTree)
there is *some* up-front computation, the analysis does it prior to
handing the result back to the querying pass.

I know some of this is fairly ugly. I'm happy to change it around if
folks can suggest a cleaner interim state, but there is going to be some
amount of unavoidable ugliness during the transition period. The good
thing is that this is very limited and will naturally go away when the
old pass infrastructure goes away. It won't hang around to bother us
later.

Next up is the initial new-PM-style call graph analysis. =]

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195722 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-26 04:19:30 +00:00
Chandler Carruth
e510665548 [PM] Complete the cross-layer interfaces with a Module-to-Function
proxy. This lets a function pass query a module analysis manager.
However, the interface is const to indicate that only cached results can
be safely queried.

With this, I think the new pass manager is largely functionally complete
for modules and analyses. Still lots to test, and need to generalize to
SCCs and Loops, and need to build an adaptor layer to support the use of
existing Pass objects in the new managers.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195538 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-23 01:25:07 +00:00
Chandler Carruth
2ea1151162 [PM] Rename TestAnalysisPass to TestFunctionAnalysis to clear the way
for a TestModuleAnalysis.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195537 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-23 01:25:02 +00:00
Chandler Carruth
b88831b204 [PM] Add support to the analysis managers to query explicitly for cached
results.

This is the last piece of infrastructure needed to effectively support
querying *up* the analysis layers. The next step will be to introduce
a proxy which provides access to those layers with appropriate use of
const to direct queries to the safe interface.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195525 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-23 00:38:42 +00:00
Chandler Carruth
4d32e85359 [PM] Switch the downward invalidation to be incremental where only the
one function's analyses are invalidated at a time. Also switch the
preservation of the proxy to *fully* preserve the lower (function)
analyses.

Combined, this gets both upward and downward analysis invalidation to
a point I'm happy with:

- A function pass invalidates its function analyses, and its parent's
  module analyses.
- A module pass invalidates all of its functions' analyses including the
  set of which functions are in the module.
- A function pass can preserve a module analysis pass.
- If all function passes preserve a module analysis pass, that
  preservation persists. If any doesn't the module analysis is
  invalidated.
- A module pass can opt into managing *all* function analysis
  invalidation itself or *none*.
- The conservative default is none, and the proxy takes the maximally
  conservative approach that works even if the set of functions has
  changed.
- If a module pass opts into managing function analysis invalidation it
  has to propagate the invalidation itself, the proxy just does nothing.

The only thing really missing is a way to query for a cached analysis or
nothing at all. With this, function passes can more safely request
a cached module analysis pass without fear of it accidentally running
part way through.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195519 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-22 23:38:07 +00:00
Chandler Carruth
5f347a9bd1 [PM] Teach the analysis managers to pass themselves as arguments to the
run methods of the analysis passes.

Also generalizes and re-uses the SFINAE for transformation passes so
that users can write an analysis pass and only accept an analysis
manager if that is useful to their pass.

This completes the plumbing to make an analysis manager available
through every pass's run method if desired so that passes no longer need
to be constructed around them.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195451 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-22 12:11:02 +00:00
Chandler Carruth
d984cdc17e [PM] Remove the IRUnitT typedef requirement for analysis passes.
Since the analysis managers were split into explicit function and module
analysis managers, it is now completely trivial to specify this when
building up the concept and model types explicitly, and it is impossible
to end up with a type error at run time. We instantiate a template when
registering a pass that will enforce the requirement at a type-system
level, and we produce a dynamic error on all the other query paths to
the analysis manager if the pass in question isn't registered.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195447 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-22 11:46:33 +00:00
Chandler Carruth
3f081983cc [PM] Fix the analysis templates' usage of IRUnitT.
This is supposed to be the whole type of the IR unit, and so we
shouldn't pass a pointer to it but rather the value itself. In turn, we
need to provide a 'Module *' as that type argument (for example). This
will become more relevant with SCCs or other units which may not be
passed as a pointer type, but also brings consistency with the
transformation pass templates.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195445 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-22 11:34:43 +00:00
Michael Gottesman
e323506316 [block-freq] Update data in test case to be unsigned long long to fix mingw build.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195411 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-22 05:00:51 +00:00
Chandler Carruth
d793a053ad [PM] Switch analysis managers to be threaded through the run methods
rather than the constructors of passes.

This simplifies the APIs of passes significantly and removes an error
prone pattern where the *same* manager had to be given to every
different layer. With the new API the analysis managers themselves will
have to be cross connected with proxy analyses that allow a pass at one
layer to query for the analysis manager of another layer. The proxy will
both expose a handle to the other layer's manager and it will provide
the invalidation hooks to ensure things remain consistent across layers.
Finally, the outer-most analysis manager has to be passed to the run
method of the outer-most pass manager. The rest of the propagation is
automatic.

I've used SFINAE again to allow passes to completely disregard the
analysis manager if they don't need or want to care. This helps keep
simple things simple for users of the new pass manager.

Also, the system specifically supports passing a null pointer into the
outer-most run method if your pass pipeline neither needs nor wants to
deal with analyses. I find this of dubious utility as while some
*passes* don't care about analysis, I'm not sure there are any
real-world users of the pass manager itself that need to avoid even
creating an analysis manager. But it is easy to support, so there we go.

Finally I renamed the module proxy for the function analysis manager to
the more verbose but less confusing name of
FunctionAnalysisManagerModuleProxy. I hate this name, but I have no idea
what else to name these things. I'm expecting in the fullness of time to
potentially have the complete cross product of types at the proxy layer:

{Module,SCC,Function,Loop,Region}AnalysisManager{Module,SCC,Function,Loop,Region}Proxy

(except for XAnalysisManagerXProxy which doesn't make any sense)

This should make it somewhat easier to do the next phases which is to
build the upward proxy and get its invalidation correct, as well as to
make the invalidation within the Module -> Function mapping pass be more
fine grained so as to invalidate fewer fuction analyses.

After all of the proxy analyses are done and the invalidation working,
I'll finally be able to start working on the next two fun fronts: how to
adapt an existing pass to work in both the legacy pass world and the new
one, and building the SCC, Loop, and Region counterparts. Fun times!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195400 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-22 00:43:29 +00:00
Chandler Carruth
edd2b49134 [PM] Widen the interface for invalidate on an analysis result now that
it is completely optional, and sink the logic for handling the preserved
analysis set into it.

This allows us to implement the delegation logic desired in the proxy
module analysis for the function analysis manager where if the proxy
itself is preserved we assume the set of functions hasn't changed and we
do a fine grained invalidation by walking the functions in the module
and running the invalidate for them all at the manager level and letting
it try to invalidate any passes.

This in turn makes it blindingly obvious why we should hoist the
invalidate trait and have two collections of results. That allows
handling invalidation for almost all analyses without indirect calls and
it allows short circuiting when the preserved set is all.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195338 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-21 10:53:05 +00:00
Chandler Carruth
212226e114 [PM] Add support for using SFINAE to reflect on an analysis's result
type and detect whether or not it provides an 'invalidate' member the
analysis manager should use.

This lets the overwhelming common case of *not* caring about custom
behavior when an analysis is invalidated be the the obvious default
behavior with no code written by the author of an analysis. Only when
they write code specifically to handle invalidation does it get used.

Both cases are actually covered by tests here. The test analysis uses
the default behavior, and the proxy module analysis actually has custom
behavior on invalidation that is firing correctly. (In fact, this is the
analysis which was the primary motivation for having custom invalidation
behavior in the first place.)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195332 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-21 09:10:21 +00:00
Chandler Carruth
7fac06c423 [PM] Add a module analysis pass proxy for the function analysis manager.
This proxy will fill the role of proxying invalidation events down IR
unit layers so that when a module changes we correctly invalidate
function analyses. Currently this is a very coarse solution -- any
change blows away the entire thing -- but the next step is to make
invalidation handling more nuanced so that we can propagate specific
amounts of invalidation from one layer to the next.

The test is extended to place a module pass between two function pass
managers each of which have preserved function analyses which get
correctly invalidated by the module pass that might have changed what
functions are even in the module.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195304 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-21 02:11:31 +00:00
Nick Kledzik
9fd7416b3b YAML I/O add support for validate()
MappingTrait template specializations can now have a validate() method which 
performs semantic checking. For details, see <http://llvm.org/docs/YamlIO.html>.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195286 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-21 00:28:07 +00:00
Nick Kledzik
25f01786ea revert r194655
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195285 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-21 00:20:10 +00:00
Chandler Carruth
fd03357c25 Make the moved-from SmallPtrSet be a valid, empty, small-state object.
Enhance the tests to actually require moves in C++11 mode, in addition
to testing the moved-from state. Further enhance the tests to cover
copy-assignment into a moved-from object and moving a large-state
object. (Note that we can't really test small-state vs. large-state as
that isn't an observable property of the API really.) This should finish
addressing review on r195239.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195261 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-20 18:29:56 +00:00
Chandler Carruth
aa8e535b57 Add a test for assignment operator behavior which was changed in
r195239, as well as a comment about the fact that assigning over
a moved-from object was in fact tested. Addresses some of the review
feedback on r195239.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195260 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-20 18:21:25 +00:00
Chandler Carruth
c49e7e6aee [PM] Add the preservation system to the new pass manager.
This adds a new set-like type which represents a set of preserved
analysis passes. The set is managed via the opaque PassT::ID() void*s.
The expected convenience templates for interacting with specific passes
are provided. It also supports a symbolic "all" state which is
represented by an invalid pointer in the set. This state is nicely
saturating as it comes up often. Finally, it supports intersection which
is used when finding the set of preserved passes after N different
transforms.

The pass API is then changed to return the preserved set rather than
a bool. This is much more self-documenting than the previous system.
Returning "none" is a conservatively correct solution just like
returning "true" from todays passes and not marking any passes as
preserved. Passes can also be dynamically preserved or not throughout
the run of the pass, and whatever gets returned is the binding state.
Finally, preserving "all" the passes is allowed for no-op transforms
that simply can't harm such things.

Finally, the analysis managers are changed to instead of blindly
invalidating all of the analyses, invalidate those which were not
preserved. This should rig up all of the basic preservation
functionality. This also correctly combines the preservation moving up
from one IR-layer to the another and the preservation aggregation across
N pass runs. Still to go is incrementally correct invalidation and
preservation across IR layers incrementally during N pass runs. That
will wait until we have a device for even exposing analyses across IR
layers.

While the core of this change is obvious, I'm not happy with the current
testing, so will improve it to cover at least some of the invalidation
that I can test easily in a subsequent commit.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195241 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-20 11:31:50 +00:00
Chandler Carruth
46198164b3 Give SmallPtrSet move semantics when we have R-value references.
Somehow, this ADT got missed which is moderately terrifying considering
the efficiency of move for it.

The code to implement move semantics for it is pretty horrible
currently but was written to reasonably closely match the rest of the
code. Unittests that cover both copying and moving (at a basic level)
added.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195239 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-20 11:14:33 +00:00
Chandler Carruth
d14894059f [PM] Make the function pass manager more regular.
The FunctionPassManager is now itself a function pass. When run over
a function, it runs all N of its passes over that function. This is the
1:N mapping in the pass dimension only. This allows it to be used in
either a ModulePassManager or potentially some other manager that
works on IR units which are supersets of Functions.

This commit also adds the obvious adaptor to map from a module pass to
a function pass, running the function pass across every function in the
module.

The test has been updated to use this new pattern.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195192 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-20 04:39:16 +00:00
Chandler Carruth
523d929368 [PM] Split the analysis manager into a function-specific interface and
a module-specific interface. This is the first of many steps necessary
to generalize the infrastructure such that we can support both
a Module-to-Function and Module-to-SCC-to-Function pass manager
nestings.

After a *lot* of attempts that never worked and didn't even make it to
a committable state, it became clear that I had gotten the layering
design of analyses flat out wrong. Four days later, I think I have most
of the plan for how to correct this, and I'm starting to reshape the
code into it. This is just a baby step I'm afraid, but starts separating
the fundamentally distinct concepts of function analysis passes and
module analysis passes so that in subsequent steps we can effectively
layer them, and have a consistent design for the eventual SCC layer.

As part of this, I've started some interface changes to make passes more
regular. The module pass accepts the module in the run method, and some
of the constructor parameters are gone. I'm still working out exactly
where constructor parameters vs. method parameters will be used, so
I expect this to fluctuate a bit.

This actually makes the invalidation less "correct" at this phase,
because now function passes don't invalidate module analysis passes, but
that was actually somewhat of a misfeature. It will return in a better
factored form which can scale to other units of IR. The documentation
has gotten less verbose and helpful.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195189 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-20 04:01:38 +00:00
John Thompson
da1ad53f6a YAML I/O - Added default trait support for std:string. Making another attempt at this, this time doing a clean build on Linux, and running the LLVM, clang, and extra tests, to try to make sure there's no problems.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195134 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-19 17:28:21 +00:00
Michael Ilseman
1b3ab9199f Add support for software expansion of 64-bit integer division instructions.
Patch by Dmitri Shtilman!



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195116 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-19 06:54:19 +00:00
Juergen Ributzka
ba0f991a78 [weak vtables] Place class definitions into anonymous namespaces to prevent weak vtables.
This patch places class definitions in implementation files into anonymous
namespaces to prevent weak vtables. This eliminates the need of providing an
out-of-line definition to pin the vtable explicitly to the file.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195092 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-19 03:08:35 +00:00
Juergen Ributzka
354362524a [weak vtables] Remove a bunch of weak vtables
This patch removes most of the trivial cases of weak vtables by pinning them to
a single object file. The memory leaks in this version have been fixed. Thanks
Alexey for pointing them out.

Differential Revision: http://llvm-reviews.chandlerc.com/D2068

Reviewed by Andy

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195064 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-19 00:57:56 +00:00
Alexander Kornienko
6919bec07f Recover gracefully when deserializing invalid YAML input.
Fixes http://llvm.org/PR16221, http://llvm.org/PR15927
Phabricator: http://llvm-reviews.chandlerc.com/D1236

Patch by Andrew Tulloch!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195016 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-18 15:50:04 +00:00
Alexey Samsonov
b21ab43cfc Revert r194865 and r194874.
This change is incorrect. If you delete virtual destructor of both a base class
and a subclass, then the following code:
  Base *foo = new Child();
  delete foo;
will not cause the destructor for members of Child class. As a result, I observe
plently of memory leaks. Notable examples I investigated are:
ObjectBuffer and ObjectBufferStream, AttributeImpl and StringSAttributeImpl.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194997 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-18 09:31:53 +00:00
Michael Gottesman
e7a1e3ee82 [block-freq] Add BlockFrequency::scale that returns a remainder from the division and make the private scale in BlockFrequency more performant.
This change is the first in a series of changes improving LLVM's Block
Frequency propogation implementation to not lose probability mass in
branchy code when propogating block frequency information from a basic
block to its successors. This patch is a simple infrastructure
improvement that does not actually modify the block frequency
algorithm. The specific changes are:

1. Changes the division algorithm used when scaling block frequencies by
branch probabilities to a short division algorithm. This gives us the
remainder for free as well as provides a nice speed boost. When I
benched the old routine and the new routine on a Sandy Bridge iMac with
disabled turbo mode performing 8192 iterations on an array of length
32768, I saw ~600% increase in speed in mean/median performance.

2. Exposes a scale method that returns a remainder. This is important so
we can ensure that when we scale a block frequency by some branch
probability BP = N/D, the remainder from the division by D can be
retrieved and propagated to other children to ensure no probability mass
is lost (more to come on this).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194950 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-17 03:25:24 +00:00
Chandler Carruth
8417e85781 [PM] Completely remove support for explicit 'require' methods on the
AnalysisManager. All this method did was assert something and we have
a perfectly good way to trigger that assert from the query path.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194947 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-17 03:18:05 +00:00
Juergen Ributzka
5a364c5561 [weak vtables] Remove a bunch of weak vtables
This patch removes most of the trivial cases of weak vtables by pinning them to
a single object file.

Differential Revision: http://llvm-reviews.chandlerc.com/D2068

Reviewed by Andy

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194865 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-15 22:34:48 +00:00
Rui Ueyama
8a631b2cbe Path: Recognize COFF import library file magic.
Summary: Make identify_magic to recognize COFF import file.

Reviewers: Bigcheese

CC: llvm-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D2165

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194852 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-15 21:22:02 +00:00
Benjamin Kramer
4da02d43b1 Give unit test its own LLVMContext so MDNodes aren't leaked even if we never call llvm_shutdown.
Found by valgrind.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194797 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-15 09:34:33 +00:00
Matt Arsenault
59d3ae6cdc Add addrspacecast instruction.
Patch by Michele Scandale!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194760 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-15 01:34:59 +00:00
Rui Ueyama
b850a05f2c Recognize 0x0000 as a COFF file magic.
Summary:
Some machine-type-neutral object files containing only undefined symbols
actually do exist in the Windows standard library. Need to recognize them
as COFF files.

Reviewers: Bigcheese

CC: llvm-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D2164

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194734 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-14 22:09:08 +00:00
Nick Kledzik
52301027aa remove extra semicolon
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194658 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-14 03:03:05 +00:00
Nick Kledzik
04fca67d6f Add dyn_cast<> support to YAML I/O's IO class
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194655 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-14 02:38:07 +00:00
Nick Kledzik
4e7c22a90b Add simple support for tags in YAML I/O
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194644 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-14 00:59:59 +00:00
Rui Ueyama
c9024c6ebc Path: Add tests for existing file magics.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194607 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-13 21:55:41 +00:00
Rui Ueyama
e0573aab49 Whitespace.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194605 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-13 20:31:21 +00:00
Chandler Carruth
3c3f6be0c8 Fix a null pointer dereference when copying a null polymorphic pointer.
This bug only bit the C++98 build bots because all of the actual uses
really do move. ;] But not *quite* ready to do the whole C++11 switch
yet, so clean it up. Also add a unit test that catches this immediately.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194548 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-13 02:48:20 +00:00
Chandler Carruth
f348c9782c Introduce an AnalysisManager which is like a pass manager but with a lot
more smarts in it. This is where most of the interesting logic that used
to live in the implicit-scheduling-hackery of the old pass manager will
live.

Like the previous commits, note that this is a very early prototype!
I expect substantial changes before this is ready to use.

The core of the design is the following:

- We have an AnalysisManager which can be used across a series of
  passes over a module.
- The code setting up a pass pipeline registers the analyses available
  with the manager.
- Individual transform passes can check than an analysis manager
  provides the analyses they require in order to fail-fast.
- There is *no* implicit registration or scheduling.
- Analysis passes are different from other passes: they produce an
  analysis result that is cached and made available via the analysis
  manager.
- Cached results are invalidated automatically by the pass managers.
- When a transform pass requests an analysis result, either the analysis
  is run to produce the result or a cached result is provided.

There are a few aspects of this design that I *know* will change in
subsequent commits:
- Currently there is no "preservation" system, that needs to be added.
- All of the analysis management should move up to the analysis library.
- The analysis management needs to support at least SCC passes. Maybe
  loop passes. Living in the analysis library will facilitate this.
- Need support for analyses which are *both* module and function passes.
- Need support for pro-actively running module analyses to have cached
  results within a function pass manager.
- Need a clear design for "immutable" passes.
- Need support for requesting cached results when available and not
  re-running the pass even if that would be necessary.
- Need more thorough testing of all of this infrastructure.

There are other aspects that I view as open questions I'm hoping to
resolve as I iterate a bit on the infrastructure, and especially as
I start writing actual passes against this.
- Should we have separate management layers for function, module, and
  SCC analyses? I think "yes", but I'm not yet ready to switch the code.
  Adding SCC support will likely resolve this definitively.
- How should the 'require' functionality work? Should *that* be the only
  way to request results to ensure that passes always require things?
- How should preservation work?
- Probably some other things I'm forgetting. =]

Look forward to more patches in shorter order now that this is in place.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194538 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-13 01:12:08 +00:00
Chandler Carruth
ea9988447c [PM] Start sketching out the new module and function pass manager.
This is still just a skeleton. I'm trying to pull together the
experimentation I've done into committable chunks, and this is the first
coherent one. Others will follow in hopefully short order that move this
more toward a useful initial implementation. I still expect the design
to continue evolving in small ways as I work through the different
requirements and features needed here though.

Keep in mind, all of this is off by default.

Currently, this mostly exercises the use of a polymorphic smart pointer
and templates to hide the polymorphism for the pass manager from the
pass implementation. The next step will be more significant, adding the
first framework of analysis support.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194325 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-09 13:09:08 +00:00
Chandler Carruth
49837ef811 Move the old pass manager infrastructure into a legacy namespace and
give the files a legacy prefix in the right directory. Use forwarding
headers in the old locations to paper over the name change for most
clients during the transitional period.

No functionality changed here! This is just clearing some space to
reduce renaming churn later on with a new system.

Even when the new stuff starts to go in, it is going to be hidden behind
a flag and off-by-default as it is still WIP and under development.

This patch is specifically designed so that very little out-of-tree code
has to change. I'm going to work as hard as I can to keep that the case.
Only direct forward declarations of the PassManager class are impacted
by this change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194324 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-09 12:26:54 +00:00
Chandler Carruth
3481cdc573 Switch to allow implicit construction. In many cases, we're wrapping
a derived type and this makes it *much* easier to write this code.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194321 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-09 05:55:03 +00:00
Chandler Carruth
c197a3ab4d Test the polymorphic behavior of this utility.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194320 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-09 04:58:13 +00:00
Chandler Carruth
8caea7237a Use something really explicit to test "move semantics" on builds without
r-value references. I still want to test that when we have them,
llvm_move is actually a move.

Have I mentioned that I really want to move to C++11? ;]

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194318 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-09 04:49:27 +00:00
Chandler Carruth
ca020d469e Add the critically missing 'clone' method. =]
Clang managed to never instantiate the copy constructor. Added tests to
ensure this path is tested.

We could still use tests for the polymorphic nature. Those coming up
next.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194317 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-09 04:32:34 +00:00
Chandler Carruth
cd7a191d8a Move the test type out of the function and into the anonymous namespace
to fix C++98 builds.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194316 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-09 04:09:50 +00:00
Chandler Carruth
aec427786b Add a polymorphic_ptr<T> smart pointer data type. It's a somewhat silly
unique ownership smart pointer which is *deep* copyable by assuming it
can call a T::clone() method to allocate a copy of the owned data.

This is mostly useful with containers or other collections of uniquely
owned data in C++98 where they *might* copy. With C++11 we can likely
remove this in favor of move-only types and containers wrapped around
those types.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194315 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-09 04:06:02 +00:00
Adrian Prantl
999ffb6085 Revert "Move copying of global initializers below the cloning of functions."
This would cause internal symbols that are only referenced by global initializers to be removed.

This reverts commit 194219.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194304 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-09 00:43:18 +00:00
Adrian Prantl
ab6f27c7ff Revert "Run clang-format on file."
This reverts commit 194219.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194303 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-09 00:43:12 +00:00
Bill Wendling
5ebdcd29b6 Run clang-format on file.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194219 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-07 20:18:21 +00:00
Bill Wendling
5d5f2c37d5 Move copying of global initializers below the cloning of functions.
The BlockAddress doesn't have access to the correct basic blocks until the
functions have been cloned. This causes the BlockAddress to point to the old
values. Just wait until the functions have been cloned before copying the
initializers.
PR13163

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194218 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-07 20:14:51 +00:00
Rafael Espindola
f94b3480fc Simplify ErrorOr.
ErrorOr had quiet a bit of complexity and indirection to be able to hold a user
type with the error.

That feature is not used anymore. This patch removes it, it will live in svn
history if we ever need it again.

If we do need it again, IMHO there is one thing that should be done
differently: Holding extra info in the error is not a property a function also
returning a value or not. The ability to hold extra info should be in the error
type and ErrorOr templated over it so that we don't need the funny looking
ErrorOr<void>.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194030 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-05 00:28:01 +00:00
Rafael Espindola
c143c7573b Merge CallGraph and BasicCallGraph.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193734 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-31 03:03:55 +00:00
Rafael Espindola
415b33f161 Add calls to doInitialization() and doFinalization() in verifyFunction()
The function verifyFunction() in lib/IR/Verifier.cpp misses some
calls. It creates a temporary FunctionPassManager that will run a
single Verifier pass. Unfortunately, FunctionPassManager is no
PassManager and does not call doInitialization() and doFinalization()
by itself. Verifier does important tasks in doInitialization() such as
collecting type information used to check DebugInfo metadata and
doFinalization() does some additional checks. Therefore these checks
were missed and debug info couldn't be verified at all, it just
crashed if the function had some.

verifyFunction() is currently not used in llvm unless -debug option is
enabled, and in unittests/IR/VerifierTest.cpp

VerifierTest had to be changed to create the function in a module from
which the type debug info can be collected.

Patch by Michael Kruse.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193719 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-30 22:37:51 +00:00
Rui Ueyama
f34c3ca304 Add {start,end}with_lower methods to StringRef.
startswith_lower is ocassionally useful and I think worth adding.
endwith_lower is added for completeness.

Differential Revision: http://llvm-reviews.chandlerc.com/D2041

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193706 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-30 18:32:26 +00:00
Nuno Lopes
d3b64efcb3 make ConstantRange::signExtend() optimal
the case [x, INT_MIN) was not handled optimally

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193694 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-30 15:36:50 +00:00
Alexey Samsonov
636a5cb8de DWARF parser: propery handle DW_FORM_ref_sig8 and fix Windows build.
Based on D2050 by Timur Iskhodzhanov.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193619 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-29 16:32:19 +00:00
Alexey Samsonov
6faff4886a DWARF parser: Use ArrayRef to represent form sizes and simplify DWARFDIE::extractFast() interface. No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193560 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-28 23:41:49 +00:00
Alexey Samsonov
c5253237f8 DebugInfo: Introduce the notion of "form classes"
Summary:
Use DWARF4 table of form classes to fetch attributes from DIE
in a more consistent way. This shouldn't change the functionality and
serves as a refactoring for upcoming change: DW_AT_high_pc has different
semantics depending on its form class.

Reviewers: dblaikie, echristo

Reviewed By: echristo

CC: echristo, llvm-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D1961

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193553 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-28 23:01:48 +00:00
Rui Ueyama
bc850d0c6c Add a few tests for StringRef::{start,end}with.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193550 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-28 22:42:54 +00:00
David Blaikie
7c0c2e56b0 DIEHash: Summary hashing of member functions
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193432 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-25 20:04:25 +00:00
Rafael Espindola
b1d39851bf Try to fix the build on windows.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193431 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-25 19:47:55 +00:00
Rafael Espindola
76a74f7253 Change MemoryBuffer::getFile to take a Twine.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193429 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-25 19:06:52 +00:00
David Blaikie
a954618c6e DIEHash: Summary hashing of nested types
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193427 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-25 18:38:43 +00:00
David Blaikie
377e83202c DIEHash: Const correct and use references where non-null/non-rebound.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193363 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-24 18:29:03 +00:00
David Blaikie
1d7d8da4cb DIEHash: Do not use shallow type hashing for unnamed types
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193361 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-24 17:53:58 +00:00
John Thompson
96b4005548 Reverting my r193344 checkin due to build breakage.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193350 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-24 14:52:56 +00:00
John Thompson
43752f2d4f Added std::string as a built-in type for mapping.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193344 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-24 13:36:58 +00:00
David Blaikie
f196208900 DWARF type hashing: pointers to members
Includes a test case/FIXME demonstrating a bug/limitation in pointer to
member hashing. To be honest I'm not sure why we don't just always use
summary hashing for referenced types... but perhaps I'm missing
something.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193175 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-22 18:14:41 +00:00
David Blaikie
449f036a81 DWARF Type Hashing: Include reference and rvalue reference type in the declarable summary hashing path
More support for 7.25 Part 5.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193129 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-21 23:06:19 +00:00
David Blaikie
f1545a2197 DWARF type hashing: begin implementing Step 5, summary hashing in declarable contexts
There are several other tag types that need similar handling but to
ensure test coverage they'll be coming incrementally.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193126 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-21 22:36:50 +00:00
Andrew Kaylor
65d60c8468 Removing unnecessary link component for MCJIT unittests
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193125 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-21 22:35:06 +00:00
David Blaikie
e46be7838a DIEHashTest: Correct the order of operands to the TEST macro
And add the 'Test' suffix so the test case name matches the file name.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193119 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-21 20:28:30 +00:00
David Blaikie
3baa3c37ce DWARF type hashing: Handle multiple (including recursive) references to the same type
This uses a map, keeping the type DIE numbering separate from the DIEs
themselves - alternatively we could do things the way GCC does if we
want to add an integer to the DIE type to record the numbering there.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193105 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-21 18:59:40 +00:00
David Blaikie
47f66d5a75 DIEHash: Support for simple (non-recursive, non-reused) type references
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192924 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-17 22:07:09 +00:00
David Blaikie
88a68cbbb5 DIEHash: Include the type's context in the type hash.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192856 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-17 00:10:34 +00:00
David Blaikie
c098708220 DIEHash: Use DW_FORM_sdata for integers, per spec.
This allows us to produce the same hash as GCC for at least some simple
examples.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192855 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-16 23:36:20 +00:00