summaryrefslogtreecommitdiffstats
path: root/test/Verifier
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2016-06-21 23:42:48 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2016-06-21 23:42:48 +0000
commit99e2e27b37142953f163c33c85203cfa3aa4687d (patch)
tree00b87679c9a3813c503b85d62cdc8fb953a9abfe /test/Verifier
parent3071cc97270bf9ff75c2bd3d1477a62d41dc5c79 (diff)
IR: Allow metadata attachments on declarations, and fix lazy loaded metadata issue with globals.
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. [1] http://lists.llvm.org/pipermail/llvm-dev/2016-June/100462.html Differential Revision: http://reviews.llvm.org/D21052 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273336 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Verifier')
-rw-r--r--test/Verifier/metadata-function-dbg.ll7
-rw-r--r--test/Verifier/metadata-function-prof.ll7
2 files changed, 10 insertions, 4 deletions
diff --git a/test/Verifier/metadata-function-dbg.ll b/test/Verifier/metadata-function-dbg.ll
index 77f7de26c87e..24989ed7aa2e 100644
--- a/test/Verifier/metadata-function-dbg.ll
+++ b/test/Verifier/metadata-function-dbg.ll
@@ -1,11 +1,14 @@
; RUN: not llvm-as %s -disable-output 2>&1 | FileCheck %s
-define void @foo() !dbg !4 {
+; CHECK: function declaration may not have a !dbg attachment
+declare !dbg !4 void @f1()
+
+define void @f2() !dbg !4 {
unreachable
}
; CHECK: function must have a single !dbg attachment
-define void @foo2() !dbg !4 !dbg !4 {
+define void @f3() !dbg !4 !dbg !4 {
unreachable
}
diff --git a/test/Verifier/metadata-function-prof.ll b/test/Verifier/metadata-function-prof.ll
index ca0628f44f89..d84a7fe54402 100644
--- a/test/Verifier/metadata-function-prof.ll
+++ b/test/Verifier/metadata-function-prof.ll
@@ -1,11 +1,14 @@
; RUN: not llvm-as %s -disable-output 2>&1 | FileCheck %s
-define void @foo() !prof !0 {
+; CHECK: function declaration may not have a !prof attachment
+declare !prof !0 void @f1()
+
+define void @f2() !prof !0 {
unreachable
}
; CHECK: function must have a single !prof attachment
-define void @foo2() !prof !0 !prof !0 {
+define void @f3() !prof !0 !prof !0 {
unreachable
}