[PATCH] D59943: [BPF] add proper multi-dimensional array support
Yonghong Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 28 09:01:55 PDT 2019
yonghong-song created this revision.
yonghong-song added a reviewer: ast.
Herald added subscribers: llvm-commits, jdoerfert.
Herald added a project: LLVM.
For multi-dimensional array like below
int a[2][3];
the previous implementation generates BTF_KIND_ARRAY type
like below:
. element_type: int
. index_type: unsigned int
. number of elements: 6
This is not the best way to represent arrays, esp.,
when converting BTF back to headers and users will see
int a[6];
instead.
This patch generates proper support for multi-dimensional arrays.
For "int a[2][3]", the two BTF_KIND_ARRAY types will be
generated:
Type #n:
. element_type: int
. index_type: unsigned int
. number of elements: 3
Type #(n+1):
. element_type: #n
. index_type: unsigned int
. number of elements: 2
The linux kernel already supports such a multi-dimensional
array representation properly.
Repository:
rL LLVM
https://reviews.llvm.org/D59943
Files:
lib/Target/BPF/BTFDebug.cpp
lib/Target/BPF/BTFDebug.h
test/CodeGen/BPF/BTF/array-1d-char.ll
test/CodeGen/BPF/BTF/array-1d-int.ll
test/CodeGen/BPF/BTF/array-2d-int.ll
test/CodeGen/BPF/BTF/array-size-0.ll
test/CodeGen/BPF/BTF/array-typedef.ll
test/CodeGen/BPF/BTF/static-var-zerolen-array.ll
test/CodeGen/BPF/BTF/union-array-typedef.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59943.192649.patch
Type: text/x-patch
Size: 20706 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190328/8a1143df/attachment.bin>
More information about the llvm-commits
mailing list