[all-commits] [llvm/llvm-project] edd71d: BPF: avoid duplicated globals for CORE relocations

yonghong-song via All-commits all-commits at lists.llvm.org
Tue Oct 6 22:42:21 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: edd71db38b0c2292e6a36fb789a3ec3cbde6a023
      https://github.com/llvm/llvm-project/commit/edd71db38b0c2292e6a36fb789a3ec3cbde6a023
  Author: Yonghong Song <yhs at fb.com>
  Date:   2020-10-06 (Tue, 06 Oct 2020)

  Changed paths:
    M llvm/lib/Target/BPF/BPFAbstractMemberAccess.cpp
    M llvm/lib/Target/BPF/BPFPreserveDIType.cpp
    A llvm/test/CodeGen/BPF/CORE/btf-id-duplicate.ll
    A llvm/test/CodeGen/BPF/CORE/field-reloc-duplicate.ll

  Log Message:
  -----------
  BPF: avoid duplicated globals for CORE relocations

This patch fixed two issues related with relocation globals.
In LLVM, if a global, e.g. with name "g", is created and
conflict with another global with the same name, LLVM will
rename the global, e.g., with a new name "g.2". Since
relocation global name has special meaning, we do not want
llvm to change it, so internally we have logic to check
whether duplication happens or not. If happens, just reuse
the previous global.

The first bug is related to non-btf-id relocation
(BPFAbstractMemberAccess.cpp). Commit 54d9f743c8b0
("BPF: move AbstractMemberAccess and PreserveDIType passes
to EP_EarlyAsPossible") changed ModulePass to FunctionPass,
i.e., handling each function at a time. But still just
one BPFAbstractMemberAccess object is created so module
level de-duplication still possible. Commit 40251fee0084
("[BPF][NewPM] Make BPFTargetMachine properly adjust NPM optimizer
pipeline") made a change to create a BPFAbstractMemberAccess
object per function so module level de-duplication is not
possible any more without going through all module globals.
This patch simply changed the map which holds reloc globals
as class static, so it will be available to all
BPFAbstractMemberAccess objects for different functions.

The second bug is related to btf-id relocation
(BPFPreserveDIType.cpp). Before Commit 54d9f743c8b0, the pass
is a ModulePass, so we have a local variable, incremented for
each instance, and works fine. But after Commit 54d9f743c8b0,
the pass becomes a FunctionPass. Local variable won't work
properly since different functions will start with the same
initial value. Fix the issue by change the local count variable
as static, so it will be truely unique across the whole module
compilation.

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




More information about the All-commits mailing list