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

1

2

3

4

5

6

7

8

9

10

11

12

13

40#include

41#include

42

43using namespace llvm;

44

47 return ++PluginKindID;

48}

49

51

55

59

61 const Twine &MsgStr,

64 MsgStr(MsgStr) {}

65

67 const Twine &MsgStr,

70 if (const MDNode *SrcLoc = I.getMetadata("srcloc")) {

71 if (SrcLoc->getNumOperands() != 0)

72 if (const auto *CI =

73 mdconst::dyn_extract(SrcLoc->getOperand(0)))

74 LocCookie = CI->getZExtValue();

75 }

76}

77

83

87

94

100

105

107 const Function &Fn, const char *ResourceName, uint64_t ResourceSize,

110 Fn(Fn), ResourceName(ResourceName), ResourceSize(ResourceSize),

111 ResourceLimit(ResourceLimit) {}

112

116 << ") in function '" << getFunction() << '\'';

117}

118

123

128

130 if (!FileName.empty()) {

132 if (LineNum > 0)

134 DP << ": ";

135 }

137}

138

144

145void DiagnosticInfo::anchor() {}

146void DiagnosticInfoStackSize::anchor() {}

147void DiagnosticInfoWithLocationBase::anchor() {}

148void DiagnosticInfoIROptimization::anchor() {}

149

151 if (DL)

152 return;

153 File = DL->getFile();

154 Line = DL->getLine();

155 Column = DL->getColumn();

156}

157

159 if (!SP)

160 return;

161

162 File = SP->getFile();

163 Line = SP->getScopeLine();

164 Column = 0;

165}

166

168 return File->getFilename();

169}

170

172 StringRef Name = File->getFilename();

174 return std::string(Name);

175

179}

180

182 return Loc.getAbsolutePath();

183}

184

186 unsigned &Line,

187 unsigned &Column) const {

188 RelativePath = Loc.getRelativePath();

189 Line = Loc.getLine();

190 Column = Loc.getColumn();

191}

192

195 unsigned Line = 0;

196 unsigned Column = 0;

199 return (Filename + ":" + Twine(Line) + ":" + Twine(Column)).str();

200}

201

207 Loc = SP;

208 }

210 Loc = I->getDebugLoc();

211

212

213

218 V->printAsOperand(OS, false);

221 OS << "call " << II->getCalledFunction()->getName();

223 Val = I->getOpcodeName();

226 Val = S->getString();

227 }

228}

229

235

238

241

244

247

250

253

257

259 unsigned long long N)

261

268

275

282

285 if (Loc) {

286 Val = (Loc->getFilename() + ":" + Twine(Loc.getLine()) + ":" +

288 } else {

289 Val = "";

290 }

291}

292

296 DP << " (hotness: " << *Hotness << ")";

297}

298

306

313

315 return Func->empty() ? nullptr : &Func->front();

316}

317

324

330

337

345

352

358

365

373

379

386

393

395 DP << Diagnostic;

396}

397

399 DP << Diagnostic;

400}

401

408

413

415 std::string Str;

417

421 DP << Str;

422}

423

427

429 DP << "Instruction selection used fallback path for " << getFunction();

430}

431

433 Args.emplace_back(S);

434}

435

437 Args.push_back(std::move(A));

438}

439

443

447

449 std::string Str;

455 OS << Arg.Val;

456 return Str;

457}

458

460 const Twine &Msg)

464 Msg(Msg) {}

465

469

470void OptimizationRemarkAnalysisFPCommute::anchor() {}

471void OptimizationRemarkAnalysisAliasing::anchor() {}

472

474 const auto *F =

476

477 if (F)

478 return;

479

480 for (int i = 0; i != 2; ++i) {

481 auto AttrName = i == 0 ? "dontcall-error" : "dontcall-warn";

483

484 if (F->hasFnAttribute(AttrName)) {

486 auto A = F->getFnAttribute(AttrName);

488 LocCookie =

491 LocCookie);

492 F->getContext().diagnose(D);

493 }

494 }

495}

496

500 DP << "error\"";

501 else

502 DP << "warn\"";

505}

MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL

static const Function * getParent(const Value *V)

static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")

static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")

This file contains the declarations for the subclasses of Constant, which represent the different fla...

static DISubprogram * getSubprogram(bool IsDistinct, Ts &&...Args)

static const BasicBlock * getFirstFunctionBlock(const Function *Func)

Definition DiagnosticInfo.cpp:314

Module.h This file contains the declarations for the Module class.

This file defines an InstructionCost class that is used when calculating the cost of an instruction,...

static DebugLoc getDebugLoc(MachineBasicBlock::instr_iterator FirstMI, MachineBasicBlock::instr_iterator LastMI)

Return the first DebugLoc that has line number information, given a range of instructions.

