Skip to content

Commit 96bb057

Browse files
committed
[TBAA] Add bail-out to skip tbaa generation to getTBAAStructInfo. (llvm#84386)
Without this bail out, we may generate fields with null nodes as tags are generated by using getTypeInfo which has the same bail out. PR: llvm#84386 (cherry-picked from 83789ff)
1 parent 42853d0 commit 96bb057

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

clang/lib/CodeGen/CodeGenTBAA.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,9 @@ CodeGenTBAA::CollectFields(uint64_t BaseOffset,
340340

341341
llvm::MDNode *
342342
CodeGenTBAA::getTBAAStructInfo(QualType QTy) {
343+
if (CodeGenOpts.OptimizationLevel == 0 || CodeGenOpts.RelaxedAliasing)
344+
return nullptr;
345+
343346
const Type *Ty = Context.getCanonicalType(QTy).getTypePtr();
344347

345348
if (llvm::MDNode *N = StructMetadataCache[Ty])

clang/test/CodeGen/tbaa-struct-relaxed-aliasing-with-tsan.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
// RUN: FileCheck %s
66
//
77
// Check that we do not create tbaa for instructions generated for copies.
8-
// FIXME: !tbaa.struct is generated with null node as tag.
98

10-
// CHECK: !tbaa.struct
119
// CHECK-NOT: !tbaa
1210

1311
struct A {

0 commit comments

Comments
 (0)