typedef struct
{
int a : 1;
int b : 2;
} MyStruct;
MyStruct x;
void consume(int);
void myEntry(void)
{
consume(x.b);
}
; ModuleID = '/tmp/semicompiled-y7VyZSOj-10242449004022500675/source.c'
source_filename = "/tmp/semicompiled-y7VyZSOj-10242449004022500675/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 { i8, [3 x i8] }
@x = dso_local global %struct.MyStruct zeroinitializer, align 4
; Function Attrs: noinline nounwind optnone uwtable
define dso_local void @myEntry() #0 {
%1 = load i8, i8* getelementptr inbounds (%struct.MyStruct, %struct.MyStruct* @x, i32 0, i32 0), align 4
%2 = shl i8 %1, 5
%3 = ashr i8 %2, 6
%4 = sext i8 %3 to i32
call void @consume(i32 %4)
ret void
}
declare dso_local void @consume(i32) #1
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" }
!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-y7VyZSOj-10242449004022500675/source.c'
source_filename = "/tmp/semicompiled-y7VyZSOj-10242449004022500675/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 { i8, [3 x i8] }
@x = dso_local global %struct.MyStruct zeroinitializer, align 4, !dbg !0
; Function Attrs: noinline nounwind optnone uwtable
define dso_local void @myEntry() #0 !dbg !17 {
%1 = load i8, i8* getelementptr inbounds (%struct.MyStruct, %struct.MyStruct* @x, i32 0, i32 0), align 4, !dbg !20
%2 = shl i8 %1, 5, !dbg !20
%3 = ashr i8 %2, 6, !dbg !20
%4 = sext i8 %3 to i32, !dbg !20
call void @consume(i32 %4), !dbg !21
ret void, !dbg !22
}
declare dso_local void @consume(i32) #1
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" }
!llvm.dbg.cu = !{!2}
!llvm.module.flags = !{!13, !14, !15}
!llvm.ident = !{!16}
!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
!1 = distinct !DIGlobalVariable(name: "x", scope: !2, file: !6, line: 6, type: !7, isLocal: false, isDefinition: true)
!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "Debian clang version 11.0.1-2", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5, splitDebugInlining: false, nameTableKind: None)
!3 = !DIFile(filename: "/tmp/semicompiled-y7VyZSOj-10242449004022500675/source.c", directory: "/__w/semicompiled/semicompiled")
!4 = !{}
!5 = !{!0}
!6 = !DIFile(filename: "/tmp/semicompiled-y7VyZSOj-10242449004022500675/source.c", directory: "")
!7 = !DIDerivedType(tag: DW_TAG_typedef, name: "MyStruct", file: !6, line: 5, baseType: !8)
!8 = distinct !DICompositeType(tag: DW_TAG_structure_type, file: !6, line: 1, size: 32, elements: !9)
!9 = !{!10, !12}
!10 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !8, file: !6, line: 3, baseType: !11, size: 1, flags: DIFlagBitField, extraData: i64 0)
!11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
!12 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !8, file: !6, line: 4, baseType: !11, size: 2, offset: 1, flags: DIFlagBitField, extraData: i64 0)
!13 = !{i32 7, !"Dwarf Version", i32 4}
!14 = !{i32 2, !"Debug Info Version", i32 3}
!15 = !{i32 1, !"wchar_size", i32 4}
!16 = !{!"Debian clang version 11.0.1-2"}
!17 = distinct !DISubprogram(name: "myEntry", scope: !6, file: !6, line: 8, type: !18, scopeLine: 9, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !4)
!18 = !DISubroutineType(types: !19)
!19 = !{null}
!20 = !DILocation(line: 10, column: 15, scope: !17)
!21 = !DILocation(line: 10, column: 5, scope: !17)
!22 = !DILocation(line: 11, column: 1, scope: !17)
(module
(type (;0;) (func))
(type (;1;) (func (param i32)))
(import "env" "consume" (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 "GOT.mem" "x" (global (;3;) (mut 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 0)
(local i32 i32 i32 i32 i32 i32 i32 i32 i32)
global.get 3
local.set 0
local.get 0
i32.load8_u
local.set 1
i32.const 29
local.set 2
local.get 1
local.get 2
i32.shl
local.set 3
i32.const 30
local.set 4
local.get 3
local.get 4
i32.shr_s
local.set 5
i32.const 24
local.set 6
local.get 5
local.get 6
i32.shl
local.set 7
local.get 7
local.get 6
i32.shr_s
local.set 8
local.get 8
call 0
return)
(global (;4;) i32 (i32.const 0))
(global (;5;) i32 (i32.const 0))
(export "__post_instantiate" (func 1))
(export "__wasm_apply_relocs" (func 2))
(export "myEntry" (func 3))
(export "x" (global 4))
(export "__dso_handle" (global 5))
(data (;0;) (global.get 1) "\00\00\00\00"))
/tmp/semicompiled-y7VyZSOj-10242449004022500675/source.o: file format elf64-bpf
Disassembly of section .text:
0000000000000000 <myEntry>:
; myEntry():
; /tmp/semicompiled-y7VyZSOj-10242449004022500675/source.c:10
; consume(x.b);
0: r1 = 0 ll
2: r1 = *(u8 *)(r1 + 0)
3: r1 <<= 61
4: r1 s>>= 62
5: call -1
; /tmp/semicompiled-y7VyZSOj-10242449004022500675/source.c:11
; }
6: exit
Join the thriving social scene at github.com/andrewbaxter/semicompiled.