linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* objtool warning "uses BP as a scratch register" with clang-9
@ 2019-08-27 12:30 Arnd Bergmann
  2019-08-27 14:51 ` Josh Poimboeuf
  0 siblings, 1 reply; 38+ messages in thread
From: Arnd Bergmann @ 2019-08-27 12:30 UTC (permalink / raw)
  To: Linux Kernel Mailing List, clang-built-linux
  Cc: Nick Desaulniers, Josh Poimboeuf

I upgraded to the latest clang-9 snapshot from http://apt.llvm.org/ today.
Many problems are fixed, but I still get tons of warnings like

arch/x86/kernel/cpu/mtrr/generic.o: warning: objtool:
mtrr_type_lookup_variable uses BP as a scratch register
arch/x86/kernel/process.o: warning: objtool: get_tsc_mode()+0x21: call
without frame pointer save/setup
arch/x86/kernel/early_printk.o: warning: objtool: early_vga_write uses
BP as a scratch register
arch/x86/kernel/sysfb_simplefb.o: warning: objtool: parse_mode uses BP
as a scratch register
arch/x86/kernel/head64.o: warning: objtool: __startup_64 uses BP as a
scratch register
kernel/time/timeconv.o: warning: objtool: time64_to_tm uses BP as a
scratch register
kernel/trace/ring_buffer.o: warning: objtool:
ring_buffer_discard_commit uses BP as a scratch register
...

I created a reduced test case:

$ cat crc32.i
typedef unsigned u32;
long a, c;
u32 b, f;
u32 *d, *e;
void fn1() {
  u32 *g = &f, *h = e, *i = d;
  for (; a < c; a++)
    b = i[b >> 8 & 255] ^ h[b] ^ g[5];
}
$ clang-9 -c  crc32.i  -O2   ; objtool check  crc32.o
crc32.o: warning: objtool: fn1 uses BP as a scratch register
$ objdump -d crc32.o
0000000000000000 <fn1>:
   0: 55                    push   %rbp
   1: 53                    push   %rbx
   2: 4c 8b 05 00 00 00 00 mov    0x0(%rip),%r8        # 9 <fn1+0x9>
   9: 48 8b 05 00 00 00 00 mov    0x0(%rip),%rax        # 10 <fn1+0x10>
  10: 4c 39 c0              cmp    %r8,%rax
  13: 7e 7f                jle    94 <fn1+0x94>
  15: 48 8b 0d 00 00 00 00 mov    0x0(%rip),%rcx        # 1c <fn1+0x1c>
  1c: 48 8b 15 00 00 00 00 mov    0x0(%rip),%rdx        # 23 <fn1+0x23>
  23: 8b 1d 00 00 00 00    mov    0x0(%rip),%ebx        # 29 <fn1+0x29>
  29: 8b 35 00 00 00 00    mov    0x0(%rip),%esi        # 2f <fn1+0x2f>
  2f: 89 c7                mov    %eax,%edi
  31: 44 29 c7              sub    %r8d,%edi
  34: 40 f6 c7 01          test   $0x1,%dil
  38: 75 05                jne    3f <fn1+0x3f>
  3a: 4c 89 c7              mov    %r8,%rdi
  3d: eb 15                jmp    54 <fn1+0x54>
  3f: 0f b6 ff              movzbl %bh,%edi
  42: 8b 1c 99              mov    (%rcx,%rbx,4),%ebx
  45: 33 1c ba              xor    (%rdx,%rdi,4),%ebx
  48: 31 f3                xor    %esi,%ebx
  4a: 89 1d 00 00 00 00    mov    %ebx,0x0(%rip)        # 50 <fn1+0x50>
  50: 49 8d 78 01          lea    0x1(%r8),%rdi
  54: 49 83 c0 01          add    $0x1,%r8
  58: 4c 39 c0              cmp    %r8,%rax
  5b: 74 30                je     8d <fn1+0x8d>
  5d: 0f 1f 00              nopl   (%rax)
  60: 0f b6 ef              movzbl %bh,%ebp
  63: 89 db                mov    %ebx,%ebx
  65: 8b 1c 99              mov    (%rcx,%rbx,4),%ebx
  68: 33 1c aa              xor    (%rdx,%rbp,4),%ebx
  6b: 31 f3                xor    %esi,%ebx
  6d: 89 1d 00 00 00 00    mov    %ebx,0x0(%rip)        # 73 <fn1+0x73>
  73: 0f b6 ef              movzbl %bh,%ebp
  76: 8b 1c 99              mov    (%rcx,%rbx,4),%ebx
  79: 33 1c aa              xor    (%rdx,%rbp,4),%ebx
  7c: 31 f3                xor    %esi,%ebx
  7e: 89 1d 00 00 00 00    mov    %ebx,0x0(%rip)        # 84 <fn1+0x84>
  84: 48 83 c7 02          add    $0x2,%rdi
  88: 48 39 c7              cmp    %rax,%rdi
  8b: 7c d3                jl     60 <fn1+0x60>
  8d: 48 89 3d 00 00 00 00 mov    %rdi,0x0(%rip)        # 94 <fn1+0x94>
  94: 5b                    pop    %rbx
  95: 5d                    pop    %rbp
  96: c3                    retq

This happens with clang-9 and clang-10 at the moment, but not clang-8.

        Arnd

^ permalink raw reply	[flat|nested] 38+ messages in thread

end of thread, other threads:[~2019-09-04 11:54 UTC | newest]

Thread overview: 38+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-27 12:30 objtool warning "uses BP as a scratch register" with clang-9 Arnd Bergmann
2019-08-27 14:51 ` Josh Poimboeuf
2019-08-27 14:59   ` Ilie Halip
2019-08-27 19:00     ` Arnd Bergmann
2019-08-27 19:22       ` Josh Poimboeuf
2019-08-27 19:47         ` Arnd Bergmann
2019-08-27 21:21           ` Nick Desaulniers
2019-08-28  9:00             ` Arnd Bergmann
2019-08-28 14:06               ` Arnd Bergmann
2019-08-28 14:51               ` Josh Poimboeuf
2019-08-28 15:29                 ` Arnd Bergmann
2019-08-28 17:57                   ` Josh Poimboeuf
2019-08-28 19:41                     ` Arnd Bergmann
2019-08-28 15:13               ` Arnd Bergmann
2019-08-28 15:22                 ` Josh Poimboeuf
2019-08-28 15:28                   ` Arnd Bergmann
2019-08-28 15:40                     ` Arnd Bergmann
2019-08-29 23:24                       ` Josh Poimboeuf
2019-08-30 10:44                         ` Arnd Bergmann
2019-08-30 15:14                           ` Josh Poimboeuf
2019-08-30 15:58                             ` Arnd Bergmann
2019-08-30 16:12                               ` David Laight
2019-08-30 16:03                             ` Linus Torvalds
2019-08-29 17:34                     ` Josh Poimboeuf
2019-08-29 18:30                       ` Linus Torvalds
2019-08-29 20:21                         ` Arnd Bergmann
2019-08-29 22:26                           ` Linus Torvalds
2019-08-30 15:02                             ` Josh Poimboeuf
2019-08-30 15:39                               ` David Laight
2019-08-30 15:48                               ` Linus Torvalds
2019-08-30 15:55                                 ` David Laight
2019-08-30 16:01                                   ` Linus Torvalds
2019-08-30 16:42                                     ` David Laight
2019-08-30 16:49                                 ` Josh Poimboeuf
2019-09-02  9:02                                   ` David Laight
2019-09-04 11:53                         ` Geert Uytterhoeven
2019-08-28 22:13         ` Nick Desaulniers
2019-08-29  0:28           ` Josh Poimboeuf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).