David Peixotto | 9690f3b | 2014-09-09 22:14:38 +0000 | [diff] [blame] | 1 | #!/bin/sh -e |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 2 | |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 3 | LLFILE=`echo $1 | sed -e 's/\.c/.ll/g'` |
Johannes Doerfert | 5e275bc | 2014-06-24 17:02:53 +0000 | [diff] [blame] | 4 | LLFILE_TMP=${LLFILE}.tmp |
Philip Pfaffe | f1fadea | 2018-05-02 15:27:32 +0000 | [diff] [blame] | 5 | SOURCE=$1 |
Johannes Doerfert | 5e275bc | 2014-06-24 17:02:53 +0000 | [diff] [blame] | 6 | |
Philip Pfaffe | f1fadea | 2018-05-02 15:27:32 +0000 | [diff] [blame] | 7 | shift |
| 8 | |
| 9 | clang -c -S -emit-llvm -O3 -mllvm -disable-llvm-optzns ${SOURCE} -o ${LLFILE} "$@" |
Tobias Grosser | 7580537 | 2011-04-29 06:27:02 +0000 | [diff] [blame] | 10 | |
Tobias Grosser | 5fa36c0 | 2014-03-25 15:50:44 +0000 | [diff] [blame] | 11 | opt -correlated-propagation -mem2reg -instcombine -loop-simplify -indvars \ |
Johannes Doerfert | 5e275bc | 2014-06-24 17:02:53 +0000 | [diff] [blame] | 12 | -instnamer ${LLFILE} -S -o ${LLFILE_TMP} |
| 13 | |
| 14 | # Insert a header into the new testcase containing a sample RUN line a FIXME and |
Christian Clauss | 5aafc6d | 2025-01-27 16:18:47 +0100 | [diff] [blame] | 15 | # an XFAIL. Then insert the formatted C code and finally the LLVM-IR without |
Johannes Doerfert | 5e275bc | 2014-06-24 17:02:53 +0000 | [diff] [blame] | 16 | # attributes, the module ID or the target triple. |
Michael Kruse | 5c02808 | 2022-03-14 08:39:25 -0500 | [diff] [blame] | 17 | echo '; RUN: opt %loadPolly -S < %s | FileCheck %s' > ${LLFILE} |
Johannes Doerfert | 5e275bc | 2014-06-24 17:02:53 +0000 | [diff] [blame] | 18 | echo ';' >> ${LLFILE} |
| 19 | echo '; FIXME: Edit the run line and add checks!' >> ${LLFILE} |
| 20 | echo ';' >> ${LLFILE} |
| 21 | echo '; XFAIL: *' >> ${LLFILE} |
| 22 | echo ';' >> ${LLFILE} |
Philip Pfaffe | f1fadea | 2018-05-02 15:27:32 +0000 | [diff] [blame] | 23 | clang-format ${SOURCE} | sed -e 's/^[^$]/; &/' -e 's/^$/;/' >> ${LLFILE} |
Johannes Doerfert | 5e275bc | 2014-06-24 17:02:53 +0000 | [diff] [blame] | 24 | echo ';' >> ${LLFILE} |
| 25 | |
Tobias Grosser | 41f02a9 | 2017-07-07 04:20:55 +0000 | [diff] [blame] | 26 | cat ${LLFILE_TMP} >> ${LLFILE} |
| 27 | sed -i".tmp" '/attributes .* =/d' ${LLFILE} |
| 28 | sed -i".tmp" -e 's/) \#[0-9]*/)/' ${LLFILE} |
Johannes Doerfert | 5e275bc | 2014-06-24 17:02:53 +0000 | [diff] [blame] | 29 | sed -i".tmp" '/; Function Attrs:/d' ${LLFILE} |
| 30 | sed -i".tmp" '/; ModuleID =/d' ${LLFILE} |
| 31 | sed -i".tmp" '/target triple/d' ${LLFILE} |
| 32 | |
Johannes Doerfert | 5e275bc | 2014-06-24 17:02:53 +0000 | [diff] [blame] | 33 | mv ${LLFILE_TMP} ${LLFILE} |