From f18de7619e5d5dde301d8d4f6f3ec0f8260be710 Mon Sep 17 00:00:00 2001 From: Mitch Phillips <31459023+hctim@users.noreply.github.com> Date: Mon, 11 Jul 2022 11:44:55 -0700 Subject: [PATCH] Update DynInit generation for ASan globals. Address a follow-up TODO for Sanitizer Metadata. Reviewed By: vitalybuka Differential Revision: https://reviews.llvm.org/D128672 --- clang/lib/CodeGen/SanitizerMetadata.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) 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); }