llvm-6502/test/Linker
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
..
Inputs IR: Split Metadata from Value 2014-12-09 18:38:53 +00:00
2002-07-17-GlobalFail.ll
2002-07-17-LinkTest2.ll
2002-08-20-ConstantExpr.ll
2003-01-30-LinkerRename.ll Make this test a bit stricter. 2014-10-23 18:44:07 +00:00
2003-01-30-LinkerTypeRename.ll
2003-04-23-LinkOnceLost.ll
2003-04-26-NullPtrLinkProblem.ll
2003-05-15-TypeProblem.ll
2003-05-31-LinkerRename.ll Make this test a bit stricter. 2014-10-23 18:52:46 +00:00
2003-06-02-TypeResolveProblem2.ll
2003-06-02-TypeResolveProblem.ll
2003-08-20-OpaqueTypeResolve.ll
2003-08-23-GlobalVarLinking.ll
2003-08-23-RecursiveOpaqueTypeResolve.ll
2003-08-24-InheritPtrSize.ll
2003-08-28-TypeResolvesGlobal2.ll
2003-08-28-TypeResolvesGlobal3.ll
2003-08-28-TypeResolvesGlobal.ll
2003-10-27-LinkOncePromote.ll
2003-11-18-TypeResolution.ll
2004-02-17-WeakStrongLinkage.ll
2004-05-07-TypeResolution1.ll
2004-05-07-TypeResolution2.ll
2004-12-03-DisagreeingType.ll
2005-02-12-ConstantGlobals-2.ll
2005-02-12-ConstantGlobals.ll
2005-12-06-AppendingZeroLengthArrays.ll
2006-01-19-ConstantPacked.ll
2008-03-05-AliasReference2.ll
2008-03-05-AliasReference.ll Use "weak alias" instead of "alias weak" 2014-07-30 22:51:54 +00:00
2008-03-07-DroppedSection_a.ll
2008-03-07-DroppedSection_b.ll
2008-06-13-LinkOnceRedefinition.ll
2008-06-26-AddressSpace.ll
2008-07-06-AliasFnDecl2.ll
2008-07-06-AliasFnDecl.ll
2008-07-06-AliasWeakDest2.ll
2008-07-06-AliasWeakDest.ll
2009-09-03-mdnode2.ll Revert "Revert "DI: Fold constant arguments into a single MDString"" 2014-10-03 20:01:09 +00:00
2009-09-03-mdnode.ll Revert "Revert "DI: Fold constant arguments into a single MDString"" 2014-10-03 20:01:09 +00:00
2011-08-04-DebugLoc2.ll Revert "Revert "DI: Fold constant arguments into a single MDString"" 2014-10-03 20:01:09 +00:00
2011-08-04-DebugLoc.ll Revert "Revert "DI: Fold constant arguments into a single MDString"" 2014-10-03 20:01:09 +00:00
2011-08-04-Metadata2.ll Revert "Revert "DI: Fold constant arguments into a single MDString"" 2014-10-03 20:01:09 +00:00
2011-08-04-Metadata.ll Revert "Revert "DI: Fold constant arguments into a single MDString"" 2014-10-03 20:01:09 +00:00
2011-08-18-unique-class-type2.ll Revert "Revert "DI: Fold constant arguments into a single MDString"" 2014-10-03 20:01:09 +00:00
2011-08-18-unique-class-type.ll Revert "Revert "DI: Fold constant arguments into a single MDString"" 2014-10-03 20:01:09 +00:00
2011-08-18-unique-debug-type2.ll Revert "Revert "DI: Fold constant arguments into a single MDString"" 2014-10-03 20:01:09 +00:00
2011-08-18-unique-debug-type.ll Revert "Revert "DI: Fold constant arguments into a single MDString"" 2014-10-03 20:01:09 +00:00
2011-08-22-ResolveAlias2.ll Use "weak alias" instead of "alias weak" 2014-07-30 22:51:54 +00:00
2011-08-22-ResolveAlias.ll Use "weak alias" instead of "alias weak" 2014-07-30 22:51:54 +00:00
alias.ll Allow alias to point to an arbitrary ConstantExpr. 2014-06-03 02:41:57 +00:00
alignment.ll Add a few extra cases to the test. NFC. 2014-12-05 00:02:42 +00:00
AppendingLinkage2.ll
AppendingLinkage.ll
available_externally_a.ll
available_externally_b.ll
basiclink.ll
comdat2.ll IR: Add COMDATs to the IR 2014-06-27 18:19:56 +00:00
comdat3.ll IR: Add COMDATs to the IR 2014-06-27 18:19:56 +00:00
comdat4.ll IR: Add COMDATs to the IR 2014-06-27 18:19:56 +00:00
comdat5.ll IR: Add COMDATs to the IR 2014-06-27 18:19:56 +00:00
comdat6.ll Simplify test. NFC. 2014-12-08 17:02:50 +00:00
comdat7.ll Cleanup this test a bit. 2014-10-23 19:36:21 +00:00
comdat8.ll Cleanup this test a bit. 2014-10-23 19:23:42 +00:00
comdat9.ll Don't crash when the key of a comdat is lazily linked. 2014-12-08 18:05:48 +00:00
comdat.ll IR: Add COMDATs to the IR 2014-06-27 18:19:56 +00:00
ConstantGlobals.ll merge tests for constant linking. 2014-10-31 05:04:16 +00:00
constructor-comdat.ll Fix use of uninitialized variable. 2014-08-11 17:07:34 +00:00
ctors.ll Fix pr20078. 2014-09-05 21:27:52 +00:00
datalayout.ll Don't assume an empty stderr. 2014-03-11 18:25:33 +00:00
DbgDeclare2.ll Revert "Revert "DI: Fold constant arguments into a single MDString"" 2014-10-03 20:01:09 +00:00
DbgDeclare.ll Revert "Revert "DI: Fold constant arguments into a single MDString"" 2014-10-03 20:01:09 +00:00
debug-info-version-a.ll Revert "Revert "DI: Fold constant arguments into a single MDString"" 2014-10-03 20:01:09 +00:00
debug-info-version-b.ll Revert "Revert "DI: Fold constant arguments into a single MDString"" 2014-10-03 20:01:09 +00:00
dllstorage-a.ll Copy dll storage in copyAttributes. 2014-02-13 05:11:35 +00:00
dllstorage-b.ll Copy dll storage in copyAttributes. 2014-02-13 05:11:35 +00:00
func-attrs-a.ll Verify that attributes are not lost during linking. 2014-01-24 19:20:15 +00:00
func-attrs-b.ll Verify that attributes are not lost during linking. 2014-01-24 19:20:15 +00:00
global_ctors.ll Don't upgrade global constructors when reading bitcode 2014-08-12 16:46:37 +00:00
ident.ll [Linker] Add some test coverage for llvm.ident merging 2014-11-05 21:33:34 +00:00
inlineasm.ll
link-global-to-func.ll
link-type-names.ll
linkage2.ll Merge alignment of common GlobalValue. 2014-09-09 17:48:18 +00:00
linkage.ll
linkmdnode2.ll
linkmdnode.ll
linknamedmdnode2.ll
linknamedmdnode.ll
LinkOnce.ll
lto-attributes.ll Lazily link GlobalVariables and GlobalAliases. 2014-12-08 18:45:16 +00:00
metadata-a.ll IR: Disallow function-local metadata attachments 2014-12-06 02:29:44 +00:00
metadata-b.ll IR: Disallow function-local metadata attachments 2014-12-06 02:29:44 +00:00
module-flags-1-a.ll
module-flags-1-b.ll
module-flags-2-a.ll
module-flags-2-b.ll
module-flags-3-a.ll
module-flags-3-b.ll
module-flags-4-a.ll
module-flags-4-b.ll
module-flags-5-a.ll
module-flags-5-b.ll
module-flags-6-a.ll
module-flags-6-b.ll
module-flags-7-a.ll
module-flags-7-b.ll
module-flags-8-a.ll
module-flags-8-b.ll
module-flags-pic-1-a.ll Add Position-independent Code model Module API. 2014-11-07 04:46:10 +00:00
module-flags-pic-2-a.ll Add Position-independent Code model Module API. 2014-11-07 04:46:10 +00:00
multiple-merged-structs.ll
opaque.ll Add a testcase reduced from clang lto bootstrap on OS X. 2014-11-28 15:45:31 +00:00
partial-type-refinement-link.ll
partial-type-refinement.ll
pr21374.ll Ask the module for its the identified types. 2014-12-03 07:18:23 +00:00
pr21494.ll Lazily link GlobalVariables and GlobalAliases. 2014-12-08 18:45:16 +00:00
PR8300.ll
prologuedata.ll Fix linking of prologue data. 2014-12-08 13:44:38 +00:00
redefinition.ll Unify and update link-messages.ll and redefinition.ll. NFC. 2014-10-31 16:52:30 +00:00
targettriple.ll Add a test for the -suppress-warnings option. 2014-10-25 01:14:15 +00:00
testlink.ll Lazily link GlobalVariables and GlobalAliases. 2014-12-08 18:45:16 +00:00
transitive-lazy-link.ll [tests] Use multiple statements instead of 'echo -e', which is not part of BSD echo. 2013-08-29 03:02:30 +00:00
type-unique-alias.ll Link the type of aliases. 2014-11-25 04:43:59 +00:00
type-unique-dst-types.ll Change how we keep track of which types are in the dest module. 2014-12-01 04:15:59 +00:00
type-unique-inheritance.ll Debug Info: In DIBuilder, the context fields of a TAG_inheritance and a 2013-09-09 23:07:58 +00:00
type-unique-name.ll Set the body of a new struct as soon as it is created. 2014-11-25 15:33:40 +00:00
type-unique-odr-a.ll [dwarfdump] Print the name for referenced specification of abstract_origin DIEs. 2014-10-06 03:36:31 +00:00
type-unique-odr-b.ll Revert "Revert "DI: Fold constant arguments into a single MDString"" 2014-10-03 20:01:09 +00:00
type-unique-opaque.ll Add back r222727 with a fix. 2014-11-28 16:41:24 +00:00
type-unique-simple2-a.ll Revert "Revert "DI: Fold constant arguments into a single MDString"" 2014-10-03 20:01:09 +00:00
type-unique-simple2-b.ll Revert "Revert "DI: Fold constant arguments into a single MDString"" 2014-10-03 20:01:09 +00:00
type-unique-simple2.ll Reland r200340 - 'Add line table debug info to COFF files when using a win32 triple' 2014-01-30 01:39:17 +00:00
type-unique-simple-a.ll Revert "Revert "DI: Fold constant arguments into a single MDString"" 2014-10-03 20:01:09 +00:00
type-unique-simple-b.ll Revert "Revert "DI: Fold constant arguments into a single MDString"" 2014-10-03 20:01:09 +00:00
type-unique-src-type.ll Split the set of identified struct types into opaque and non-opaque ones. 2014-12-03 22:36:37 +00:00
type-unique-type-array-a.ll Revert "Revert "DI: Fold constant arguments into a single MDString"" 2014-10-03 20:01:09 +00:00
type-unique-type-array-b.ll Revert "Revert "DI: Fold constant arguments into a single MDString"" 2014-10-03 20:01:09 +00:00
type-unique-unrelated.ll Add an interesting test that we already get right. NFC. 2014-11-25 03:47:57 +00:00
unique-fwd-decl-a.ll IR: Simplify uniquing for MDNode 2014-11-17 23:28:21 +00:00
unique-fwd-decl-order.ll IR: Split Metadata from Value 2014-12-09 18:38:53 +00:00
unnamed-addr1-a.ll Allow aliases to be unnamed_addr. 2014-06-06 01:20:28 +00:00
unnamed-addr1-b.ll Make this input file pass the verifier. 2014-09-09 15:40:12 +00:00
unnamed-addr-err-a.ll Error on linking appending globals with different unnamed_addr. 2013-09-04 15:33:34 +00:00
unnamed-addr-err-b.ll Error on linking appending globals with different unnamed_addr. 2013-09-04 15:33:34 +00:00
visibility.ll Revert r221096 bringing back r221014 with a fix. 2014-11-02 13:28:57 +00:00
weakextern.ll Pass the .ll files to llvm-link directly. NFC. 2014-11-24 20:35:59 +00:00