[all-commits] [llvm/llvm-project] ed0683: [BPF] Use SectionForGlobal() for section names com...

eddyz87 via All-commits all-commits at lists.llvm.org
Thu Dec 29 11:27:47 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: ed068386b451b90efac11d7ca991ceedf0474ebd
      https://github.com/llvm/llvm-project/commit/ed068386b451b90efac11d7ca991ceedf0474ebd
  Author: Eduard Zingerman <eddyz87 at gmail.com>
  Date:   2022-12-29 (Thu, 29 Dec 2022)

  Changed paths:
    M llvm/lib/Target/BPF/BTFDebug.cpp
    A llvm/test/CodeGen/BPF/BTF/global-var-bss-and-data.ll

  Log Message:
  -----------
  [BPF] Use SectionForGlobal() for section names computation in BTF

Use function TargetLoweringObjectFile::SectionForGlobal() to compute
section names for globals described in BTF_KIND_DATASEC records.

This fixes a discrepancy in section name computation between
BTFDebug::processGlobals and the rest of the LLVM pipeline.

Specifically, the following example illustrates the discrepancy
before this commit:

  struct Foo {
    int i;
  } __attribute__((aligned(16)));
  struct Foo foo = { 0 };

The initializer for 'foo' looks as follows:

  %struct.Foo { i32 0, [12 x i8] undef }

TargetLoweringObjectFile::SectionForGlobal() classifies 'foo' as
a part of '.bss' section, while BTFDebug::processGlobals
classified it as a part of '.data' section because of the
following expression:

  SecName = Global.getInitializer()->isZeroValue() ? ".bss" : ".data"

The isZeroValue() returns false because of the undef tail of the
initializer, while SectionForGlobal() allows such patterns in '.bss'.

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




More information about the All-commits mailing list