[LLVMdev] [RFC] Semantic changes in the Metadata/Value split

Duncan P. N. Exon Smith dexonsmith at apple.com
Thu Dec 4 18:44:36 PST 2014

As of Monday, I finally got a preliminary patch passing check and
check-clang with the metadata-value split.

It's rather massive, but mostly NFC.

I've managed to keep the bitcode format, assembly syntax, and C API
unchanged, except for a few semantic restrictions that I'll separate out
and commit ahead of time via assertions to the extent I can.  (Obviously
I plan to clean up assembly and bitcode in a follow-up commit.)

This is mainly a heads up about what the semantic changes are; I think
they're mostly unavoidable given the constraints.

  - Function-local metadata is restricted to direct arguments to call
    intrinsics (i.e., `metadata !{i32 %val}`).  Temporarily, it's
    spelled the same way as an `MDNode` in assembly.

  - Except during "construction" -- for uniquing forward declarations --
    `MDNode` does not support `replaceAllUsesWith()`.

  - When an `MDNode` operand changes and there's a uniquing collision,
    uniquing is dropped for that node -- it becomes "distinct".  (Note
    that an operand going to null no longer turns off uniquing, unless
    there's a collision.  `MDNode` now supports `dropAllReferences()`,
    so there's no more web of RAUW during teardown of the context.)

  - Nodes that self-reference aren't uniqued at all.

I've attached my current patch (rebased last night) as a reference.
I'll separate out as much as I can before committing the main thing.

Aside from adding assertions for the above-mentioned semantic changes,
if anyone sees anything obvious to separate out let me know.

There are also a few follow-ups that I've left until later:

  - Change assembly syntax to make metadata look as typeless as it is.
    (This will come with painful clang testcase updates... yay!)

  - Ditto for bitcode.

  - Add assembly syntax, bitcode support, and C++ API for
    `MDNode::getDistinct()`, which explicitly opts out of uniquing.

  - Add `MDInt`, which is a generic integer represented by an `APSInt`
    for use in metadata.

  - Upgrade various types of metadata to use `MDInt` and/or

  - Add reference counting semantics to some types of metadata, so that
    no-longer-referenced metadata gets cleaned up.

  - Upgrade `DebugLoc` from 8 bits of column info to 16.

  - ... and get back to the debug info IR changes that get me into this
    mess :).

(I actually tried really hard to get half of this working without the
other half.  I created the `ValueAsMetadata` bridge and restricted
`MDNode` to only have subclasses of `Metadata` as operands, but left
`Metadata` inheriting from `Value`.  This only took a few days to get
compiling, but left tons of errors to be found at runtime due to failing
`cast<>` failures.  Although there are small things that I can break
off, IMO fundamentally splitting up this patch is untenable.)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: metadata-value-split.patch
Type: application/octet-stream
Size: 350563 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20141204/cb7020eb/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: metadata-value-split-clang.patch
Type: application/octet-stream
Size: 68983 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20141204/cb7020eb/attachment-0001.obj>

More information about the llvm-dev mailing list