Skip to content

Commit 757a0e6

Browse files
authored
[SystemZ] Treat FAKE_USE instructions as instructions without a size (#144390)
This patch fixes an error in which `FAKE_USE` instructions would trigger an assertion in SystemZLongBranch due to them having a size of 0 without being excepted in the assertion that each instruction, other than a set of known 0-size instruction types, should have a non-0 size. `FAKE_USE` instructions are no-op instructions that are emitted into LLVM by the `-fextend-variable-liveness` clang flag to help preserve the liveness of source variables in optimized code, and therefore they should be understood as being valid size 0 instructions.
1 parent 6fcdde2 commit 757a0e6

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

llvm/lib/Target/SystemZ/SystemZLongBranch.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ static unsigned getInstSizeInBytes(const MachineInstr &MI,
215215
// These do not have a size:
216216
MI.isDebugOrPseudoInstr() || MI.isPosition() || MI.isKill() ||
217217
MI.isImplicitDef() || MI.getOpcode() == TargetOpcode::MEMBARRIER ||
218-
MI.getOpcode() == TargetOpcode::INIT_UNDEF ||
218+
MI.getOpcode() == TargetOpcode::INIT_UNDEF || MI.isFakeUse() ||
219219
// These have a size that may be zero:
220220
MI.isInlineAsm() || MI.getOpcode() == SystemZ::STACKMAP ||
221221
MI.getOpcode() == SystemZ::PATCHPOINT ||
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
; RUN: llc -O0 < %s -mtriple=s390x-linux-gnu 2>&1 | FileCheck %s
2+
3+
;; Tests that we can handle FAKE_USE instructions, emitting a comment for them
4+
;; in the resulting assembly.
5+
6+
; CHECK: .type idd,@function
7+
; CHECK: # %bb.0:
8+
; CHECK-NEXT: # fake_use:
9+
10+
define double @idd(double %d) {
11+
entry:
12+
notail call void (...) @llvm.fake.use(double %d)
13+
ret double %d
14+
}

0 commit comments

Comments
 (0)