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