#include "BPF.h"
#include "BPFCORE.h"
#include "BPFTargetMachine.h"
#include "llvm/BinaryFormat/Dwarf.h"
#include "llvm/DebugInfo/BTF/BTF.h"
#include "llvm/IR/DebugInfoMetadata.h"
#include "llvm/IR/GlobalVariable.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicsBPF.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/PassManager.h"
#include "llvm/IR/Type.h"
#include "llvm/IR/User.h"
#include "llvm/IR/Value.h"
#include "llvm/IR/ValueHandle.h"
#include "llvm/Pass.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include <stack>
#define DEBUG_TYPE …
namespace llvm {
constexpr StringRef BPFCoreSharedInfo::AmaAttr;
uint32_t BPFCoreSharedInfo::SeqNum;
Instruction *BPFCoreSharedInfo::insertPassThrough(Module *M, BasicBlock *BB,
Instruction *Input,
Instruction *Before) { … }
}
usingnamespacellvm;
namespace {
class BPFAbstractMemberAccess final { … };
std::map<std::string, GlobalVariable *> BPFAbstractMemberAccess::GEPGlobals;
}
bool BPFAbstractMemberAccess::run(Function &F) { … }
void BPFAbstractMemberAccess::ResetMetadata(struct CallInfo &CInfo) { … }
void BPFAbstractMemberAccess::CheckCompositeType(DIDerivedType *ParentTy,
DICompositeType *CTy) { … }
void BPFAbstractMemberAccess::CheckDerivedType(DIDerivedType *ParentTy,
DIDerivedType *DTy) { … }
void BPFAbstractMemberAccess::CheckAnonRecordType(DIDerivedType *ParentTy,
DIType *Ty) { … }
static bool SkipDIDerivedTag(unsigned Tag, bool skipTypedef) { … }
static DIType * stripQualifiers(DIType *Ty, bool skipTypedef = true) { … }
static const DIType * stripQualifiers(const DIType *Ty) { … }
static uint32_t calcArraySize(const DICompositeType *CTy, uint32_t StartDim) { … }
static Type *getBaseElementType(const CallInst *Call) { … }
static uint64_t getConstant(const Value *IndexValue) { … }
bool BPFAbstractMemberAccess::IsPreserveDIAccessIndexCall(const CallInst *Call,
CallInfo &CInfo) { … }
static void replaceWithGEP(CallInst *Call, uint32_t DimensionIndex,
uint32_t GEPIndex) { … }
void BPFCoreSharedInfo::removeArrayAccessCall(CallInst *Call) { … }
void BPFCoreSharedInfo::removeStructAccessCall(CallInst *Call) { … }
void BPFCoreSharedInfo::removeUnionAccessCall(CallInst *Call) { … }
bool BPFAbstractMemberAccess::removePreserveAccessIndexIntrinsic(Function &F) { … }
bool BPFAbstractMemberAccess::IsValidAIChain(const MDNode *ParentType,
uint32_t ParentAI,
const MDNode *ChildType) { … }
void BPFAbstractMemberAccess::traceAICall(CallInst *Call,
CallInfo &ParentInfo) { … }
void BPFAbstractMemberAccess::traceBitCast(BitCastInst *BitCast,
CallInst *Parent,
CallInfo &ParentInfo) { … }
void BPFAbstractMemberAccess::traceGEP(GetElementPtrInst *GEP, CallInst *Parent,
CallInfo &ParentInfo) { … }
void BPFAbstractMemberAccess::collectAICallChains(Function &F) { … }
void BPFAbstractMemberAccess::GetStorageBitRange(DIDerivedType *MemberTy,
Align RecordAlignment,
uint32_t &StartBitOffset,
uint32_t &EndBitOffset) { … }
uint32_t BPFAbstractMemberAccess::GetFieldInfo(uint32_t InfoKind,
DICompositeType *CTy,
uint32_t AccessIndex,
uint32_t PatchImm,
MaybeAlign RecordAlignment) { … }
bool BPFAbstractMemberAccess::HasPreserveFieldInfoCall(CallInfoStack &CallStack) { … }
Value *BPFAbstractMemberAccess::computeBaseAndAccessKey(CallInst *Call,
CallInfo &CInfo,
std::string &AccessKey,
MDNode *&TypeMeta) { … }
MDNode *BPFAbstractMemberAccess::computeAccessKey(CallInst *Call,
CallInfo &CInfo,
std::string &AccessKey,
bool &IsInt32Ret) { … }
bool BPFAbstractMemberAccess::transformGEPChain(CallInst *Call,
CallInfo &CInfo) { … }
bool BPFAbstractMemberAccess::doTransformation(Function &F) { … }
PreservedAnalyses
BPFAbstractMemberAccessPass::run(Function &F, FunctionAnalysisManager &AM) { … }