clang 20.0.0git
CodeGenTBAA.h
Go to the documentation of this file.
1//===--- CodeGenTBAA.h - TBAA information for LLVM CodeGen ------*- 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 is the code that manages TBAA information and defines the TBAA policy
10// for the optimizer to use.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_CLANG_LIB_CODEGEN_CODEGENTBAA_H
15#define LLVM_CLANG_LIB_CODEGEN_CODEGENTBAA_H
16
17#include "clang/AST/Type.h"
18#include "clang/Basic/LLVM.h"
19#include "llvm/ADT/DenseMap.h"
20#include "llvm/IR/MDBuilder.h"
21#include "llvm/IR/Metadata.h"
22
23namespace clang {
24 class ASTContext;
25 class CodeGenOptions;
26 class LangOptions;
27 class MangleContext;
28 class QualType;
29 class Type;
30
31namespace CodeGen {
32class CodeGenTypes;
33
34// TBAAAccessKind - A kind of TBAA memory access descriptor.
35enum class TBAAAccessKind : unsigned {
39};
40
41// TBAAAccessInfo - Describes a memory access in terms of TBAA.
44 llvm::MDNode *AccessType, uint64_t Offset, uint64_t Size)
47 {}
48
49 TBAAAccessInfo(llvm::MDNode *BaseType, llvm::MDNode *AccessType,
50 uint64_t Offset, uint64_t Size)
52 Offset, Size)
53 {}
54
55 explicit TBAAAccessInfo(llvm::MDNode *AccessType, uint64_t Size)
56 : TBAAAccessInfo(/* BaseType= */ nullptr, AccessType, /* Offset= */ 0, Size)
57 {}
58
60 : TBAAAccessInfo(/* AccessType= */ nullptr, /* Size= */ 0)
61 {}
62
65 /* BaseType= */ nullptr, /* AccessType= */ nullptr,
66 /* Offset= */ 0, /* Size= */ 0);
67 }
68
69 bool isMayAlias() const { return Kind == TBAAAccessKind::MayAlias; }
70
73 /* BaseType= */ nullptr, /* AccessType= */ nullptr,
74 /* Offset= */ 0, /* Size= */ 0);
75 }
76
77 bool isIncomplete() const { return Kind == TBAAAccessKind::Incomplete; }
78
79 bool operator==(const TBAAAccessInfo &Other) const {
80 return Kind == Other.Kind &&
81