Coverage Report

Created: 2022-07-16 07:03

/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/lib/CodeGen/CodeGenTBAA.cpp
Line
Count
Source (jump to first uncovered line)
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"
22
#include "clang/Basic/CodeGenOptions.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
3.21k
{}
39
40
3.21k
CodeGenTBAA::~CodeGenTBAA() {
41
3.21k
}
42
43
3.51k
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
3.51k
  if (!Root) {
49
2.89k
    if (Features.CPlusPlus)
50
1.20k
      Root = MDHelper.createTBAARoot("Simple C++ TBAA");
51
1.69k
    else
52
1.69k
      Root = MDHelper.createTBAARoot("Simple C/C++ TBAA");
53
2.89k
  }
54
55
3.51k
  return Root;
56
3.51k
}
57
58
llvm::MDNode *CodeGenTBAA::createScalarTypeNode(StringRef Name,
59
                                                llvm::MDNode *Parent,
60
22.0k
                                                uint64_t Size) {
61
22.0k
  if (CodeGenOpts.NewStructPathTBAA) {
62
155
    llvm::Metadata *Id = MDHelper.createString(Name);
63
155
    return MDHelper.createTBAATypeNode(Parent, Size, Id);
64
155
  }
65
21.8k
  return MDHelper.createTBAAScalarTypeNode(Name, Parent);
66
22.0k
}
67
68
20.8k
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
20.8k
  if (!Char)
74
2.89k
    Char = createScalarTypeNode("omnipotent char", getRoot(), /* Size= */ 1);
75
76
20.8k
  return Char;
77
20.8k
}
78
79
403k
static bool TypeHasMayAlias(QualType QTy) {
80
  // Tagged types have declarations, and therefore may have attributes.
81
403k
  if (auto *TD = QTy->getAsTagDecl())
82
13.7k
    if (TD->hasAttr<MayAliasAttr>())
83
5
      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
970k
  
while (auto *403k
TT = QTy->getAs<TypedefType>()) {
89
567k
    if (TT->getDecl()->hasAttr<MayAliasAttr>())
90
11
      return true;
91
567k
    QTy = TT->desugar();
92
567k
  }
93
403k
  return false;
94
403k
}
95
96
/// Check if the given type is a valid base type to be used in access tags.
97
213k
static bool isValidBaseType(QualType QTy) {
98
213k
  if (QTy->isReferenceType())
99
1.33k
    return false;
100
212k
  if (const RecordType *TTy = QTy->getAs<RecordType>()) {
101
15.6k
    const RecordDecl *RD = TTy->getDecl()->getDefinition();
102
    // Incomplete types are not valid base access types.
103
15.6k
    if (!RD)
104
0
      return false;
105
15.6k
    if (RD->hasFlexibleArrayMember())
106
18
      return false;
107
    // RD can be struct, union, class, interface or enum.
108
    // For now, we only handle struct and class.
109
15.6k
    if (RD->isStruct() || 
RD->isClass()2.68k
)
110
15.4k
      return true;
111
15.6k
  }
112
197k
  return false;
113
212k
}
114
115
22.2k
llvm::MDNode *CodeGenTBAA::getTypeInfoHelper(const Type *Ty) {
116
22.2k
  uint64_t Size = Context.getTypeSizeInChars(Ty).getQuantity();
117
118
  // Handle builtin types.
119
22.2k
  if (const BuiltinType *BTy = dyn_cast<BuiltinType>(Ty)) {
120
16.6k
    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
9
    case BuiltinType::Char_U:
127
82
    case BuiltinType::Char_S:
128
486
    case BuiltinType::UChar:
129
915
    case BuiltinType::SChar:
130
915
      return getChar();
131
132
    // Unsigned types can alias their corresponding signed types.
133
429
    case BuiltinType::UShort:
134
429
      return getTypeInfo(Context.ShortTy);
135
617
    case BuiltinType::UInt:
136
617
      return getTypeInfo(Context.IntTy);
137
475
    case BuiltinType::ULong:
138
475
      return getTypeInfo(Context.LongTy);
139
43
    case BuiltinType::ULongLong:
140
43
      return getTypeInfo(Context.LongLongTy);
141
2
    case BuiltinType::UInt128:
142
2
      return getTypeInfo(Context.Int128Ty);
143
144
1
    case BuiltinType::UShortFract:
145
1
      return getTypeInfo(Context.ShortFractTy);
146
1
    case BuiltinType::UFract:
147
1
      return getTypeInfo(Context.FractTy);
148
1
    case BuiltinType::ULongFract:
149
1
      return getTypeInfo(Context.LongFractTy);
150
151
1
    case BuiltinType::SatUShortFract:
152
1
      return getTypeInfo(Context.SatShortFractTy);
153
1
    case BuiltinType::SatUFract:
154
1
      return getTypeInfo(Context.SatFractTy);
155
1
    case BuiltinType::SatULongFract:
156
1
      return getTypeInfo(Context.SatLongFractTy);
157
158
1
    case BuiltinType::UShortAccum:
159
1
      return getTypeInfo(Context.ShortAccumTy);
160
1
    case BuiltinType::UAccum:
161
1
      return getTypeInfo(Context.AccumTy);
162
1
    case BuiltinType::ULongAccum:
163
1
      return getTypeInfo(Context.LongAccumTy);
164
165
1
    case BuiltinType::SatUShortAccum:
166
1
      return getTypeInfo(Context.SatShortAccumTy);
167
1
    case BuiltinType::SatUAccum:
168
1
      return getTypeInfo(Context.SatAccumTy);
169
1
    case BuiltinType::SatULongAccum:
170
1
      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
14.1k
    default:
176
14.1k
      return createScalarTypeNode(BTy->getName(Features), getChar(), Size);
177
16.6k
    }
178
16.6k
  }
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
5.67k
  if (Ty->isStdByteType())
