Commit 50e0a92a authored by nagayama15's avatar nagayama15

Function挿入順変更手法の埋め込み実験を追加

parent 96284a67
......@@ -77,7 +77,8 @@ ${OBJ_DIR}/stage1-wm/%.o: 8cc/%.c
clang ${CFLAGS} -S -emit-llvm -o ${@:%.o=%.ll} $<
opt -load=${ROOT}/bin/${BUILD_TYPE}/src/nykk.so -block-wm -watermark=${WATERMARK} -S -o ${@:%.o=%-block-wm.ll} ${@:%.o=%.ll} 2> ${@:%.o=%-block-wm.txt}
opt -load=${ROOT}/bin/${BUILD_TYPE}/src/nykk.so -inst-wm -watermark=${WATERMARK} -S -o ${@:%.o=%-inst-wm.ll} ${@:%.o=%-block-wm.ll} 2> ${@:%.o=%-inst-wm.txt}
clang ${CFLAGS} -o $@ -c ${@:%.o=%-inst-wm.ll}
opt -load=${ROOT}/bin/${BUILD_TYPE}/src/nykk.so -func-wm -watermark=${WATERMARK} -S -o ${@:%.o=%-func-wm.ll} ${@:%.o=%-inst-wm.ll} 2> ${@:%.o=%-func-wm.txt}
clang ${CFLAGS} -o $@ -c ${@:%.o=%-func-wm.ll}
${OBJ_DIR}/stage2-wm/%.o: 8cc/%.c ${BIN_DIR}/stage1-wm/8cc.out
@mkdir -p ${@D}
......
......@@ -42,4 +42,5 @@ ${OBJ_DIR}/%.ll: cJSON/%.c
%-wm.ll: %.ll
opt -load=${ROOT}/bin/${BUILD_TYPE}/src/nykk.so -block-wm -watermark=${WATERMARK} -S -o ${@:%-wm.ll=%-block-wm.ll} $< 2> ${@:%-wm.ll=%-block-wm.txt}
opt -load=${ROOT}/bin/${BUILD_TYPE}/src/nykk.so -inst-wm -watermark=${WATERMARK} -S -o $@ ${@:%-wm.ll=%-block-wm.ll} 2> ${@:%-wm.ll=%-inst-wm.txt}
opt -load=${ROOT}/bin/${BUILD_TYPE}/src/nykk.so -inst-wm -watermark=${WATERMARK} -S -o ${@:%-wm.ll=%-inst-wm.ll} ${@:%-wm.ll=%-block-wm.ll} 2> ${@:%-wm.ll=%-inst-wm.txt}
opt -load=${ROOT}/bin/${BUILD_TYPE}/src/nykk.so -func-wm -watermark=${WATERMARK} -S -o $@ ${@:%-wm.ll=%-inst-wm.ll} 2> ${@:%-wm.ll=%-func-wm.txt}
......@@ -26,7 +26,8 @@ ${OBJ_DIR}/fizzbuzz.ll: fizzbuzz.rs
${OBJ_DIR}/fizzbuzz-wm.ll: ${OBJ_DIR}/fizzbuzz.ll
@mkdir -p ${@D}
opt -load=${ROOT}/bin/${BUILD_TYPE}/src/nykk.so -block-wm -watermark=rust-project -S -o ${@:%-wm.ll=%-block.ll} $< 2> ${@:%-wm.ll=%-block-wm.txt}
opt -load=${ROOT}/bin/${BUILD_TYPE}/src/nykk.so -inst-wm -watermark=rust-project -S -o $@ ${@:%-wm.ll=%-block.ll} 2> ${@:%-wm.ll=%-inst-wm.txt}
opt -load=${ROOT}/bin/${BUILD_TYPE}/src/nykk.so -inst-wm -watermark=rust-project -S -o ${@:%-wm.ll=%-inst.ll} ${@:%-wm.ll=%-block.ll} 2> ${@:%-wm.ll=%-inst-wm.txt}
opt -load=${ROOT}/bin/${BUILD_TYPE}/src/nykk.so -func-wm -watermark=rust-project -S -o $@ ${@:%-wm.ll=%-inst.ll} 2> ${@:%-wm.ll=%-func-wm.txt}
${OBJ_DIR}/probestack.o: probestack.s
@mkdir -p ${@D}
......
......@@ -13,12 +13,16 @@ LLS_0 := ${LLS:%.ll=%-0.ll}
LLS_1 := ${LLS:%.ll=%-1.ll}
LLS_2 := ${LLS:%.ll=%-2.ll}
LLS_3 := ${LLS:%.ll=%-3.ll}
LLS_4 := ${LLS:%.ll=%-4.ll}
LLS_5 := ${LLS:%.ll=%-5.ll}
BINS := \
${LLS:${OBJ_DIR}/%.ll=${BIN_DIR}/%.out} \
${LLS_0:${OBJ_DIR}/%.ll=${BIN_DIR}/%.out} \
${LLS_1:${OBJ_DIR}/%.ll=${BIN_DIR}/%.out} \
${LLS_2:${OBJ_DIR}/%.ll=${BIN_DIR}/%.out} \
${LLS_3:${OBJ_DIR}/%.ll=${BIN_DIR}/%.out}
${LLS_3:${OBJ_DIR}/%.ll=${BIN_DIR}/%.out} \
${LLS_4:${OBJ_DIR}/%.ll=${BIN_DIR}/%.out} \
${LLS_5:${OBJ_DIR}/%.ll=${BIN_DIR}/%.out}
all: ${BINS}
......@@ -27,7 +31,7 @@ test: ${BINS}
do $$i > $$i.txt; \
done
${BINS}: ${LLS} ${LLS_0} ${LLS_1} ${LLS_2} ${LLS_3}
${BINS}: ${LLS} ${LLS_0} ${LLS_1} ${LLS_2} ${LLS_3} ${LLS_4} ${LLS_5}
${OBJ_DIR}/%.ll: %.c
@mkdir -p ${@D}
......@@ -41,6 +45,10 @@ ${OBJ_DIR}/%.ll: %.c
opt -load=${ROOT}/bin/${BUILD_TYPE}/src/nykk.so -inst-wm -watermark=2 -S -o $@ $< 2> ${@:.ll=.txt}
%-3.ll: %.ll
opt -load=${ROOT}/bin/${BUILD_TYPE}/src/nykk.so -inst-wm -watermark=3 -S -o $@ $< 2> ${@:.ll=.txt}
%-4.ll: %.ll
opt -load=${ROOT}/bin/${BUILD_TYPE}/src/nykk.so -func-wm -watermark=4 -S -o $@ $< 2> ${@:.ll=.txt}
%-5.ll: %.ll
opt -load=${ROOT}/bin/${BUILD_TYPE}/src/nykk.so -func-wm -watermark=5 -S -o $@ $< 2> ${@:.ll=.txt}
${BIN_DIR}/%.out: ${OBJ_DIR}/%.ll
@mkdir -p ${@D}
......
......@@ -69,4 +69,5 @@ ${OBJ_DIR}/%.o: ${OBJ_DIR}/%.ll
${OBJ_DIR}/%-wm.ll: ${OBJ_DIR}/%.ll
opt -load=${ROOT}/bin/${BUILD_TYPE}/src/nykk.so -block-wm -watermark=${WATERMARK} -S -o ${@:%-wm.ll=%-block-wm.ll} $< 2> ${@:%-wm.ll=%-block-wm.txt}
opt -load=${ROOT}/bin/${BUILD_TYPE}/src/nykk.so -inst-wm -watermark=${WATERMARK} -S -o $@ ${@:%-wm.ll=%-block-wm.ll} 2> ${@:%-wm.ll=%-inst-wm.txt}
opt -load=${ROOT}/bin/${BUILD_TYPE}/src/nykk.so -inst-wm -watermark=${WATERMARK} -S -o ${@:%-wm.ll=%-inst-wm.ll} ${@:%-wm.ll=%-block-wm.ll} 2> ${@:%-wm.ll=%-inst-wm.txt}
opt -load=${ROOT}/bin/${BUILD_TYPE}/src/nykk.so -func-wm -watermark=${WATERMARK} -S -o $@ ${@:%-wm.ll=%-inst-wm.ll} 2> ${@:%-wm.ll=%-func-wm.txt}
......@@ -76,4 +76,5 @@ ${OBJ_DIR}/%.ll: lua/%.c
%-wm.ll: %.ll
opt -load=${ROOT}/bin/${BUILD_TYPE}/src/nykk.so -block-wm -watermark=${WATERMARK} -S -o ${@:%-wm.ll=%-block-wm.ll} $< 2> ${@:%-wm.ll=%-block-wm.txt}
opt -load=${ROOT}/bin/${BUILD_TYPE}/src/nykk.so -inst-wm -watermark=${WATERMARK} -S -o $@ ${@:%-wm.ll=%-block-wm.ll} 2> ${@:%-wm.ll=%-inst-wm.txt}
opt -load=${ROOT}/bin/${BUILD_TYPE}/src/nykk.so -inst-wm -watermark=${WATERMARK} -S -o ${@:%-wm.ll=%-inst-wm.ll} ${@:%-wm.ll=%-block-wm.ll} 2> ${@:%-wm.ll=%-inst-wm.txt}
opt -load=${ROOT}/bin/${BUILD_TYPE}/src/nykk.so -func-wm -watermark=${WATERMARK} -S -o $@ ${@:%-wm.ll=%-inst-wm.ll} 2> ${@:%-wm.ll=%-func-wm.txt}
......@@ -27,7 +27,8 @@ target/release/deps/*.ll:
${OBJ_DIR}/numguess-wm.ll: ${OBJ_DIR}/numguess.ll
@mkdir -p ${@D}
opt -load=${ROOT}/bin/${BUILD_TYPE}/src/nykk.so -block-wm -watermark=rust-project -S -o ${@:%-wm.ll=%-block.ll} $< 2> ${@:%-wm.ll=%-block-wm.txt}
opt -load=${ROOT}/bin/${BUILD_TYPE}/src/nykk.so -inst-wm -watermark=rust-project -S -o $@ ${@:%-wm.ll=%-block.ll} 2> ${@:%-wm.ll=%-inst-wm.txt}
opt -load=${ROOT}/bin/${BUILD_TYPE}/src/nykk.so -inst-wm -watermark=rust-project -S -o ${@:%-wm.ll=%-inst.ll} ${@:%-wm.ll=%-block.ll} 2> ${@:%-wm.ll=%-inst-wm.txt}
opt -load=${ROOT}/bin/${BUILD_TYPE}/src/nykk.so -func-wm -watermark=rust-project -S -o $@ ${@:%-wm.ll=%-inst.ll} 2> ${@:%-wm.ll=%-func-wm.txt}
${OBJ_DIR}/probestack.o: probestack.s
@mkdir -p ${@D}
......
......@@ -49,4 +49,5 @@ ${OBJ_DIR}/%.ll: tree/%.c
%-wm.ll: %.ll
opt -load=${ROOT}/bin/${BUILD_TYPE}/src/nykk.so -block-wm -watermark=${WATERMARK} -S -o ${@:%-wm.ll=%-block-wm.ll} $< 2> ${@:%-wm.ll=%-block-wm.txt}
opt -load=${ROOT}/bin/${BUILD_TYPE}/src/nykk.so -inst-wm -watermark=${WATERMARK} -S -o $@ ${@:%-wm.ll=%-block-wm.ll} 2> ${@:%-wm.ll=%-inst-wm.txt}
opt -load=${ROOT}/bin/${BUILD_TYPE}/src/nykk.so -inst-wm -watermark=${WATERMARK} -S -o ${@:%-wm.ll=%-inst-wm.ll} ${@:%-wm.ll=%-block-wm.ll} 2> ${@:%-wm.ll=%-inst-wm.txt}
opt -load=${ROOT}/bin/${BUILD_TYPE}/src/nykk.so -func-wm -watermark=${WATERMARK} -S -o $@ ${@:%-wm.ll=%-inst-wm.ll} 2> ${@:%-wm.ll=%-func-wm.txt}
......@@ -45,30 +45,30 @@ define watermark
.PRECIOUS: \
$${SRCS:zlib/%.c=$${OBJ_DIR}/$1/%-block-wm.ll} \
$${SRCS:zlib/%.c=$${OBJ_DIR}/$1/%-inst-wm.ll} \
$${SRCS:zlib/%.c=$${OBJ_DIR}/$1/%-wm.ll}
$${SRCS:zlib/%.c=$${OBJ_DIR}/$1/%-func-wm.ll}
all: \
$${BIN_DIR}/$1/benchmark-block-wm \
$${BIN_DIR}/$1/benchmark-inst-wm \
$${BIN_DIR}/$1/benchmark-wm
$${BIN_DIR}/$1/benchmark-func-wm
test: \
$${BIN_DIR}/$1/benchmark-block-wm \
$${BIN_DIR}/$1/benchmark-inst-wm \
$${BIN_DIR}/$1/benchmark-wm
$${BIN_DIR}/$1/benchmark-func-wm
benchmark:: \
$${BIN_DIR}/$1/benchmark-block-wm \
$${BIN_DIR}/$1/benchmark-inst-wm \
$${BIN_DIR}/$1/benchmark-wm
$${BIN_DIR}/$1/benchmark-func-wm
$${BIN_DIR}/$1/benchmark-block-wm | tee $${BIN_DIR}/$1/benchmark-block-wm.txt
$${BIN_DIR}/$1/benchmark-inst-wm | tee $${BIN_DIR}/$1/benchmark-inst-wm.txt
$${BIN_DIR}/$1/benchmark-wm | tee $${BIN_DIR}/$1/benchmark-wm.txt
paste -d "\t" $${BIN_DIR}/benchmark.txt $${BIN_DIR}/$1/benchmark-block-wm.txt $${BIN_DIR}/$1/benchmark-inst-wm.txt $${BIN_DIR}/$1/benchmark-wm.txt > $${BIN_DIR}/$1/benchmark.csv
$${BIN_DIR}/$1/benchmark-func-wm | tee $${BIN_DIR}/$1/benchmark-func-wm.txt
paste -d "\t" $${BIN_DIR}/benchmark.txt $${BIN_DIR}/$1/benchmark-block-wm.txt $${BIN_DIR}/$1/benchmark-inst-wm.txt $${BIN_DIR}/$1/benchmark-func-wm.txt > $${BIN_DIR}/$1/benchmark.csv
$${BIN_DIR}/$1/libz-block-wm.a: $${SRCS:zlib/%.c=$${OBJ_DIR}/$1/%-block-wm.o}
$${BIN_DIR}/$1/libz-inst-wm.a: $${SRCS:zlib/%.c=$${OBJ_DIR}/$1/%-inst-wm.o}
$${BIN_DIR}/$1/libz-wm.a: $${SRCS:zlib/%.c=$${OBJ_DIR}/$1/%-wm.o}
$${BIN_DIR}/$1/libz-func-wm.a: $${SRCS:zlib/%.c=$${OBJ_DIR}/$1/%-func-wm.o}
$${BIN_DIR}/$1/benchmark-%: $${OBJ_DIR}/benchmark.o $${BIN_DIR}/$1/libz-%.a
@mkdir -p $${@D}
......@@ -82,11 +82,18 @@ $${OBJ_DIR}/$1/%-inst-wm.ll: $${OBJ_DIR}/%.ll
@mkdir -p $${@D}
opt -load=$${ROOT}/bin/$${BUILD_TYPE}/src/nykk.so -inst-wm -watermark="$1" -S -o $$@ $$< 2> $${@:%.ll=%.txt}
$${OBJ_DIR}/$1/%-wm.ll: $${OBJ_DIR}/$1/%-block-wm.ll
opt -load=$${ROOT}/bin/$${BUILD_TYPE}/src/nykk.so -inst-wm -watermark="$1" -S -o $$@ $$< 2> /dev/null
$${OBJ_DIR}/$1/%-func-wm.ll: $${OBJ_DIR}/%.ll
@mkdir -p $${@D}
opt -load=$${ROOT}/bin/$${BUILD_TYPE}/src/nykk.so -func-wm -watermark="$1" -S -o $$@ $$< 2> $${@:%.ll=%.txt}
$${OBJ_DIR}/$1/%-block-wm.o: $${OBJ_DIR}/$1/%-block-wm.ll
clang -o $$@ -c $$<
$${OBJ_DIR}/$1/%.o: $${OBJ_DIR}/$1/%.ll
$${OBJ_DIR}/$1/%-inst-wm.o: $${OBJ_DIR}/$1/%-inst-wm.ll
clang -o $$@ -c $$<
$${OBJ_DIR}/$1/%-func-wm.o: $${OBJ_DIR}/$/%-func-wm.ll
clang $${CFLAGS} -o $$@ -c $$<
endef
.PRECIOUS: ${SRCS:zlib/%.c=${OBJ_DIR}/%.ll}
......
#!/bin/bash
# ==== block-wm ====
g1() {
FILE=$(basename ${1/-block-wm.txt/.c})
FUNCS=$(cat $1 | wc -l)
......@@ -22,6 +24,7 @@ h1() {
echo "$R" | awk '{f++; a+=$2; b+=$3; c+=$4} END {print "files: " f ", funcs: " a ", blocks: " b ", bits: " c}'
}
# ==== inst-wm ====
g2() {
FILE=$(basename ${1/-inst-wm.txt/.c})
INSTS=$(awk '{a+=$2} END {print a}' $1)
......@@ -44,6 +47,30 @@ h2() {
echo "$R" | awk '{f++; a+=$2; b+=$3} END {print "files: " f ", insts: " a ", bits: " b}'
}
# ==== func-wm ====
g3() {
FILE=$(basename ${1/-func-wm.txt/.c})
FUNCS=$(awk '{a+=$2} END {print a}' $1)
BITS=$(awk '{a+=$3} END {print a}' $1)
echo "$FILE, $FUNCS, $BITS"
}
f3() {
for i in "$@"
do g3 $i
done
}
h3() {
R=$(f3 $@)
echo "file, funcs, bits"
echo "$R"
echo "$R" | awk '{f++; a+=$2; b+=$3} END {print "files: " f ", funcs: " a ", bits: " b}'
}
echo "********************************************************"
echo "==== 8cc block-wm ===="
h1 obj/$1/example/8cc/stage1-wm/*-block-wm.txt
echo "==== zlib block-wm ===="
......@@ -61,6 +88,7 @@ h1 obj/$1/example/fizzbuzz-rs/*-block-wm.txt
echo "==== numguess-rs block-wm ===="
h1 obj/$1/example/numguess-rs/*-block-wm.txt
echo "********************************************************"
echo "==== 8cc inst-wm ===="
h2 obj/$1/example/8cc/stage1-wm/*-inst-wm.txt
echo "==== zlib inst-wm ===="
......@@ -77,3 +105,21 @@ echo "==== fizzbuzz-rs inst-wm ===="
h2 obj/$1/example/fizzbuzz-rs/*-inst-wm.txt
echo "==== numguess-rs inst-wm ===="
h2 obj/$1/example/numguess-rs/*-inst-wm.txt
echo "********************************************************"
echo "==== 8cc func-wm ===="
h3 obj/$1/example/8cc/stage1-wm/*-func-wm.txt
echo "==== zlib func-wm ===="
h3 obj/$1/example/zlib/zlib-watermark/*-func-wm.txt
echo "==== lua func-wm ===="
h3 obj/$1/example/lua/*-func-wm.txt
echo "==== cJSON func-wm ===="
h3 obj/$1/example/cJSON/*-func-wm.txt
echo "==== tree func-wm ===="
h3 obj/$1/example/tree/*-func-wm.txt
echo "==== jemalloc func-wm ===="
h3 obj/$1/example/jemalloc/*-func-wm.txt
echo "==== fizzbuzz-rs func-wm ===="
h3 obj/$1/example/fizzbuzz-rs/*-func-wm.txt
echo "==== numguess-rs func-wm ===="
h3 obj/$1/example/numguess-rs/*-func-wm.txt
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment