This is an archive of the discontinued LLVM Phabricator instance.

[PostDom] add findNearestCommonDominator for instructions
AbandonedPublic

Authored by khei4 on Jul 16 2023, 11:06 PM.

Details

Reviewers
nikic
Summary

Implement PostDom version findNearestCommonDominator for instructions.

This seems symmetric to DominatorTree but contains some differences, e.g. returned ptr is nullable, and the use-case is only https://reviews.llvm.org/D155406. (TODO: search the use-cases).

Diff Detail

Event Timeline

khei4 created this revision.Jul 16 2023, 11:06 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 16 2023, 11:06 PM
khei4 requested review of this revision.Jul 16 2023, 11:06 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 16 2023, 11:06 PM

TODO: it might be better to add unit test for Pdom if it's reasonable to add this method.

nikic added a comment.Jul 17 2023, 6:22 AM

I think I would prefer to add this as a local helper to MemCpyOpt until we have a second use case.

llvm/include/llvm/Analysis/PostDominators.h
49

The "in the sense" part isn't correct for post-dominators.

llvm/lib/Analysis/PostDominators.cpp
90

I wasn't able to come up with an example where the nearest common post-dom would be an exception pad, so I think getFirstNonPHI() is fine.

khei4 abandoned this revision.Jul 19 2023, 4:14 PM

I think I would prefer to add this as a local helper to MemCpyOpt until we have a second use case.

It seems reasonable! I'll move this to https://reviews.llvm.org/D155406 ;)

llvm/include/llvm/Analysis/PostDominators.h
49

Thanks! I'll fix it on the https://reviews.llvm.org/D155406.