This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Override EmitToStreamer in RISCVAsmPrinter to handle missed compression opportunities
ClosedPublic

Authored by sabuasal on Mar 30 2018, 7:34 PM.

Details

Summary

[RISCV] Update EmitToStreamer in RISCVAsmPrinter to handle missed compression
opportunities

Updating Compression hooks in D41932 to move compression from
ElfStream to AsmPrinter caused missing  opportunities for
compression. This is due to emitPseudoExpansionLowering lowering
Machine instructions to MC Instructions and emitting them directly
to the stream without calling compression.

This patch fixes the problem by shadowing EmitToStreamer in
RISCVAsmPrinter to call compressInst before emitting.

Diff Detail

Event Timeline

sabuasal created this revision.Mar 30 2018, 7:34 PM

Oh, I didn't realize there was another codepath when I suggested RISCVAsmPrinter::EmitInstruction.

It's generally a good idea to avoid virtual functions where possible... in this context, I think it would work correctly if you just shadow the function?

asb added a comment.Apr 4 2018, 7:44 AM

This seems like a good improvement. As Eli says, avoiding the virtual function if possible would be ideal.

sabuasal updated this revision to Diff 141244.Apr 5 2018, 5:22 PM

Shadow instead of override.

Thanks @efriedma !

sabuasal edited the summary of this revision. (Show Details)Apr 5 2018, 5:24 PM
asb accepted this revision.Apr 6 2018, 2:55 AM

Looks good to me. Thanks.

This revision is now accepted and ready to land.Apr 6 2018, 2:55 AM