[clang] 83789ff - [TBAA] Add bail-out to skip tbaa generation to getTBAAStructInfo. (#84386)

via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 8 12:43:38 PST 2024


Author: Florian Hahn
Date: 2024-03-08T20:43:35Z
New Revision: 83789ffbd857bb78b69d6e54560310ff2d347f04

URL: https://github.com/llvm/llvm-project/commit/83789ffbd857bb78b69d6e54560310ff2d347f04
DIFF: https://github.com/llvm/llvm-project/commit/83789ffbd857bb78b69d6e54560310ff2d347f04.diff

LOG: [TBAA] Add bail-out to skip tbaa generation to getTBAAStructInfo. (#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: https://github.com/llvm/llvm-project/pull/84386

Added: 
    

Modified: 
    clang/lib/CodeGen/CodeGenTBAA.cpp
    clang/test/CodeGen/tbaa-struct-relaxed-aliasing-with-tsan.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/CodeGen/CodeGenTBAA.cpp b/clang/lib/CodeGen/CodeGenTBAA.cpp
index 8a081612193978..1f07205a5af225 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 931ff2476cd1bb..ce613b9d6b23f8 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 {


        


More information about the cfe-commits mailing list