This introduces an analysis pass that wraps IRSimilarityIdentifier, and adds a printer pass to examine in what function similarities are being found.
Test for what the printer pass can find are in test/Analysis/IRSimilarityIdentifier.
Details
Diff Detail
Event Timeline
llvm/lib/Analysis/IRSimilarityIdentifier.cpp | ||
---|---|---|
685 | The accessors for Optional do this check for you, so you can just "dereference" it with * or -> as needed without worrying about adding your own assertion on it. If it's expected that IRSI will always have this populated once it has been constructed, then maybe getSimilarity() ought to be the one to unwrap the Optional. |
llvm/lib/Analysis/IRSimilarityIdentifier.cpp | ||
---|---|---|
685 | Well findSimilarity needs to have been run, or the constructor where a module has been passed to the IRSI. So, it's possible that you can construct IRSI where the SimilarityCandidates are None. I'm not sure if that changes what you're proposing. I think it could still make sense to put the derefence in getSimilarity since you shouldn't be calling it unless you've populated the IRSI with a module already. |
llvm/lib/Analysis/IRSimilarityIdentifier.cpp | ||
---|---|---|
685 |
agreed | |
689 | So maybe this is just: for (std::vector<IRSimilarityCandidate> &CandVec : IRSI.getSimilarity()) { or for (std::vector<IRSimilarityCandidate> &CandVec : *IRSI.getSimilarity()) { depending on which way you decide to go w/ moving that dereference. |
The accessors for Optional do this check for you, so you can just "dereference" it with * or -> as needed without worrying about adding your own assertion on it.
If it's expected that IRSI will always have this populated once it has been constructed, then maybe getSimilarity() ought to be the one to unwrap the Optional.