DI: Add Function::getSubprogram()
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Fri, 28 Aug 2015 21:55:35 +0000 (21:55 +0000)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Fri, 28 Aug 2015 21:55:35 +0000 (21:55 +0000)
commit819d0a503e30a7ad9332ef9127d742c02777b06e
treeae1533f006fb132638f7c5141e8dc3bc1a9c07a7
parent155b4af95d985e6f0b6c22cf9d318b0bff2324a4
DI: Add Function::getSubprogram()

Add `Function::setSubprogram()` and `Function::getSubprogram()`,
convenience methods to forward to `setMetadata()` and `getMetadata()`,
respectively, and deal in `DISubprogram` instead of `MDNode`.

Also add a verifier check to enforce that `!dbg` attachments are always
subprograms.

Originally (when I had the llvm-dev discussion back in April) I thought
I'd store a pointer directly on `llvm::Function` for these attachments
-- we frequently have debug info, and that's much cheaper than using map
in the context if there are no other function-level attachments -- but
for now I'm just using the generic infrastructure.  Let's add the extra
complexity only if this shows up in a profile.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@246339 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/IR/Function.h
lib/IR/Metadata.cpp
lib/IR/Verifier.cpp
test/Verifier/metadata-function-dbg.ll [new file with mode: 0644]
unittests/IR/MetadataTest.cpp