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/unittests | |
| 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/unittests')
| -rw-r--r-- | llvm/unittests/IR/MetadataTest.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/llvm/unittests/IR/MetadataTest.cpp b/llvm/unittests/IR/MetadataTest.cpp index b3c26eb407f..6741c79afc9 100644 --- a/llvm/unittests/IR/MetadataTest.cpp +++ b/llvm/unittests/IR/MetadataTest.cpp @@ -2273,4 +2273,16 @@ TEST_F(FunctionAttachmentTest, EntryCount) { EXPECT_EQ(12304u, *F->getEntryCount()); } +TEST_F(FunctionAttachmentTest, SubprogramAttachment) { + Function *F = getFunction("foo"); + DISubprogram *SP = getSubprogram(); + F->setSubprogram(SP); + + // Note that the static_cast confirms that F->getSubprogram() actually + // returns an DISubprogram. + EXPECT_EQ(SP, static_cast<DISubprogram *>(F->getSubprogram())); + EXPECT_EQ(SP, F->getMetadata("dbg")); + EXPECT_EQ(SP, F->getMetadata(LLVMContext::MD_dbg)); +} + } |

