From fa7494306bc6fbe16cc82a67b93e762241b26777 Mon Sep 17 00:00:00 2001 From: Nuno Lopes Date: Mon, 18 Jun 2012 16:04:04 +0000 Subject: add the 'alloc' metadata node to represent the size of offset of buffers pointed to by pointers. This metadata can be attached to any instruction returning a pointer git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158660 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/Verifier/alloc-1.ll | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ test/Verifier/alloc-2.ll | 19 +++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 test/Verifier/alloc-1.ll create mode 100644 test/Verifier/alloc-2.ll (limited to 'test/Verifier') diff --git a/test/Verifier/alloc-1.ll b/test/Verifier/alloc-1.ll new file mode 100644 index 0000000..60917a0 --- /dev/null +++ b/test/Verifier/alloc-1.ll @@ -0,0 +1,48 @@ +; RUN: not llvm-as < %s -o /dev/null |& FileCheck %s + +declare i32 @size() readonly +declare i32 @sizeR() +declare i32 @size1(i32) readnone +declare i32 @size1i8(i8) readnone +declare i32* @sizeptr() readnone + +define void @f1(i8** %x, i32* %y) { +entry: + %0 = load i8** %x, !alloc !0 + %1 = load i8** %x, !alloc !1 + %2 = load i8** %x, !alloc !2 + %3 = load i8** %x, !alloc !3 + %4 = load i8** %x, !alloc !4 + %5 = load i8** %x, !alloc !5 + %6 = load i8** %x, !alloc !6 + %7 = load i8** %x, !alloc !7 + %8 = load i8** %x, !alloc !8 + %9 = load i32* %y, !alloc !9 + %10 = load i8** %x, !alloc !10 + %11 = load i8** %x, !alloc !11 + ret void +} +; CHECK: alloc takes at least one operand +!0 = metadata !{} +; CHECK: first parameter of alloc must be a function +!1 = metadata !{i32 0} +; CHECK: second parameter of alloc must be either a function or null +!2 = metadata !{i32 ()* @size, i32 0} +; CHECK: size function number of parameters mismatch +!3 = metadata !{i32 ()* @size, null, i32 0} +; CHECK: offset function number of parameters mismatch +!4 = metadata !{i32 (i32)* @size1, i32 ()* @size, i32 1} +; CHECK: size function must be readonly/readnone +!5 = metadata !{i32 ()* @sizeR, i32 ()* @size} +; CHECK: offset function must be readonly/readnone +!6 = metadata !{i32 ()* @size, i32 ()* @sizeR} +; CHECK: size function parameter type mismatch +!7 = metadata !{i32 (i32)* @size1, i32 (i8)* @size1i8, i8 5} +; CHECK: offset function parameter type mismatch +!8 = metadata !{i32 (i8)* @size1i8, i32 (i32)* @size1, i8 5} +; CHECK: alloc requires a pointer result +!9 = metadata !{i32 ()* @size, null} +; CHECK: size function must return an integer +!10 = metadata !{i32* ()* @sizeptr, null} +; CHECK: offset function must return an integer +!11 = metadata !{i32 ()* @size, i32* ()* @sizeptr} diff --git a/test/Verifier/alloc-2.ll b/test/Verifier/alloc-2.ll new file mode 100644 index 0000000..10496d1 --- /dev/null +++ b/test/Verifier/alloc-2.ll @@ -0,0 +1,19 @@ +; RUN: llvm-as < %s -o /dev/null + +declare i32 @size() readonly +declare i32 @size1(i32) readnone +declare i32 @size1i8(i8) readnone + +define void @ok(i8** %x, i32 %y) { +entry: + %0 = load i8** %x, !alloc !0 + %1 = load i8** %x, !alloc !1 + %2 = load i8** %x, !alloc !2 + %3 = load i8** %x, !alloc !3 + %4 = load i8** %x, !alloc !{i32 (i32)* @size1, i32 (i32)* @size1, i32 %y} + ret void +} +!0 = metadata !{i32 ()* @size, i32 ()* @size} +!1 = metadata !{i32 ()* @size, null} +!2 = metadata !{i32 (i32)* @size1, i32 (i32)* @size1, i32 0} +!3 = metadata !{i32 (i8)* @size1i8, i32 (i8)* @size1i8, i8 0} -- cgit v1.1