Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/include/llvm/IR/GlobalIFunc.h
Line
Count
Source (jump to first uncovered line)
1
//===-------- llvm/GlobalIFunc.h - GlobalIFunc class ------------*- C++ -*-===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
///
9
/// \brief
10
/// This file contains the declaration of the GlobalIFunc class, which
11
/// represents a single indirect function in the IR. Indirect function uses
12
/// ELF symbol type extension to mark that the address of a declaration should
13
/// be resolved at runtime by calling a resolver function.
14
///
15
//===----------------------------------------------------------------------===//
16
17
#ifndef LLVM_IR_GLOBALIFUNC_H
18
#define LLVM_IR_GLOBALIFUNC_H
19
20
#include "llvm/ADT/ilist_node.h"
21
#include "llvm/IR/GlobalIndirectSymbol.h"
22
#include "llvm/IR/Value.h"
23
24
namespace llvm {
25
26
class Twine;
27
class Module;
28
29
// Traits class for using GlobalIFunc in symbol table in Module.
30
template <typename ValueSubClass> class SymbolTableListTraits;
31
32
class GlobalIFunc final : public GlobalIndirectSymbol,
33
                          public ilist_node<GlobalIFunc> {
34
  friend class SymbolTableListTraits<GlobalIFunc>;
35
36
  GlobalIFunc(Type *Ty, unsigned AddressSpace, LinkageTypes Linkage,
37
              const Twine &Name, Constant *Resolver, Module *Parent);
38
39
public:
40
  GlobalIFunc(const GlobalIFunc &) = delete;
41
  GlobalIFunc &operator=(const GlobalIFunc &) = delete;
42
43
  /// If a parent module is specified, the ifunc is automatically inserted into
44
  /// the end of the specified module's ifunc list.
45
  static GlobalIFunc *create(Type *Ty, unsigned AddressSpace,
46
                             LinkageTypes Linkage, const Twine &Name,
47
                             Constant *Resolver, Module *Parent);
48
49
0
  void copyAttributesFrom(const GlobalIFunc *Src) {
50
0
    GlobalValue::copyAttributesFrom(Src);
51
0
  }
52
53
  /// This method unlinks 'this' from the containing module, but does not
54
  /// delete it.
55
  void removeFromParent();
56
57
  /// This method unlinks 'this' from the containing module and deletes it.
58
  void eraseFromParent();
59
60
  /// These methods retrieve and set ifunc resolver function.
61
2
  void setResolver(Constant *Resolver) {
62
2
    setIndirectSymbol(Resolver);
63
2
  }
64
212
  const Constant *getResolver() const {
65
212
    return getIndirectSymbol();
66
212
  }
67
13
  Constant *getResolver() {
68
13
    return getIndirectSymbol();
69
13
  }
70
71
  // Methods for support type inquiry through isa, cast, and dyn_cast:
72
6.95M
  static bool classof(const Value *V) {
73
6.95M
    return V->getValueID() == Value::GlobalIFuncVal;
74
6.95M
  }
75
};
76
77
} // end namespace llvm
78
79
#endif // LLVM_IR_GLOBALIFUNC_H