[llvm] [Mips] Did not put fake_use into delay slot (PR #201537)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 4 02:12:30 PDT 2026
https://github.com/yingopq created https://github.com/llvm/llvm-project/pull/201537
Fix #198835.
>From fdd425fbba174eda8379264ef1e2cb06d3d2f668 Mon Sep 17 00:00:00 2001
From: Ying Huang <ying.huang at oss.cipunited.com>
Date: Thu, 4 Jun 2026 16:51:57 +0800
Subject: [PATCH] [Mips] Did not put fake_use into delay slot
Fix #198835.
---
llvm/lib/Target/Mips/MipsDelaySlotFiller.cpp | 17 +++++++++--------
llvm/test/CodeGen/Mips/fake-use.ll | 15 +++++++++++++++
2 files changed, 24 insertions(+), 8 deletions(-)
create mode 100644 llvm/test/CodeGen/Mips/fake-use.ll
diff --git a/llvm/lib/Target/Mips/MipsDelaySlotFiller.cpp b/llvm/lib/Target/Mips/MipsDelaySlotFiller.cpp
index bcfaa7cd2ed2d..7d7dac22520ea 100644
--- a/llvm/lib/Target/Mips/MipsDelaySlotFiller.cpp
+++ b/llvm/lib/Target/Mips/MipsDelaySlotFiller.cpp
@@ -854,10 +854,17 @@ bool MipsDelaySlotFiller::searchRange(MachineBasicBlock &MBB, IterTy Begin,
IterTy CurrI = I;
++I;
LLVM_DEBUG(dbgs() << DEBUG_TYPE ": checking instruction: "; CurrI->dump());
- // Skip debug value.
+
+ if (terminateSearch(*CurrI)) {
+ LLVM_DEBUG(dbgs() << DEBUG_TYPE ": should terminate search: ";
+ CurrI->dump());
+ break;
+ }
+ // Skip debug and pseudo instructions.
// Instruction TargetOpcode::JUMP_TABLE_DEBUG_INFO is only used to note
// jump table debug info.
- if (CurrI->isDebugInstr() || CurrI->isJumpTableDebugInfo()) {
+ if (CurrI->isDebugInstr() || CurrI->isJumpTableDebugInfo() ||
+ CurrI->isMetaInstruction()) {
LLVM_DEBUG(dbgs() << DEBUG_TYPE ": ignoring debug instruction: ";
CurrI->dump());
continue;
@@ -871,12 +878,6 @@ bool MipsDelaySlotFiller::searchRange(MachineBasicBlock &MBB, IterTy Begin,
continue;
}
- if (terminateSearch(*CurrI)) {
- LLVM_DEBUG(dbgs() << DEBUG_TYPE ": should terminate search: ";
- CurrI->dump());
- break;
- }
-
assert((!CurrI->isCall() && !CurrI->isReturn() && !CurrI->isBranch()) &&
"Cannot put calls, returns or branches in delay slot.");
diff --git a/llvm/test/CodeGen/Mips/fake-use.ll b/llvm/test/CodeGen/Mips/fake-use.ll
new file mode 100644
index 0000000000000..c8c7f83624314
--- /dev/null
+++ b/llvm/test/CodeGen/Mips/fake-use.ll
@@ -0,0 +1,15 @@
+; RUN: llc -verify-machineinstrs -mtriple=mipsel-linux-gnu -mcpu=mips32r2 %s -o - | FileCheck %s
+
+define void @fake_use(ptr %aaaa) {
+; CHECK-LABEL: fake_use:
+; CHECK: # %bb.0: # %entry
+; CHECK-NEXT: # fake_use: $a0
+; CHECK-NEXT: jr $ra
+; CHECK-NEXT: nop
+entry:
+ notail call void (...) @llvm.fake.use(ptr %aaaa)
+ ret void
+}
+
+declare void @llvm.fake.use(...)
+
More information about the llvm-commits
mailing list