diff options
author | Bill Wendling <isanbard@gmail.com> | 2012-02-11 11:38:06 +0000 |
---|---|---|
committer | Bill Wendling <isanbard@gmail.com> | 2012-02-11 11:38:06 +0000 |
commit | d34cb1e09f5e4b3feb7305346655b83ad2f67773 (patch) | |
tree | 3c9b16358ee97a16da10b8eb0ed4e75420ed6b72 /test/Linker | |
parent | a819c397e71adf0fede275ad4abde1947bb21086 (diff) | |
download | external_llvm-d34cb1e09f5e4b3feb7305346655b83ad2f67773.zip external_llvm-d34cb1e09f5e4b3feb7305346655b83ad2f67773.tar.gz external_llvm-d34cb1e09f5e4b3feb7305346655b83ad2f67773.tar.bz2 |
[WIP] Initial code for module flags.
Module flags are key-value pairs associated with the module. They include a
'behavior' value, indicating how module flags react when mergine two
files. Normally, it's just the union of the two module flags. But if two module
flags have the same key, then the resulting flags are dictated by the behaviors.
Allowable behaviors are:
Error
Emits an error if two values disagree.
Warning
Emits a warning if two values disagree.
Require
Emits an error when the specified value is not present
or doesn't have the specified value. It is an error for
two (or more) llvm.module.flags with the same ID to have
the Require behavior but different values. There may be
multiple Require flags per ID.
Override
Uses the specified value if the two values disagree. It
is an error for two (or more) llvm.module.flags with the
same ID to have the Override behavior but different
values.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150300 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Linker')
-rw-r--r-- | test/Linker/module-flags-1-a.ll | 16 | ||||
-rw-r--r-- | test/Linker/module-flags-1-b.ll | 8 | ||||
-rw-r--r-- | test/Linker/module-flags-2-a.ll | 10 | ||||
-rw-r--r-- | test/Linker/module-flags-2-b.ll | 6 | ||||
-rw-r--r-- | test/Linker/module-flags-3-a.ll | 14 | ||||
-rw-r--r-- | test/Linker/module-flags-3-b.ll | 8 | ||||
-rw-r--r-- | test/Linker/module-flags-4-a.ll | 10 | ||||
-rw-r--r-- | test/Linker/module-flags-4-b.ll | 8 | ||||
-rw-r--r-- | test/Linker/module-flags-5-a.ll | 9 | ||||
-rw-r--r-- | test/Linker/module-flags-5-b.ll | 6 | ||||
-rw-r--r-- | test/Linker/module-flags-6-a.ll | 9 | ||||
-rw-r--r-- | test/Linker/module-flags-6-b.ll | 6 |
12 files changed, 110 insertions, 0 deletions
diff --git a/test/Linker/module-flags-1-a.ll b/test/Linker/module-flags-1-a.ll new file mode 100644 index 0000000..973aa80 --- /dev/null +++ b/test/Linker/module-flags-1-a.ll @@ -0,0 +1,16 @@ +; RUN: llvm-link %s %p/module-flags-1-b.ll -S -o - | sort | FileCheck %s + +; Test basic functionality of module flags. + +; CHECK: !0 = metadata !{i32 1, metadata !"foo", i32 37} +; CHECK: !1 = metadata !{i32 1, metadata !"qux", i32 42} +; CHECK: !2 = metadata !{i32 1, metadata !"mux", metadata !3} +; CHECK: !3 = metadata !{metadata !"hello world", i32 927} +; CHECK: !4 = metadata !{i32 2, metadata !"bar", i32 42} +; CHECK: !llvm.module.flags = !{!0, !1, !2, !4} + +!0 = metadata !{ i32 1, metadata !"foo", i32 37 } +!1 = metadata !{ i32 2, metadata !"bar", i32 42 } +!2 = metadata !{ i32 1, metadata !"mux", metadata !{ metadata !"hello world", i32 927 } } + +!llvm.module.flags = !{ !0, !1, !2 } diff --git a/test/Linker/module-flags-1-b.ll b/test/Linker/module-flags-1-b.ll new file mode 100644 index 0000000..bf3f5e5 --- /dev/null +++ b/test/Linker/module-flags-1-b.ll @@ -0,0 +1,8 @@ +; This file is used with module-flags-1-a.ll +; RUN: true + +!0 = metadata !{ i32 1, metadata !"foo", i32 37 } +!1 = metadata !{ i32 1, metadata !"qux", i32 42 } +!2 = metadata !{ i32 1, metadata !"mux", metadata !{ metadata !"hello world", i32 927 } } + +!llvm.module.flags = !{ !0, !1, !2 } diff --git a/test/Linker/module-flags-2-a.ll b/test/Linker/module-flags-2-a.ll new file mode 100644 index 0000000..3ae0288 --- /dev/null +++ b/test/Linker/module-flags-2-a.ll @@ -0,0 +1,10 @@ +; RUN: llvm-link %s %p/module-flags-2-b.ll -S -o - | sort | FileCheck %s + +; Test the 'override' behavior. + +; CHECK: !0 = metadata !{i32 4, metadata !"foo", i32 37} +; CHECK: !llvm.module.flags = !{!0} + +!0 = metadata !{ i32 1, metadata !"foo", i32 927 } + +!llvm.module.flags = !{ !0 } diff --git a/test/Linker/module-flags-2-b.ll b/test/Linker/module-flags-2-b.ll new file mode 100644 index 0000000..ab55e4b --- /dev/null +++ b/test/Linker/module-flags-2-b.ll @@ -0,0 +1,6 @@ +; This file is used with module-flags-2-a.ll +; RUN: true + +!0 = metadata !{ i32 4, metadata !"foo", i32 37 } ; Override the "foo" value. + +!llvm.module.flags = !{ !0 } diff --git a/test/Linker/module-flags-3-a.ll b/test/Linker/module-flags-3-a.ll new file mode 100644 index 0000000..4233a0a --- /dev/null +++ b/test/Linker/module-flags-3-a.ll @@ -0,0 +1,14 @@ +; RUN: llvm-link %s %p/module-flags-3-b.ll -S -o - | sort | FileCheck %s + +; Test 'require' behavior. + +; CHECK: !0 = metadata !{i32 1, metadata !"foo", i32 37} +; CHECK: !1 = metadata !{i32 3, metadata !"foo", metadata !2} +; CHECK: !2 = metadata !{metadata !"bar", i32 42} +; CHECK: !3 = metadata !{i32 1, metadata !"bar", i32 42} +; CHECK: !llvm.module.flags = !{!0, !1, !3} + +!0 = metadata !{ i32 1, metadata !"foo", i32 37 } +!1 = metadata !{ i32 1, metadata !"bar", i32 42 } + +!llvm.module.flags = !{ !0, !1 } diff --git a/test/Linker/module-flags-3-b.ll b/test/Linker/module-flags-3-b.ll new file mode 100644 index 0000000..76be802 --- /dev/null +++ b/test/Linker/module-flags-3-b.ll @@ -0,0 +1,8 @@ +; This file is used with module-flags-3-a.ll +; RUN: true + +!0 = metadata !{ i32 3, metadata !"foo", + metadata !{ metadata !"bar", i32 42 } +} + +!llvm.module.flags = !{ !0 } diff --git a/test/Linker/module-flags-4-a.ll b/test/Linker/module-flags-4-a.ll new file mode 100644 index 0000000..0199ef4 --- /dev/null +++ b/test/Linker/module-flags-4-a.ll @@ -0,0 +1,10 @@ +; RUN: not llvm-link %s %p/module-flags-4-b.ll -S -o - |& FileCheck %s + +; Test 'require' error. + +; CHECK: Linking module flags 'bar': does not have the required value + +!0 = metadata !{ i32 1, metadata !"foo", i32 37 } +!1 = metadata !{ i32 1, metadata !"bar", i32 927 } + +!llvm.module.flags = !{ !0, !1 } diff --git a/test/Linker/module-flags-4-b.ll b/test/Linker/module-flags-4-b.ll new file mode 100644 index 0000000..3a460bb --- /dev/null +++ b/test/Linker/module-flags-4-b.ll @@ -0,0 +1,8 @@ +; This file is used with module-flags-4-a.ll +; RUN: true + +!0 = metadata !{ i32 3, metadata !"foo", + metadata !{ metadata !"bar", i32 42 } +} + +!llvm.module.flags = !{ !0 } diff --git a/test/Linker/module-flags-5-a.ll b/test/Linker/module-flags-5-a.ll new file mode 100644 index 0000000..21b20a3 --- /dev/null +++ b/test/Linker/module-flags-5-a.ll @@ -0,0 +1,9 @@ +; RUN: not llvm-link %s %p/module-flags-5-b.ll -S -o - |& FileCheck %s + +; Test the 'override' error. + +; CHECK: Linking module flags 'foo': IDs have conflicting override values + +!0 = metadata !{ i32 4, metadata !"foo", i32 927 } + +!llvm.module.flags = !{ !0 } diff --git a/test/Linker/module-flags-5-b.ll b/test/Linker/module-flags-5-b.ll new file mode 100644 index 0000000..1e99b20 --- /dev/null +++ b/test/Linker/module-flags-5-b.ll @@ -0,0 +1,6 @@ +; This file is used with module-flags-5-a.ll +; RUN: true + +!0 = metadata !{ i32 4, metadata !"foo", i32 37 } ; Override the "foo" value. + +!llvm.module.flags = !{ !0 } diff --git a/test/Linker/module-flags-6-a.ll b/test/Linker/module-flags-6-a.ll new file mode 100644 index 0000000..aeade47 --- /dev/null +++ b/test/Linker/module-flags-6-a.ll @@ -0,0 +1,9 @@ +; RUN: not llvm-link %s %p/module-flags-6-b.ll -S -o - |& FileCheck %s + +; Test module flags error messages. + +; CHECK: Linking module flags 'foo': IDs have conflicting values + +!0 = metadata !{ i32 1, metadata !"foo", i32 37 } + +!llvm.module.flags = !{ !0 } diff --git a/test/Linker/module-flags-6-b.ll b/test/Linker/module-flags-6-b.ll new file mode 100644 index 0000000..2bc5a96 --- /dev/null +++ b/test/Linker/module-flags-6-b.ll @@ -0,0 +1,6 @@ +; This file is used with module-flags-6-a.ll +; RUN: true + +!0 = metadata !{ i32 1, metadata !"foo", i32 38 } + +!llvm.module.flags = !{ !0 } |