<div dir="ltr"><a class="gmail_plusreply" id="plusReplyChip-0" href="mailto:mascasa@google.com" tabindex="-1">+Matt Morehouse</a> <a class="gmail_plusreply" id="plusReplyChip-1" href="mailto:justin@justinbogner.com" tabindex="-1">+Justin Bogner</a> <br></div><br><div class="gmail_quote"><div dir="ltr">On Wed, Aug 15, 2018 at 3:28 AM Jean-Pierre Münch via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello List,<br>
<br>
I'm currently writing my own little optimization pass (on LLVM 6.0) and<br>
considered it a neat idea to fuzz it using llvm-opt-fuzzer, which in<br>
theory should be a ready-made tool for such jobs as far as I can tell,<br>
potentially helping me to find UB and Address issues in my pass.<br>
<br>
So I went ahead and followed the instructions in the build manual [1] to<br>
build LLVM's llvm-opt-fuzzer as "RelWithDebInfo" with clang / clang++<br>
using my 18.04.1 LTS Ubuntu instance (and its default clang which is<br>
version 6.0). Then I tried to run llvm-opt-fuzzer and it complained that<br>
it wasn't linked to LibFuzzer and thus no fuzzing would be performed. So<br>
I hacked the Link.txt file for llvm-opt-fuzzer in my cmake build<br>
directory to add the -fsanitize=fuzzer flag and remove the dummy object<br>
file from linking. Now it would actually look at the corpus, but then<br>
immediately give up because<br>
<br>
"ERROR: no interesting inputs were found. Is the code instrumented for<br>
coverage? Exiting."<br>
<br>
at which point I'm lost because of my lack of experience with CMake and<br>
LibFuzzer I don't know how I can build LLVM with the required<br>
instrumentation.<br>
<br>
So my (first) question is:<br>
<br>
What are the proper arguments to pass to CMake to actually get<br>
llvm-opt-fuzzer to work as intended?<br>
<br>
Additionally my pass has the problem that it requires -loop-simplify<br>
being run beforehand (which can't be requested using<br>
AnalysisUsage.addRequired<>() apparently). So I tried to specify<br>
'-passes "loop-simplify mypass"' to llvm-opt-fuzzer but it was rejected<br>
because "./llvm-opt-fuzzer: can't parse pass pipeline". Naturally I<br>
tried to find any documentation for this format but a search would only<br>
show me the fact that LLVM applies all passes on a function / module<br>
before moving on to the next for locality reasons.<br>
<br>
So my (second) question is:<br>
<br>
What are the proper arguments to pass to llvm-opt-fuzzer to have it run<br>
more than one pass, e.g. first loop-simplify and then DCE?<br>
<br>
Alternate (third?) question:<br>
<br>
Is there any way to require the loops be in simplified form for your own<br>
pass short of re-implementing loop-simplify yourself in your pass?<br>
<br>
I hope somebody here can and is willing to help me.<br>
<br>
Kind Regards<br>
<br>
Jean-Pierre Münch<br>
<br>
[1]: <a href="https://llvm.org/docs/CMake.html" rel="noreferrer" target="_blank">https://llvm.org/docs/CMake.html</a><br>
<br>
P.S.: While on my above "adventure" I noticed that building LLVM with<br>
clang and -DLLVM_USE_SANITIZER="MemoryWithOrigins" fails to complete<br>
because it apparently detects a bug in one of the build helper tools.<br>
<br>
<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>