clang  14.0.0git
CodeGenTBAA.cpp
Go to the documentation of this file.
1 //===-- CodeGenTBAA.cpp - TBAA information for LLVM CodeGen ---------------===//
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. Relevant standards text includes:
11 //
12 // C99 6.5p7
13 // C++ [basic.lval] (p10 in n3126, p15 in some earlier versions)
14 //
15 //===----------------------------------------------------------------------===//
16 
17 #include "CodeGenTBAA.h"
18 #include "clang/AST/ASTContext.h"
19 #include "clang/AST/Attr.h"
20 #include "clang/AST/Mangle.h"
21 #include "clang/AST/RecordLayout.h"
23 #include "llvm/ADT/SmallSet.h"
24 #include "llvm/IR/Constants.h"
25 #include "llvm/IR/LLVMContext.h"
26 #include "llvm/IR/Metadata.h"
27 #include "llvm/IR/Module.h"
28 #include "llvm/IR/Type.h"
29 using namespace clang;
30 using namespace CodeGen;
31 
32 CodeGenTBAA::CodeGenTBAA(ASTContext &Ctx, llvm::Module &M,
33  const CodeGenOptions &CGO,
34  const LangOptions &Features, MangleContext &MContext)
35  : Context(Ctx), Module(M), CodeGenOpts(CGO),
36  Features(Features), MContext(MContext), MDHelper(M.getContext()),
37  Root(nullptr), Char(nullptr)
38 {}
39 
41 }
42 
43 llvm::MDNode *CodeGenTBAA::getRoot() {
44  // Define the root of the tree. This identifies the tree, so that
45  // if our LLVM IR is linked with LLVM IR from a different front-end
46  // (or a different version of this front-end), their TBAA trees will
47  // remain distinct, and the optimizer will treat them conservatively.
48  if (!Root) {
49  if (Features.CPlusPlus)
50  Root = MDHelper.createTBAARoot("Simple C++ TBAA");
51  else
52  Root = MDHelper.createTBAARoot("Simple C/C++ TBAA");
53  }
54 
55  return Root;
56 }
57 
58 llvm::MDNode *CodeGenTBAA::createScalarTypeNode(StringRef Name,
59  llvm::MDNode *Parent,
60  uint64_t Size) {
61  if (CodeGenOpts.NewStructPathTBAA) {
62  llvm::Metadata *Id = MDHelper.createString(Name);
63  return MDHelper.createTBAATypeNode(Parent, Size, Id);
64  }
65  return MDHelper.createTBAAScalarTypeNode(Name, Parent);
66 }
67 
68 llvm::MDNode *CodeGenTBAA::getChar() {
69  // Define the root of the tree for user-accessible memory. C and C++
70  // give special powers to char and certain similar types. However,
71  // these special powers only cover user-accessible memory, and doesn't
72  // include things like vtables.
73  if (!Char)
74  Char = createScalarTypeNode("omnipotent char", getRoot(), /* Size= */ 1);
75 
76  return Char;
77 }
78 
79 static bool TypeHasMayAlias(QualType QTy) {
80  // Tagged types have declarations, and therefore may have attributes.
81  if (auto *TD = QTy->getAsTagDecl())
82  if (TD->hasAttr<MayAliasAttr>())
83  return true;
84 
85  // Also look for may_alias as a declaration attribute on a typedef.
86  // FIXME: We should follow GCC and model may_alias as a type attribute
87  // rather than as a declaration attribute.
88  while (auto *TT = QTy->getAs<TypedefType>()) {
89  if (TT->getDecl()->hasAttr<MayAliasAttr>())
90  return true;
91  QTy = TT->desugar();
92  }
93  return false;
94 }
95 
96 /// Check if the given type is a valid base type to be used in access tags.
97 static bool isValidBaseType(QualType QTy) {
98  if (QTy->isReferenceType())
99  return false;
100  if (const RecordType *TTy = QTy->getAs<RecordType>()) {
101  const RecordDecl *RD = TTy->getDecl()->getDefinition();
102  // Incomplete types are not valid base access types.
103  if (!RD)
104  return false;
105  if (RD->hasFlexibleArrayMember())
106  return false;
107  // RD can be struct, union, class, interface or enum.
108  // For now, we only handle struct and class.
109  if (RD->isStruct() || RD->isClass())
110  return true;
111  }
112  return false;
113 }
114 
115 llvm::MDNode *CodeGenTBAA::getTypeInfoHelper(const Type *Ty) {
116  uint64_t Size = Context.getTypeSizeInChars(Ty).getQuantity();
117 
118  // Handle builtin types.
119  if (const BuiltinType *BTy = dyn_cast<BuiltinType>(Ty)) {
120  switch (BTy->getKind()) {
121  // Character types are special and can alias anything.
122  // In C++, this technically only includes "char" and "unsigned char",
123  // and not "signed char". In C, it includes all three. For now,
124  // the risk of exploiting this detail in C++ seems likely to outweigh
125  // the benefit.
126  case BuiltinType::Char_U:
127  case BuiltinType::Char_S:
128  case BuiltinType::UChar:
129  case BuiltinType::SChar:
130  return getChar();
131 
132  // Unsigned types can alias their corresponding signed types.
133  case BuiltinType::UShort:
134  return getTypeInfo(Context.ShortTy);
135  case BuiltinType::UInt:
136  return getTypeInfo(Context.IntTy);
137  case BuiltinType::ULong:
138  return getTypeInfo(Context.LongTy);
139  case BuiltinType::ULongLong:
140  return getTypeInfo(Context.LongLongTy);
141  case BuiltinType::UInt128:
142  return getTypeInfo(Context.Int128Ty);
143 
144  case BuiltinType::UShortFract:
145  return getTypeInfo(Context.ShortFractTy);
146  case BuiltinType::UFract:
147  return getTypeInfo(Context.FractTy);
148  case BuiltinType::ULongFract:
149  return getTypeInfo(Context.LongFractTy);
150 
151  case BuiltinType::SatUShortFract:
152  return getTypeInfo(Context.SatShortFractTy);
153  case BuiltinType::SatUFract:
154  return getTypeInfo(Context.SatFractTy);
155  case BuiltinType::SatULongFract:
156  return getTypeInfo(Context.SatLongFractTy);
157 
158  case BuiltinType::UShortAccum:
159  return getTypeInfo(Context.ShortAccumTy);
160  case BuiltinType::UAccum:
161  return getTypeInfo(Context.AccumTy);
162  case BuiltinType::ULongAccum:
163  return getTypeInfo(Context.LongAccumTy);
164 
165  case BuiltinType::SatUShortAccum:
166  return getTypeInfo(Context.SatShortAccumTy);
167  case BuiltinType::SatUAccum:
168  return getTypeInfo(Context.SatAccumTy);
169  case BuiltinType::SatULongAccum:
170  return getTypeInfo(Context.SatLongAccumTy);
171 
172  // Treat all other builtin types as distinct types. This includes
173  // treating wchar_t, char16_t, and char32_t as distinct from their
174  // "underlying types".
175  default:
176  return createScalarTypeNode(BTy->getName(Features), getChar(), Size);
177  }
178  }
179 
180  // C++1z [basic.lval]p10: "If a program attempts to access the stored value of
181  // an object through a glvalue of other than one of the following types the
182  // behavior is undefined: [...] a char, unsigned char, or std::byte type."
183  if (Ty->isStdByteType())
184  return getChar();
185 
186  // Handle pointers and references.
187  // TODO: Implement C++'s type "similarity" and consider dis-"similar"
188  // pointers distinct.
189  if (Ty->isPointerType() || Ty->isReferenceType())
190  return createScalarTypeNode("any pointer", getChar(), Size);
191 
192  // Accesses to arrays are accesses to objects of their element types.
193  if (CodeGenOpts.NewStructPathTBAA && Ty->isArrayType())
194  return getTypeInfo(cast<ArrayType>(Ty)->getElementType());
195 
196  // Enum types are distinct types. In C++ they have "underlying types",
197  // however they aren't related for TBAA.
198  if (const EnumType *ETy = dyn_cast<EnumType>(Ty)) {
199  // In C++ mode, types have linkage, so we can rely on the ODR and
200  // on their mangled names, if they're external.
201  // TODO: Is there a way to get a program-wide unique name for a
202  // decl with local linkage or no linkage?
203  if (!Features.CPlusPlus || !ETy->getDecl()->isExternallyVisible())
204  return getChar();
205 
206  SmallString<256> OutName;
207  llvm::raw_svector_ostream Out(OutName);
208  MContext.mangleTypeName(QualType(ETy, 0), Out);
209  return createScalarTypeNode(OutName, getChar(), Size);
210  }
211 
212  if (const auto *EIT = dyn_cast<ExtIntType>(Ty)) {
213  SmallString<256> OutName;
214  llvm::raw_svector_ostream Out(OutName);
215  // Don't specify signed/unsigned since integer types can alias despite sign
216  // differences.
217  Out << "_ExtInt(" << EIT->getNumBits() << ')';
218  return createScalarTypeNode(OutName, getChar(), Size);
219  }
220 
221  // For now, handle any other kind of type conservatively.
222  return getChar();
223 }
224 
225 llvm::MDNode *CodeGenTBAA::getTypeInfo(QualType QTy) {
226  // At -O0 or relaxed aliasing, TBAA is not emitted for regular types.
227  if (CodeGenOpts.OptimizationLevel == 0 || CodeGenOpts.RelaxedAliasing)
228  return nullptr;
229 
230  // If the type has the may_alias attribute (even on a typedef), it is
231  // effectively in the general char alias class.
232  if (TypeHasMayAlias(QTy))
233  return getChar();
234 
235  // We need this function to not fall back to returning the "omnipotent char"
236  // type node for aggregate and union types. Otherwise, any dereference of an
237  // aggregate will result into the may-alias access descriptor, meaning all
238  // subsequent accesses to direct and indirect members of that aggregate will
239  // be considered may-alias too.
240  // TODO: Combine getTypeInfo() and getBaseTypeInfo() into a single function.
241  if (isValidBaseType(QTy))
242  return getBaseTypeInfo(QTy);
243 
244  const Type *Ty = Context.getCanonicalType(QTy).getTypePtr();
245  if (llvm::MDNode *N = MetadataCache[Ty])
246  return N;
247 
248  // Note that the following helper call is allowed to add new nodes to the
249  // cache, which invalidates all its previously obtained iterators. So we
250  // first generate the node for the type and then add that node to the cache.
251  llvm::MDNode *TypeNode = getTypeInfoHelper(Ty);
252  return MetadataCache[Ty] = TypeNode;
253 }
254 
256  // Pointee values may have incomplete types, but they shall never be
257  // dereferenced.
258  if (AccessType->isIncompleteType())
260 
261  if (TypeHasMayAlias(AccessType))
263 
264  uint64_t Size = Context.getTypeSizeInChars(AccessType).getQuantity();
265  return TBAAAccessInfo(getTypeInfo(AccessType), Size);
266 }
267 
269  llvm::DataLayout DL(&Module);
270  unsigned Size = DL.getPointerTypeSize(VTablePtrType);
271  return TBAAAccessInfo(createScalarTypeNode("vtable pointer", getRoot(), Size),
272  Size);
273 }
274 
275 bool
276 CodeGenTBAA::CollectFields(uint64_t BaseOffset,
277  QualType QTy,
279  Fields,
280  bool MayAlias) {
281  /* Things not handled yet include: C++ base classes, bitfields, */
282 
283  if (const RecordType *TTy = QTy->getAs<RecordType>()) {
284  const RecordDecl *RD = TTy->getDecl()->getDefinition();
285  if (RD->hasFlexibleArrayMember())
286  return false;
287 
288  // TODO: Handle C++ base classes.
289  if (const CXXRecordDecl *Decl = dyn_cast<CXXRecordDecl>(RD))
290  if (Decl->bases_begin() != Decl->bases_end())
291  return false;
292 
293  const ASTRecordLayout &Layout = Context.getASTRecordLayout(RD);
294 
295  unsigned idx = 0;
297  e = RD->field_end(); i != e; ++i, ++idx) {
298  if ((*i)->isZeroSize(Context) || (*i)->isUnnamedBitfield())
299  continue;
300  uint64_t Offset = BaseOffset +
301  Layout.getFieldOffset(idx) / Context.getCharWidth();
302  QualType FieldQTy = i->getType();
303  if (!CollectFields(Offset, FieldQTy, Fields,
304  MayAlias || TypeHasMayAlias(FieldQTy)))
305  return false;
306  }
307  return true;
308  }
309 
310  /* Otherwise, treat whatever it is as a field. */
311  uint64_t Offset = BaseOffset;
312  uint64_t Size = Context.getTypeSizeInChars(QTy).getQuantity();
313  llvm::MDNode *TBAAType = MayAlias ? getChar() : getTypeInfo(QTy);
314  llvm::MDNode *TBAATag = getAccessTagInfo(TBAAAccessInfo(TBAAType, Size));
315  Fields.push_back(llvm::MDBuilder::TBAAStructField(Offset, Size, TBAATag));
316  return true;
317 }
318 
319 llvm::MDNode *
321  const Type *Ty = Context.getCanonicalType(QTy).getTypePtr();
322 
323  if (llvm::MDNode *N = StructMetadataCache[Ty])
324  return N;
325 
327  if (CollectFields(0, QTy, Fields, TypeHasMayAlias(QTy)))
328  return MDHelper.createTBAAStructNode(Fields);
329 
330  // For now, handle any other kind of type conservatively.
331  return StructMetadataCache[Ty] = nullptr;
332 }
333 
334 llvm::MDNode *CodeGenTBAA::getBaseTypeInfoHelper(const Type *Ty) {
335  if (auto *TTy = dyn_cast<RecordType>(Ty)) {
336  const RecordDecl *RD = TTy->getDecl()->getDefinition();
337  const ASTRecordLayout &Layout = Context.getASTRecordLayout(RD);
339  for (FieldDecl *Field : RD->fields()) {
340  if (Field->isZeroSize(Context) || Field->isUnnamedBitfield())
341  continue;
342  QualType FieldQTy = Field->getType();
343  llvm::MDNode *TypeNode = isValidBaseType(FieldQTy) ?
344  getBaseTypeInfo(FieldQTy) : getTypeInfo(FieldQTy);
345  if (!TypeNode)
346  return BaseTypeMetadataCache[Ty] = nullptr;
347 
348  uint64_t BitOffset = Layout.getFieldOffset(Field->getFieldIndex());
349  uint64_t Offset = Context.toCharUnitsFromBits(BitOffset).getQuantity();
350  uint64_t Size = Context.getTypeSizeInChars(FieldQTy).getQuantity();
351  Fields.push_back(llvm::MDBuilder::TBAAStructField(Offset, Size,
352  TypeNode));
353  }
354 
355  SmallString<256> OutName;
356  if (Features.CPlusPlus) {
357  // Don't use the mangler for C code.
358  llvm::raw_svector_ostream Out(OutName);
359  MContext.mangleTypeName(QualType(Ty, 0), Out);
360  } else {
361  OutName = RD->getName();
362  }
363 
364  if (CodeGenOpts.NewStructPathTBAA) {
365  llvm::MDNode *Parent = getChar();
366  uint64_t Size = Context.getTypeSizeInChars(Ty).getQuantity();
367  llvm::Metadata *Id = MDHelper.createString(OutName);
368  return MDHelper.createTBAATypeNode(Parent, Size, Id, Fields);
369  }
370 
371  // Create the struct type node with a vector of pairs (offset, type).
373  for (const auto &Field : Fields)
374  OffsetsAndTypes.push_back(std::make_pair(Field.Type, Field.Offset));
375  return MDHelper.createTBAAStructTypeNode(OutName, OffsetsAndTypes);
376  }
377 
378  return nullptr;
379 }
380 
382  if (!isValidBaseType(QTy))
383  return nullptr;
384 
385  const Type *Ty = Context.getCanonicalType(QTy).getTypePtr();
386  if (llvm::MDNode *N = BaseTypeMetadataCache[Ty])
387  return N;
388 
389  // Note that the following helper call is allowed to add new nodes to the
390  // cache, which invalidates all its previously obtained iterators. So we
391  // first generate the node for the type and then add that node to the cache.
392  llvm::MDNode *TypeNode = getBaseTypeInfoHelper(Ty);
393  return BaseTypeMetadataCache[Ty] = TypeNode;
394 }
395 
397  assert(!Info.isIncomplete() && "Access to an object of an incomplete type!");
398 
399  if (Info.isMayAlias())
400  Info = TBAAAccessInfo(getChar(), Info.Size);
401 
402  if (!Info.AccessType)
403  return nullptr;
404 
405  if (!CodeGenOpts.StructPathTBAA)
406  Info = TBAAAccessInfo(Info.AccessType, Info.Size);
407 
408  llvm::MDNode *&N = AccessTagMetadataCache[Info];
409  if (N)
410  return N;
411 
412  if (!Info.BaseType) {
413  Info.BaseType = Info.AccessType;
414  assert(!Info.Offset && "Nonzero offset for an access with no base type!");
415  }
416  if (CodeGenOpts.NewStructPathTBAA) {
417  return N = MDHelper.createTBAAAccessTag(Info.BaseType, Info.AccessType,
418  Info.Offset, Info.Size);
419  }
420  return N = MDHelper.createTBAAStructTagNode(Info.BaseType, Info.AccessType,
421  Info.Offset);
422 }
423 
426  if (SourceInfo.isMayAlias() || TargetInfo.isMayAlias())
428  return TargetInfo;
429 }
430 
433  TBAAAccessInfo InfoB) {
434  if (InfoA == InfoB)
435  return InfoA;
436 
437  if (!InfoA || !InfoB)
438  return TBAAAccessInfo();
439 
440  if (InfoA.isMayAlias() || InfoB.isMayAlias())
442 
443  // TODO: Implement the rest of the logic here. For example, two accesses
444  // with same final access types result in an access to an object of that final
445  // access type regardless of their base types.
447 }
448 
451  TBAAAccessInfo SrcInfo) {
452  if (DestInfo == SrcInfo)
453  return DestInfo;
454 
455  if (!DestInfo || !SrcInfo)
456  return TBAAAccessInfo();
457 
458  if (DestInfo.isMayAlias() || SrcInfo.isMayAlias())
460 
461  // TODO: Implement the rest of the logic here. For example, two accesses
462  // with same final access types result in an access to an object of that final
463  // access type regardless of their base types.
465 }
clang::BuiltinType
This class is used for builtin types like 'int'.
Definition: Type.h:2493
clang::RecordDecl::hasFlexibleArrayMember
bool hasFlexibleArrayMember() const
Definition: Decl.h:3913
clang::ASTContext::getTypeSizeInChars
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
Definition: ASTContext.cpp:2450
clang::RecordDecl::field_begin
field_iterator field_begin() const
Definition: Decl.cpp:4605
clang::CodeGen::CodeGenTBAA::mergeTBAAInfoForConditionalOperator
TBAAAccessInfo mergeTBAAInfoForConditionalOperator(TBAAAccessInfo InfoA, TBAAAccessInfo InfoB)
mergeTBAAInfoForConditionalOperator - Get merged TBAA information for the purpose of conditional oper...
Definition: CodeGenTBAA.cpp:432
clang::ASTRecordLayout::getFieldOffset
uint64_t getFieldOffset(unsigned FieldNo) const
getFieldOffset - Get the offset of the given field index, in bits.
Definition: RecordLayout.h:200
clang::DeclContext::specific_decl_iterator
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext,...
Definition: DeclBase.h:2135
clang::ASTContext::getCharWidth
uint64_t getCharWidth() const
Return the size of the character type, in bits.
Definition: ASTContext.h:2249
clang::Type::isStdByteType
bool isStdByteType() const
Definition: Type.cpp:2728
clang::CodeGen::CodeGenTBAA::getTypeInfo
llvm::MDNode * getTypeInfo(QualType QTy)
getTypeInfo - Get metadata used to describe accesses to objects of the given type.
Definition: CodeGenTBAA.cpp:225
llvm::SmallVector
Definition: LLVM.h:38
clang::QualType
A (possibly-)qualified type.
Definition: Type.h:673
Attr.h
clang::ASTContext::SatLongAccumTy
CanQualType SatLongAccumTy
Definition: ASTContext.h:1093
clang::FieldDecl
Represents a member of a struct/union/class.
Definition: Decl.h:2835
clang::ASTContext::SatShortAccumTy
CanQualType SatShortAccumTy
Definition: ASTContext.h:1093
clang::TargetInfo
Exposes information about the current target.
Definition: TargetInfo.h:189
clang::CodeGen::CodeGenTBAA::getVTablePtrAccessInfo
TBAAAccessInfo getVTablePtrAccessInfo(llvm::Type *VTablePtrType)
getVTablePtrAccessInfo - Get the TBAA information that describes an access to a virtual table pointer...
Definition: CodeGenTBAA.cpp:268
clang::RecordDecl::getDefinition
RecordDecl * getDefinition() const
Returns the RecordDecl that actually defines this struct/union/class.
Definition: Decl.h:4064
clang::Type
The base class of the type hierarchy.
Definition: Type.h:1490
clang::TypedefType
Definition: Type.h:4371
Offset
unsigned Offset
Definition: Format.cpp:2335
CodeGenOptions.h
clang::CanQual::getTypePtr
const T * getTypePtr() const
Retrieve the underlying type pointer, which refers to a canonical type.
Definition: CanonicalType.h:83
clang::Type::isReferenceType
bool isReferenceType() const
Definition: Type.h:6685
clang::CodeGen::TBAAAccessKind::MayAlias
@ MayAlias
clang::CodeGen::TBAAAccessInfo::isMayAlias
bool isMayAlias() const
Definition: CodeGenTBAA.h:69
clang::CodeGen::TBAAAccessInfo
Definition: CodeGenTBAA.h:42
clang::RecordType
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Definition: Type.h:4613
clang::ASTContext::SatLongFractTy
CanQualType SatLongFractTy
Definition: ASTContext.h:1096
clang::MangleContext
MangleContext - Context for tracking state which persists across multiple calls to the C++ name mangl...
Definition: Mangle.h:44
clang::Module
Describes a module or submodule.
Definition: Module.h:96
isValidBaseType
static bool isValidBaseType(QualType QTy)
Check if the given type is a valid base type to be used in access tags.
Definition: CodeGenTBAA.cpp:97
clang::ASTContext::AccumTy
CanQualType AccumTy
Definition: ASTContext.h:1088
clang::Type::getAsTagDecl
TagDecl * getAsTagDecl() const
Retrieves the TagDecl that this type refers to, either because the type is a TagType or because it is...
Definition: Type.cpp:1761
Id
int Id
Definition: ASTDiff.cpp:191
clang::ASTContext
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:212
clang::Type::getAs
const T * getAs() const
Member-template getAs<specific type>'.
Definition: Type.h:7162
clang::CodeGen::TBAAAccessInfo::isIncomplete
bool isIncomplete() const
Definition: CodeGenTBAA.h:77
clang::index::SymbolKind::Field
@ Field
clang::CodeGen::TBAAAccessInfo::BaseType
llvm::MDNode * BaseType
BaseType - The base/leading access type.
Definition: CodeGenTBAA.h:101
clang::MangleContext::mangleTypeName
virtual void mangleTypeName(QualType T, raw_ostream &)=0
Generates a unique string for an externally visible type for use with TBAA or type uniquing.
llvm::SmallString
Definition: LLVM.h:37
ASTContext.h
clang::ASTContext::LongAccumTy
CanQualType LongAccumTy
Definition: ASTContext.h:1089
clang::CodeGen::CodeGenTBAA::CodeGenTBAA
CodeGenTBAA(ASTContext &Ctx, llvm::Module &M, const CodeGenOptions &CGO, const LangOptions &Features, MangleContext &MContext)
Definition: CodeGenTBAA.cpp:32
clang::ASTContext::getCanonicalType
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
Definition: ASTContext.h:2468
clang::ASTContext::SatAccumTy
CanQualType SatAccumTy
Definition: ASTContext.h:1093
clang::CodeGen::CodeGenTBAA::getBaseTypeInfo
llvm::MDNode * getBaseTypeInfo(QualType QTy)
getBaseTypeInfo - Get metadata that describes the given base access type.
Definition: CodeGenTBAA.cpp:381
clang::CodeGen::CodeGenTBAA::getAccessTagInfo
llvm::MDNode * getAccessTagInfo(TBAAAccessInfo Info)
getAccessTagInfo - Get TBAA tag for a given memory access.
Definition: CodeGenTBAA.cpp:396
clang::CodeGen::TBAAAccessInfo::getIncompleteInfo
static TBAAAccessInfo getIncompleteInfo()
Definition: CodeGenTBAA.h:71
clang::CodeGenOptions
CodeGenOptions - Track various options which control how the code is optimized and passed to the back...
Definition: CodeGenOptions.h:49
clang::ASTContext::ShortTy
CanQualType ShortTy
Definition: ASTContext.h:1084
TypeHasMayAlias
static bool TypeHasMayAlias(QualType QTy)
Definition: CodeGenTBAA.cpp:79
clang::CodeGen::CodeGenTBAA::getTBAAStructInfo
llvm::MDNode * getTBAAStructInfo(QualType QTy)
getTBAAStructInfo - Get the TBAAStruct MDNode to be used for a memcpy of the given type.
Definition: CodeGenTBAA.cpp:320
clang::ASTContext::FractTy
CanQualType FractTy
Definition: ASTContext.h:1091
clang::TagDecl::isClass
bool isClass() const
Definition: Decl.h:3515
clang::ASTRecordLayout
ASTRecordLayout - This class contains layout information for one RecordDecl, which is a struct/union/...
Definition: RecordLayout.h:38
clang::CXXRecordDecl
Represents a C++ struct/union/class.
Definition: DeclCXX.h:255
clang::ASTContext::LongLongTy
CanQualType LongLongTy
Definition: ASTContext.h:1084
clang::CodeGen::TBAAAccessInfo::Size
uint64_t Size
Size - The size of access, in bytes.
Definition: CodeGenTBAA.h:112
clang::Type::isPointerType
bool isPointerType() const
Definition: Type.h:6673
clang::syntax::NodeRole::Size
@ Size
clang::ASTContext::IntTy
CanQualType IntTy
Definition: ASTContext.h:1084
clang::ASTContext::Int128Ty
CanQualType Int128Ty
Definition: ASTContext.h:1084
clang::ASTContext::LongFractTy
CanQualType LongFractTy
Definition: ASTContext.h:1091
clang::RecordDecl::fields
field_range fields() const
Definition: Decl.h:4079
clang::Decl
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:89
clang::ASTContext::LongTy
CanQualType LongTy
Definition: ASTContext.h:1084
clang::TagDecl::isStruct
bool isStruct() const
Definition: Decl.h:3513
clang::RecordDecl::field_end
field_iterator field_end() const
Definition: Decl.h:4082
clang::LangOptions
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:58
clang::CodeGen::CodeGenTBAA::mergeTBAAInfoForCast
TBAAAccessInfo mergeTBAAInfoForCast(TBAAAccessInfo SourceInfo, TBAAAccessInfo TargetInfo)
mergeTBAAInfoForCast - Get merged TBAA information for the purpose of type casts.
Definition: CodeGenTBAA.cpp:424
clang::CodeGen::CodeGenTBAA::~CodeGenTBAA
~CodeGenTBAA()
Definition: CodeGenTBAA.cpp:40
clang::CodeGen::TBAAAccessInfo::Offset
uint64_t Offset
Offset - The byte offset of the final access within the base one.
Definition: CodeGenTBAA.h:109
clang
Definition: CalledOnceCheck.h:17
clang::Type::isArrayType
bool isArrayType() const
Definition: Type.h:6739
clang::ASTContext::toCharUnitsFromBits
CharUnits toCharUnitsFromBits(int64_t BitSize) const
Convert a size in bits to a size in characters.
Definition: ASTContext.cpp:2439
clang::ASTContext::SatFractTy
CanQualType SatFractTy
Definition: ASTContext.h:1096
clang::CodeGen::TBAAAccessInfo::getMayAliasInfo
static TBAAAccessInfo getMayAliasInfo()
Definition: CodeGenTBAA.h:63
clang::ASTContext::getASTRecordLayout
const ASTRecordLayout & getASTRecordLayout(const RecordDecl *D) const
Get or compute information about the layout of the specified record (struct/union/class) D,...
Definition: RecordLayoutBuilder.cpp:3246
Parent
NodeId Parent
Definition: ASTDiff.cpp:192
clang::ASTContext::ShortAccumTy
CanQualType ShortAccumTy
Definition: ASTContext.h:1088
Mangle.h
llvm::SmallVectorImpl
Definition: LLVM.h:39
clang::CodeGen::CodeGenTBAA::getAccessInfo
TBAAAccessInfo getAccessInfo(QualType AccessType)
getAccessInfo - Get TBAA information that describes an access to an object of the given type.
Definition: CodeGenTBAA.cpp:255
clang::EnumType
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums.
Definition: Type.h:4639
clang::ASTContext::SatShortFractTy
CanQualType SatShortFractTy
Definition: ASTContext.h:1096
clang::CodeGen::TBAAAccessInfo::AccessType
llvm::MDNode * AccessType
AccessType - The final access type.
Definition: CodeGenTBAA.h:105
clang::Type::isIncompleteType
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types,...
Definition: Type.cpp:2210
clang::CodeGen::CodeGenTBAA::mergeTBAAInfoForMemoryTransfer
TBAAAccessInfo mergeTBAAInfoForMemoryTransfer(TBAAAccessInfo DestInfo, TBAAAccessInfo SrcInfo)
mergeTBAAInfoForMemoryTransfer - Get merged TBAA information for the purpose of memory transfer calls...
Definition: CodeGenTBAA.cpp:450
CodeGenTBAA.h
clang::RecordDecl
Represents a struct/union/class.
Definition: Decl.h:3859
clang::ASTContext::ShortFractTy
CanQualType ShortFractTy
Definition: ASTContext.h:1091
clang::CharUnits::getQuantity
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
Definition: CharUnits.h:179
RecordLayout.h
clang::NamedDecl::getName
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
Definition: Decl.h:276