Skip to content

Goto function inlining #262

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion regression/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
DIRS = ansi-c cbmc cpp goto-instrument goto-instrument-unwind goto-analyzer

DIRS = ansi-c cbmc cpp goto-instrument goto-instrument-unwind goto-analyzer inlining

test:
$(foreach var,$(DIRS), $(MAKE) -C $(var) test || exit 1;)
20 changes: 20 additions & 0 deletions regression/inlining/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
default: tests.log

test:
@./test.sh

tests.log: ../test.pl
@./test.sh

show:
@for dir in *; do \
if [ -d "$$dir" ]; then \
vim -o "$$dir/*.java" "$$dir/*.out"; \
fi; \
done;

clean:
find . -name '*.*~' | xargs rm -f
find . -name '*.out' | xargs rm -f
find . -name '*.o' | xargs rm -f
rm -f tests.log
19 changes: 19 additions & 0 deletions regression/inlining/chain.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

set -e

src=../../../src
goto_cc=$src/goto-cc/goto-cc
goto_instrument=$src/goto-instrument/goto-instrument
cbmc=$src/cbmc/cbmc

name=${@:$#}
name=${name%.c}

args=${@:1:$#-1}

$goto_cc -o $name.o $name.c
$goto_instrument $args $name.o $name-new.o
$goto_instrument --show-goto-functions $name-new.o
$cbmc $name-new.o

24 changes: 24 additions & 0 deletions regression/inlining/inline_01/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include <assert.h>

int x;

int h() {
return 9;
}

void g(int i) {
x += i + h(); // += 12
}

void f(int i, int j) {
g(i);
x += i + j; // +=10
}

int main()
{
x = 0;
f(3, 7);
assert(x == 22);
}

11 changes: 11 additions & 0 deletions regression/inlining/inline_01/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
CORE
main.c
--inline
^EXIT=0$
^SIGNAL=0$
^VERIFICATION SUCCESSFUL$
--
f[(].*[)];$
g[(].*[)];$
h[(].*[)];$
^warning: ignoring
24 changes: 24 additions & 0 deletions regression/inlining/inline_02/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include <assert.h>

int x;

int h() {
return 9;
}

void g(int i) {
x += i + h(); // += 12
}

void f(int i, int j) {
g(i);
x += i + j; // +=10
}

int main()
{
x = 0;
f(3, 7);
assert(x == 22);
}

11 changes: 11 additions & 0 deletions regression/inlining/inline_02/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
CORE
main.c
--partial-inline
^EXIT=0$
^SIGNAL=0$
^VERIFICATION SUCCESSFUL$
f[(].*[)];$
g[(].*[)];$
h[(].*[)];$
--
^warning: ignoring
24 changes: 24 additions & 0 deletions regression/inlining/inline_03/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include <assert.h>

int x;

inline int h() {
return 9;
}

void g(int i) {
x += i + h(); // += 12
}

void f(int i, int j) {
g(i);
x += i + j; // +=10
}

int main()
{
x = 0;
f(3, 7);
assert(x == 22);
}

11 changes: 11 additions & 0 deletions regression/inlining/inline_03/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
CORE
main.c
--partial-inline
^EXIT=0$
^SIGNAL=0$
^VERIFICATION SUCCESSFUL$
f[(].*[)];$
g[(].*[)];$
--
h[(].*[)];$
^warning: ignoring
28 changes: 28 additions & 0 deletions regression/inlining/inline_04/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include <assert.h>

int x;

int h() {
return 9;
}

void g(int i) {
x += i + h(); // += 12
}

void f(int i, int j) {
g(i);
x += i + j; // +=10
}

void other_func() {}

int main()
{
x = 0;
f(3, 7);
other_func();

assert(x == 22);
}

12 changes: 12 additions & 0 deletions regression/inlining/inline_04/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
CORE
main.c
--function-inline main
^EXIT=0$
^SIGNAL=0$
^VERIFICATION SUCCESSFUL$
g[(].*[)];$
h[(].*[)];$
--
f[(].*[)];$
other_func[(].*[)];$
^warning: ignoring
38 changes: 38 additions & 0 deletions regression/inlining/inline_05/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#include <assert.h>

int x;

void f()
{
x += 1;

if(x < 10)
f();
}

void h()
{
x += 1;
if(x < 20)
g();
}

void g()
{
x += 1;
h();
}

int main()
{
// direct recursion
x = 0;
f();
assert(x == 1);

// indirect recursion
x = 0;
g();
assert(x == 2);
}

10 changes: 10 additions & 0 deletions regression/inlining/inline_05/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
CORE
main.c
--inline
^EXIT=0$
^SIGNAL=0$
^VERIFICATION SUCCESSFUL$
recursion.*ignored.*[`]f
recursion.*ignored.*[`]g
--
^warning: ignoring
38 changes: 38 additions & 0 deletions regression/inlining/inline_06/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#include <assert.h>

int x;

inline void f()
{
x += 1;

if(x < 10)
f();
}

inline void h()
{
x += 1;
if(x < 20)
g();
}

inline void g()
{
x += 1;
h();
}

int main()
{
// direct recursion
x = 0;
f();
assert(x == 10);

// indirect recursion
x = 0;
g();
assert(x == 20);
}

10 changes: 10 additions & 0 deletions regression/inlining/inline_06/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
CORE
main.c
--partial-inline
^EXIT=0$
^SIGNAL=0$
^VERIFICATION SUCCESSFUL$
recursion.*ignored.*[`]f
recursion.*ignored.*[`]g
--
^warning: ignoring
38 changes: 38 additions & 0 deletions regression/inlining/inline_07/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#include <assert.h>

int x;

void f()
{
x += 1;

if(x < 10)
f();
}

void h()
{
x += 1;
if(x < 20)
g();
}

void g()
{
x += 1;
h();
}

int main()
{
// direct recursion
x = 0;
f();
assert(x == 1);

// indirect recursion
x = 0;
g();
assert(x == 2);
}

10 changes: 10 additions & 0 deletions regression/inlining/inline_07/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
CORE
main.c
--function-inline main
^EXIT=0$
^SIGNAL=0$
^VERIFICATION SUCCESSFUL$
recursion.*ignored.*[`]f
recursion.*ignored.*[`]g
--
^warning: ignoring
20 changes: 20 additions & 0 deletions regression/inlining/inline_08/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include <assert.h>

int x;

int f()
{
if(x)
return 1;
else
return 2;

return 3;
}

int main()
{
int y;
y = f();
}

11 changes: 11 additions & 0 deletions regression/inlining/inline_08/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
CORE
main.c
--inline
^EXIT=0$
^SIGNAL=0$
^VERIFICATION SUCCESSFUL$
y = 1;
y = 2;
y = 3;
--
^warning: ignoring
Loading