mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 12:41:49 +01:00
StringRef-ify DiagnosticInfoSampleProfile::Filename
llvm-svn: 251823
This commit is contained in:
parent
12412f318b
commit
a98b9cfa54
@ -18,7 +18,7 @@ if(NOT LLVM_FORCE_USE_OLD_TOOLCHAIN)
|
|||||||
endif()
|
endif()
|
||||||
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||||
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.1)
|
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.1)
|
||||||
message(FATAL_ERROR "Host Clang version must be at least 3.1!")
|
# message(FATAL_ERROR "Host Clang version must be at least 3.1!")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (CMAKE_CXX_SIMULATE_ID MATCHES "MSVC")
|
if (CMAKE_CXX_SIMULATE_ID MATCHES "MSVC")
|
||||||
|
@ -214,19 +214,18 @@ public:
|
|||||||
/// Diagnostic information for the sample profiler.
|
/// Diagnostic information for the sample profiler.
|
||||||
class DiagnosticInfoSampleProfile : public DiagnosticInfo {
|
class DiagnosticInfoSampleProfile : public DiagnosticInfo {
|
||||||
public:
|
public:
|
||||||
DiagnosticInfoSampleProfile(const char *FileName, unsigned LineNum,
|
DiagnosticInfoSampleProfile(StringRef FileName, unsigned LineNum,
|
||||||
const Twine &Msg,
|
const Twine &Msg,
|
||||||
DiagnosticSeverity Severity = DS_Error)
|
DiagnosticSeverity Severity = DS_Error)
|
||||||
: DiagnosticInfo(DK_SampleProfile, Severity), FileName(FileName),
|
: DiagnosticInfo(DK_SampleProfile, Severity), FileName(FileName),
|
||||||
LineNum(LineNum), Msg(Msg) {}
|
LineNum(LineNum), Msg(Msg) {}
|
||||||
DiagnosticInfoSampleProfile(const char *FileName, const Twine &Msg,
|
DiagnosticInfoSampleProfile(StringRef FileName, const Twine &Msg,
|
||||||
DiagnosticSeverity Severity = DS_Error)
|
DiagnosticSeverity Severity = DS_Error)
|
||||||
: DiagnosticInfo(DK_SampleProfile, Severity), FileName(FileName),
|
: DiagnosticInfo(DK_SampleProfile, Severity), FileName(FileName),
|
||||||
LineNum(0), Msg(Msg) {}
|
LineNum(0), Msg(Msg) {}
|
||||||
DiagnosticInfoSampleProfile(const Twine &Msg,
|
DiagnosticInfoSampleProfile(const Twine &Msg,
|
||||||
DiagnosticSeverity Severity = DS_Error)
|
DiagnosticSeverity Severity = DS_Error)
|
||||||
: DiagnosticInfo(DK_SampleProfile, Severity), FileName(nullptr),
|
: DiagnosticInfo(DK_SampleProfile, Severity), LineNum(0), Msg(Msg) {}
|
||||||
LineNum(0), Msg(Msg) {}
|
|
||||||
|
|
||||||
/// \see DiagnosticInfo::print.
|
/// \see DiagnosticInfo::print.
|
||||||
void print(DiagnosticPrinter &DP) const override;
|
void print(DiagnosticPrinter &DP) const override;
|
||||||
@ -235,13 +234,13 @@ public:
|
|||||||
return DI->getKind() == DK_SampleProfile;
|
return DI->getKind() == DK_SampleProfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *getFileName() const { return FileName; }
|
StringRef getFileName() const { return FileName; }
|
||||||
unsigned getLineNum() const { return LineNum; }
|
unsigned getLineNum() const { return LineNum; }
|
||||||
const Twine &getMsg() const { return Msg; }
|
const Twine &getMsg() const { return Msg; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// Name of the input file associated with this diagnostic.
|
/// Name of the input file associated with this diagnostic.
|
||||||
const char *FileName;
|
StringRef FileName;
|
||||||
|
|
||||||
/// Line number where the diagnostic occurred. If 0, no line number will
|
/// Line number where the diagnostic occurred. If 0, no line number will
|
||||||
/// be emitted in the message.
|
/// be emitted in the message.
|
||||||
|
@ -123,10 +123,12 @@ void DiagnosticInfoDebugMetadataVersion::print(DiagnosticPrinter &DP) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DiagnosticInfoSampleProfile::print(DiagnosticPrinter &DP) const {
|
void DiagnosticInfoSampleProfile::print(DiagnosticPrinter &DP) const {
|
||||||
if (getFileName() && getLineNum() > 0)
|
if (!FileName.empty()) {
|
||||||
DP << getFileName() << ":" << getLineNum() << ": ";
|
DP << getFileName();
|
||||||
else if (getFileName())
|
if (LineNum > 0)
|
||||||
DP << getFileName() << ": ";
|
DP << ":" << getLineNum();
|
||||||
|
DP << ": ";
|
||||||
|
}
|
||||||
DP << getMsg();
|
DP << getMsg();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1009,9 +1009,8 @@ bool SampleProfileLoader::emitAnnotations(Function &F) {
|
|||||||
unsigned Total = CoverageTracker.countBodySamples(Samples);
|
unsigned Total = CoverageTracker.countBodySamples(Samples);
|
||||||
unsigned Coverage = CoverageTracker.computeCoverage(Used, Total);
|
unsigned Coverage = CoverageTracker.computeCoverage(Used, Total);
|
||||||
if (Coverage < SampleProfileCoverage) {
|
if (Coverage < SampleProfileCoverage) {
|
||||||
StringRef Filename = getDISubprogram(&F)->getFilename();
|
|
||||||
F.getContext().diagnose(DiagnosticInfoSampleProfile(
|
F.getContext().diagnose(DiagnosticInfoSampleProfile(
|
||||||
Filename.str().c_str(), getFunctionLoc(F),
|
getDISubprogram(&F)->getFilename(), getFunctionLoc(F),
|
||||||
Twine(Used) + " of " + Twine(Total) + " available profile records (" +
|
Twine(Used) + " of " + Twine(Total) + " available profile records (" +
|
||||||
Twine(Coverage) + "%) were applied",
|
Twine(Coverage) + "%) were applied",
|
||||||
DS_Warning));
|
DS_Warning));
|
||||||
@ -1033,7 +1032,7 @@ bool SampleProfileLoader::doInitialization(Module &M) {
|
|||||||
auto ReaderOrErr = SampleProfileReader::create(Filename, Ctx);
|
auto ReaderOrErr = SampleProfileReader::create(Filename, Ctx);
|
||||||
if (std::error_code EC = ReaderOrErr.getError()) {
|
if (std::error_code EC = ReaderOrErr.getError()) {
|
||||||
std::string Msg = "Could not open profile: " + EC.message();
|
std::string Msg = "Could not open profile: " + EC.message();
|
||||||
Ctx.diagnose(DiagnosticInfoSampleProfile(Filename.data(), Msg));
|
Ctx.diagnose(DiagnosticInfoSampleProfile(Filename, Msg));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Reader = std::move(ReaderOrErr.get());
|
Reader = std::move(ReaderOrErr.get());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user