[DomTree] Accept Value as Def (NFC)
authorNikita Popov <nikita.ppv@gmail.com>
Sat, 17 Oct 2020 18:54:53 +0000 (20:54 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Thu, 22 Oct 2020 16:32:03 +0000 (18:32 +0200)
commit32b6e9a450fff59690a3a7c828524c176d8b855e
treeb4639800bbcbb468e3d73f321bf3a3c6ca83f4dc
parentd842b8868771a9b6b039144c1f7550adec245f0c
[DomTree] Accept Value as Def (NFC)

Non-instruction defs like arguments, constants or global values
always dominate all instructions/uses inside the function. This
case currently needs to be treated separately by the caller, see
https://reviews.llvm.org/D89623#inline-832818 for an example.

This patch makes the dominator tree APIs accept a Value instead of
an Instruction and always returns true for the non-Instruction case.

A complication here is that BasicBlocks are also Values. For that
reason we can't support the dominates(Value *, BasicBlock *)
variant, as it would conflict with dominates(BasicBlock *, BasicBlock *),
which has different semantics. For the other two APIs we assert
that the passed value is not a BasicBlock.

Differential Revision: https://reviews.llvm.org/D89632
llvm/include/llvm/IR/Dominators.h
llvm/lib/IR/Dominators.cpp
llvm/unittests/IR/DominatorTreeTest.cpp