typedef struct
{
int a;
} MyStruct;
MyStruct *produce(void);
MyStruct myEntry(void)
{
return *produce();
}
; ModuleID = '/tmp/semicompiled-luM6Ryi0-3944431309124335505/source.c'
source_filename = "/tmp/semicompiled-luM6Ryi0-3944431309124335505/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
%struct.MyStruct = type { i32 }
; Function Attrs: noinline nounwind optnone uwtable
define dso_local i32 @myEntry() #0 {
%1 = alloca %struct.MyStruct, align 4
%2 = call %struct.MyStruct* @produce()
%3 = bitcast %struct.MyStruct* %1 to i8*
%4 = bitcast %struct.MyStruct* %2 to i8*
call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 4 %4, i64 4, i1 false)
%5 = getelementptr inbounds %struct.MyStruct, %struct.MyStruct* %1, i32 0, i32 0
%6 = load i32, i32* %5, align 4
ret i32 %6
}
declare dso_local %struct.MyStruct* @produce() #1
; Function Attrs: argmemonly nounwind willreturn
declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #2
attributes #0 = { noinline nounwind optnone uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #1 = { "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #2 = { argmemonly nounwind willreturn }
!llvm.module.flags = !{!0}
!llvm.ident = !{!1}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{!"Debian clang version 11.0.1-2"}
; ModuleID = '/tmp/semicompiled-luM6Ryi0-3944431309124335505/source.c'
source_filename = "/tmp/semicompiled-luM6Ryi0-3944431309124335505/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
%struct.MyStruct = type { i32 }
; Function Attrs: noinline nounwind optnone uwtable
define dso_local i32 @myEntry() #0 !dbg !7 {
%1 = alloca %struct.MyStruct, align 4
%2 = call %struct.MyStruct* @produce(), !dbg !16
%3 = bitcast %struct.MyStruct* %1 to i8*, !dbg !17
%4 = bitcast %struct.MyStruct* %2 to i8*, !dbg !17
call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %3, i8* align 4 %4, i64 4, i1 false), !dbg !17
%5 = getelementptr inbounds %struct.MyStruct, %struct.MyStruct* %1, i32 0, i32 0, !dbg !18
%6 = load i32, i32* %5, align 4, !dbg !18
ret i32 %6, !dbg !18
}
declare dso_local %struct.MyStruct* @produce() #1
; Function Attrs: argmemonly nounwind willreturn
declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #2
attributes #0 = { noinline nounwind optnone uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #1 = { "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #2 = { argmemonly nounwind willreturn }
!llvm.dbg.cu = !{!0}
!llvm.module.flags = !{!3, !4, !5}
!llvm.ident = !{!6}
!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "Debian clang version 11.0.1-2", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)
!1 = !DIFile(filename: "/tmp/semicompiled-luM6Ryi0-3944431309124335505/source.c", directory: "/__w/semicompiled/semicompiled")
!2 = !{}
!3 = !{i32 7, !"Dwarf Version", i32 4}
!4 = !{i32 2, !"Debug Info Version", i32 3}
!5 = !{i32 1, !"wchar_size", i32 4}
!6 = !{!"Debian clang version 11.0.1-2"}
!7 = distinct !DISubprogram(name: "myEntry", scope: !8, file: !8, line: 6, type: !9, scopeLine: 7, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
!8 = !DIFile(filename: "/tmp/semicompiled-luM6Ryi0-3944431309124335505/source.c", directory: "")
!9 = !DISubroutineType(types: !10)
!10 = !{!11}
!11 = !DIDerivedType(tag: DW_TAG_typedef, name: "MyStruct", file: !8, line: 4, baseType: !12)
!12 = distinct !DICompositeType(tag: DW_TAG_structure_type, file: !8, line: 1, size: 32, elements: !13)
!13 = !{!14}
!14 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !12, file: !8, line: 3, baseType: !15, size: 32)
!15 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
!16 = !DILocation(line: 8, column: 13, scope: !7)
!17 = !DILocation(line: 8, column: 12, scope: !7)
!18 = !DILocation(line: 8, column: 5, scope: !7)
(module
(type (;0;) (func))
(type (;1;) (func (result i32)))
(import "env" "produce" (func (;0;) (type 1)))
(import "env" "__stack_pointer" (global (;0;) (mut i32)))
(import "env" "__memory_base" (global (;1;) i32))
(import "env" "__table_base" (global (;2;) i32))
(import "env" "memory" (memory (;0;) 0))
(import "env" "__indirect_function_table" (table (;0;) 0 funcref))
(func (;1;) (type 0)
call 2)
(func (;2;) (type 0))
(func (;3;) (type 1) (result i32)
(local i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32)
global.get 0
local.set 0
i32.const 16
local.set 1
local.get 0
local.get 1
i32.sub
local.set 2
local.get 2
global.set 0
i32.const 8
local.set 3
local.get 2
local.get 3
i32.add
local.set 4
local.get 4
local.set 5
call 0
local.set 6
local.get 6
i32.load
local.set 7
local.get 5
local.get 7
i32.store
local.get 2
i32.load offset=8
local.set 8
i32.const 16
local.set 9
local.get 2
local.get 9
i32.add
local.set 10
local.get 10
global.set 0
local.get 8
return)
(global (;3;) i32 (i32.const 0))
(export "__post_instantiate" (func 1))
(export "__wasm_apply_relocs" (func 2))
(export "myEntry" (func 3))
(export "__dso_handle" (global 3)))
eBPF doesn't support struct returns or pass by value.
Join the thriving social scene at github.com/andrewbaxter/semicompiled.