Skip to content

Instantly share code, notes, and snippets.

Created October 31, 2017 18:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/5d72495c77f28269fe3c01715e770e19 to your computer and use it in GitHub Desktop.
Save anonymous/5d72495c77f28269fe3c01715e770e19 to your computer and use it in GitHub Desktop.
struct f2
{
float x0;
float x1;
};
struct f2 funf2(float x0, float x1);
float foo() {
struct f2 fl2;
fl2 = funf2(0.0, 1.0);
return fl2.x0 + fl2.x1;
}
int main() {
return foo();
}
; ModuleID = 'test.c'
source_filename = "test.c"
target datalayout = "E-m:e-p:32:32-i64:32-f64:32:64-a:0:32-n32-S32"
target triple = "opus2-octasic-opuskernel"
; Function Attrs: nounwind
define float @foo() local_unnamed_addr #0 !dbg !7 {
entry:
%call = tail call i64 @funf2(float 0.000000e+00, float 1.000000e+00) #3, !dbg !17
%coerce.sroa.0.sroa.0.0.extract.shift = lshr i64 %call, 32, !dbg !17
%coerce.sroa.0.sroa.0.0.extract.trunc = trunc i64 %coerce.sroa.0.sroa.0.0.extract.shift to i32, !dbg !17
%coerce.sroa.0.sroa.2.0.extract.trunc = trunc i64 %call to i32, !dbg !17
tail call void @llvm.dbg.value(metadata i32 %coerce.sroa.0.sroa.0.0.extract.trunc, metadata !12, metadata !DIExpression(DW_OP_LLVM_fragment, 0, 32)), !dbg !18
tail call void @llvm.dbg.value(metadata i32 %coerce.sroa.0.sroa.2.0.extract.trunc, metadata !12, metadata !DIExpression(DW_OP_LLVM_fragment, 32, 32)), !dbg !18
%0 = bitcast i32 %coerce.sroa.0.sroa.0.0.extract.trunc to float, !dbg !19
%1 = bitcast i32 %coerce.sroa.0.sroa.2.0.extract.trunc to float, !dbg !19
%add = fadd float %1, %0, !dbg !19
ret float %add, !dbg !19
}
declare i64 @funf2(float, float) local_unnamed_addr #1
; Function Attrs: nounwind
define i32 @main() local_unnamed_addr #0 !dbg !20 {
entry:
%call.i = tail call i64 @funf2(float 0.000000e+00, float 1.000000e+00) #3, !dbg !24
%coerce.sroa.0.sroa.0.0.extract.shift.i = lshr i64 %call.i, 32, !dbg !24
%coerce.sroa.0.sroa.0.0.extract.trunc.i = trunc i64 %coerce.sroa.0.sroa.0.0.extract.shift.i to i32, !dbg !24
%coerce.sroa.0.sroa.2.0.extract.trunc.i = trunc i64 %call.i to i32, !dbg !24
tail call void @llvm.dbg.value(metadata i32 %coerce.sroa.0.sroa.0.0.extract.trunc.i, metadata !12, metadata !DIExpression(DW_OP_LLVM_fragment, 0, 32)) #3, !dbg !26
tail call void @llvm.dbg.value(metadata i32 %coerce.sroa.0.sroa.2.0.extract.trunc.i, metadata !12, metadata !DIExpression(DW_OP_LLVM_fragment, 32, 32)) #3, !dbg !26
%0 = bitcast i32 %coerce.sroa.0.sroa.0.0.extract.trunc.i to float, !dbg !27
%1 = bitcast i32 %coerce.sroa.0.sroa.2.0.extract.trunc.i to float, !dbg !27
%add.i = fadd float %1, %0, !dbg !27
%conv = fptosi float %add.i to i32, !dbg !28
ret i32 %conv, !dbg !28
}
; Function Attrs: nounwind readnone speculatable
declare void @llvm.dbg.value(metadata, metadata, metadata) #2
attributes #0 = { nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="opus2" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #1 = { "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "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" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="opus2" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #2 = { nounwind readnone speculatable }
attributes #3 = { nounwind }
!llvm.dbg.cu = !{!0}
!llvm.module.flags = !{!3, !4, !5}
!llvm.ident = !{!6}
!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "Octasic clang (trunk) (based on LLVM 6.0.0svn)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
!1 = !DIFile(filename: "test.c", directory: "d:\5Ctest", checksumkind: CSK_MD5, checksum: "70caaeef2b87a6eead3dfae100ef6faa")
!2 = !{}
!3 = !{i32 2, !"Dwarf Version", i32 4}
!4 = !{i32 2, !"Debug Info Version", i32 3}
!5 = !{i32 1, !"wchar_size", i32 4}
!6 = !{!"Octasic clang (trunk) (based on LLVM 6.0.0svn)"}
!7 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 10, type: !8, isLocal: false, isDefinition: true, scopeLine: 10, isOptimized: true, unit: !0, variables: !11)
!8 = !DISubroutineType(types: !9)
!9 = !{!10}
!10 = !DIBasicType(name: "float", size: 32, encoding: DW_ATE_float)
!11 = !{!12}
!12 = !DILocalVariable(name: "fl2", scope: !7, file: !1, line: 11, type: !13)
!13 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "f2", file: !1, line: 2, size: 64, elements: !14)
!14 = !{!15, !16}
!15 = !DIDerivedType(tag: DW_TAG_member, name: "x0", scope: !13, file: !1, line: 4, baseType: !10, size: 32)
!16 = !DIDerivedType(tag: DW_TAG_member, name: "x1", scope: !13, file: !1, line: 5, baseType: !10, size: 32, offset: 32)
!17 = !DILocation(line: 12, column: 8, scope: !7)
!18 = !DILocation(line: 11, column: 12, scope: !7)
!19 = !DILocation(line: 13, column: 2, scope: !7)
!20 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 17, type: !21, isLocal: false, isDefinition: true, scopeLine: 17, isOptimized: true, unit: !0, variables: !2)
!21 = !DISubroutineType(types: !22)
!22 = !{!23}
!23 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
!24 = !DILocation(line: 12, column: 8, scope: !7, inlinedAt: !25)
!25 = distinct !DILocation(line: 18, column: 2, scope: !20)
!26 = !DILocation(line: 11, column: 12, scope: !7, inlinedAt: !25)
!27 = !DILocation(line: 13, column: 2, scope: !7, inlinedAt: !25)
!28 = !DILocation(line: 18, column: 2, scope: !20)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment