fix(optimizer): correct semantic classification of TRON instructions#118
Merged
CodeNinjaEvan merged 1 commit intoJun 24, 2026
Conversation
|
Thank you for your contribution to the Solidity compiler! A team member will follow up shortly. If you haven't read our contributing guidelines and our review checklist before, please do it now, this makes the reviewing process and accepting your contribution smoother. If you have any questions or need our help, feel free to post them in the PR or talk to us directly on the #solidity-dev channel on Matrix. |
NATIVEFREEZEEXPIRETIME read state but was treated as movable, letting the via-IR optimizer CSE its result across a freeze write and read stale data. Add it and ISCONTRACT to the proper SemanticInformation whitelists; guard NATIVEVOTE bounds and mark its memory reads as unknown-length.
edb6c79 to
8a3c264
Compare
CodeNinjaEvan
approved these changes
Jun 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
libevmasm/SemanticInformation.cppmis-classifies several TRON-specific instructions for the optimizer. The most serious is a Critical miscompilation on the via-IR pipeline.Fixes
NATIVEFREEZEEXPIRETIMEwas treated as movable (Critical). It reads an address's stake expire-time — state thatNATIVEFREEZE/NATIVEUNFREEZEmutate — but withsideEffects=falseand no entry in themovable()/movableApartFromEffects()whitelists it fell through to "movable". The Yul CSE/LICM then reuses a cachedfreezeExpireTimevalue across an intervening freeze write, reading stale data. Added it to both whitelists (alongsideTOKENBALANCE).ISCONTRACTwas missing frommovableApartFromEffects()andisDeterministic(). It is the same family asEXTCODESIZE/TOKENBALANCE; added so it is optimized correctly and not over-conservatively.NATIVEVOTEinreadWriteOperations(): the memory-read length was the array element count rather than a byte length, which could letUnusedStoreEliminatordrop the array writes. Changed to a conservative unknown-length read, and added aparamCount >= 4guard before thesize_tsubtractions.return true;after themovable()switch.Verification
solcbuilds cleanly.--experimental-via-ir --optimize,NATIVEFREEZEEXPIRETIME(0xd7) is now emitted twice across a freeze write (previously CSE collapsed it to one).voteand ordinary contracts still compile on both the legacy and via-IR pipelines.Targets
release_0.8.28.🤖 Generated with Claude Code