Skip to content

Implement TBAA-based load/store optimization in standalone Python IR#5

Draft
Copilot wants to merge 7 commits intomasterfrom
copilot/implement-advanced-alias-classes
Draft

Implement TBAA-based load/store optimization in standalone Python IR#5
Copilot wants to merge 7 commits intomasterfrom
copilot/implement-advanced-alias-classes

Conversation

Copy link

Copilot AI commented Feb 1, 2026

Extends the toy load/store optimizer from https://github.com/tekknolagi/tekknolagi.github.com/blob/main/loadstore.py with Type-Based Alias Analysis to distinguish memory operations on different Ruby object types.

Changes

Core TBAA implementation (loadstore.py)

  • 8 typed allocation operations: alloc_array(), alloc_hash(), alloc_string(), etc.
  • may_alias(obj1, obj2, offset1, offset2): returns false for different types, enabling cross-type optimization
  • optimize_load_store_tbaa(): eliminates loads invalidated only by same-type stores

Key insight: Stores to different object types cannot alias, even at the same offset. This allows load elimination across type boundaries that would otherwise require conservative invalidation.

Example optimization:

array = bb.alloc_array()
hash = bb.alloc_hash()
v1 = bb.load(array, 0)
bb.store(hash, 0, 42)    # Different type - doesn't invalidate array load
v2 = bb.load(array, 0)   # Eliminated, reuses v1

Without TBAA, the hash store would conservatively invalidate the array load.

Documentation

  • LOADSTORE_README.md: Technical details, aliasing rules, limitations
  • QUICKSTART.md: Getting started guide
  • demo_loadstore.py: 6 concrete optimization scenarios

Test coverage: 11 tests covering basic load/store elimination and TBAA-specific scenarios (same type conservative, different types aggressive, unknown types safe).

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • bernsteinbear.com
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

tekknolagi and others added 2 commits August 26, 2025 09:10
@tekknolagi
Copy link
Owner

Don't do this in HIR. Just make a small Ruby implementation of a sample IR like the blog post

Copilot AI and others added 5 commits February 1, 2026 20:09
Co-authored-by: tekknolagi <401167+tekknolagi@users.noreply.github.com>
Co-authored-by: tekknolagi <401167+tekknolagi@users.noreply.github.com>
Co-authored-by: tekknolagi <401167+tekknolagi@users.noreply.github.com>
Co-authored-by: tekknolagi <401167+tekknolagi@users.noreply.github.com>
Co-authored-by: tekknolagi <401167+tekknolagi@users.noreply.github.com>
Copilot AI changed the title [WIP] Add advanced alias classes with TBAA implementation Implement TBAA-based load/store optimization in standalone Python IR Feb 1, 2026
Copilot AI requested a review from tekknolagi February 1, 2026 20:18
tekknolagi pushed a commit that referenced this pull request Feb 3, 2026
* OpenSSL::PKCS12.create calling the PKCS12_create() has the argument mac_iter
  which uses a MAC key using PKCS12KDF which is not FIPS-approved.
* OpenSSL::PKCS12.new with base64-encoded example calling PKCS12_parse()
  verifies the MAC key using PKCS12KDF which is not FIPS-approved.
* PBE-SHA1-3DES uses PKCS12KDF which is not FIPS-approved according to the RFC
  7292 PKCS#12.
  https://datatracker.ietf.org/doc/html/rfc7292#appendix-C
  > The PBES1 encryption scheme defined in PKCS #5 provides a number of
  > algorithm identifiers for deriving keys and IVs; here, we specify a
  > few more, all of which use the procedure detailed in Appendices B.2
  > and B.3 to construct keys (and IVs, where needed).  As is implied by
  > their names, all of the object identifiers below use the hash
  > function SHA-1.
  > ...
  > pbeWithSHAAnd3-KeyTripleDES-CBC  OBJECT IDENTIFIER ::= {pkcs-12PbeIds 3}

  Note that the pbeWithSHAAnd3-KeyTripleDES-CBC (pkcs12-pbeids 3) in the RFC
  7292 PKCS#12 means PBE-SHA1-3DES in OpenSSL. PKCS12KDF is used in PKCS#12.
  https://oidref.com/1.2.840.113549.1.12.1.3
  https://github.com/openssl/openssl/blob/ed57d1e06dca28689190e00d9893e0fd7ecc67c1/crypto/objects/objects.txt#L385

ruby/openssl@2aa6d97a54
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