[PATCH] D65718: [LangRef] Document forward-progress requirement

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 7 08:17:50 PDT 2019


nikic updated this revision to Diff 213895.
nikic marked an inline comment as done.
nikic added a comment.

Clarify that any synthetic side-effect is sufficient. Add llvm.sideeffect to infinite loop in phi example.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65718/new/

https://reviews.llvm.org/D65718

Files:
  llvm/docs/LangRef.rst


Index: llvm/docs/LangRef.rst
===================================================================
--- llvm/docs/LangRef.rst
+++ llvm/docs/LangRef.rst
@@ -2489,6 +2489,20 @@
 ``fast``
    This flag implies all of the others.
 
+Forward-Progress Requirement
+----------------------------
+
+Every thread of execution is required to eventually cause a side-effect
+(including but not limited to accessing inaccessible memory, volatile or
+atomic memory access, or other forms of thread synchronization). Failure to
+cause a side-effect in a finite amount of time results in undefined behavior.
+
+In particular, infinite loops and infinite recursion without side-effects
+result in undefined behavior. Language frontends that do not have a
+forward-progress requirement should insert a synthetic side-effect as part of
+of every function definition and every loop. The `@llvm.sideeffect` intrinsic
+is provided for this purpose.
+
 .. _uselistorder:
 
 Use-list Order Directives
@@ -10063,6 +10077,7 @@
 
     Loop:       ; Infinite loop that counts from 0 on up...
       %indvar = phi i32 [ 0, %LoopHeader ], [ %nextindvar, %Loop ]
+      call void @llvm.sideeffect() ; Ensure forward progress
       %nextindvar = add i32 %indvar, 1
       br label %Loop
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65718.213895.patch
Type: text/x-patch
Size: 1256 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190807/467a54f2/attachment.bin>


More information about the llvm-commits mailing list