about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src
diff options
context:
space:
mode:
authorAndreas Molzer <andreas.molzer@gmx.de>2019-05-23 01:00:43 +0200
committerAndreas Molzer <andreas.molzer@gmx.de>2020-11-05 19:24:49 +0100
commita41e2fd963915c940a46a67825ec053afb004f87 (patch)
treec345d0877d6f17c529086a907800188f5bfb8e36 /compiler/rustc_codegen_llvm/src
parent4fdf8a5630a621c44a0928a1e30d881b0e00022b (diff)
downloadrust-a41e2fd963915c940a46a67825ec053afb004f87.tar.gz
rust-a41e2fd963915c940a46a67825ec053afb004f87.zip
Convert the recursive find_state to a loop
The basic conversion is a straightforward conversion of the linear
recursion to a loop forwards and backwards propagation of the result.
But this uses an optimization to avoid the need for extra space that
would otherwise be necessary to store the stack of unfinished states as
the function is not tail recursive.

Observe that only non-root-nodes in cycles have a recursive call and
that every such call overwrites their own node state. Thus we reuse the
node state itself as temporary storage for the stack of unfinished
states by inverting the links to a chain back to the previous state
update. When we hit the root or end of the full explored chain we
propagate the node state update backwards by following the chain until
a node with a link to itself.
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
0 files changed, 0 insertions, 0 deletions