[all-commits] [llvm/llvm-project] c43053: [BPF] fix a bug in __builtin_preserve_field_info()...

yonghong-song via All-commits all-commits at lists.llvm.org
Sun Nov 3 08:23:30 PST 2019


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: c4305337716f0f3eb76400f288cd0dee001d744d
      https://github.com/llvm/llvm-project/commit/c4305337716f0f3eb76400f288cd0dee001d744d
  Author: Yonghong Song <yhs at fb.com>
  Date:   2019-11-03 (Sun, 03 Nov 2019)

  Changed paths:
    M llvm/lib/Target/BPF/BPFAbstractMemberAccess.cpp
    A llvm/test/CodeGen/BPF/CORE/intrinsic-fieldinfo-byte-size-4.ll

  Log Message:
  -----------
  [BPF] fix a bug in __builtin_preserve_field_info() with FIELD_BYTE_SIZE

During deriving proper bitfield access FIELD_BYTE_SIZE,
function Member->getStorageOffsetInBits() is used to
get llvm IR type storage offset in bits so that
the byte size can permit aligned loads/stores with previously
derived FIELD_BYTE_OFFSET.

The function should only be used with bitfield members and it will
assert if ASSERT is turned on during cmake build.
  Constant *getStorageOffsetInBits() const {
    assert(getTag() == dwarf::DW_TAG_member && isBitField());
    if (auto *C = cast_or_null<ConstantAsMetadata>(getExtraData()))
      return C->getValue();
    return nullptr;
  }

This patch fixed the issue by using Member->isBitField()
directly and a test case is added to cover this missing case.
This issue is discovered when running Andrii's linux kernel CO-RE
tests.

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




More information about the All-commits mailing list