#!/bin/bash
current_path=$(
  cd $(dirname $0)
  pwd
)
perf_data=${current_path}/../perf/perf.data
if [[ ! -f ${perf_data} ]]; then
  echo "[ERROR] ${perf_data} is not exist"
  exit 1
fi

gcov_file=${current_path}/gcov.afdo
echo "[INFO] Start to create ${gcov_file}"
create_gcov --binary=${current_path}/../lmbench-3.0-a9/bin/aarch64-linux-gnu/lat_mem_rd --profile=${perf_data} --gcov=${gcov_file} --gcov_version=1 --use_lbr=0 >>${current_path}/gcov.log 2>&1
echo "[INFO] End to create ${gcov_file}"

/usr/bin/gcc -fauto-profile=/opt/lmbench/gcov/gcov.afdo.inst_retired:u -fcache-misses-profile=/opt/lmbench/gcov/gcov.afdo.cache-misses:u -fprefetch-loop-arrays=2 $@
/usr/bin/gcc_old -fauto-profile=/opt/a-fot/20220518-154030/profile.gcov.inst_retired:u -fcache-misses-profile=/opt/a-fot/20220518-154030/profile.gcov.cache-misses:u -fprefetch-loop-arrays=2 $@