Commit 2614db4
committed
[BOLT][Linux] Skip some functions
Skip some functions to simplify things, making BOLT for Linux more reliable
and saving development efforts.
We use "-bolt-function-list-file" to gather a list of C function when building
Linux kernel, then BOLT can choose to optimize them only.
BOLT can not handle some functions defined in assembly code reliably, since
they may have extra semantics/enforcements BOLT can never know. For example,
irq_entries_start defined in arch/x86/include/asm/idtentry.h is actually an
“array” but BOLT views it as an ordinary function. If BOLT applies basic
block reordering, instrumentation, etc to it, run time errors would happen.
We could explicitly specify those functions to skip, but to find all of them
we usually need to test & debug many times. That is a lot of work and we may
still miss some.
In my own experience, when adapting BOLT for Linux to a new architecture or
Linux version, we may spend lots of time on fixing runtime errors related to
functions defined in assembly code.
Only handling C functions makes BOLT for Linux more reliable, and may save
lots of development efforts.
"-bolt-function-list-file" can be used as follows:
* put "-mllvm -bolt-function-list-file=filename" in KCFLAGS when
buildling Linux
* specify "-funcs-file-no-regex=filename" when invoking llvm-bolt
Some functions's address are used in add/sub/comparision. To make things
simple, they should keep their address (after relocation mode is
supported).
See __bpf_call_base in kernel/bpf/core.c for an example.
Currently, we just skip them.
"bolt-keep-address-function-list-file" can be used as follows:
* put "-mllvm -bolt-keep-address-function-list-file=filename" in
KCFLAGS when buildling Linux
* specify "-keep-address-funcs-file-no-regex=filename" when
invoking llvm-bolt
Functions in sections other than .text (e.g. .head.text, .init.text,
.exit.text) are (mostly) run during initialization and shutdown, and
not (much) relevant to application performance.
Skipping them also helps to avoid runtime errors, especially those
even before the first message is printed out, which are not easy to
debug.
Only handling functions in .text also make sure no function is moved to
a different section (after relocation mode is supported). Linux kernel
code may compare function pointers with section boundary symbols, and
if we move functions to another section, runtime errors may happen.1 parent 01cc1d1 commit 2614db4
File tree
5 files changed
+112
-2
lines changed- bolt
- include/bolt/Core
- lib/Rewrite
- llvm/lib/CodeGen
5 files changed
+112
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
433 | 433 | | |
434 | 434 | | |
435 | 435 | | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
436 | 443 | | |
437 | 444 | | |
438 | 445 | | |
| |||
911 | 918 | | |
912 | 919 | | |
913 | 920 | | |
914 | | - | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
915 | 926 | | |
916 | 927 | | |
917 | 928 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
294 | 294 | | |
295 | 295 | | |
296 | 296 | | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
297 | 300 | | |
298 | 301 | | |
299 | 302 | | |
| |||
1318 | 1321 | | |
1319 | 1322 | | |
1320 | 1323 | | |
| 1324 | + | |
| 1325 | + | |
| 1326 | + | |
1321 | 1327 | | |
1322 | 1328 | | |
1323 | 1329 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
351 | 351 | | |
352 | 352 | | |
353 | 353 | | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
354 | 381 | | |
355 | 382 | | |
356 | 383 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
137 | 137 | | |
138 | 138 | | |
139 | 139 | | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
140 | 150 | | |
141 | 151 | | |
142 | 152 | | |
| |||
2982 | 2992 | | |
2983 | 2993 | | |
2984 | 2994 | | |
| 2995 | + | |
| 2996 | + | |
2985 | 2997 | | |
2986 | 2998 | | |
2987 | 2999 | | |
| |||
2996 | 3008 | | |
2997 | 3009 | | |
2998 | 3010 | | |
| 3011 | + | |
| 3012 | + | |
| 3013 | + | |
| 3014 | + | |
2999 | 3015 | | |
3000 | 3016 | | |
3001 | 3017 | | |
| |||
3043 | 3059 | | |
3044 | 3060 | | |
3045 | 3061 | | |
3046 | | - | |
| 3062 | + | |
| 3063 | + | |
3047 | 3064 | | |
3048 | 3065 | | |
3049 | 3066 | | |
| |||
3094 | 3111 | | |
3095 | 3112 | | |
3096 | 3113 | | |
| 3114 | + | |
| 3115 | + | |
| 3116 | + | |
| 3117 | + | |
3097 | 3118 | | |
3098 | 3119 | | |
3099 | 3120 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
| 88 | + | |
88 | 89 | | |
89 | 90 | | |
90 | 91 | | |
| |||
274 | 275 | | |
275 | 276 | | |
276 | 277 | | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
277 | 286 | | |
278 | 287 | | |
279 | 288 | | |
| |||
505 | 514 | | |
506 | 515 | | |
507 | 516 | | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
508 | 532 | | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
509 | 554 | | |
510 | 555 | | |
511 | 556 | | |
| |||
0 commit comments