]> granicus.if.org Git - llvm/commit
[BPF] Generate array dimension size properly for zero-size elements
authorYonghong Song <yhs@fb.com>
Tue, 24 Sep 2019 22:38:43 +0000 (22:38 +0000)
committerYonghong Song <yhs@fb.com>
Tue, 24 Sep 2019 22:38:43 +0000 (22:38 +0000)
commit2bc1224a89cb7958c48a8f012529e7771f706d67
treebee8a1790d9d6843a9e10691c5b407266c2b1fab
parent4ead4395854bbbec249d53e8fe6e279128b34a61
[BPF] Generate array dimension size properly for zero-size elements

Currently, if an array element type size is 0, the number of
array elements will be set to 0, regardless of what user
specified. This implementation is done in the beginning where
BTF is mostly used to calculate the member offset.

For example,
  struct s {};
  struct s1 {
        int b;
        struct s a[2];
  };
  struct s1 s1;
The BTF will have struct "s1" member "a" with element count 0.

Now BTF types are used for compile-once and run-everywhere
relocations and we need more precise type representation
for type comparison. Andrii reported the issue as there
are differences between original structure and BTF-generated
structure.

This patch made the change to correctly assign "2"
as the number elements of member "a".
Some dead codes related to ElemSize compuation are also removed.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@372785 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/BPF/BTFDebug.cpp
test/CodeGen/BPF/BTF/array-size-0.ll