[cfe-dev] how to disable return type optimize when compile to IR code with clang ?
zh
zhangheng607 at 163.com
Wed Aug 20 18:54:56 PDT 2014
Hi all,
the example code is:
union mixtype
{
long long asInt64;
double asDouble;
int asIntPtr[2];
};
union mixtype double2mixtype(double d)
{
union mixtype result;
result.asDouble = d;
return result;
}
then I compile it to IR code like this:
clang.exe -S -emit-llvm test.c
and the test.ll file is:
; ModuleID = 'test.c'
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"
target triple = "i686-pc-win32"
%union.mixtype = type { i64 }
; Function Attrs: nounwind
define i64 @double2mixtype(double %d) #0 {
entry:
%retval = alloca %union.mixtype, align 8
%d.addr = alloca double, align 8
%result = alloca %union.mixtype, align 8
store double %d, double* %d.addr, align 8
%0 = load double* %d.addr, align 8
%asDouble = bitcast %union.mixtype* %result to double*
store double %0, double* %asDouble, align 8
%1 = bitcast %union.mixtype* %retval to i8*
%2 = bitcast %union.mixtype* %result to i8*
call void @llvm.memcpy.p0i8.p0i8.i32(i8* %1, i8* %2, i32 8, i32 8, i1 false)
%coerce.dive = getelementptr %union.mixtype* %retval, i32 0, i32 0
%3 = load i64* %coerce.dive
ret i64 %3
}
; Function Attrs: nounwind
declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture, i8* nocapture readonly, i32, i32, i1) #1
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" }
attributes #1 = { nounwind }
!llvm.ident = !{!0}
!0 = metadata !{metadata !"clang version 3.4.2 (tags/RELEASE_34/dot2-final)"}
so, I wonder, how to set the options when compiling, to force double2mixtype return %union.mixtype but not i64 ?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140821/54fe1855/attachment.html>
More information about the cfe-dev
mailing list