Commit d1d7bec
committed
[BoundsSafety] Improve the soft trap call interface to reduce codesize impact
This patch makes several changes motivated to reduce the code size
impact at call sites to runtime functions.
* `__bounds_safety_soft_trap_c` function no longer takes an integer argument and
has been renamed to remove the `_c` suffix. The corresponding
`call-with-code` option to `-fbounds-safety-soft-traps=` has been
renamed to `call-minimal`. We can reduce codeisze by avoiding writing
constants into the `x0` on arm64 which saves us 1 instruction (4
bytes) per call. The original motivation for passing an integer code
was to aid debugging in the scenario where debug info is missing.
This scenario isn't the primary use case and codesize is far more
important so removing the argument seems like the better design
choice.
* The runtime functions now use the `preserve_all` calling convention
on x86_64 and arm64. This calling convention means that some registers
that are normally caller-saved become callee-saved. This means that
these registers do not need to be spilled at callsites which should
reduce some code size overhead. This isn't the perfect calling
convention because the argument passing registers could also be made
callee saved currently aren't but such a calling convention isn't
currently implemented in LLVM so this is the best we can do for now.
A hidden flag (`-bounds-safety-soft-trap-preserve-all-cc=false`) to
turn off this behavior is included. It is primarly there to make it
easy to measure the codesize impact without having to rebuild the
compiler.
Note: While this is an ABI breaking change
`__CLANG_BOUNDS_SAFETY_SOFT_TRAP_API_VERSION` has not been bumped
because there are currently aren't any adopters of the soft trap mode
yet.
rdar://164341162
(cherry picked from commit 4455ec3)
Conflicts:
clang/test/BoundsSafety/CodeGen/soft-traps/call_minimal.c
clang/test/BoundsSafety/CodeGen/soft-traps/call_minimal_custom_func.c
clang/test/BoundsSafety/CodeGen/soft-traps/call_minimal_with_ubsan.c
clang/test/BoundsSafety/CodeGen/soft-traps/call_with_str.c
clang/test/BoundsSafety/CodeGen/soft-traps/call_with_str_custom_func.c
clang/test/BoundsSafety/CodeGen/soft-traps/call_with_str_with_ubsan.c1 parent 5ff34b0 commit d1d7bec
File tree
20 files changed
+301
-123
lines changed- clang
- include/clang
- Basic
- Driver
- lib
- CodeGen
- Frontend
- Headers
- test/BoundsSafety
- CodeGen
- soft-traps
- trap-reasons
- Sema
- lldb/test/Shell/BoundsSafety
- Inputs
20 files changed
+301
-123
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
194 | 194 | | |
195 | 195 | | |
196 | 196 | | |
197 | | - | |
198 | | - | |
199 | | - | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
200 | 201 | | |
201 | 202 | | |
202 | 203 | | |
203 | 204 | | |
204 | | - | |
| 205 | + | |
205 | 206 | | |
206 | 207 | | |
207 | 208 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2065 | 2065 | | |
2066 | 2066 | | |
2067 | 2067 | | |
2068 | | - | |
| 2068 | + | |
2069 | 2069 | | |
2070 | 2070 | | |
2071 | 2071 | | |
2072 | 2072 | | |
2073 | | - | |
2074 | | - | |
2075 | | - | |
2076 | | - | |
| 2073 | + | |
| 2074 | + | |
| 2075 | + | |
| 2076 | + | |
| 2077 | + | |
2077 | 2078 | | |
2078 | | - | |
| 2079 | + | |
2079 | 2080 | | |
2080 | 2081 | | |
2081 | 2082 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
69 | 77 | | |
70 | 78 | | |
71 | 79 | | |
| |||
4714 | 4722 | | |
4715 | 4723 | | |
4716 | 4724 | | |
4717 | | - | |
| 4725 | + | |
4718 | 4726 | | |
4719 | 4727 | | |
4720 | 4728 | | |
4721 | | - | |
4722 | | - | |
4723 | | - | |
4724 | | - | |
4725 | | - | |
| 4729 | + | |
| 4730 | + | |
| 4731 | + | |
| 4732 | + | |
4726 | 4733 | | |
4727 | 4734 | | |
4728 | 4735 | | |
4729 | 4736 | | |
4730 | | - | |
4731 | | - | |
4732 | | - | |
4733 | | - | |
4734 | | - | |
4735 | | - | |
| 4737 | + | |
| 4738 | + | |
| 4739 | + | |
| 4740 | + | |
| 4741 | + | |
| 4742 | + | |
| 4743 | + | |
4736 | 4744 | | |
4737 | 4745 | | |
4738 | 4746 | | |
4739 | 4747 | | |
4740 | 4748 | | |
4741 | | - | |
4742 | | - | |
4743 | 4749 | | |
4744 | 4750 | | |
4745 | | - | |
| 4751 | + | |
| 4752 | + | |
| 4753 | + | |
| 4754 | + | |
| 4755 | + | |
| 4756 | + | |
| 4757 | + | |
| 4758 | + | |
| 4759 | + | |
| 4760 | + | |
| 4761 | + | |
| 4762 | + | |
| 4763 | + | |
| 4764 | + | |
| 4765 | + | |
| 4766 | + | |
| 4767 | + | |
| 4768 | + | |
| 4769 | + | |
| 4770 | + | |
| 4771 | + | |
| 4772 | + | |
| 4773 | + | |
| 4774 | + | |
| 4775 | + | |
| 4776 | + | |
| 4777 | + | |
4746 | 4778 | | |
4747 | 4779 | | |
4748 | 4780 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2566 | 2566 | | |
2567 | 2567 | | |
2568 | 2568 | | |
2569 | | - | |
2570 | | - | |
| 2569 | + | |
| 2570 | + | |
2571 | 2571 | | |
2572 | 2572 | | |
2573 | 2573 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
25 | 36 | | |
26 | 37 | | |
27 | 38 | | |
28 | 39 | | |
29 | 40 | | |
30 | 41 | | |
| 42 | + | |
31 | 43 | | |
32 | 44 | | |
33 | | - | |
34 | | - | |
35 | 45 | | |
36 | 46 | | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
43 | 50 | | |
44 | 51 | | |
45 | 52 | | |
| |||
Lines changed: 39 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
Lines changed: 24 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
| 40 | + | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
| 46 | + | |
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
| 52 | + | |
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
72 | | - | |
| 72 | + | |
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
78 | | - | |
| 78 | + | |
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
84 | | - | |
| 84 | + | |
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
94 | 104 | | |
| 105 | + | |
| 106 | + | |
95 | 107 | | |
96 | 108 | | |
97 | 109 | | |
98 | 110 | | |
| 111 | + | |
| 112 | + | |
99 | 113 | | |
100 | 114 | | |
101 | 115 | | |
| |||
Lines changed: 38 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
0 commit comments