Help understanding SlitherIR SSA form in loops with if/else branches #2763
Unanswered
almirmcunhajr
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone,
I'm trying to understand how Slither builds its SSA form in the presence of loops with internal branching. I have two simple examples and I would appreciate clarification on how the IR is constructed.
First example (simple while loop)
Command:
Output:
This makes sense to me: there's a phi node
x_2that merges the initial valuex_1and the updated onex_3, and it is used in the condition and body.Second example (loop with if/else)
Command:
Output:
In this second case, I'm trying to understand how the loop semantics are handled. Specifically:
x_4merges the two branches, but it doesn't appear to be used afterward.x > 0and the arithmetic expressions usex_1instead of a value from a phi node representing the updated value across iterations, like in the first example.In my understanding, this structure seems a bit confusing since the loop condition and arithmetic expressions continue to use the initial value x_1, it looks like the updated value (x_4) from the if/else branch isn't actually used in subsequent iterations.
Thanks in advance for any help understanding this case!
Beta Was this translation helpful? Give feedback.
All reactions