<div dir="ltr"><div>Aha, thanks for the report.</div><div><br></div><div>This looks like a bug resulting from the work to support i64 on sparcv8. The SparcV8 backend marks v2i32 as a legal type, in order to implement 64bit load/store. (It couldn't use i64, because marking an integral type legal which doesn't have arithmetic legal causes a BUNCH of issues in the ISel framework. Using v2i32 was much less problematic -- handling of function calls and return values being essentially the only complication.)</div><div><br></div><div>Anyhow, it appears I missed one thing: to transform the result type back from the two split-apart return registers, into a single v2i32 value. That is, in the "Copy all of the result registers" loop at the end of SparcTargetLowering::LowerCall_32, it needs to reconstruct a v2i32 from the two RVLocs, just like the code in ARMTargetLowering::LowerCallResult does.<br></div><div><br></div><div>If you don't fix it yourself, could you open a bug report so I don't forget?</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jan 28, 2016 at 6:25 PM, Chris.Dewhurst <span dir="ltr"><<a href="mailto:Chris.Dewhurst@lero.ie" target="_blank">Chris.Dewhurst@lero.ie</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">




<div>
<div style="direction:ltr;font-family:Tahoma;color:#000000;font-size:10pt">Apologies. I had cut too much out from the file. The full file is as follows:
<div>
<div><br>
</div>
</div>
<blockquote style="margin:0 0 0 40px;border:none;padding:0px">
<div>
<div><font face="Courier New">typedef char vec8 __attribute__((vector_size(4)));</font></div>
</div>
<div>
<div><font face="Courier New">typedef short vec16 __attribute__((vector_size(4)));</font></div>
</div><span class="">
<div>
<div><font face="Courier New"><br>
</font></div>
</div>
<div>
<div><font face="Courier New">extern vec8 foo1_8(void);</font></div>
</div>
<div>
<div><font face="Courier New">extern vec8 foo2_8(void);</font></div>
</div>
<div>
<div><font face="Courier New"><br>
</font></div>
</div>
<div>
<div><font face="Courier New">vec8 fun8(void)</font></div>
</div>
<div>
<div><font face="Courier New">{</font></div>
</div>
<div>
<div><font face="Courier New">  return foo1_8 () & foo2_8 ();</font></div>
</div>
<div>
<div><font face="Courier New">}</font></div>
</div>
<div>
<div><font face="Courier New"><br>
</font></div>
</div>
</span><div>
<div><font face="Courier New">extern vec16 foo1_16(void);</font></div>
</div>
<div>
<div><font face="Courier New">extern vec16 foo2_16(void);</font></div>
</div>
<div>
<div><font face="Courier New"><br>
</font></div>
</div>
<div>
<div><font face="Courier New">vec16 fun16(void)</font></div>
</div>
<div>
<div><font face="Courier New">{</font></div>
</div>
<div>
<div><font face="Courier New">  return foo1_16 () & foo1_16 ();</font></div>
</div>
<div>
<div><font face="Courier New">}</font></div>
</div>
</blockquote>
<div>
<div><br>
</div>
<div><span style="font-size:10pt">I'm trying to get this working for Sparc v8. I tried the command-lines that you referred to James. The v8 one fails as I had before on the latest I had (not quite up-to-date with the trunk, but only about a week old). The
 v9 works, which I hadn't noticed before as I'm focussed on the v8 back-end.</span></div>
