]> granicus.if.org Git - llvm/commitdiff
[BPF] handle derived type properly for computing type id
authorYonghong Song <yhs@fb.com>
Fri, 22 Mar 2019 01:30:50 +0000 (01:30 +0000)
committerYonghong Song <yhs@fb.com>
Fri, 22 Mar 2019 01:30:50 +0000 (01:30 +0000)
Currently, the type id for a derived type is computed incorrectly.
For example,
  type #1: int
  type #2: ptr to #1

For a global variable "int *a", type #1 will be attributed to variable "a".
This is due to a bug which assigns the type id of the basetype of
that derived type as the derived type's type id. This happens
to "const", "volatile", "restrict", "typedef" and "pointer" types.

This patch fixed this bug, fixed existing test cases and added
a new one focusing on pointers plus other derived types.

Signed-off-by: Yonghong Song <yhs@fb.com>
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@356727 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/BPF/BTFDebug.cpp
test/CodeGen/BPF/BTF/global-var-sec-readonly.ll
test/CodeGen/BPF/BTF/static-var-derived-type.ll [new file with mode: 0644]
test/CodeGen/BPF/BTF/static-var-inited-sec.ll
test/CodeGen/BPF/BTF/static-var-inited.ll
test/CodeGen/BPF/BTF/static-var-readonly-sec.ll
test/CodeGen/BPF/BTF/static-var-readonly.ll
test/CodeGen/BPF/BTF/static-var-sec.ll
test/CodeGen/BPF/BTF/static-var-zerolen-array.ll
test/CodeGen/BPF/BTF/static-var.ll

