[all-commits] [llvm/llvm-project] ae0d22: [BPF] Fix linking issues in static map initializer...

Nick Zavaritsky via All-commits all-commits at lists.llvm.org
Fri Jul 5 07:32:30 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: ae0d2244a23567c8d9863e63b338d34c31416a7b
      https://github.com/llvm/llvm-project/commit/ae0d2244a23567c8d9863e63b338d34c31416a7b
  Author: Nick Zavaritsky <mejedi at gmail.com>
  Date:   2024-07-05 (Fri, 05 Jul 2024)

  Changed paths:
    M clang/include/clang/AST/ASTConsumer.h
    M clang/include/clang/Frontend/MultiplexConsumer.h
    M clang/include/clang/Sema/Sema.h
    M clang/lib/CodeGen/BackendConsumer.h
    M clang/lib/CodeGen/CGExpr.cpp
    M clang/lib/CodeGen/CodeGenAction.cpp
    M clang/lib/CodeGen/CodeGenModule.cpp
    M clang/lib/CodeGen/CodeGenModule.h
    M clang/lib/CodeGen/ModuleBuilder.cpp
    M clang/lib/Frontend/MultiplexConsumer.cpp
    M clang/lib/Interpreter/IncrementalParser.cpp
    M clang/lib/Sema/SemaDecl.cpp
    A clang/test/CodeGen/bpf-debug-info-extern-func.c
    A clang/test/CodeGen/bpf-debug-info-unref.c
    M llvm/lib/Target/BPF/BTFDebug.cpp
    M llvm/lib/Target/BPF/BTFDebug.h
    A llvm/test/CodeGen/BPF/BTF/extern-var-func2.ll

  Log Message:
  -----------
  [BPF] Fix linking issues in static map initializers (#91310)

When BPF object files are linked with bpftool, every symbol must be
accompanied by BTF info. Ensure that extern functions referenced by
global variable initializers are included in BTF.

The primary motivation is "static" initialization of PROG maps:

```c
extern int elsewhere(struct xdp_md *);

struct {
  __uint(type, BPF_MAP_TYPE_PROG_ARRAY);
  __uint(max_entries, 1);
  __type(key, int);
  __type(value, int);
  __array(values, int (struct xdp_md *));
} prog_map SEC(".maps") = { .values = { elsewhere } };
```

BPF backend needs debug info to produce BTF. Debug info is not
normally generated for external variables and functions. Previously, it
was solved differently for variables (collecting variable declarations
    in ExternalDeclarations vector) and functions (logic invoked during
    codegen in CGExpr.cpp).

This patch generalises ExternalDefclarations to include both function
and variable declarations. This change ensures that function references
    are not missed no matter the context. Previously external functions
    referenced in constant expressions lacked debug info.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list