diff options
author | Andrew V. Tischenko <andrew.v.tischenko@gmail.com> | 2017-12-15 18:13:05 +0000 |
---|---|---|
committer | Andrew V. Tischenko <andrew.v.tischenko@gmail.com> | 2017-12-15 18:13:05 +0000 |
commit | 22f0742dda8da93de7c6585c9129c81483346b68 (patch) | |
tree | 447cdc1d4ec6d628879defc049fc678c064a0faa /llvm/lib | |
parent | 5efd4d8b5e469f207a633bd4158bd7c3df41c084 (diff) | |
download | llvm-22f0742dda8da93de7c6585c9129c81483346b68.zip llvm-22f0742dda8da93de7c6585c9129c81483346b68.tar.gz llvm-22f0742dda8da93de7c6585c9129c81483346b68.tar.bz2 |
Fix for bug PR35549 - Repeated schedule comments.
Differential Revision: https://reviews.llvm.org/D40960
llvm-svn: 320837
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 24 | ||||
-rw-r--r-- | llvm/lib/Target/X86/MCTargetDesc/X86BaseInfo.h | 4 | ||||
-rw-r--r-- | llvm/lib/Target/X86/X86MCInstLower.cpp | 6 |
3 files changed, 24 insertions, 10 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index 20381e4..294ea51 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -722,7 +722,9 @@ void AsmPrinter::EmitFunctionEntryLabel() { } /// emitComments - Pretty-print comments for instructions. -static void emitComments(const MachineInstr &MI, raw_ostream &CommentOS, +/// It returns true iff the sched comment was emitted. +/// Otherwise it returns false. +static bool emitComments(const MachineInstr &MI, raw_ostream &CommentOS, AsmPrinter *AP) { const MachineFunction *MF = MI.getMF(); const TargetInstrInfo *TII = MF->getSubtarget().getInstrInfo(); @@ -766,12 +768,16 @@ static void emitComments(const MachineInstr &MI, raw_ostream &CommentOS, CommentOS << " Reload Reuse"; } - if (Commented && AP->EnablePrintSchedInfo) - // If any comment was added above and we need sched info comment then - // add this new comment just after the above comment w/o "\n" between them. - CommentOS << " " << MF->getSubtarget().getSchedInfoStr(MI) << "\n"; - else if (Commented) + if (Commented) { + if (AP->EnablePrintSchedInfo) { + // If any comment was added above and we need sched info comment then add + // this new comment just after the above comment w/o "\n" between them. + CommentOS << " " << MF->getSubtarget().getSchedInfoStr(MI) << "\n"; + return true; + } CommentOS << "\n"; + } + return false; } /// emitImplicitDef - This method emits the specified machine instruction @@ -1013,8 +1019,10 @@ void AsmPrinter::EmitFunctionBody() { } } - if (isVerbose()) - emitComments(MI, OutStreamer->GetCommentOS(), this); + if (isVerbose() && emitComments(MI, OutStreamer->GetCommentOS(), this)) { + MachineInstr *MIP = const_cast<MachineInstr *>(&MI); + MIP->setAsmPrinterFlag(MachineInstr::NoSchedComment); + } switch (MI.getOpcode()) { case TargetOpcode::CFI_INSTRUCTION: diff --git a/llvm/lib/Target/X86/MCTargetDesc/X86BaseInfo.h b/llvm/lib/Target/X86/MCTargetDesc/X86BaseInfo.h index f65ba1b..07cc488 100644 --- a/llvm/lib/Target/X86/MCTargetDesc/X86BaseInfo.h +++ b/llvm/lib/Target/X86/MCTargetDesc/X86BaseInfo.h @@ -59,7 +59,9 @@ namespace X86 { IP_HAS_AD_SIZE = 2, IP_HAS_REPEAT_NE = 4, IP_HAS_REPEAT = 8, - IP_HAS_LOCK = 16 + IP_HAS_LOCK = 16, + NO_SCHED_INFO = 32 // Don't add sched comment to the current instr because + // it was already added }; } // end namespace X86; diff --git a/llvm/lib/Target/X86/X86MCInstLower.cpp b/llvm/lib/Target/X86/X86MCInstLower.cpp index f6617b4..8a7179e 100644 --- a/llvm/lib/Target/X86/X86MCInstLower.cpp +++ b/llvm/lib/Target/X86/X86MCInstLower.cpp @@ -100,7 +100,9 @@ void X86AsmPrinter::StackMapShadowTracker::emitShadowPadding( } void X86AsmPrinter::EmitAndCountInstruction(MCInst &Inst) { - OutStreamer->EmitInstruction(Inst, getSubtargetInfo(), EnablePrintSchedInfo); + OutStreamer->EmitInstruction(Inst, getSubtargetInfo(), + EnablePrintSchedInfo && + !(Inst.getFlags() & X86::NO_SCHED_INFO)); SMShadowTracker.count(Inst, getSubtargetInfo(), CodeEmitter.get()); } @@ -2000,6 +2002,8 @@ void X86AsmPrinter::EmitInstruction(const MachineInstr *MI) { MCInst TmpInst; MCInstLowering.Lower(MI, TmpInst); + if (MI->getAsmPrinterFlag(MachineInstr::NoSchedComment)) + TmpInst.setFlags(TmpInst.getFlags() | X86::NO_SCHED_INFO); // Stackmap shadows cannot include branch targets, so we can count the bytes // in a call towards the shadow, but must ensure that the no thread returns |