LLVM 20.0.0git
DomConditionCache.h
Go to the documentation of this file.
1//===- llvm/Analysis/DomConditionCache.h ------------------------*- C++ -*-===//
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// Cache for branch conditions that affect a certain value for use by
10// ValueTracking. Unlike AssumptionCache, this class does not perform any
11// automatic analysis or invalidation. The caller is responsible for registering
12// all relevant branches (and re-registering them if they change), and for
13// removing invalidated values from the cache.
14//
15//===----------------------------------------------------------------------===//
16
17#ifndef LLVM_ANALYSIS_DOMCONDITIONCACHE_H
18#define LLVM_ANALYSIS_DOMCONDITIONCACHE_H
19
20#include "llvm/ADT/ArrayRef.h"
21#include "llvm/ADT/DenseMap.h"
23
24namespace llvm {
25
26class Value;
27class BranchInst;
28
30private:
31 /// A map of values about which a branch might be providing information.
33 AffectedValuesMap AffectedValues;
34
35public:
36 /// Add a branch condition to the cache.
37 void registerBranch(BranchInst *BI);
38
39 /// Remove a value from the cache, e.g. because it will be erased.
40 void removeValue(Value *V) { AffectedValues.erase(V); }
41
42 /// Access the list of branches which affect this value.
44 auto AVI = AffectedValues.find_as(const_cast<Value *>(V));
45 if (AVI == AffectedValues.end())
47
48 return AVI->second;
49 }
50};
51
52} // end namespace llvm
53
54#endif // LLVM_ANALYSIS_DOMCONDITIONCACHE_H
This file defines the DenseMap class.
This file defines the SmallVector class.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
Conditional or Unconditional Branch instruction.
bool erase(const KeyT &Val)
Definition: DenseMap.h:321
iterator find_as(const LookupKeyT &Val)
Alternate version of find() which allows a different, and possibly less expensive,...
Definition: DenseMap.h:176
iterator end()
Definition: DenseMap.h:84
ArrayRef< BranchInst * > conditionsFor(const Value *V) const
Access the list of branches which affect this value.
void removeValue(Value *V)
Remove a value from the cache, e.g. because it will be erased.
void registerBranch(BranchInst *BI)
Add a branch condition to the cache.
LLVM Value Representation.
Definition: Value.h:74
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18