[PATCH] D21052: IR: Allow metadata attachments on declarations, and fix lazy loaded metadata issue with globals.
Peter Collingbourne via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 6 18:48:09 PDT 2016
pcc created this revision.
pcc added reviewers: aprantl, dexonsmith, mehdi_amini.
pcc added a subscriber: llvm-commits.
This change is motivated by an upcoming change to the metadata representation
used for CFI. The indirect function call checker needs type information for
external function declarations in order to correctly generate jump table
entries for such declarations. We currently associate such type information
with declarations using a global metadata node, but I plan [1] to move all
such metadata to global object attachments.
In bitcode, metadata attachments for function declarations appear in the
global metadata block. This seems reasonable to me because I expect metadata
attachments on declarations to be uncommon. In the long term I'd also expect
this to be the case for CFI, because we'd want to use some specialized bitcode
format for this metadata that could be read as part of the ThinLTO thin-link
phase, which would mean that it would not appear in the global metadata block.
To solve the lazy loaded metadata issue I was seeing with D20147, I use the
same bitcode representation for metadata attachments for global variables as I
do for function declarations. Since there's a use case for metadata attachments
in the global metadata block, we might as well use that representation for
global variables as well, at least until we have a mechanism for lazy loading
global variables.
In the assembly format, the metadata attachments appear after the "declare"
keyword in order to avoid a parsing ambiguity. I could make the same change
for function definition attachments if that seems reasonable.
[1] http://lists.llvm.org/pipermail/llvm-dev/2016-June/100462.html
http://reviews.llvm.org/D21052
Files:
docs/BitCodeFormat.rst
include/llvm/Bitcode/LLVMBitCodes.h
lib/AsmParser/LLParser.cpp
lib/Bitcode/Reader/BitcodeReader.cpp
lib/Bitcode/Writer/BitcodeWriter.cpp
lib/Bitcode/Writer/ValueEnumerator.cpp
lib/Bitcode/Writer/ValueEnumerator.h
lib/IR/AsmWriter.cpp
lib/IR/Verifier.cpp
test/Assembler/metadata-decl.ll
test/Assembler/metadata.ll
tools/llvm-dis/llvm-dis.cpp
unittests/IR/MetadataTest.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21052.59817.patch
Type: text/x-patch
Size: 17336 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160607/8ad5eb91/attachment.bin>
More information about the llvm-commits
mailing list