Go to the documentation of this file.
25 #define DEBUG_TYPE "amdgpu-lower-ctor-dtor"
28 class AMDGPUCtorDtorLowering final :
public ModulePass {
29 bool runOnModule(
Module &
M)
override;
33 StringRef InitOrFiniKernelName =
"amdgcn.device.init";
35 InitOrFiniKernelName =
"amdgcn.device.fini";
46 InitOrFiniKernel->
addFnAttr(
"device-init");
48 InitOrFiniKernel->
addFnAttr(
"device-fini");
49 return InitOrFiniKernel;
58 Function *InitOrFiniKernel = createInitOrFiniKernelFunction(
M, IsCtor);
61 auto *CS = cast<ConstantStruct>(V);
62 if (
Function *
F = dyn_cast<Function>(CS->getOperand(1))) {
64 M.getOrInsertFunction(
F->getName(), IRB.
getVoidTy());
80 "Lower ctors and dtors for AMDGPU",
false,
false)
83 return new AMDGPUCtorDtorLowering();
86 bool AMDGPUCtorDtorLowering::runOnModule(
Module &M) {
89 createInitOrFiniKernel(M,
M.getGlobalVariable(
"llvm.global_ctors"),
92 createInitOrFiniKernel(M,
M.getGlobalVariable(
"llvm.global_dtors"),
ModulePass * createAMDGPUCtorDtorLoweringPass()
This is an optimization pass for GlobalISel generic memory operations.
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
INITIALIZE_PASS(AMDGPUCtorDtorLowering, DEBUG_TYPE, "Lower ctors and dtors for AMDGPU", false, false) ModulePass *llvm
const BasicBlock & getEntryBlock() const
static FunctionType * get(Type *Result, ArrayRef< Type * > Params, bool isVarArg)
This static method is the primary way of constructing a FunctionType.
bool hasInitializer() const
Definitions have initializers, declarations don't.
LLVM Basic Block Representation.
ConstantArray - Constant Array Declarations.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
const Constant * getInitializer() const
getInitializer - Return the initializer for this global variable.
void appendToUsed(Module &M, ArrayRef< GlobalValue * > Values)
Adds global values to the llvm.used list.
char & AMDGPUCtorDtorLoweringID
A Module instance is used to store all the information related to an LLVM module.
static Function * createWithDefaultAttr(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace, const Twine &N="", Module *M=nullptr)
Creates a function with some attributes recorded in llvm.module.flags applied.
StringRef - Represent a constant reference to a string, i.e.
void setCallingConv(CallingConv::ID CC)
static BasicBlock * Create(LLVMContext &Context, const Twine &Name="", Function *Parent=nullptr, BasicBlock *InsertBefore=nullptr)
Creates a new BasicBlock.
@ AMDGPU_KERNEL
Calling convention for AMDGPU code object kernels.
static ReturnInst * Create(LLVMContext &C, Value *retVal=nullptr, Instruction *InsertBefore=nullptr)
@ ExternalLinkage
Externally visible function.
static Type * getVoidTy(LLVMContext &C)
unsigned getNumOperands() const
void addFnAttr(Attribute::AttrKind Kind)
Add function attributes to this function.
A handy container for a FunctionType+Callee-pointer pair, which can be passed around as a single enti...
const Instruction * getTerminator() const LLVM_READONLY
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
Type * getVoidTy()
Fetch the type representing void.
LLVM Value Representation.
CallInst * CreateCall(FunctionType *FTy, Value *Callee, ArrayRef< Value * > Args=None, const Twine &Name="", MDNode *FPMathTag=nullptr)