[PATCH] D61610: [PPC64] implement Thunk Section Spacing

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 8 00:06:32 PDT 2019


MaskRay added a comment.

I was trying to find a good value used in 
`uint32_t PPC64::getThunkSectionSpacing() const { return 0x8000 - 0x1000; }` before I noticed this caused an extreme slowdown in thunk creation.

We have a large program whose text segment is of 1.3GiB. Its OutputSection `.text` consists of 1948775 InputSections. It takes 20 seconds to link but with this patch it doesn't stop in 10 minutes.

The reason is that:

  std::tie(T, IsNew) = getThunk(*Rel.Sym, Rel.Type, Src);
  
  if (IsNew) {
    // Find or create a ThunkSection for the new Thunk
    ThunkSection *TS;
    if (auto *TIS = T->getTargetInputSection())
      TS = getISThunkSec(TIS);
    else
      TS = getISDThunkSec(OS, IS, ISD, Rel.Type, Src); // it takes O(|ISD->ThunkSections|) time, `ISD->ThunkSections` is large (20000+) when getThunkSectionSpacing is enabled.
    TS->addThunk(T);
    Thunks[T->getThunkTargetSym()] = T;
  }





================
Comment at: lld/test/ELF/ppc64-branch-thunkspacing.s:18
+        mr 31,1
+	bl  too_far1
+
----------------
MaskRay wrote:
> mixed tab and spaces? Probably move the bl instruction to another `.init` section:
> 
> ```
> .section .init,"ax", at progbits,unique,2
> .align 2
>   bl too_far1
> ```
> 
> to mimic the crti.o crtn.o `.init`
This comment is not done.

You should create several `.init` sections to emulate `.init` used on FreeBSD: it is built from bits spread across several object files.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61610





More information about the llvm-commits mailing list