summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2015-08-14 05:09:07 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2015-08-14 05:09:07 +0000
commitb611e3f50e6c9fb564864e437ad8fd26809f0a19 (patch)
treec477eac6aca9a13eb68fb6f1f012b35736114e0c /llvm/test
parentfb1e7f7d1aca7bcfc341e9214bda8b554f5ae9b6 (diff)
downloadbcm5719-llvm-b611e3f50e6c9fb564864e437ad8fd26809f0a19.tar.gz
bcm5719-llvm-b611e3f50e6c9fb564864e437ad8fd26809f0a19.zip
[IR] Add token types
This introduces the basic functionality to support "token types". The motivation stems from the need to perform operations on a Value whose provenance cannot be obscured. There are several applications for such a type but my immediate motivation stems from WinEH. Our personality routine enforces a single-entry - single-exit regime for cleanups. After several rounds of optimizations, we may be left with a terminator whose "cleanup-entry block" is not entirely clear because control flow has merged two cleanups together. We have experimented with using labels as operands inside of instructions which are not terminators to indicate where we came from but found that LLVM does not expect such exotic uses of BasicBlocks. Instead, we can use this new type to clearly associate the "entry point" and "exit point" of our cleanup. This is done by having the cleanuppad yield a Token and consuming it at the cleanupret. The token type makes it impossible to obscure or otherwise hide the Value, making it trivial to track the relationship between the two points. What is the burden to the optimizer? Well, it turns out we have already paid down this cost by accepting that there are certain calls that we are not permitted to duplicate, optimizations have to watch out for such instructions anyway. There are additional places in the optimizer that we will probably have to update but early examination has given me the impression that this will not be heroic. Differential Revision: http://reviews.llvm.org/D11861 llvm-svn: 245029
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/Assembler/token.ll6
-rw-r--r--llvm/test/Bitcode/compatibility.ll3
-rw-r--r--llvm/test/Verifier/token1.ll11
-rw-r--r--llvm/test/Verifier/token2.ll11
-rw-r--r--llvm/test/Verifier/token3.ll8
-rw-r--r--llvm/test/Verifier/token4.ll4
-rw-r--r--llvm/test/Verifier/token5.ll7
-rw-r--r--llvm/test/Verifier/token6.ll7
-rw-r--r--llvm/test/Verifier/token7.ll8
9 files changed, 65 insertions, 0 deletions
diff --git a/llvm/test/Assembler/token.ll b/llvm/test/Assembler/token.ll
new file mode 100644
index 00000000000..22d71b0b730
--- /dev/null
+++ b/llvm/test/Assembler/token.ll
@@ -0,0 +1,6 @@
+; RUN: llvm-as < %s | llvm-dis | FileCheck %s
+; RUN: verify-uselistorder %s
+; Basic smoke test for token type.
+
+; CHECK: declare void @llvm.token.foobar(token)
+declare void @llvm.token.foobar(token)
diff --git a/llvm/test/Bitcode/compatibility.ll b/llvm/test/Bitcode/compatibility.ll
index 585d51b73d4..8763fd4cad1 100644
--- a/llvm/test/Bitcode/compatibility.ll
+++ b/llvm/test/Bitcode/compatibility.ll
@@ -1212,6 +1212,9 @@ define void @misc.metadata() {
ret void
}
+declare void @llvm.tokenfoo(token)
+; CHECK: declare void @llvm.tokenfoo(token)
+
; CHECK: attributes #0 = { alignstack=4 }
; CHECK: attributes #1 = { alignstack=8 }
; CHECK: attributes #2 = { alwaysinline }
diff --git a/llvm/test/Verifier/token1.ll b/llvm/test/Verifier/token1.ll
new file mode 100644
index 00000000000..ac7ff30948e
--- /dev/null
+++ b/llvm/test/Verifier/token1.ll
@@ -0,0 +1,11 @@
+; RUN: not llvm-as %s -o /dev/null 2>&1 | FileCheck %s
+
+define void @f(token %A, token %B) {
+entry:
+ br label %bb
+
+bb:
+ %phi = phi token [ %A, %bb ], [ %B, %entry]
+; CHECK: PHI nodes cannot have token type!
+ br label %bb
+}
diff --git a/llvm/test/Verifier/token2.ll b/llvm/test/Verifier/token2.ll
new file mode 100644
index 00000000000..b58079de770
--- /dev/null
+++ b/llvm/test/Verifier/token2.ll
@@ -0,0 +1,11 @@
+; RUN: not llvm-as %s -o /dev/null 2>&1 | FileCheck %s
+
+define void @f(token %A, token %B) {
+entry:
+ br label %bb
+
+bb:
+ %sel = select i1 undef, token %A, token %B
+; CHECK: select values cannot have token type
+ br label %bb
+}
diff --git a/llvm/test/Verifier/token3.ll b/llvm/test/Verifier/token3.ll
new file mode 100644
index 00000000000..2cce6b83e7f
--- /dev/null
+++ b/llvm/test/Verifier/token3.ll
@@ -0,0 +1,8 @@
+; RUN: not llvm-as %s -o /dev/null 2>&1 | FileCheck %s
+
+define void @f(token %A, token %B) {
+entry:
+ alloca token
+; CHECK: invalid type for alloca
+ ret void
+}
diff --git a/llvm/test/Verifier/token4.ll b/llvm/test/Verifier/token4.ll
new file mode 100644
index 00000000000..87a8b14efa0
--- /dev/null
+++ b/llvm/test/Verifier/token4.ll
@@ -0,0 +1,4 @@
+; RUN: not llvm-as %s -o /dev/null 2>&1 | FileCheck %s
+
+@GV = external global token
+; CHECK: invalid type for global variable
diff --git a/llvm/test/Verifier/token5.ll b/llvm/test/Verifier/token5.ll
new file mode 100644
index 00000000000..6fc1b045375
--- /dev/null
+++ b/llvm/test/Verifier/token5.ll
@@ -0,0 +1,7 @@
+; RUN: not llvm-as %s -o /dev/null 2>&1 | FileCheck %s
+
+define void @f(token %A) {
+entry:
+ ret void
+}
+; CHECK: Function takes token but isn't an intrinsic
diff --git a/llvm/test/Verifier/token6.ll b/llvm/test/Verifier/token6.ll
new file mode 100644
index 00000000000..9614b91db73
--- /dev/null
+++ b/llvm/test/Verifier/token6.ll
@@ -0,0 +1,7 @@
+; RUN: not llvm-as %s -o /dev/null 2>&1 | FileCheck %s
+
+define token @f() {
+entry:
+ ret token undef
+}
+; CHECK: Functions returns a token but isn't an intrinsic
diff --git a/llvm/test/Verifier/token7.ll b/llvm/test/Verifier/token7.ll
new file mode 100644
index 00000000000..939878cc427
--- /dev/null
+++ b/llvm/test/Verifier/token7.ll
@@ -0,0 +1,8 @@
+; RUN: not llvm-as %s -o /dev/null 2>&1 | FileCheck %s
+
+define void @f() {
+entry:
+ call token () undef ()
+ ret void
+}
+; CHECK: Return type cannot be token for indirect call!
OpenPOWER on IntegriCloud