Lines Matching refs:M

28 static void appendToGlobalArray(StringRef ArrayName, Module &M, Function *F,  in appendToGlobalArray()  argument
30 IRBuilder<> IRB(M.getContext()); in appendToGlobalArray()
37 if (GlobalVariable *GVCtor = M.getNamedGlobal(ArrayName)) { in appendToGlobalArray()
69 (void)new GlobalVariable(M, NewInit->getType(), false, in appendToGlobalArray()
73 void llvm::appendToGlobalCtors(Module &M, Function *F, int Priority, Constant *Data) { in appendToGlobalCtors() argument
74 appendToGlobalArray("llvm.global_ctors", M, F, Priority, Data); in appendToGlobalCtors()
77 void llvm::appendToGlobalDtors(Module &M, Function *F, int Priority, Constant *Data) { in appendToGlobalDtors() argument
78 appendToGlobalArray("llvm.global_dtors", M, F, Priority, Data); in appendToGlobalDtors()
91 static void appendToUsedList(Module &M, StringRef Name, ArrayRef<GlobalValue *> Values) { in appendToUsedList() argument
92 GlobalVariable *GV = M.getGlobalVariable(Name); in appendToUsedList()
99 Type *ArrayEltTy = llvm::PointerType::getUnqual(M.getContext()); in appendToUsedList()
107 GV = new llvm::GlobalVariable(M, ATy, false, GlobalValue::AppendingLinkage, in appendToUsedList()
113 void llvm::appendToUsed(Module &M, ArrayRef<GlobalValue *> Values) { in appendToUsed() argument
114 appendToUsedList(M, "llvm.used", Values); in appendToUsed()
117 void llvm::appendToCompilerUsed(Module &M, ArrayRef<GlobalValue *> Values) { in appendToCompilerUsed() argument
118 appendToUsedList(M, "llvm.compiler.used", Values); in appendToCompilerUsed()
121 static void removeFromUsedList(Module &M, StringRef Name, in removeFromUsedList() argument
123 GlobalVariable *GV = M.getNamedGlobal(Name); in removeFromUsedList()
141 new GlobalVariable(M, ATy, false, GlobalValue::AppendingLinkage, in removeFromUsedList()
151 void llvm::removeFromUsedLists(Module &M, in removeFromUsedLists() argument
153 removeFromUsedList(M, "llvm.used", ShouldRemove); in removeFromUsedLists()
154 removeFromUsedList(M, "llvm.compiler.used", ShouldRemove); in removeFromUsedLists()
157 void llvm::setKCFIType(Module &M, Function &F, StringRef MangledType) { in setKCFIType() argument
158 if (!M.getModuleFlag("kcfi")) in setKCFIType()
161 LLVMContext &Ctx = M.getContext(); in setKCFIType()
171 M.getModuleFlag("kcfi-offset"))) { in setKCFIType()
177 FunctionCallee llvm::declareSanitizerInitFunction(Module &M, StringRef InitName, in declareSanitizerInitFunction() argument
181 auto *VoidTy = Type::getVoidTy(M.getContext()); in declareSanitizerInitFunction()
183 auto FnCallee = M.getOrInsertFunction(InitName, FnTy); in declareSanitizerInitFunction()
190 Function *llvm::createSanitizerCtor(Module &M, StringRef CtorName) { in createSanitizerCtor() argument
192 FunctionType::get(Type::getVoidTy(M.getContext()), false), in createSanitizerCtor()
193 GlobalValue::InternalLinkage, M.getDataLayout().getProgramAddressSpace(), in createSanitizerCtor()
194 CtorName, &M); in createSanitizerCtor()
196 setKCFIType(M, *Ctor, "_ZTSFvvE"); // void (*)(void) in createSanitizerCtor()
197 BasicBlock *CtorBB = BasicBlock::Create(M.getContext(), "", Ctor); in createSanitizerCtor()
198 ReturnInst::Create(M.getContext(), CtorBB); in createSanitizerCtor()
200 appendToUsed(M, {Ctor}); in createSanitizerCtor()
205 Module &M, StringRef CtorName, StringRef InitName, in createSanitizerCtorAndInitFunctions() argument
212 declareSanitizerInitFunction(M, InitName, InitArgTypes, Weak); in createSanitizerCtorAndInitFunctions()
213 Function *Ctor = createSanitizerCtor(M, CtorName); in createSanitizerCtorAndInitFunctions()
214 IRBuilder<> IRB(M.getContext()); in createSanitizerCtorAndInitFunctions()
219 auto *EntryBB = BasicBlock::Create(M.getContext(), "entry", Ctor, RetBB); in createSanitizerCtorAndInitFunctions()
221 BasicBlock::Create(M.getContext(), "callfunc", Ctor, RetBB); in createSanitizerCtorAndInitFunctions()
236 FunctionCallee VersionCheckFunction = M.getOrInsertFunction( in createSanitizerCtorAndInitFunctions()
250 Module &M, StringRef CtorName, StringRef InitName, in getOrCreateSanitizerCtorAndInitFunctions() argument
256 if (Function *Ctor = M.getFunction(CtorName)) in getOrCreateSanitizerCtorAndInitFunctions()
260 Ctor->getReturnType() == Type::getVoidTy(M.getContext())) in getOrCreateSanitizerCtorAndInitFunctions()
262 declareSanitizerInitFunction(M, InitName, InitArgTypes, Weak)}; in getOrCreateSanitizerCtorAndInitFunctions()
267 M, CtorName, InitName, InitArgTypes, InitArgs, VersionCheckName, Weak); in getOrCreateSanitizerCtorAndInitFunctions()
300 std::string llvm::getUniqueModuleId(Module *M) { in getUniqueModuleId() argument
312 for (auto &F : *M) in getUniqueModuleId()
314 for (auto &GV : M->globals()) in getUniqueModuleId()
316 for (auto &GA : M->aliases()) in getUniqueModuleId()
318 for (auto &IF : M->ifuncs()) in getUniqueModuleId()
332 void llvm::embedBufferInModule(Module &M, MemoryBufferRef Buf, in embedBufferInModule() argument
336 M.getContext(), ArrayRef(Buf.getBufferStart(), Buf.getBufferSize())); in embedBufferInModule()
338 M, ModuleConstant->getType(), true, GlobalValue::PrivateLinkage, in embedBufferInModule()
343 LLVMContext &Ctx = M.getContext(); in embedBufferInModule()
344 NamedMDNode *MD = M.getOrInsertNamedMetadata("llvm.embedded.objects"); in embedBufferInModule()
351 appendToCompilerUsed(M, GV); in embedBufferInModule()
355 Module &M, ArrayRef<GlobalIFunc *> FilteredIFuncsToLower) { in lowerGlobalIFuncUsersAsGlobalCtor() argument
359 for (GlobalIFunc &GI : M.ifuncs()) in lowerGlobalIFuncUsersAsGlobalCtor()
365 LLVMContext &Ctx = M.getContext(); in lowerGlobalIFuncUsersAsGlobalCtor()
366 const DataLayout &DL = M.getDataLayout(); in lowerGlobalIFuncUsersAsGlobalCtor()
379 M, FuncPtrTableTy, false, GlobalValue::InternalLinkage, in lowerGlobalIFuncUsersAsGlobalCtor()
387 DL.getProgramAddressSpace(), "", &M); in lowerGlobalIFuncUsersAsGlobalCtor()
444 appendToGlobalCtors(M, NewCtor, Priority, in lowerGlobalIFuncUsersAsGlobalCtor()