<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 class="Apple-tab-span" style="white-space:pre">        </span>result.asDouble = d;</div><div><span class="Apple-tab-span" style="white-space:pre"> </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 id="netease_mail_footer"></span></span>