uint64_t IntrinsicInst * II

static bool isValid(const char C)

Returns true if C is a valid mangled character: <0-9a-zA-Z_>.

LLVM Basic Block Representation.

Value * getCalledOperand() const

This class represents a function call, abstracting a target machine's calling convention.

Subprogram description. Uses SubclassData1.

StringRef getNote() const

StringRef getFunctionName() const

void print(DiagnosticPrinter &DP) const override

Print using the given DP a user-friendly message.

Definition DiagnosticInfo.cpp:497

void print(DiagnosticPrinter &DP) const override

Definition DiagnosticInfo.cpp:56

const Twine & getMsgStr() const

const Twine & getMsgStr() const

void print(DiagnosticPrinter &DP) const override

Definition DiagnosticInfo.cpp:52

DiagnosticInfoIROptimization(enum DiagnosticKind Kind, enum DiagnosticSeverity Severity, const char *PassName, StringRef RemarkName, const Function &Fn, const DiagnosticLocation &Loc, const BasicBlock *CodeRegion=nullptr)

PassName is the name of the pass emitting this diagnostic.

const Function & getFunction() const

void print(DiagnosticPrinter &DP) const override

Print using the given DP a user-friendly message.

Definition DiagnosticInfo.cpp:428

DiagnosticInfoInlineAsm(uint64_t LocCookie, const Twine &MsgStr LLVM_LIFETIME_BOUND, DiagnosticSeverity Severity=DS_Error)

LocCookie if non-zero gives the line number for this report.

const Twine & getMsgStr() const

void print(DiagnosticPrinter &DP) const override

Definition DiagnosticInfo.cpp:78

uint64_t getLocCookie() const

void print(DiagnosticPrinter &DP) const override

Print using the given DP a user-friendly message.

Definition DiagnosticInfo.cpp:424

void print(DiagnosticPrinter &DP) const override

Print using the given DP a user-friendly message.

Definition DiagnosticInfo.cpp:84

const Twine & getMsgStr() const

void print(DiagnosticPrinter &DP) const override

Print using the given DP a user-friendly message.

Definition DiagnosticInfo.cpp:394

const Twine & getMsg() const

void print(DiagnosticPrinter &DP) const override

Definition DiagnosticInfo.cpp:466

DiagnosticInfoMisExpect(const Instruction *Inst, const Twine &Msg LLVM_LIFETIME_BOUND)

Definition DiagnosticInfo.cpp:459

int FirstExtraArgIndex

If positive, the index of the first argument that only appear in the optimization records and not in ...

const char * PassName

Name of the pass that triggers this report.

void insert(StringRef S)

Definition DiagnosticInfo.cpp:432

StringRef getPassName() const

StringRef RemarkName

Textual identifier for the remark (single-word, CamelCase).

std::string getMsg() const

Definition DiagnosticInfo.cpp:448

void print(DiagnosticPrinter &DP) const override

Definition DiagnosticInfo.cpp:293

bool IsVerbose

The remark is expected to be noisy.

std::optional< uint64_t > Hotness

If profile information is available, this is the number of times the corresponding code was executed ...

SmallVector< Argument, 4 > Args

Arguments collected via the streaming interface.

bool isEnabled() const override

Definition DiagnosticInfo.cpp:409

DiagnosticInfoOptimizationFailure(const Function &Fn, const DiagnosticLocation &Loc, const Twine &Msg)

Fn is the function where the diagnostic is being emitted.

const char * getFileName() const

void print(DiagnosticPrinter &DP) const override

Definition DiagnosticInfo.cpp:139

const Twine & getMsg() const

DiagnosticInfoRegAllocFailure(const Twine &MsgStr, const Function &Fn, const DiagnosticLocation &DL, DiagnosticSeverity Severity=DS_Error)

MsgStr is the message to be reported to the frontend.

Definition DiagnosticInfo.cpp:88

void print(DiagnosticPrinter &DP) const override

Definition DiagnosticInfo.cpp:101

const Function & getFunction() const

void print(DiagnosticPrinter &DP) const override

Definition DiagnosticInfo.cpp:113

const char * getResourceName() const

uint64_t getResourceLimit() const

uint64_t getResourceSize() const

DiagnosticInfoResourceLimit(const Function &Fn, const char *ResourceName, uint64_t ResourceSize, uint64_t ResourceLimit, DiagnosticSeverity Severity=DS_Warning, DiagnosticKind Kind=DK_ResourceLimit)

The function that is concerned by this stack size diagnostic.

Definition DiagnosticInfo.cpp:106

void print(DiagnosticPrinter &DP) const override

Definition DiagnosticInfo.cpp:129

unsigned getLineNum() const

StringRef getFileName() const

const Twine & getMsg() const

void print(DiagnosticPrinter &DP) const override

