LLVM 24.0.0git
BPFFuncTable.cpp File Reference

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "bpf-func-table"

Functions

static bool isInText (const Function &F)
 The address of a function in another section is the address of a program, e.g.
static bool isCallbackUse (const Use &U, SmallPtrSetImpl< const User * > &Seen)
 A callback: bpf_loop(), bpf_timer_set_callback() and co.
static bool isAddressUse (const Use &U)
 The use is the address of the function as a value.
static void replaceAddress (Function &F, Constant *Index)
static bool runFuncTable (Module &M)
 INITIALIZE_PASS (BPFFuncTableLegacy, DEBUG_TYPE, "BPF Function Table", false, false) ModulePass *llvm

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "bpf-func-table"

Definition at line 51 of file BPFFuncTable.cpp.

Function Documentation

◆ INITIALIZE_PASS()

INITIALIZE_PASS ( BPFFuncTableLegacy ,
DEBUG_TYPE ,
"BPF Function Table" ,
false ,
false  )

Definition at line 219 of file BPFFuncTable.cpp.

References llvm::createBPFFuncTablePass(), and DEBUG_TYPE.

◆ isAddressUse()

bool isAddressUse ( const Use & U)
static

The use is the address of the function as a value.

Definition at line 90 of file BPFFuncTable.cpp.

References llvm::dyn_cast(), llvm::isa(), and isCallbackUse().

Referenced by canFoldIVIncExpr(), replaceAddress(), and runFuncTable().

◆ isCallbackUse()

bool isCallbackUse ( const Use & U,
SmallPtrSetImpl< const User * > & Seen )
static

A callback: bpf_loop(), bpf_timer_set_callback() and co.

The kernel calls it and wants the function. A helper is a number, a kfunc a declaration.

Definition at line 71 of file BPFFuncTable.cpp.

References llvm::all_of(), llvm::dyn_cast(), F, llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::isa(), and llvm::Value::uses().

Referenced by isAddressUse().

◆ isInText()

bool isInText ( const Function & F)
static

The address of a function in another section is the address of a program, e.g.

in struct_ops.

Definition at line 65 of file BPFFuncTable.cpp.

References F.

Referenced by runFuncTable().

◆ replaceAddress()

void replaceAddress ( Function & F,
Constant * Index )
static

Definition at line 102 of file BPFFuncTable.cpp.

References C(), llvm::dyn_cast(), F, llvm::isa(), isAddressUse(), and llvm::make_early_inc_range().

Referenced by runFuncTable().

◆ runFuncTable()