23#define DEBUG_TYPE "ppc-prep-ifunc-aix"
28class PPCPrepareIFuncsOnAIX :
public ModulePass {
34 bool runOnModule(
Module &M)
override;
36 StringRef getPassName()
const override {
37 return "PPC Prepare for AIX IFunc lowering";
42char PPCPrepareIFuncsOnAIX::ID = 0;
45 "PPC Prepare for AIX IFunc lowering",
false,
false)
48 return new PPCPrepareIFuncsOnAIX();
63bool PPCPrepareIFuncsOnAIX::runOnModule(
Module &M) {
64 if (
M.ifuncs().empty())
67 const DataLayout &
DL =
M.getDataLayout();
68 LLVMContext &Ctx =
M.getContext();
69 auto *PtrTy = PointerType::getUnqual(Ctx);
70 StringRef IFuncUpdatePrefix =
"__update_";
71 StringRef IFuncUpdateSectionName =
"__ifunc_sec";
74 StringRef IFuncConstructorName =
"__init_ifuncs";
75 auto *IFuncConstructorFnType =
76 FunctionType::get(Type::getVoidTy(Ctx), {},
false);
78 M.getOrInsertFunction(IFuncConstructorName, IFuncConstructorFnType)
81 for (GlobalIFunc &IFunc :
M.ifuncs()) {
83 LLVM_DEBUG(
dbgs() <<
"expanding ifunc " << IFunc.getName() <<
"\n");
86 std::string
Name = (Twine(IFuncUpdatePrefix) + IFunc.getName()).str();
87 auto *GV =
new GlobalVariable(M, IFuncPairType,
false,
89 GV->setAlignment(
DL.getPointerPrefAlignment());
90 GV->setSection(IFuncUpdateSectionName);
95 Constant *InitVals[] = {&IFunc, IFunc.getResolver()};
99 IFunc.setMetadata(LLVMContext::MD_implicit_ref,
106 LLVMContext::MD_implicit_ref,
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Module.h This file contains the declarations for the Module class.
#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)
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.
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.