96 lines · plain
1; RUN: opt -O2 -mtriple=bpf-pc-linux %s | llvm-dis > %t12; RUN: llc -o - %t1 | FileCheck %s3; RUN: opt -passes='default<O2>' -mtriple=bpf-pc-linux %s | llvm-dis > %t14; RUN: llc -o - %t1 | FileCheck %s5;6; Source:7; struct s1 { int a; int b; };8; int foo(struct s1 *arg) { return __builtin_btf_type_id(*arg, 0); }9; int bar(struct s1 *arg) { return __builtin_btf_type_id(*arg, 0); }10; Compilation flag:11; clang -target bpf -O2 -S -emit-llvm -g -Xclang -disable-llvm-passes test.c12 13%struct.s1 = type { i32, i32 }14 15; Function Attrs: nounwind16define dso_local i32 @foo(ptr %arg) !dbg !7 {17entry:18 %arg.addr = alloca ptr, align 819 store ptr %arg, ptr %arg.addr, align 8, !tbaa !1820 call void @llvm.dbg.declare(metadata ptr %arg.addr, metadata !17, metadata !DIExpression()), !dbg !2221 %0 = call i64 @llvm.bpf.btf.type.id(i32 0, i64 0), !dbg !23, !llvm.preserve.access.index !1222 %conv = trunc i64 %0 to i32, !dbg !2323 ret i32 %conv, !dbg !2424}25 26; Function Attrs: nofree nosync nounwind readnone speculatable willreturn27declare void @llvm.dbg.declare(metadata, metadata, metadata)28 29; Function Attrs: nounwind readnone30declare i64 @llvm.bpf.btf.type.id(i32, i64)31 32; Function Attrs: nounwind33define dso_local i32 @bar(ptr %arg) !dbg !25 {34entry:35 %arg.addr = alloca ptr, align 836 store ptr %arg, ptr %arg.addr, align 8, !tbaa !1837 call void @llvm.dbg.declare(metadata ptr %arg.addr, metadata !27, metadata !DIExpression()), !dbg !2838 %0 = call i64 @llvm.bpf.btf.type.id(i32 1, i64 0), !dbg !29, !llvm.preserve.access.index !1239 %conv = trunc i64 %0 to i32, !dbg !2940 ret i32 %conv, !dbg !3041}42 43; CHECK: .long 1 # BTF_KIND_STRUCT(id = 2)44 45; CHECK: .ascii "s1" # string offset=146; CHECK: .ascii ".text" # string offset=2047; CHECK: .byte 48 # string offset=2648 49; CHECK: .long 16 # FieldReloc50; CHECK-NEXT: .long 20 # Field reloc section string offset=2051; CHECK-NEXT: .long 252; CHECK-NEXT: .long .Ltmp{{[0-9]+}}53; CHECK-NEXT: .long 254; CHECK-NEXT: .long 2655; CHECK-NEXT: .long 656; CHECK-NEXT: .long .Ltmp{{[0-9]+}}57; CHECK-NEXT: .long 258; CHECK-NEXT: .long 2659; CHECK-NEXT: .long 660 61!llvm.dbg.cu = !{!0}62!llvm.module.flags = !{!3, !4, !5}63!llvm.ident = !{!6}64 65!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 12.0.0 (https://github.com/llvm/llvm-project.git c1c153c3c70641a23c4a9540a897ff2d4eb4c5b2)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)66!1 = !DIFile(filename: "test.c", directory: "/home/yhs/work/tests/dup")67!2 = !{}68!3 = !{i32 7, !"Dwarf Version", i32 4}69!4 = !{i32 2, !"Debug Info Version", i32 3}70!5 = !{i32 1, !"wchar_size", i32 4}71!6 = !{!"clang version 12.0.0 (https://github.com/llvm/llvm-project.git c1c153c3c70641a23c4a9540a897ff2d4eb4c5b2)"}72!7 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 2, type: !8, scopeLine: 2, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !16)73!8 = !DISubroutineType(types: !9)74!9 = !{!10, !11}75!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)76!11 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 64)77!12 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "s1", file: !1, line: 1, size: 64, elements: !13)78!13 = !{!14, !15}79!14 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !12, file: !1, line: 1, baseType: !10, size: 32)80!15 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !12, file: !1, line: 1, baseType: !10, size: 32, offset: 32)81!16 = !{!17}82!17 = !DILocalVariable(name: "arg", arg: 1, scope: !7, file: !1, line: 2, type: !11)83!18 = !{!19, !19, i64 0}84!19 = !{!"any pointer", !20, i64 0}85!20 = !{!"omnipotent char", !21, i64 0}86!21 = !{!"Simple C/C++ TBAA"}87!22 = !DILocation(line: 2, column: 20, scope: !7)88!23 = !DILocation(line: 2, column: 34, scope: !7)89!24 = !DILocation(line: 2, column: 27, scope: !7)90!25 = distinct !DISubprogram(name: "bar", scope: !1, file: !1, line: 3, type: !8, scopeLine: 3, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !26)91!26 = !{!27}92!27 = !DILocalVariable(name: "arg", arg: 1, scope: !25, file: !1, line: 3, type: !11)93!28 = !DILocation(line: 3, column: 20, scope: !25)94!29 = !DILocation(line: 3, column: 34, scope: !25)95!30 = !DILocation(line: 3, column: 27, scope: !25)96