Commit Graph

586 Commits

Author SHA1 Message Date
Manman Ren
0d12d4ebc6 [llvm link] Destroy ConstantArrays in LLVMContext if they are not used.
ConstantArrays constructed during linking can cause quadratic memory
explosion. An example is the ConstantArrays constructed when linking in
GlobalVariables with appending linkage.

Releasing all unused constants can cause a 20% LTO compile-time
slowdown for a large application. So this commit releases unused ConstantArrays
only.

rdar://19040716. It reduces memory footprint from 20+G to 6+G.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226592 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-20 19:24:59 +00:00
Rafael Espindola
68016e0a6e Use the DiagnosticHandler to print diagnostics when reading bitcode.
The bitcode reading interface used std::error_code to report an error to the
callers and it is the callers job to print diagnostics.

This is not ideal for error handling or diagnostic reporting:

* For error handling, all that the callers care about is 3 possibilities:
  * It worked
  * The bitcode file is corrupted/invalid.
  * The file is not bitcode at all.

* For diagnostic, it is user friendly to include far more information
  about the invalid case so the user can find out what is wrong with the
  bitcode file. This comes up, for example, when a developer introduces a
  bug while extending the format.

The compromise we had was to have a lot of error codes.

With this patch we use the DiagnosticHandler to communicate with the
human and std::error_code to communicate with the caller.

This allows us to have far fewer error codes and adds the infrastructure to
print better diagnostics. This is so because the diagnostics are printed when
he issue is found. The code that detected the problem in alive in the stack and
can pass down as much context as needed. As an example the patch updates
test/Bitcode/invalid.ll.

Using a DiagnosticHandler also moves the fatal/non-fatal error decision to the
caller. A simple one like llvm-dis can just use fatal errors. The gold plugin
needs a bit more complex treatment because of being passed non-bitcode files. An
hypothetical interactive tool would make all bitcode errors non-fatal.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225562 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-10 00:07:30 +00:00
Duncan P. N. Exon Smith
c742e3a68d Linker: Don't use MDNode::replaceOperandWith()
`MDNode::replaceOperandWith()` changes all instances of metadata.  Stop
using it when linking module flags, since (due to uniquing) the flag
values could be used by other metadata.

Instead, use new API `NamedMDNode::setOperand()` to update the reference
directly.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225397 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-07 21:32:27 +00:00
Rafael Espindola
d27b926340 Finish removing DestroySource.
Fixes pr21901.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224782 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-23 19:16:45 +00:00
Duncan P. N. Exon Smith
33ed2ef4ff Rename MapValue(Metadata*) to MapMetadata()
Instead of reusing the name `MapValue()` when mapping `Metadata`, use
`MapMetadata()`.  The old name doesn't make much sense after the
`Metadata`/`Value` split.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224566 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-19 06:06:18 +00:00
Duncan P. N. Exon Smith
ee40b16641 Reapply "Linker: Drop superseded subprograms"
This reverts commit r224416, reapplying r224389.  The buildbots hadn't
recovered after my revert, waiting until David reverted a couple of his
commits.  It looks like it was just bad timing (where we were both
modifying code related to the same assertion).  Trying again...

Here's the original text:

    When a function gets replaced by `ModuleLinker`, drop superseded
    subprograms.  This ensures that the "first" subprogram pointing at a
    function is the same one that `!dbg` references point at.

    This is a stop-gap fix for PR21910.  Notably, this fixes Release+Asserts
    bootstraps that are currently asserting out in
    `LexicalScopes::initialize()` due to the explicit instantiations in
    `lib/IR/Dominators.cpp` eventually getting replaced by -argpromotion.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224487 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-18 01:05:33 +00:00
Duncan P. N. Exon Smith
80c5783c88 Revert "Linker: Drop superseded subprograms"
This reverts commit r224389.  Based on feedback from the bots, the
assertion seems to be going off *more* often, not less (previously I was
just seeing it in an internal bootstrap, now it's happening in public
builds too).

http://lab.llvm.org:8080/green/job/clang-stage2-configure-Rlto_build/936/
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap/builds/5325

Reverting in order to investigate.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224416 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-17 07:27:31 +00:00
Duncan P. N. Exon Smith
d4017d0489 Linker: Drop superseded subprograms
When a function gets replaced by `ModuleLinker`, drop superseded
subprograms.  This ensures that the "first" subprogram pointing at a
function is the same one that `!dbg` references point at.

This is a stop-gap fix for PR21910.  Notably, this fixes Release+Asserts
bootstraps that are currently asserting out in
`LexicalScopes::initialize()` due to the explicit instantiations in
`lib/IR/Dominators.cpp` eventually getting replaced by -argpromotion.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224389 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-16 23:23:41 +00:00
Rafael Espindola
e1bf514b2b Make the assert a bit stronger.
We should get no declarations in here.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224382 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-16 22:29:43 +00:00
Michael Ilseman
f651477d66 Sink the isa into the assert
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224291 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-15 23:41:21 +00:00
Michael Ilseman
bc541ae238 Clean up warning about unused variable
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224281 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-15 21:47:09 +00:00
Michael Ilseman
9f0d59ab46 Revert of r223763, in spirit.
r223763 was made to work around a temporary issue where a user of the
JIT was passing down a declaration (incorrectly). This shouldn't
occur, so assert rather than silently continue.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224277 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-15 21:36:29 +00:00
Duncan P. N. Exon Smith
dad20b2ae2 IR: Split Metadata from Value
Split `Metadata` away from the `Value` class hierarchy, as part of
PR21532.  Assembly and bitcode changes are in the wings, but this is the
bulk of the change for the IR C++ API.

I have a follow-up patch prepared for `clang`.  If this breaks other
sub-projects, I apologize in advance :(.  Help me compile it on Darwin
I'll try to fix it.  FWIW, the errors should be easy to fix, so it may
be simpler to just fix it yourself.

This breaks the build for all metadata-related code that's out-of-tree.
Rest assured the transition is mechanical and the compiler should catch
almost all of the problems.

Here's a quick guide for updating your code:

  - `Metadata` is the root of a class hierarchy with three main classes:
    `MDNode`, `MDString`, and `ValueAsMetadata`.  It is distinct from
    the `Value` class hierarchy.  It is typeless -- i.e., instances do
    *not* have a `Type`.

  - `MDNode`'s operands are all `Metadata *` (instead of `Value *`).

  - `TrackingVH<MDNode>` and `WeakVH` referring to metadata can be
    replaced with `TrackingMDNodeRef` and `TrackingMDRef`, respectively.

    If you're referring solely to resolved `MDNode`s -- post graph
    construction -- just use `MDNode*`.

  - `MDNode` (and the rest of `Metadata`) have only limited support for
    `replaceAllUsesWith()`.

    As long as an `MDNode` is pointing at a forward declaration -- the
    result of `MDNode::getTemporary()` -- it maintains a side map of its
    uses and can RAUW itself.  Once the forward declarations are fully
    resolved RAUW support is dropped on the ground.  This means that
    uniquing collisions on changing operands cause nodes to become
    "distinct".  (This already happened fairly commonly, whenever an
    operand went to null.)

    If you're constructing complex (non self-reference) `MDNode` cycles,
    you need to call `MDNode::resolveCycles()` on each node (or on a
    top-level node that somehow references all of the nodes).  Also,
    don't do that.  Metadata cycles (and the RAUW machinery needed to
    construct them) are expensive.

  - An `MDNode` can only refer to a `Constant` through a bridge called
    `ConstantAsMetadata` (one of the subclasses of `ValueAsMetadata`).

    As a side effect, accessing an operand of an `MDNode` that is known
    to be, e.g., `ConstantInt`, takes three steps: first, cast from
    `Metadata` to `ConstantAsMetadata`; second, extract the `Constant`;
    third, cast down to `ConstantInt`.

    The eventual goal is to introduce `MDInt`/`MDFloat`/etc. and have
    metadata schema owners transition away from using `Constant`s when
    the type isn't important (and they don't care about referring to
    `GlobalValue`s).

    In the meantime, I've added transitional API to the `mdconst`
    namespace that matches semantics with the old code, in order to
    avoid adding the error-prone three-step equivalent to every call
    site.  If your old code was:

        MDNode *N = foo();
        bar(isa             <ConstantInt>(N->getOperand(0)));
        baz(cast            <ConstantInt>(N->getOperand(1)));
        bak(cast_or_null    <ConstantInt>(N->getOperand(2)));
        bat(dyn_cast        <ConstantInt>(N->getOperand(3)));
        bay(dyn_cast_or_null<ConstantInt>(N->getOperand(4)));

    you can trivially match its semantics with:

        MDNode *N = foo();
        bar(mdconst::hasa               <ConstantInt>(N->getOperand(0)));
        baz(mdconst::extract            <ConstantInt>(N->getOperand(1)));
        bak(mdconst::extract_or_null    <ConstantInt>(N->getOperand(2)));
        bat(mdconst::dyn_extract        <ConstantInt>(N->getOperand(3)));
        bay(mdconst::dyn_extract_or_null<ConstantInt>(N->getOperand(4)));

    and when you transition your metadata schema to `MDInt`:

        MDNode *N = foo();
        bar(isa             <MDInt>(N->getOperand(0)));
        baz(cast            <MDInt>(N->getOperand(1)));
        bak(cast_or_null    <MDInt>(N->getOperand(2)));
        bat(dyn_cast        <MDInt>(N->getOperand(3)));
        bay(dyn_cast_or_null<MDInt>(N->getOperand(4)));

  - A `CallInst` -- specifically, intrinsic instructions -- can refer to
    metadata through a bridge called `MetadataAsValue`.  This is a
    subclass of `Value` where `getType()->isMetadataTy()`.

    `MetadataAsValue` is the *only* class that can legally refer to a
    `LocalAsMetadata`, which is a bridged form of non-`Constant` values
    like `Argument` and `Instruction`.  It can also refer to any other
    `Metadata` subclass.