index 01d3b9e9d00d090757da599eb1e67945e2c356e1..f054933a2aa44ad59df76f83ad2c103284236649 100644 (file)
@@ -511,7 +511,8 @@ void BTFDebug::visitDerivedType(const DIDerivedType *DTy, uint32_t &TypeId) {
 
   // Visit base type of pointer, typedef, const, volatile, restrict or
   // struct/union member.
-  visitTypeEntry(DTy->getBaseType().resolve(), TypeId);
+  uint32_t TempTypeId = 0;
+  visitTypeEntry(DTy->getBaseType().resolve(), TempTypeId);
 }
 
 void BTFDebug::visitTypeEntry(const DIType *Ty, uint32_t &TypeId) {
index 634c82ae360b3d0df0f364a81ab7d4c1fa142b64..79416711ffe35e6cfaff5275d463f033329f8f0c 100644 (file)
@@ -28,7 +28,7 @@
 ; CHECK-NEXT:        .long   16777248                # 0x1000020
 ; CHECK-NEXT:        .long   5                       # BTF_KIND_VAR(id = 3)
 ; CHECK-NEXT:        .long   234881024               # 0xe000000
-; CHECK-NEXT:        .long   2
+; CHECK-NEXT:        .long   1
 ; CHECK-NEXT:        .long   1
 ; CHECK-NEXT:        .long   9                       # BTF_KIND_VAR(id = 4)
 ; CHECK-NEXT:        .long   234881024               # 0xe000000
diff --git a/test/CodeGen/BPF/BTF/static-var-derived-type.ll b/test/CodeGen/BPF/BTF/static-var-derived-type.ll
new file mode 100644 (file)
index 0000000..8a0ffdd
--- /dev/null
@@ -0,0 +1,190 @@
+; RUN: llc -march=bpfel -filetype=asm -o - %s | FileCheck -check-prefixes=CHECK %s
+; RUN: llc -march=bpfeb -filetype=asm -o - %s | FileCheck -check-prefixes=CHECK %s
+
+; Source code:
+;   typedef int * int_ptr;
+;   static int * volatile v1;
+;   static const int * volatile v2;
+;   static volatile int_ptr v3 = 0;
+;   static volatile const int_ptr v4 = 0;
+;   long foo() { return (long)(v1 - v2 + v3 - v4); }
+; Compilation flag:
+;   clang -target bpf -O2 -g -S -emit-llvm test.c
+
+@v1 = internal global i32* null, align 8, !dbg !0
+@v2 = internal global i32* null, align 8, !dbg !8
+@v3 = internal global i32* null, align 8, !dbg !14
+@v4 = internal constant i32* null, align 8, !dbg !19
+
+; Function Attrs: norecurse nounwind
+define dso_local i64 @foo() local_unnamed_addr #0 !dbg !27 {
+  %1 = load volatile i32*, i32** @v1, align 8, !dbg !29, !tbaa !30
+  %2 = load volatile i32*, i32** @v2, align 8, !dbg !34, !tbaa !30
+  %3 = ptrtoint i32* %1 to i64, !dbg !35
+  %4 = ptrtoint i32* %2 to i64, !dbg !35
+  %5 = sub i64 %3, %4, !dbg !35
+  %6 = ashr exact i64 %5, 2, !dbg !35
+  %7 = load volatile i32*, i32** @v3, align 8, !dbg !36, !tbaa !30
+  %8 = getelementptr inbounds i32, i32* %7, i64 %6, !dbg !37
+  %9 = load volatile i32*, i32** @v4, align 8, !dbg !38, !tbaa !30
+  %10 = ptrtoint i32* %8 to i64, !dbg !39
+  %11 = ptrtoint i32* %9 to i64, !dbg !39
+  %12 = sub i64 %10, %11, !dbg !39
+  %13 = ashr exact i64 %12, 2, !dbg !39
+  ret i64 %13, !dbg !40
+}
+
+; CHECK:             .section        .BTF,"",@progbits
+; CHECK-NEXT:        .short  60319                   # 0xeb9f
+; CHECK-NEXT:        .byte   1
+; CHECK-NEXT:        .byte   0
+; CHECK-NEXT:        .long   24
+; CHECK-NEXT:        .long   0
+; CHECK-NEXT:        .long   288
+; CHECK-NEXT:        .long   288
+; CHECK-NEXT:        .long   95
+; CHECK-NEXT:        .long   0                       # BTF_KIND_FUNC_PROTO(id = 1)
+; CHECK-NEXT:        .long   218103808               # 0xd000000
+; CHECK-NEXT:        .long   2
+; CHECK-NEXT:        .long   45                      # BTF_KIND_INT(id = 2)
+; CHECK-NEXT:        .long   16777216                # 0x1000000
+; CHECK-NEXT:        .long   8
+; CHECK-NEXT:        .long   16777280                # 0x1000040
+; CHECK-NEXT:        .long   54                      # BTF_KIND_FUNC(id = 3)
+; CHECK-NEXT:        .long   201326592               # 0xc000000
+; CHECK-NEXT:        .long   1
+; CHECK-NEXT:        .long   0                       # BTF_KIND_VOLATILE(id = 4)
+; CHECK-NEXT:        .long   150994944               # 0x9000000
+; CHECK-NEXT:        .long   5
+; CHECK-NEXT:        .long   0                       # BTF_KIND_PTR(id = 5)
+; CHECK-NEXT:        .long   33554432                # 0x2000000
+; CHECK-NEXT:        .long   6
+; CHECK-NEXT:        .long   58                      # BTF_KIND_INT(id = 6)
+; CHECK-NEXT:        .long   16777216                # 0x1000000
+; CHECK-NEXT:        .long   4
+; CHECK-NEXT:        .long   16777248                # 0x1000020
+; CHECK-NEXT:        .long   62                      # BTF_KIND_VAR(id = 7)
+; CHECK-NEXT:        .long   234881024               # 0xe000000
+; CHECK-NEXT:        .long   4
+; CHECK-NEXT:        .long   0
+; CHECK-NEXT:        .long   0                       # BTF_KIND_VOLATILE(id = 8)
+; CHECK-NEXT:        .long   150994944               # 0x9000000
+; CHECK-NEXT:        .long   9
+; CHECK-NEXT:        .long   0                       # BTF_KIND_PTR(id = 9)
+; CHECK-NEXT:        .long   33554432                # 0x2000000
+; CHECK-NEXT:        .long   10
+; CHECK-NEXT:        .long   0                       # BTF_KIND_CONST(id = 10)
+; CHECK-NEXT:        .long   167772160               # 0xa000000
+; CHECK-NEXT:        .long   6
+; CHECK-NEXT:        .long   65                      # BTF_KIND_VAR(id = 11)
+; CHECK-NEXT:        .long   234881024               # 0xe000000
+; CHECK-NEXT:        .long   8
+; CHECK-NEXT:        .long   0
+; CHECK-NEXT:        .long   0                       # BTF_KIND_VOLATILE(id = 12)
+; CHECK-NEXT:        .long   150994944               # 0x9000000
+; CHECK-NEXT:        .long   13
+; CHECK-NEXT:        .long   68                      # BTF_KIND_TYPEDEF(id = 13)
+; CHECK-NEXT:        .long   134217728               # 0x8000000
+; CHECK-NEXT:        .long   5
+; CHECK-NEXT:        .long   76                      # BTF_KIND_VAR(id = 14)
+; CHECK-NEXT:        .long   234881024               # 0xe000000
+; CHECK-NEXT:        .long   12
+; CHECK-NEXT:        .long   0
+; CHECK-NEXT:        .long   0                       # BTF_KIND_CONST(id = 15)
+; CHECK-NEXT:        .long   167772160               # 0xa000000
+; CHECK-NEXT:        .long   12
+; CHECK-NEXT:        .long   79                      # BTF_KIND_VAR(id = 16)
+; CHECK-NEXT:        .long   234881024               # 0xe000000
+; CHECK-NEXT:        .long   15
+; CHECK-NEXT:        .long   0
+; CHECK-NEXT:        .long   82                      # BTF_KIND_DATASEC(id = 17)
+; CHECK-NEXT:        .long   251658241               # 0xf000001
+; CHECK-NEXT:        .long   0
+; CHECK-NEXT:        .long   16
+; CHECK-NEXT:        .long   v4
+; CHECK-NEXT:        .long   8
+; CHECK-NEXT:        .long   90                      # BTF_KIND_DATASEC(id = 18)
+; CHECK-NEXT:        .long   251658243               # 0xf000003
+; CHECK-NEXT:        .long   0
+; CHECK-NEXT:        .long   7
+; CHECK-NEXT:        .long   v1
+; CHECK-NEXT:        .long   8
+; CHECK-NEXT:        .long   11
+; CHECK-NEXT:        .long   v2
+; CHECK-NEXT:        .long   8
+; CHECK-NEXT:        .long   14
+; CHECK-NEXT:        .long   v3
+; CHECK-NEXT:        .long   8
+; CHECK-NEXT:        .byte   0                       # string offset=0
+; CHECK-NEXT:        .ascii  ".text"                 # string offset=1
+; CHECK-NEXT:        .byte   0
+; CHECK-NEXT:        .ascii  "/home/yhs/work/tests/llvm/bugs/test.c" # string offset=7
+; CHECK-NEXT:        .byte   0
+; CHECK-NEXT:        .ascii  "long int"              # string offset=45
+; CHECK-NEXT:        .byte   0
+; CHECK-NEXT:        .ascii  "foo"                   # string offset=54
+; CHECK-NEXT:        .byte   0
+; CHECK-NEXT:        .ascii  "int"                   # string offset=58
+; CHECK-NEXT:        .byte   0
+; CHECK-NEXT:        .ascii  "v1"                    # string offset=62
+; CHECK-NEXT:        .byte   0
+; CHECK-NEXT:        .ascii  "v2"                    # string offset=65
+; CHECK-NEXT:        .byte   0
+; CHECK-NEXT:        .ascii  "int_ptr"               # string offset=68
+; CHECK-NEXT:        .byte   0
+; CHECK-NEXT:        .ascii  "v3"                    # string offset=76
+; CHECK-NEXT:        .byte   0
+; CHECK-NEXT:        .ascii  "v4"                    # string offset=79
+; CHECK-NEXT:        .byte   0
+; CHECK-NEXT:        .ascii  ".rodata"               # string offset=82
+; CHECK-NEXT:        .byte   0
+; CHECK-NEXT:        .ascii  ".bss"                  # string offset=90
+; CHECK-NEXT:        .byte   0
+
+attributes #0 = { norecurse nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
+
+!llvm.dbg.cu = !{!2}
+!llvm.module.flags = !{!23, !24, !25}
+!llvm.ident = !{!26}
+
+!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+!1 = distinct !DIGlobalVariable(name: "v1", scope: !2, file: !3, line: 2, type: !22, isLocal: true, isDefinition: true)
+!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 8.0.20181009 ", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !5, globals: !7, nameTableKind: None)
+!3 = !DIFile(filename: "test.c", directory: "/home/yhs/work/tests/llvm/bugs")
+!4 = !{}
+!5 = !{!6}
+!6 = !DIBasicType(name: "long int", size: 64, encoding: DW_ATE_signed)
+!7 = !{!0, !8, !14, !19}
+!8 = !DIGlobalVariableExpression(var: !9, expr: !DIExpression())
+!9 = distinct !DIGlobalVariable(name: "v2", scope: !2, file: !3, line: 3, type: !10, isLocal: true, isDefinition: true)
+!10 = !DIDerivedType(tag: DW_TAG_volatile_type, baseType: !11)
+!11 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 64)
+!12 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !13)
+!13 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!14 = !DIGlobalVariableExpression(var: !15, expr: !DIExpression())
+!15 = distinct !DIGlobalVariable(name: "v3", scope: !2, file: !3, line: 4, type: !16, isLocal: true, isDefinition: true)
+!16 = !DIDerivedType(tag: DW_TAG_volatile_type, baseType: !17)
+!17 = !DIDerivedType(tag: DW_TAG_typedef, name: "int_ptr", file: !3, line: 1, baseType: !18)
+!18 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !13, size: 64)
+!19 = !DIGlobalVariableExpression(var: !20, expr: !DIExpression())
+!20 = distinct !DIGlobalVariable(name: "v4", scope: !2, file: !3, line: 5, type: !21, isLocal: true, isDefinition: true)
+!21 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !16)
+!22 = !DIDerivedType(tag: DW_TAG_volatile_type, baseType: !18)
+!23 = !{i32 2, !"Dwarf Version", i32 4}
+!24 = !{i32 2, !"Debug Info Version", i32 3}
+!25 = !{i32 1, !"wchar_size", i32 4}
+!26 = !{!"clang version 8.0.20181009 "}
+!27 = distinct !DISubprogram(name: "foo", scope: !3, file: !3, line: 6, type: !28, isLocal: false, isDefinition: true, scopeLine: 6, isOptimized: true, unit: !2, retainedNodes: !4)
+!28 = !DISubroutineType(types: !5)
+!29 = !DILocation(line: 6, column: 28, scope: !27)
+!30 = !{!31, !31, i64 0}
+!31 = !{!"any pointer", !32, i64 0}
+!32 = !{!"omnipotent char", !33, i64 0}
+!33 = !{!"Simple C/C++ TBAA"}
+!34 = !DILocation(line: 6, column: 33, scope: !27)
+!35 = !DILocation(line: 6, column: 31, scope: !27)
+!36 = !DILocation(line: 6, column: 38, scope: !27)
+!37 = !DILocation(line: 6, column: 36, scope: !27)
+!38 = !DILocation(line: 6, column: 43, scope: !27)
+!39 = !DILocation(line: 6, column: 41, scope: !27)
+!40 = !DILocation(line: 6, column: 14, scope: !27)
index 007b9a5c8a02b8ddd1cb3860f9a53c4776e4bcbf..beeffa0d5e8ada6733c7332f5426d753f2142c3c 100644 (file)
@@ -51,7 +51,7 @@ define dso_local i32 @foo() local_unnamed_addr #0 !dbg !2 {
 ; CHECK-NEXT:        .long   16777232                # 0x1000010
 ; CHECK-NEXT:        .long   58                      # BTF_KIND_VAR(id = 6)
 ; CHECK-NEXT:        .long   234881024               # 0xe000000
