[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:00:03 PDT 2018


morehouse added inline comments.


================
Comment at: llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp:409
     appendToUsed(M, GlobalsToAppendToUsed);
+    appendToCompilerUsed(M, GlobalsToAppendToCompilerUsed);
+  }
----------------
eugenis wrote:
> morehouse wrote:
> > eugenis wrote:
> > > morehouse wrote:
> > > > eugenis wrote:
> > > > > morehouse wrote:
> > > > > > eugenis wrote:
> > > > > > > this is unnecessary, llvm.used is strictly stronger than llvm.compiler.used
> > > > > > I'm not sure I understand...  We're appending different things to each list.
> > > > > Right. Sorry.
> > > > > A different question then: why only MachO?
> > > > Kostya mentioned his reasoning in http://lists.llvm.org/pipermail/llvm-dev/2017-September/117315.html.
> > > I don't understand that thread :(
> > > What I know is, without compiler.used, neither comdat nor !associated nor a named section would save pctable from the optimizer. Try passing this through opt -O3:
> > > 
> > > $a = comdat any
> > > @a = global i32 0, align 4, comdat($a)
> > > @b = internal global i32 0, align 4, section "abc", !associated !0, comdat($a)
> > > ; @llvm.compiler.used = appending global [1 x i8*] [i8* bitcast (i32* @b to i8*)]
> > > !0 = !{i32 *@a}
> > > 
> > `clang++ -fsanitize=fuzzer -O3 -S -emit-llvm -o-` shows the pc-tables still there.  But if I run the output of that through `opt -O3`, the pc-tables get stripped.
> > 
> > So maybe running directly through `opt` performs some stripping that otherwise wouldn't be done?
> Most optimizations are done before fuzzer instrumentation.
> Try with MSan, it adds a few more at the end.
With `-fsanitize=fuzzer,memory -O3`, the pc-tables are still there.

But either way, I don't think it would hurt to add pc-tables to llvm.compiler.used on all platforms.



https://reviews.llvm.org/D48203





More information about the llvm-commits mailing list