<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jul 11, 2017 at 4:40 PM, Peter Smith via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Thanks for the example, it looks like relaxations can occur at any<br>
point within the section.<br></blockquote><div><br></div><div>Welcome.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I think that regardless of the approaches, you'll need a relaxation<br>
function that is in a similar place or is merged with createThunks().<br>
I don't know enough about RiscV to say if you can get away with doing<br>
all you need to do in one pass, or if you will need multiple passes<br>
with the address of each section recalculated after each relaxation<br>
pass.<br></blockquote><div><br></div><div>Relocation is of course compulsory. Relaxation is optional. You can do zero passes of it.</div><div><br></div><div>So I suppose it comes down to "how likely are you to get significant gains from a 2nd (or later) relaxation pass"?</div><div><br></div><div>There is only one size of conditional branch: +/- 4 KB. In the rare case of a function being bigger than that the compiler will invert the condition and branch around an unconditional branch (range: +/- 1 MB) or luipc;jr pair (range: +/- 2 GB). I don't even know whether the binutils linker will relax a conditional branch around an unconditional branch. So that's I suppose the major source of iterated relaxation not being relevent: x86 and others with +/- 128 byte branches, which really do frequently have cascading effects.</div><div><br></div><div>Relaxed 32 bit instruction function calls have +/- 1 MB range. The chances of a 2nd round of relaxation tipping more call offsets from just over 1 MB to just under 1 MB are fairly slim.</div><div><br></div><div>I would say that a 2nd pass of relaxation would seldom be profitable enough to be worthwhile.</div><div><br></div></div></div></div>