kastiglione wrote:

Nested conditionals is where this will be helpful:

Consider this python:

```python
if first == 1:
    if second == 2:
        return "thing"
return "other"
```

without a `return` op, the above code would have to be transformed to:

```python
if first == 1:
    if second == 2:
        result = "thing"
if not (first == 1 and second == 2):
    result = "other"
```

 the bytecode for this this would look something like:

```
pick … # get `first` from the stack
dup 1 ==
{
    pick … # get `second` from the stack
    dup 2 ==
    {
        "thing"
    } if
} if
& ~ # not (first == 1 and second == 2)
{
    "other"
} if
```

with a `return` op, it simplifies to:

```
pick … # get `first` from the stack
1 ==
{
    pick … # get `second` from the stack
    2 ==
    {
        "thing"
        return
    } if
} if
"other"
```

https://github.com/llvm/llvm-project/pull/121602
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to