[PATCH] D52156: [LLD] [COFF] Alternative ARM range thunk algorithm

Peter Smith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 17 18:08:57 PDT 2018


peter.smith added a comment.

My best suggestion for a test that will need exceed the margin is to use input sections with high alignment requirements. If these are on a natural boundary prior to adding thunks then adding a thunk will result in a large amount of bytes inserted to maintain section alignment. As long as these padding bytes are in between the source and destination of a branch and exceed the margin then a test case can be constructed without needing to insert hundreds of Thunks.



================
Comment at: COFF/Writer.cpp:485
+    return;
+  size_t OrigNumChunks = 0, NumChunks = 0;
+  for (OutputSection *Sec : OutputSections) {
----------------
Given that we expect most programs not to need any thunks at all then would moving the verify part ahead of createThunks make sense? Something like

```
while (true) {
  if (verifyRanges)
    // were done exit
  else {
    if pass 0 initialise margin else double it.
    create thunks()
    assignAddresses()
    ++ThunkPasses;
  }
}
```
That would mean one more call to verifyRanges if thunks are needed, but that is expected to be the exception.


    


================
Comment at: COFF/Writer.cpp:491
+  int ThunkPass = 0;
+  bool AddressesChanged;
+  int Margin = 1024 * 100;
----------------
Can you move this to line 500?


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D52156





More information about the llvm-commits mailing list