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