Sync llvm 21#60
Merged
bjjwwang merged 2 commits intoSVF-tools:mainfrom Apr 30, 2026
Merged
Conversation
Upstream commits 899d00a (Port SVF to LLVM 21) and 0aa951d (Semi-Sparse
infrastructure) together broke Assignment-3:
1. AbstractState::getByteOffset(GepStmt*) was deleted (moved to
AbstractStateManager::getGepByteOffset).
2. AbsExtAPI's constructor changed from
AbsExtAPI(Map<const ICFGNode*, AbstractState>&)
to
AbsExtAPI(AbstractStateManager*).
3. The same set of methods was deleted on the Python pysvf binding.
CI / packaging:
- Dockerfile + build.yml: bump llvm_version 18.1.0 -> 21.1.0 to match the
npm svf-lib package after SVF-npm sync-llvm-21 republishes.
Assignment-3 C++:
- Assignment_3_Helper.h: add AbstractExecutionHelper::getByteOffset
(header-only). Body is a faithful port of the upstream
AbstractStateManager::getGepByteOffset, reading non-constant indices
from `as[idxVar.getId()]` instead of going through a stateMgr -- works
because Assignment-3 keeps a dense per-node trace.
- Assignment_3.h / _Helper.cpp: own a lazily-constructed
AbstractStateManager* svfStateMgr so AbsExtAPI(svfStateMgr) compiles.
Around the single utils->handleExtAPI(callNode) site, sync postAbsTrace
into the mgr and copy any updates back, since AbsExtAPI now reads
abstract values exclusively through the mgr.
- Migrate the 3 stale call sites:
as.getByteOffset(gep) -> bufOverflowHelper.getByteOffset(as, gep)
Assignment-3 Python (mirrors C++ shape):
- Assignment_3_Helper.py: add 4 helpers on AbstractExecutionHelper that
port the upstream behavior: getByteOffset, getGepObjAddrs,
getPointeeElement, getAllocaInstByteSize. Three of them need svfir
(already a member of the helper); getByteOffset uses
pysvf.Options.max_field_limit() and gep.getStructFieldOffset(...) which
SVF-Python sync-llvm-21 newly exposes.
- Migrate 9 stale call sites:
abstract_state.<method>(...) -> self.buf_overflow_helper.<method>(abstract_state, ...)
(or self.<method>(...) when the caller is already inside the helper).
Symmetric with the C++ bufOverflowHelper.<method>(as, ...) pattern.
Locally: SVF builds clean against brew llvm@21 (21.1.4) on darwin/arm64;
SSA builds 100% (bin/ass3 produced); pysvf imports + Assignment-3 helpers
import + Options.max_field_limit() and AbstractStateManager are visible.
test-ae.{cpp,py} need a real .bc fixture to run end-to-end and have not
been exercised yet.
Depends on (publish in this order):
1. SVF-npm sync-llvm-21 (republish svf-lib)
2. SVF-Python sync-llvm-21 (republish pysvf to TestPyPI)
3. this branch
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The previous sync (deb5cb1) wired stateMgr into AbstractExecution but only as a placeholder for AbsExtAPI. Reads/writes still went through a separate postAbsTrace map and the GEP/load/size helpers were ported by hand. That defeated the point: the C++ side held a stateMgr it never actually called, and the Python side never even built one. This commit makes both languages use the stateMgr as the authoritative post-trace store and routes the GEP helpers through its API. C++ Assignment-3: - Drop the standalone Map<const ICFGNode*, AbstractState> postAbsTrace. Replace with `Map<...>& postAbsTrace() { return svfStateMgr->getTrace(); }` so existing call sites still read like `postAbsTrace()[node]`. - getAbsStateFromTrace returns `(*svfStateMgr)[node]`. - All call sites of `as.getByteOffset(gep)` (now removed upstream) and the intermediate `bufOverflowHelper.getByteOffset(as, gep)` shim go directly to `svfStateMgr->getGepByteOffset(gep)`. - Drop the in-out trace sync that used to wrap `utils->handleExtAPI(...)`. AbsExtAPI now reads and writes through the same stateMgr that backs the post trace, so there is nothing to sync. - Drop the 60-line `AbstractExecutionHelper::getByteOffset` re-implementation; it has no remaining caller. Python Assignment-3: - Construct `self.ander = pysvf.AndersenWaveDiff(svfir)` and `self.svf_state_mgr = pysvf.AbstractStateManager(svfir, self.ander)` in `AbstractExecution.__init__`. - Alias `self.post_abs_trace = self.svf_state_mgr` so every existing `self.post_abs_trace[node]`, `node in self.post_abs_trace`, and `self.post_abs_trace[node] = state` call site continues to work -- pysvf.AbstractStateManager's new __getitem__/__setitem__/__contains__ bindings carry the dict protocol. - Pass the stateMgr into AbstractExecutionHelper.__init__. - AbstractExecutionHelper.getByteOffset/getGepObjAddrs/getAllocaInstByteSize shrink to one-liners that delegate to the stateMgr's upstream impl, matching the C++ shape `svfStateMgr->getGepByteOffset(gep)`. getPointeeElement keeps a local impl because the upstream signature takes (ObjVar, ICFGNode) while the existing call sites only have a NodeID for what is typically a ValVar pointer -- not 1:1 convertible. Net asymmetry left: 1 local helper on the Python side (getPointeeElement); everything else now flows through stateMgr on both languages. Locally: bin/ass3 builds at 100%; Python imports clean; helper methods visibly delegate to self.svf_state_mgr. Depends on bjjwwang/SVF-Python sync-llvm-21 head bb03d79 for the new __setitem__/__contains__ on AbstractStateManager. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.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.
No description provided.