Commit 6b8923a
committed
[llvm][ARM] Correct the properties of trap instructions
Fixes #113154
The encodings used for llvm.trap() on ARM were all marked as
barriers and terminators. This lead to stack frame destroy
code being inserted before the trap if the trap was the last
thing in the function and it had no return statement.
```
void fn() {
volatile int i = 0;
__builtin_trap();
}
```
Produced:
```
fn:
push {r11, lr} << stack frame create
<...>
mov sp, r11
pop {r11, lr} << stack frame destroy
.inst 0xe7ffdefe << trap
bx lr
```
All the other targets don't mark them this way, instead
they mark them with isTrap. I've changed ARM to do this,
which fixes the code generation:
```
fn:
push {r11, lr} << stack frame create
<...>
.inst 0xe7ffdefe << trap
mov sp, r11
pop {r11, lr} << stack frame destroy
bx lr
```
I've updated the existing trap test to force the need for
a stack frame, then check that the instruction immediately
after the trap is resetting the stack pointer.1 parent 4614b80 commit 6b8923a
File tree
3 files changed
+38
-17
lines changed- llvm
- lib/Target/ARM
- test/CodeGen/ARM
3 files changed
+38
-17
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2378 | 2378 | | |
2379 | 2379 | | |
2380 | 2380 | | |
2381 | | - | |
| 2381 | + | |
2382 | 2382 | | |
2383 | 2383 | | |
2384 | 2384 | | |
2385 | 2385 | | |
2386 | 2386 | | |
2387 | | - | |
| 2387 | + | |
2388 | 2388 | | |
2389 | 2389 | | |
2390 | 2390 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
675 | 675 | | |
676 | 676 | | |
677 | 677 | | |
678 | | - | |
| 678 | + | |
679 | 679 | | |
680 | 680 | | |
681 | 681 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
1 | 4 | | |
2 | 5 | | |
3 | 6 | | |
| |||
29 | 32 | | |
30 | 33 | | |
31 | 34 | | |
32 | | - | |
| 35 | + | |
33 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
34 | 41 | | |
35 | | - | |
| 42 | + | |
| 43 | + | |
36 | 44 | | |
37 | 45 | | |
38 | | - | |
| 46 | + | |
| 47 | + | |
39 | 48 | | |
40 | 49 | | |
41 | | - | |
| 50 | + | |
| 51 | + | |
42 | 52 | | |
43 | 53 | | |
44 | | - | |
| 54 | + | |
| 55 | + | |
45 | 56 | | |
46 | 57 | | |
47 | | - | |
| 58 | + | |
| 59 | + | |
48 | 60 | | |
49 | 61 | | |
50 | 62 | | |
| |||
53 | 65 | | |
54 | 66 | | |
55 | 67 | | |
56 | | - | |
| 68 | + | |
57 | 69 | | |
58 | 70 | | |
59 | | - | |
| 71 | + | |
60 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
61 | 77 | | |
62 | | - | |
| 78 | + | |
| 79 | + | |
63 | 80 | | |
64 | 81 | | |
65 | | - | |
| 82 | + | |
| 83 | + | |
66 | 84 | | |
67 | 85 | | |
68 | | - | |
| 86 | + | |
| 87 | + | |
69 | 88 | | |
70 | 89 | | |
71 | | - | |
| 90 | + | |
| 91 | + | |
72 | 92 | | |
73 | 93 | | |
74 | | - | |
| 94 | + | |
| 95 | + | |
75 | 96 | | |
76 | 97 | | |
77 | 98 | | |
| |||
80 | 101 | | |
81 | 102 | | |
82 | 103 | | |
83 | | - | |
| 104 | + | |
84 | 105 | | |
85 | 106 | | |
86 | 107 | | |
| |||
0 commit comments