BPF: rename BTF_KIND_TAG to BTF_KIND_DECL_TAG
authorYonghong Song <yhs@fb.com>
Tue, 12 Oct 2021 00:11:22 +0000 (17:11 -0700)
committerYonghong Song <yhs@fb.com>
Tue, 12 Oct 2021 04:33:39 +0000 (21:33 -0700)
Per discussion in https://reviews.llvm.org/D111199,
the existing btf_tag attribute will be renamed to
btf_decl_tag. This patch updated BTF backend to
use btf_decl_tag attribute name and also
renamed BTF_KIND_TAG to BTF_KIND_DECL_TAG.

Differential Revision: https://reviews.llvm.org/D111592

llvm/lib/Target/BPF/BTF.def
llvm/lib/Target/BPF/BTF.h
llvm/lib/Target/BPF/BTFDebug.cpp
llvm/lib/Target/BPF/BTFDebug.h
llvm/test/CodeGen/BPF/BTF/tag-1.ll
llvm/test/CodeGen/BPF/BTF/tag-2.ll

index 8a152cf..aeb81c6 100644 (file)
@@ -31,6 +31,6 @@ HANDLE_BTF_KIND(13, FUNC_PROTO)
 HANDLE_BTF_KIND(14, VAR)
 HANDLE_BTF_KIND(15, DATASEC)
 HANDLE_BTF_KIND(16, FLOAT)
-HANDLE_BTF_KIND(17, TAG)
+HANDLE_BTF_KIND(17, DECL_TAG)
 
 #undef HANDLE_BTF_KIND
