summaryrefslogtreecommitdiff
path: root/docs
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 /docs
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 'docs')
-rw-r--r--docs/LangRef.rst30
1 files changed, 30 insertions, 0 deletions
diff --git a/docs/LangRef.rst b/docs/LangRef.rst
index 8cbed7d87d1..b097230591f 100644
--- a/docs/LangRef.rst
+++ b/docs/LangRef.rst
@@ -14267,6 +14267,36 @@ not overflow at link time under the medium code model if ``x`` is an
a constant initializer folded into a function body. This intrinsic can be
used to avoid the possibility of overflows when loading from such a constant.
+'``llvm.sideeffect``' Intrinsic
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Syntax:
+"""""""
+
+::
+
+ declare void @llvm.sideeffect() inaccessiblememonly nounwind
+
+Overview:
+"""""""""
+
+The ``llvm.sideeffect`` intrinsic doesn't perform any operation. Optimizers
+treat it as having side effects, so it can be inserted into a loop to
+indicate that the loop shouldn't be assumed to terminate (which could
+potentially lead to the loop being optimized away entirely), even if it's
+an infinite loop with no other side effects.
+
+Arguments:
+""""""""""
+
+None.
+
+Semantics:
+""""""""""
+
+This intrinsic actually does nothing, but optimizers must assume that it
+has externally observable side effects.
+
Stack Map Intrinsics
--------------------