-; CHECK-NEXT:        .long   5
+; CHECK-NEXT:        .long   4
 ; CHECK-NEXT:        .long   0
 ; CHECK-NEXT:        .long   0                       # BTF_KIND_VOLATILE(id = 7)
 ; CHECK-NEXT:        .long   150994944               # 0x9000000
@@ -62,7 +62,7 @@ define dso_local i32 @foo() local_unnamed_addr #0 !dbg !2 {
 ; CHECK-NEXT:        .long   16777224                # 0x1000008
 ; CHECK-NEXT:        .long   69                      # BTF_KIND_VAR(id = 9)
 ; CHECK-NEXT:        .long   234881024               # 0xe000000
-; CHECK-NEXT:        .long   8
+; CHECK-NEXT:        .long   7
 ; CHECK-NEXT:        .long   0
 ; CHECK-NEXT:        .long   71                      # BTF_KIND_DATASEC(id = 10)
 ; CHECK-NEXT:        .long   251658242               # 0xf000002
index 7f11c765f350c5c2c5e900741c36be1e0427d0be..b3b3576fb6bf455b9f15b0384032923487a61066 100644 (file)
@@ -51,7 +51,7 @@ define dso_local i32 @foo() local_unnamed_addr #0 !dbg !2 {
 ; CHECK-NEXT:        .long   16777232                # 0x1000010
 ; CHECK-NEXT:        .long   58                      # BTF_KIND_VAR(id = 6)
 ; CHECK-NEXT:        .long   234881024               # 0xe000000
