summaryrefslogtreecommitdiff
path: root/test/CodeGen/Generic
diff options
context:
space:
mode:
authorDan Gohman <dan433584@gmail.com>2017-11-08 21:59:51 +0000
committerDan Gohman <dan433584@gmail.com>2017-11-08 21:59:51 +0000
commitb5e0bec282c01ed9e075a9587e1c4274c3d939fe (patch)
treeea1a52ffb4a64ddb467bd7304eb55ce642690c78 /test/CodeGen/Generic
parentbfc1e953bcc9264c0873a0a8546d487b407e3c76 (diff)
Add an @llvm.sideeffect intrinsic
This patch implements Chandler's idea [0] for supporting languages that require support for infinite loops with side effects, such as Rust, providing part of a solution to bug 965 [1]. Specifically, it adds an `llvm.sideeffect()` intrinsic, which has no actual effect, but which appears to optimization passes to have obscure side effects, such that they don't optimize away loops containing it. It also teaches several optimization passes to ignore this intrinsic, so that it doesn't significantly impact optimization in most cases. As discussed on llvm-dev [2], this patch is the first of two major parts. The second part, to change LLVM's semantics to have defined behavior on infinite loops by default, with a function attribute for opting into potential-undefined-behavior, will be implemented and posted for review in a separate patch. [0] http://lists.llvm.org/pipermail/llvm-dev/2015-July/088103.html [1] https://bugs.llvm.org/show_bug.cgi?id=965 [2] http://lists.llvm.org/pipermail/llvm-dev/2017-October/118632.html Differential Revision: https://reviews.llvm.org/D38336 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317729 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGen/Generic')
-rw-r--r--test/CodeGen/Generic/intrinsics.ll9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/CodeGen/Generic/intrinsics.ll b/test/CodeGen/Generic/intrinsics.ll
index 4d04786a58d..6a51d2d371b 100644
--- a/test/CodeGen/Generic/intrinsics.ll
+++ b/test/CodeGen/Generic/intrinsics.ll
@@ -45,3 +45,12 @@ define i8* @barrier(i8* %p) {
%q = call i8* @llvm.invariant.group.barrier(i8* %p)
ret i8* %q
}
+
+; sideeffect
+
+declare void @llvm.sideeffect()
+
+define void @test_sideeffect() {
+ call void @llvm.sideeffect()
+ ret void
+}