[llvm] e52617c - BPF: change BTF_KIND_TAG format
Yonghong Song via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 9 19:05:44 PDT 2021
Author: Yonghong Song
Date: 2021-09-09T19:03:57-07:00
New Revision: e52617c31de1171c208b7ba0bb96520b78d130b3
URL: https://github.com/llvm/llvm-project/commit/e52617c31de1171c208b7ba0bb96520b78d130b3
DIFF: https://github.com/llvm/llvm-project/commit/e52617c31de1171c208b7ba0bb96520b78d130b3.diff
LOG: BPF: change BTF_KIND_TAG format
Previously we have the following binary representation:
struct bpf_type { name, info, type }
struct btf_tag { __u32 component_idx; }
If the tag points to a struct/union/var/func type, we will have
kflag = 1, component_idx = 0
if the tag points to struct/union member or func argument, we will have
kflag = 0, component_idx = 0, ..., vlen - 1
The above rather makes interface complex to have both kflag and
component needed to determine its legality and index.
This patch simplifies the interface by removing kflag involvement.
component_idx = (u32)-1 : tag pointing to a type
component_idx = 0 ... vlen - 1 : tag pointing to a member or argument
and kflag is always 0 and there is no need to check.
Differential Revision: https://reviews.llvm.org/D109560
Added:
Modified:
llvm/lib/Target/BPF/BTFDebug.cpp
llvm/test/CodeGen/BPF/BTF/tag-1.ll
llvm/test/CodeGen/BPF/BTF/tag-2.ll
Removed:
################################################################################
diff --git a/llvm/lib/Target/BPF/BTFDebug.cpp b/llvm/lib/Target/BPF/BTFDebug.cpp
index c13e2dcf8c6fe..b3573a518634d 100644
--- a/llvm/lib/Target/BPF/BTFDebug.cpp
+++ b/llvm/lib/Target/BPF/BTFDebug.cpp
@@ -386,12 +386,12 @@ void BTFTypeFloat::completeType(BTFDebug &BDebug) {
BTFType.NameOff = BDebug.addString(Name);
}
-BTFTypeTag::BTFTypeTag(uint32_t BaseTypeId, int ComponentId, StringRef Tag)
+BTFTypeTag::BTFTypeTag(uint32_t BaseTypeId, int ComponentIdx, StringRef Tag)
: Tag(Tag) {
Kind = BTF::BTF_KIND_TAG;
- BTFType.Info = ((ComponentId < 0) << 31) | (Kind << 24);
+ BTFType.Info = Kind << 24;
BTFType.Type = BaseTypeId;
- Info = ComponentId < 0 ? 0 : ComponentId;
+ Info = ComponentIdx;
}
void BTFTypeTag::completeType(BTFDebug &BDebug) {
@@ -497,7 +497,7 @@ void BTFDebug::visitSubroutineType(
}
void BTFDebug::processAnnotations(DINodeArray Annotations, uint32_t BaseTypeId,
- int ComponentId) {
+ int ComponentIdx) {
if (!Annotations)
return;
@@ -508,7 +508,7 @@ void BTFDebug::processAnnotations(DINodeArray Annotations, uint32_t BaseTypeId,
continue;
const MDString *Value = cast<MDString>(MD->getOperand(1));
- auto TypeEntry = std::make_unique<BTFTypeTag>(BaseTypeId, ComponentId,
+ auto TypeEntry = std::make_unique<BTFTypeTag>(BaseTypeId, ComponentIdx,
Value->getString());
addType(std::move(TypeEntry));
}
diff --git a/llvm/test/CodeGen/BPF/BTF/tag-1.ll b/llvm/test/CodeGen/BPF/BTF/tag-1.ll
index dd31ecf0c98cf..2035589b109ad 100644
--- a/llvm/test/CodeGen/BPF/BTF/tag-1.ll
+++ b/llvm/test/CodeGen/BPF/BTF/tag-1.ll
@@ -50,13 +50,13 @@
; CHECK-NEXT: .long 4
; CHECK-NEXT: .long 32 # 0x20
; CHECK-NEXT: .long 10 # BTF_KIND_TAG(id = 2)
-; CHECK-NEXT: .long 2432696320 # 0x91000000
+; CHECK-NEXT: .long 285212672 # 0x11000000
; CHECK-NEXT: .long 1
-; CHECK-NEXT: .long 0
+; CHECK-NEXT: .long 4294967295
; CHECK-NEXT: .long 15 # BTF_KIND_TAG(id = 3)
-; CHECK-NEXT: .long 2432696320 # 0x91000000
+; CHECK-NEXT: .long 285212672 # 0x11000000
; CHECK-NEXT: .long 1
-; CHECK-NEXT: .long 0
+; CHECK-NEXT: .long 4294967295
; CHECK-NEXT: .long 20 # BTF_KIND_INT(id = 4)
; CHECK-NEXT: .long 16777216 # 0x1000000
; CHECK-NEXT: .long 4
@@ -74,13 +74,13 @@
; CHECK-NEXT: .long 1
; CHECK-NEXT: .long 1
; CHECK-NEXT: .long 10 # BTF_KIND_TAG(id = 8)
-; CHECK-NEXT: .long 2432696320 # 0x91000000
+; CHECK-NEXT: .long 285212672 # 0x11000000
; CHECK-NEXT: .long 7
-; CHECK-NEXT: .long 0
+; CHECK-NEXT: .long 4294967295
; CHECK-NEXT: .long 15 # BTF_KIND_TAG(id = 9)
-; CHECK-NEXT: .long 2432696320 # 0x91000000
+; CHECK-NEXT: .long 285212672 # 0x11000000
; CHECK-NEXT: .long 7
-; CHECK-NEXT: .long 0
+; CHECK-NEXT: .long 4294967295
; CHECK: .ascii "t1" # string offset=1
; CHECK: .ascii "a1" # string offset=4
diff --git a/llvm/test/CodeGen/BPF/BTF/tag-2.ll b/llvm/test/CodeGen/BPF/BTF/tag-2.ll
index 9be1db672aaff..6a2e9829f6aab 100644
--- a/llvm/test/CodeGen/BPF/BTF/tag-2.ll
+++ b/llvm/test/CodeGen/BPF/BTF/tag-2.ll
@@ -95,9 +95,9 @@ attributes #3 = { nounwind }
; CHECK-NEXT: .long 4
; CHECK-NEXT: .long 1
; CHECK-NEXT: .long 19 # BTF_KIND_TAG(id = 6)
-; CHECK-NEXT: .long 2432696320 # 0x91000000
+; CHECK-NEXT: .long 285212672 # 0x11000000
; CHECK-NEXT: .long 4
-; CHECK-NEXT: .long 0
+; CHECK-NEXT: .long 4294967295
; CHECK-NEXT: .long 0 # BTF_KIND_FUNC_PROTO(id = 7)
; CHECK-NEXT: .long 218103810 # 0xd000002
; CHECK-NEXT: .long 1
@@ -109,12 +109,13 @@ attributes #3 = { nounwind }
; CHECK-NEXT: .long 201326594 # 0xc000002
; CHECK-NEXT: .long 7
; CHECK-NEXT: .long 19 # BTF_KIND_TAG(id = 9)
-; CHECK-NEXT: .long 2432696320 # 0x91000000
+; CHECK-NEXT: .long 285212672 # 0x11000000
; CHECK-NEXT: .long 8
-; CHECK-NEXT: .long 0
+; CHECK-NEXT: .long 4294967295
; CHECK-NEXT: .long 76 # BTF_KIND_TAG(id = 10)
-; CHECK-NEXT: .long 2432696320 # 0x91000000
+; CHECK-NEXT: .long 285212672 # 0x11000000
; CHECK-NEXT: .long 8
+; CHECK-NEXT: .long 4294967295
; CHECK: .ascii "int" # string offset=1
; CHECK: .ascii "arg1" # string offset=5
More information about the llvm-commits
mailing list