clang 24.0.0git
CIRBasicAliasAnalysis.h
Go to the documentation of this file.
1//===- CIRBasicAliasAnalysis.h - Basic CIR Alias Analysis -------*- 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// This file defines CIRBasicAliasAnalysis, a CIR-specific alias analysis
10// implementation based on pointer provenance and distinct allocation sites.
11// Register with an mlir::AliasAnalysis aggregate via
12// addAnalysisImplementation(), or use registerCIRAliasAnalyses() to add the
13// full suite of CIR analyses at once.
14//
15//===----------------------------------------------------------------------===//
16
17#ifndef CLANG_CIR_DIALECT_ANALYSIS_CIRBASICALIASANALYSIS_H
18#define CLANG_CIR_DIALECT_ANALYSIS_CIRBASICALIASANALYSIS_H
19
20#include "mlir/Analysis/AliasAnalysis.h"
21#include "mlir/IR/Operation.h"
22#include "mlir/IR/Value.h"
23#include "mlir/Interfaces/DataLayoutInterfaces.h"
24
25namespace cir {
26
27/// Basic CIR alias analysis based on pointer provenance and distinct allocation
28/// sites. Conservative defaults (MayAlias / ModRef) are returned for cases
29/// that are not yet handled.
31public:
32 explicit CIRBasicAliasAnalysis(mlir::Operation *op)
33 : dataLayout(mlir::DataLayout::closest(op)) {}
35
36 /// Return the aliasing behavior between two values.
37 ///
38 /// Both values are traced back to the object they point into and to their
39 /// byte offset within it. Pointers into provably different objects don't
40 /// alias, and pointers at the same offset into the same object must alias.
41 /// MayAlias is returned whenever a more precise answer cannot be determined.
42 /// Every value queried is assumed to be dereferenced. Results for pointers
43 /// that are only compared or stored are not meaningful.
44 mlir::AliasResult alias(mlir::Value lhs, mlir::Value rhs);
45
46 /// Return the modify-reference behavior of `op` on `location`.
47 ///
48 /// Returns ModRef conservatively. CIR ops that carry explicit memory-effect
49 /// attributes or that are known to be pure/read-only can be handled here.
50 mlir::ModRefResult getModRef(mlir::Operation *op, mlir::Value location);
51
52private:
53 mlir::DataLayout dataLayout;
54};
55
56} // namespace cir
57
58#endif // CLANG_CIR_DIALECT_ANALYSIS_CIRBASICALIASANALYSIS_H
mlir::ModRefResult getModRef(mlir::Operation *op, mlir::Value location)
Return the modify-reference behavior of op on location.
CIRBasicAliasAnalysis(CIRBasicAliasAnalysis &&)=default
mlir::AliasResult alias(mlir::Value lhs, mlir::Value rhs)
Return the aliasing behavior between two values.
CIRBasicAliasAnalysis(mlir::Operation *op)