]> granicus.if.org Git - llvm/commit
[BPF] use std::map to ensure consistent output
authorYonghong Song <yhs@fb.com>
Wed, 27 Mar 2019 15:45:27 +0000 (15:45 +0000)
committerYonghong Song <yhs@fb.com>
Wed, 27 Mar 2019 15:45:27 +0000 (15:45 +0000)
commit85ad8db97e9bd0bbff8b6dbaed8fae052bd7f3d4
tree62c358f40a4a4ed9a0544761373bea03c12f2f42
parent88220ed3cb24d326503414e2f7240961893c8915
[BPF] use std::map to ensure consistent output

The .BTF.ext FuncInfoTable and LineInfoTable contain
information organized per ELF section. Current definition
of FuncInfoTable/LineInfoTable is:
  std::unordered_map<uint32_t, std::vector<BTFFuncInfo>> FuncInfoTable
  std::unordered_map<uint32_t, std::vector<BTFLineInfo>> LineInfoTable
where the key is the section name off in the string table.
The unordered_map may cause the order of section output
different for different platforms.

The same for unordered map definition of
  std::unordered_map<std::string, std::unique_ptr<BTFKindDataSec>>
    DataSecEntries
where BTF_KIND_DATASEC entries may have different ordering
for different platforms.

This patch fixed the issue by using std::map.
Test static-var-derived-type.ll is modified to generate two
DataSec's which will ensure the ordering is the same for all
supported platforms.

Signed-off-by: Yonghong Song <yhs@fb.com>
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@357077 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/BPF/BTFDebug.h
test/CodeGen/BPF/BTF/static-var-derived-type.ll