Lines Matching refs:M
29 static void appendToGlobalArray(StringRef ArrayName, Module &M, Function *F, in appendToGlobalArray() argument
31 IRBuilder<> IRB(M.getContext()); in appendToGlobalArray()
38 if (GlobalVariable *GVCtor = M.getNamedGlobal(ArrayName)) { in appendToGlobalArray()
70 (void)new GlobalVariable(M, NewInit->getType(), false, in appendToGlobalArray()
74 void llvm::appendToGlobalCtors(Module &M, Function *F, int Priority, Constant *Data) { in appendToGlobalCtors() argument
75 appendToGlobalArray("llvm.global_ctors", M, F, Priority, Data); in appendToGlobalCtors()
78 void llvm::appendToGlobalDtors(Module &M, Function *F, int Priority, Constant *Data) { in appendToGlobalDtors() argument
79 appendToGlobalArray("llvm.global_dtors", M, F, Priority, Data); in appendToGlobalDtors()
92 static void appendToUsedList(Module &M, StringRef Name, ArrayRef<GlobalValue *> Values) { in appendToUsedList() argument
93 GlobalVariable *GV = M.getGlobalVariable(Name); in appendToUsedList()
100 Type *ArrayEltTy = llvm::PointerType::getUnqual(M.getContext()); in appendToUsedList()
108 GV = new llvm::GlobalVariable(M, ATy, false, GlobalValue::AppendingLinkage, in appendToUsedList()
114 void llvm::appendToUsed(Module &M, ArrayRef<GlobalValue *> Values) { in appendToUsed() argument
115 appendToUsedList(M, "llvm.used", Values); in appendToUsed()
118 void llvm::appendToCompilerUsed(Module &M, ArrayRef<GlobalValue *> Values) { in appendToCompilerUsed() argument
119 appendToUsedList(M, "llvm.compiler.used", Values); in appendToCompilerUsed()
122 static void removeFromUsedList(Module &M, StringRef Name, in removeFromUsedList() argument
124 GlobalVariable *GV = M.getNamedGlobal(Name); in removeFromUsedList()
142 new GlobalVariable(M, ATy, false, GlobalValue::AppendingLinkage, in removeFromUsedList()
152 void llvm::removeFromUsedLists(Module &M, in removeFromUsedLists() argument
154 removeFromUsedList(M, "llvm.used", ShouldRemove); in removeFromUsedLists()
155 removeFromUsedList(M, "llvm.compiler.used", ShouldRemove); in removeFromUsedLists()
158 void llvm::setKCFIType(Module &M, Function &F, StringRef MangledType) { in setKCFIType() argument
159 if (!M.getModuleFlag("kcfi")) in setKCFIType()
162 LLVMContext &Ctx = M.getContext(); in setKCFIType()
165 if (M.getModuleFlag("cfi-normalize-integers")) in setKCFIType()
174 M.getModuleFlag("kcfi-offset"))) { in setKCFIType()
180 FunctionCallee llvm::declareSanitizerInitFunction(Module &M, StringRef InitName, in declareSanitizerInitFunction() argument
184 auto *VoidTy = Type::getVoidTy(M.getContext()); in declareSanitizerInitFunction()
186 auto FnCallee = M.getOrInsertFunction(InitName, FnTy); in declareSanitizerInitFunction()
193 Function *llvm::createSanitizerCtor(Module &M, StringRef CtorName) { in createSanitizerCtor() argument
195 FunctionType::get(Type::getVoidTy(M.getContext()), false), in createSanitizerCtor()
196 GlobalValue::InternalLinkage, M.getDataLayout().getProgramAddressSpace(), in createSanitizerCtor()
197 CtorName, &M); in createSanitizerCtor()
199 setKCFIType(M, *Ctor, "_ZTSFvvE"); // void (*)(void) in createSanitizerCtor()
200 BasicBlock *CtorBB = BasicBlock::Create(M.getContext(), "", Ctor); in createSanitizerCtor()
201 ReturnInst::Create(M.getContext(), CtorBB); in createSanitizerCtor()
203 appendToUsed(M, {Ctor}); in createSanitizerCtor()
208 Module &M, StringRef CtorName, StringRef InitName, in createSanitizerCtorAndInitFunctions() argument
215 declareSanitizerInitFunction(M, InitName, InitArgTypes, Weak); in createSanitizerCtorAndInitFunctions()
216 Function *Ctor = createSanitizerCtor(M, CtorName); in createSanitizerCtorAndInitFunctions()
217 IRBuilder<> IRB(M.getContext()); in createSanitizerCtorAndInitFunctions()
222 auto *EntryBB = BasicBlock::Create(M.getContext(), "entry", Ctor, RetBB); in createSanitizerCtorAndInitFunctions()
224 BasicBlock::Create(M.getContext(), "callfunc", Ctor, RetBB); in createSanitizerCtorAndInitFunctions()
239 FunctionCallee VersionCheckFunction = M.getOrInsertFunction( in createSanitizerCtorAndInitFunctions()
253 Module &M, StringRef CtorName, StringRef InitName, in getOrCreateSanitizerCtorAndInitFunctions() argument
259 if (Function *Ctor = M.getFunction(CtorName)) in getOrCreateSanitizerCtorAndInitFunctions()
263 Ctor->getReturnType() == Type::getVoidTy(M.getContext())) in getOrCreateSanitizerCtorAndInitFunctions()
265 declareSanitizerInitFunction(M, InitName, InitArgTypes, Weak)}; in getOrCreateSanitizerCtorAndInitFunctions()
270 M, CtorName, InitName, InitArgTypes, InitArgs, VersionCheckName, Weak); in getOrCreateSanitizerCtorAndInitFunctions()
303 std::string llvm::getUniqueModuleId(Module *M) { in getUniqueModuleId() argument
315 for (auto &F : *M) in getUniqueModuleId()
317 for (auto &GV : M->globals()) in getUniqueModuleId()
319 for (auto &GA : M->aliases()) in getUniqueModuleId()
321 for (auto &IF : M->ifuncs()) in getUniqueModuleId()
335 void llvm::embedBufferInModule(Module &M, MemoryBufferRef Buf, in embedBufferInModule() argument
339 M.getContext(), ArrayRef(Buf.getBufferStart(), Buf.getBufferSize())); in embedBufferInModule()
341 M, ModuleConstant->getType(), true, GlobalValue::PrivateLinkage, in embedBufferInModule()
346 LLVMContext &Ctx = M.getContext(); in embedBufferInModule()
347 NamedMDNode *MD = M.getOrInsertNamedMetadata("llvm.embedded.objects"); in embedBufferInModule()
354 appendToCompilerUsed(M, GV); in embedBufferInModule()
358 Module &M, ArrayRef<GlobalIFunc *> FilteredIFuncsToLower) { in lowerGlobalIFuncUsersAsGlobalCtor() argument
362 for (GlobalIFunc &GI : M.ifuncs()) in lowerGlobalIFuncUsersAsGlobalCtor()
368 LLVMContext &Ctx = M.getContext(); in lowerGlobalIFuncUsersAsGlobalCtor()
369 const DataLayout &DL = M.getDataLayout(); in lowerGlobalIFuncUsersAsGlobalCtor()
382 M, FuncPtrTableTy, false, GlobalValue::InternalLinkage, in lowerGlobalIFuncUsersAsGlobalCtor()
390 DL.getProgramAddressSpace(), "", &M); in lowerGlobalIFuncUsersAsGlobalCtor()
447 appendToGlobalCtors(M, NewCtor, Priority, in lowerGlobalIFuncUsersAsGlobalCtor()