<div><span style="font-size:10pt"><br>
</span></div>
<div><span style="font-size:10pt">Chris.</span></div>
<div>
<div style="font-family:Times New Roman;color:#000000;font-size:16px">
<hr>
<div style="direction:ltr"><font face="Tahoma" size="2" color="#000000"><b>From:</b> James Y Knight [<a href="mailto:jyknight@google.com" target="_blank">jyknight@google.com</a>]<br>
<b>Sent:</b> 28 January 2016 20:55<br>
<b>To:</b> Chris.Dewhurst<br>
<b>Cc:</b> <a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<b>Subject:</b> Re: [llvm-dev] Vectors in Sparc<br>
</font><br>
</div><div><div class="h5">
<div></div>
<div>
<div dir="ltr">That test does not crash for me on trunk, neither with "clang -S -o - -target sparc test-sparc.c" nor "clang -S -o - -target sparcv9 test-sparc.c" (I'm not sure which you meant). So, maybe it's been fixed, or maybe I'm not using the same commandline
 as you are.
<div><br>
</div>
<div>However, even if it doesn't crash, Clang certainly isn't implementing a correct ABI for vector types on SPARC. So don't expect interoperability with other compilers for functions that have vector params or returns.</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Thu, Jan 28, 2016 at 2:22 PM, Chris.Dewhurst 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">
<div>
<div style="direction:ltr;font-family:Tahoma;color:#000000;font-size:10pt">The following code is causing me problems in the Sparc back-end and I believe it's related to a lot of issues that I have, so I'd love to work out what I need to do to resolve this.
 I'm currently not making much headway into it. I'm going to try to simplify this to the core problem I can see and hope I haven't missed anything relevant.
<div><br>
</div>
<div>The original code I have is as follows:</div>
<div><br>
</div>
<blockquote style="margin:0 0 0 40px;border:none;padding:0px">
<div>
<div>
<div><font face="Courier New">typedef char vec8 __attribute__((vector_size(4)));</font></div>
</div>
</div>
<div>
<div><font face="Courier New"><br>
</font></div>
</div>
<div>
<div><font face="Courier New">extern vec8 foo1_8(void);</font></div>
</div>
<div>
<div><font face="Courier New">extern vec8 foo2_8(void);</font></div>
</div>
<div>
<div><font face="Courier New"><br>
</font></div>
</div>
<div>
<div><font face="Courier New">vec8 fun8(void)</font></div>
</div>
<div>
<div><font face="Courier New">{</font></div>
</div>
<div>
<div><font face="Courier New">  return foo1_8 () & foo2_8 ();</font></div>
</div>
<div>
<div><font face="Courier New">}</font></div>
</div>
</blockquote>
<div><br>
</div>
<div>On x86, this compiles into this IR:</div>
<div><br>
</div>
<blockquote style="margin:0 0 0 40px;border:none;padding:0px">
<div>
<div><font face="Courier New">; Function Attrs: nounwind uwtable</font></div>
</div>
<div>
<div><font face="Courier New">define i32 @fun8() #0 !dbg !4 {</font></div>
</div>
<div>
<div><font face="Courier New">  %1 = tail call i32 @foo1_8() #2, !dbg !23</font></div>
</div>
<div>
<div><font face="Courier New">  %2 = tail call i32 @foo2_8() #2, !dbg !24</font></div>
</div>
<div>
<div><font face="Courier New">  %3 = and i32 %2, %1, !dbg !26</font></div>
</div>
<div>
<div><font face="Courier New">  ret i32 %3, !dbg !27</font></div>
</div>
<div>
<div><font face="Courier New">}</font></div>
</div>
</blockquote>
<div><br>
</div>
<div>On Sparc, this compiles into this IR:</div>
<div>
<blockquote style="margin:0 0 0 40px;border:none;padding:0px">
<div><font face="Courier New"><br>
</font></div>
<div>
<div><font face="Courier New">; Function Attrs: nounwind</font></div>
</div>
<div>
<div><font face="Courier New">define <4 x i8> @fun8() #0 !dbg !4 {</font></div>
</div>
<div>
<div><font face="Courier New">  %1 = tail call <4 x i8> @foo1_8() #2, !dbg !23</font></div>
</div>
<div>
<div><font face="Courier New">  %2 = tail call <4 x i8> @foo2_8() #2, !dbg !24</font></div>
</div>
<div>
<div><font face="Courier New">  %3 = and <4 x i8> %2, %1, !dbg !26</font></div>
</div>
<div>
<div><font face="Courier New">  ret <4 x i8> %3, !dbg !27</font></div>
</div>
<div>
<div><font face="Courier New">}</font></div>
</div>
</blockquote>
</div>
<div><br>
</div>
<div>When I try to compile this down to an object file using llc, I get this error for Sparc (none for x86):</div>
<div><br>
</div>
<div>   LowerCall didn't emit the correct number of values!</div>
<div><br>
</div>
<div>It appears that the Sparc system doesn't know how to lower calls using vectors. I need to either be able to (1) Work out how to get clang to compile the Sparc code into something more similar to the x86 code, or (2) to work out how to get the llc backend
 for sparc to know how to lower calls containing vectors.</div>
<div><br>
</div>
<div>I'd prefer to do the first of these and get the vectors represented as registers. This seems more efficient.</div>
<div><br>
</div>
<div>Any help pointing me in the right direction will be greatly appreciated. I don't suppose there's anything as simple a a clang command-line flag that will do this???</div>
<div><br>
</div>
<div>Chris Dewhurst,</div>
<div>LERO, The Irish Software Research Centre,</div>
<div>University of Limerick.</div>
</div>
</div>
<br>
_______________________________________________<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/mailman/listinfo/llvm-dev</a><br>
<br>
</blockquote>
</div>
<br>
</div>
</div>
</div></div></div>
</div>
</div>
</div>
</div>

</blockquote></div><br></div>