From 965445287b45049e7cb10cd1208ae077b79d3d65 Mon Sep 17 00:00:00 2001 From: Justin Bogner Date: Fri, 25 Aug 2017 01:24:54 +0000 Subject: [PATCH] [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 --- lib/Transforms/Instrumentation/SanitizerCoverage.cpp | 4 ++++ 1 file changed, 4 insertions(+) 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( -- 2.50.1