[PATCH] D65618: [BPF] Handling type conversions correctly for CO-RE

Yonghong Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 1 16:04:24 PDT 2019


yonghong-song created this revision.
yonghong-song added a reviewer: ast.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

With newly added debuginfo type
metadata for preserve_array_access_index() intrinsic,
this patch did the following two things:
 (1). checking validity before adding a new access index

  to the access chain.

(2). calculating access byte offset in IR phase

  BPFAbstractMemberAccess instead of when BTF is emitted.

For (1), the metadata provided by all preserve_*_access_index()
intrinsics are used to check whether the to-be-added type
is a proper struct/union member or array element.

For (2), with all available metadata, calculating access byte
offset becomes easier in BPFAbstractMemberAccess IR phase.
This enables us to remove the unnecessary complexity in
BTFDebug.cpp.

New tests are added for

  . user explicit casting to array/structure/union
  . global variable (or its dereference) as the source of base
  . multi demensional arrays
  . array access given a base pointer
  . cases where we won't generate relocation if we cannot find
    type name.


Repository:
  rL LLVM

https://reviews.llvm.org/D65618

Files:
  lib/Target/BPF/BPFAbstractMemberAccess.cpp
  lib/Target/BPF/BTFDebug.cpp
  lib/Target/BPF/BTFDebug.h
  test/CodeGen/BPF/CORE/offset-reloc-cast-array-1.ll
  test/CodeGen/BPF/CORE/offset-reloc-cast-array-2.ll
  test/CodeGen/BPF/CORE/offset-reloc-cast-struct-1.ll
  test/CodeGen/BPF/CORE/offset-reloc-cast-struct-2.ll
  test/CodeGen/BPF/CORE/offset-reloc-cast-struct-3.ll
  test/CodeGen/BPF/CORE/offset-reloc-cast-union-1.ll
  test/CodeGen/BPF/CORE/offset-reloc-cast-union-2.ll
  test/CodeGen/BPF/CORE/offset-reloc-global-1.ll
  test/CodeGen/BPF/CORE/offset-reloc-global-2.ll
  test/CodeGen/BPF/CORE/offset-reloc-global-3.ll
  test/CodeGen/BPF/CORE/offset-reloc-ignore.ll
  test/CodeGen/BPF/CORE/offset-reloc-multi-array-1.ll
  test/CodeGen/BPF/CORE/offset-reloc-multi-array-2.ll
  test/CodeGen/BPF/CORE/offset-reloc-pointer-1.ll
  test/CodeGen/BPF/CORE/offset-reloc-pointer-2.ll
  test/CodeGen/BPF/CORE/offset-reloc-struct-anonymous.ll
  test/CodeGen/BPF/CORE/offset-reloc-struct-array.ll
  test/CodeGen/BPF/CORE/offset-reloc-typedef-array.ll
  test/CodeGen/BPF/CORE/offset-reloc-typedef.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65618.212923.patch
Type: text/x-patch
Size: 125516 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190801/050cd86f/attachment-0001.bin>


More information about the llvm-commits mailing list