184
1
    return getChar();
185
186
  // Handle pointers and references.
187
  // TODO: Implement C++'s type "similarity" and consider dis-"similar"
188
  // pointers distinct.
189
5.67k
  if (Ty->isPointerType() || 
Ty->isReferenceType()2.09k
)
190
4.04k
    return createScalarTypeNode("any pointer", getChar(), Size);
191
192
  // Accesses to arrays are accesses to objects of their element types.
193
1.62k
  if (CodeGenOpts.NewStructPathTBAA && 
Ty->isArrayType()68
)
194
4
    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
1.62k
  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
24
    if (!Features.CPlusPlus || 
!ETy->getDecl()->isExternallyVisible()23
)
204
5
      return getChar();
205
206
19
    SmallString<256> OutName;
207
19
    llvm::raw_svector_ostream Out(OutName);
208
19
    MContext.mangleTypeName(QualType(ETy, 0), Out);
209
19
    return createScalarTypeNode(OutName, getChar(), Size);
210
24
  }
211
212
1.59k
  if (const auto *EIT = dyn_cast<BitIntType>(Ty)) {
213
310
    SmallString<256> OutName;
214
310
    llvm::raw_svector_ostream Out(OutName);
215
    // Don't specify signed/unsigned since integer types can alias despite sign
216
    // differences.
217
310
    Out << "_BitInt(" << EIT->getNumBits() << ')';
218
310
    return createScalarTypeNode(OutName, getChar(), Size);
219
310
  }
220
221
  // For now, handle any other kind of type conservatively.
222
1.28k
  return getChar();
