[clang] f18de76 - Update DynInit generation for ASan globals.

Mitch Phillips via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 11 12:24:00 PDT 2022


Author: Mitch Phillips
Date: 2022-07-11T12:23:37-07:00
New Revision: f18de7619e5d5dde301d8d4f6f3ec0f8260be710

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

LOG: Update DynInit generation for ASan globals.

Address a follow-up TODO for Sanitizer Metadata.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D128672

Added: 
    

Modified: 
    clang/lib/CodeGen/SanitizerMetadata.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/CodeGen/SanitizerMetadata.cpp b/clang/lib/CodeGen/SanitizerMetadata.cpp
index 5f4eb9be981f..0c752304b13d 100644
--- a/clang/lib/CodeGen/SanitizerMetadata.cpp
+++ b/clang/lib/CodeGen/SanitizerMetadata.cpp
@@ -64,13 +64,11 @@ void SanitizerMetadata::reportGlobal(llvm::GlobalVariable *GV,
   Meta.NoMemtag |= CGM.isInNoSanitizeList(
       FsanitizeArgument.Mask & SanitizerKind::MemTag, GV, Loc, Ty);
 
-  if (FsanitizeArgument.has(SanitizerKind::Address)) {
-    // TODO(hctim): Make this conditional when we migrate off llvm.asan.globals.
-    IsDynInit &= !CGM.isInNoSanitizeList(SanitizerKind::Address |
-                                             SanitizerKind::KernelAddress,
-                                         GV, Loc, Ty, "init");
-    Meta.IsDynInit = IsDynInit;
-  }
+  Meta.IsDynInit = IsDynInit && !Meta.NoAddress &&
+                   FsanitizeArgument.has(SanitizerKind::Address) &&
+                   !CGM.isInNoSanitizeList(SanitizerKind::Address |
+                                               SanitizerKind::KernelAddress,
+                                           GV, Loc, Ty, "init");
 
   GV->setSanitizerMetadata(Meta);
 }


        


More information about the cfe-commits mailing list