Fix for bug PR35549 - Repeated schedule comments.

Differential Revision: https://reviews.llvm.org/D40960

llvm-svn: 320837
This commit is contained in:
Andrew V. Tischenko 2017-12-15 18:13:05 +00:00
parent 5efd4d8b5e
commit 22f0742dda
4 changed files with 24 additions and 18 deletions

View File

@ -722,7 +722,9 @@ void AsmPrinter::EmitFunctionEntryLabel() {
} }
/// emitComments - Pretty-print comments for instructions. /// 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) { AsmPrinter *AP) {
const MachineFunction *MF = MI.getMF(); const MachineFunction *MF = MI.getMF();
const TargetInstrInfo *TII = MF->getSubtarget().getInstrInfo(); const TargetInstrInfo *TII = MF->getSubtarget().getInstrInfo();
@ -766,13 +768,17 @@ static void emitComments(const MachineInstr &MI, raw_ostream &CommentOS,
CommentOS << " Reload Reuse"; CommentOS << " Reload Reuse";
} }
if (Commented && AP->EnablePrintSchedInfo) if (Commented) {
// If any comment was added above and we need sched info comment then if (AP->EnablePrintSchedInfo) {
// add this new comment just after the above comment w/o "\n" between them. // 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"; CommentOS << " " << MF->getSubtarget().getSchedInfoStr(MI) << "\n";
else if (Commented) return true;
}
CommentOS << "\n"; CommentOS << "\n";
} }
return false;
}
/// emitImplicitDef - This method emits the specified machine instruction /// emitImplicitDef - This method emits the specified machine instruction
/// that is an implicit def. /// that is an implicit def.
@ -1013,8 +1019,10 @@ void AsmPrinter::EmitFunctionBody() {
} }
} }
if (isVerbose()) if (isVerbose() && emitComments(MI, OutStreamer->GetCommentOS(), this)) {
emitComments(MI, OutStreamer->GetCommentOS(), this); MachineInstr *MIP = const_cast<MachineInstr *>(&MI);
MIP->setAsmPrinterFlag(MachineInstr::NoSchedComment);
}
switch (MI.getOpcode()) { switch (MI.getOpcode()) {
case TargetOpcode::CFI_INSTRUCTION: case TargetOpcode::CFI_INSTRUCTION:

View File

@ -59,7 +59,9 @@ namespace X86 {
IP_HAS_AD_SIZE = 2, IP_HAS_AD_SIZE = 2,
IP_HAS_REPEAT_NE = 4, IP_HAS_REPEAT_NE = 4,
IP_HAS_REPEAT = 8, 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; } // end namespace X86;

View File

@ -100,7 +100,9 @@ void X86AsmPrinter::StackMapShadowTracker::emitShadowPadding(
} }
void X86AsmPrinter::EmitAndCountInstruction(MCInst &Inst) { 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()); SMShadowTracker.count(Inst, getSubtargetInfo(), CodeEmitter.get());
} }
@ -2000,6 +2002,8 @@ void X86AsmPrinter::EmitInstruction(const MachineInstr *MI) {
MCInst TmpInst; MCInst TmpInst;
MCInstLowering.Lower(MI, 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 // 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 // in a call towards the shadow, but must ensure that the no thread returns

View File

@ -8811,10 +8811,8 @@ define <16 x float> @broadcast_ss_spill(float %x) {
; GENERIC-NEXT: .cfi_def_cfa_offset 32 ; GENERIC-NEXT: .cfi_def_cfa_offset 32
; GENERIC-NEXT: vaddss %xmm0, %xmm0, %xmm0 # sched: [3:1.00] ; GENERIC-NEXT: vaddss %xmm0, %xmm0, %xmm0 # sched: [3:1.00]
; GENERIC-NEXT: vmovaps %xmm0, (%rsp) # 16-byte Spill sched: [5:1.00] ; GENERIC-NEXT: vmovaps %xmm0, (%rsp) # 16-byte Spill sched: [5:1.00]
; GENERIC-NEXT: # sched: [5:1.00]
; GENERIC-NEXT: callq func_f32 ; GENERIC-NEXT: callq func_f32
; GENERIC-NEXT: vbroadcastss (%rsp), %zmm0 # 16-byte Folded Reload sched: [5:1.00] ; GENERIC-NEXT: vbroadcastss (%rsp), %zmm0 # 16-byte Folded Reload sched: [5:1.00]
; GENERIC-NEXT: # sched: [5:1.00]
; GENERIC-NEXT: addq $24, %rsp # sched: [1:0.33] ; GENERIC-NEXT: addq $24, %rsp # sched: [1:0.33]
; GENERIC-NEXT: retq # sched: [1:1.00] ; GENERIC-NEXT: retq # sched: [1:1.00]
; ;
@ -8824,10 +8822,8 @@ define <16 x float> @broadcast_ss_spill(float %x) {
; SKX-NEXT: .cfi_def_cfa_offset 32 ; SKX-NEXT: .cfi_def_cfa_offset 32
; SKX-NEXT: vaddss %xmm0, %xmm0, %xmm0 # sched: [4:0.33] ; SKX-NEXT: vaddss %xmm0, %xmm0, %xmm0 # sched: [4:0.33]
; SKX-NEXT: vmovaps %xmm0, (%rsp) # 16-byte Spill sched: [1:1.00] ; SKX-NEXT: vmovaps %xmm0, (%rsp) # 16-byte Spill sched: [1:1.00]
; SKX-NEXT: # sched: [1:1.00]
; SKX-NEXT: callq func_f32 ; SKX-NEXT: callq func_f32
; SKX-NEXT: vbroadcastss (%rsp), %zmm0 # 16-byte Folded Reload sched: [8:0.50] ; SKX-NEXT: vbroadcastss (%rsp), %zmm0 # 16-byte Folded Reload sched: [8:0.50]
; SKX-NEXT: # sched: [8:0.50]
; SKX-NEXT: addq $24, %rsp # sched: [1:0.25] ; SKX-NEXT: addq $24, %rsp # sched: [1:0.25]
; SKX-NEXT: retq # sched: [7:1.00] ; SKX-NEXT: retq # sched: [7:1.00]
%a = fadd float %x, %x %a = fadd float %x, %x
@ -8845,10 +8841,8 @@ define <8 x double> @broadcast_sd_spill(double %x) {
; GENERIC-NEXT: .cfi_def_cfa_offset 32 ; GENERIC-NEXT: .cfi_def_cfa_offset 32
; GENERIC-NEXT: vaddsd %xmm0, %xmm0, %xmm0 # sched: [3:1.00] ; GENERIC-NEXT: vaddsd %xmm0, %xmm0, %xmm0 # sched: [3:1.00]
; GENERIC-NEXT: vmovapd %xmm0, (%rsp) # 16-byte Spill sched: [5:1.00] ; GENERIC-NEXT: vmovapd %xmm0, (%rsp) # 16-byte Spill sched: [5:1.00]
; GENERIC-NEXT: # sched: [5:1.00]
; GENERIC-NEXT: callq func_f64 ; GENERIC-NEXT: callq func_f64
; GENERIC-NEXT: vbroadcastsd (%rsp), %zmm0 # 16-byte Folded Reload sched: [5:1.00] ; GENERIC-NEXT: vbroadcastsd (%rsp), %zmm0 # 16-byte Folded Reload sched: [5:1.00]
; GENERIC-NEXT: # sched: [5:1.00]
; GENERIC-NEXT: addq $24, %rsp # sched: [1:0.33] ; GENERIC-NEXT: addq $24, %rsp # sched: [1:0.33]
; GENERIC-NEXT: retq # sched: [1:1.00] ; GENERIC-NEXT: retq # sched: [1:1.00]
; ;
@ -8858,10 +8852,8 @@ define <8 x double> @broadcast_sd_spill(double %x) {
; SKX-NEXT: .cfi_def_cfa_offset 32 ; SKX-NEXT: .cfi_def_cfa_offset 32
; SKX-NEXT: vaddsd %xmm0, %xmm0, %xmm0 # sched: [4:0.33] ; SKX-NEXT: vaddsd %xmm0, %xmm0, %xmm0 # sched: [4:0.33]
; SKX-NEXT: vmovapd %xmm0, (%rsp) # 16-byte Spill sched: [1:1.00] ; SKX-NEXT: vmovapd %xmm0, (%rsp) # 16-byte Spill sched: [1:1.00]
; SKX-NEXT: # sched: [1:1.00]
; SKX-NEXT: callq func_f64 ; SKX-NEXT: callq func_f64
; SKX-NEXT: vbroadcastsd (%rsp), %zmm0 # 16-byte Folded Reload sched: [8:0.50] ; SKX-NEXT: vbroadcastsd (%rsp), %zmm0 # 16-byte Folded Reload sched: [8:0.50]
; SKX-NEXT: # sched: [8:0.50]
; SKX-NEXT: addq $24, %rsp # sched: [1:0.25] ; SKX-NEXT: addq $24, %rsp # sched: [1:0.25]
; SKX-NEXT: retq # sched: [7:1.00] ; SKX-NEXT: retq # sched: [7:1.00]
%a = fadd double %x, %x %a = fadd double %x, %x