Commit f414207
committed
[llvm] Pass MachineInstr flags to storeRegToStackSlot/loadRegFromStackSlot (NFC)
This patch is in preparation to enable setting the MachineInstr::MIFlag flags,
i.e. FrameSetup/FrameDestroy, on callee saved register spill/reload instructions
in prologue/epilogue. This eventually helps in setting the prologue_end and
epilogue_begin markers more accurately.
The DWARF Spec in "6.4 Call Frame Information" says:
The code that allocates space on the call frame stack and performs the save
operation is called the subroutine’s prologue, and the code that performs
the restore operation and deallocates the frame is called its epilogue.
which means the callee saved register spills and reloads are part of prologue
(a.k.a frame setup) and epilogue (a.k.a frame destruction), respectively. And,
IIUC, LLVM backend uses FrameSetup/FrameDestroy flags to identify instructions
that are part of call frame setup and destruction.
In the trunk, while most targets consistently set FrameSetup/FrameDestroy on
save/restore call frame information (CFI) instructions of callee saved
registers, they do not consistently set those flags on the actual callee saved
register spill/reload instructions.
I believe this patch provides a clean mechanism to set FrameSetup/FrameDestroy
flags on the actual callee saved register spill/reload instructions as needed.
And, by having default argument of MachineInstr::NoFlags for Flags, this patch
is a NFC.
With this patch, the targets have to just pass FrameSetup/FrameDestroy flag to
the storeRegToStackSlot/loadRegFromStackSlot calls from the target derived
spillCalleeSavedRegisters and restoreCalleeSavedRegisters to set those flags
on callee saved register spill/reload instructions.
Also, this patch makes it very easy to set the source line information on callee
saved register spill/reload instructions which is needed by the DwarfDebug.cpp
implementation to set prologue_end and epilogue_begin markers more accurately.
As per DwarfDebug.cpp implementation:
prologue_end is the first known non-DBG_VALUE and non-FrameSetup location
that marks the beginning of the function body
epilogue_begin is the first FrameDestroy location that has been seen in the
epilogue basic block
With this patch, the targets have to just do the following to set the source
line information on callee saved register spill/reload instructions, without
hampering the LLVM's efforts to avoid adding source line information on the
artificial code generated by the compiler.
<Foo>InstrInfo::storeRegToStackSlot() {
...
DebugLoc DL =
Flags & MachineInstr::FrameSetup ? DebugLoc() : MBB.findDebugLoc(I);
...
}
<Foo>InstrInfo::loadRegFromStackSlot() {
...
DebugLoc DL =
Flags & MachineInstr::FrameDestroy ? MBB.findDebugLoc(I) : DebugLoc();
...
}
While I understand this patch would break out-of-tree backend builds, I think
it is in the right direction.
One immediate use case that can benefit from this patch is fixing #120553
becomes simpler.1 parent 547bfda commit f414207
File tree
51 files changed
+446
-475
lines changed- llvm
- include/llvm/CodeGen
- lib/Target
- AArch64
- AMDGPU
- ARC
- ARM
- AVR
- BPF
- CSKY
- Hexagon
- Lanai
- LoongArch
- M68k
- MSP430
- Mips
- NVPTX
- PowerPC
- RISCV
- Sparc
- SystemZ
- VE
- X86
- XCore
- Xtensa
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
51 files changed
+446
-475
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1142 | 1142 | | |
1143 | 1143 | | |
1144 | 1144 | | |
1145 | | - | |
1146 | | - | |
1147 | | - | |
1148 | | - | |
1149 | | - | |
1150 | | - | |
1151 | | - | |
| 1145 | + | |
| 1146 | + | |
| 1147 | + | |
| 1148 | + | |
| 1149 | + | |
| 1150 | + | |
| 1151 | + | |
| 1152 | + | |
1152 | 1153 | | |
1153 | 1154 | | |
1154 | 1155 | | |
| |||
1160 | 1161 | | |
1161 | 1162 | | |
1162 | 1163 | | |
1163 | | - | |
1164 | | - | |
1165 | | - | |
1166 | | - | |
1167 | | - | |
1168 | | - | |
1169 | | - | |
| 1164 | + | |
| 1165 | + | |
| 1166 | + | |
| 1167 | + | |
| 1168 | + | |
| 1169 | + | |
| 1170 | + | |
| 1171 | + | |
1170 | 1172 | | |
1171 | 1173 | | |
1172 | 1174 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5278 | 5278 | | |
5279 | 5279 | | |
5280 | 5280 | | |
5281 | | - | |
| 5281 | + | |
| 5282 | + | |
5282 | 5283 | | |
5283 | 5284 | | |
5284 | 5285 | | |
| |||
5445 | 5446 | | |
5446 | 5447 | | |
5447 | 5448 | | |
5448 | | - | |
5449 | | - | |
5450 | | - | |
5451 | | - | |
5452 | | - | |
5453 | | - | |
| 5449 | + | |
| 5450 | + | |
| 5451 | + | |
| 5452 | + | |
5454 | 5453 | | |
5455 | 5454 | | |
5456 | 5455 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
347 | 347 | | |
348 | 348 | | |
349 | 349 | | |
350 | | - | |
351 | | - | |
352 | | - | |
353 | | - | |
354 | | - | |
355 | | - | |
356 | | - | |
357 | | - | |
358 | | - | |
359 | | - | |
360 | | - | |
361 | | - | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
362 | 361 | | |
363 | 362 | | |
364 | 363 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1724 | 1724 | | |
1725 | 1725 | | |
1726 | 1726 | | |
1727 | | - | |
| 1727 | + | |
| 1728 | + | |
1728 | 1729 | | |
1729 | 1730 | | |
1730 | 1731 | | |
| |||
1951 | 1952 | | |
1952 | 1953 | | |
1953 | 1954 | | |
1954 | | - | |
| 1955 | + | |
| 1956 | + | |
1955 | 1957 | | |
1956 | 1958 | | |
1957 | 1959 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
280 | 280 | | |
281 | 281 | | |
282 | 282 | | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | | - | |
291 | | - | |
292 | | - | |
293 | | - | |
294 | | - | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
295 | 294 | | |
296 | 295 | | |
297 | 296 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
294 | 294 | | |
295 | 295 | | |
296 | 296 | | |
297 | | - | |
| 297 | + | |
| 298 | + | |
298 | 299 | | |
299 | 300 | | |
300 | 301 | | |
| |||
323 | 324 | | |
324 | 325 | | |
325 | 326 | | |
326 | | - | |
| 327 | + | |
| 328 | + | |
327 | 329 | | |
328 | 330 | | |
329 | 331 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
83 | 82 | | |
84 | 83 | | |
85 | 84 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1118 | 1118 | | |
1119 | 1119 | | |
1120 | 1120 | | |
1121 | | - | |
| 1121 | + | |
| 1122 | + | |
1122 | 1123 | | |
1123 | 1124 | | |
1124 | 1125 | | |
| |||
1379 | 1380 | | |
1380 | 1381 | | |
1381 | 1382 | | |
1382 | | - | |
1383 | | - | |
1384 | | - | |
1385 | | - | |
1386 | | - | |
1387 | | - | |
| 1383 | + | |
| 1384 | + | |
| 1385 | + | |
| 1386 | + | |
1388 | 1387 | | |
1389 | 1388 | | |
1390 | 1389 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
212 | 212 | | |
213 | 213 | | |
214 | 214 | | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
227 | 226 | | |
228 | 227 | | |
229 | 228 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
120 | | - | |
| 120 | + | |
| 121 | + | |
121 | 122 | | |
122 | 123 | | |
123 | 124 | | |
| |||
141 | 142 | | |
142 | 143 | | |
143 | 144 | | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
150 | 149 | | |
151 | 150 | | |
152 | 151 | | |
| |||
0 commit comments