Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/contrib/llvm-project/llvm/lib/Analysis/DomConditionCache.cpp
35232 views
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"
11
using namespace llvm;
12
13
static void findAffectedValues(Value *Cond,
14
SmallVectorImpl<Value *> &Affected) {
15
auto InsertAffected = [&Affected](Value *V) { Affected.push_back(V); };
16
findValuesAffectedByCondition(Cond, /*IsAssume=*/false, InsertAffected);
17
}
18
19
void DomConditionCache::registerBranch(BranchInst *BI) {
20
assert(BI->isConditional() && "Must be conditional branch");
21
SmallVector<Value *, 16> Affected;
22
findAffectedValues(BI->getCondition(), Affected);
23
for (Value *V : Affected) {
24
auto &AV = AffectedValues[V];
25
if (!is_contained(AV, BI))
26
AV.push_back(BI);
27
}
28
}
29
30