From: Justin Bogner Date: Fri, 25 Aug 2017 01:24:54 +0000 (+0000) Subject: [sanitizer-coverage] Make sure pc-tables aren't dead stripped X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=965445287b45049e7cb10cd1208ae077b79d3d65;p=llvm [sanitizer-coverage] Make sure pc-tables aren't dead stripped Add a reference to the PC array in llvm.used so that linkers that aggressively dead strip (like ld64) don't remove it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@311742 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/Instrumentation/SanitizerCoverage.cpp b/lib/Transforms/Instrumentation/SanitizerCoverage.cpp index c6f0d17f8fe..fdf265143fd 100644 --- a/lib/Transforms/Instrumentation/SanitizerCoverage.cpp +++ b/lib/Transforms/Instrumentation/SanitizerCoverage.cpp @@ -557,6 +557,10 @@ void SanitizerCoverageModule::CreatePCArray(Function &F, FunctionPCsArray->setInitializer( ConstantArray::get(ArrayType::get(Int8PtrTy, N), PCs)); FunctionPCsArray->setConstant(true); + + // We don't reference the PCs array in any of our runtime functions, so we + // need to prevent it from being dead stripped. + appendToUsed(*F.getParent(), {FunctionPCsArray}); } void SanitizerCoverageModule::CreateFunctionLocalArrays(