[BOLT][NFC] Simplify debug logging in case of JT heuristic failure

Move logging into LLVM_DEBUG scope.
Remove redundant printing of jump table parents:

Old logging:
```
failed to analyze jump table in function _ZN12_GLOBAL__N_116InitHeaderSearch23Ad
dDefaultCIncludePathsERKN4llvm6TripleERKN5clang19HeaderSearchOptionsE/1(*2)
PIC Jump table JUMP_TABLE/_ZN12_GLOBAL__N_116InitHeaderSearch23AddDefaultCInclud
ePathsERKN4llvm6TripleERKN5clang19HeaderSearchOptionsE/1.1 for function _ZN12_GL
OBAL__N_116InitHeaderSearch23AddDefaultCIncludePathsERKN4llvm6TripleERKN5clang19
HeaderSearchOptionsE/1(*2) at 0x65996e0 with a total count of 0:
  0x9dc

next jump table at 0x659a810 belongs to function _ZN5clang5Lexer40LexDependencyD
irectiveTokenWhileSkippingERNS_5TokenE
PIC Jump table JUMP_TABLE/_ZN5clang5Lexer40LexDependencyDirectiveTokenWhileSkipp
ingERNS_5TokenE.0 for function _ZN5clang5Lexer40LexDependencyDirectiveTokenWhile
SkippingERNS_5TokenE at 0x659a810 with a total count of 0:

jump table heuristic failure
```

New logging:
```
failed to analyze PIC Jump table JUMP_TABLE/_ZN12_GLOBAL__N_116InitHeaderSearch2
3AddDefaultCIncludePathsERKN4llvm6TripleERKN5clang19HeaderSearchOptionsE/1.1 for
function _ZN12_GLOBAL__N_116InitHeaderSearch23AddDefaultCIncludePathsERKN4llvm6T
ripleERKN5clang19HeaderSearchOptionsE/1(*2) at 0x65996e0 with a total count of 0:
  absolute offset: 0x52ac58c

next PIC Jump table JUMP_TABLE/_ZN5clang5Lexer40LexDependencyDirectiveTokenWhile
SkippingERNS_5TokenE.0 for function _ZN5clang5Lexer40LexDependencyDirectiveToken
WhileSkippingERNS_5TokenE at 0x659a810 with a total count of 0:

jump table heuristic failure
```

Reviewed By: rafauler

Differential Revision: https://reviews.llvm.org/D131243
This commit is contained in:
Amir Ayupov 2022-08-17 17:34:49 -07:00
parent cdef841fe7
commit 055f9f6d08
1 changed files with 8 additions and 18 deletions

View File

@ -646,24 +646,14 @@ void BinaryContext::populateJumpTables() {
analyzeJumpTable(JT->getAddress(), JT->Type, *(JT->Parents[0]),
NextJTAddress, &JT->EntriesAsAddress);
if (!Success) {
LLVM_DEBUG(ListSeparator LS;
dbgs() << "failed to analyze jump table in function ";
for (BinaryFunction *Frag
: JT->Parents) dbgs()
<< LS << *Frag;
dbgs() << '\n';);
JT->print(dbgs());
if (NextJTI != JTE) {
LLVM_DEBUG(ListSeparator LS;
dbgs() << "next jump table at 0x"
<< Twine::utohexstr(NextJTI->second->getAddress())
<< " belongs to function ";
for (BinaryFunction *Frag
: NextJTI->second->Parents) dbgs()
<< LS << *Frag;
dbgs() << "\n";);
NextJTI->second->print(dbgs());
}
LLVM_DEBUG({
dbgs() << "failed to analyze ";
JT->print(dbgs());
if (NextJTI != JTE) {
dbgs() << "next ";
NextJTI->second->print(dbgs());
}
});
llvm_unreachable("jump table heuristic failure");
}
for (BinaryFunction *Frag : JT->Parents) {