LLVM: lib/IR/LLVMRemarkStreamer.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

21#include

22

23using namespace llvm;

24

25

27 switch (Kind) {

28 default:

45 }

46}

47

48

49static std::optionalremarks::RemarkLocation

51 if (DL.isValid())

52 return std::nullopt;

54 unsigned Line = DL.getLine();

55 unsigned Col = DL.getColumn();

57}

58

59

62 remarks::Remark R;

66 R.FunctionName =

70

71 for (const DiagnosticInfoOptimizationBase::Argument &Arg : Diag.getArgs()) {

72 R.Args.emplace_back();

73 R.Args.back().Key = Arg.Key;

74 R.Args.back().Val = Arg.Val;

76 }

77

78 return R;

79}

80

82 if (!RS.matchesFilter(Diag.getPassName()))

83 return;

84

85

87

88 RS.getSerializer().emit(R);

89}

90

94

100 Context.setDiagnosticsHotnessRequested(true);

101

103

106

110

111 std::error_code EC;

114 auto RemarksFile =

115 std::make_unique(RemarksFilename, EC, Flags);

116

117

118 if (EC)

120

125

126 auto RS = std::make_uniqueremarks::RemarkStreamer(

128

131 RS->releaseSerializer();

133 }

134

135

136

137 Context.setMainRemarkStreamer(std::move(RS));

138

139

140 Context.setLLVMRemarkStreamer(

141 std::make_unique(*Context.getMainRemarkStreamer()));

142

144}

145

146void LLVMRemarkFileHandle::Finalizer::finalize() {

147 if (!Context)

148 return;

150 Context = nullptr;

151}

152

158 Context.setDiagnosticsHotnessRequested(true);

159

161

165

170

171 auto RS =

172 std::make_uniqueremarks::RemarkStreamer(std::move(*RemarkSerializer));

173

176 RS->releaseSerializer();

178 }

179

180

181

182 Context.setMainRemarkStreamer(std::move(RS));

183

184

185 Context.setLLVMRemarkStreamer(

186 std::make_unique(*Context.getMainRemarkStreamer()));

187

189}

190

192 Context.setLLVMRemarkStreamer(nullptr);

193 if (auto *RS = Context.getMainRemarkStreamer()) {

194 RS->releaseSerializer();

195 Context.setMainRemarkStreamer(nullptr);

196 }

197}

MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL

Common features for diagnostics dealing with optimization remarks that are used by both IR and MIR pa...

ArrayRef< Argument > getArgs() const

StringRef getPassName() const

StringRef getRemarkName() const

std::optional< uint64_t > getHotness() const

const Function & getFunction() const

void getLocation(StringRef &RelativePath, unsigned &Line, unsigned &Column) const

Return location information for this diagnostic in three parts: the relative source file path,...

Lightweight error class with error context and mandatory checking.

static ErrorSuccess success()

Create a success value.

Tagged union holding either a T or a Error.

Error takeError()

Take ownership of the stored error.

static StringRef dropLLVMManglingEscape(StringRef Name)

If the given string begins with the GlobalValue name mangling escape character '\1',...

This is an important class for using LLVM in a threaded context.

RAII handle that manages the lifetime of the ToolOutputFile used to output remarks.

StringRef - Represent a constant reference to a string, i.e.

LLVM_ABI StringRef getName() const

Return a constant reference to the value's name.

This class implements an extremely fast bulk output stream that can only output to a stream.

@ OF_TextWithCRLF

The file should be opened in text mode and use a carriage linefeed '\r '.

This is an optimization pass for GlobalISel generic memory operations.

cl::opt< std::string > RemarksFormat("lto-pass-remarks-format", cl::desc("The format used for serializing remarks (default: YAML)"), cl::value_desc("format"), cl::init("yaml"))

LLVM_ABI Expected< LLVMRemarkFileHandle > setupLLVMOptimizationRemarks(LLVMContext &Context, StringRef RemarksFilename, StringRef RemarksPasses, StringRef RemarksFormat, bool RemarksWithHotness, std::optional< uint64_t > RemarksHotnessThreshold=0)

Set up optimization remarks that output to a file.

Definition LLVMRemarkStreamer.cpp:95

cl::opt< std::string > RemarksPasses("lto-pass-remarks-filter", cl::desc("Only record optimization remarks from passes whose " "names match the given regular expression"), cl::value_desc("regex"))

DiagnosticKind

Defines the different supported kind of a diagnostic.

@ DK_OptimizationRemarkAnalysis

@ DK_OptimizationRemarkAnalysisAliasing

@ DK_MachineOptimizationRemark

@ DK_OptimizationRemarkMissed

@ DK_MachineOptimizationRemarkAnalysis

@ DK_MachineOptimizationRemarkMissed

@ DK_OptimizationRemarkAnalysisFPCommute

cl::opt< bool > RemarksWithHotness("lto-pass-remarks-with-hotness", cl::desc("With PGO, include profile count in optimization remarks"), cl::Hidden)

cl::opt< std::string > RemarksFilename("lto-pass-remarks-output", cl::desc("Output filename for pass remarks"), cl::value_desc("filename"))

Error make_error(ArgTs &&... Args)

Make a Error instance representing failure using the given error info type.

cl::opt< std::optional< uint64_t >, false, remarks::HotnessThresholdParser > RemarksHotnessThreshold("lto-pass-remarks-hotness-threshold", cl::desc("Minimum profile count required for an " "optimization remark to be output." " Use 'auto' to apply the threshold from profile summary."), cl::value_desc("uint or 'auto'"), cl::init(0), cl::Hidden)

LLVM_ABI Error errorCodeToError(std::error_code EC)

Helper for converting an std::error_code to a Error.

LLVM_ABI void finalizeLLVMOptimizationRemarks(LLVMContext &Context)

Finalize optimization remarks and deregister the RemarkStreamer from the Context.

Definition LLVMRemarkStreamer.cpp:191