[PATCH] D48203: [SanitizerCoverage] Add associated metadata to pc-tables.

Matt Morehouse via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 14 18:49:25 PDT 2018


morehouse updated this revision to Diff 151449.
morehouse added a comment.

- Require LLD for gc-sections.test


https://reviews.llvm.org/D48203

Files:
  compiler-rt/test/fuzzer/gc-sections.test
  llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp


Index: llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
===================================================================
--- llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
+++ llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
@@ -598,7 +598,8 @@
   }
   if (Options.PCTable) {
     FunctionPCsArray = CreatePCArray(F, AllBlocks);
-    GlobalsToAppendToUsed.push_back(FunctionPCsArray);
+    MDNode *MD = MDNode::get(F.getContext(), ValueAsMetadata::get(&F));
+    FunctionPCsArray->addMetadata(LLVMContext::MD_associated, *MD);
   }
 }
 
Index: compiler-rt/test/fuzzer/gc-sections.test
===================================================================
--- compiler-rt/test/fuzzer/gc-sections.test
+++ compiler-rt/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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48203.151449.patch
Type: text/x-patch
Size: 1554 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180615/66114f8f/attachment.bin>


More information about the llvm-commits mailing list