1 |
313 |
jeremybenn |
/* Check that long calls to different sections are not optimized to "bl". */
|
2 |
|
|
/* { dg-do compile { target { arm32 && fpic } } } */
|
3 |
|
|
/* { dg-options "-O2 -fpic" } */
|
4 |
|
|
|
5 |
|
|
#define section(S) __attribute__((section(S)))
|
6 |
|
|
#define weak __attribute__((weak))
|
7 |
|
|
#define noinline __attribute__((noinline))
|
8 |
|
|
#define long_call __attribute__((long_call))
|
9 |
|
|
#define short_call __attribute__((short_call))
|
10 |
|
|
|
11 |
|
|
#define REMOTE_CALL(ID, TARGET_ATTRS, CALL_ATTRS) \
|
12 |
|
|
const char *TARGET_ATTRS ID (void); \
|
13 |
|
|
const char *CALL_ATTRS call_##ID (void) { return ID () + 1; }
|
14 |
|
|
|
15 |
|
|
#define EXTERN_CALL(ID, TARGET_ATTRS, CALL_ATTRS) \
|
16 |
|
|
const char *TARGET_ATTRS noinline ID (void) { return #ID; } \
|
17 |
|
|
const char *CALL_ATTRS call_##ID (void) { return ID () + 1; } \
|
18 |
|
|
const char *CALL_ATTRS sibcall_##ID (void) { return ID (); }
|
19 |
|
|
|
20 |
|
|
#define STATIC_CALL(ID, TARGET_ATTRS, CALL_ATTRS) \
|
21 |
|
|
static const char *TARGET_ATTRS noinline ID (void) { return #ID; } \
|
22 |
|
|
const char *CALL_ATTRS call_##ID (void) { return ID () + 1; } \
|
23 |
|
|
const char *CALL_ATTRS sibcall_##ID (void) { return ID (); }
|
24 |
|
|
|
25 |
|
|
#define DO_TESTS_SECTION(ID, TEST, TARGET_ATTRS) \
|
26 |
|
|
TEST (ID##1, TARGET_ATTRS, ) \
|
27 |
|
|
TEST (ID##2, TARGET_ATTRS section (".test.a"), section (".test.b")) \
|
28 |
|
|
TEST (ID##3, TARGET_ATTRS section (".test.c"), section (".test.c"))
|
29 |
|
|
|
30 |
|
|
#define DO_TESTS_CALL_ATTR(ID, TEST, TARGET_ATTRS) \
|
31 |
|
|
DO_TESTS_SECTION (ID##n, TEST, TARGET_ATTRS) \
|
32 |
|
|
DO_TESTS_SECTION (ID##l, TEST, TARGET_ATTRS long_call) \
|
33 |
|
|
DO_TESTS_SECTION (ID##s, TEST, TARGET_ATTRS short_call)
|
34 |
|
|
|
35 |
|
|
DO_TESTS_CALL_ATTR (remote_, REMOTE_CALL,)
|
36 |
|
|
DO_TESTS_CALL_ATTR (strong_, EXTERN_CALL,)
|
37 |
|
|
DO_TESTS_CALL_ATTR (weak_, EXTERN_CALL, weak)
|
38 |
|
|
DO_TESTS_CALL_ATTR (static_, STATIC_CALL,)
|
39 |
|
|
|
40 |
|
|
|
41 |
|
|
/* Calls to remote_*, strong_* and weak_* should honor the call type
|
42 |
|
|
attribute, with "short" being the default.
|
43 |
|
|
|
44 |
|
|
In the regular expressions below:
|
45 |
|
|
|
46 |
|
|
* The PLT marker is optional, even though we are using -fpic,
|
47 |
|
|
because it is not used (or required) on some targets.
|
48 |
|
|
|
49 |
|
|
* We allow both "b" and "bl" in some cases to allow for the
|
50 |
|
|
possibility of sibling calls. As of this writing, GCC does not
|
51 |
|
|
use sibling calls in Thumb-2 mode. */
|
52 |
|
|
|
53 |
|
|
/* { dg-final { scan-assembler "\tbl\tremote_n1(\\(PLT\\))?\n" } } */
|
54 |
|
|
/* { dg-final { scan-assembler "\tbl\tremote_n2(\\(PLT\\))?\n" } } */
|
55 |
|
|
/* { dg-final { scan-assembler "\tbl\tremote_n3(\\(PLT\\))?\n" } } */
|
56 |
|
|
|
57 |
|
|
/* { dg-final { scan-assembler-not "\tbl\tremote_l1(\\(PLT\\))?\n" } } */
|
58 |
|
|
/* { dg-final { scan-assembler-not "\tbl\tremote_l2(\\(PLT\\))?\n" } } */
|
59 |
|
|
/* { dg-final { scan-assembler-not "\tbl\tremote_l3(\\(PLT\\))?\n" } } */
|
60 |
|
|
|
61 |
|
|
/* { dg-final { scan-assembler "\tbl\tremote_s1(\\(PLT\\))?\n" } } */
|
62 |
|
|
/* { dg-final { scan-assembler "\tbl\tremote_s2(\\(PLT\\))?\n" } } */
|
63 |
|
|
/* { dg-final { scan-assembler "\tbl\tremote_s3(\\(PLT\\))?\n" } } */
|
64 |
|
|
|
65 |
|
|
|
66 |
|
|
/* { dg-final { scan-assembler "\tbl\tstrong_n1(\\(PLT\\))?\n" } } */
|
67 |
|
|
/* { dg-final { scan-assembler "\tbl?\tstrong_n1(\\(PLT\\))?\n" } } */
|
68 |
|
|
/* { dg-final { scan-assembler "\tbl\tstrong_n2(\\(PLT\\))?\n" } } */
|
69 |
|
|
/* { dg-final { scan-assembler "\tbl?\tstrong_n2(\\(PLT\\))?\n" } } */
|
70 |
|
|
/* { dg-final { scan-assembler "\tbl\tstrong_n3(\\(PLT\\))?\n" } } */
|
71 |
|
|
/* { dg-final { scan-assembler "\tbl?\tstrong_n3(\\(PLT\\))?\n" } } */
|
72 |
|
|
|
73 |
|
|
/* { dg-final { scan-assembler-not "\tbl\tstrong_l1(\\(PLT\\))?\n" } } */
|
74 |
|
|
/* { dg-final { scan-assembler-not "\tbl?\tstrong_l2(\\(PLT\\))?\n" } } */
|
75 |
|
|
/* { dg-final { scan-assembler-not "\tbl\tstrong_l3(\\(PLT\\))?\n" } } */
|
76 |
|
|
|
77 |
|
|
/* { dg-final { scan-assembler "\tbl\tstrong_s1(\\(PLT\\))?\n" } } */
|
78 |
|
|
/* { dg-final { scan-assembler "\tbl?\tstrong_s1(\\(PLT\\))?\n" } } */
|
79 |
|
|
/* { dg-final { scan-assembler "\tbl\tstrong_s2(\\(PLT\\))?\n" } } */
|
80 |
|
|
/* { dg-final { scan-assembler "\tbl?\tstrong_s2(\\(PLT\\))?\n" } } */
|
81 |
|
|
/* { dg-final { scan-assembler "\tbl\tstrong_s3(\\(PLT\\))?\n" } } */
|
82 |
|
|
/* { dg-final { scan-assembler "\tbl?\tstrong_s3(\\(PLT\\))?\n" } } */
|
83 |
|
|
|
84 |
|
|
|
85 |
|
|
/* { dg-final { scan-assembler "\tbl\tweak_n1(\\(PLT\\))?\n" } } */
|
86 |
|
|
/* { dg-final { scan-assembler "\tbl?\tweak_n1(\\(PLT\\))?\n" } } */
|
87 |
|
|
/* { dg-final { scan-assembler "\tbl\tweak_n2(\\(PLT\\))?\n" } } */
|
88 |
|
|
/* { dg-final { scan-assembler "\tbl?\tweak_n2(\\(PLT\\))?\n" } } */
|
89 |
|
|
/* { dg-final { scan-assembler "\tbl\tweak_n3(\\(PLT\\))?\n" } } */
|
90 |
|
|
/* { dg-final { scan-assembler "\tbl?\tweak_n3(\\(PLT\\))?\n" } } */
|
91 |
|
|
|
92 |
|
|
/* { dg-final { scan-assembler-not "\tbl?\tweak_l1(\\(PLT\\))?\n" } } */
|
93 |
|
|
/* { dg-final { scan-assembler-not "\tbl?\tweak_l2(\\(PLT\\))?\n" } } */
|
94 |
|
|
/* { dg-final { scan-assembler-not "\tbl?\tweak_l3(\\(PLT\\))?\n" } } */
|
95 |
|
|
|
96 |
|
|
/* { dg-final { scan-assembler "\tbl\tweak_s1(\\(PLT\\))?\n" } } */
|
97 |
|
|
/* { dg-final { scan-assembler "\tbl?\tweak_s1(\\(PLT\\))?\n" } } */
|
98 |
|
|
/* { dg-final { scan-assembler "\tbl\tweak_s2(\\(PLT\\))?\n" } } */
|
99 |
|
|
/* { dg-final { scan-assembler "\tbl?\tweak_s2(\\(PLT\\))?\n" } } */
|
100 |
|
|
/* { dg-final { scan-assembler "\tbl\tweak_s3(\\(PLT\\))?\n" } } */
|
101 |
|
|
/* { dg-final { scan-assembler "\tbl?\tweak_s3(\\(PLT\\))?\n" } } */
|
102 |
|
|
|
103 |
|
|
|
104 |
|
|
/* Calls to static_*2 calls should honor the call type attribute,
|
105 |
|
|
with "short" being the default. Calls to other static_* functions
|
106 |
|
|
should be short. */
|
107 |
|
|
|
108 |
|
|
/* { dg-final { scan-assembler "\tbl\tstatic_n1((\\(PLT\\))?)\n" } } */
|
109 |
|
|
/* { dg-final { scan-assembler "\tbl?\tstatic_n1((\\(PLT\\))?)\n" } } */
|
110 |
|
|
/* { dg-final { scan-assembler "\tbl\tstatic_n2((\\(PLT\\))?)\n" } } */
|
111 |
|
|
/* { dg-final { scan-assembler "\tbl?\tstatic_n2((\\(PLT\\))?)\n" } } */
|
112 |
|
|
/* { dg-final { scan-assembler "\tbl\tstatic_n3((\\(PLT\\))?)\n" } } */
|
113 |
|
|
/* { dg-final { scan-assembler "\tbl?\tstatic_n3((\\(PLT\\))?)\n" } } */
|
114 |
|
|
|
115 |
|
|
/* { dg-final { scan-assembler "\tbl\tstatic_l1((\\(PLT\\))?)\n" } } */
|
116 |
|
|
/* { dg-final { scan-assembler "\tbl?\tstatic_l1((\\(PLT\\))?)\n" } } */
|
117 |
|
|
/* { dg-final { scan-assembler-not "\tbl?\tstatic_l2((\\(PLT\\))?)\n" } } */
|
118 |
|
|
/* { dg-final { scan-assembler "\tbl\tstatic_l3((\\(PLT\\))?)\n" } } */
|
119 |
|
|
/* { dg-final { scan-assembler "\tbl?\tstatic_l3((\\(PLT\\))?)\n" } } */
|
120 |
|
|
|
121 |
|
|
/* { dg-final { scan-assembler "\tbl\tstatic_s1((\\(PLT\\))?)\n" } } */
|
122 |
|
|
/* { dg-final { scan-assembler "\tbl?\tstatic_s1((\\(PLT\\))?)\n" } } */
|
123 |
|
|
/* { dg-final { scan-assembler "\tbl\tstatic_s2((\\(PLT\\))?)\n" } } */
|
124 |
|
|
/* { dg-final { scan-assembler "\tbl?\tstatic_s2((\\(PLT\\))?)\n" } } */
|
125 |
|
|
/* { dg-final { scan-assembler "\tbl\tstatic_s3((\\(PLT\\))?)\n" } } */
|
126 |
|
|
/* { dg-final { scan-assembler "\tbl?\tstatic_s3((\\(PLT\\))?)\n" } } */
|