-; CHECK-NEXT:        .long   5
+; CHECK-NEXT:        .long   4
 ; CHECK-NEXT:        .long   0
 ; CHECK-NEXT:        .long   0                       # BTF_KIND_VOLATILE(id = 7)
 ; CHECK-NEXT:        .long   150994944               # 0x9000000
@@ -62,7 +62,7 @@ define dso_local i32 @foo() local_unnamed_addr #0 !dbg !2 {
 ; CHECK-NEXT:        .long   16777224                # 0x1000008
 ; CHECK-NEXT:        .long   69                      # BTF_KIND_VAR(id = 9)
 ; CHECK-NEXT:        .long   234881024               # 0xe000000
-; CHECK-NEXT:        .long   8
+; CHECK-NEXT:        .long   7
 ; CHECK-NEXT:        .long   0
 ; CHECK-NEXT:        .long   71                      # BTF_KIND_DATASEC(id = 10)
 ; CHECK-NEXT:        .long   251658242               # 0xf000002
index 49b1389e2e90b94bd68b7b498e48bfdd02550ba0..546f2bcbc0d1f59afe2cf885d1a841c7f448285d 100644 (file)
@@ -54,7 +54,7 @@ define dso_local i32 @foo() local_unnamed_addr #0 !dbg !2 {
 ; CHECK-NEXT:        .long   16777232                # 0x1000010
 ; CHECK-NEXT:        .long   58                      # BTF_KIND_VAR(id = 7)
 ; CHECK-NEXT:        .long   234881024               # 0xe000000
