llvm-project/bolt/lib
Amir Ayupov 6aa735ceaf [BOLT] Split functions: support fragments with multiple parents
Summary:
Gracefully handle binaries with split functions where two fragments are folded
into one, resulting in a fragment with two parent functions.

This behavior is expected in GCC8+ with -O2 optimization level, where both
function splitting and ICF are enabled by default.

On the BOLT side, the changes are:
- BinaryFunction: allow multiple parent fragments:
  - `ParentFragment` --> `ParentFragments`,
  - `setParentFragment` --> `addParentFragment`.
- BinaryContext:
  - `populateJumpTables`: mark fragments to be skipped later,
  - `registerFragment`: add a name heuristic check, return false if it failed,
  - `processInterproceduralReferences`: check if `registerFragment`
succeeded, otherwise issue a warning,
  - `skipMarkedFragments`: move out fragment traversal and skipping from
  `populateJumpTables` into a separate function.

This change fixes an issue where unrelated functions might be registered
as fragments:

```
BOLT-WARNING: interprocedural reference between unrelated fragments:
bad_gs/1(*2) and amd_decode_mce.cold.27/1(*2)
```

(Linux kernel binary)

(cherry picked from FBD32786688)
2021-12-01 21:14:56 -08:00
..
Core [BOLT] Split functions: support fragments with multiple parents 2021-12-01 21:14:56 -08:00
Passes [BOLT] Refactor BinaryBasicBlock to use ADT 2021-12-09 11:53:12 -08:00
Profile [BOLT] Use more ADT data structures for BinaryFunction 2021-12-08 22:59:09 -08:00
Rewrite [BOLT] Split functions: support fragments with multiple parents 2021-12-01 21:14:56 -08:00
RuntimeLibs Rebase: [NFC] Refactor sources to be buildable in shared mode 2021-10-08 11:47:10 -07:00
Target [BOLT] Refactor BinaryBasicBlock to use ADT 2021-12-09 11:53:12 -08:00
Utils [BOLT] Fix Windows build 2021-11-11 18:14:53 -08:00
CMakeLists.txt Rebase: [NFC] Refactor sources to be buildable in shared mode 2021-10-08 11:47:10 -07:00