This is an archive of the discontinued LLVM Phabricator instance.

Add a dominanance check interface that uses caching for instructions within same basic block.
ClosedPublic

Authored by trentxintong on May 20 2017, 12:36 PM.

Details

Summary

This problem stems from the fact that instructions are allocated using new
in LLVM, i.e. there is no relationship that can be derived by just looking
at the pointer value.

This interface dispatches to appropriate dominance check given 2 instructions,
i.e. in case the instructions are in the same basic block, ordered basicblock
(with instruction numbering and caching) are used. Otherwise, dominator tree
is used.

This is a preparation patch for https://reviews.llvm.org/D32720

Diff Detail

Repository
rL LLVM

Event Timeline

trentxintong created this revision.May 20 2017, 12:36 PM

Update test.

davide added a subscriber: davide.May 20 2017, 1:50 PM

This is a really nice cleanup and I think we can greatly benefit from it in other passes as well :)
Some comments inline.

lib/Transforms/Utils/OrderedInstructions.cpp
10 ↗(On Diff #99677)

I'd say check dominance relation between two instructions rather than information (and I'd add efficiently, as we take shortcuts here :))

17–18 ↗(On Diff #99677)

Do you need to define DEBUG_TYPE ?
This doesn't use any DEBUG() statements

19 ↗(On Diff #99677)

I'd add a comment to this explaining what it does/how.

30–31 ↗(On Diff #99677)

braces around this else, for consistency.

unittests/Transforms/Utils/OrderedInstructions.cpp
16 ↗(On Diff #99677)

Do you need to include LegacyPassManager.h ?

30–31 ↗(On Diff #99677)

Do you mind to add a textual representation of these tests for the reader? (it doesn't need to be perfect, just as guidance).

Address comments from @davide

Ping, appreciate it if this can get reviewed faster.

dberlin added inline comments.May 26 2017, 7:59 AM
lib/Transforms/Utils/OrderedInstructions.cpp
22 ↗(On Diff #99680)

Can you just take the DT in the constructor?
That way i can fill in the rest of the DT use cases as functions, and not have to take dominatortree anywhere.

Address comments.

Add a line of comment.

dberlin edited edge metadata.Jun 5 2017, 1:45 PM

LGTM with one change to start. I'll add the other pieces of dominators functionality.

include/llvm/Transforms/Utils/OrderedInstructions.h
41 ↗(On Diff #101446)

This should be const and the obbmap mutable

dberlin accepted this revision.Jun 5 2017, 1:45 PM
This revision is now accepted and ready to land.Jun 5 2017, 1:45 PM
This revision was automatically updated to reflect the committed changes.