namespace {
class RISCVAsmPrinter : public AsmPrinter {
- const MCSubtargetInfo *MCSTI;
const RISCVSubtarget *STI;
public:
explicit RISCVAsmPrinter(TargetMachine &TM,
std::unique_ptr<MCStreamer> Streamer)
- : AsmPrinter(TM, std::move(Streamer)), MCSTI(TM.getMCSubtargetInfo()) {}
+ : AsmPrinter(TM, std::move(Streamer)) {}
StringRef getPassName() const override { return "RISCV Assembly Printer"; }
}
bool RISCVAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
- // Set the current MCSubtargetInfo to a copy which has the correct
- // feature bits for the current MachineFunction
- MCSubtargetInfo &NewSTI =
- OutStreamer->getContext().getSubtargetCopy(*TM.getMCSubtargetInfo());
- NewSTI.setFeatureBits(MF.getSubtarget().getFeatureBits());
- MCSTI = &NewSTI;
STI = &MF.getSubtarget<RISCVSubtarget>();
SetupMachineFunction(MF);
void RISCVAsmPrinter::emitAttributes() {
RISCVTargetStreamer &RTS =
static_cast<RISCVTargetStreamer &>(*OutStreamer->getTargetStreamer());
- RTS.emitTargetAttributes(*MCSTI);
+ // Use MCSubtargetInfo from TargetMachine. Individual functions may have
+ // attributes that differ from other functions in the module and we have no
+ // way to know which function is correct.
+ RTS.emitTargetAttributes(*TM.getMCSubtargetInfo());
}
void RISCVAsmPrinter::emitFunctionEntryLabel() {