[Lldb-commits] [lldb] [lldb] Add a return opcode to the formatter bytecode (PR #121602)
Dave Lee via lldb-commits
lldb-commits at lists.llvm.org
Fri Jan 3 14:38:17 PST 2025
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
More information about the lldb-commits
mailing list