Skip to content

[Mips] Correctly report sizes for PATCHABLE_* - #188229

Merged
nikic merged 2 commits into
llvm:mainfrom
nikic:mips-instr-size
Apr 1, 2026
Merged

[Mips] Correctly report sizes for PATCHABLE_*#188229
nikic merged 2 commits into
llvm:mainfrom
nikic:mips-instr-size

Conversation

@nikic

@nikic nikic commented Mar 24, 2026

Copy link
Copy Markdown
Contributor

Report the size of the xray sled.

See

void MipsAsmPrinter::EmitSled(const MachineInstr &MI, SledKind Kind) {
for the corresponding lowering.

This came up while working on #187703.

@nikic
nikic requested a review from yingopq March 24, 2026 11:49
@llvmbot

llvmbot commented Mar 24, 2026

Copy link
Copy Markdown
Member

@llvm/pr-subscribers-backend-mips

Author: Nikita Popov (nikic)

Changes

Report the size of the xray sled.

See

void MipsAsmPrinter::EmitSled(const MachineInstr &MI, SledKind Kind) {
for the corresponding lowering.

This came up while working on #187703.


Full diff: https://github.com/llvm/llvm-project/pull/188229.diff

1 Files Affected:

  • (modified) llvm/lib/Target/Mips/MipsInstrInfo.cpp (+8)
diff --git a/llvm/lib/Target/Mips/MipsInstrInfo.cpp b/llvm/lib/Target/Mips/MipsInstrInfo.cpp
index c879c46e49dd4..a02340fdce973 100644
--- a/llvm/lib/Target/Mips/MipsInstrInfo.cpp
+++ b/llvm/lib/Target/Mips/MipsInstrInfo.cpp
@@ -714,6 +714,14 @@ unsigned MipsInstrInfo::getInstSizeInBytes(const MachineInstr &MI) const {
     const char *AsmStr = MI.getOperand(0).getSymbolName();
     return getInlineAsmLength(AsmStr, *MF->getTarget().getMCAsmInfo());
   }
+  case TargetOpcode::PATCHABLE_FUNCTION_ENTER:
+  case TargetOpcode::PATCHABLE_FUNCTION_EXIT:
+  case TargetOpcode::PATCHABLE_TAIL_CALL:
+    // Size of xray sled
+    if (Subtarget.isGP64bit())
+      return 16 * 4;
+    else
+      return 13 * 4;
   case Mips::CONSTPOOL_ENTRY:
     // If this machine instr is a constant pool entry, its size is recorded as
     // operand #2.

@github-actions

github-actions Bot commented Mar 24, 2026

Copy link
Copy Markdown

🪟 Windows x64 Test Results

  • 132970 tests passed
  • 3047 tests skipped

✅ The build succeeded and all tests passed.

@nikic

nikic commented Mar 31, 2026

Copy link
Copy Markdown
Contributor Author

Ping

if (Subtarget.isGP64bit())
return 16 * 4;
else
return 13 * 4;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add some comments regarding the numbers?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@nikic
nikic force-pushed the mips-instr-size branch from c08bc50 to 883ff1d Compare April 1, 2026 08:13
@yingopq

yingopq commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

LGTM.

@nikic
nikic merged commit d148881 into llvm:main Apr 1, 2026
10 checks passed
@nikic
nikic deleted the mips-instr-size branch April 1, 2026 12:35
joaovam pushed a commit to joaovam/llvm-project that referenced this pull request Apr 2, 2026
Report the size of the xray sled.

This came up while working on
llvm#187703.
zwu-2025 pushed a commit to zwu-2025/llvm-project that referenced this pull request May 17, 2026
Report the size of the xray sled.

This came up while working on
llvm#187703.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants