Skip to content

Conversation

luoliwoshang
Copy link
Contributor

@luoliwoshang luoliwoshang commented Aug 22, 2025

fixed #5008

Problem:
The original code used a break statement inside a switch within a for loop, which only exited the switch but continued processing subsequent MapUpdate operations. This led to AsmFull returning register values from map updates that happened after the function call, violating the expected behavior.

Solution:

  • Stops processing when encountering the AsmFull call itself

@luoliwoshang luoliwoshang force-pushed the fix-asmfull-mapupdate-bug branch from fa7af34 to 73a1250 Compare August 22, 2025 10:52
@luoliwoshang luoliwoshang changed the base branch from release to dev August 22, 2025 11:16
Copy link
Contributor

@eliasnaur eliasnaur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably for @aykevl

registers[key] = b.getValue(r.Value.(*ssa.MakeInterface).X, getPos(instr))
case *ssa.Call:
if r.Common() == instr {
break
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of extracting collectInlineAsmRegisters, why not name the outer loop and use break <name>? Something like:

referrers:
    for _, r := range *registerMap.Referrers() {
...
        if r.Common() == instr {
	        break referrers
        }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the great suggestion! You're absolutely right - using labeled break is cleaner and more idiomatic. I've updated the code accordingly. I initially went with function extraction due to personal preference, but your approach is definitely better with fewer code changes. Thanks for the review!

@luoliwoshang luoliwoshang force-pushed the fix-asmfull-mapupdate-bug branch 2 times, most recently from 6fd682d to 07aa451 Compare August 24, 2025 15:00
@eliasnaur
Copy link
Contributor

The test disappeared, was that on purpose? Also, please squash the two "goto" and "named break" commits into one.

Probably @aykevl for the meat of this change.

builder/createInlineAsm:with independant logic to avoid goto operate
@luoliwoshang luoliwoshang force-pushed the fix-asmfull-mapupdate-bug branch from 07aa451 to a996f85 Compare August 25, 2025 01:18
@luoliwoshang
Copy link
Contributor Author

The test disappeared, was that on purpose? Also, please squash the two "goto" and "named break" commits into one.

I have merged the two commits into one. I temporarily removed the added tests to confirm whether the test failure issue is only coming from the CI environment. I will add back the tests shortly.

@luoliwoshang luoliwoshang force-pushed the fix-asmfull-mapupdate-bug branch from 702167d to 2986a7a Compare August 25, 2025 02:15
@luoliwoshang
Copy link
Contributor Author

luoliwoshang commented Aug 26, 2025

Hey @aykevl! 👋 I found a little bug in TinyGo and managed to fix it - would love to get your eyes on the PR when you have a moment!
Thanks for building such an awesome project! TinyGo makes embedded Go so much fun, and I'd love to be part of the contributor community

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.

Bug Report: AsmFull incorrectly processes MapUpdate operations after the call
2 participants