On Wed, Mar 17, 2021 at 10:10 PM Alexander Lochmann <info@xxxxxxxxxxxxxxxxxxxxx> wrote: > On 15.03.21 09:02, Dmitry Vyukov wrote: > >>> Does this introduce an additional real of t->kcov_mode? > >>> If yes, please reuse the value read in check_kcov_mode. > >> Okay. How do I get that value from check_kcov_mode() to the caller? > >> Shall I add an additional parameter to check_kcov_mode()? > > > > Yes, I would try to add an additional pointer parameter for mode. I > > think after inlining the compiler should be able to regestrize it. > First, I'll go for the extra argument. However, the compiler doesn't > seem to inline check_kcov_mode(). Can I enforce inlining? > I'm using GCC 9.3 on Debian Testing. That's very strange and wrong. Maybe you use something like CONFIG_CC_OPTIMIZE_FOR_SIZE=y? With gcc-10 I am getting: ffffffff81529ba0 <__sanitizer_cov_trace_pc>: ffffffff81529ba0: 65 8b 05 59 53 af 7e mov %gs:0x7eaf5359(%rip),%eax # 1ef00 <__preempt_count> ffffffff81529ba7: 89 c1 mov %eax,%ecx ffffffff81529ba9: 48 8b 34 24 mov (%rsp),%rsi ffffffff81529bad: 81 e1 00 01 00 00 and $0x100,%ecx ffffffff81529bb3: 65 48 8b 14 25 40 ef mov %gs:0x1ef40,%rdx ffffffff81529bba: 01 00 ffffffff81529bbc: a9 00 01 ff 00 test $0xff0100,%eax ffffffff81529bc1: 74 0e je ffffffff81529bd1 <__sanitizer_cov_trace_pc+0x31> ffffffff81529bc3: 85 c9 test %ecx,%ecx ffffffff81529bc5: 74 35 je ffffffff81529bfc <__sanitizer_cov_trace_pc+0x5c> ffffffff81529bc7: 8b 82 d4 14 00 00 mov 0x14d4(%rdx),%eax ffffffff81529bcd: 85 c0 test %eax,%eax ffffffff81529bcf: 74 2b je ffffffff81529bfc <__sanitizer_cov_trace_pc+0x5c> ffffffff81529bd1: 8b 82 b0 14 00 00 mov 0x14b0(%rdx),%eax ffffffff81529bd7: 83 f8 02 cmp $0x2,%eax ffffffff81529bda: 75 20 jne ffffffff81529bfc <__sanitizer_cov_trace_pc+0x5c> ffffffff81529bdc: 48 8b 8a b8 14 00 00 mov 0x14b8(%rdx),%rcx ffffffff81529be3: 8b 92 b4 14 00 00 mov 0x14b4(%rdx),%edx ffffffff81529be9: 48 8b 01 mov (%rcx),%rax ffffffff81529bec: 48 83 c0 01 add $0x1,%rax ffffffff81529bf0: 48 39 c2 cmp %rax,%rdx ffffffff81529bf3: 76 07 jbe ffffffff81529bfc <__sanitizer_cov_trace_pc+0x5c> ffffffff81529bf5: 48 89 34 c1 mov %rsi,(%rcx,%rax,8) ffffffff81529bf9: 48 89 01 mov %rax,(%rcx) ffffffff81529bfc: c3 retq Oh, wait gcc-9 indeed does not inline: 0000000000000070 <__sanitizer_cov_trace_pc>: 70: 65 48 8b 0c 25 00 00 mov %gs:0x0,%rcx 77: 00 00 79: bf 02 00 00 00 mov $0x2,%edi 7e: 48 89 ce mov %rcx,%rsi 81: 4c 8b 04 24 mov (%rsp),%r8 85: e8 76 ff ff ff callq 0 <check_kcov_mode> 8a: 84 c0 test %al,%al 8c: 74 20 je ae <__sanitizer_cov_trace_pc+0x3e> 8e: 48 8b 91 b8 14 00 00 mov 0x14b8(%rcx),%rdx 95: 8b 89 b4 14 00 00 mov 0x14b4(%rcx),%ecx 9b: 48 8b 02 mov (%rdx),%rax 9e: 48 83 c0 01 add $0x1,%rax a2: 48 39 c1 cmp %rax,%rcx a5: 76 07 jbe ae <__sanitizer_cov_trace_pc+0x3e> a7: 4c 89 04 c2 mov %r8,(%rdx,%rax,8) ab: 48 89 02 mov %rax,(%rdx) ae: c3 retq This looks like a bug in gcc-8/9. gcc-6 inlines again as well as clang-11/12 inline. Please add __always_inline for check_kcov_mode.