This is an archive of the discontinued LLVM Phabricator instance.

Add support for metadata attachments for global variables.
ClosedPublic

Authored by pcc on May 9 2016, 10:57 AM.

Details

Summary

This patch adds an IR, assembly and bitcode representation for metadata
attachments for globals. Future patches will port existing features to use
these new attachments.

Diff Detail

Repository
rL LLVM

Event Timeline

pcc updated this revision to Diff 56597.May 9 2016, 10:57 AM
pcc retitled this revision from to Add support for metadata attachments for global variables..
pcc updated this object.
pcc added reviewers: aprantl, dexonsmith, dblaikie.
pcc added a subscriber: llvm-commits.
aprantl edited edge metadata.May 9 2016, 11:07 AM

Small nitpicks after a quick read-through.

include/llvm/IR/GlobalObject.h
74 ↗(On Diff #56597)

FYI: We run doxygen with auto-brief now. This makes "\brief" in redundant for one-sentence first paragraphs. Yay!

lib/Bitcode/Reader/BitcodeReader.cpp
3832 ↗(On Diff #56597)

if (auto *GV = ...) ?

pcc updated this revision to Diff 56601.May 9 2016, 11:12 AM
pcc marked an inline comment as done.
pcc edited edge metadata.
  • Address review comments
pcc marked an inline comment as done.May 9 2016, 11:13 AM
pcc added inline comments.
include/llvm/IR/GlobalObject.h
74 ↗(On Diff #56597)

Yep. This was moved from Function so I didn't look too closely at it. Fixed.

aprantl accepted this revision.May 31 2016, 11:02 AM
aprantl edited edge metadata.

Some more minor comments, but otherwise this looks good from my end. Thanks!

docs/BitCodeFormat.rst
851 ↗(On Diff #56601)

Should this be code 19?

docs/LangRef.rst
629 ↗(On Diff #56601)

Should this be

(!<name> !<N>)*

?

lib/Bitcode/Reader/BitcodeReader.cpp
4160 ↗(On Diff #56601)

I think we need to guard against corrupted input here.

if (Record.size() % 2)
    return error("Invalid record");
4202 ↗(On Diff #56601)

Oh. Given that this is here we can do an assert above. I still wonder whether an odd number of fields shouldn't be a hard error here.

test/Assembler/metadata.ll
8 ↗(On Diff #56601)

Should we use variables here or renumber the metadata in the testcase here? It's odd to check for something different than the input here.

This revision is now accepted and ready to land.May 31 2016, 11:02 AM
pcc added inline comments.May 31 2016, 4:08 PM
docs/BitCodeFormat.rst
851 ↗(On Diff #56601)

Yes, fixed.

docs/LangRef.rst
629 ↗(On Diff #56601)

Maybe, but we do have other sigil-variable forms in these grammars, and I think the intent is clear enough.

(If we did want to change this, there's another one like this for functions.)

lib/Bitcode/Reader/BitcodeReader.cpp
4160 ↗(On Diff #56601)

Added assert (see below) and guard to the GLOBALVAR_ATTACHMENT case above.

4202 ↗(On Diff #56601)

Added assert above.

I think we need to be able to accept an odd number of fields here for instruction metadata attachments (and presumably would need to keep accepting them for upgrades even if we change the representation).

test/Assembler/metadata.ll
8 ↗(On Diff #56601)

I started using variables for all tests in this file.

This revision was automatically updated to reflect the committed changes.