-; CHECK-NEXT:        .long   6
+; CHECK-NEXT:        .long   4
 ; CHECK-NEXT:        .long   0
 ; CHECK-NEXT:        .long   0                       # BTF_KIND_CONST(id = 8)
 ; CHECK-NEXT:        .long   167772160               # 0xa000000
@@ -68,7 +68,7 @@ define dso_local i32 @foo() local_unnamed_addr #0 !dbg !2 {
 ; CHECK-NEXT:        .long   16777224                # 0x1000008
 ; CHECK-NEXT:        .long   69                      # BTF_KIND_VAR(id = 11)
 ; CHECK-NEXT:        .long   234881024               # 0xe000000
-; CHECK-NEXT:        .long   10
+; CHECK-NEXT:        .long   8
 ; CHECK-NEXT:        .long   0
 ; CHECK-NEXT:        .long   71                      # BTF_KIND_DATASEC(id = 12)
 ; CHECK-NEXT:        .long   251658242               # 0xf000002
index 12bef91a05813cc8879412d7ebe2a8af44e14cae..e39e737865de333c01d193ed67cf7540dbdf89f6 100644 (file)
@@ -54,7 +54,7 @@ define dso_local i32 @foo() local_unnamed_addr #0 !dbg !2 {
 ; CHECK-NEXT:        .long   16777232                # 0x1000010
 ; CHECK-NEXT:        .long   58                      # BTF_KIND_VAR(id = 7)
 ; CHECK-NEXT:        .long   234881024               # 0xe000000
-; CHECK-NEXT:        .long   6
+; CHECK-NEXT:        .long   4
 ; CHECK-NEXT:        .long   0
 ; CHECK-NEXT:        .long   0                       # BTF_KIND_CONST(id = 8)
 ; CHECK-NEXT:        .long   167772160               # 0xa000000
@@ -68,7 +68,7 @@ define dso_local i32 @foo() local_unnamed_addr #0 !dbg !2 {
 ; CHECK-NEXT:        .long   16777224                # 0x1000008
 ; CHECK-NEXT:        .long   69                      # BTF_KIND_VAR(id = 11)
 ; CHECK-NEXT:        .long   234881024               # 0xe000000
