<div class="gmail_quote">On Thu, Mar 25, 2010 at 4:21 PM, Daniel Dunbar <span dir="ltr"><<a href="mailto:daniel@zuster.org">daniel@zuster.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><div></div><div class="h5">On Thu, Mar 25, 2010 at 5:33 AM, Artur Pietrek <<a href="mailto:pietreka@gmail.com">pietreka@gmail.com</a>> wrote:<br>
>> Hi Artur,<br>
><br>
> Hi Daniel<br>
><br>
>><br>
>> > Hi all,<br>
>> > so after "greping" the code I was able to do (more or less) everything I<br>
>> > wanted to do.<br>
>><br>
>> As you have discovered, this stuff isn't very well documented yet. Do<br>
>> you feel like writing up a blurb we could add to our Internals Manual<br>
>> describing what you have discovered?<br>
><br>
> I'll try when I'll make it work correct ;)<br>
><br>
> BTW I've noticed strange behaviour. When I switched from llvm-gcc to clang,<br>
> my benchmarks stopped working. When I compile simple code:<br>
><br>
> char array[] =<br>
> "+0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz";<br>
><br>
> int main() {<br>
>   return array[31];<br>
> }<br>
><br>
> like this:<br>
> clang -ccc-host-triple mycpu -O0 -S hello.c -o hello.s<br>
><br>
> The code is wrong, to be precise in one instruction I get<br>
> lbs $r16 = 0[$r17] instead of lbs $r16 = 31[$r17]<br>
><br>
> but the code is correct when I do it like this:<br>
> clang -ccc-host-triple mycpu -O0 hello.c -c -emit-llvm -o hello.bc<br>
> llc -march=mycpu hello.bc -o hello.s<br>
><br>
><br>
> Am I missing something? Shouldn't these two be equivalent?<br>
<br>
</div></div>Unfortunately, no. The driver sets a variety of options in the LLVM<br>
backend that you would need to pass to llc by hand. Try running<br>
$ clang -ccc-host-triple mycpu -O0 hello.c -c -emit-llvm -o hello.bc -###<br>
to see how clang is calling the compiler (clang -cc1), and look for -m<br>
arguments. For example, -mcpu sets the CPU to target, and other -m<br>
options do things like disable use of a frame pointer.<br>
<br>
 - Daniel<br></blockquote><div><br>Thanks for advice, there was a bug in relocation in my backend and indeed clang was triggering it by passing different options than llc.<br><br>Now I'm trying to find another bug. I don't know why I'm ending up with reg to reg copy from 64bit to 32bit register class but only using clang and turned on optimization (when i compile with llvm-gcc or again with clang to bitcode and then using llc the problem does not occur). <br>
I've tried to change options given to compiler, but this changes nothing. <br>The code I try to compile has castings from i8* to i64*.<br>Any ideas what could trigger that?<br>Is there a way to force clang to dump debug information similar to "llc -debug"?<br>
</div></div><br>Once more, thanks for your help!<br>Artur<br><br>