Skip to content

Commit 28963d8

Browse files
committed
[GlobalISel] Don't DCE LIFETIME_START/LIFETIME_END markers.
These are pseudos without any users, so DCE was killing them in the combiner. Marking them as having side effects doesn't seem quite right since they don't. Gives a nice 0.3% geomean size win on CTMark -Os. Differential Revision: https://reviews.llvm.org/D98811
1 parent 1a4bc3a commit 28963d8

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

llvm/lib/CodeGen/GlobalISel/Utils.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,10 @@ bool llvm::isTriviallyDead(const MachineInstr &MI,
200200
// Don't delete frame allocation labels.
201201
if (MI.getOpcode() == TargetOpcode::LOCAL_ESCAPE)
202202
return false;
203+
// LIFETIME markers should be preserved even if they seem dead.
204+
if (MI.getOpcode() == TargetOpcode::LIFETIME_START ||
205+
MI.getOpcode() == TargetOpcode::LIFETIME_END)
206+
return false;
203207

204208
// If we can move an instruction, we can remove it. Otherwise, it has
205209
// a side-effect of some sort.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2+
# RUN: llc -mtriple aarch64 -run-pass=aarch64-prelegalizer-combiner -global-isel -verify-machineinstrs %s -o - | FileCheck %s
3+
# Check that we don't DCE the lifetime markers even though they don't have any users.
4+
---
5+
name: test_lifetime_no_dce
6+
alignment: 4
7+
tracksRegLiveness: true
8+
frameInfo:
9+
maxAlignment: 4
10+
stack:
11+
- { id: 0, size: 4, alignment: 4 }
12+
machineFunctionInfo: {}
13+
body: |
14+
bb.1:
15+
;%0:_(p0) = G_FRAME_INDEX %stack.0.slot
16+
; CHECK-LABEL: name: test_lifetime_no_dce
17+
; CHECK: LIFETIME_START %stack.0
18+
; CHECK: LIFETIME_END %stack.0
19+
; CHECK: RET_ReallyLR
20+
LIFETIME_START %stack.0
21+
LIFETIME_END %stack.0
22+
RET_ReallyLR
23+
24+
...

0 commit comments

Comments
 (0)