Skip to content

[WIP] On demand analyze for allocation - #37

Draft
keremsahn wants to merge 2 commits into
compiler-research:mainfrom
keremsahn:on-demand-analyze
Draft

[WIP] On demand analyze for allocation#37
keremsahn wants to merge 2 commits into
compiler-research:mainfrom
keremsahn:on-demand-analyze

Conversation

@keremsahn

@keremsahn keremsahn commented Aug 22, 2026

Copy link
Copy Markdown

Built upon #35
Added wrapping for GetAllocType, and it is called if user sets gUseAllocAnalyze variable, which is disabled by default. Analyzer has lower priority compared to attribute check.

A detail: Analyzer caches the result, so once the function is called with gUseAllocAnalyze, the result stays, even though the flag is set to False laterly.
@aaronj0 @vgvassilev @Vipul-Cariappa

…p information and this information effects kIsCreator flag of overload group , currently analyzer is not called, just attribute checker is called
@Vipul-Cariappa
Vipul-Cariappa marked this pull request as draft August 23, 2026 04:54
@Vipul-Cariappa Vipul-Cariappa changed the title On demand analyze for allocation [WIP] On demand analyze for allocation Aug 23, 2026

@Vipul-Cariappa Vipul-Cariappa left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comments. LGTM!

def test03_analyzer_new(self):
import cppjit

cppjit._backend.SetUseAllocAnalyzer(True)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a wrapper in __init__.py, such that the user can directly do
cppjit.use_alloc_analyzer(...). Note that in Python, function names should be in snake case.

Comment on lines +44 to +47
cppjit._backend.SetUseAllocAnalyzer(False)
obj = cppjit.gbl.allocNew2()
assert type(obj) == cppjit.gbl.memAnalysisKlass
assert not (obj.__python_owns__)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need a test for reusing existing results... i.e. already analyzed, but use_alloc_analyzer(False).

Comment on lines +13 to +14
inline memAnalysisKlass* allocNew() { return new memAnalysisKlass; }
inline memAnalysisKlass* allocNew2() { return new memAnalysisKlass; }

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can the function names be a bit more descriptive? In the context of the test. Example:
AnalysisOnAllocNew & AnalysisOffAllocNew?

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