Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 9, 2024

Conversation

topperc
Copy link
Collaborator

@topperc topperc commented Oct 9, 2024

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.

…::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.
@llvmbot
Copy link
Member

llvmbot commented Oct 9, 2024

@llvm/pr-subscribers-backend-risc-v

Author: Craig Topper (topperc)

Changes

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.


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

1 Files Affected:

  • (modified) llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp (+1-1)
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;
 }
 

Copy link
Member

@lenary lenary left a comment

Choose a reason for hiding this comment

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

Seems reasonable to me.

@topperc topperc merged commit f0fc1d3 into llvm:main Oct 9, 2024
11 checks passed
@topperc topperc deleted the pr/sti branch October 9, 2024 19:55
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