[llvm] 1321e47 - BPF: rename BTF_KIND_TAG to BTF_KIND_DECL_TAG

Yonghong Song via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 11 21:34:12 PDT 2021


Author: Yonghong Song
Date: 2021-10-11T21:33:39-07:00
New Revision: 1321e47298c722de9d2afe0e28d7122fa20e61bf

URL: https://github.com/llvm/llvm-project/commit/1321e47298c722de9d2afe0e28d7122fa20e61bf
DIFF: https://github.com/llvm/llvm-project/commit/1321e47298c722de9d2afe0e28d7122fa20e61bf.diff

LOG: BPF: rename BTF_KIND_TAG to BTF_KIND_DECL_TAG

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

Added: 
    

Modified: 
    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

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/BPF/BTF.def b/llvm/lib/Target/BPF/BTF.def
index 8a152cf8ea888..aeb81c6fecaf5 100644
--- a/llvm/lib/Target/BPF/BTF.def
+++ b/llvm/lib/Target/BPF/BTF.def
@@ -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

diff  --git a/llvm/lib/Target/BPF/BTF.h b/llvm/lib/Target/BPF/BTF.h
index cf29547b4249b..59ba982b36b24 100644
--- a/llvm/lib/Target/BPF/BTF.h
+++ b/llvm/lib/Target/BPF/BTF.h
@@ -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;

diff  --git a/llvm/lib/Target/BPF/BTFDebug.cpp b/llvm/lib/Target/BPF/BTFDebug.cpp
index b3573a518634d..233397533511f 100644
--- a/llvm/lib/Target/BPF/BTFDebug.cpp
+++ b/llvm/lib/Target/BPF/BTFDebug.cpp
@@ -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));
   }
 }

diff  --git a/llvm/lib/Target/BPF/BTFDebug.h b/llvm/lib/Target/BPF/BTFDebug.h
index c0e672c719894..30f9d9abaec99 100644
--- a/llvm/lib/Target/BPF/BTFDebug.h
+++ b/llvm/lib/Target/BPF/BTFDebug.h
@@ -205,12 +205,12 @@ class BTFTypeFloat : public BTFTypeBase {
 };
 
 /// 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;

diff  --git a/llvm/test/CodeGen/BPF/BTF/tag-1.ll b/llvm/test/CodeGen/BPF/BTF/tag-1.ll
index 2035589b109ad..c2d9eb967d0ba 100644
--- a/llvm/test/CodeGen/BPF/BTF/tag-1.ll
+++ b/llvm/test/CodeGen/BPF/BTF/tag-1.ll
@@ -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}
@@ -49,11 +49,11 @@
 ; 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
@@ -61,11 +61,11 @@
 ; 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
@@ -73,11 +73,11 @@
 ; 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

diff  --git a/llvm/test/CodeGen/BPF/BTF/tag-2.ll b/llvm/test/CodeGen/BPF/BTF/tag-2.ll
index 6a2e9829f6aab..e1e6bf5192de4 100644
--- a/llvm/test/CodeGen/BPF/BTF/tag-2.ll
+++ b/llvm/test/CodeGen/BPF/BTF/tag-2.ll
@@ -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


        


More information about the llvm-commits mailing list