<div dir="ltr">This isn't an optimization, it is actually how Clang is able to match the native ABI on your platform through LLVM IR. There is no flag to disable it. If we don't do this, we need some other way to ensure that the data is returned in eax:edx on i686-pc-win32.<div>
<br></div><div>Previously we have discussed adding an ISA triple value for analysis only that uses simple IR lowerings, like making all struct passing indirect through pointers. That might be useful to you, depending on what you are trying to do.</div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Aug 20, 2014 at 6:54 PM, zh <span dir="ltr"><<a href="mailto:zhangheng607@163.com" target="_blank">zhangheng607@163.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="line-height:1.7;color:#000000;font-size:14px;font-family:Arial"><div>Hi all,</div><div>the example code is:</div><div><div>union mixtype</div><div>{</div><div>    long long asInt64;</div><div>    double asDouble;</div>
<div>    int asIntPtr[2];</div><div>};</div><div><br></div><div>union mixtype double2mixtype(double d)</div><div>{</div><div>    union mixtype result;</div><div><span style="white-space:pre-wrap">    </span>result.asDouble = d;</div>
<div><span style="white-space:pre-wrap">  </span>return result;</div><div>}</div></div><div><br></div><div>then I compile it to IR code like this:</div><div>clang.exe -S -emit-llvm  test.c</div><div><br></div><div>and the test.ll file is:</div>
<div><div>; ModuleID = 'test.c'</div><div>target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-f80:128:128-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32-S32"</div>
<div>target triple = "i686-pc-win32"</div><div><br></div><div>%union.mixtype = type { i64 }</div><div><br></div><div>; Function Attrs: nounwind</div><div>define i64 @double2mixtype(double %d) #0 {</div><div>entry:</div>
<div>  %retval = alloca %union.mixtype, align 8</div><div>  %d.addr = alloca double, align 8</div><div>  %result = alloca %union.mixtype, align 8</div><div>  store double %d, double* %d.addr, align 8</div><div>  %0 = load double* %d.addr, align 8</div>
<div>  %asDouble = bitcast %union.mixtype* %result to double*</div><div>  store double %0, double* %asDouble, align 8</div><div>  %1 = bitcast %union.mixtype* %retval to i8*</div><div>  %2 = bitcast %union.mixtype* %result to i8*</div>
<div>  call void @llvm.memcpy.p0i8.p0i8.i32(i8* %1, i8* %2, i32 8, i32 8, i1 false)</div><div>  %coerce.dive = getelementptr %union.mixtype* %retval, i32 0, i32 0</div><div>  %3 = load i64* %coerce.dive</div><div>  ret i64 %3</div>
<div>}</div><div><br></div><div>; Function Attrs: nounwind</div><div>declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture, i8* nocapture readonly, i32, i32, i1) #1</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"="false" }</div>
<div>attributes #1 = { nounwind }</div><div><br></div><div>!llvm.ident = !{!0}</div><div><br></div><div>!0 = metadata !{metadata !"clang version 3.4.2 (tags/RELEASE_34/dot2-final)"}</div></div><div><br></div><div>
so, I wonder, how to set the options when compiling, to force <span style="line-height:1.7">double2mixtype return </span><span style="line-height:1.7">%union.mixtype but not i64 ?</span></div></div><br><br><span title="neteasefooter"><span></span></span><br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br></div>