[PATCH] D97982: [MC] Introduce NeverAlign fragment type

Amir Ayupov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 14 15:34:04 PDT 2021


Amir added a comment.

In D97982#2811315 <https://reviews.llvm.org/D97982#2811315>, @efriedma wrote:

>> Which disables NeverAlign padding (0 bytes)
>
> When do we actually do this computation?  At first glance, MCAssembler::layoutSectionOnce never actually goes back to recompute the size of the NeverAlign padding.

So it's the case that layoutSectionOnce/layoutOnce actually recomputes the size of the NeverAlign padding indirectly:

Inside layoutSectionOnce, when it relaxes the fragment (relaxFragment), if the fragment is FT_Relaxable, it calls relaxInstruction, which in turn checks fragmentNeedsRelaxation for the passed fragment F, which then goes over F->getFixups, calling evaluateFixup, and so on through Layout.getSymbolOffset(Sym) and Layout.getFragmentOffset, inside the ensureValid check, calls layoutFragment, which then computes fragment size (computeFragmentSize):

  (gdb) l
  382           return 0;
  383         return Size;
  384       }
  385
  386       case MCFragment::FT_NeverAlign: {
  >387         const MCNeverAlignFragment &NAF = cast<MCNeverAlignFragment>(F);
  388         const MCFragment *NF = F.getNextNode();
  389         uint64_t Offset = Layout.getFragmentOffset(&NAF);
  390         size_t NextFragSize = 0;
  391         if (const auto *NextFrag = dyn_cast<MCRelaxableFragment>(NF)) {
  (gdb) bt
  #0  llvm::MCAssembler::computeFragmentSize (this=0x10499e0, Layout=..., F=...) at /home/aaupov/local/llvm-project/llvm/lib/MC/MCAssembler.cpp:387
  #1  0x0000000000503e54 in llvm::MCAsmLayout::layoutFragment (this=0x7fffffffc4e0, F=0x104e770)
      at /home/aaupov/local/llvm-project/llvm/lib/MC/MCAssembler.cpp:470
  #2  0x0000000000553b8f in llvm::MCAsmLayout::ensureValid (this=0x7fffffffc4e0, F=0x104e9a0)
      at /home/aaupov/local/llvm-project/llvm/lib/MC/MCFragment.cpp:91
  #3  0x0000000000553bc7 in llvm::MCAsmLayout::getFragmentOffset (this=0x7fffffffc4e0, F=0x104e9a0)
      at /home/aaupov/local/llvm-project/llvm/lib/MC/MCFragment.cpp:97
  #4  0x0000000000553ce7 in getLabelOffset (Layout=..., S=..., ReportError=true, Val=@0x7fffffffbc68: 17057240)
      at /home/aaupov/local/llvm-project/llvm/lib/MC/MCFragment.cpp:111
  #5  0x0000000000553d79 in getSymbolOffsetImpl (Layout=..., S=..., ReportError=true, Val=@0x7fffffffbc68: 17057240)
      at /home/aaupov/local/llvm-project/llvm/lib/MC/MCFragment.cpp:118
  #6  0x0000000000553fa8 in llvm::MCAsmLayout::getSymbolOffset (this=0x7fffffffc4e0, S=...)
      at /home/aaupov/local/llvm-project/llvm/lib/MC/MCFragment.cpp:154
  #7  0x00000000005030e2 in llvm::MCAssembler::evaluateFixup (this=0x10499e0, Layout=..., Fixup=..., DF=0x104e470, Target=...,
      Value=@0x7fffffffbdb8: 18446744073709551615, WasForced=@0x7fffffffbdb7: false) at /home/aaupov/local/llvm-project/llvm/lib/MC/MCAssembler.cpp:258
  #8  0x00000000005067ff in llvm::MCAssembler::fixupNeedsRelaxation (this=0x10499e0, Fixup=..., DF=0x104e470, Layout=...)
      at /home/aaupov/local/llvm-project/llvm/lib/MC/MCAssembler.cpp:1026
  #9  0x0000000000506994 in llvm::MCAssembler::fragmentNeedsRelaxation (this=0x10499e0, F=0x104e470, Layout=...)
      at /home/aaupov/local/llvm-project/llvm/lib/MC/MCAssembler.cpp:1045
  #10 0x0000000000506a2d in llvm::MCAssembler::relaxInstruction (this=0x10499e0, Layout=..., F=...)
      at /home/aaupov/local/llvm-project/llvm/lib/MC/MCAssembler.cpp:1055
  #11 0x0000000000507664 in llvm::MCAssembler::relaxFragment (this=0x10499e0, Layout=..., F=...)
      at /home/aaupov/local/llvm-project/llvm/lib/MC/MCAssembler.cpp:1241
  #12 0x00000000005077f2 in llvm::MCAssembler::layoutSectionOnce (this=0x10499e0, Layout=..., Sec=...)
      at /home/aaupov/local/llvm-project/llvm/lib/MC/MCAssembler.cpp:1270


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97982



More information about the llvm-commits mailing list