223
1.59k
}
224
225
203k
llvm::MDNode *CodeGenTBAA::getTypeInfo(QualType QTy) {
226
  // At -O0 or relaxed aliasing, TBAA is not emitted for regular types.
227
203k
  if (CodeGenOpts.OptimizationLevel == 0 || 
CodeGenOpts.RelaxedAliasing203k
)
228
164
    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
203k
  if (TypeHasMayAlias(QTy))
233
0
    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
203k
  if (isValidBaseType(QTy))
242
6.61k
    return getBaseTypeInfo(QTy);
243
244
197k
  const Type *Ty = Context.getCanonicalType(QTy).getTypePtr();
245
197k
  if (llvm::MDNode *N = MetadataCache[Ty])
246
174k
    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
22.2k
  llvm::MDNode *TypeNode = getTypeInfoHelper(Ty);
252
22.2k
  return MetadataCache[Ty] = TypeNode;
253
197k
}
254
255
199k
TBAAAccessInfo CodeGenTBAA::getAccessInfo(QualType AccessType) {
256
  // Pointee values may have incomplete types, but they shall never be
257
  // dereferenced.
258
199k
  if (AccessType->isIncompleteType())
259
20
    return TBAAAccessInfo::getIncompleteInfo();
260
261
199k
  if (TypeHasMayAlias(AccessType))
262
16
    return TBAAAccessInfo::getMayAliasInfo();
263
264
199k
  uint64_t Size = Context.getTypeSizeInChars(AccessType).getQuantity();
265
199k
  return TBAAAccessInfo(getTypeInfo(AccessType), Size);
266
199k
}
267
268
622
TBAAAccessInfo CodeGenTBAA::getVTablePtrAccessInfo(llvm::Type *VTablePtrType) {
269
622
  llvm::DataLayout DL(&Module);
270
622
  unsigned Size = DL.getPointerTypeSize(VTablePtrType);
271
622
  return TBAAAccessInfo(createScalarTypeNode("vtable pointer", getRoot(), Size),
272
622
                        Size);
273
622
}
274
275
bool
276
CodeGenTBAA::CollectFields(uint64_t BaseOffset,
277
                           QualType QTy,
278
                           SmallVectorImpl<llvm::MDBuilder::TBAAStructField> &
279
                             Fields,
280
880
                           bool MayAlias) {
281
  /* Things not handled yet include: C++ base classes, bitfields, */
282
283
880
  if (const RecordType *TTy = QTy->getAs<RecordType>()) {
284
355
    const RecordDecl *RD = TTy->getDecl()->getDefinition();
285
355
    if (RD->hasFlexibleArrayMember())
286
2
      return false;
287
288
    // TODO: Handle C++ base classes.
289
353
    if (const CXXRecordDecl *Decl = dyn_cast<CXXRecordDecl>(RD))
290
122
      if (Decl->bases_begin() != Decl->bases_end())
291
23
        return false;
292
293
330
    const ASTRecordLayout &Layout = Context.getASTRecordLayout(RD);
294
295
330
    unsigned idx = 0;
296
330
    for (RecordDecl::field_iterator i = RD->field_begin(),
297
912
         e = RD->field_end(); i != e; 
++i, ++idx582
) {
298
582
      if ((*i)->isZeroSize(Context) || 
(*i)->isUnnamedBitfield()573
)
299
37
        continue;
300
545
      uint64_t Offset = BaseOffset +
301
545
                        Layout.getFieldOffset(idx) / Context.getCharWidth();
302
545
      QualType FieldQTy = i->getType();
303
545
      if (!CollectFields(Offset, FieldQTy, Fields,
304
545
                         MayAlias || TypeHasMayAlias(FieldQTy)))
305
0
        return false;
306
545
    }
307
330
    return true;
308
330
  }
309
310
  /* Otherwise, treat whatever it is as a field. */
311
525
  uint64_t Offset = BaseOffset;
312
525
  uint64_t Size = Context.getTypeSizeInChars(QTy).getQuantity();
313
525
  llvm::MDNode *TBAAType = MayAlias ? 
getChar()0
: getTypeInfo(QTy);
314
525
  llvm::MDNode *TBAATag = getAccessTagInfo(TBAAAccessInfo(TBAAType, Size));
315
525
  Fields.push_back(llvm::MDBuilder::TBAAStructField(Offset, Size, TBAATag));
316
525
  return true;
317
880
}
318
319
llvm::MDNode *
320
335
CodeGenTBAA::getTBAAStructInfo(QualType QTy) {
321
335
  const Type *Ty = Context.getCanonicalType(QTy).getTypePtr();
322
323
335
  if (llvm::MDNode *N = StructMetadataCache[Ty])
324
0
    return N;
325
326
335
  SmallVector<llvm::MDBuilder::TBAAStructField, 4> Fields;
327
335
  if (CollectFields(0, QTy, Fields, TypeHasMayAlias(QTy)))
328
310
    return MDHelper.createTBAAStructNode(Fields);
329
330
  // For now, handle any other kind of type conservatively.
331
25
  return StructMetadataCache[Ty] = nullptr;
332
335
}
333
334
1.42k
llvm::MDNode *CodeGenTBAA::getBaseTypeInfoHelper(const Type *Ty) {
335
1.42k
  if (auto *TTy = dyn_cast<RecordType>(Ty)) {
336
1.42k
    const RecordDecl *RD = TTy->getDecl()->getDefinition();
337
1.42k
    const ASTRecordLayout &Layout = Context.getASTRecordLayout(RD);
338
1.42k
    using TBAAStructField = llvm::MDBuilder::TBAAStructField;
339
1.42k
    SmallVector<TBAAStructField, 4> Fields;
340
1.42k
    if (const CXXRecordDecl *CXXRD = dyn_cast<CXXRecordDecl>(RD)) {
341
      // Handle C++ base classes. Non-virtual bases can treated a a kind of
342
      // field. Virtual bases are more complex and omitted, but avoid an
343
      // incomplete view for NewStructPathTBAA.
344
1.17k
      if (CodeGenOpts.NewStructPathTBAA && 
CXXRD->getNumVBases() != 047
)
345
3
        return BaseTypeMetadataCache[Ty] = nullptr;
346
1.16k
      for (const CXXBaseSpecifier &B : CXXRD->bases()) {
347
314
        if (B.isVirtual())
348
52
          continue;
349
262
        QualType BaseQTy = B.getType();
350
262
        const CXXRecordDecl *BaseRD = BaseQTy->getAsCXXRecordDecl();
351
262
        if (BaseRD->isEmpty())
352
62
          continue;
353
200
        llvm::MDNode *TypeNode = isValidBaseType(BaseQTy)
354
200
                                     ? getBaseTypeInfo(BaseQTy)
355
200
                                     : 
getTypeInfo(BaseQTy)0
;
356
200
        if (!TypeNode)
357
0
          return BaseTypeMetadataCache[Ty] = nullptr;
358
200
        uint64_t Offset = Layout.getBaseClassOffset(BaseRD).getQuantity();
359
200
        uint64_t Size =
360
200
            Context.getASTRecordLayout(BaseRD).getDataSize().getQuantity();
361
200
        Fields.push_back(
362
200
            llvm::MDBuilder::TBAAStructField(Offset, Size, TypeNode));
363
200
      }
364
      // The order in which base class subobjects are allocated is unspecified,
365
      // so may differ from declaration order. In particular, Itanium ABI will
366
      // allocate a primary base first.
367
      // Since we exclude empty subobjects, the objects are not overlapping and
368
      // their offsets are unique.
369
1.16k
      llvm::sort(Fields,
370
1.16k
                 [](const TBAAStructField &A, const TBAAStructField &B) {
371
34
                   return A.Offset < B.Offset;
372
34
                 });
373
1.16k
    }
374
1.54k
    
for (FieldDecl *Field : RD->fields())1.41k
{
375
1.54k
      if (Field->isZeroSize(Context) || 
Field->isUnnamedBitfield()1.50k
)
376
77
        continue;
377
1.46k
      QualType FieldQTy = Field->getType();
378
1.46k
      llvm::MDNode *TypeNode = isValidBaseType(FieldQTy) ?
379
1.27k
          
getBaseTypeInfo(FieldQTy)188
: getTypeInfo(FieldQTy);
380
1.46k
      if (!TypeNode)
381
4
        return BaseTypeMetadataCache[Ty] = nullptr;
382
383
1.46k
      uint64_t BitOffset = Layout.getFieldOffset(Field->getFieldIndex());
384
1.46k
      uint64_t Offset = Context.toCharUnitsFromBits(BitOffset).getQuantity();
385
1.46k
      uint64_t Size = Context.getTypeSizeInChars(FieldQTy).getQuantity();
386
1.46k
      Fields.push_back(llvm::MDBuilder::TBAAStructField(Offset, Size,
387
1.46k
                                                        TypeNode));
388
1.46k
    }
389
390
1.41k
    SmallString<256> OutName;
391
1.41k
    if (Features.CPlusPlus) {
392
      // Don't use the mangler for C code.
393
1.16k
      llvm::raw_svector_ostream Out(OutName);
394
1.16k
      MContext.mangleTypeName(QualType(Ty, 0), Out);
395
1.16k
    } else {
396
251
      OutName = RD->getName();
397
251
    }
398
399
1.41k
    if (CodeGenOpts.NewStructPathTBAA) {
400
43
      llvm::MDNode *Parent = getChar();
401
43
      uint64_t Size = Context.getTypeSizeInChars(Ty).getQuantity();
402
43
      llvm::Metadata *Id = MDHelper.createString(OutName);
403
43
      return MDHelper.createTBAATypeNode(Parent, Size, Id, Fields);
404
43
    }
405
406
    // Create the struct type node with a vector of pairs (offset, type).
407
1.37k
    SmallVector<std::pair<llvm::MDNode*, uint64_t>, 4> OffsetsAndTypes;
408
1.37k
    for (const auto &Field : Fields)
409
1.56k
        OffsetsAndTypes.push_back(std::make_pair(Field.Type, Field.Offset));
410
1.37k
    return MDHelper.createTBAAStructTypeNode(OutName, OffsetsAndTypes);
411
1.41k
  }
412
413
0
  return nullptr;
414
1.42k
}
415
416
8.43k
llvm::MDNode *CodeGenTBAA::getBaseTypeInfo(QualType QTy) {
417
8.43k
  if (!isValidBaseType(QTy))
418
0
    return nullptr;
419
420
8.43k
  const Type *Ty = Context.getCanonicalType(QTy).getTypePtr();
421
8.43k
  if (llvm::MDNode *N = BaseTypeMetadataCache[Ty])
422
7.01k
    return N;
423
424
  // Note that the following helper call is allowed to add new nodes to the
425
  // cache, which invalidates all its previously obtained iterators. So we
426
  // first generate the node for the type and then add that node to the cache.
427
1.42k
  llvm::MDNode *TypeNode = getBaseTypeInfoHelper(Ty);
428
1.42k
  return BaseTypeMetadataCache[Ty] = TypeNode;
429
8.43k
}
430
431
192k
llvm::MDNode *CodeGenTBAA::getAccessTagInfo(TBAAAccessInfo Info) {
432
192k
  assert(!Info.isIncomplete() && "Access to an object of an incomplete type!");
433
434
192k
  if (Info.isMayAlias())
435
49
    Info = TBAAAccessInfo(getChar(), Info.Size);
436
437
192k
  if (!Info.AccessType)
438
174
    return nullptr;
439
440
192k
  if (!CodeGenOpts.StructPathTBAA)
441
281
    Info = TBAAAccessInfo(Info.AccessType, Info.Size);
442
443
192k
  llvm::MDNode *&N = AccessTagMetadataCache[Info];
444
192k
  if (N)
445
175k
    return N;
446
447
16.6k
  if (!Info.BaseType) {
448
16.2k
    Info.BaseType = Info.AccessType;
449
16.2k
    assert(!Info.Offset && "Nonzero offset for an access with no base type!");
450
16.2k
  }
451
16.6k
  if (CodeGenOpts.NewStructPathTBAA) {
452
126
    return N = MDHelper.createTBAAAccessTag(Info.BaseType, Info.AccessType,
453
126
                                            Info.Offset, Info.Size);
454
126
  }
455
16.5k
  return N = MDHelper.createTBAAStructTagNode(Info.BaseType, Info.AccessType,
456
16.5k
                                              Info.Offset);
457
16.6k
}
458
459
TBAAAccessInfo CodeGenTBAA::mergeTBAAInfoForCast(TBAAAccessInfo SourceInfo,
460
468
                                                 TBAAAccessInfo TargetInfo) {
461
468
  if (SourceInfo.isMayAlias() || TargetInfo.isMayAlias())
462
0
    return TBAAAccessInfo::getMayAliasInfo();
463
468
  return TargetInfo;
464
468
}
465
466
TBAAAccessInfo
467
CodeGenTBAA::mergeTBAAInfoForConditionalOperator(TBAAAccessInfo InfoA,
468
10
                                                 TBAAAccessInfo InfoB) {
469
10
  if (InfoA == InfoB)
470
8
    return InfoA;
471
472
2
  if (!InfoA || !InfoB)
473
0
    return TBAAAccessInfo();
474
475
2
  if (InfoA.isMayAlias() || 
InfoB.isMayAlias()1
)
476
2
    return TBAAAccessInfo::getMayAliasInfo();
477
478
  // TODO: Implement the rest of the logic here. For example, two accesses
479
  // with same final access types result in an access to an object of that final
480
  // access type regardless of their base types.
481
0
  return TBAAAccessInfo::getMayAliasInfo();
482
2
}
483
484
TBAAAccessInfo
485
CodeGenTBAA::mergeTBAAInfoForMemoryTransfer(TBAAAccessInfo DestInfo,
486
0
                                            TBAAAccessInfo SrcInfo) {
487
0
  if (DestInfo == SrcInfo)
488
0
    return DestInfo;
489
490
0
  if (!DestInfo || !SrcInfo)
491
0
    return TBAAAccessInfo();
492
493
0
  if (DestInfo.isMayAlias() || SrcInfo.isMayAlias())
494
0
    return TBAAAccessInfo::getMayAliasInfo();
495
496
  // TODO: Implement the rest of the logic here. For example, two accesses
497
  // with same final access types result in an access to an object of that final
498
  // access type regardless of their base types.
499
0
  return TBAAAccessInfo::getMayAliasInfo();
500
0
}