10000 bpo-42349: Clarify basicblocks and give some examples by sweeneyde · Pull Request #714 · python/devguide · GitHub
[go: up one dir, main page]

Skip to content

bpo-42349: Clarify basicblocks and give some examples #714

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 16, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Apply suggestions from code review
Co-authored-by: Mariatta Wijaya <Mariatta@users.noreply.github.com>
  • Loading branch information
sweeneyde and Mariatta authored Jul 15, 2021
commit 440c62e1e2bfad73ed61f0250d3c808160dd0e07
20 changes: 10 additions & 10 deletions compiler.rst
Original file line number Diff line number Diff line change
Expand Up @@ -310,19 +310,19 @@ As an example, consider the following code snippet:
g()
end()

The `x < 10` guard is represented by its own basic block that
compares `x` with `10` and then ends in a conditional jump based on
The ``x < 10`` guard is represented by its own basic block that
compares ``x`` with ``10`` and then ends in a conditional jump based on
the result of the comparison. This conditional jump allows the block
to point to both the body of the `if` and the body of the `else`. The
`if` basic block contains the `f1()` and `f2()` calls and points to
the `end()` basic block. The `else` basic block contains the `g()`
call and similarly points to the `end()` block.
to point to both the body of the ``if`` and the body of the ``else``. The
``if`` basic block contains the ``f1()`` and ``f2()`` calls and points to
the ``end()`` basic block. The ``else`` basic block contains the ``g()``
call and similarly points to the ``end()`` block.

Note that more complex code in the guard, the `if` body, or the `else`
Note that more complex code in the guard, the ``if`` body, or the ``else``
body may be represented by multiple basic blocks. For instance,
short-circuiting boolean logic in a guard like `if x or y:`
will produce one basic block that tests the truth value of `x`
and then points both (1) to the start of the `if` body and (2) to
short-circuiting boolean logic in a guard like ``if x or y:``
will produce one basic block that tests the truth value of ``x``
and then points both (1) to the start of the ``if`` body and (2) to
a different basic block that tests the truth value of y.

CFGs are usually one step away from final code output. Code is directly
Expand Down
0