<div dir="ltr"><span style="font-size:12.8000001907349px">Hi, </span><div style="font-size:12.8000001907349px">I have kept working on this and found the following (as llvm 3.5):</div><div style="font-size:12.8000001907349px">1) In the function MCObjectStreamer::EmitInstruction there is a check for the instruction being relaxable or not:</div><div style="font-size:12.8000001907349px"><div>    if (!Assembler.getBackend().mayNeedRelaxation(Inst)) {</div><div>       EmitInstToData(Inst, STI);</div><div>       return;</div><div>    } </div></div><div style="font-size:12.8000001907349px">   At this stage, the instruction as been already selected to be ARM::ADR.</div><div style="font-size:12.8000001907349px">   The call to mayNeedRelaxation() resolve to ARMAsmBackend::getRelaxedOpcode().</div><div style="font-size:12.8000001907349px">   There is no processing in there for ARM:ADR. I added the following line: </div><div style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">           <b>case ARM::ADR:        return ARM::t2ADR;</b></span><br></div><div style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px"><b>   </b>As a result, if relaxation is enabled or bundling is enabled then the instruction is relaxed.</span></div><div style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">   And compilation to object passes.</span></div><div style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">   I am not familiar enough with this to understand why there is a condition to enter the relaxtion step : I had to set manually Assembler.setRelaxAll(true) to get into this step.</span></div><div style="font-size:12.8000001907349px">2) It seems that Fast instruction selection is enabled by default (even when using -O3). The problem does not appear when not using Fast sel (again used a hack in the code) although the same ADR instruction is selected since the offset to apply to the fixup is small enough.</div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">I am not sure I am on the right track, but as far as I understand:</div><div style="font-size:12.8000001907349px">1)ARM::ADR is not handled by relaxation</div><div style="font-size:12.8000001907349px">2)Relaxtion happens under some condition in the ObjectStreamer that I don't fully understand</div><div style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px"> </span><br></div><div style="font-size:12.8000001907349px">What do you think?</div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">Thanks,</div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">Eric</div><div style="font-size:12.8000001907349px"><div style="font-size:12.8000001907349px"><img class="" src="https://ssl.gstatic.com/ui/v1/icons/mail/images/cleardot.gif" style="font-size: 12.8000001907349px;"><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">2015-07-13 15:41 GMT+03:00 Eric Bentura <span dir="ltr"><<a href="mailto:ebentura@gmail.com" target="_blank">ebentura@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi, <div>I have kept working on this and found the following (as llvm 3.5):</div><div>1) In the function MCObjectStreamer::EmitInstruction there is a check for the instruction being relaxable or not:</div><div><div> if (!Assembler.getBackend().mayNeedRelaxation(Inst)) {</div><div>    EmitInstToData(Inst, STI);</div><div>    return;</div><div>  }</div></div><div>At this stage, the instruction as been already selected to be ARM::ADR.</div><div>The call to mayNeed</div><div><br></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">2015-07-07 18:06 GMT+03:00 Tim Northover <span dir="ltr"><<a href="mailto:t.p.northover@gmail.com" target="_blank">t.p.northover@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>On 7 July 2015 at 06:06, Eric Bentura <<a href="mailto:ebentura@gmail.com" target="_blank">ebentura@gmail.com</a>> wrote:<br>
> I have created a small ll file to reproduce the problem.<br>
> I used the intrinsic function llvm.arm.space to introduce space between the<br>
> beginning of the code and the jump table.<br>
<br>
</span>It does look like the value in @llvm.arm.space is interpreted<br>
incorrectly if it's bigger than INT_MAX, but that's well outside its<br>
intended range and could inevitably be used to break ConstantIslands<br>
(the longest ARM immediate branch is 26-bits; no indivisible entity in<br>
.text can be bigger than that). It's probably an unrelated issue.<br>
<br>
Also, I know I said the backend should accept any size code, but 2GB<br>
is definitely going to trigger more edge cases than average.<br>
<br>
Cheers.<br>
<span><font color="#888888"><br>
Tim.<br>
</font></span></blockquote></div><br></div>
</div></div></blockquote></div><br></div>