26#define DEBUG_TYPE "ppc-prep-ifunc-aix"
31class PPCPrepareIFuncsOnAIX :
public ModulePass {
37 bool runOnModule(
Module &M)
override;
39 StringRef getPassName()
const override {
40 return "PPC Prepare for AIX IFunc lowering";
45char PPCPrepareIFuncsOnAIX::ID = 0;
48 "PPC Prepare for AIX IFunc lowering",
false,
false)
51 return new PPCPrepareIFuncsOnAIX();
66bool PPCPrepareIFuncsOnAIX::runOnModule(
Module &M) {
67 if (
M.ifuncs().empty())
70 const DataLayout &
DL =
M.getDataLayout();
71 LLVMContext &Ctx =
M.getContext();
72 auto *PtrTy = PointerType::getUnqual(Ctx);
73 StringRef IFuncUpdatePrefix =
"__update_";
74 StringRef IFuncUpdateSectionName =
"__ifunc_sec";
77 StringRef IFuncConstructorName =
"__init_ifuncs";
78 auto *IFuncConstructorFnType =
79 FunctionType::get(Type::getVoidTy(Ctx), {},
false);
81 M.getOrInsertFunction(IFuncConstructorName, IFuncConstructorFnType)
84 for (GlobalIFunc &IFunc :
M.ifuncs()) {
86 LLVM_DEBUG(
dbgs() <<
"expanding ifunc " << IFunc.getName() <<
"\n");
89 std::string
Name = (Twine(IFuncUpdatePrefix) + IFunc.getName()).str();
90 auto *GV =
new GlobalVariable(M, IFuncPairType,
false,
92 GV->setAlignment(
DL.getPointerPrefAlignment());
93 GV->setSection(IFuncUpdateSectionName);
98 Constant *InitVals[] = {&IFunc, IFunc.getResolver()};
102 IFunc.setMetadata(LLVMContext::MD_implicit_ref,
109 LLVMContext::MD_implicit_ref,
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Module.h This file contains the declarations for the Module class.
Machine Check Debug Module
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
Target-Independent Code Generator Pass Configuration Options pass.
static LLVM_ABI Constant * get(StructType *T, ArrayRef< Constant * > V)
@ PrivateLinkage
Like Internal, but omit from symbol table.
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
A Module instance is used to store all the information related to an LLVM module.
static LLVM_ABI StructType * get(LLVMContext &Context, ArrayRef< Type * > Elements, bool isPacked=false)
This static method is the primary way to create a literal StructType.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
This is an optimization pass for GlobalISel generic memory operations.
ModulePass * createPPCPrepareIFuncsOnAIXPass()
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.