-; CHECK-NEXT:        .long   10
+; CHECK-NEXT:        .long   8
 ; CHECK-NEXT:        .long   0
 ; CHECK-NEXT:        .long   71                      # BTF_KIND_DATASEC(id = 12)
 ; CHECK-NEXT:        .long   251658242               # 0xf000002
index 4f70512b0f67e71fff2623d3f6ed8f01d0ef8c6a..36ce07d8968cb67bae9ec4631d1d73d851a23b4c 100644 (file)
@@ -51,7 +51,7 @@ define dso_local i32 @foo() local_unnamed_addr #0 !dbg !2 {
 ; CHECK-NEXT:        .long   16777232                # 0x1000010
 ; CHECK-NEXT:        .long   58                      # BTF_KIND_VAR(id = 6)
 ; CHECK-NEXT:        .long   234881024               # 0xe000000
-; CHECK-NEXT:        .long   5
+; CHECK-NEXT:        .long   4
 ; CHECK-NEXT:        .long   0
 ; CHECK-NEXT:        .long   0                       # BTF_KIND_VOLATILE(id = 7)
 ; CHECK-NEXT:        .long   150994944               # 0x9000000
@@ -62,7 +62,7 @@ define dso_local i32 @foo() local_unnamed_addr #0 !dbg !2 {
 ; CHECK-NEXT:        .long   16777224                # 0x1000008
 ; CHECK-NEXT:        .long   69                      # BTF_KIND_VAR(id = 9)
 ; CHECK-NEXT:        .long   234881024               # 0xe000000
-; CHECK-NEXT:        .long   8
+; CHECK-NEXT:        .long   7
 ; CHECK-NEXT:        .long   0
 ; CHECK-NEXT:        .long   71                      # BTF_KIND_DATASEC(id = 10)
 ; CHECK-NEXT:        .long   251658242               # 0xf000002
index 7fb1488a9e4f1af0377b07870bf1a0a791198338..30eb657cbe92489800864977e2c3d2b4c7147535 100644 (file)
@@ -70,7 +70,7 @@ define dso_local i32 @test() local_unnamed_addr #0 !dbg !21 {
 ; CHECK-NEXT:        .long   16777224                # 0x1000008
 ; CHECK-NEXT:        .long   86                      # BTF_KIND_VAR(id = 9)
 ; CHECK-NEXT:        .long   234881024               # 0xe000000
-; CHECK-NEXT:        .long   5
+; CHECK-NEXT:        .long   4
 ; CHECK-NEXT:        .long   0
 ; CHECK-NEXT:        .long   89                      # BTF_KIND_DATASEC(id = 10)
 ; CHECK-NEXT:        .long   251658241               # 0xf000001
index bfd532fcc0e5155f984b72b8e559bd575245de9f..5d09b19b5206af4192ddb1f9264eff587ba139e9 100644 (file)
@@ -51,7 +51,7 @@ define dso_local i32 @foo() local_unnamed_addr #0 !dbg !2 {
 ; CHECK-NEXT:        .long   16777232                # 0x1000010
 ; CHECK-NEXT:        .long   58                      # BTF_KIND_VAR(id = 6)
 ; CHECK-NEXT:        .long   234881024               # 0xe000000
-; CHECK-NEXT:        .long   5
+; CHECK-NEXT:        .long   4
 ; CHECK-NEXT:        .long   0
 ; CHECK-NEXT:        .long   0                       # BTF_KIND_VOLATILE(id = 7)
 ; CHECK-NEXT:        .long   150994944               # 0x9000000
@@ -62,7 +62,7 @@ define dso_local i32 @foo() local_unnamed_addr #0 !dbg !2 {
 ; CHECK-NEXT:        .long   16777224                # 0x1000008
 ; CHECK-NEXT:        .long   69                      # BTF_KIND_VAR(id = 9)
 ; CHECK-NEXT:        .long   234881024               # 0xe000000
-; CHECK-NEXT:        .long   8
+; CHECK-NEXT:        .long   7
 ; CHECK-NEXT:        .long   0
 ; CHECK-NEXT:        .long   71                      # BTF_KIND_DATASEC(id = 10)
 ; CHECK-NEXT:        .long   251658242               # 0xf000002