<div dir="ltr">I have created a small ll file to reproduce the problem.<div>I used the intrinsic function llvm.arm.space to introduce space between the beginning of the code and the jump table.</div><div>If the first argument of llvm.arm.space is higher than INT_MAX (<b>2147483647)</b>, then the bug is hit. Lower or equal to that value, it passes. It looks like a precision issue. Does this sound familiar to someone?</div><div><br></div><div><div>; ModuleID = 'test.c'</div><div>target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"</div><div>target triple = "armv5e-none-linux-androideabi"</div><div><br></div><div>declare i32 @llvm.arm.space(i32, i32)</div><div><br></div><div>; Function Attrs: nounwind</div><div>define i32 @main() #0 {</div><div>entry:</div><div>  %retval = alloca i32, align 4</div><div>  %a = alloca i32, align 4</div><div>  store i32 0, i32* %retval</div><div>  store i32 0, i32* %a, align 4</div><div>  %0 = load i32* %a, align 4</div><div>  call i32 @llvm.arm.space(i32<b> 2147483647</b>, i32 undef)</div><div>  switch i32 %0, label %sw.default [</div><div>    i32 0, label %<a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__sw.bb&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=Mfk2qtn1LTDThVkh6-oGglNfMADXfJdty4_bhmuhMHA&m=DFvzCR2aN1GUO8co-4PYeO_fyuY3jUR0UGUMhMgMssM&s=sY0iMrbf8oue5xpVNy9Sh4Op_LdFTnilmvYpQnxGGtc&e=">sw.bb</a></div><div>    i32 1, label %sw.bb1</div><div>    i32 2, label %sw.bb2</div><div>    i32 3, label %sw.bb3</div><div>  ]</div><div><br></div><div><a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__sw.bb&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=Mfk2qtn1LTDThVkh6-oGglNfMADXfJdty4_bhmuhMHA&m=DFvzCR2aN1GUO8co-4PYeO_fyuY3jUR0UGUMhMgMssM&s=sY0iMrbf8oue5xpVNy9Sh4Op_LdFTnilmvYpQnxGGtc&e=">sw.bb</a>:                                            ; preds = %entry</div><div>  store i32 1, i32* %retval</div><div>  br label %return</div><div><br></div><div>sw.bb1:                                           ; preds = %entry</div><div>  store i32 2, i32* %retval</div><div>  br label %return</div><div><br></div><div>sw.bb2:                                           ; preds = %entry</div><div>  store i32 3, i32* %retval</div><div>  br label %return</div><div><br></div><div>sw.bb3:                                           ; preds = %entry</div><div>  store i32 4, i32* %retval</div><div>  br label %return</div><div><br></div><div>sw.default:                                       ; preds = %entry</div><div>  br label %sw.epilog</div><div><br></div><div>sw.epilog:                                        ; preds = %sw.default</div><div>  store i32 0, i32* %retval</div><div>  br label %return</div><div><br></div><div>return:                                           ; preds = %sw.epilog, %sw.bb3, %sw.bb2, %sw.bb1, %<a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__sw.bb&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=Mfk2qtn1LTDThVkh6-oGglNfMADXfJdty4_bhmuhMHA&m=DFvzCR2aN1GUO8co-4PYeO_fyuY3jUR0UGUMhMgMssM&s=sY0iMrbf8oue5xpVNy9Sh4Op_LdFTnilmvYpQnxGGtc&e=">sw.bb</a></div><div>  %2 = load i32* %retval</div><div>  ret i32 %2</div><div>}</div><div><br></div><div>; Function Attrs: nounwind</div><div>declare i32 @rand() #0</div><div><br></div><div>attributes #0 = { nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="true" }</div><div>attributes #1 = { nounwind }</div><div><br></div><div>!llvm.module.flags = !{!0, !1, !2}</div><div>!llvm.ident = !{!3}</div><div><br></div><div>!0 = !{i32 1, !"wchar_size", i32 4}</div><div>!1 = !{i32 1, !"min_enum_size", i32 4}</div><div>!2 = !{i32 1, !"PIC Level", i32 1}</div><div>!3 = !{!"clang version 3.7.0 (trunk 229364)"}</div></div></div><div class="gmail_extra"><br><div class="gmail_quote">2015-07-06 21:13 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">It is certainly helping - Thanks Renato.</div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">2015-07-06 18:39 GMT+03:00 Renato Golin <span dir="ltr"><<a href="mailto:renato.golin@linaro.org" target="_blank">renato.golin@linaro.org</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>On 6 July 2015 at 16:32, Eric Bentura <<a href="mailto:ebentura@gmail.com" target="_blank">ebentura@gmail.com</a>> wrote:<br>
> I tried to build the object file using clang 3.7 and it fails with the same<br>
> error.<br>
> Where should I look at in the ARM backend to understand what happens?<br>
> Where the jump table instruction is generated and supposed to be relaxed?<br>
<br>
</span>Have a look at lib/Target/ARM/ARMConstantIslandPass.cpp, especially<br>
where Tim's patch touches:<br>
<br>
<a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Fview-3Drevision-26revision-3D238680&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=Mfk2qtn1LTDThVkh6-oGglNfMADXfJdty4_bhmuhMHA&m=DFvzCR2aN1GUO8co-4PYeO_fyuY3jUR0UGUMhMgMssM&s=mECPP5fzml0nGpLlGFK8Hb7Jhp6g_wx1IeE-UEuayFA&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?view=revision&revision=238680</a><br>
<br>
Instruction relaxation rules should be in the TableGen files, I think,<br>
but that means it could be in a number of places.<br>
<br>
Step through lib/Target/ARM/ARMAsmPrinter.cpp, at<br>
ARMAsmPrinter::EmitJumpTableInsts and see what the operand is.<br>
<br>
You'd expect that it would be already relaxed by that point. If it is,<br>
the bug is in the printer. If not, it could be in the instruction<br>
selection process, either ARMISelLowering or during validation, at<br>
ARMISelDAGToDAG.<br>
<br>
Hope that helps.<br>
<br>
cheers,<br>
--renato<br>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>