summaryrefslogtreecommitdiffstats
path: root/llvm/test/Verifier/metadata-function-dbg.ll
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2015-08-28 21:55:35 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2015-08-28 21:55:35 +0000
commitb56b5af4c37e3e00f65e17e40055dc6c4b2f6ade (patch)
tree6035671e7a04416d616261d46da7c1f61ecc0f8e /llvm/test/Verifier/metadata-function-dbg.ll
parent6eaa8323a887a878f54dfcc65d4fff72c0f5c161 (diff)
downloadbcm5719-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/test/Verifier/metadata-function-dbg.ll')
-rw-r--r--llvm/test/Verifier/metadata-function-dbg.ll23
1 files changed, 23 insertions, 0 deletions
diff --git a/llvm/test/Verifier/metadata-function-dbg.ll b/llvm/test/Verifier/metadata-function-dbg.ll
new file mode 100644
index 00000000000..43c632babda
--- /dev/null
+++ b/llvm/test/Verifier/metadata-function-dbg.ll
@@ -0,0 +1,23 @@
+; RUN: not llvm-as %s -disable-output 2>&1 | FileCheck %s
+
+define void @foo() !dbg !4 {
+ unreachable
+}
+
+; CHECK-NOT: !dbg
+; CHECK: function !dbg attachment must be a subprogram
+; CHECK-NEXT: void ()* @bar
+; CHECK-NEXT: !{{[0-9]+}} = !{}
+define void @bar() !dbg !6 {
+ unreachable
+}
+
+!llvm.module.flags = !{!0}
+!0 = !{i32 2, !"Debug Info Version", i32 3}
+
+!llvm.dbg.cu = !{!1}
+!1 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, subprograms: !3)
+!2 = !DIFile(filename: "t.c", directory: "/path/to/dir")
+!3 = !{!4}
+!4 = distinct !DISubprogram(name: "foo", scope: !1, file: !2, function: void ()* @foo)
+!6 = !{}
OpenPOWER on IntegriCloud