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.
clang-format: please reformat the code
- runWithDomTree(*M, "f", - [&](Function &F, DominatorTree *DT, PostDominatorTree *PDT) { - Argument *A = F.getArg(0); - GlobalValue *G = M->getNamedValue("foo"); - Constant *C = ConstantInt::getNullValue(Type::getInt8Ty(Context)); - - Instruction *I = F.getEntryBlock().getTerminator(); - EXPECT_TRUE(DT->dominates(A, I)); - EXPECT_TRUE(DT->dominates(G, I)); - EXPECT_TRUE(DT->dominates(C, I));22 diff lines are omitted. See full path.