2
0

ModuleUtils.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. #ifndef LLVM_TRANSFORMS_UTILS_MODULEUTILS_H
  14. #define LLVM_TRANSFORMS_UTILS_MODULEUTILS_H
  15. #include "llvm/ADT/ArrayRef.h"
  16. #include <utility> // for std::pair
  17. namespace llvm {
  18. class Module;
  19. class Function;
  20. class GlobalValue;
  21. class GlobalVariable;
  22. class Constant;
  23. class StringRef;
  24. class Value;
  25. class Type;
  26. template <class PtrType> class SmallPtrSetImpl;
  27. /// Append F to the list of global ctors of module M with the given Priority.
  28. /// This wraps the function in the appropriate structure and stores it along
  29. /// side other global constructors. For details see
  30. /// http://llvm.org/docs/LangRef.html#intg_global_ctors
  31. void appendToGlobalCtors(Module &M, Function *F, int Priority);
  32. /// Same as appendToGlobalCtors(), but for global dtors.
  33. void appendToGlobalDtors(Module &M, Function *F, int Priority);
  34. /// \brief Given "llvm.used" or "llvm.compiler.used" as a global name, collect
  35. /// the initializer elements of that global in Set and return the global itself.
  36. GlobalVariable *collectUsedGlobalVariables(Module &M,
  37. SmallPtrSetImpl<GlobalValue *> &Set,
  38. bool CompilerUsed);
  39. // Validate the result of Module::getOrInsertFunction called for an interface
  40. // function of given sanitizer. If the instrumented module defines a function
  41. // with the same name, their prototypes must match, otherwise
  42. // getOrInsertFunction returns a bitcast.
  43. Function *checkSanitizerInterfaceFunction(Constant *FuncOrBitcast);
  44. /// \brief Creates sanitizer constructor function, and calls sanitizer's init
  45. /// function from it.
  46. /// \return Returns pair of pointers to constructor, and init functions
  47. /// respectively.
  48. std::pair<Function *, Function *> createSanitizerCtorAndInitFunctions(
  49. Module &M, StringRef CtorName, StringRef InitName,
  50. ArrayRef<Type *> InitArgTypes, ArrayRef<Value *> InitArgs);
  51. } // End llvm namespace
  52. #endif // LLVM_TRANSFORMS_UTILS_MODULEUTILS_H