<div dir="ltr">Do reply to ALL recipients (in particular to the mailing list) when replying!<br><br><br><div class="gmail_extra"><br><div class="gmail_quote">On 18 November 2016 at 17:27, Shilpa B <span dir="ltr"><<a href="mailto:shilpabvb@gmail.com" target="_blank">shilpabvb@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div><div><div><div>Hi Mats,<br><br></div>Thanks for the reply and the link. I am attaching the sample file that I had used to test.<br></div>It is an LLVM IR file and I modified it to include rand function to generate random numbers and used the command<br><br></div>clang print.ll -std=c++11 -Wl,-rpath,/usr/include  -o print.o <br><br>to generate the executable file. However, when I execute print.o it shows the random numbers generated as zero.<br></div></div></div></blockquote><div><br></div><div>Nope, rand is (most likely) returning correct values you are printing floating point values from integer values, and that quite often results in zero being printed - depending on the architecture, register vs. memory used for varargs, etc.<br><br>....<br>@.str = private unnamed_addr constant [4 x i8] c"%f\09\00", align 1<br>....<br>  %callr = call i32 @rand()<br>  store i32 %callr, i32* %arrayidx5, align 8<br>  %val = load i32, i32* %arrayidx5, align 8<br>  %call = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i32 %val)<br>....<br></div><div><br></div><div>change %f to %d, and it lists a bunch of seemingly random numbers, at least on my machine.<br></div><div><br>--<br></div><div>Mats<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div><br></div>Thanks,<br></div>Shilpa<br></div><div class="gmail-HOEnZb"><div class="gmail-h5"><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Nov 18, 2016 at 9:39 PM, mats petersson <span dir="ltr"><<a href="mailto:mats@planetcatfish.com" target="_blank">mats@planetcatfish.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Without reproducible steps, it's hard to give meaningful advice. In my experience, linking using `clang` (or `gcc`) will work.<br><br></div><div>My compiler does that around in this function:<br><a href="https://github.com/Leporacanthicus/lacsap/blob/master/binary.cpp#L126" target="_blank">https://github.com/Leporacanth<wbr>icus/lacsap/blob/master/<wbr>binary.cpp#L126</a><br></div><div><br>--<br></div>Mats<br></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="gmail-m_-7605785603530518390h5">On 18 November 2016 at 11:20, Shilpa B 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></div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div class="gmail-m_-7605785603530518390h5"><div dir="ltr">Hi,<div><br></div><div>I have a LLVM IR file generated for a different source language (Not C). I have added a rand() function in it to generate random numbers.</div><div><br></div><div>I compiled the .ll file to .o using clang. However, when I execute the .o file all generated numbers are zeros. </div><div><br></div><div>How should I link the .ll file with the standard library for the clang to generate the random numbers?</div><div><br></div><div><br></div><div>Thanks</div><span class="gmail-m_-7605785603530518390m_469812175368457636HOEnZb"><font color="#888888"><div>-Shilpa</div></font></span></div>
<br></div></div>______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div></div>