2014-09-10 06:14:38 +08:00
|
|
|
#!/bin/sh -e
|
2011-04-29 14:27:02 +08:00
|
|
|
|
|
|
|
LLFILE=`echo $1 | sed -e 's/\.c/.ll/g'`
|
2014-06-25 01:02:53 +08:00
|
|
|
LLFILE_TMP=${LLFILE}.tmp
|
2018-05-02 23:27:32 +08:00
|
|
|
SOURCE=$1
|
2014-06-25 01:02:53 +08:00
|
|
|
|
2018-05-02 23:27:32 +08:00
|
|
|
shift
|
|
|
|
|
|
|
|
clang -c -S -emit-llvm -O3 -mllvm -disable-llvm-optzns ${SOURCE} -o ${LLFILE} "$@"
|
2011-04-29 14:27:02 +08:00
|
|
|
|
2014-03-25 23:50:44 +08:00
|
|
|
opt -correlated-propagation -mem2reg -instcombine -loop-simplify -indvars \
|
2014-06-25 01:02:53 +08:00
|
|
|
-instnamer ${LLFILE} -S -o ${LLFILE_TMP}
|
|
|
|
|
|
|
|
# Insert a header into the new testcase containing a sample RUN line a FIXME and
|
|
|
|
# an XFAIL. Then insert the formated C code and finally the LLVM-IR without
|
|
|
|
# attributes, the module ID or the target triple.
|
|
|
|
echo '; RUN: opt %loadPolly -analyze < %s | FileCheck %s' > ${LLFILE}
|
|
|
|
echo ';' >> ${LLFILE}
|
|
|
|
echo '; FIXME: Edit the run line and add checks!' >> ${LLFILE}
|
|
|
|
echo ';' >> ${LLFILE}
|
|
|
|
echo '; XFAIL: *' >> ${LLFILE}
|
|
|
|
echo ';' >> ${LLFILE}
|
2018-05-02 23:27:32 +08:00
|
|
|
clang-format ${SOURCE} | sed -e 's/^[^$]/; &/' -e 's/^$/;/' >> ${LLFILE}
|
2014-06-25 01:02:53 +08:00
|
|
|
echo ';' >> ${LLFILE}
|
|
|
|
|
2017-07-07 12:20:55 +08:00
|
|
|
cat ${LLFILE_TMP} >> ${LLFILE}
|
|
|
|
sed -i".tmp" '/attributes .* =/d' ${LLFILE}
|
|
|
|
sed -i".tmp" -e 's/) \#[0-9]*/)/' ${LLFILE}
|
2014-06-25 01:02:53 +08:00
|
|
|
sed -i".tmp" '/; Function Attrs:/d' ${LLFILE}
|
|
|
|
sed -i".tmp" '/; ModuleID =/d' ${LLFILE}
|
|
|
|
sed -i".tmp" '/target triple/d' ${LLFILE}
|
|
|
|
|
|
|
|
mv ${LLFILE_TMP} ${LLFILE}
|