blob: 1c03d9a015e01fc7969dcd1751573589b82c32e3 [file] [log] [blame]
David Peixotto9690f3b2014-09-09 22:14:38 +00001#!/bin/sh -e
Tobias Grosser75805372011-04-29 06:27:02 +00002
Tobias Grosser75805372011-04-29 06:27:02 +00003LLFILE=`echo $1 | sed -e 's/\.c/.ll/g'`
Johannes Doerfert5e275bc2014-06-24 17:02:53 +00004LLFILE_TMP=${LLFILE}.tmp
Philip Pfaffef1fadea2018-05-02 15:27:32 +00005SOURCE=$1
Johannes Doerfert5e275bc2014-06-24 17:02:53 +00006
Philip Pfaffef1fadea2018-05-02 15:27:32 +00007shift
8
9clang -c -S -emit-llvm -O3 -mllvm -disable-llvm-optzns ${SOURCE} -o ${LLFILE} "$@"
Tobias Grosser75805372011-04-29 06:27:02 +000010
Tobias Grosser5fa36c02014-03-25 15:50:44 +000011opt -correlated-propagation -mem2reg -instcombine -loop-simplify -indvars \
Johannes Doerfert5e275bc2014-06-24 17:02:53 +000012-instnamer ${LLFILE} -S -o ${LLFILE_TMP}
13
14# Insert a header into the new testcase containing a sample RUN line a FIXME and
Christian Clauss5aafc6d2025-01-27 16:18:47 +010015# an XFAIL. Then insert the formatted C code and finally the LLVM-IR without
Johannes Doerfert5e275bc2014-06-24 17:02:53 +000016# attributes, the module ID or the target triple.
Michael Kruse5c028082022-03-14 08:39:25 -050017echo '; RUN: opt %loadPolly -S < %s | FileCheck %s' > ${LLFILE}
Johannes Doerfert5e275bc2014-06-24 17:02:53 +000018echo ';' >> ${LLFILE}
19echo '; FIXME: Edit the run line and add checks!' >> ${LLFILE}
20echo ';' >> ${LLFILE}
21echo '; XFAIL: *' >> ${LLFILE}
22echo ';' >> ${LLFILE}
Philip Pfaffef1fadea2018-05-02 15:27:32 +000023clang-format ${SOURCE} | sed -e 's/^[^$]/; &/' -e 's/^$/;/' >> ${LLFILE}
Johannes Doerfert5e275bc2014-06-24 17:02:53 +000024echo ';' >> ${LLFILE}
25
Tobias Grosser41f02a92017-07-07 04:20:55 +000026cat ${LLFILE_TMP} >> ${LLFILE}
27sed -i".tmp" '/attributes .* =/d' ${LLFILE}
28sed -i".tmp" -e 's/) \#[0-9]*/)/' ${LLFILE}
Johannes Doerfert5e275bc2014-06-24 17:02:53 +000029sed -i".tmp" '/; Function Attrs:/d' ${LLFILE}
30sed -i".tmp" '/; ModuleID =/d' ${LLFILE}
31sed -i".tmp" '/target triple/d' ${LLFILE}
32
Johannes Doerfert5e275bc2014-06-24 17:02:53 +000033mv ${LLFILE_TMP} ${LLFILE}