diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2015-08-28 21:55:35 +0000 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2015-08-28 21:55:35 +0000 |
commit | b56b5af4c37e3e00f65e17e40055dc6c4b2f6ade (patch) | |
tree | 6035671e7a04416d616261d46da7c1f61ecc0f8e /llvm/lib/IR/Metadata.cpp | |
parent | 6eaa8323a887a878f54dfcc65d4fff72c0f5c161 (diff) | |
download | bcm5719-llvm-b56b5af4c37e3e00f65e17e40055dc6c4b2f6ade.tar.gz bcm5719-llvm-b56b5af4c37e3e00f65e17e40055dc6c4b2f6ade.zip |
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.
llvm-svn: 246339
Diffstat (limited to 'llvm/lib/IR/Metadata.cpp')
-rw-r--r-- | llvm/lib/IR/Metadata.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/IR/Metadata.cpp b/llvm/lib/IR/Metadata.cpp index 431fee1b7b7..7d8c3523743 100644 --- a/llvm/lib/IR/Metadata.cpp +++ b/llvm/lib/IR/Metadata.cpp @@ -1259,3 +1259,11 @@ void Function::clearMetadata() { getContext().pImpl->FunctionMetadata.erase(this); setHasMetadataHashEntry(false); } + +void Function::setSubprogram(DISubprogram *SP) { + setMetadata(LLVMContext::MD_dbg, SP); +} + +DISubprogram *Function::getSubprogram() const { + return cast_or_null<DISubprogram>(getMetadata(LLVMContext::MD_dbg)); +} |