1; REQUIRES: x86-registered-target 2; RUN: llc -filetype=obj -mtriple=x86_64-unknown-linux-gnu -o %t %s 3; RUN: llvm-dwarfdump -debug-info %t | FileCheck %s 4; Source: 5; #define __tag1 __attribute__((btf_decl_tag("tag1"))) 6; #define __tag2 __attribute__((btf_decl_tag("tag2"))) 7; 8; struct t1 { 9; int a __tag1 __tag2; 10; } __tag1 __tag2; 11; 12; int g1 __tag1 __tag2; 13; 14; int __tag1 __tag2 foo(struct t1 *arg __tag1 __tag2) { 15; return arg->a; 16; } 17; Compilation flag: 18; clang -target x86_64 -g -S -emit-llvm t.c 19 20%struct.t1 = type { i32 } 21 22@g1 = dso_local global i32 0, align 4, !dbg !0 23 24; Function Attrs: noinline nounwind optnone uwtable 25define dso_local i32 @foo(ptr %arg) #0 !dbg !16 { 26entry: 27 %arg.addr = alloca ptr, align 8 28 store ptr %arg, ptr %arg.addr, align 8 29 call void @llvm.dbg.declare(metadata ptr %arg.addr, metadata !23, metadata !DIExpression()), !dbg !24 30 %0 = load ptr, ptr %arg.addr, align 8, !dbg !25 31 %1 = load i32, ptr %0, align 4, !dbg !26 32 ret i32 %1, !dbg !27 33} 34 35; Function Attrs: nofree nosync nounwind readnone speculatable willreturn 36declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 37 38attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } 39attributes #1 = { nofree nosync nounwind readnone speculatable willreturn } 40 41!llvm.dbg.cu = !{!2} 42!llvm.module.flags = !{!10, !11, !12, !13, !14} 43!llvm.ident = !{!15} 44 45!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) 46!1 = distinct !DIGlobalVariable(name: "g1", scope: !2, file: !3, line: 8, type: !6, isLocal: false, isDefinition: true, annotations: !7) 47 48; CHECK: DW_TAG_variable 49; CHECK-NEXT: DW_AT_name ("g1") 50; CHECK: DW_TAG_LLVM_annotation 51; CHECK-NEXT: DW_AT_name ("btf_decl_tag") 52; CHECK-NEXT: DW_AT_const_value ("tag1") 53; CHECK-EMPTY: 54; CHECK-NEXT: DW_TAG_LLVM_annotation 55; CHECK-NEXT: DW_AT_name ("btf_decl_tag") 56; CHECK-NEXT: DW_AT_const_value ("tag2") 57; CHECK-EMPTY: 58; CHECK-NEXT: NULL 59 60!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 13.0.0 (https://github.com/llvm/llvm-project.git 305231a4f71b68945b4dd92925c76ff49e377c86)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5, splitDebugInlining: false, nameTableKind: None) 61!3 = !DIFile(filename: "t.c", directory: "/tmp/home/yhs/work/tests/llvm/btf_tag") 62!4 = !{} 63!5 = !{!0} 64!6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) 65!7 = !{!8, !9} 66!8 = !{!"btf_decl_tag", !"tag1"} 67!9 = !{!"btf_decl_tag", !"tag2"} 68!10 = !{i32 7, !"Dwarf Version", i32 4} 69!11 = !{i32 2, !"Debug Info Version", i32 3} 70!12 = !{i32 1, !"wchar_size", i32 4} 71!13 = !{i32 7, !"uwtable", i32 1} 72!14 = !{i32 7, !"frame-pointer", i32 2} 73!15 = !{!"clang version 13.0.0 (https://github.com/llvm/llvm-project.git 305231a4f71b68945b4dd92925c76ff49e377c86)"} 74!16 = distinct !DISubprogram(name: "foo", scope: !3, file: !3, line: 10, type: !17, scopeLine: 10, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !4, annotations: !7) 75 76; CHECK: DW_TAG_subprogram 77; CHECK: DW_AT_name ("foo") 78; CHECK: DW_TAG_formal_parameter 79; CHECK: DW_TAG_LLVM_annotation 80; CHECK-NEXT: DW_AT_name ("btf_decl_tag") 81; CHECK-NEXT: DW_AT_const_value ("tag1") 82; CHECK-EMPTY: 83; CHECK-NEXT: DW_TAG_LLVM_annotation 84; CHECK-NEXT: DW_AT_name ("btf_decl_tag") 85; CHECK-NEXT: DW_AT_const_value ("tag2") 86; CHECK-EMPTY: 87; CHECK-NEXT: NULL 88; CHECK-EMPTY: 89; CHECK-NEXT: DW_TAG_LLVM_annotation 90; CHECK-NEXT: DW_AT_name ("btf_decl_tag") 91; CHECK-NEXT: DW_AT_const_value ("tag1") 92; CHECK-EMPTY: 93; CHECK-NEXT: DW_TAG_LLVM_annotation 94; CHECK-NEXT: DW_AT_name ("btf_decl_tag") 95; CHECK-NEXT: DW_AT_const_value ("tag2") 96; CHECK-EMPTY: 97; CHECK-NEXT: NULL 98 99!17 = !DISubroutineType(types: !18) 100!18 = !{!6, !19} 101!19 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !20, size: 64) 102!20 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "t1", file: !3, line: 4, size: 32, elements: !21, annotations: !7) 103!21 = !{!22} 104!22 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !20, file: !3, line: 5, baseType: !6, size: 32, annotations: !7) 105 106; CHECK: DW_TAG_structure_type 107; CHECK-NEXT: DW_AT_name ("t1") 108; CHECK: DW_TAG_member 109; CHECK-NEXT: DW_AT_name ("a") 110; CHECK: DW_TAG_LLVM_annotation 111; CHECK-NEXT: DW_AT_name ("btf_decl_tag") 112; CHECK-NEXT: DW_AT_const_value ("tag1") 113; CHECK-EMPTY: 114; CHECK-NEXT: DW_TAG_LLVM_annotation 115; CHECK-NEXT: DW_AT_name ("btf_decl_tag") 116; CHECK-NEXT: DW_AT_const_value ("tag2") 117; CHECK-EMPTY: 118; CHECK-NEXT: NULL 119; CHECK-EMPTY: 120; CHECK-NEXT: DW_TAG_LLVM_annotation 121; CHECK-NEXT: DW_AT_name ("btf_decl_tag") 122; CHECK-NEXT: DW_AT_const_value ("tag1") 123; CHECK-EMPTY: 124; CHECK-NEXT: DW_TAG_LLVM_annotation 125; CHECK-NEXT: DW_AT_name ("btf_decl_tag") 126; CHECK-NEXT: DW_AT_const_value ("tag2") 127; CHECK-EMPTY: 128; CHECK-NEXT: NULL 129 130!23 = !DILocalVariable(name: "arg", arg: 1, scope: !16, file: !3, line: 10, type: !19, annotations: !7) 131!24 = !DILocation(line: 10, column: 48, scope: !16) 132!25 = !DILocation(line: 11, column: 10, scope: !16) 133!26 = !DILocation(line: 11, column: 15, scope: !16) 134!27 = !DILocation(line: 11, column: 3, scope: !16) 135