Commit ad605bd
authored
[bolt][aarch64] Change indirect call instrumentation snippet
Indirect call instrumentation snippet uses x16 register in exit
handler to go to destination target
__bolt_instr_ind_call_handler_func:
msr nzcv, x1
ldp x0, x1, [sp], #16
ldr x16, [sp], #16
ldp x0, x1, [sp], #16
br x16 <-----
This patch adds the instrumentation snippet by calling instrumentation
runtime library through indirect call instruction and adding the wrapper
to store/load target value and the register for original indirect instruction.
Example:
mov x16, foo
infirectCall:
adrp x8, Label
add x8, x8, #:lo12:Label
blr x8
Before:
Instrumented indirect call:
stp x0, x1, [sp, #-16]!
mov x0, x8
movk x1, #0x0, lsl #48
movk x1, #0x0, lsl #32
movk x1, #0x0, lsl #16
movk x1, #0x0
stp x0, x1, [sp, #-16]!
adrp x0, __bolt_instr_ind_call_handler_func
add x0, x0, #:lo12:__bolt_instr_ind_call_handler_func
blr x0
__bolt_instr_ind_call_handler: (exit snippet)
msr nzcv, x1
ldp x0, x1, [sp], #16
ldr x16, [sp], #16
ldp x0, x1, [sp], #16
br x16 <- overwrites the original value in X16
__bolt_instr_ind_call_handler_func: (entry snippet)
stp x0, x1, [sp, #-16]!
mrs x1, nzcv
adrp x0, __bolt_instr_ind_call_handler
add x0, x0, x0, #:lo12:__bolt_instr_ind_call_handler
ldr x0, [x0]
cmp x0, #0x0
b.eq __bolt_instr_ind_call_handler
str x30, [sp, #-16]!
blr x0 <--- runtime lib store/load all regs
ldr x30, [sp], #16
b __bolt_instr_ind_call_handler
_________________________________________________________________________
After:
mov x16, foo
infirectCall:
adrp x8, Label
add x8, x8, #:lo12:Label
blr x8
Instrumented indirect call:
stp x0, x1, [sp, #-16]!
mov x0, x8
movk x1, #0x0, lsl #48
movk x1, #0x0, lsl #32
movk x1, #0x0, lsl #16
movk x1, #0x0
stp x0, x30, [sp, #-16]!
adrp x8, __bolt_instr_ind_call_handler_func
add x8, x8, #:lo12:__bolt_instr_ind_call_handler_func
blr x8 <--- call trampoline instr lib
ldp x0, x30, [sp], #16
mov x8, x0 <---- restore original target
ldp x0, x1, [sp], #16
blr x8 <--- original indirect call instruction
// don't touch regs besides x0, x1
__bolt_instr_ind_call_handler: (exit snippet)
ret <---- return to original function with indirect call
__bolt_instr_ind_call_handler_func: (entry snippet)
adrp x0, __bolt_instr_ind_call_handler
add x0, x0, #:lo12:__bolt_instr_ind_call_handler
ldr x0, [x0]
cmp x0, #0x0
b.eq __bolt_instr_ind_call_handler
str x30, [sp, #-16]!
blr x0 <--- runtime lib store/load all regs
ldr x30, [sp], #16
b __bolt_instr_ind_call_handler1 parent d39f524 commit ad605bd
File tree
6 files changed
+164
-63
lines changed- bolt
- include/bolt/Core
- lib
- Passes
- Target/AArch64
- runtime
- test/runtime/AArch64
6 files changed
+164
-63
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
538 | 538 | | |
539 | 539 | | |
540 | 540 | | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
541 | 546 | | |
542 | 547 | | |
543 | 548 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
305 | 305 | | |
306 | 306 | | |
307 | 307 | | |
308 | | - | |
309 | | - | |
310 | | - | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
311 | 314 | | |
312 | 315 | | |
313 | 316 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | | - | |
| 51 | + | |
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
| 58 | + | |
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| |||
2114 | 2114 | | |
2115 | 2115 | | |
2116 | 2116 | | |
| 2117 | + | |
| 2118 | + | |
| 2119 | + | |
| 2120 | + | |
| 2121 | + | |
| 2122 | + | |
| 2123 | + | |
| 2124 | + | |
2117 | 2125 | | |
2118 | 2126 | | |
2119 | 2127 | | |
| |||
2471 | 2479 | | |
2472 | 2480 | | |
2473 | 2481 | | |
2474 | | - | |
2475 | 2482 | | |
2476 | | - | |
2477 | | - | |
2478 | | - | |
2479 | | - | |
2480 | | - | |
2481 | | - | |
2482 | | - | |
2483 | | - | |
2484 | | - | |
2485 | | - | |
2486 | | - | |
2487 | | - | |
2488 | | - | |
| 2483 | + | |
| 2484 | + | |
| 2485 | + | |
| 2486 | + | |
| 2487 | + | |
| 2488 | + | |
| 2489 | + | |
2489 | 2490 | | |
2490 | 2491 | | |
2491 | 2492 | | |
| |||
2561 | 2562 | | |
2562 | 2563 | | |
2563 | 2564 | | |
2564 | | - | |
2565 | 2565 | | |
2566 | | - | |
2567 | | - | |
| 2566 | + | |
| 2567 | + | |
2568 | 2568 | | |
2569 | 2569 | | |
2570 | 2570 | | |
2571 | 2571 | | |
2572 | 2572 | | |
2573 | | - | |
2574 | | - | |
| 2573 | + | |
2575 | 2574 | | |
2576 | | - | |
| 2575 | + | |
| 2576 | + | |
| 2577 | + | |
| 2578 | + | |
| 2579 | + | |
| 2580 | + | |
2577 | 2581 | | |
2578 | | - | |
| 2582 | + | |
| 2583 | + | |
2579 | 2584 | | |
2580 | | - | |
| 2585 | + | |
2581 | 2586 | | |
2582 | 2587 | | |
2583 | 2588 | | |
2584 | 2589 | | |
2585 | | - | |
| 2590 | + | |
2586 | 2591 | | |
2587 | | - | |
2588 | | - | |
| 2592 | + | |
| 2593 | + | |
2589 | 2594 | | |
2590 | 2595 | | |
| 2596 | + | |
2591 | 2597 | | |
2592 | | - | |
| 2598 | + | |
| 2599 | + | |
2593 | 2600 | | |
2594 | | - | |
2595 | | - | |
2596 | | - | |
| 2601 | + | |
| 2602 | + | |
| 2603 | + | |
| 2604 | + | |
| 2605 | + | |
| 2606 | + | |
| 2607 | + | |
| 2608 | + | |
| 2609 | + | |
| 2610 | + | |
| 2611 | + | |
| 2612 | + | |
| 2613 | + | |
| 2614 | + | |
| 2615 | + | |
| 2616 | + | |
| 2617 | + | |
2597 | 2618 | | |
2598 | 2619 | | |
2599 | 2620 | | |
| |||
2602 | 2623 | | |
2603 | 2624 | | |
2604 | 2625 | | |
2605 | | - | |
| 2626 | + | |
2606 | 2627 | | |
2607 | | - | |
2608 | | - | |
2609 | | - | |
2610 | | - | |
| 2628 | + | |
| 2629 | + | |
2611 | 2630 | | |
2612 | 2631 | | |
2613 | 2632 | | |
2614 | 2633 | | |
2615 | 2634 | | |
2616 | 2635 | | |
2617 | 2636 | | |
| 2637 | + | |
| 2638 | + | |
| 2639 | + | |
| 2640 | + | |
| 2641 | + | |
| 2642 | + | |
| 2643 | + | |
| 2644 | + | |
| 2645 | + | |
| 2646 | + | |
| 2647 | + | |
| 2648 | + | |
| 2649 | + | |
| 2650 | + | |
| 2651 | + | |
| 2652 | + | |
| 2653 | + | |
| 2654 | + | |
| 2655 | + | |
| 2656 | + | |
| 2657 | + | |
| 2658 | + | |
| 2659 | + | |
2618 | 2660 | | |
2619 | | - | |
2620 | | - | |
2621 | | - | |
2622 | | - | |
2623 | | - | |
2624 | | - | |
2625 | | - | |
2626 | | - | |
2627 | | - | |
2628 | | - | |
2629 | | - | |
2630 | | - | |
2631 | | - | |
2632 | | - | |
2633 | | - | |
2634 | | - | |
| 2661 | + | |
| 2662 | + | |
2635 | 2663 | | |
2636 | 2664 | | |
2637 | | - | |
| 2665 | + | |
| 2666 | + | |
2638 | 2667 | | |
2639 | | - | |
| 2668 | + | |
| 2669 | + | |
2640 | 2670 | | |
2641 | | - | |
| 2671 | + | |
| 2672 | + | |
2642 | 2673 | | |
2643 | 2674 | | |
2644 | 2675 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1691 | 1691 | | |
1692 | 1692 | | |
1693 | 1693 | | |
| 1694 | + | |
| 1695 | + | |
| 1696 | + | |
1694 | 1697 | | |
1695 | 1698 | | |
1696 | | - | |
| 1699 | + | |
1697 | 1700 | | |
1698 | 1701 | | |
1699 | 1702 | | |
| |||
1728 | 1731 | | |
1729 | 1732 | | |
1730 | 1733 | | |
| 1734 | + | |
| 1735 | + | |
| 1736 | + | |
1731 | 1737 | | |
1732 | 1738 | | |
1733 | | - | |
| 1739 | + | |
1734 | 1740 | | |
1735 | 1741 | | |
1736 | 1742 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | | - | |
| 25 | + | |
| 26 | + | |
25 | 27 | | |
26 | 28 | | |
27 | 29 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
18 | 24 | | |
19 | 25 | | |
20 | | - | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
21 | 75 | | |
22 | 76 | | |
23 | 77 | | |
| |||
0 commit comments