Enzyme main
Loading...
Searching...
No Matches
LibraryFuncs.h File Reference
#include <llvm/ADT/StringMap.h>
#include <llvm/Analysis/AliasAnalysis.h>
#include <llvm/Analysis/TargetLibraryInfo.h>
#include <llvm/IR/IRBuilder.h>
#include <llvm/IR/InlineAsm.h>
#include <llvm/IR/Instructions.h>
#include "Utils.h"
Include dependency graph for LibraryFuncs.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

static bool isAllocationFunction (const llvm::StringRef name, const llvm::TargetLibraryInfo &TLI)
 Return whether a given function is a known C/C++ memory allocation function For updating below one should read MemoryBuiltins.cpp, TargetLibraryInfo.cpp.
 
static bool isDeallocationFunction (const llvm::StringRef name, const llvm::TargetLibraryInfo &TLI)
 Return whether a given function is a known C/C++ memory deallocation function For updating below one should read MemoryBuiltins.cpp, TargetLibraryInfo.cpp.
 
static void zeroKnownAllocation (llvm::IRBuilder<> &bb, llvm::Value *toZero, llvm::ArrayRef< llvm::Value * > argValues, const llvm::StringRef funcName, const llvm::TargetLibraryInfo &TLI, llvm::CallInst *orig)
 
llvm::CallInst * freeKnownAllocation (llvm::IRBuilder<> &builder, llvm::Value *tofree, llvm::StringRef allocationfn, const llvm::DebugLoc &debuglocation, const llvm::TargetLibraryInfo &TLI, llvm::CallInst *orig, GradientUtils *gutils)
 Perform the corresponding deallocation of tofree, given it was allocated by allocationfn.
 
static bool isAllocationCall (const llvm::Value *TmpOrig, llvm::TargetLibraryInfo &TLI)
 
static bool isDeallocationCall (const llvm::Value *TmpOrig, llvm::TargetLibraryInfo &TLI)
 

Variables

llvm::StringMap< std::function< llvm::Value *(llvm::IRBuilder<> &, llvm::CallInst *, llvm::ArrayRef< llvm::Value * >, GradientUtils *)> > shadowHandlers
 
llvm::StringMap< std::function< llvm::CallInst *(llvm::IRBuilder<> &, llvm::Value *)> > shadowErasers
 

Function Documentation

◆ freeKnownAllocation()

llvm::CallInst * freeKnownAllocation ( llvm::IRBuilder<> & builder,
llvm::Value * tofree,
llvm::StringRef allocationfn,
const llvm::DebugLoc & debuglocation,
const llvm::TargetLibraryInfo & TLI,
llvm::CallInst * orig,
GradientUtils * gutils )

Perform the corresponding deallocation of tofree, given it was allocated by allocationfn.

Definition at line 9697 of file GradientUtils.cpp.

Referenced by AdjointGenerator::handleKnownCallDerivatives().

◆ isAllocationCall()

◆ isAllocationFunction()

static bool isAllocationFunction ( const llvm::StringRef name,
const llvm::TargetLibraryInfo & TLI )
inlinestatic

Return whether a given function is a known C/C++ memory allocation function For updating below one should read MemoryBuiltins.cpp, TargetLibraryInfo.cpp.

Definition at line 46 of file LibraryFuncs.h.

References shadowHandlers, and CacheUtility::TLI.

Referenced by AdjointGenerator::handleKnownCallDerivatives(), isAllocationCall(), TypeAnalyzer::visitCallBase(), writesToMemoryReadBy(), and zeroKnownAllocation().

◆ isDeallocationCall()

static bool isDeallocationCall ( const llvm::Value * TmpOrig,
llvm::TargetLibraryInfo & TLI )
inlinestatic

◆ isDeallocationFunction()

static bool isDeallocationFunction ( const llvm::StringRef name,
const llvm::TargetLibraryInfo & TLI )
inlinestatic

Return whether a given function is a known C/C++ memory deallocation function For updating below one should read MemoryBuiltins.cpp, TargetLibraryInfo.cpp.

Definition at line 123 of file LibraryFuncs.h.

References CacheUtility::TLI.

Referenced by isDeallocationCall(), TypeAnalyzer::visitCallBase(), and writesToMemoryReadBy().

◆ zeroKnownAllocation()

static void zeroKnownAllocation ( llvm::IRBuilder<> & bb,
llvm::Value * toZero,
llvm::ArrayRef< llvm::Value * > argValues,
const llvm::StringRef funcName,
const llvm::TargetLibraryInfo & TLI,
llvm::CallInst * orig )
inlinestatic

Variable Documentation

◆ shadowErasers

llvm::StringMap< std::function<llvm::CallInst *(llvm::IRBuilder<> &, llvm::Value *)> > shadowErasers
extern

Definition at line 71 of file GradientUtils.cpp.

Referenced by EnzymeRegisterAllocationHandler().

◆ shadowHandlers

llvm::StringMap<std::function<llvm::Value *( llvm::IRBuilder<> &, llvm::CallInst *, llvm::ArrayRef<llvm::Value *>, GradientUtils *)> > shadowHandlers
extern

Definition at line 70 of file GradientUtils.cpp.

Referenced by isAllocationFunction().