Skip to content

Commit c6f9231

Browse files
author
Daniel Kroening
authored
Merge pull request diffblue#2553 from tautschnig/always-inline-partial-revert
Partial revert of diffblue#1898 (always_inline support, second attempt)
2 parents fa94bc0 + e501317 commit c6f9231

File tree

34 files changed

+274
-133
lines changed

34 files changed

+274
-133
lines changed

regression/ansi-c/always_inline1/test.desc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CORE
1+
KNOWNBUG
22
main.c
33

44
^EXIT=0$
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
static inline __attribute__((__always_inline__)) int func(int val)
2+
{
3+
return val;
4+
}
5+
6+
static inline int func2(int *p)
7+
{
8+
// the typecast, although redundant, is essential to show the problem
9+
return func(*(int*)p);
10+
}
11+
12+
int main()
13+
{
14+
int x;
15+
return func2(&x);
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE gcc-only
2+
main.c
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
^warning: ignoring
8+
^CONVERSION ERROR$
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
static inline __attribute__((__always_inline__)) int func(int val)
2+
{
3+
if(val > 0)
4+
return func(val - 1);
5+
return 0;
6+
}
7+
8+
int main()
9+
{
10+
int x;
11+
return func(x);
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE gcc-only
2+
main.c
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
^warning: ignoring
8+
^CONVERSION ERROR$
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
extern int func_alias(int val) __asm__("" "func");
2+
3+
static inline __attribute__((__always_inline__)) int func(int val)
4+
{
5+
if(val > 0)
6+
return func_alias(val - 1);
7+
return 0;
8+
}
9+
10+
int main()
11+
{
12+
int x;
13+
return func(x);
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE gcc-only
2+
main.c
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
^warning: ignoring
8+
^CONVERSION ERROR$
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
static inline
2+
__attribute__((__section__(".init"))) __attribute__((__always_inline__))
3+
int func(int val)
4+
{
5+
return val + 1;
6+
}
7+
8+
int main()
9+
{
10+
int x;
11+
return func(x);
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE gcc-only
2+
main.c
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
^warning: ignoring
8+
^CONVERSION ERROR$
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
static inline __attribute__((__always_inline__)) int func(int val, ...)
2+
{
3+
return val + 1;
4+
}
5+
6+
int main()
7+
{
8+
int x;
9+
return func(x, x);
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE gcc-only
2+
main.c
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
^warning: ignoring
8+
^CONVERSION ERROR$
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
static inline __attribute__((__always_inline__)) int func(int val)
2+
{
3+
int local = val;
4+
return local;
5+
}
6+
7+
int main()
8+
{
9+
int x;
10+
return func(x);
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE gcc-only
2+
main.c
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
^warning: ignoring
8+
^CONVERSION ERROR$
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
static inline __attribute__((__always_inline__)) int func(int val)
2+
{
3+
return (__typeof__(val))42;
4+
}
5+
6+
int main()
7+
{
8+
int x;
9+
return func(x);
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE gcc-only
2+
main.c
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
^warning: ignoring
8+
^CONVERSION ERROR$
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
static inline __attribute__((__always_inline__)) int func(int val)
2+
{
3+
val = val + 1;
4+
return val;
5+
}
6+
7+
int main()
8+
{
9+
int x;
10+
return func(x);
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE gcc-only
2+
main.c
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
^warning: ignoring
8+
^CONVERSION ERROR$

regression/cbmc/always_inline1/main.c

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include <assert.h>
2+
3+
#ifndef __GNUC__
4+
#define __attribute__(x)
5+
#endif
6+
7+
static inline __attribute__((__always_inline__)) void func(int *val)
8+
{
9+
*val = 1;
10+
return;
11+
}
12+
13+
static inline int func2(int *p)
14+
{
15+
func(p);
16+
return *p;
17+
}
18+
19+
int main()
20+
{
21+
int x;
22+
assert(func2(&x) == 1);
23+
return 0;
24+
}
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring

regression/cbmc/always_inline2/main.c

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#include <assert.h>
2+
3+
#ifndef __GNUC__
4+
#define __attribute__(x)
5+
#endif
6+
7+
static inline __attribute__((__always_inline__)) int func(int *val)
8+
{
9+
switch(*val)
10+
{
11+
case 1:
12+
return *val + 1;
13+
case 2:
14+
return *val + 2;
15+
}
16+
17+
return *val;
18+
}
19+
20+
static inline int func2(int *p)
21+
{
22+
return func(p);
23+
}
24+
25+
int main()
26+
{
27+
int x = 1;
28+
assert(func2(&x) == 2);
29+
return 0;
30+
}
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring

regression/cbmc/always_inline3/main.c

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#include <assert.h>
2+
3+
#ifndef __GNUC__
4+
#define __attribute__(x)
5+
#endif
6+
7+
static inline __attribute__((__always_inline__)) void func(int *val)
8+
{
9+
if(*val < 0)
10+
{
11+
*val = 1;
12+
return;
13+
}
14+
else
15+
{
16+
*val = 1;
17+
return;
18+
}
19+
}
20+
21+
static inline int func2(int *p)
22+
{
23+
func(p);
24+
return *p;
25+
}
26+
27+
int main()
28+
{
29+
int x;
30+
assert(func2(&x) == 1);
31+
return 0;
32+
}
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring

src/ansi-c/ansi_c_convert_type.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,6 @@ void ansi_c_convert_typet::read_rec(const typet &type)
171171
c_storage_spec.is_weak=true;
172172
else if(type.id() == ID_used)
173173
c_storage_spec.is_used = true;
174-
else if(type.id() == ID_always_inline)
175-
c_storage_spec.is_always_inline = true;
176174
else if(type.id()==ID_auto)
177175
{
178176
// ignore

src/ansi-c/ansi_c_declaration.cpp

-5
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,6 @@ void ansi_c_declarationt::output(std::ostream &out) const
8181
out << " is_extern";
8282
if(get_is_static_assert())
8383
out << " is_static_assert";
84-
if(get_is_always_inline())
85-
out << " is_always_inline";
8684
out << "\n";
8785

8886
out << "Type: " << type().pretty() << "\n";
@@ -166,9 +164,6 @@ void ansi_c_declarationt::to_symbol(
166164
symbol.is_extern=false;
167165
else if(get_is_extern()) // traditional GCC
168166
symbol.is_file_local=true;
169-
170-
if(get_is_always_inline())
171-
symbol.is_macro = true;
172167
}
173168

174169
// GCC __attribute__((__used__)) - do not treat those as file-local

src/ansi-c/ansi_c_declaration.h

-10
Original file line numberDiff line numberDiff line change
@@ -205,16 +205,6 @@ class ansi_c_declarationt:public exprt
205205
set(ID_is_used, is_used);
206206
}
207207

208-
bool get_is_always_inline() const
209-
{
210-
return get_bool(ID_is_always_inline);
211-
}
212-
213-
void set_is_always_inline(bool is_always_inline)
214-
{
215-
set(ID_is_always_inline, is_always_inline);
216-
}
217-
218208
void to_symbol(
219209
const ansi_c_declaratort &,
220210
symbolt &symbol) const;

src/ansi-c/c_storage_spec.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ void c_storage_spect::read(const typet &type)
3434
is_weak=true;
3535
else if(type.id() == ID_used)
3636
is_used = true;
37-
else if(type.id() == ID_always_inline)
38-
is_always_inline = true;
3937
else if(type.id()==ID_auto)
4038
{
4139
// ignore

src/ansi-c/c_storage_spec.h

+2-7
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,13 @@ class c_storage_spect
3636
is_inline=false;
3737
is_weak=false;
3838
is_used = false;
39-
is_always_inline = false;
4039
alias.clear();
4140
asm_label.clear();
4241
section.clear();
4342
}
4443

45-
bool is_typedef, is_extern, is_static, is_register, is_inline,
46-
is_thread_local, is_weak, is_used, is_always_inline;
44+
bool is_typedef, is_extern, is_static, is_register,
45+
is_inline, is_thread_local, is_weak, is_used;
4746

4847
// __attribute__((alias("foo")))
4948
irep_idt alias;
@@ -54,7 +53,6 @@ class c_storage_spect
5453

5554
bool operator==(const c_storage_spect &other) const
5655
{
57-
// clang-format off
5856
return is_typedef==other.is_typedef &&
5957
is_extern==other.is_extern &&
6058
is_static==other.is_static &&
@@ -63,11 +61,9 @@ class c_storage_spect
6361
is_inline==other.is_inline &&
6462
is_weak==other.is_weak &&
6563
is_used == other.is_used &&
66-
is_always_inline == other.is_always_inline &&
6764
alias==other.alias &&
6865
asm_label==other.asm_label &&
6966
section==other.section;
70-
// clang-format on
7167
}
7268

7369
bool operator!=(const c_storage_spect &other) const
@@ -85,7 +81,6 @@ class c_storage_spect
8581
is_thread_local |=other.is_thread_local;
8682
is_weak |=other.is_weak;
8783
is_used |=other.is_used;
88-
is_always_inline |= other.is_always_inline;
8984
if(alias.empty())
9085
alias=other.alias;
9186
if(asm_label.empty())

0 commit comments

Comments
 (0)