Bound external memory field expansion - #1883
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1883 +/- ##
=======================================
Coverage 67.89% 67.89%
=======================================
Files 261 261
Lines 26677 26682 +5
Branches 5110 5109 -1
=======================================
+ Hits 18112 18117 +5
Misses 8565 8565
🚀 New features to boost your workflow:
|
| /// Maximum number of flattened fields expanded for one external memory | ||
| /// operation (e.g. memcpy/memset) before it is summarized. 0 (the default) | ||
| /// keeps the unlimited field-by-field expansion. | ||
| static const Option<u32_t> ExtMemFieldLimit; |
There was a problem hiding this comment.
Why do we need another option but not reusing Options::MaxFieldLimit()?
There was a problem hiding this comment.
Why do we need another option but not reusing Options::MaxFieldLimit()?
Reuse it
c018f8f to
953ba92
Compare
| return objType; | ||
| } | ||
|
|
||
| void SVFIRBuilder::addExtMemCopySummary(Value* D, Value* S) |
There was a problem hiding this comment.
Why do we need this method?
953ba92 to
55cb4a4
Compare
|
Have you tested the large bcs? I will merge it once the testing is done. |
|
--- base.log PTACallGraph Stats (Andersen analysis)****** Persistent Points-To Cache Statistics: Andersen's analysis bitvector Memory SSA Statistics****** SVFG Statistics****** PTACallGraph Stats (Flow-sensitive analysis)****** Persistent Points-To Cache Statistics: flow-sensitive analysis bitvector |
| const DataLayout& dl, | ||
| IRGraph* pag, | ||
| std::vector<MemcpyField>& fields, | ||
| u32_t fieldLimit, |
There was a problem hiding this comment.
Do we need this argument? If not, pls remove.
55cb4a4 to
4f95e0f
Compare
| { | ||
| if (llvmType == nullptr || svfType == nullptr) | ||
| return; | ||
| if (fields.size() >= std::max(Options::MaxFieldLimit(), 1u)) |
634affc to
31ec4fc
Compare
Aggregate memcpy and memset models create GEP, load, and store statements for each flattened field. A single external call can therefore dominate SVFIR construction even though the existing field limit already bounds object field sensitivity. Apply -field-limit while collecting AccessPaths and byte-layout pointer fields for external memory operations, then reuse the existing field-wise modeling. This bounds generated statements by a constant factor of the field limit without adding another option or a separate summary path. A zero field limit retains one representative field, consistent with field-insensitive object modeling.
31ec4fc to
c763274
Compare
Sub- PR from #1878
Aggregate memcpy and memset models create one SVF statement per flattened field, so a single external call can dominate SVFIR construction on large recovered types.
Add the opt-in -ext-mem-field-limit option. Once the limit is exceeded, summarize the operation through field-insensitive variant-GEP pointers instead of continuing field-wise expansion. Statically resolved objects are marked immediately, while variant GEPs conservatively collapse objects discovered during points-to analysis, including objects reached through formal parameters.
The option defaults to zero (unlimited), preserving existing behavior.