index cf29547..59ba982 100644 (file)
@@ -106,14 +106,14 @@ struct CommonType {
   /// Bits 24-27: kind (e.g. int, ptr, array...etc)
   /// Bits 28-30: unused
   /// Bit     31: kind_flag, currently used by
-  ///             struct, union, fwd and tag
+  ///             struct, union, fwd and decl_tag
   uint32_t Info;
 
   /// "Size" is used by INT, ENUM, STRUCT and UNION.
   /// "Size" tells the size of the type it is describing.
   ///
   /// "Type" is used by PTR, TYPEDEF, VOLATILE, CONST, RESTRICT,
-  /// FUNC, FUNC_PROTO, VAR and TAG.
+  /// FUNC, FUNC_PROTO, VAR and DECL_TAG.
   /// "Type" is a type_id referring to another type.
   union {
     uint32_t Size;
index b3573a5..2333975 100644 (file)
@@ -386,15 +386,16 @@ void BTFTypeFloat::completeType(BTFDebug &BDebug) {
   BTFType.NameOff = BDebug.addString(Name);
 }
 
-BTFTypeTag::BTFTypeTag(uint32_t BaseTypeId, int ComponentIdx, StringRef Tag)
+BTFTypeDeclTag::BTFTypeDeclTag(uint32_t BaseTypeId, int ComponentIdx,
+                               StringRef Tag)
     : Tag(Tag) {
-  Kind = BTF::BTF_KIND_TAG;
+  Kind = BTF::BTF_KIND_DECL_TAG;
   BTFType.Info = Kind << 24;
   BTFType.Type = BaseTypeId;
   Info = ComponentIdx;
 }
 
-void BTFTypeTag::completeType(BTFDebug &BDebug) {
+void BTFTypeDeclTag::completeType(BTFDebug &BDebug) {
   if (IsCompleted)
     return;
   IsCompleted = true;
@@ -402,7 +403,7 @@ void BTFTypeTag::completeType(BTFDebug &BDebug) {
   BTFType.NameOff = BDebug.addString(Tag);
 }
 
-void BTFTypeTag::emitType(MCStreamer &OS) {
+void BTFTypeDeclTag::emitType(MCStreamer &OS) {
   BTFTypeBase::emitType(OS);
   OS.emitInt32(Info);
 }
@@ -504,12 +505,12 @@ void BTFDebug::processAnnotations(DINodeArray Annotations, uint32_t BaseTypeId,
   for (const Metadata *Annotation : Annotations->operands()) {
     const MDNode *MD = cast<MDNode>(Annotation);
     const MDString *Name = cast<MDString>(MD->getOperand(0));
-    if (!Name->getString().equals("btf_tag"))
+    if (!Name->getString().equals("btf_decl_tag"))
       continue;
 
     const MDString *Value = cast<MDString>(MD->getOperand(1));
-    auto TypeEntry = std::make_unique<BTFTypeTag>(BaseTypeId, ComponentIdx,
-                                                  Value->getString());
+    auto TypeEntry = std::make_unique<BTFTypeDeclTag>(BaseTypeId, ComponentIdx,
+                                                      Value->getString());
     addType(std::move(TypeEntry));
   }
 }
index c0e672c..30f9d9a 100644 (file)
@@ -205,12 +205,12 @@ public:
 };
 
 /// Handle tags.
-class BTFTypeTag : public BTFTypeBase {
+class BTFTypeDeclTag : public BTFTypeBase {
   uint32_t Info;
   StringRef Tag;
 
 public:
-  BTFTypeTag(uint32_t BaseTypeId, int ComponentId, StringRef Tag);
+  BTFTypeDeclTag(uint32_t BaseTypeId, int ComponentId, StringRef Tag);
   uint32_t getSize() override { return BTFTypeBase::getSize() + 4; }
   void completeType(BTFDebug &BDebug) override;
   void emitType(MCStreamer &OS) override;
index 2035589..c2d9eb9 100644 (file)
@@ -2,8 +2,8 @@
 ; RUN: llc -march=bpfeb -filetype=asm -o - %s | FileCheck -check-prefixes=CHECK %s
 
 ; Source code:
-;   #define __tag1 __attribute__((btf_tag("tag1")))
-;   #define __tag2 __attribute__((btf_tag("tag2")))
+;   #define __tag1 __attribute__((btf_decl_tag("tag1")))
+;   #define __tag2 __attribute__((btf_decl_tag("tag2")))
 ;   struct t1 {
 ;     int a1;
 ;     int a2 __tag1 __tag2;
@@ -32,8 +32,8 @@
 !9 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
 !10 = !DIDerivedType(tag: DW_TAG_member, name: "a2", scope: !6, file: !3, line: 5, baseType: !9, size: 32, offset: 32, annotations: !11)
 !11 = !{!12, !13}
-!12 = !{!"btf_tag", !"tag1"}
-!13 = !{!"btf_tag", !"tag2"}
+!12 = !{!"btf_decl_tag", !"tag1"}
+!13 = !{!"btf_decl_tag", !"tag2"}
 !14 = !{i32 7, !"Dwarf Version", i32 4}
 !15 = !{i32 2, !"Debug Info Version", i32 3}
 !16 = !{i32 1, !"wchar_size", i32 4}
 ; CHECK-NEXT:        .long   7
 ; CHECK-NEXT:        .long   4
 ; CHECK-NEXT:        .long   32                              # 0x20
-; CHECK-NEXT:        .long   10                              # BTF_KIND_TAG(id = 2)
+; CHECK-NEXT:        .long   10                              # BTF_KIND_DECL_TAG(id = 2)
 ; CHECK-NEXT:        .long   285212672                       # 0x11000000
 ; CHECK-NEXT:        .long   1
 ; CHECK-NEXT:        .long   4294967295
-; CHECK-NEXT:        .long   15                              # BTF_KIND_TAG(id = 3)
+; CHECK-NEXT:        .long   15                              # BTF_KIND_DECL_TAG(id = 3)
 ; CHECK-NEXT:        .long   285212672                       # 0x11000000
 ; CHECK-NEXT:        .long   1
 ; CHECK-NEXT:        .long   4294967295
 ; CHECK-NEXT:        .long   16777216                        # 0x1000000
 ; CHECK-NEXT:        .long   4
 ; CHECK-NEXT:        .long   16777248                        # 0x1000020
-; CHECK-NEXT:        .long   10                              # BTF_KIND_TAG(id = 5)
+; CHECK-NEXT:        .long   10                              # BTF_KIND_DECL_TAG(id = 5)
 ; CHECK-NEXT:        .long   285212672                       # 0x11000000
 ; CHECK-NEXT:        .long   1
 ; CHECK-NEXT:        .long   1
-; CHECK-NEXT:        .long   15                              # BTF_KIND_TAG(id = 6)
+; CHECK-NEXT:        .long   15                              # BTF_KIND_DECL_TAG(id = 6)
 ; CHECK-NEXT:        .long   285212672                       # 0x11000000
 ; CHECK-NEXT:        .long   1
 ; CHECK-NEXT:        .long   1
 ; CHECK-NEXT:        .long   234881024                       # 0xe000000
 ; CHECK-NEXT:        .long   1
 ; CHECK-NEXT:        .long   1
-; CHECK-NEXT:        .long   10                              # BTF_KIND_TAG(id = 8)
+; CHECK-NEXT:        .long   10                              # BTF_KIND_DECL_TAG(id = 8)
 ; CHECK-NEXT:        .long   285212672                       # 0x11000000
 ; CHECK-NEXT:        .long   7
 ; CHECK-NEXT:        .long   4294967295
-; CHECK-NEXT:        .long   15                              # BTF_KIND_TAG(id = 9)
+; CHECK-NEXT:        .long   15                              # BTF_KIND_DECL_TAG(id = 9)
 ; CHECK-NEXT:        .long   285212672                       # 0x11000000
 ; CHECK-NEXT:        .long   7
 ; CHECK-NEXT:        .long   4294967295
index 6a2e982..e1e6bf5 100644 (file)
@@ -2,8 +2,8 @@
 ; RUN: llc -march=bpfeb -filetype=asm -o - %s | FileCheck -check-prefixes=CHECK %s
 
 ; Source code:
-;   #define __tag1 __attribute__((btf_tag("tag1")))
-;   #define __tag2 __attribute__((btf_tag("tag2")))
+;   #define __tag1 __attribute__((btf_decl_tag("tag1")))
+;   #define __tag2 __attribute__((btf_decl_tag("tag2")))
 ;   extern int bar(int a1, int a2) __tag1 __tag2;
 ;   int __tag1 foo(int arg1, int *arg2 __tag1) {
 ; ;   return arg1 + *arg2 + bar(arg1, arg1 + 1);
@@ -55,7 +55,7 @@ attributes #3 = { nounwind }
 !14 = !DILocalVariable(name: "arg1", arg: 1, scope: !8, file: !1, line: 4, type: !11)
 !15 = !DILocalVariable(name: "arg2", arg: 2, scope: !8, file: !1, line: 4, type: !12, annotations: !16)
 !16 = !{!17}
-!17 = !{!"btf_tag", !"tag1"}
+!17 = !{!"btf_decl_tag", !"tag1"}
 !18 = !DILocation(line: 0, scope: !8)
 !19 = !DILocation(line: 5, column: 17, scope: !8)
 !20 = !{!21, !21, i64 0}
@@ -71,7 +71,7 @@ attributes #3 = { nounwind }
 !30 = !DISubroutineType(types: !31)
 !31 = !{!11, !11, !11}
 !32 = !{!17, !33}
-!33 = !{!"btf_tag", !"tag2"}
+!33 = !{!"btf_decl_tag", !"tag2"}
 
 ; CHECK:             .long   1                               # BTF_KIND_INT(id = 1)
 ; CHECK-NEXT:        .long   16777216                        # 0x1000000
@@ -90,11 +90,11 @@ attributes #3 = { nounwind }
 ; CHECK-NEXT:        .long   15                              # BTF_KIND_FUNC(id = 4)
 ; CHECK-NEXT:        .long   201326593                       # 0xc000001
 ; CHECK-NEXT:        .long   3
-; CHECK-NEXT:        .long   19                              # BTF_KIND_TAG(id = 5)
+; CHECK-NEXT:        .long   19                              # BTF_KIND_DECL_TAG(id = 5)
 ; CHECK-NEXT:        .long   285212672                       # 0x11000000
 ; CHECK-NEXT:        .long   4
 ; CHECK-NEXT:        .long   1
-; CHECK-NEXT:        .long   19                              # BTF_KIND_TAG(id = 6)
+; CHECK-NEXT:        .long   19                              # BTF_KIND_DECL_TAG(id = 6)
 ; CHECK-NEXT:        .long   285212672                       # 0x11000000
 ; CHECK-NEXT:        .long   4
 ; CHECK-NEXT:        .long   4294967295
@@ -108,11 +108,11 @@ attributes #3 = { nounwind }
 ; CHECK-NEXT:        .long   72                              # BTF_KIND_FUNC(id = 8)
 ; CHECK-NEXT:        .long   201326594                       # 0xc000002
 ; CHECK-NEXT:        .long   7
-; CHECK-NEXT:        .long   19                              # BTF_KIND_TAG(id = 9)
+; CHECK-NEXT:        .long   19                              # BTF_KIND_DECL_TAG(id = 9)
 ; CHECK-NEXT:        .long   285212672                       # 0x11000000
 ; CHECK-NEXT:        .long   8
 ; CHECK-NEXT:        .long   4294967295
-; CHECK-NEXT:        .long   76                              # BTF_KIND_TAG(id = 10)
+; CHECK-NEXT:        .long   76                              # BTF_KIND_DECL_TAG(id = 10)
 ; CHECK-NEXT:        .long   285212672                       # 0x11000000
 ; CHECK-NEXT:        .long   8
 ; CHECK-NEXT:        .long   4294967295