1//===- DomConditionCache.cpp ----------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#include "llvm/Analysis/DomConditionCache.h"
10#include "llvm/Analysis/ValueTracking.h"
11using namespace llvm;
12
13static void findAffectedValues(Value *Cond,
14 SmallVectorImpl<Value *> &Affected) {
15 auto InsertAffected = [&Affected](Value *V) { Affected.push_back(Elt: V); };
16 findValuesAffectedByCondition(Cond, /*IsAssume=*/false, InsertAffected);
17}
18
19void DomConditionCache::registerBranch(BranchInst *BI) {
20 assert(BI->isConditional() && "Must be conditional branch");
21 SmallVector<Value *, 16> Affected;
22 findAffectedValues(Cond: BI->getCondition(), Affected);
23 for (Value *V : Affected) {
24 auto &AV = AffectedValues[V];
25 if (!is_contained(Range&: AV, Element: BI))
26 AV.push_back(Elt: BI);
27 }
28}
29

source code of llvm/lib/Analysis/DomConditionCache.cpp