From caf1213e99a49b112af8467202d96945b140f7db Mon Sep 17 00:00:00 2001 From: Peter Waegemann <waegemann@cs.fau.de> Date: Mon, 28 Mar 2016 19:24:07 +0200 Subject: [PATCH] Add script adding noinline attribute to function annotated by entrypoint Pragma --- script/add_noinline_annotation.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 script/add_noinline_annotation.sh diff --git a/script/add_noinline_annotation.sh b/script/add_noinline_annotation.sh new file mode 100755 index 0000000..fbbb0d0 --- /dev/null +++ b/script/add_noinline_annotation.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +if [ $# -ne 1 ]; then + echo "usage: $0 <tacle-bench-root-dir>" >&2 + exit 1 +fi + +TACLE_ROOT=$1 + +for i in $(grep -r "entrypoint" `find $TACLE_ROOT -name "*.c"` | cut -d: -f1) ; +do + # ugly workaround: run clang-format prior to the annotiation + # to have { at the end of the line + temp=$(tempfile) + clang-format $i > $temp + mv $temp $i + + exists=$(grep -c '__attribute__((noinline))' $i ) + if [ $exists -eq 0 ]; then + echo "annotating $i" + # get the line number: + line=$(grep -n "entrypoint" $i |cut -d: -f1) + echo "found in line $line" + sed -i "${line}s/{/__attribute__((noinline)){/g" $i + fi +done -- GitLab