Hi, all,<br><br>I am trying the swift compiler these days in ppc64le, and found that, if the function return type is aggr, the code swift generated didn't conform the ppc64le ABI.<br><br>&gt; cat test.swift <br>func test() -&gt; (Bool, Double, Int){<br>&nbsp;&nbsp;&nbsp; return (true,3.0,3);<br>}<br><br>test();<br><br>&gt; swiftc test.swift -emit-ir<br>; ModuleID = '-'<br>target datalayout = "e-m:e-i64:64-n32:64"<br>target triple = "powerpc64le-unknown-linux-gnu"<br>...<br>define protected signext i32 @main(i32 signext, i8**) #0 {<br>entry:<br>&nbsp; %2 = bitcast i8** %1 to i8*<br>&nbsp; store i32 %0, i32* getelementptr inbounds (%Vs5Int32, %Vs5Int32* @_TZvOs7Process5_argcVs5Int32, i32 0, i32 0), align 4<br>&nbsp; call void @swift_once(i64* @globalinit_33_1BDF70FFC18749BAB495A73B459ED2F0_token3, i8* bitcast (void ()* @globalinit_33_1BDF70FFC18749BAB495A73B459ED2F0_func3 to i8*))<br>&nbsp; store i8* %2, i8** getelementptr inbounds (%Sp, %Sp* @_TZvOs7Process11_unsafeArgvGSpGSpVs4Int8__, i32 0, i32 0), align 8<br>&nbsp; %3 = call<span style="font-weight: bold;"> { i1, double, i64 }</span> @_TF4test4testFT_TSbSdSi_()<br>&nbsp; %4 = extractvalue { i1, double, i64 } %3, 0<br>&nbsp; %5 = extractvalue { i1, double, i64 } %3, 1<br>&nbsp; %6 = extractvalue { i1, double, i64 } %3, 2<br>&nbsp; ret i32 0<br>}<br><br>We can see that, swift emit the <span style="font-weight: bold;"> { i1, double, i64 } </span>as its return type and llvm will pass the return value of _TF4test4testFT_TSbSdSi_ by register.<br>&gt; objdump -dr test.o<br>...<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 4c: R_PPC64_TOC16_HA&nbsp;&nbsp;&nbsp; .toc+0x18<br>&nbsp; 50:&nbsp;&nbsp;&nbsp; 00 00 63 e8 &nbsp;&nbsp;&nbsp; ld&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; r3,0(r3)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 50: R_PPC64_TOC16_LO_DS&nbsp;&nbsp;&nbsp; .toc+0x18<br>&nbsp; 54:&nbsp;&nbsp;&nbsp; 60 00 9f e8 &nbsp;&nbsp;&nbsp; ld&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; r4,96(r31)<br>&nbsp; 58:&nbsp;&nbsp;&nbsp; 00 00 83 f8 &nbsp;&nbsp;&nbsp; std&nbsp;&nbsp;&nbsp;&nbsp; r4,0(r3)<br>&nbsp; 5c:&nbsp;&nbsp;&nbsp; 01 00 00 48 &nbsp;&nbsp;&nbsp; bl&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 5c &lt;main+0x5c&gt;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 5c: R_PPC64_REL24&nbsp;&nbsp;&nbsp; _TF4test4testFT_TSbSdSi_<br>&nbsp; 60:&nbsp;&nbsp;&nbsp; 00 00 00 60 &nbsp;&nbsp;&nbsp; nop<br><br>However, for ppc64le ABI, this should be passed by address. See what clang emit the ir for return aggr of this type.<br><br>&gt; cat test2.cpp <br>struct A {<br>bool b;<br>double d;<br>long long m;<br>};<br><br>A test();<br><br>int main() {<br>&nbsp;&nbsp;&nbsp; test();<br>&nbsp;&nbsp;&nbsp; return 0;<br>}<br>&gt; clang test2.cpp -S -emit-llvm <br>&gt; cat test2.ll <br>; ModuleID = 'test2.cpp'<br>target datalayout = "e-m:e-i64:64-n32:64"<br>target triple = "powerpc64le-unknown-linux-gnu"<br><br>%struct.A = type { i8, double, i64 }<br><br>; Function Attrs: norecurse<br>define signext i32 @main() #0 {<br>&nbsp; %1 = alloca i32, align 4<br>&nbsp; %2 = alloca %struct.A, align 8<br>&nbsp; store i32 0, i32* %1, align 4<br>&nbsp; <span style="font-weight: bold;">call void @_Z4testv(%struct.A* sret %2)</span><br>&nbsp; ret i32 0<br>}<br><br>declare void @_Z4testv(%struct.A* sret) #1<br><br>Clang frontend will place it as the first parameter of the function. That would cause serious issues if we are linking with code write from other language(i.e. c/c++). Any comments?<br><br>