Demote dead code into a stdout warning #328

Merged
sb10q merged 1 commits from issue-118 into master 2024-08-17 17:37:20 +08:00
3 changed files with 44 additions and 28 deletions

View File

@ -16,8 +16,8 @@ demo="$1"
echo -n "Checking $demo... " echo -n "Checking $demo... "
./interpret_demo.py "$demo" > interpreted.log ./interpret_demo.py "$demo" > interpreted.log
./run_demo.sh "${nac3args[@]}" "$demo" > run.log ./run_demo.sh --out run.log "${nac3args[@]}" "$demo"
./run_demo_lli.sh "${nac3args[@]}" "$demo" > run_lli.log ./run_demo.sh --lli --out run_lli.log "${nac3args[@]}" "$demo"
derppening marked this conversation as resolved Outdated
Outdated
Review

That parameter name is too long and also it's unclear that this creates run.log.

Can it be changed to something like --out run.log?

That parameter name is too long and also it's unclear that this creates ``run.log``. Can it be changed to something like ``--out run.log``?
diff -Nau interpreted.log run.log diff -Nau interpreted.log run.log
diff -Nau interpreted.log run_lli.log diff -Nau interpreted.log run_lli.log
echo "ok" echo "ok"

View File

@ -7,6 +7,23 @@ if [ -z "$1" ]; then
exit 1 exit 1
fi fi
declare -a nac3args
while [ $# -ge 1 ]; do
case "$1" in
--out)
shift
outfile="$1"
;;
--lli)
use_lli=1
;;
*)
nac3args+=("$1")
;;
derppening marked this conversation as resolved Outdated
Outdated
Review

You may want to merge run_demo and run_demo_lli to reduce code duplication, and add a --lli flag.

You may want to merge run_demo and run_demo_lli to reduce code duplication, and add a --lli flag.
esac
shift
done
if [ -e ../../target/release/nac3standalone ]; then if [ -e ../../target/release/nac3standalone ]; then
nac3standalone=../../target/release/nac3standalone nac3standalone=../../target/release/nac3standalone
else else
@ -14,9 +31,29 @@ else
nac3standalone=../../target/x86_64-unknown-linux-gnu/release/nac3standalone nac3standalone=../../target/x86_64-unknown-linux-gnu/release/nac3standalone
fi fi
if [ -z "$use_lli" ]; then
rm -f "*.o" demo rm -f "*.o" demo
$nac3standalone "$@" $nac3standalone "${nac3args[@]}"
clang -c -std=gnu11 -Wall -Wextra -O3 -o demo.o demo.c clang -c -std=gnu11 -Wall -Wextra -O3 -o demo.o demo.c
clang -lm -o demo module.o demo.o clang -lm -o demo module.o demo.o
if [ -z "$outfile" ]; then
./demo ./demo
else
./demo > "$outfile"
fi
else
rm -f "*.o" "*.bc" demo
$nac3standalone --emit-llvm "${nac3args[@]}"
clang -c -std=gnu11 -Wall -Wextra -O3 -emit-llvm -o demo.bc demo.c
if [ -z "$outfile" ]; then
lli --extra-module demo.bc --extra-module irrt.bc main.bc
else
lli --extra-module demo.bc --extra-module irrt.bc main.bc > "$outfile"
fi
fi

View File

@ -1,21 +0,0 @@
#!/usr/bin/env bash
set -e
if [ -z "$1" ]; then
echo "No argument supplied"
exit 1
fi
if [ -e ../../target/release/nac3standalone ]; then
nac3standalone=../../target/release/nac3standalone
else
# used by Nix builds
nac3standalone=../../target/x86_64-unknown-linux-gnu/release/nac3standalone
fi
rm -f "*.o" "*.bc" demo
$nac3standalone --emit-llvm "$@"
clang -c -std=gnu11 -Wall -Wextra -O3 -emit-llvm -o demo.bc demo.c
lli --extra-module demo.bc --extra-module irrt.bc main.bc