(I'll break all your testcases in a follow-up commit, when I propagate
this change to assembly.)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223802 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-09 18:38:53 +00:00
Michael Ilseman
ebaf61e498 Skip declarations in the case of functions.
This is a revert of r223521 in spirit, if not in content. I am not
sure why declarations ended up in LazilyLinkGlobalValues in the first
place; that will take some more investigation.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223763 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-09 08:20:06 +00:00
Rafael Espindola
7fd7effa37 Lazily link GlobalVariables and GlobalAliases.
We were already lazily linking functions, but all GlobalValues can be treated
uniformly for this.

The test updates are to ensure that a given GlobalValue is still linked in.

This fixes pr21494.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223681 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-08 18:45:16 +00:00
Rafael Espindola
dcc44c64c1 Don't crash when the key of a comdat is lazily linked.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223673 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-08 18:05:48 +00:00
Rafael Espindola
968f0454b8 Move the ValueMap lookup inside linkFunctionBody. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223659 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-08 14:25:26 +00:00
Rafael Espindola
eaa2992eb2 Use range loops. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223658 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-08 14:20:10 +00:00
Rafael Espindola
e305256ca2 Use range loops. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223657 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-08 14:05:33 +00:00
Rafael Espindola
7779b87b25 Fix linking of prologue data.
It would crash when the function was lazy linked.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223656 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-08 13:44:38 +00:00
Rafael Espindola
254e67955f Simple style fixes.
* Use a range loop.
* Move simple continue checks earlier.
* clang-format.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223654 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-08 13:35:09 +00:00
Rafael Espindola
95d1d167d0 Move materialize/Dematerialize calls to linkFunctionBody. NFC.
Just less code duplication.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223653 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-08 13:29:33 +00:00
Benjamin Kramer
2991725fe2 Turn some DenseMaps that are only used for set operations into DenseSets.
DenseSet has better memory efficiency now.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223589 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-06 19:22:54 +00:00
Rafael Espindola
9423af6b70 Remove dead code. We are only lazy about functions with bodies.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223521 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-05 21:36:06 +00:00
Rafael Espindola
f117c8ae03 Simplify the loop linking function bodies. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223512 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-05 21:04:36 +00:00
Rafael Espindola
98821ee350 Remove unused arguments. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223503 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-05 19:35:07 +00:00
Rafael Espindola
24ba29981c Refactor duplicated code. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223486 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-05 17:53:15 +00:00
Rafael Espindola
dd6794f01d Small cleanup on how we clear constant variables. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223474 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-05 16:05:19 +00:00
Rafael Espindola
46cbde27ce Use an early return. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223470 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-05 15:42:30 +00:00
Rafael Espindola
7eaee304ab linkGlobalVariableProto never returns null. Simplify the caller. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223424 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-05 00:30:47 +00:00
Rafael Espindola
aa8cddcd3a Move merging of alignment to a central location. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223418 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-05 00:09:02 +00:00
Rafael Espindola
55d5ea3be3 Split the set of identified struct types into opaque and non-opaque ones.
The non-opaque part can be structurally uniqued. To keep this to just
a hash lookup, we don't try to unique cyclic types.

Also change the type mapping algorithm to be optimistic about a type
not being recursive and only create a new type when proven to be wrong.
This is not as strong as trying to speculate that we can keep the source
type, but is simpler (no speculation to revert) and more powerfull
than what we had before (we don't copy non-recursive types at least).

I initially wrote this to try to replace the name based type merging.
It is not strong enough to replace it, but is is a useful addition.

With this patch the number of named struct types is a clang lto bootstrap goes
from 49674 to 15986.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223278 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-03 22:36:37 +00:00
Rafael Espindola
eee41dbb65 Ask the module for its the identified types.
When lazy reading a module, the types used in a function will not be visible to
a TypeFinder until the body is read.

This patch fixes that by asking the module for its identified struct types.
If a materializer is present, the module asks it. If not, it uses a TypeFinder.

This fixes pr21374.

I will be the first to say that this is ugly, but it was the best I could find.

Some of the options I looked at:

* Asking the LLVMContext. This could be made to work for gold, but not currently
  for ld64. ld64 will load multiple modules into a single context before merging
  them. This causes us to see types from future merges. Unfortunately,
  MappedTypes is not just a cache when it comes to opaque types. Once the
  mapping has been made, we have to remember it for as long as the key may
  be used. This would mean moving MappedTypes to the Linker class and having
  to drop the Linker::LinkModules static methods, which are visible from C.

* Adding an option to ignore function bodies in the TypeFinder. This would
  fix the PR by picking the worst result. It would work, but unfortunately
  we are currently quite dependent on the upfront type merging. I will
  try to reduce our dependency, but it is not clear that we will be able
  to get rid of it for now.

The only clean solution I could think of is making the Module own the types.
This would have other advantages, but it is a much bigger change. I will
propose it, but it is nice to have this fixed while that is discussed.

With the gold plugin, this patch takes the number of types in the LTO clang
binary from 52817 to 49669.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223215 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-03 07:18:23 +00:00
Peter Collingbourne
bb660fc192 Prologue support
Patch by Ben Gamari!

This redefines the `prefix` attribute introduced previously and
introduces a `prologue` attribute.  There are a two primary usecases
that these attributes aim to serve,

  1. Function prologue sigils

  2. Function hot-patching: Enable the user to insert `nop` operations
     at the beginning of the function which can later be safely replaced
     with a call to some instrumentation facility

  3. Runtime metadata: Allow a compiler to insert data for use by the
     runtime during execution. GHC is one example of a compiler that
     needs this functionality for its tables-next-to-code functionality.

Previously `prefix` served cases (1) and (2) quite well by allowing the user
to introduce arbitrary data at the entrypoint but before the function
body. Case (3), however, was poorly handled by this approach as it
required that prefix data was valid executable code.

Here we redefine the notion of prefix data to instead be data which
occurs immediately before the function entrypoint (i.e. the symbol
address). Since prefix data now occurs before the function entrypoint,
there is no need for the data to be valid code.

The previous notion of prefix data now goes under the name "prologue
data" to emphasize its duality with the function epilogue.

The intention here is to handle cases (1) and (2) with prologue data and
case (3) with prefix data.

References
----------

This idea arose out of discussions[1] with Reid Kleckner in response to a
proposal to introduce the notion of symbol offsets to enable handling of
case (3).

[1] http://lists.cs.uiuc.edu/pipermail/llvmdev/2014-May/073235.html

Test Plan: testsuite

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223189 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-03 02:08:38 +00:00
Rafael Espindola
f97b79e09e Use a continue to reduce indentation and clang-format. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223067 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-01 19:17:46 +00:00
Rafael Espindola
6eee2bbbbb Use a range loop. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223066 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-01 19:08:07 +00:00
Rafael Espindola
e8f8c64e35 Drop SrcStructTypesSet. It is redundant.
At the only point in the code it is used, we haven't added any of the src types
to DstStructTypesSet yet.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223057 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-01 18:42:18 +00:00
Rafael Espindola
d9788e9372 Partial revert of r222986.
The explicit set of destination types is not fully redundant when lazy loading
since the TypeFinder will not find types used only in function bodies.

This keeps the logic to drop the name of mapped types since it still helps
with avoiding further renaming.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223043 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-01 16:32:20 +00:00
Rafael Espindola
7a551b7c6d Change how we keep track of which types are in the dest module.
Instead of keeping an explicit set, just drop the names of types we choose
to map to some other type.

This has the advantage that the name of the unused will not cause the context
to rename types on module read.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222986 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-01 04:15:59 +00:00
Rafael Espindola
f716393db9 Add back r222727 with a fix.
The original patch would fail when:

* A dst opaque type (%A) is matched with a src type (%A).
* A src opaque (%E) type is then speculatively matched with %A and the
  speculation fails afterward.
* When rolling back the speculation we would cancel the source %A to dest
  %A mapping.

The fix is to keep an explicit list of which resolutions are speculative.

Original message:

Fix overly aggressive type merging.

If we find out that two types are *not* isomorphic, we learn nothing about
opaque sub types in both the source and destination.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222923 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-28 16:41:24 +00:00
Rafael Espindola
fdf8098678 Add an assert and use a range loop. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222922 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-28 16:26:14 +00:00
Duncan P. N. Exon Smith
eb70fd030a Revert "Fix overly aggressive type merging."
This reverts commit r222727, which causes LTO bootstrap failures.

Last passing @ r222698:
http://lab.llvm.org:8080/green/job/clang-Rlto_master_build/532/

First failing @ r222843:
http://lab.llvm.org:8080/green/job/clang-Rlto_master_build/533/

Internal bootstraps pointed at a much narrower range: r222725 is
passing, and r222731 is failing.

LTO crashes while handling libclang.dylib:
http://lab.llvm.org:8080/green/job/clang-Rlto_master_build/533/consoleFull#-158682280549ba4694-19c4-4d7e-bec5-911270d8a58c

    GEP is not of right type for indices!
      %InfoObj.i.i = getelementptr inbounds %"class.llvm::OnDiskIterableChainedHashTable"* %.lcssa, i64 0, i32 0, i32 4, !dbg !123627
     %"class.clang::serialization::reader::ASTIdentifierLookupTrait" = type { %"class.clang::ASTReader.31859"*, %"class.clang::serialization::ModuleFile.31870"*, %"class.clang::IdentifierInfo"* }LLVM ERROR: Broken function found, compilation aborted!
    clang: error: linker command failed with exit code 1 (use -v to see invocation)

Looks like the new algorithm doesn't merge types aggressively enough.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222895 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-27 17:01:10 +00:00
Rafael Espindola
b4e2bdb21b Set the body of a new struct as soon as it is created.
This changes the order in which different types are passed to get, but
one order is not inherently better than the other.

The main motivation is that this simplifies linkDefinedTypeBodies now that
it is only linking "real" opaque types. It is also means that we only have to
call it once and that we don't need getImpl.

A small change in behavior is that we don't copy type names when resolving
opaque types. This is an improvement IMHO, but it can be added back if
desired. A test is included with the new behavior.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222764 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-25 15:33:40 +00:00
Rafael Espindola
b3d06a043a Misc style fixes. NFC.
This just reduces the noise in the next patch.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222761 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-25 14:35:53 +00:00
Rafael Espindola
b959a30a14 Remove a bit of duplicated code.
Exactly the same checks are present in areTypesIsomorphic.

This might have been a premature performance optimization. I cannot reproduce
any slowdown with this patch.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222758 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-25 13:19:46 +00:00
Rafael Espindola
95f8931c55 Use a range loop. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222730 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-25 06:16:27 +00:00
Rafael Espindola
8665715bdd Style fix: don't indent inside a namemespace.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222729 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-25 06:11:24 +00:00
Rafael Espindola
fbc90b1bb1 Remove a nested anonymous namespace.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222728 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-25 06:07:51 +00:00
Rafael Espindola
842d2b62ed Fix overly aggressive type merging.
If we find out that two types are *not* isomorphic, we learn nothing about
opaque sub types in both the source and destination.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222727 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-25 05:59:24 +00:00
Rafael Espindola
453ce91dbc Link the type of aliases.
They are not more or less "well typed" than GlobalVariables.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222725 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-25 04:43:59 +00:00