diff --git a/clang/lib/CodeGen/CodeGenTBAA.cpp b/clang/lib/CodeGen/CodeGenTBAA.cpp index 8a08161219397..1f07205a5af22 100644 --- a/clang/lib/CodeGen/CodeGenTBAA.cpp +++ b/clang/lib/CodeGen/CodeGenTBAA.cpp @@ -343,6 +343,9 @@ CodeGenTBAA::CollectFields(uint64_t BaseOffset, llvm::MDNode * CodeGenTBAA::getTBAAStructInfo(QualType QTy) { + if (CodeGenOpts.OptimizationLevel == 0 || CodeGenOpts.RelaxedAliasing) + return nullptr; + const Type *Ty = Context.getCanonicalType(QTy).getTypePtr(); if (llvm::MDNode *N = StructMetadataCache[Ty]) diff --git a/clang/test/CodeGen/tbaa-struct-relaxed-aliasing-with-tsan.cpp b/clang/test/CodeGen/tbaa-struct-relaxed-aliasing-with-tsan.cpp index 931ff2476cd1b..ce613b9d6b23f 100644 --- a/clang/test/CodeGen/tbaa-struct-relaxed-aliasing-with-tsan.cpp +++ b/clang/test/CodeGen/tbaa-struct-relaxed-aliasing-with-tsan.cpp @@ -5,9 +5,7 @@ // RUN: FileCheck %s // // Check that we do not create tbaa for instructions generated for copies. -// FIXME: !tbaa.struct is generated with null node as tag. -// CHECK: !tbaa.struct // CHECK-NOT: !tbaa struct A {