Skip to content

Commit

Permalink
script parse and stack update, fix #43 and #44
Browse files Browse the repository at this point in the history
  • Loading branch information
ahueck committed Dec 30, 2020
1 parent 4381f11 commit 785b67e
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 9 deletions.
29 changes: 25 additions & 4 deletions scripts/apply.sh.in
Original file line number Diff line number Diff line change
@@ -1,8 +1,29 @@
#!/bin/bash

target=$1
ta_more_args=${2:-""}
optimize=${3:-" "}
optimize=""
ta_more_args=""

shift # skip over $1
while (( "$#" )); do
case "$1" in
-o|--optimization)
if [ -n "$2" ] && [ ${2:0:2} == "-O" ]; then
optimize=$2
shift 2
else
echo "Error: Optimization argument for $1 is erroneous: $2" >&2
exit 1
fi
;;
*) # preserve other arguments
ta_more_args="$ta_more_args $1"
shift
;;
esac
done
# set other positional arguments in their proper place
eval set -- "ta_more_args"

extension="${target##*.}"
tmpfile=${target##*/}
Expand All @@ -24,12 +45,12 @@ function make_no_optim() {

function make_with_optim() {
# Order: heap, optimize, alloca with additional args..
$compiler @TYPEART_INCLUDE_DIRS@ -O1 -Xclang -disable-llvm-passes -S -emit-llvm "$target" -o - | opt $typeart_plugin -typeart-stats | opt $optimize -S | opt $typeart_plugin -typeart-alloca -typeart-stats $ta_more_args -S 2>&1
$compiler @TYPEART_INCLUDE_DIRS@ -O1 -Xclang -disable-llvm-passes -S -emit-llvm "$target" -o - | opt $typeart_plugin -typeart-stats -S | opt $optimize -S | opt $typeart_plugin -typeart-no-heap -typeart-alloca -typeart-stats $ta_more_args -S 2>&1
}

function compile() {
local typeart_plugin="-load @TYPEART_ANALYSIS_PASS_DIR@/@TYPEART_ANALYSIS_PLUGIN@ -load @TYPEART_PASS_DIR@/@TYPEART_PLUGIN@ -typeart"
if [ "$optimize" == " " ]; then
if [ "$optimize" == "" ]; then
make_no_optim
else
make_with_optim
Expand Down
27 changes: 24 additions & 3 deletions scripts/run.sh.in
Original file line number Diff line number Diff line change
@@ -1,8 +1,29 @@
#!/bin/bash

target=$1
ta_more_args=${2:-""}
optimize=${3:-" "}
optimize=""
ta_more_args=""

shift # skip over $1
while (( "$#" )); do
case "$1" in
-o|--optimization)
if [ -n "$2" ] && [ ${2:0:2} == "-O" ]; then
optimize=$2
shift 2
else
echo "Error: Optimization argument for $1 is erroneous: $2" >&2
exit 1
fi
;;
*) # preserve other arguments
ta_more_args="$ta_more_args $1"
shift
;;
esac
done
# set other positional arguments in their proper place
eval set -- "ta_more_args"

extension="${target##*.}"
tmpfile=${target##*/}
Expand All @@ -24,7 +45,7 @@ function make_no_optim() {

function make_with_optim() {
# Order: heap, optimize, alloca with additional args..
$compiler @TYPEART_INCLUDE_DIRS@ -O1 -Xclang -disable-llvm-passes -S -emit-llvm "$target" -o - | opt $typeart_plugin -typeart-stats | opt $optimize -S | opt $typeart_plugin -typeart-alloca -typeart-stats $ta_more_args | llc -x=ir -filetype=obj -o "$tmpfile".o
$compiler @TYPEART_INCLUDE_DIRS@ -O1 -Xclang -disable-llvm-passes -S -emit-llvm "$target" -o - | opt $typeart_plugin -typeart-stats $ta_more_args | opt $optimize -S | opt $typeart_plugin -typeart-no-heap -typeart-alloca -typeart-stats $ta_more_args | llc -x=ir -filetype=obj -o "$tmpfile".o
}

function compile() {
Expand Down
4 changes: 2 additions & 2 deletions test/runtime/18_softcounter_empty.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %run %s -O3 2>&1 | FileCheck %s
// RUN: %run %s -o -O3 2>&1 | FileCheck %s
// REQUIRED: softcounter

void __typeart_leave_scope(int alloca_count);
Expand Down Expand Up @@ -27,5 +27,5 @@ int main(void) {
// CHECK-NEXT: Bytes per node map/stack : 96 , 8 , -
// CHECK-NEXT: {{(#|-)+}}
// CHECK-NEXT: Allocation type detail (heap, stack, global)
// CHECK: {{(#|-)+}}
// CHECK-NEXT: {{(#|-)+}}
// CHECK-NEXT: Free allocation type detail (heap, stack)

0 comments on commit 785b67e

Please sign in to comment.