[Support][NFC] Fix generic `ChildrenGetterTy` of `IDFCalculatorBase`
authorMarkus Böck <markus.boeck02@gmail.com>
Sun, 30 Jan 2022 21:08:53 +0000 (22:08 +0100)
committerMarkus Böck <markus.boeck02@gmail.com>
Sun, 30 Jan 2022 21:09:07 +0000 (22:09 +0100)
commite0b11c7659f81a382a3c76e26ed792308248f41c
tree0a3f458d22d46a62b8b9b01796c735b6c6d3af64
parente1075186a6458de75492f5de5fb8b8139097ff5f
[Support][NFC] Fix generic `ChildrenGetterTy` of `IDFCalculatorBase`

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.

Differential Revision: https://reviews.llvm.org/D118386
clang/include/clang/Analysis/Analyses/Dominators.h
clang/include/clang/Analysis/CFG.h
llvm/include/llvm/Support/GenericIteratedDominanceFrontier.h
llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp