[llvm] [RISCV] Use cached SubtargetInfo in AsmPrinter (NFC) (PR #147269)

Petr Vesely via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 7 03:36:12 PDT 2025


================
@@ -517,12 +516,9 @@ void RISCVAsmPrinter::emitSled(const MachineInstr *MI, SledKind Kind) {
   // Assuming we're using JAL to jump to .tmpN, then we only need
   // (68 - 4)/2 = 32 NOPs for RV64 and (44 - 4)/2 = 20 for RV32. However, there
   // is a chance that we'll use C.JAL instead, so an additional NOP is needed.
-  const uint8_t NoopsInSledCount =
-      MI->getParent()->getParent()->getSubtarget<RISCVSubtarget>().is64Bit()
-          ? 33
-          : 21;
+  const uint8_t NoopsInSledCount = STI->is64Bit() ? 33 : 21;
 
-  OutStreamer->emitCodeAlignment(Align(4), &getSubtargetInfo());
----------------
veselypeta wrote:

I think `getSubtargetInfo()` is fine. It's part of the AsmPrinter interface and just returns the non specialised SubtargetInfo - it's also just fetched from the MachineFunction.

https://github.com/llvm/llvm-project/pull/147269


More information about the llvm-commits mailing list