This is an archive of the discontinued LLVM Phabricator instance.

[Support][NFC] Fix generic `ChildrenGetterTy` of `IDFCalculatorBase`
ClosedPublic

Authored by zero9178 on Jan 27 2022, 9:11 AM.

Details

Summary

Both IDFCalculatorBase and its accompanying DominatorTreeBase only supports pointer nodes. The template argument is the block type itself and any uses of GraphTraits is therefore done via a pointer to the node type.
However, the ChildrenGetterTy type of IDFCalculatorBase has a use on just the node type instead of a pointer to the node type. Various parts of the monorepo has worked around this issue by providing specializations of GraphTraits for the node type directly, or not been affected by using specializations instead of the generic case. These are unnecessary however and instead the generic code should be fixed instead.

An example from within Tree is eg. A use of IDFCalculatorBase in InstrRefBasedImpl.cpp. It basically instantiates a IDFCalculatorBase<MachineBasicBlock, false> but due to the bug above then goes on to specialize GraphTraits<MachineBasicBlock> although GraphTraits<MachineBasicBlock*> exists (and should be used instead).

Similar dead code exists in clang which defines redundant GraphTraits to work around this bug.

This patch fixes both the original issue and removes the dead code that was used to work around the issue.

As a side node, my own motivation was when using MLIR and using mlir::Blocks as nodes. As MLIR correctly only provides GraphTraits<mlir::Block*> I was not able to use IDFCalculatorBase.

Diff Detail

Event Timeline

zero9178 created this revision.Jan 27 2022, 9:11 AM
zero9178 requested review of this revision.Jan 27 2022, 9:11 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJan 27 2022, 9:11 AM
kuhar accepted this revision.Jan 30 2022, 11:49 AM

LGTM

This revision is now accepted and ready to land.Jan 30 2022, 11:49 AM
This revision was landed with ongoing or failed builds.Jan 30 2022, 1:09 PM
This revision was automatically updated to reflect the committed changes.