Trust: reuse named LLVM decls instead of snprintf.1 (re-#32122) - #32347
Merged
Conversation
lookupFunction-miss then addFunction() silently renamed libc snprintf when the symbol already existed in the module, which is the Module.php:180 class from #31894/#32122. Route snprintf through LibcExtern::ensureSnprintf and register getNamedFunction hits for the remaining formatter/GC/parse_url leaves. Co-authored-by: Cursor <cursoragent@cursor.com>
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
lookupFunction()miss thenaddFunction('snprintf')silently createdsnprintf.1when the libc symbol already existed in the module (php-llvmModule.php:180).ZendDoubleStringRuntime,SprintfSnprintfRuntime,NumberFormatRuntime) and backed-enum now callLibcExtern::ensureSnprintf; GC /parse_urlleaves registergetNamedFunction()hits instead of skipping them.runtime/*.c. php-src:Zend/zend_operators.cfloat→string /ext/standard/formatted_print.c/ext/standard/math.cstill own the observable sprintf/number_format behavior.Refs #32122, #31894.
Test plan
./script/phpunit.sh --filter 'SnprintfRuntimeShrinkTest|LibcExternDeadDeclsRuntimeShrinkTest'→ OK (36 tests, 684 assertions)./script/docker-exec.sh -- bash -lc 'printf %s "<?php echo \"hi\\n\";" > /tmp/hello32122.php; php bin/compile.php -o /tmp/hello32122.bin /tmp/hello32122.php && /tmp/hello32122.bin'→hi./script/docker-exec.sh -- bash -lc 'printf %s "<?php echo 1.5, PHP_EOL;" > /tmp/echo15.php; php bin/compile.php -o /tmp/echo15.bin /tmp/echo15.php && /tmp/echo15.bin'→1.5./script/release-readiness.sh(implementer warm-up skip) or./script/aot-smoke.shthis turn.Made with Cursor