[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / CodeGen / builtin-bpf-btf-type-id.c
blob4c6efd69eb9563410fa51900386975d5a1faf2ee
1 // REQUIRES: bpf-registered-target
2 // RUN: %clang -target bpf -emit-llvm -S -g -Xclang -disable-llvm-passes %s -o - | FileCheck %s
4 unsigned test1(int a) { return __builtin_btf_type_id(a, 0); }
5 unsigned test2(int a) { return __builtin_btf_type_id(&a, 0); }
7 struct t1 { int a; };
8 typedef struct t1 __t1;
9 unsigned test3() {
10 return __builtin_btf_type_id(*(struct t1 *)0, 1) +
11 __builtin_btf_type_id(*(__t1 *)0, 1);
14 // CHECK: define dso_local i32 @test1
15 // CHECK: call i64 @llvm.bpf.btf.type.id(i32 0, i64 0), !dbg !{{[0-9]+}}, !llvm.preserve.access.index ![[INT:[0-9]+]]
16 // CHECK: define dso_local i32 @test2
17 // CHECK: call i64 @llvm.bpf.btf.type.id(i32 1, i64 0), !dbg !{{[0-9]+}}, !llvm.preserve.access.index ![[INT_POINTER:[0-9]+]]
18 // CHECK: define dso_local i32 @test3
19 // CHECK: call i64 @llvm.bpf.btf.type.id(i32 2, i64 1), !dbg !{{[0-9]+}}, !llvm.preserve.access.index ![[STRUCT_T1:[0-9]+]]
20 // CHECK: call i64 @llvm.bpf.btf.type.id(i32 3, i64 1), !dbg !{{[0-9]+}}, !llvm.preserve.access.index ![[TYPEDEF_T1:[0-9]+]]
22 // CHECK: ![[INT]] = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed
23 // CHECK: ![[INT_POINTER]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: ![[INT]], size: 64
24 // CHECK: ![[STRUCT_T1]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "t1"
25 // CHECK: ![[TYPEDEF_T1]] = !DIDerivedType(tag: DW_TAG_typedef, name: "__t1"