summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/lib/IR/Verifier.cpp7
-rw-r--r--llvm/test/Verifier/metadata-function-prof.ll12
2 files changed, 18 insertions, 1 deletions
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index 0395f5b36fe..29550e2e733 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/lib/IR/Verifier.cpp
@@ -1976,7 +1976,7 @@ void Verifier::visitFunction(const Function &F) {
"blockaddress may not be used with the entry block!", Entry);
}
- unsigned NumDebugAttachments = 0;
+ unsigned NumDebugAttachments = 0, NumProfAttachments = 0;
// Visit metadata attachments.
for (const auto &I : MDs) {
// Verify that the attachment is legal.
@@ -1990,6 +1990,11 @@ void Verifier::visitFunction(const Function &F) {
AssertDI(isa<DISubprogram>(I.second),
"function !dbg attachment must be a subprogram", &F, I.second);
break;
+ case LLVMContext::MD_prof:
+ ++NumProfAttachments;
+ Assert(NumProfAttachments == 1,
+ "function must have a single !prof attachment", &F, I.second);
+ break;
}
// Verify the metadata itself.
diff --git a/llvm/test/Verifier/metadata-function-prof.ll b/llvm/test/Verifier/metadata-function-prof.ll
new file mode 100644
index 00000000000..ca0628f44f8
--- /dev/null
+++ b/llvm/test/Verifier/metadata-function-prof.ll
@@ -0,0 +1,12 @@
+; RUN: not llvm-as %s -disable-output 2>&1 | FileCheck %s
+
+define void @foo() !prof !0 {
+ unreachable
+}
+
+; CHECK: function must have a single !prof attachment
+define void @foo2() !prof !0 !prof !0 {
+ unreachable
+}
+
+!0 = !{}
OpenPOWER on IntegriCloud