Skip to content

Commit c655301

Browse files
author
Daniel Kroening
authored
Merge pull request #262 from danpoe/goto-function-inlining
Goto function inlining
2 parents 268f751 + 05f19bf commit c655301

File tree

35 files changed

+2372
-754
lines changed

35 files changed

+2372
-754
lines changed

regression/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
DIRS = ansi-c cbmc cpp goto-instrument goto-instrument-unwind goto-analyzer
1+
2+
DIRS = ansi-c cbmc cpp goto-instrument goto-instrument-unwind goto-analyzer inlining
23

34
test:
45
$(foreach var,$(DIRS), $(MAKE) -C $(var) test || exit 1;)

regression/inlining/Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
default: tests.log
2+
3+
test:
4+
@./test.sh
5+
6+
tests.log: ../test.pl
7+
@./test.sh
8+
9+
show:
10+
@for dir in *; do \
11+
if [ -d "$$dir" ]; then \
12+
vim -o "$$dir/*.java" "$$dir/*.out"; \
13+
fi; \
14+
done;
15+
16+
clean:
17+
find . -name '*.*~' | xargs rm -f
18+
find . -name '*.out' | xargs rm -f
19+
find . -name '*.o' | xargs rm -f
20+
rm -f tests.log

regression/inlining/chain.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
src=../../../src
6+
goto_cc=$src/goto-cc/goto-cc
7+
goto_instrument=$src/goto-instrument/goto-instrument
8+
cbmc=$src/cbmc/cbmc
9+
10+
name=${@:$#}
11+
name=${name%.c}
12+
13+
args=${@:1:$#-1}
14+
15+
$goto_cc -o $name.o $name.c
16+
$goto_instrument $args $name.o $name-new.o
17+
$goto_instrument --show-goto-functions $name-new.o
18+
$cbmc $name-new.o
19+

regression/inlining/inline_01/main.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include <assert.h>
2+
3+
int x;
4+
5+
int h() {
6+
return 9;
7+
}
8+
9+
void g(int i) {
10+
x += i + h(); // += 12
11+
}
12+
13+
void f(int i, int j) {
14+
g(i);
15+
x += i + j; // +=10
16+
}
17+
18+
int main()
19+
{
20+
x = 0;
21+
f(3, 7);
22+
assert(x == 22);
23+
}
24+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CORE
2+
main.c
3+
--inline
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
f[(].*[)];$
9+
g[(].*[)];$
10+
h[(].*[)];$
11+
^warning: ignoring

regression/inlining/inline_02/main.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include <assert.h>
2+
3+
int x;
4+
5+
int h() {
6+
return 9;
7+
}
8+
9+
void g(int i) {
10+
x += i + h(); // += 12
11+
}
12+
13+
void f(int i, int j) {
14+
g(i);
15+
x += i + j; // +=10
16+
}
17+
18+
int main()
19+
{
20+
x = 0;
21+
f(3, 7);
22+
assert(x == 22);
23+
}
24+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CORE
2+
main.c
3+
--partial-inline
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
f[(].*[)];$
8+
g[(].*[)];$
9+
h[(].*[)];$
10+
--
11+
^warning: ignoring

regression/inlining/inline_03/main.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include <assert.h>
2+
3+
int x;
4+
5+
inline int h() {
6+
return 9;
7+
}
8+
9+
void g(int i) {
10+
x += i + h(); // += 12
11+
}
12+
13+
void f(int i, int j) {
14+
g(i);
15+
x += i + j; // +=10
16+
}
17+
18+
int main()
19+
{
20+
x = 0;
21+
f(3, 7);
22+
assert(x == 22);
23+
}
24+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CORE
2+
main.c
3+
--partial-inline
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
f[(].*[)];$
8+
g[(].*[)];$
9+
--
10+
h[(].*[)];$
11+
^warning: ignoring

regression/inlining/inline_04/main.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#include <assert.h>
2+
3+
int x;
4+
5+
int h() {
6+
return 9;
7+
}
8+
9+
void g(int i) {
10+
x += i + h(); // += 12
11+
}
12+
13+
void f(int i, int j) {
14+
g(i);
15+
x += i + j; // +=10
16+
}
17+
18+
void other_func() {}
19+
20+
int main()
21+
{
22+
x = 0;
23+
f(3, 7);
24+
other_func();
25+
26+
assert(x == 22);
27+
}
28+

0 commit comments

Comments
 (0)