This is an archive of the discontinued LLVM Phabricator instance.

[DA] Refactor with a better API
ClosedPublic

Authored by congzhe on Apr 11 2022, 6:09 PM.

Details

Reviewers
Meinersbur
bmahjour
fhahn
Group Reviewers
Restricted Project
Commits
rG557b131c885b: [DA] Refactor with a better API
Summary

Refactor from iteratively using BitCastInst::getOperand() to using stripPointerCasts() instead. This is an improvement since now we are able to analyze more cases, please refer to test cases added in this patch.

After this patch, I will update the same piece of code in https://reviews.llvm.org/D122857 correspondingly.

Diff Detail

Event Timeline

congzhe created this revision.Apr 11 2022, 6:09 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 11 2022, 6:09 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
congzhe requested review of this revision.Apr 11 2022, 6:09 PM
Meinersbur added a comment.EditedApr 11 2022, 8:05 PM

Note that his is not strictly NFC, stripPointerCasts also strips zero GEPs and calls with returned attribute, ie. strictly more powerful. For instance:

%0 = getelementptr i32* %a, i32 0
%bitcast = bitcast i32* %0 to i64*

stripPointerCasts on %bitcast would return %a.

llvm/lib/Analysis/DependenceAnalysis.cpp
3352–3354

No If-condition needed, stripPointerCasts will return itself if not strippable.

fhahn added a subscriber: fhahn.Apr 12 2022, 1:32 AM

Note that his is not strictly NFC, stripPointerCasts also strips zero GEPs and calls with returned attribute, ie. strictly more powerful. For instance:

i32 = getelementpointer i32* %a, i32 0
%bitcast = bitcast i32* %0 to i64*

stripPointerCasts on %bitcast would return %a.

Would be good to add a test case for that?

congzhe updated this revision to Diff 422352.Apr 12 2022, 4:06 PM
congzhe retitled this revision from [DA] Refactor with a better API (NFC) to [DA] Refactor with a better API.
congzhe edited the summary of this revision. (Show Details)
congzhe added a reviewer: fhahn.

Thanks for the comments! I modified the wording a bit for the title and summary, addressed the comment from Michael @Meinersbur and added test cases correspondingly, thus addressed the comment from @fhahn.

Please let me know if you have further comments, thanks.

congzhe updated this revision to Diff 422359.Apr 12 2022, 4:09 PM
Meinersbur accepted this revision.Apr 12 2022, 9:03 PM

LGTM, thanks

This revision is now accepted and ready to land.Apr 12 2022, 9:03 PM
This revision was landed with ongoing or failed builds.Apr 13 2022, 11:52 AM
This revision was automatically updated to reflect the committed changes.