Commit 5e6dd72
committed
[LoongArch] Fix assertion failure for annotate tablejump
Fix a use-after-free issue related to annotateTableJump in the LoongArch
target.
Previously, LoongArchPreRAExpandPseudo::annotateTableJump() recorded a
reference to a MachineOperand representing a jump table index. However,
later optimizations such as the BranchFolder pass may delete the
instruction containing this operand, leaving a dangling reference.
This led to an assertion failure in LoongArchAsmPrinter::emitJumpTableInfo()
when trying to access a freed MachineOperand via getIndex().
The fix avoids holding a reference to the MachineOperand. Instead, we
extract and store the jump table index at the time of annotation. During
emitJumpTableInfo(), we verify whether the recorded index still exists
in the MachineFunction's jump table. If not, we skip emission for that
entry.
Fixes #1409041 parent 1a08aa2 commit 5e6dd72
File tree
3 files changed
+15
-12
lines changed- llvm/lib/Target/LoongArch
3 files changed
+15
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
265 | 265 | | |
266 | 266 | | |
267 | 267 | | |
268 | | - | |
269 | 268 | | |
270 | 269 | | |
| 270 | + | |
271 | 271 | | |
272 | | - | |
| 272 | + | |
273 | 273 | | |
274 | 274 | | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
275 | 278 | | |
276 | 279 | | |
277 | 280 | | |
278 | 281 | | |
279 | 282 | | |
280 | 283 | | |
281 | 284 | | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
282 | 288 | | |
283 | 289 | | |
284 | 290 | | |
285 | 291 | | |
286 | 292 | | |
287 | | - | |
288 | | - | |
289 | | - | |
| 293 | + | |
290 | 294 | | |
291 | 295 | | |
292 | 296 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
636 | 636 | | |
637 | 637 | | |
638 | 638 | | |
639 | | - | |
| 639 | + | |
| 640 | + | |
640 | 641 | | |
641 | 642 | | |
642 | 643 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
| 44 | + | |
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
80 | | - | |
| 79 | + | |
| 80 | + | |
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
84 | | - | |
85 | | - | |
86 | | - | |
| 84 | + | |
87 | 85 | | |
88 | 86 | | |
89 | 87 | | |
| |||
0 commit comments