[PATCH] D75203: [X86] Relax existing instructions to reduce the number of nops needed for alignment purposes

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 11 15:26:14 PST 2021


MaskRay added subscribers: condy, vsk.
MaskRay added a comment.
Herald added subscribers: dantrushin, pengfei.

The patch locates MCRelaxableFragment's within two MCSymbol's and relaxes some MCRelaxableFragment's to reduce the size of a MCAlignFragment. The behavior is hence dependent on additional temporary labels due to -g.

@condy reported an example where `clang -O1 -g` and `clang -O1` have different .text content
https://bugs.llvm.org/show_bug.cgi?id=42138#c13 (a MCRelaxableFragment (jmp) has 5 bytes with -O1 and 2 bytes with -O1 -g)
(There is also a thread https://lists.llvm.org/pipermail/llvm-dev/2021-January/147568.html CC @vsk for thoughts).

`.p2align 4, 0x90` is common due to loops. For a larger program, with a lot of temporary labels (-g vs non -g), the assembly output difference may be quite destined.

  --- a.s 2021-01-11 13:57:25.055152745 -0800
  +++ b.s 2021-01-11 13:57:20.627140370 -0800
  @@ -2,2 +2,3 @@
          .file   "czw.cc"
  +       .file   1 "/tmp/c" "czw.cc"
          .globl  _ZN1k1lEv                       # -- Begin function _ZN1k1lEv
  @@ -7,2 +8,3 @@
   .Lfunc_begin0:
  +       .loc    1 26 0                          # czw.cc:26:0
          .cfi_startproc
  @@ -11,2 +13,3 @@
   # %bb.0:                                # %entry
  +       #DEBUG_VALUE: l:this <- $rdi
          pushq   %r15
  @@ -27,2 +30,4 @@
   .Ltmp0:
  +.Ltmp3:
  +       #DEBUG_VALUE: l:this <- $rbx
          .cfi_escape 0x2e, 0x00
  @@ -30,9 +35,17 @@
          movq    %rsp, %rdx
  +.Ltmp4:
  +       .loc    1 27 15 prologue_end            # czw.cc:27:15
          movl    $.L.str, %esi
          callq   _ZN1eIciEC1EPc9allocator


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75203/new/

https://reviews.llvm.org/D75203



More information about the llvm-commits mailing list