[clang] [CIR] Add object offset calculation for basic AA (PR #219047)
Bruno Cardoso Lopes via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 17 12:24:48 PDT 2026
================
@@ -20,31 +20,25 @@
#include "mlir/Analysis/AliasAnalysis.h"
#include "mlir/IR/Operation.h"
#include "mlir/IR/Value.h"
+#include "mlir/Interfaces/DataLayoutInterfaces.h"
namespace cir {
/// Basic CIR alias analysis based on pointer provenance and distinct allocation
/// sites. Conservative defaults (MayAlias / ModRef) are returned for cases
/// that are not yet handled.
class CIRBasicAliasAnalysis {
- enum class ObjectRelation {
- /// Provably different underlying allocations.
- Distinct,
- /// Same underlying allocation, no offset.
- Identical,
- /// Cannot determine the relationship.
- Unknown,
- };
-
public:
- CIRBasicAliasAnalysis() = default;
+ explicit CIRBasicAliasAnalysis(mlir::Operation *op)
+ : dataLayout(mlir::DataLayout::closest(op)) {}
CIRBasicAliasAnalysis(CIRBasicAliasAnalysis &&) = default;
/// Return the aliasing behavior between two values.
///
- /// Returns MayAlias conservatively unless a more precise result can be
- /// determined from CIR-specific information (e.g. distinct alloca ops,
- /// pointer provenance, restrict attributes).
+ /// Both values are traced back to the object they point into and to their
----------------
bcardosolopes wrote:
One more sentence here, something like "every value queried is assumed to be dereferenced; results for pointers that are only compared or stored are not meaningful" (I know we have this comment elsewhere, but the current comments are too close to the ops (like base_class_addr), which might never get read.
https://github.com/llvm/llvm-project/pull/219047
More information about the cfe-commits
mailing list