[PATCH] D48203: [SanitizerCoverage] Add associated metadata to pc-tables.
Matt Morehouse via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 15 13:17:35 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL334858: [SanitizerCoverage] Add associated metadata to pc-tables. (authored by morehouse, committed by ).
Herald added a subscriber: delcypher.
Changed prior to commit:
https://reviews.llvm.org/D48203?vs=151547&id=151549#toc
Repository:
rL LLVM
https://reviews.llvm.org/D48203
Files:
compiler-rt/trunk/test/fuzzer/gc-sections.test
llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
Index: compiler-rt/trunk/test/fuzzer/gc-sections.test
===================================================================
--- compiler-rt/trunk/test/fuzzer/gc-sections.test
+++ compiler-rt/trunk/test/fuzzer/gc-sections.test
@@ -1,12 +1,12 @@
-REQUIRES: linux
+REQUIRES: linux, lld-available
No gc-sections:
RUN: %cpp_compiler %S/GcSectionsTest.cpp -o %t
RUN: nm %t | grep UnusedFunctionShouldBeRemovedByLinker | count 1
With gc-sections. Currently, we can't remove unused code.
-DISABLED: %cpp_compiler %S/GcSectionsTest.cpp -o %t -ffunction-sections -Wl,-gc-sections
-DISABLED: nm %t | grep UnusedFunctionShouldBeRemovedByLinker | count 1
+RUN: %cpp_compiler %S/GcSectionsTest.cpp -o %t -ffunction-sections -Wl,-gc-sections -fuse-ld=lld
+RUN: nm %t | not grep UnusedFunctionShouldBeRemovedByLinker
With gc sections, with trace-pc. Unused code is removed.
RUN: %cpp_compiler %S/GcSectionsTest.cpp -o %t -fsanitize-coverage=0 -fsanitize-coverage=trace-pc -ffunction-sections -Wl,-gc-sections
Index: llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
===================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
+++ llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
@@ -243,6 +243,7 @@
GlobalVariable *Function8bitCounterArray; // for inline-8bit-counters.
GlobalVariable *FunctionPCsArray; // for pc-table.
SmallVector<GlobalValue *, 20> GlobalsToAppendToUsed;
+ SmallVector<GlobalValue *, 20> GlobalsToAppendToCompilerUsed;
SanitizerCoverageOptions Options;
};
@@ -405,6 +406,7 @@
// so we need to prevent them from being dead stripped.
if (TargetTriple.isOSBinFormatMachO())
appendToUsed(M, GlobalsToAppendToUsed);
+ appendToCompilerUsed(M, GlobalsToAppendToCompilerUsed);
return true;
}
@@ -598,7 +600,9 @@
}
if (Options.PCTable) {
FunctionPCsArray = CreatePCArray(F, AllBlocks);
- GlobalsToAppendToUsed.push_back(FunctionPCsArray);
+ GlobalsToAppendToCompilerUsed.push_back(FunctionPCsArray);
+ MDNode *MD = MDNode::get(F.getContext(), ValueAsMetadata::get(&F));
+ FunctionPCsArray->addMetadata(LLVMContext::MD_associated, *MD);
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48203.151549.patch
Type: text/x-patch
Size: 2215 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180615/8e7fc97c/attachment.bin>
More information about the llvm-commits
mailing list