Skip to content

fix[docs]: fix venom examples#4475

Merged
charles-cooper merged 9 commits intovyperlang:masterfrom
2xic:patch-1
Mar 13, 2025
Merged

fix[docs]: fix venom examples#4475
charles-cooper merged 9 commits intovyperlang:masterfrom
2xic:patch-1

Conversation

@2xic
Copy link
Copy Markdown
Contributor

@2xic 2xic commented Feb 13, 2025

What I did

I was playing around with the venom IR parser and ran into issues when using some of the instructions per the README. The current docs has swapped the usage of labels and the vars a few places.

How I did it

I got a error message which hinted at the issue

  File "/Users/brage/Downloads/vyper/vyper/venom/analysis/liveness.py", line 90, in input_vars_from
    for label, var in inst.phi_operands:
  File "/Users/brage/Downloads/vyper/vyper/venom/basicblock.py", line 374, in phi_operands
    assert isinstance(label, IRLabel), "phi operand must be a label"
AssertionError: phi operand must be a label

Then I ran the following on a Vyper file which would use the phi function to find a reference

 vyper --experimental-codegen -f bb_runtime 

It gave out

%ret_size:3 = phi @8_then, %ret_size:5, @9_else, %ret_size:4

How to verify it

Per the docs, this should compile, but it doesn't

function global {
  global:
    jnz 1, @1_then, @2_then
  1_then:
    %1 = 1
    jmp @3_phi
  2_then:
    %2 = 2
    jmp @3_phi
  3_phi:
    %3 = phi %1, @1_then, %2, @2_then
    return 0,%3
}

With my suggested fix it does compile

function global {
  global:
    jnz 1, @1_then, @2_then
  1_then:
    %1 = 1
    jmp @3_phi
  2_then:
    %2 = 2
    jmp @3_phi
  3_phi:
    %3 = phi %1, @1_then, %2, @2_then
    return 0,%3
}

Using python3 -m vyper.cli.venom_main [file] to verify. Same is true for jnz and the example code.

Commit message

Fix operands order and clarify opcodes in README for Venom IR

The README incorrectly swapped the arguments for the some of the
opcodes example. This change fixes that and clarifies some of the
opcode usages.

Description for the changelog

Cute Animal Picture

Put a link to a cute animal picture inside the parenthesis-->

@2xic 2xic marked this pull request as draft February 13, 2025 22:21
@2xic 2xic changed the title [docs]: Fix incorrect phi instruction usage example [docs]: Fix incorrect venom instruction usage example Feb 13, 2025
@charles-cooper charles-cooper marked this pull request as ready for review February 16, 2025 20:08
@charles-cooper
Copy link
Copy Markdown
Member

@2xic is this ready for review?

@codecov
Copy link
Copy Markdown

codecov bot commented Feb 16, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.15%. Comparing base (41108f9) to head (bdf121c).
Report is 85 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4475   +/-   ##
=======================================
  Coverage   92.15%   92.15%           
=======================================
  Files         123      123           
  Lines       17469    17469           
  Branches     2957     2957           
=======================================
  Hits        16099    16099           
  Misses        958      958           
  Partials      412      412           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@charles-cooper charles-cooper changed the title [docs]: Fix incorrect venom instruction usage example fix[docs]: fix venom examples Feb 18, 2025
@2xic
Copy link
Copy Markdown
Contributor Author

2xic commented Mar 5, 2025

@2xic is this ready for review?

Sorry, missed your comment. I'm hoping to update this PR sometime this week or next week and make it ready for review. Still some places in the readme that has to be updated, but playing around with some other parts of the IR now and want to make sure that is also correctly documented.

@2xic
Copy link
Copy Markdown
Contributor Author

2xic commented Mar 13, 2025

@2xic is this ready for review?

Sorry it took so long, it should be ready for review now @charles-cooper

@charles-cooper charles-cooper enabled auto-merge (squash) March 13, 2025 22:04
@charles-cooper charles-cooper merged commit 8e277fd into vyperlang:master Mar 13, 2025
159 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants