1 ; RUN: opt < %s -passes='default<O2>' | llc -march=bpfel -filetype=asm -o /dev/null -
2 ; RUN: opt < %s -passes='default<O0>' | llc -march=bpfel -filetype=asm -o /dev/null -
6 ; struct ss { int a; };
7 ; int foo() { return __builtin_btf_type_id(0, 0) + __builtin_preserve_type_info(*(struct ss *)0, 0); }
8 ; $ clang -target bpf -g -S -emit-llvm t.c -Xclang -disable-llvm-passes /tmp/a.c
12 ; Function Attrs: noinline nounwind optnone
13 define dso_local i32 @foo() #0 !dbg !9 {
15 %0 = call i64 @llvm.bpf.btf.type.id(i32 0, i64 0), !dbg !11, !llvm.preserve.access.index !4
16 %1 = call i32 @llvm.bpf.preserve.type.info(i32 1, i64 0), !dbg !12, !llvm.preserve.access.index !13
17 %conv = zext i32 %1 to i64, !dbg !12
18 %add = add i64 %0, %conv, !dbg !16
19 %conv1 = trunc i64 %add to i32, !dbg !11
20 ret i32 %conv1, !dbg !17
23 ; Function Attrs: nounwind readnone
24 declare i64 @llvm.bpf.btf.type.id(i32, i64) #1
26 ; Function Attrs: nounwind readnone
27 declare i32 @llvm.bpf.preserve.type.info(i32, i64) #1
29 attributes #0 = { noinline nounwind optnone }
30 attributes #1 = { nounwind readnone }
33 !llvm.module.flags = !{!5, !6, !7}
36 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 12.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !3, splitDebugInlining: false, nameTableKind: None)
37 !1 = !DIFile(filename: "C:/src/tmp\\a.c", directory: "C:\\src\\llvm-project")
40 !4 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
41 !5 = !{i32 7, !"Dwarf Version", i32 4}
42 !6 = !{i32 2, !"Debug Info Version", i32 3}
43 !7 = !{i32 1, !"wchar_size", i32 4}
44 !8 = !{!"clang version 12.0.0"}
45 !9 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 2, type: !10, scopeLine: 2, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
46 !10 = !DISubroutineType(types: !3)
47 !11 = !DILocation(line: 2, column: 20, scope: !9)
48 !12 = !DILocation(line: 2, column: 50, scope: !9)
49 !13 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "ss", file: !1, line: 1, size: 32, elements: !14)
51 !15 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !13, file: !1, line: 1, baseType: !4, size: 32)
52 !16 = !DILocation(line: 2, column: 48, scope: !9)
53 !17 = !DILocation(line: 2, column: 13, scope: !9)