34 lines · bash
1#!/bin/sh -e2 3LLFILE=`echo $1 | sed -e 's/\.c/.ll/g'`4LLFILE_TMP=${LLFILE}.tmp5SOURCE=$16 7shift8 9clang -c -S -emit-llvm -O3 -mllvm -disable-llvm-optzns ${SOURCE} -o ${LLFILE} "$@"10 11opt -correlated-propagation -mem2reg -instcombine -loop-simplify -indvars \12-instnamer ${LLFILE} -S -o ${LLFILE_TMP}13 14# Insert a header into the new testcase containing a sample RUN line a FIXME and15# an XFAIL. Then insert the formatted C code and finally the LLVM-IR without16# attributes, the module ID or the target triple.17echo '; RUN: opt %loadPolly -S < %s | FileCheck %s' > ${LLFILE}18echo ';' >> ${LLFILE}19echo '; FIXME: Edit the run line and add checks!' >> ${LLFILE}20echo ';' >> ${LLFILE}21echo '; XFAIL: *' >> ${LLFILE}22echo ';' >> ${LLFILE}23clang-format ${SOURCE} | sed -e 's/^[^$]/; &/' -e 's/^$/;/' >> ${LLFILE}24echo ';' >> ${LLFILE}25 26cat ${LLFILE_TMP} >> ${LLFILE}27sed -i".tmp" '/attributes .* =/d' ${LLFILE}28sed -i".tmp" -e 's/) \#[0-9]*/)/' ${LLFILE}29sed -i".tmp" '/; Function Attrs:/d' ${LLFILE}30sed -i".tmp" '/; ModuleID =/d' ${LLFILE}31sed -i".tmp" '/target triple/d' ${LLFILE}32 33mv ${LLFILE_TMP} ${LLFILE}34