From c7b90947bd0179d914fea56b52be545c8f60f20a Mon Sep 17 00:00:00 2001 From: Evgeniy Stepanov Date: Wed, 26 Apr 2017 00:51:06 +0000 Subject: [PATCH] [asan] Unconditionally enable GC of globals on COFF. This change restores pre-r301225 behavior, where linker GC compatible global instrumentation was used on COFF targets disregarding -f(no-)data-sections and/or /Gw flags. This instrumentation puts each global in a COMDAT with an ASan descriptor for that global. It effectively enables -fdata-sections, but limits it to ASan-instrumented globals. llvm-svn: 301374 --- clang/lib/CodeGen/BackendUtil.cpp | 3 +-- clang/test/CodeGen/asan-globals-gc.cpp | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index 2f35423dd5df..85788b427208 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -196,9 +196,8 @@ static void addSanitizerCoveragePass(const PassManagerBuilder &Builder, static bool asanUseGlobalsGC(const Triple &T, const CodeGenOptions &CGOpts) { switch (T.getObjectFormat()) { case Triple::MachO: - return true; case Triple::COFF: - return CGOpts.DataSections; + return true; case Triple::ELF: return CGOpts.DataSections && !CGOpts.DisableIntegratedAS; default: diff --git a/clang/test/CodeGen/asan-globals-gc.cpp b/clang/test/CodeGen/asan-globals-gc.cpp index b492cebd2ce9..6d64f41dda8d 100644 --- a/clang/test/CodeGen/asan-globals-gc.cpp +++ b/clang/test/CodeGen/asan-globals-gc.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsanitize=address -emit-llvm -o - -triple x86_64-windows-msvc %s | FileCheck %s --check-prefix=WITHOUT-GC +// RUN: %clang_cc1 -fsanitize=address -emit-llvm -o - -triple x86_64-windows-msvc %s | FileCheck %s --check-prefix=WITH-GC // RUN: %clang_cc1 -fsanitize=address -emit-llvm -o - -triple x86_64-windows-msvc -fdata-sections %s | FileCheck %s --check-prefix=WITH-GC int global;