diff options
Diffstat (limited to 'llvm/test')
-rw-r--r-- | llvm/test/Instrumentation/cgprofile.ll | 28 | ||||
-rw-r--r-- | llvm/test/MC/ELF/cgprofile.ll | 50 | ||||
-rw-r--r-- | llvm/test/Verifier/module-flags-cgprofile.ll | 30 |
3 files changed, 108 insertions, 0 deletions
diff --git a/llvm/test/Instrumentation/cgprofile.ll b/llvm/test/Instrumentation/cgprofile.ll new file mode 100644 index 00000000000..f515a511f84 --- /dev/null +++ b/llvm/test/Instrumentation/cgprofile.ll @@ -0,0 +1,28 @@ +; RUN: opt < %s -cg-profile -S | FileCheck %s + +declare void @b() + +define void @a() !prof !1 { + call void @b() + ret void +} + +define void @freq(i1 %cond) !prof !1 { + br i1 %cond, label %A, label %B, !prof !2 +A: + call void @a(); + ret void +B: + call void @b(); + ret void +} + +!1 = !{!"function_entry_count", i64 32} +!2 = !{!"branch_weights", i32 5, i32 10} + +; CHECK: !llvm.module.flags = !{![[cgprof:[0-9]+]]} +; CHECK: ![[cgprof]] = !{i32 5, !"CG Profile", ![[prof:[0-9]+]]} +; CHECK: ![[prof]] = !{![[e0:[0-9]+]], ![[e1:[0-9]+]], ![[e2:[0-9]+]]} +; CHECK: ![[e0]] = !{void ()* @a, void ()* @b, i64 32} +; CHECK: ![[e1]] = !{void (i1)* @freq, void ()* @a, i64 11} +; CHECK: ![[e2]] = !{void (i1)* @freq, void ()* @b, i64 20} diff --git a/llvm/test/MC/ELF/cgprofile.ll b/llvm/test/MC/ELF/cgprofile.ll new file mode 100644 index 00000000000..27b43f1172c --- /dev/null +++ b/llvm/test/MC/ELF/cgprofile.ll @@ -0,0 +1,50 @@ +; RUN: llc -filetype=asm %s -o - -mtriple x86_64-pc-linux-gnu | FileCheck %s +; RUN: llc -filetype=obj %s -o %t -mtriple x86_64-pc-linux-gnu +; RUN: llvm-readobj -elf-cg-profile %t | FileCheck %s --check-prefix=OBJ + +declare void @b() + +define void @a() { + call void @b() + ret void +} + +define void @freq(i1 %cond) { + br i1 %cond, label %A, label %B +A: + call void @a(); + ret void +B: + call void @b(); + ret void +} + +!llvm.module.flags = !{!0} + +!0 = !{i32 5, !"CG Profile", !1} +!1 = !{!2, !3, !4} +!2 = !{void ()* @a, void ()* @b, i64 32} +!3 = !{void (i1)* @freq, void ()* @a, i64 11} +!4 = !{void (i1)* @freq, void ()* @b, i64 20} + +; CHECK: .cg_profile a, b, 32 +; CHECK: .cg_profile freq, a, 11 +; CHECK: .cg_profile freq, b, 20 + +; OBJ: CGProfile [ +; OBJ: CGProfileEntry { +; OBJ: From: a +; OBJ: To: b +; OBJ: Weight: 32 +; OBJ: } +; OBJ: CGProfileEntry { +; OBJ: From: freq +; OBJ: To: a +; OBJ: Weight: 11 +; OBJ: } +; OBJ: CGProfileEntry { +; OBJ: From: freq +; OBJ: To: b +; OBJ: Weight: 20 +; OBJ: } +; OBJ:] diff --git a/llvm/test/Verifier/module-flags-cgprofile.ll b/llvm/test/Verifier/module-flags-cgprofile.ll new file mode 100644 index 00000000000..307c4f28705 --- /dev/null +++ b/llvm/test/Verifier/module-flags-cgprofile.ll @@ -0,0 +1,30 @@ +; RUN: not llvm-as < %s -o /dev/null 2>&1 | FileCheck %s + +declare void @b() +declare void @a() + +!llvm.module.flags = !{!0} + +!0 = !{i32 5, !"CG Profile", !1} +!1 = !{!2, !"", !3, !4, !5, !6, !7, !8} +!2 = !{void ()* @a, void ()* @b, i64 32} +!3 = !{void ()* @a, void ()* @b} +!4 = !{void ()* @a, void ()* @b, i64 32, i64 32} +!5 = !{!"a", void ()* @b, i64 32} +!6 = !{void ()* @a, !"b", i64 32} +!7 = !{void ()* @a, void ()* @b, !""} +!8 = !{void ()* @a, void ()* @b, null} + +; CHECK: expected a MDNode triple +; CHECK: !"" +; CHECK: expected a MDNode triple +; CHECK: !3 = !{void ()* @a, void ()* @b} +; CHECK: expected a MDNode triple +; CHECK: !4 = !{void ()* @a, void ()* @b, i64 32, i64 32} +; CHECK: expected a Function +; CHECK: !"a" +; CHECK: expected a Function +; CHECK: !"b" +; CHECK: expected an integer constant +; CHECK: !"" +; CHECK: expected an integer constant |