LLVM 22.0.0git
HipStdPar.cpp File Reference
#include "llvm/Transforms/HipStdPar/HipStdPar.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Analysis/CallGraph.h"
#include "llvm/Analysis/OptimizationRemarkEmitter.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/Module.h"
#include "llvm/Transforms/Utils/ModuleUtils.h"
#include <cassert>
#include <string>
#include <utility>

Go to the source code of this file.

Functions

template<typename T>
static void eraseFromModule (T &ToErase)
static bool checkIfSupported (GlobalVariable &G)
static void clearModule (Module &M)
static SmallVector< std::reference_wrapper< Use > > collectIndirectableUses (GlobalVariable *G)
static GlobalVariablegetGlobalForName (GlobalVariable *G)
static GlobalVariablegetIndirectionGlobal (Module *M)
static ConstantappendIndirectedGlobal (const GlobalVariable *IndirectionTable, SmallVector< Constant * > &SymbolIndirections, GlobalVariable *ToIndirect)
static void fillIndirectionTable (GlobalVariable *IndirectionTable, SmallVector< Constant * > Indirections)
static void replaceWithIndirectUse (const Use &U, const GlobalVariable *G, Constant *IndirectedG)
static bool isValidIndirectionTable (GlobalVariable *IndirectionTable)
static void indirectGlobals (GlobalVariable *IndirectionTable, SmallVector< GlobalVariable * > ToIndirect)
static void maybeHandleGlobals (Module &M)
template<unsigned N>
static void removeUnreachableFunctions (const SmallPtrSet< const Function *, N > &Reachable, Module &M)
static bool isAcceleratorExecutionRoot (const Function *F)
static bool checkIfSupported (const Function *F, const CallBase *CB)

Variables

static constexpr std::pair< StringLiteral, StringLiteralReplaceMap []
static constexpr std::pair< StringLiteral, StringLiteralHiddenMap []
static constexpr std::pair< StringLiteral, StringLiteralMathLibToHipStdPar []

Function Documentation

◆ appendIndirectedGlobal()

◆ checkIfSupported() [1/2]

◆ checkIfSupported() [2/2]

◆ clearModule()

void clearModule ( Module & M)
inlinestatic

◆ collectIndirectableUses()

SmallVector< std::reference_wrapper< Use > > collectIndirectableUses ( GlobalVariable * G)
static

Definition at line 130 of file HipStdPar.cpp.

References G, llvm::isa(), llvm::transform(), and Uses.

Referenced by indirectGlobals().

◆ eraseFromModule()

template<typename T>
void eraseFromModule ( T & ToErase)
inlinestatic

◆ fillIndirectionTable()

◆ getGlobalForName()

GlobalVariable * getGlobalForName ( GlobalVariable * G)
inlinestatic

◆ getIndirectionGlobal()

◆ indirectGlobals()

◆ isAcceleratorExecutionRoot()

bool isAcceleratorExecutionRoot ( const Function * F)
inlinestatic

Definition at line 365 of file HipStdPar.cpp.

References llvm::CallingConv::AMDGPU_KERNEL, and F.

Referenced by llvm::HipStdParAcceleratorCodeSelectionPass::run().

◆ isValidIndirectionTable()

bool isValidIndirectionTable ( GlobalVariable * IndirectionTable)
inlinestatic

◆ maybeHandleGlobals()

◆ removeUnreachableFunctions()

template<unsigned N>
void removeUnreachableFunctions ( const SmallPtrSet< const Function *, N > & Reachable,
Module & M )
inlinestatic

◆ replaceWithIndirectUse()

void replaceWithIndirectUse ( const Use & U,
const GlobalVariable * G,
Constant * IndirectedG )
static

Definition at line 223 of file HipStdPar.cpp.

References assert(), llvm::cast(), llvm::dyn_cast(), G, I, and OpIdx.

Referenced by indirectGlobals().

Variable Documentation

◆ HiddenMap

std::pair<StringLiteral, StringLiteral> HiddenMap[]
staticconstexpr
Initial value:
{
{"__hipstdpar_hidden_malloc", "__libc_malloc"},
{"__hipstdpar_hidden_free", "__libc_free"},
{"__hipstdpar_hidden_memalign", "__libc_memalign"},
{"__hipstdpar_hidden_mmap", "mmap"},
{"__hipstdpar_hidden_munmap", "munmap"}}

Definition at line 484 of file HipStdPar.cpp.

Referenced by llvm::HipStdParAllocationInterpositionPass::run().

◆ MathLibToHipStdPar

std::pair<StringLiteral, StringLiteral> MathLibToHipStdPar[]
staticconstexpr

Definition at line 534 of file HipStdPar.cpp.

Referenced by llvm::HipStdParMathFixupPass::run().

◆ ReplaceMap

std::pair<StringLiteral, StringLiteral> ReplaceMap[]
staticconstexpr

Definition at line 442 of file HipStdPar.cpp.

Referenced by llvm::HipStdParAllocationInterpositionPass::run().