1 //===-- ModuleUtils.h - Functions to manipulate Modules ---------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 // 10 // This family of functions perform manipulations on Modules. 11 // 12 //===----------------------------------------------------------------------===// 13 14 #ifndef LLVM_TRANSFORMS_UTILS_MODULEUTILS_H 15 #define LLVM_TRANSFORMS_UTILS_MODULEUTILS_H 16 17 namespace llvm { 18 19 class Module; 20 class Function; 21 class GlobalValue; 22 class GlobalVariable; 23 class Constant; 24 template <class PtrType> class SmallPtrSetImpl; 25 26 /// Append F to the list of global ctors of module M with the given Priority. 27 /// This wraps the function in the appropriate structure and stores it along 28 /// side other global constructors. For details see 29 /// http://llvm.org/docs/LangRef.html#intg_global_ctors 30 void appendToGlobalCtors(Module &M, Function *F, int Priority); 31 32 /// Same as appendToGlobalCtors(), but for global dtors. 33 void appendToGlobalDtors(Module &M, Function *F, int Priority); 34 35 /// \brief Given "llvm.used" or "llvm.compiler.used" as a global name, collect 36 /// the initializer elements of that global in Set and return the global itself. 37 GlobalVariable *collectUsedGlobalVariables(Module &M, 38 SmallPtrSetImpl<GlobalValue *> &Set, 39 bool CompilerUsed); 40 41 // Validate the result of Module::getOrInsertFunction called for an interface 42 // function of given sanitizer. If the instrumented module defines a function 43 // with the same name, their prototypes must match, otherwise 44 // getOrInsertFunction returns a bitcast. 45 Function *checkSanitizerInterfaceFunction(Constant *FuncOrBitcast); 46 } // End llvm namespace 47 48 #endif // LLVM_TRANSFORMS_UTILS_MODULEUTILS_H 49