Print using the given DP a user-friendly message.

Definition DiagnosticInfo.cpp:398

void print(DiagnosticPrinter &DP) const override

Print using the given DP a user-friendly message.

Definition DiagnosticInfo.cpp:414

std::string getLocationStr() const

Return a string with the location information for this diagnostic in the format "file:line:col".

Definition DiagnosticInfo.cpp:193

std::string getAbsolutePath() const

Return the absolute path tot the file.

Definition DiagnosticInfo.cpp:181

bool isLocationAvailable() const

Return true if location information is available for this diagnostic.

const Function & getFunction() const

DiagnosticLocation getLocation() const

DiagnosticInfoWithLocationBase(enum DiagnosticKind Kind, enum DiagnosticSeverity Severity, const Function &Fn, const DiagnosticLocation &Loc)

Fn is the function where the diagnostic is being emitted.

This is the base abstract class for diagnostic reporting in the backend.

DiagnosticSeverity getSeverity() const

LLVM_ABI std::string getAbsolutePath() const

Return the full path to the file.

Definition DiagnosticInfo.cpp:171

LLVM_ABI StringRef getRelativePath() const

Return the file name relative to the compilation directory.

Definition DiagnosticInfo.cpp:167

DiagnosticLocation()=default

Interface for custom diagnostic printing.

FunctionType * getFunctionType() const

Returns the FunctionType for me.

static StringRef dropLLVMManglingEscape(StringRef Name)

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

MDNode * getMetadata(unsigned KindID) const

Get the metadata of given kind attached to this Instruction.

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

LLVM_ABI const DiagnosticHandler * getDiagHandlerPtr() const

getDiagHandlerPtr - Returns const raw pointer of DiagnosticHandler set by setDiagnosticHandler.

const std::string & getModuleIdentifier() const

Get the module identifier which is, essentially, the name of the module.

SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...

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

std::string str() const

str - Get the contents as an std::string.

Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...

The instances of the Type class are immutable: once they are created, they are never changed.

LLVM Value Representation.

LLVM_ABI const Value * stripPointerCasts() const

Strip off pointer casts, all-zero GEPs and address space casts.

LLVM_ABI StringRef getName() const

Return a constant reference to the value's name.

A raw_ostream that writes to an std::string.

This provides a very simple, boring adaptor for a begin and end iterator into a range type.

@ C

The default llvm calling convention, compatible with C.

std::enable_if_t< detail::IsValidPointer< X, Y >::value, X * > extract(Y &&MD)

Extract a Value from Metadata.

LLVM_ABI StringRef remove_leading_dotslash(StringRef path LLVM_LIFETIME_BOUND, Style style=Style::native)

Remove redundant leading "./" pieces and consecutive separators.

LLVM_ABI bool is_absolute(const Twine &path, Style style=Style::native)

Is path absolute?

LLVM_ABI void append(SmallVectorImpl< char > &path, const Twine &a, const Twine &b="", const Twine &c="", const Twine &d="")

Append to path.

This is an optimization pass for GlobalISel generic memory operations.

decltype(auto) dyn_cast(const From &Val)

dyn_cast - Return the argument parameter cast to the specified type.

LLVM_ABI void diagnoseDontCall(const CallInst &CI)

Definition DiagnosticInfo.cpp:473

iterator_range< T > make_range(T x, T y)

Convenience function for iterating over sub-ranges.

std::string utostr(uint64_t X, bool isNeg=false)

DiagnosticKind

Defines the different supported kind of a diagnostic.

@ DK_OptimizationRemarkAnalysis

@ DK_OptimizationRemarkMissed

bool isa(const From &Val)

isa - Return true if the parameter to the template is an instance of one of the template type argu...

const char * to_string(ThinOrFullLTOPhase Phase)

LLVM_ABI int getNextAvailablePluginDiagnosticKind()

Get the next available kind ID for a plugin diagnostic.

Definition DiagnosticInfo.cpp:45

DiagnosticSeverity

Defines the different supported severity of a diagnostic.

DEMANGLE_ABI std::string demangle(std::string_view MangledName)

Attempt to demangle a string using different demangling schemes.

std::string itostr(int64_t X)

Implement std::hash so that hash_code can be used in STL containers.

virtual bool isPassedOptRemarkEnabled(StringRef PassName) const

Return true if passed optimization remarks are enabled, override to provide different implementation.

virtual bool isAnalysisRemarkEnabled(StringRef PassName) const

Return true if analysis remarks are enabled, override to provide different implementation.

virtual bool isMissedOptRemarkEnabled(StringRef PassName) const

Return true if missed optimization remarks are enabled, override to provide different implementation.

Used in the streaming interface as the general argument type.

Argument(StringRef Str="")

Used to set IsVerbose via the stream interface.