mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-09 20:37:25 +03:00
[PGO] Fix LLVM 3.9 error handling code.
This commit is contained in:
parent
8bae926fd4
commit
aadb45a946
2 changed files with 20 additions and 4 deletions
|
@ -719,6 +719,16 @@ static void loadInstrProfileData(IRState *irs) {
|
||||||
|
|
||||||
auto readerOrErr =
|
auto readerOrErr =
|
||||||
llvm::IndexedInstrProfReader::create(global.params.datafileInstrProf);
|
llvm::IndexedInstrProfReader::create(global.params.datafileInstrProf);
|
||||||
|
#if LDC_LLVM_VER >= 309
|
||||||
|
if (auto E = readerOrErr.takeError()) {
|
||||||
|
handleAllErrors(std::move(E), [&](const llvm::ErrorInfoBase &EI) {
|
||||||
|
irs->dmodule->error("Could not read profile file %s: %s",
|
||||||
|
global.params.datafileInstrProf,
|
||||||
|
EI.message().c_str());
|
||||||
|
});
|
||||||
|
fatal();
|
||||||
|
}
|
||||||
|
#else
|
||||||
std::error_code EC = readerOrErr.getError();
|
std::error_code EC = readerOrErr.getError();
|
||||||
if (EC) {
|
if (EC) {
|
||||||
irs->dmodule->error("Could not read profile file %s: %s",
|
irs->dmodule->error("Could not read profile file %s: %s",
|
||||||
|
@ -726,6 +736,7 @@ static void loadInstrProfileData(IRState *irs) {
|
||||||
EC.message().c_str());
|
EC.message().c_str());
|
||||||
fatal();
|
fatal();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
irs->PGOReader = std::move(readerOrErr.get());
|
irs->PGOReader = std::move(readerOrErr.get());
|
||||||
|
|
||||||
#if LDC_LLVM_VER >= 309
|
#if LDC_LLVM_VER >= 309
|
||||||
|
|
13
gen/pgo.cpp
13
gen/pgo.cpp
|
@ -890,14 +890,19 @@ void CodeGenPGO::emitCounterIncrement(const RootObject *S) const {
|
||||||
void CodeGenPGO::loadRegionCounts(llvm::IndexedInstrProfReader *PGOReader,
|
void CodeGenPGO::loadRegionCounts(llvm::IndexedInstrProfReader *PGOReader,
|
||||||
const FuncDeclaration *fd) {
|
const FuncDeclaration *fd) {
|
||||||
RegionCounts.clear();
|
RegionCounts.clear();
|
||||||
if (std::error_code EC =
|
if (auto E =
|
||||||
PGOReader->getFunctionCounts(FuncName, FunctionHash, RegionCounts)) {
|
PGOReader->getFunctionCounts(FuncName, FunctionHash, RegionCounts)) {
|
||||||
if (EC == llvm::instrprof_error::unknown_function) {
|
#if LDC_LLVM_VER >= 309
|
||||||
|
auto IPE = llvm::InstrProfError::take(std::move(E));
|
||||||
|
#else
|
||||||
|
auto IPE = E;
|
||||||
|
#endif
|
||||||
|
if (IPE == llvm::instrprof_error::unknown_function) {
|
||||||
IF_LOG Logger::println("No profile data for function: %s",
|
IF_LOG Logger::println("No profile data for function: %s",
|
||||||
FuncName.c_str());
|
FuncName.c_str());
|
||||||
// Don't output a compiler warning when profile data is missing for a
|
// Don't output a compiler warning when profile data is missing for a
|
||||||
// function, because it could be intentional.
|
// function, because it could be intentional.
|
||||||
} else if (EC == llvm::instrprof_error::hash_mismatch) {
|
} else if (IPE == llvm::instrprof_error::hash_mismatch) {
|
||||||
IF_LOG Logger::println(
|
IF_LOG Logger::println(
|
||||||
"Ignoring profile data: hash mismatch for function: %s",
|
"Ignoring profile data: hash mismatch for function: %s",
|
||||||
FuncName.c_str());
|
FuncName.c_str());
|
||||||
|
@ -905,7 +910,7 @@ void CodeGenPGO::loadRegionCounts(llvm::IndexedInstrProfReader *PGOReader,
|
||||||
"control-flow hash mismatch",
|
"control-flow hash mismatch",
|
||||||
const_cast<FuncDeclaration *>(fd)->toPrettyChars(),
|
const_cast<FuncDeclaration *>(fd)->toPrettyChars(),
|
||||||
FuncName.c_str());
|
FuncName.c_str());
|
||||||
} else if (EC == llvm::instrprof_error::malformed) {
|
} else if (IPE == llvm::instrprof_error::malformed) {
|
||||||
IF_LOG Logger::println("Profile data is malformed for function: %s",
|
IF_LOG Logger::println("Profile data is malformed for function: %s",
|
||||||
FuncName.c_str());
|
FuncName.c_str());
|
||||||
warning(fd->loc, "Ignoring profile data for function '%s' ('%s'): "
|
warning(fd->loc, "Ignoring profile data for function '%s' ('%s'): "
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue