[PATCH] D118386: [Support][NFC] Fix generic `ChildrenGetterTy` of `IDFCalculatorBase`
Markus Böck via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 27 09:11:05 PST 2022
zero9178 created this revision.
zero9178 added reviewers: Szelethus, jmorse, kuhar.
Herald added subscribers: Chia-hungDuan, dexonsmith, rriddle, hiraditya.
zero9178 requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, stephenneuendorffer.
Herald added projects: clang, LLVM.
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::Block`s as nodes. As MLIR correctly only provides `GraphTraits<mlir::Block*>` I was not able to use `IDFCalculatorBase`.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D118386
Files:
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D118386.403668.patch
Type: text/x-patch
Size: 5252 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220127/28fcc6b2/attachment-0001.bin>
More information about the cfe-commits
mailing list