Skip to content

Fix AOT superglobal isset and coalesce lowering (partial #99, #148)#448

Open
PurHur wants to merge 1 commit into
masterfrom
fix/aot-coalesce-and-superglobal-isset
Open

Fix AOT superglobal isset and coalesce lowering (partial #99, #148)#448
PurHur wants to merge 1 commit into
masterfrom
fix/aot-coalesce-and-superglobal-isset

Conversation

@PurHur
Copy link
Copy Markdown
Owner

@PurHur PurHur commented May 21, 2026

Summary

  • Fix superglobal isset() in LLVM/AOT to use runtime __hashtable__offsetIsSetStringKey instead of baking compile-time false when QUERY_STRING is only known at run time.
  • Fix ?? lowering when php-cfg emits Assign after Coalesce: write into the assignee slot, reuse the same $_GET slot for isset and fetch, and inherit scope after isset operands are compiled.
  • Fix coalesce branch wiring in JIT: merge branches jump from branch tail blocks (after fetch/assign), not entry blocks that skipped the fetch IR.

Test output (Docker php-compiler:22.04-dev, tar copy harness)

composer install && ./script/apply-patches.sh
export PATH=/opt/llvm9/bin:$PATH
vendor/bin/phpunit --group aot-link --exclude-group serve
Tests: 117, Assertions: 640, Failures: 1.

Before (master): 2 failures (coalesce_get_present, superglobal_get_assign munmap).

After: 1 failure remaining.

Remaining failure (needs follow-up)

vendor/bin/phpunit --group aot-link --filter coalesce_get_present
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'Ada'
+''

Repro:

vendor/bin/phpunit test/aot/AotTest.php --filter 'coalesce_get_present'
# or compile + run:
php bin/compile.php -q name=Ada -o /tmp/coal - <<'PHP'
<?php
$name = $_GET['name'] ?? 'Guest';
echo $name, "\n";
PHP
QUERY_STRING=name=Ada /tmp/coal   # prints blank line only

VM path works with the same sources (bin/vm.php prints Ada). Issue is LLVM merge/echo of the coalesce result, not the compiler CFG.

Test plan

  • vendor/bin/phpunit --group aot-link --exclude-group serve in Docker (116/117 pass)
  • coalesce_get_present AOT output Ada / Guest (tracked above)
  • Full ./script/ci-local.sh in Docker when merging

Made with Cursor

- Lower ?? into the assignee slot when php-cfg emits Assign immediately after Coalesce
- Reuse isset container/dim slots for the left-branch fetch (wrong $_GET slot)
- Resolve isset targets before branching so child blocks inherit scope
- Use runtime __hashtable__offsetIsSetStringKey for superglobal isset in JIT
- Branch coalesce merge from branch tail blocks, not entry blocks

AOT aot-link: 117 tests, 1 remaining failure (coalesce_get_present empty output).
VM coalesce with $_GET works; LLVM echo after merge still needs follow-up.

Co-authored-by: Cursor <cursoragent@cursor.com>
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.

1 participant