[llvm] [RISCV] Use MCStreamer::emitInstruction instead of calling AsmPrinter::EmitToStreamer. NFC (PR #111714)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 9 10:00:23 PDT 2024


https://github.com/topperc created https://github.com/llvm/llvm-project/pull/111714

This allows us to pass the STI we already have cachced instead of AsmPrinter::EmitToStreamer looking it up from the MachineFunction again.

My plan is to make EmitHwasanMemaccessSymbols use RISCVAsmPrinter::EmitToStreamer instead calling MCStreamer::emitInstruction. To do that I need control of the MCSubtargetInfo.

>From 08d07d5c41fc0e2d88246e2b85bac633847125de Mon Sep 17 00:00:00 2001
From: Craig Topper <craig.topper at sifive.com>
Date: Wed, 9 Oct 2024 09:08:04 -0700
Subject: [PATCH] [RISCV] Use MCStreamer::emitInstruction instead of calling
 AsmPrinter::EmitToStreamer. NFC

This allows us to pass the STI we already have cachced instead of
AsmPrinter::EmitToStreamer looking it up from the MachineFunction
again.

My plan is to make EmitHwasanMemaccessSymbols use RISCVAsmPrinter::EmitToStreamer
instead calling MCStreamer::emitInstruction. To do that I need
control of the MCSubtargetInfo.
---
 llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp b/llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp
index 3bed8c4349dac0..384a7cf59f0632 100644
--- a/llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp
+++ b/llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp
@@ -247,7 +247,7 @@ bool RISCVAsmPrinter::EmitToStreamer(MCStreamer &S, const MCInst &Inst) {
   bool Res = RISCVRVC::compress(CInst, Inst, *STI);
   if (Res)
     ++RISCVNumInstrsCompressed;
-  AsmPrinter::EmitToStreamer(S, Res ? CInst : Inst);
+  S.emitInstruction(Res ? CInst : Inst, *STI);
   return Res;
 }
 



More information about the llvm-commits mailing list