aboutsummaryrefslogtreecommitdiffhomepage
path: root/projects
diff options
context:
space:
mode:
authorGravatar igor-laevsky <igmyrj@gmail.com>2017-12-18 18:25:06 +0300
committerGravatar Abhishek Arya <inferno@chromium.org>2017-12-18 07:25:06 -0800
commit538b42a26c5f28cb656e792f4c88bc9fa27aa820 (patch)
treed60e0feffa6a801351cb8cc23cab5165aab61ad1 /projects
parent7c3acdbd4539d2a210d7c21c27631bb77747709d (diff)
[llvm][opt-instcombine] Generate corpus out of the llvm-lit tests for instcombine (#1041)
Diffstat (limited to 'projects')
-rw-r--r--projects/llvm/build.sh27
1 files changed, 27 insertions, 0 deletions
diff --git a/projects/llvm/build.sh b/projects/llvm/build.sh
index adaa54b2..380d414e 100644
--- a/projects/llvm/build.sh
+++ b/projects/llvm/build.sh
@@ -60,6 +60,7 @@ for fuzzer in "${FUZZERS[@]}"; do
ninja $fuzzer
cp bin/$fuzzer $OUT
done
+ninja llvm-as
# isel-fuzzer encodes its default flags in the name.
cp $OUT/llvm-isel-fuzzer $OUT/llvm-isel-fuzzer--aarch64-O2
@@ -67,3 +68,29 @@ cp $OUT/llvm-isel-fuzzer $OUT/llvm-isel-fuzzer--x86_64-O2
mv $OUT/llvm-isel-fuzzer $OUT/llvm-isel-fuzzer--aarch64-gisel
# Same for llvm-opt-fuzzer
mv $OUT/llvm-opt-fuzzer $OUT/llvm-opt-fuzzer--x86_64-instcombine
+
+# Build corpus for the llvm-opt-fuzzer
+function build_corpus {
+ local lit_path="${1}"
+ local fuzzer_name="${2}"
+
+ [[ -e "${WORK}/corpus-tmp" ]] && rm -r "${WORK}/corpus-tmp"
+ mkdir "${WORK}/corpus-tmp"
+
+ cd "${SRC}"
+
+ # Compile all lit tests into bitcode. Ignore possible llvm-as failures.
+ find "${lit_path}" -name "*.ll" -print0 |
+ xargs -t -i -0 -n1 sh -c "build/bin/llvm-as "{}" || true"
+
+ # Move freshly created bitcode into temp directory.
+ find "${lit_path}" -name "*.bc" -print0 |
+ xargs -t -i -0 -n1 mv "{}" "${WORK}/corpus-tmp"
+
+ # Archive the corpus.
+ zip -j "${OUT}/${fuzzer_name}_seed_corpus.zip" "${WORK}"/corpus-tmp/*
+
+ rm -r "${WORK}/corpus-tmp"
+}
+
+build_corpus "llvm/test/Transforms/InstCombine/" "llvm-opt-fuzzer--x86_64-instcombine"