LLVM 19.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"
24#include "llvm/IR/ValueHandle.h"
25
26namespace llvm {
27
28class Value;
29class BranchInst;
30
32private:
33 /// A map of values about which a branch might be providing information.
35 AffectedValuesMap AffectedValues;
36
37public:
38 /// Add a branch condition to the cache.
39 void registerBranch(BranchInst *BI);
40
41 /// Remove a value from the cache, e.g. because it will be erased.
42 void removeValue(Value *V) { AffectedValues.erase(V); }
43
44 /// Access the list of branches which affect this value.
46 auto AVI = AffectedValues.find_as(const_cast<Value *>(V));
47 if (AVI == AffectedValues.end())
49
50 return AVI->second;
51 }
52};
53
54} // end namespace llvm
55
56#endif // LLVM_ANALYSIS_DOMCONDITIONCACHE_H
This file defines DenseMapInfo traits for DenseMap.
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:329
iterator find_as(const LookupKeyT &Val)
Alternate version of find() which allows a different, and possibly less expensive,...
Definition: DenseMap.h:180
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