From: Matt Morehouse Date: Thu, 12 Jul 2018 20:24:58 +0000 (+0000) Subject: [SanitizerCoverage] Add associated metadata to 8-bit counters. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3418676967e14d46493469040af1a69e19bab3bb;p=llvm [SanitizerCoverage] Add associated metadata to 8-bit counters. Summary: This allows counters associated with unused functions to be dead-stripped along with their functions. This approach is the same one we used for PC tables. Fixes an issue where LLD removes an unused PC table but leaves the 8-bit counter. Reviewers: eugenis Reviewed By: eugenis Subscribers: llvm-commits, hiraditya, kcc Differential Revision: https://reviews.llvm.org/D49264 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@336941 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/Instrumentation/SanitizerCoverage.cpp b/lib/Transforms/Instrumentation/SanitizerCoverage.cpp index a9336381edd..a4dd48c8dd6 100644 --- a/lib/Transforms/Instrumentation/SanitizerCoverage.cpp +++ b/lib/Transforms/Instrumentation/SanitizerCoverage.cpp @@ -595,7 +595,9 @@ void SanitizerCoverageModule::CreateFunctionLocalArrays( if (Options.Inline8bitCounters) { Function8bitCounterArray = CreateFunctionLocalArrayInSection( AllBlocks.size(), F, Int8Ty, SanCovCountersSectionName); - GlobalsToAppendToUsed.push_back(Function8bitCounterArray); + GlobalsToAppendToCompilerUsed.push_back(Function8bitCounterArray); + MDNode *MD = MDNode::get(F.getContext(), ValueAsMetadata::get(&F)); + Function8bitCounterArray->addMetadata(LLVMContext::MD_associated, *MD); } if (Options.PCTable) { FunctionPCsArray = CreatePCArray(F, AllBlocks);