17#ifndef CLANG_CIR_DIALECT_ANALYSIS_CIRPOINTSTOANALYSIS_H
18#define CLANG_CIR_DIALECT_ANALYSIS_CIRPOINTSTOANALYSIS_H
20#include "mlir/IR/Operation.h"
21#include "mlir/IR/Value.h"
22#include "llvm/ADT/ArrayRef.h"
23#include "llvm/ADT/DenseMap.h"
24#include "llvm/ADT/MapVector.h"
25#include "llvm/ADT/SetVector.h"
26#include "llvm/Support/Compiler.h"
27#include "llvm/Support/raw_ostream.h"
44 return objects.getArrayRef();
54 void print(llvm::raw_ostream &os)
const;
55 LLVM_DUMP_METHOD
void dump()
const;
62 bool hitSizeLimit()
const {
return sizeLimitHit; }
65 bool insert(mlir::Value
object) {
return objects.insert(
object); }
68 bool insertUnknown() {
return !std::exchange(unknown,
true); }
71 bool merge(
const PointsToSet &other);
75 void replaceWithUnknown();
77 llvm::SmallSetVector<mlir::Value, 4> objects;
79 bool sizeLimitHit =
false;
82inline llvm::raw_ostream &
operator<<(llvm::raw_ostream &os,
138 void emitRemarks(llvm::StringRef subCategory = {})
const;
142 void compute(mlir::Operation *op);
146 bool visit(mlir::Operation *op);
161 mlir::Operation *root;
166 llvm::DenseMap<mlir::Value, PointsToSet> valuePointsTo;
169 llvm::DenseMap<mlir::Value, PointsToSet> memoryPointsTo;
173 llvm::MapVector<mlir::Value, mlir::Operation *> escaped;
181 bool operationLimitHit =
false;
const PointsToSet & getPointsTo(mlir::Value value) const
Return the objects value may point to.
PointsToAnalysis(mlir::Operation *op, const PointsToLimits &limits=PointsToLimits())
PointsToAnalysis(const PointsToAnalysis &)=delete
void emitRemarks(llvm::StringRef subCategory={}) const
Report the results as optimization remarks in the "points-to" category, when remarks are enabled for ...
PointsToAnalysis & operator=(const PointsToAnalysis &)=delete
The objects a value may point to.
friend class PointsToAnalysis
bool containsUnknown() const
Whether the set contains "unknown".
LLVM_DUMP_METHOD void dump() const
llvm::ArrayRef< mlir::Value > getObjects() const
The tracked objects in the set.
void print(llvm::raw_ostream &os) const
Print the set as the sorted names of the cir.alloca operations of its objects, followed by "unknown" ...
llvm::raw_ostream & operator<<(llvm::raw_ostream &os, const PointsToSet &set)
__builtin_elementwise_add_sat __builtin_elementwise_sub_sat uint32_t uint64_t __builtin_riscv_ssha_i32 __builtin_riscv_sshl_u32 uint64_t
Limits on the work done by PointsToAnalysis.
unsigned maxOperations
The largest number of operations the analysis is computed for.
unsigned maxSetSize
The largest number of objects a set holds.
unsigned workPerOperation
The work allowed to compute the sets, counted as the number of times an operation is visited.