comparison lib/CodeGen/MachineOptimizationRemarkEmitter.cpp @ 134:3a76565eade5 LLVM5.0.1

update 5.0.1
author mir3636
date Sat, 17 Feb 2018 09:57:20 +0900
parents 803732b1fca8
children c2174574ed3a
comparison
equal deleted inserted replaced
133:c60214abe0e8 134:3a76565eade5
14 ///===---------------------------------------------------------------------===// 14 ///===---------------------------------------------------------------------===//
15 15
16 #include "llvm/CodeGen/MachineOptimizationRemarkEmitter.h" 16 #include "llvm/CodeGen/MachineOptimizationRemarkEmitter.h"
17 #include "llvm/CodeGen/LazyMachineBlockFrequencyInfo.h" 17 #include "llvm/CodeGen/LazyMachineBlockFrequencyInfo.h"
18 #include "llvm/CodeGen/MachineInstr.h" 18 #include "llvm/CodeGen/MachineInstr.h"
19 #include "llvm/IR/DebugInfo.h"
20 #include "llvm/IR/DiagnosticInfo.h" 19 #include "llvm/IR/DiagnosticInfo.h"
21 #include "llvm/IR/LLVMContext.h" 20 #include "llvm/IR/LLVMContext.h"
22 21
23 using namespace llvm; 22 using namespace llvm;
24 23
26 StringRef MKey, const MachineInstr &MI) 25 StringRef MKey, const MachineInstr &MI)
27 : Argument() { 26 : Argument() {
28 Key = MKey; 27 Key = MKey;
29 28
30 raw_string_ostream OS(Val); 29 raw_string_ostream OS(Val);
31 MI.print(OS, /*SkipOpers=*/false, /*SkipDebugLoc=*/true); 30 MI.print(OS, /*IsStandalone=*/true, /*SkipOpers=*/false,
31 /*SkipDebugLoc=*/true);
32 } 32 }
33 33
34 Optional<uint64_t> 34 Optional<uint64_t>
35 MachineOptimizationRemarkEmitter::computeHotness(const MachineBasicBlock &MBB) { 35 MachineOptimizationRemarkEmitter::computeHotness(const MachineBasicBlock &MBB) {
36 if (!MBFI) 36 if (!MBFI)
49 void MachineOptimizationRemarkEmitter::emit( 49 void MachineOptimizationRemarkEmitter::emit(
50 DiagnosticInfoOptimizationBase &OptDiagCommon) { 50 DiagnosticInfoOptimizationBase &OptDiagCommon) {
51 auto &OptDiag = cast<DiagnosticInfoMIROptimization>(OptDiagCommon); 51 auto &OptDiag = cast<DiagnosticInfoMIROptimization>(OptDiagCommon);
52 computeHotness(OptDiag); 52 computeHotness(OptDiag);
53 53
54 LLVMContext &Ctx = MF.getFunction()->getContext(); 54 LLVMContext &Ctx = MF.getFunction().getContext();
55 55
56 // If a diagnostic has a hotness value, then only emit it if its hotness 56 // Only emit it if its hotness meets the threshold.
57 // meets the threshold. 57 if (OptDiag.getHotness().getValueOr(0) <
58 if (OptDiag.getHotness() && 58 Ctx.getDiagnosticsHotnessThreshold()) {
59 *OptDiag.getHotness() < Ctx.getDiagnosticsHotnessThreshold()) {
60 return; 59 return;
61 } 60 }
62 61
63 Ctx.diagnose(OptDiag); 62 Ctx.diagnose(OptDiag);
64 } 63 }
71 70
72 bool MachineOptimizationRemarkEmitterPass::runOnMachineFunction( 71 bool MachineOptimizationRemarkEmitterPass::runOnMachineFunction(
73 MachineFunction &MF) { 72 MachineFunction &MF) {
74 MachineBlockFrequencyInfo *MBFI; 73 MachineBlockFrequencyInfo *MBFI;
75 74
76 if (MF.getFunction()->getContext().getDiagnosticsHotnessRequested()) 75 if (MF.getFunction().getContext().getDiagnosticsHotnessRequested())
77 MBFI = &getAnalysis<LazyMachineBlockFrequencyInfoPass>().getBFI(); 76 MBFI = &getAnalysis<LazyMachineBlockFrequencyInfoPass>().getBFI();
78 else 77 else
79 MBFI = nullptr; 78 MBFI = nullptr;
80 79
81 ORE = llvm::make_unique<MachineOptimizationRemarkEmitter>(MF, MBFI); 80 ORE = llvm::make_unique<MachineOptimizationRemarkEmitter>(MF, MBFI);