This is an archive of the discontinued LLVM Phabricator instance.

[FuncSpec] Return changed if function is changed by tryToReplaceWithConstant
ClosedPublic

Authored by ChuanqiXu on Aug 6 2021, 12:13 AM.

Details

Summary

The may get changed before specialization by RunSCCPSolver. In other words, the pass may change the function without specialization happens. Add test and comment to reveal this.
And it may return No Changed if the function get changed by RunSCCPSolver before the specialization. It looks like a potential bug.

Test Plan: check-all

Diff Detail

Event Timeline

ChuanqiXu created this revision.Aug 6 2021, 12:13 AM
ChuanqiXu requested review of this revision.Aug 6 2021, 12:13 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 6 2021, 12:13 AM
SjoerdMeijer added inline comments.Aug 6 2021, 12:36 AM
llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
765–767

I think this now deserves a comment.

ChuanqiXu added inline comments.Aug 6 2021, 1:05 AM
llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
765–767

hmm, I think it is easy to know that tryToReplaceWithConstant may change the function. I tried to add comments for this. But I find my words are a little redundant. I would make it if there is any good suggestion.

SjoerdMeijer accepted this revision.Aug 6 2021, 1:53 AM

LGTM.

The remark about the comment was a nit anyway. Feel free to modify or omit it before committing.

llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
765–767

I thought the idea was that this:

// FIXME: The solver may make changes to the function here, so set Changed, even if later
// function specialization does not trigger.
This revision is now accepted and ready to land.Aug 6 2021, 1:53 AM