PR c++/67273
[official-gcc.git] / gcc / testsuite / gcc.target / arm / long-calls-2.c
blob8ce2404c1f7c86c35feda7ca979f27fcb272173d
1 /* Check that long calls to different sections are not optimized to "bl". */
2 /* { dg-do compile { target { arm32 && nonpic } } } */
3 /* { dg-options "-O2 -mlong-calls" } */
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))
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; }
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 (); }
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 (); }
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"))
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)
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,)
41 /* Calls to remote_* should honor the call type attribute,
42 with "long" being the default.
44 In the regular expressions below:
46 * We allow both "b" and "bl" in some cases to allow for the
47 possibility of sibling calls. As of this writing, GCC does not
48 use sibling calls in Thumb-2 mode. */
50 /* { dg-final { scan-assembler-not "\tbl\tremote_n1\n" } } */
51 /* { dg-final { scan-assembler-not "\tbl\tremote_n2\n" } } */
52 /* { dg-final { scan-assembler-not "\tbl\tremote_n3\n" } } */
54 /* { dg-final { scan-assembler-not "\tbl\tremote_l1\n" } } */
55 /* { dg-final { scan-assembler-not "\tbl\tremote_l2\n" } } */
56 /* { dg-final { scan-assembler-not "\tbl\tremote_l3\n" } } */
58 /* { dg-final { scan-assembler "\tbl\tremote_s1\n" } } */
59 /* { dg-final { scan-assembler "\tbl\tremote_s2\n" } } */
60 /* { dg-final { scan-assembler "\tbl\tremote_s3\n" } } */
63 /* Calls to strong_*2 calls should honor the call type attribute,
64 with "long" being the default. Calls to other strong_* functions
65 should be short. */
67 /* { dg-final { scan-assembler "\tbl\tstrong_n1\n" } } */
68 /* { dg-final { scan-assembler "\tbl?\tstrong_n1\n" } } */
69 /* { dg-final { scan-assembler-not "\tbl\tstrong_n2\n" } } */
70 /* { dg-final { scan-assembler "\tbl\tstrong_n3\n" } } */
71 /* { dg-final { scan-assembler "\tbl?\tstrong_n3\n" } } */
73 /* { dg-final { scan-assembler "\tbl\tstrong_l1\n" } } */
74 /* { dg-final { scan-assembler "\tbl?\tstrong_l1\n" } } */
75 /* { dg-final { scan-assembler-not "\tbl?\tstrong_l2\n" } } */
76 /* { dg-final { scan-assembler "\tbl\tstrong_l3\n" } } */
77 /* { dg-final { scan-assembler "\tbl?\tstrong_l3\n" } } */
79 /* { dg-final { scan-assembler "\tbl\tstrong_s1\n" } } */
80 /* { dg-final { scan-assembler "\tbl?\tstrong_s1\n" } } */
81 /* { dg-final { scan-assembler "\tbl\tstrong_s2\n" } } */
82 /* { dg-final { scan-assembler "\tbl?\tstrong_s2\n" } } */
83 /* { dg-final { scan-assembler "\tbl\tstrong_s3\n" } } */
84 /* { dg-final { scan-assembler "\tbl?\tstrong_s3\n" } } */
87 /* Calls to weak_* should honor the call type attribute,
88 with "long" being the default. */
90 /* { dg-final { scan-assembler-not "\tbl?\tweak_n1\n" } } */
91 /* { dg-final { scan-assembler-not "\tbl?\tweak_n2\n" } } */
92 /* { dg-final { scan-assembler-not "\tbl?\tweak_n3\n" } } */
94 /* { dg-final { scan-assembler-not "\tbl?\tweak_l1\n" } } */
95 /* { dg-final { scan-assembler-not "\tbl?\tweak_l2\n" } } */
96 /* { dg-final { scan-assembler-not "\tbl?\tweak_l3\n" } } */
98 /* { dg-final { scan-assembler "\tbl\tweak_s1\n" } } */
99 /* { dg-final { scan-assembler "\tbl?\tweak_s1\n" } } */
100 /* { dg-final { scan-assembler "\tbl\tweak_s2\n" } } */
101 /* { dg-final { scan-assembler "\tbl?\tweak_s2\n" } } */
102 /* { dg-final { scan-assembler "\tbl\tweak_s3\n" } } */
103 /* { dg-final { scan-assembler "\tbl?\tweak_s3\n" } } */
106 /* Calls to static_*2 calls should honor the call type attribute,
107 with "long" being the default. Calls to other static_* functions
108 should be short. */
110 /* { dg-final { scan-assembler "\tbl\tstatic_n1\n" } } */
111 /* { dg-final { scan-assembler "\tbl?\tstatic_n1\n" } } */
112 /* { dg-final { scan-assembler-not "\tbl?\tstatic_n2\n" } } */
113 /* { dg-final { scan-assembler "\tbl\tstatic_n3\n" } } */
114 /* { dg-final { scan-assembler "\tbl?\tstatic_n3\n" } } */
116 /* { dg-final { scan-assembler "\tbl\tstatic_l1\n" } } */
117 /* { dg-final { scan-assembler "\tbl?\tstatic_l1\n" } } */
118 /* { dg-final { scan-assembler-not "\tbl?\tstatic_l2\n" } } */
119 /* { dg-final { scan-assembler "\tbl\tstatic_l3\n" } } */
120 /* { dg-final { scan-assembler "\tbl?\tstatic_l3\n" } } */
122 /* { dg-final { scan-assembler "\tbl\tstatic_s1\n" } } */
123 /* { dg-final { scan-assembler "\tbl?\tstatic_s1\n" } } */
124 /* { dg-final { scan-assembler "\tbl\tstatic_s2\n" } } */
125 /* { dg-final { scan-assembler "\tbl?\tstatic_s2\n" } } */
126 /* { dg-final { scan-assembler "\tbl\tstatic_s3\n" } } */
127 /* { dg-final { scan-assembler "\tbl?\tstatic_s3\n" } } */